Reveal the selection head in the prompt input, not the anchor - #2053
Conversation
|
🚨 SLOP COP 🚨 · I am reviewing this pull request now. I will check security, code quality, performance, architecture, and the prompt input behavior. |
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Plain English summary
This change makes the prompt input follow the end of a text selection that the user moves. It stops upward selections from jumping downward.
This review covers commit d71a0155. The pull request gained commit 17b386a5 after this review, so this result does not cover that commit.
Findings
I found no issue caused by the reviewed change.
The production change uses selection.head, which ProseMirror defines as the moving end. A collapsed selection keeps the same behavior.
The security check found no new risk. It found a separate clipboard trust issue that already exists on main.
The architecture scan found no duplicate caret geometry helper. The prompt-specific helper should remain in its current location.
The existing code schedules one reveal for each animation frame. This pull request adds no layout reads or performance cost.
Verification
- Chrome 151 followed backward and forward selections without reverse movement or jitter.
- The backward test moved
scrollTopfrom 275 to 0. - The forward test moved
scrollTopfrom 3 to 275. - All 101 focused prompt tests passed.
- The
@bb/apptype check passed. - The diff check passed.
- The final independent GPT-5.6 review found no issue.
Doobie supports Chrome, so this review did not include Safari or Firefox.
Fixes #2051 Co-Authored-By: Claude <noreply@anthropic.com>
17b386a to
7585807
Compare
What was wrong
revealPromptEditorSelectionscrollededitor.state.selection.tointo the prompt scroll container on every selection update. When you drag or Shift+Arrow a selection upward, the anchor stays below andtois the anchor, not the moving head. The browser autoscrolled up toward the head; the reveal scrolled back down toward the anchor; the prompt jittered and you could not select text above the viewport.What changed
Reveal
selection.headinstead ofselection.to. For a caret both are equal, so caret behavior does not change. For a selection the head is the end the user moves.How I verified
Added
PromptBoxInternal selection revealtest: a 100px viewport atscrollTop = 500, anchor below and head above. Before the fix one selection update movedscrollTopto 588 (toward the anchor); after the fix it moves up.@bb/appPromptBoxInternal tests: 101 passed.@bb/apptypecheck passes.Fixes #2051