Skip to content

fix(pinpoint): restore click handler after exiting plan diff#238

Merged
backnotprop merged 1 commit intomainfrom
pinpoint-patch
Mar 7, 2026
Merged

fix(pinpoint): restore click handler after exiting plan diff#238
backnotprop merged 1 commit intomainfrom
pinpoint-patch

Conversation

@backnotprop
Copy link
Owner

Summary

  • Bug: Pinpoint mode stops working (clicks do nothing) after entering and exiting Plan Diff view. Drag selection continues to work fine.
  • Root cause: The usePinpoint click effect read highlighterRef.current at effect setup time and exited early if null. After exiting plan diff, the Viewer component fully remounts — usePinpoint's click effect ran before the highlighter init effect (line 500), so the ref was still null. The effect bailed without installing the click handler, and nothing triggered a re-run since all dependencies (stable refs, unchanged isActive) remained the same.
  • Why drag selection still worked: Drag selection uses web-highlighter's own internal mouseup listener (set up during highlighter.run()), which is independent of the usePinpoint hook.
  • Why hover overlay still worked: The mousemove effect in usePinpoint doesn't depend on highlighterRef, so it continued functioning normally.

Fix

Moved highlighterRef.current from effect setup time into the click handler body, so it's resolved lazily at click time when the highlighter is guaranteed to be initialized.

Test plan

  • Open a plan with version history (so diff badge appears)
  • Switch to Pinpoint input method
  • Click the diff badge to enter Plan Diff view
  • Exit Plan Diff view (click "Exit Diff" or press Escape)
  • Verify pinpoint hover overlay still appears on elements
  • Verify clicking an element in pinpoint mode creates an annotation
  • Verify drag selection still works after toggling diff on/off
  • Verify pinpoint works on initial load (no regression)

🤖 Generated with Claude Code

The pinpoint click effect read `highlighterRef.current` at effect setup
time and bailed early if it was null. After exiting plan diff, the
Viewer fully remounts — usePinpoint's click effect ran before the
highlighter init effect, so `highlighterRef.current` was still null.
The effect returned early without installing the click handler, and
nothing triggered it to re-run since the dependencies (stable refs,
unchanged `isActive`) didn't change.

Move the highlighter read into the click handler body so it's resolved
lazily at click time, when the highlighter is guaranteed to be ready.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@backnotprop
Copy link
Owner Author

Code review

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

🤖 Generated with Claude Code

@backnotprop backnotprop merged commit 6be5c01 into main Mar 7, 2026
3 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.

1 participant