Closed
Conversation
Add annotation support to the plan clean diff view so users can select text in added/removed/modified sections and leave feedback. Annotations carry a diffContext field that flows through export, sharing, and drafts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…bugs Extract ~250 lines of duplicated annotation plumbing from Viewer.tsx and PlanCleanDiffView.tsx into a shared useAnnotationHighlighter hook. Fixes two bugs from the original copy-paste: highlights vanishing on re-render (unstable callback in useEffect deps) and persisted annotations not restoring into DOM (missing findTextInDOM path). Diff annotations are explicitly excluded from text-based restoration to avoid wrong-match binding. Also fixes code-block annotation deletion not re-applying syntax highlighting (data-highlighted attribute and execution order). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Route annotation deletions through diffViewerRef when diff mode is active (fixes stale marks). Filter annotations by diffContext so diff annotations stay in diff view and normal annotations stay in normal view (fixes bleed-through both directions). Simplify diff badge to neutral "diff" label. Simplify export label to "[In diff content]". Add unchanged to diffContext union and resolveDiffContext match. Fix code-block deletion syntax re-highlighting order. Known limitations: unchanged-text annotations don't reliably survive diff toggle, cross-section selections pick one context tag, pinpoint mode not integrated in diff view. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace fragile text-selection annotation in diff mode with block-level hover annotation. Hovering added/removed/modified sections shows the annotation toolbar (same pattern as code block hover in Viewer). No web-highlighter, no DOM marks, no findTextInDOM restoration. Annotations live purely in React state — delete just removes from state, toggle preserves annotations in panel, no stale marks possible. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Owner
Author
Code reviewNo issues found above the confidence threshold. Checked for bugs, CLAUDE.md compliance, and dead/stale code from refactoring. Note: Several cleanup opportunities were identified at moderate confidence (scored 75/100 each, below the 80 threshold for flagging). These are all dead code from the multi-iteration refactoring on this branch — not bugs, but worth a cleanup pass:
🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
PlanCleanDiffView no longer uses this hook (switched to block-level hover). Remove the resolveContext option, ref, sync effect, and call site — no consumer passes it. Update header comment to reflect the hook is Viewer-only. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…tions - Remove no-op scroll-to-selected useEffect - Add hoverTimeoutRef cleanup on unmount - Deduplicate toolbar onMouseLeave (call handleLeave) - Remove dead annotations prop from PlanDiffViewer - Remove as any cast + stale isGlobal field from hook - Remove unused 'unchanged' from diffContext type - Filter diff annotations from share/draft restore paths - Fix stale CLAUDE.md claims Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
9 tasks
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.
Summary
Adds annotation support to the plan diff view using block-level hover. Users hover over added/removed/modified diff sections and annotate entire blocks — same pattern as code block hover in the normal Viewer.
What we tried and why we pivoted
Attempt 1: Text-selection via web-highlighter. Copied ~250 lines of annotation plumbing from Viewer.tsx into PlanCleanDiffView. Worked for basic cases but was fragile —
findTextInDOMbroke across diff boundaries, unchanged text got orphaned on toggle, cross-section selections picked wrong contexts, and highlights vanished on re-render due to unstable callback dependencies.Attempt 2: Extracted
useAnnotationHighlighterhook. Deduplicated the shared logic between Viewer and PlanCleanDiffView. Fixed the re-render teardown bug and added auto-restore for persisted annotations. But the core fragility remained — text-search restoration in a fragmented diff DOM is inherently unreliable.Final approach: Block-level hover annotation. Replaced text-selection entirely. Hovering a diff section shows the annotation toolbar anchored to that block. No web-highlighter, no DOM marks, no
findTextInDOM. Annotations live purely in React state. Delete just removes from state. Toggle is trivial — nothing to restore.What shipped
useAnnotationHighlighterhook — extracted from Viewer.tsx, used by Viewer only (not diff view)diffbadge in AnnotationPanel for all diff annotations[In diff content]label in exported feedbackKnown limitations
Test plan
diffbadge[In diff content]labelsbun run build:hook→ production build succeeds🤖 Generated with Claude Code