Skip to content

Conversation

@bxff
Copy link

@bxff bxff commented Jan 24, 2026

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:

  1. Scrolling to show the start of text (default position)
  2. Scrolling to show the cursor at the end (scroll margin behavior)

Solution

  • Set scrollMargin={0} to disable the automatic scroll-to-cursor margin behavior
  • Extract CustomAnswerTextarea component with proper lifecycle management via onMount
  • Add custom onPaste handler that prevents default paste behavior and manually handles text insertion with explicit viewport positioning
  • Disable cursor blinking to reduce unnecessary render cycles
  • Use gotoBufferEnd() for consistent cursor positioning at end of content

Fix Demo

Screen.Recording.2026-01-25.at.3.40.14.AM.mov

Testing

  1. Run bun dev in packages/opencode
  2. Trigger a question with custom answer option
  3. Select "Type your own answer"
  4. Paste a long sentence.
  5. Verify text displays stably without flickering

Changes

  • packages/opencode/src/cli/cmd/tui/routes/session/question.tsx
    • Extracted CustomAnswerTextarea component
    • Added scrollMargin={0} prop
    • Added custom onPaste handler with viewport management
    • Added cursorStyle={{ style: "block", blinking: false }}
    • Changed from gotoLineEnd() to gotoBufferEnd()

…ion prompt

The custom answer textarea was flickering between showing the start and end
of pasted text due to scroll position conflicts caused by the default
scrollMargin (0.2) fighting with cursor positioning.

Changes:
- Extract CustomAnswerTextarea component with proper lifecycle management
- Set scrollMargin={0} to disable automatic scroll-to-cursor margin
- Add custom onPaste handler with manual viewport positioning
- Disable cursor blinking to reduce render cycles
- Use gotoBufferEnd() for consistent cursor positioning
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

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.

Textarea flickering when pasting long text in question

1 participant