Skip to content

Textarea cursor doesn't auto-scroll when typing long prompts #10401

@jubayeramb

Description

@jubayeramb

Description

When typing a long prompt in the TUI input textarea that exceeds the visible area (maxHeight of 6 lines), the cursor doesn't automatically scroll to stay in view. This causes several issues:

  1. The cursor moves but the viewport doesn't follow, leaving the text invisible
  2. Black/empty spaces appear where text should be visible
  3. The cursor can go below the textarea boundary
  4. The bottom status bar (model name, variants) occasionally renders outside its boundary

Expected Behavior
The textarea should auto-scroll to keep the cursor visible as the user types, similar to standard text editor behavior.

Root Cause
The onContentChange handler in the prompt component updates state but doesn't trigger a layout recalculation and re-render. This causes the viewport to become out of sync with the cursor position.

Proposed Fix
Add markDirty() and requestRender() calls to the onContentChange handler, matching the pattern already used in onPaste and TuiEvent.PromptAppend handlers.
File: packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx

Plugins

opencode-antigravity-auth@latest

OpenCode version

1.1.34

Steps to reproduce

  1. Run bun dev
  2. Start typing a long multi-line prompt (more than 6 lines)
  3. Observe that the cursor disappears from view as you type beyond the visible area
  4. Manually scroll down to see the typed text

Screenshot and/or share link

opencode-input-scrolling-issue.mp4

Operating System

macOS Darwin 25.2.0 (arm64)

Terminal

VS Code integrated terminal (1.108.2), Shell: zsh

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingopentuiThis relates to changes in v1.0, now that opencode uses opentui

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions