Conversation
Toggling a Markdown file back to its diff refreshes the repository state to pick up the edits. That refresh replaced the whole review comment list with `getReviewCommentsFromState`, which only projects comments that come from the backend. Working trees have none, so every locally created comment was dropped, including comments on unrelated files. Merge the refreshed comments over the local ones instead, so backend comments still win on matching ids while local comments survive the refresh. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Member
|
Thank you! New release coming in a bit. |
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.
Clicking "View as Diff" on a Markdown file discarded every review comment in the session, including comments on unrelated files.
toggleMarkdownPreviewcallsonRefreshMarkdownwhen leaving preview mode for an editable working-tree section, so Markdown edits are flushed and the repository state is re-read. That refresh inrefreshMarkdownFilethen didsetReviewComments(getReviewCommentsFromState(orderedState)).getReviewCommentsFromStateonly projectsstate.reviewComments, which holds backend comments and is populated for pull request sources. The refresh path only runs forworking-treeandbranch-working-treesources, where that field is always empty, so the call replaced the entire comment list with[].Locally created comments never set
isReadOnlyand live only in React state, so all of them were lost: comment on a few lines of a JS file, toggle a Markdown file to its diff, and the comments are gone.This adds
getRefreshedReviewComments, which merges the refreshed backend comments over the local ones via the existingmergeReviewCommentshelper. Backend comments still win on matching ids, and local comments survive the refresh. The othergetReviewCommentsFromStatecall sites are deliberate full reloads (initial load, source switch, whitespace preference change) and are unchanged.Testing
core/__tests__/review-comments.test.tscovers both directions: local comments (including empty drafts) survive a refresh that returns no backend comments, and read-only comments are replaced by the refreshed state. Both fail against the previous behavior. Also verified by hand in the app on a working tree with a JS and a Markdown file.🤖 Generated with Claude Code