Skip to content

fix(desktop): diff viewer — hunk revert path + comment-send data loss#358

Merged
YingxuanHu merged 2 commits into
mainfrom
fix/diff-review
Jul 10, 2026
Merged

fix(desktop): diff viewer — hunk revert path + comment-send data loss#358
YingxuanHu merged 2 commits into
mainfrom
fix/diff-review

Conversation

@YingxuanHu

Copy link
Copy Markdown
Contributor

Two diff-viewer fixes (one branch per category).

Tested: ESLint + ui tsc --noEmit pass; diffHunkRevert unit test 3/3; runtime /api/fs/write verified (relative → 400, absolute → 200 + file written).

Closes #347
Closes #349

Alvin Hu added 2 commits July 9, 2026 20:19
Per-hunk revert wrote a git-relative path to /api/fs/write, which resolves relative paths against the server process cwd (not the project dir), so the write landed outside the workspace and 400'd — revert silently failed. Send an absolute path via toViewAbsolutePath(), matching the editor's save action.

Closes #347
Send-to-chat consumed (cleared) the comment drafts before awaiting sendMessage, so any failure permanently lost the user's comments. Read without consuming, clear only on success, and guard against a double-send.

Closes #349
Copilot AI review requested due to automatic review settings July 10, 2026 00:21
@YingxuanHu
YingxuanHu merged commit f00a2a2 into main Jul 10, 2026
@YingxuanHu
YingxuanHu deleted the fix/diff-review branch July 10, 2026 00:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes two desktop diff-viewer regressions: (1) per-hunk revert failing due to sending a git-relative path to the fs/write endpoint, and (2) inline diff comment drafts being lost when “Send to chat” fails.

Changes:

  • Write reverted hunks back using an absolute path via toViewAbsolutePath(directory, filePath) to satisfy /api/fs/write workspace validation.
  • Prevent comment draft data loss by only clearing drafts after a successful send, and add an in-flight guard to prevent double-sends.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
desktop/packages/ui/src/components/views/useDiffHunkRevert.ts Sends an absolute filesystem path for per-hunk revert writes to avoid “outside active workspace” failures.
desktop/packages/ui/src/components/views/DiffCommentSummaryBar.tsx Defers clearing inline comment drafts until send succeeds and guards against double-click re-sends.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +39 to +42
const pending = useInlineCommentDraftStore.getState().drafts[sessionKey] ?? EMPTY_DRAFTS
if (pending.length === 0) return

const formatted = formatInlineCommentDrafts(consumed)
const formatted = formatInlineCommentDrafts(pending)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Send to chat" discards inline diff comments when the send fails Reverting a single diff hunk always fails with "Path is outside of active workspace"

2 participants