fix(tui): resolve textarea flickering when pasting long text in question prompt #10449
+73
−22
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.
Problem
When pasting long text into the "Type your own answer" textarea in the question tool UI, the text would continuously flicker between showing the start of the text and the end of the text. Clicking with the cursor would temporarily stop the flickering. This bug to me occurred by the use of text-to-speech software like Superwhisper which paste the whole speech as text into the text area.
Fixes: #10450 and (likely) #9885
Bug Demo
Screen.Recording.2026-01-25.at.3.37.43.AM.mov
Root Cause
The default
scrollMargin(0.2 = 20% of viewport) was causing a scroll position conflict. On each render frame, the textarea was trying to keep the cursor visible with a margin, which caused the viewport to alternate between:Solution
scrollMargin={0}to disable the automatic scroll-to-cursor margin behaviorCustomAnswerTextareacomponent with proper lifecycle management viaonMountonPastehandler that prevents default paste behavior and manually handles text insertion with explicit viewport positioninggotoBufferEnd()for consistent cursor positioning at end of contentFix Demo
Screen.Recording.2026-01-25.at.3.40.14.AM.mov
Testing
bun devinpackages/opencodeChanges
packages/opencode/src/cli/cmd/tui/routes/session/question.tsxCustomAnswerTextareacomponentscrollMargin={0}proponPastehandler with viewport managementcursorStyle={{ style: "block", blinking: false }}gotoLineEnd()togotoBufferEnd()