fix(desktop): open DiffPane comment composer on pointer-up#4977
Conversation
…er-down Pierre's top-level `onSelectedLinesChange` fires for every selection notify — start, drag, and end — so the composer was popping the moment the user moused down and following the drag. Switch to the per-item `onLineSelectionEnd` callback, which fires only from `handleDocumentPointerUp`, so the composer appears once with the committed range. The gutter "+" path was already mouse-up driven and also reaches `onLineSelectionEnd`, so `onGutterUtilityClick` is reduced to a required non-null stub (pierre's gutter pointer flow early-returns without it). `onLineSelectionEnd` chosen over `onLineSelected` because the latter also fires on imperative selection writes (e.g. our own `clearSelectedLines` or future jump-to-thread), which would spuriously re-open the composer.
|
Capy auto-review is paused for this organization because the monthly auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews. |
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThe PR migrates diff pane line selection handling from ChangesLine Selection Signal Migration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Ready to review this PR? Stage has broken it down into 3 individual chapters for you:
Chapters generated by Stage for commit 23d097a on May 28, 2026 5:44pm UTC. |
There was a problem hiding this comment.
No issues found across 2 files
Architecture diagram
sequenceDiagram
participant User as User (Mouse)
participant DiffPane as DiffPane Component
participant Hook as useDiffCommentComposer Hook
participant Pierre as @pierre/diffs Library
participant State as DiffCommentComposer State
Note over User,State: DiffPane Comment Composer Flow
User->>DiffPane: Click/Pointer-down on diff line
DiffPane->>Pierre: onLineSelectionStart (pass-through)
Pierre->>Pierre: Track pointer session
User->>DiffPane: Drag pointer to new line
DiffPane->>Pierre: Notify selection change
Pierre->>Pierre: Update internal selection
Note over DiffPane,Pierre: Top-level onSelectedLinesChange (removed)<br/>NO LONGER fires composer open
User->>DiffPane: Pointer-up / mouse-up
Pierre->>Pierre: handleDocumentPointerUp
Pierre->>Hook: onLineSelectionEnd(range, context)
alt Valid range and context.type === "diff"
Hook->>State: setComposer({ itemId, range })
State-->>DiffPane: Render composer annotation
else Null range (deselect)
Hook->>State: setComposer(null)
State-->>DiffPane: Close composer
end
Note over User,Pierre: Gutter "+" button path
User->>DiffPane: Click gutter "+" button
DiffPane->>Pierre: onGutterUtilityClick (no-op stub)
Pierre->>Pierre: Start gutter pointer session (gated on non-null handler)
Pierre->>Pierre: notifySelectionEnd (from pointer-up)
Pierre->>Hook: onLineSelectionEnd(range, context)
alt Range present
Hook->>State: setComposer({ itemId, range })
State-->>DiffPane: Open composer
end
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
|
Greptile encountered an error while reviewing this PR. Please reach out to support@greptile.com for assistance. |
Summary
onSelectedLinesChangefires for every selection notify (start, drag, end), which is why.onLineSelectionEndcallback, which only fires from pierre'shandleDocumentPointerUp. The composer now appears once on mouse-up with the committed range.onGutterUtilityClickis reduced to a required non-null stub — pierre gates the "+" button's pointer flow on a non-null handler, but the gutter pointer-up path already firesnotifySelectionEnd→onLineSelectionEnd, so the open is handled there.onLineSelectionEndchosen overonLineSelectedbecause the latter also fires on imperative selection writes (clearSelectedLines, future jump-to-thread, etc.), which would re-open the composer spuriously.Test plan
clearSelectedLinesruns; composer does not re-open from the imperative clear.Summary by cubic
Fixes the DiffPane inline comment composer so it opens on mouse-up, not mouse-down, preventing it from popping during drag. Uses the per-item selection end signal to open once with the committed range.
onLineSelectionEndfrom@pierre/diffsto open the composer on pointer-up.onGutterUtilityClickas a no-op stub; the gutter path already triggers selection end on release.Written for commit 1349647. Summary will update on new commits.
Review in cubic
Summary by CodeRabbit