Skip to content

Reveal the selection head in the prompt input, not the anchor - #2053

Merged
SawyerHood merged 1 commit into
mainfrom
bb/fix-scroll-jitter-and-file-thr_ccbzf38he5
Aug 20, 2026
Merged

Reveal the selection head in the prompt input, not the anchor#2053
SawyerHood merged 1 commit into
mainfrom
bb/fix-scroll-jitter-and-file-thr_ccbzf38he5

Conversation

@SawyerHood

Copy link
Copy Markdown
Collaborator

What was wrong

revealPromptEditorSelection scrolled editor.state.selection.to into the prompt scroll container on every selection update. When you drag or Shift+Arrow a selection upward, the anchor stays below and to is 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.head instead of selection.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 reveal test: a 100px viewport at scrollTop = 500, anchor below and head above. Before the fix one selection update moved scrollTop to 588 (toward the anchor); after the fix it moves up. @bb/app PromptBoxInternal tests: 101 passed. @bb/app typecheck passes.

Fixes #2051

AGENT GENERATED: by Claude Opus 5

@bb-slop-cop

bb-slop-cop Bot commented Aug 20, 2026

Copy link
Copy Markdown

🚨 SLOP COP 🚨 · review

I am reviewing this pull request now. I will check security, code quality, performance, architecture, and the prompt input behavior.

@bb-slop-cop bb-slop-cop Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 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 scrollTop from 275 to 0.
  • The forward test moved scrollTop from 3 to 275.
  • All 101 focused prompt tests passed.
  • The @bb/app type 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>
@SawyerHood
SawyerHood force-pushed the bb/fix-scroll-jitter-and-file-thr_ccbzf38he5 branch from 17b386a to 7585807 Compare August 20, 2026 18:24
@SawyerHood
SawyerHood merged commit 099f134 into main Aug 20, 2026
13 checks passed
@SawyerHood
SawyerHood deleted the bb/fix-scroll-jitter-and-file-thr_ccbzf38he5 branch August 20, 2026 18:27
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.

Prompt input jitters and snaps back down when you drag a text selection upward

1 participant