Aggressive Input Auto-focus prevents scrolling and interacting with Terminal #6560

Closed
opened 2026-02-16 18:04:35 -05:00 by yindo · 2 comments
Owner

Originally created by @qcwssss on GitHub (Jan 17, 2026).

Originally assigned to: @adamdotdevin on GitHub.

I'm experiencing a UX issue where the chat input box aggressively grabs focus, making it difficult to interact with the Terminal output.

Problem:
When I try to scroll the terminal output (to view previous command logs), the focus is forcibly pulled back to the chat input box. This causes the scroll action (or "Arrow Up" key if mapped) to trigger the "History Navigation" of the chat input (showing the previous sent message) instead of scrolling the terminal buffer.

Observations:

  1. It seems prompt-input.tsx has a createEffect that calls editorRef.focus() aggressively.
  2. session.tsx adds a global keydown listener that might be redirecting focus back to the input unless the active element has data-prevent-autofocus.
  3. Even when clicking inside the Terminal component (which has data-prevent-autofocus), the focus often snaps back to the input, possibly because the actual active element (e.g., the canvas or an inner div of ghostty-web) is not being correctly identified as "protected".

Expected Behavior:
When I click or scroll in the Terminal area, the focus should stay in the Terminal so I can scroll up/down and copy text without being interrupted. The Input box should only grab focus when I explicitly click it or start typing in a neutral context.

Environment:

  • OS: macOS
  • Browser/App: OpenCode Desktop App
  • Terminal: iTerm2 (where OpenCode is running) / Internal OpenCode Terminal

Please relax the auto-focus logic to allow the Terminal to retain focus.

Originally created by @qcwssss on GitHub (Jan 17, 2026). Originally assigned to: @adamdotdevin on GitHub. I'm experiencing a UX issue where the chat input box aggressively grabs focus, making it difficult to interact with the Terminal output. **Problem:** When I try to scroll the terminal output (to view previous command logs), the focus is forcibly pulled back to the chat input box. This causes the scroll action (or "Arrow Up" key if mapped) to trigger the "History Navigation" of the chat input (showing the previous sent message) instead of scrolling the terminal buffer. **Observations:** 1. It seems `prompt-input.tsx` has a `createEffect` that calls `editorRef.focus()` aggressively. 2. `session.tsx` adds a global `keydown` listener that might be redirecting focus back to the input unless the active element has `data-prevent-autofocus`. 3. Even when clicking inside the Terminal component (which has `data-prevent-autofocus`), the focus often snaps back to the input, possibly because the actual active element (e.g., the canvas or an inner div of `ghostty-web`) is not being correctly identified as "protected". **Expected Behavior:** When I click or scroll in the Terminal area, the focus should stay in the Terminal so I can scroll up/down and copy text without being interrupted. The Input box should only grab focus when I explicitly click it or start typing in a neutral context. **Environment:** - OS: macOS - Browser/App: OpenCode Desktop App - Terminal: iTerm2 (where OpenCode is running) / Internal OpenCode Terminal Please relax the auto-focus logic to allow the Terminal to retain focus.
yindo added the web label 2026-02-16 18:04:35 -05:00
yindo closed this issue 2026-02-16 18:04:35 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 17, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #7530: Cannot type in terminal in web app with mobile browser - Similar focus conflict between chat input and terminal
  • #7578: Opencode Web: Terminal not working - Terminal input being intercepted by chat interface
  • #7990: Poor mobile web experience - Multiple input/focus related issues on mobile, including icons overlapping input component
  • #6616: UI becomes unresponsive when tool permission dialog appears - Related keyboard event conflicts and input handling issues

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 17, 2026): This issue might be a duplicate of existing issues. Please check: - #7530: Cannot type in terminal in web app with mobile browser - Similar focus conflict between chat input and terminal - #7578: Opencode Web: Terminal not working - Terminal input being intercepted by chat interface - #7990: Poor mobile web experience - Multiple input/focus related issues on mobile, including icons overlapping input component - #6616: UI becomes unresponsive when tool permission dialog appears - Related keyboard event conflicts and input handling issues Feel free to ignore if none of these address your specific case.
Author
Owner

@qcwssss commented on GitHub (Jan 17, 2026):

This is the same issue #6209

@qcwssss commented on GitHub (Jan 17, 2026): This is the same issue #6209
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#6560