fix(desktop): diff viewer — hunk revert path + comment-send data loss#358
Merged
Conversation
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
There was a problem hiding this comment.
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/writeworkspace 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two diff-viewer fixes (one branch per category).
/api/fs/write, which resolves against the server process cwd (not the project dir), so it 400'd "Path is outside of active workspace" and revert silently failed. Now sends an absolute path viatoViewAbsolutePath(), matching the file editor's save.Tested: ESLint + ui
tsc --noEmitpass;diffHunkRevertunit test 3/3; runtime/api/fs/writeverified (relative → 400, absolute → 200 + file written).Closes #347
Closes #349