Skip to content

fix(comments): associate comments with their commit when reviewing per-commit#442

Merged
agavra merged 1 commit into
agavra:mainfrom
thiblahute:per_commit_comments
Jul 6, 2026
Merged

fix(comments): associate comments with their commit when reviewing per-commit#442
agavra merged 1 commit into
agavra:mainfrom
thiblahute:per_commit_comments

Conversation

@thiblahute

Copy link
Copy Markdown
Contributor

Comments were keyed only by (path, line), so when reviewing commit-by-commit via the inline selector, a comment made on commit A's line 42 also showed on commit B's line 42 — mixing up the diff view, comment navigator, and submit preflight.

  • Add commit_id: Option<String> to Comment (serde #[default], so legacy session JSON rehydrates as None = always visible), stamped when the inline selector shows exactly one commit.
  • Visibility rule (comment_visible_with): visible if commit_id is None or its SHA is in the selected commit set. Applied in rebuild_annotations, both diff renderers, file_render_body_height, the comment navigator, and the submit preflight; hot paths compute the commit set once and pass it down.
  • find_comment_at_cursor guards against stale annotations during an async commit-selection reload, so delete/edit no-op on hidden comments.
  • Also fixes a latent bug: delete_comment_at_cursor and enter_edit_mode re-derived the comment index by counting side-matching comments, but AnnotatedLine::LineComment.comment_idx is the absolute index into the stored Vec. Both now use the absolute index directly.

…r-commit

Comments had no commit association — FileReview.line_comments was keyed
only by (path, line). When reviewing commit-by-commit via the inline
selector, a comment made on commit A's line 42 showed on commit B's
line 42 even when the content was entirely different, causing a total
mixup across the diff view, comment navigator, and submit preflight.

Add a commit_id: Option<String> field to Comment (serde #[default],
so legacy session JSON rehydrates as None = always visible). The field
records the SHA of the commit a comment was made against, stamped only
when the inline selector shows exactly one commit.

Visibility rule (App::comment_visible): a comment is visible if
commit_id is None (legacy / review-level / full-range) OR its SHA is
in the currently-selected commit set. Filtering is applied in every
read path: rebuild_annotations, both diff renderers, the comment
navigator (via filtered annotations), and the submit preflight.

Also fixes a latent bug: delete_comment_at_cursor and enter_edit_mode
re-derived the comment index by counting side-matching comments, but
AnnotatedLine::LineComment.comment_idx is the absolute index into the
stored Vec. Now both use the absolute index directly.
@agavra

agavra commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Thanks! This makes sense to me.

@agavra
agavra merged commit f8df88c into agavra:main Jul 6, 2026
4 checks passed
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.

2 participants