Skip to content

feat: content-based comment anchoring for carry-forward positioning#296

Merged
tomasz-tomczyk merged 4 commits intomainfrom
carry-forward-comment-positioning
Apr 17, 2026
Merged

feat: content-based comment anchoring for carry-forward positioning#296
tomasz-tomczyk merged 4 commits intomainfrom
carry-forward-comment-positioning

Conversation

@tomasz-tomczyk
Copy link
Copy Markdown
Owner

Summary

  • Store an anchor field (full text of commented lines) on every line comment at creation time
  • During carry-forward between review rounds, verify the LCS-remapped position still matches the anchor text — if not, search the file for the anchor and remap there; if gone entirely, mark the comment as drifted
  • Fix git-mode carry-forward which previously had zero remapping for markdown files (only carryForwardAllComments was called)
  • Frontend shows "Drifted" badge + collapsible "Original content" panel on drifted comments
  • All agent integration docs updated to document anchor and drifted fields

Test plan

  • 15 new unit tests for anchor population, carry-forward verification, drifted detection, backwards compatibility
  • make test-diff now includes carry-forward test scenarios on ports 3003 (file-mode) and 3004 (git-mode) with 5 comments covering: simple shifts, removed content, rewritten content
  • End-to-end smoke test: C1/C2/C5 shift correctly, C3/C4 marked drifted
  • Go expert review: fixed HIGH (anchorLen from anchor text, not LCS span), MEDIUM (merged lock blocks)
  • Frontend expert review: fixed MEDIUM (aria-expanded/aria-controls on toggle)
  • CI

🤖 Generated with Claude Code

tomasz-tomczyk and others added 2 commits April 17, 2026 10:59
Store an anchor (full text of commented lines) on every line comment at
creation time. During carry-forward between review rounds, verify the
LCS-remapped position still matches the anchor text. If it doesn't,
search the new file for the anchor and remap there. If the anchor text
is gone entirely, mark the comment as drifted.

Backend:
- Add Anchor and Drifted fields to Comment struct
- Auto-populate anchor in AddComment and crit comment CLI
- Verify + correct LCS remapping using anchor text in carryForwardComments
- Fix git-mode to snapshot PreviousContent and call carryForwardComments
  (was previously skipped — comments stayed at original line numbers)

Frontend:
- Show "Drifted" badge on comments where anchor text wasn't found
- Collapsible "Original content" section showing the anchor text

Integration docs updated for all agents (anchor field, drifted flag).
Test infrastructure: carry-forward test scenarios in make test-diff.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace native <details>/<summary> with a custom toggle button:
- Rotating chevron with CSS transition
- Left-border accent panel using yellow/warning color family
- Proper focus-visible keyboard accessibility
- Panel hidden when comment card is collapsed
- New --drifted-bg and --drifted-border CSS vars in all 4 theme blocks

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tomasz-tomczyk tomasz-tomczyk force-pushed the carry-forward-comment-positioning branch from 400f106 to af6a379 Compare April 17, 2026 10:45
The anchorLen in verifyAndCorrectPosition was computed from
lcsEnd - lcsStart + 1, which is wrong when LCS maps the start and
end lines farther apart than the original span (e.g. lines inserted
between them). Use len(strings.Split(anchor, "\n")) instead.

Also merge two adjacent lock blocks in handleRoundCompleteGit.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tomasz-tomczyk tomasz-tomczyk force-pushed the carry-forward-comment-positioning branch from af6a379 to 82260d2 Compare April 17, 2026 13:06
New anchor and drifted fields in the review file format.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tomasz-tomczyk tomasz-tomczyk force-pushed the carry-forward-comment-positioning branch from 00a609d to 077a0db Compare April 17, 2026 13:13
@tomasz-tomczyk tomasz-tomczyk merged commit 76c6611 into main Apr 17, 2026
4 checks passed
@tomasz-tomczyk tomasz-tomczyk deleted the carry-forward-comment-positioning branch April 17, 2026 13:22
tomasz-tomczyk pushed a commit that referenced this pull request Apr 29, 2026
Drop the old focus-picker popover (Working tree / Your stack / Other PRs /
Branches) in favour of a narrower, more focused UI inspired by stacked-PR
review tools that only handle in-stack navigation.

Frontend
- New stack breadcrumb in the header: main > #294 > #295 (reviewing) >
  #296, rendered inline (not a popover). Default-branch click flips
  diff_scope to full_stack on the current focus; other entries swap focus
  via /api/focus. Visibility uses stack.length > 1 (not is_stacked) so
  local-only stacks and Sapling-style commit chains also get the
  breadcrumb. Long stacks collapse the middle into an ellipsis.
- New Working tree pill, visible whenever focus is range in git mode.
- Layer/full-stack toggle now appears whenever default_sha is resolved,
  not only for is_stacked focus.
- Other PRs / Remote branches sections deleted from the frontend; backend
  /api/picker still returns them but the frontend stops consuming them.
- focus-changed SSE handler fixed to parse the wrapper.content payload
  correctly (the old handler relied on page reloads in tests to mask this).

Backend (picker.go)
- detectStack adds tier-3 fallback for naked-commit ancestors on the topic
  chain (commits reachable from HEAD but not the default branch). Uses
  first-line commit subject as the label so Sapling-style git stacks of
  unbranched commits surface in the picker.
- Topic-chain filter prevents long-lived feature branches from drowning
  the breadcrumb in default-branch ancestors.

CLI
- Help text now lists --pr <num|url> and --range <baseSHA>..<headSHA> as
  the entry points into range mode.

Tests
- Rewrote focus-picker.rangemode.spec.ts and focus-picker-wt-entry for
  the breadcrumb. Added breadcrumb-current-marker,
  breadcrumb-default-branch, breadcrumb-ellipsis, breadcrumb-local-stack,
  breadcrumb-no-pr specs.
- Updated focus-switch.rangemode for the working-tree pill.
- loading.filemode + nogit.nogit assert the breadcrumb and pill stay
  hidden in non-VCS modes.
- range-loading header-label test now checks the breadcrumb reviewing
  marker instead of the removed #focusPickerLabel.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant