Skip to content

feat: bidirectional scroll navigation between annotations and highlights#253

Merged
backnotprop merged 2 commits intobacknotprop:mainfrom
grubmanItay:feature/bidirectional-annotation-scroll
Mar 9, 2026
Merged

feat: bidirectional scroll navigation between annotations and highlights#253
backnotprop merged 2 commits intobacknotprop:mainfrom
grubmanItay:feature/bidirectional-annotation-scroll

Conversation

@grubmanItay
Copy link
Contributor

@grubmanItay grubmanItay commented Mar 9, 2026

Summary

  • Clicking an annotation card in the right panel scrolls the plan content to the corresponding highlighted text and applies a distinctive "focused" highlight color (cyan glow)
  • Clicking highlighted text in the plan scrolls the annotation panel to bring the corresponding card into view
  • New .annotation-highlight.focused CSS class with dark and light mode support
  • Scroll targets are centered in the viewport for easy visibility
  • Creating a new annotation does not trigger scroll/focus (user is already looking at it)

Motivation

When reviewing a long, detailed plan with many annotations — especially after importing a teammate's review — it's easy to lose track of which annotation card corresponds to which highlighted line in the content. The existing behavior only applies a subtle selected border to the card when a highlight is clicked, but doesn't scroll either panel, forcing the user to manually hunt for the matching element.

How it works

  1. Card → Highlight: Viewer.tsx watches selectedAnnotationId and uses highlighter.getDoms() (for web-highlighter annotations) or querySelector('[data-bind-id]') (for shared/imported annotations) to find the
    corresponding <mark> elements. It applies a .focused class (bright cyan glow) and calls scrollIntoView({ behavior: 'smooth', block: 'center' }).
  2. Highlight → Card: AnnotationPanel.tsx watches selectedId and scrolls the matching [data-annotation-id] card into view within the panel's scroll container using block: 'center'.
  3. Skip on creation: A justCreatedIdRef tracks newly created annotation IDs so the scroll+focus effect is skipped when the user just added an annotation (they're already looking at it).
  4. Edge cases: Global comments (no highlight in content) gracefully no-op. Multi-node selections focus all marks and scroll to the first. Already-visible elements scroll smoothly to the center.

Test plan

  • Add several annotations spread across a long plan
  • Click an annotation card → content scrolls to highlight with cyan glow, centered in viewport
  • Click highlighted text → panel scrolls to show the corresponding card with selected border, centered
  • Add a new annotation → no cyan focus or scroll triggered (user stays in place)
  • Click a global comment card → no scroll in content (expected)
  • Import a teammate's shared review → verify bidirectional navigation works with imported annotations
  • Verify focused highlight color in both dark and light mode
  • Test across Chrome, Firefox, Safari, and Edge

🤖 Generated with Claude Code

grubmanItay and others added 2 commits March 9, 2026 11:45
When reviewing long plans with many annotations, it's hard to visually
connect which annotation card corresponds to which highlighted line.

- Click annotation card → scrolls content to the highlight + applies
  a bright cyan "focused" color for visibility
- Click highlighted text → scrolls the right panel to bring the
  corresponding annotation card into view
- Works with both web-highlighter and manually created (shared/imported)
  annotations
- Handles edge cases: global comments (no highlight), multi-node
  selections, already-visible elements

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Change scrollIntoView block from 'nearest' to 'center' so targets
  appear prominently in the middle of the viewport
- Track just-created annotation IDs to skip scroll+focus effect when
  a new annotation is added (user is already looking at it)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@grubmanItay grubmanItay force-pushed the feature/bidirectional-annotation-scroll branch from 7f88f1d to 6e1b685 Compare March 9, 2026 09:46
@backnotprop
Copy link
Owner

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

@backnotprop backnotprop merged commit 2a46138 into backnotprop:main Mar 9, 2026
@grubmanItay grubmanItay deleted the feature/bidirectional-annotation-scroll branch March 9, 2026 14:05
@backnotprop
Copy link
Owner

This is live in v0.11.4. Thanks @grubmanItay!

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