Repository navigation
Description
Description
QuestionPrompt displays "tab" hint but doesn't handle tab key, causing unintended agent switch
When using the Question tool with a custom primary agent that has question: allow permission, pressing Tab in the QuestionPrompt UI causes the system to unexpectedly switch to another primary agent (e.g., build).
Root Cause
Two issues were identified:
- Keyboard Binding Conflict
The QuestionPrompt component displays ⇆ tab as the hint for switching between question tabs, but:
- The actual implementation uses left/right or h/l keys (not tab)
- The tab key event is not consumed (evt.preventDefault() is not called)
- The global agent_cycle keybind defaults to tab
- When user presses Tab, the event bubbles up and triggers agent switching
Relevant code:
packages/opencode/src/cli/cmd/tui/routes/session/question.tsx:150-162
// Only handles left/right/h/l, NOT tab
if (evt.name === "left" || evt.name === "h") {
evt.preventDefault()
const next = (store.tab - 1 + tabs()) % tabs()
setStore("tab", next)
setStore("selected", 0)
}
if (evt.name === "right" || evt.name === "l") {
evt.preventDefault()
const next = (store.tab + 1) % tabs()
setStore("tab", next)
setStore("selected", 0)
}
But the UI hint at line 346 shows:
<text fg={theme.text}>
{"⇆"} <span style={{ fg: theme.textMuted }}>tab</span>
</text>
- Agent Reset on Component Remount (Secondary Issue)
After answering a question, the Prompt component may be remounted due to session() briefly becoming undefined during data sync. This causes:
- syncedSessionID (a closure variable) to reset to undefined
- The createEffect in prompt/index.tsx:132-150 re-executes
- Agent is set based on lastUserMessage().agent, which may be a different agent
Plugins
No response
OpenCode version
1.1.8
Steps to reproduce
- Create a custom primary agent with question: allow permission
- Switch to the custom agent
- Send a prompt that triggers the Question tool
- When QuestionPrompt appears, press Tab key
- Observed: System switches to build agent (or next primary agent)
- Expected: Tab should switch between question tabs (or at minimum, not trigger agent switch)
Screenshot and/or share link
No response
Operating System
CachyOS x86_64
Terminal
alacritty 0.16.1
Activity
github-actions commentedon Jan 9, 2026
This issue might be a duplicate of existing issues. Please check:
Esckey 'through to the model #7384: TUI Commands modal passes Esc key through to other handlers (event propagation issue)Additionally, since this issue involves keyboard shortcuts (Tab key), please also check our pinned keybinds documentation: #4997
Feel free to ignore if none of these address your specific case.
faileon commentedon Feb 4, 2026
I think in general the question tool is very annoying to work with mainly due to the agent switching - often i am in plan mode, and i would like to switch to build mode during the question tool, but i cannot do that - or i havent found a way to do that... Tab for me swiches between the question tabs.
Mishkun commentedon Feb 13, 2026
I guess the issue here that question tool does not consume tab key and it is passed further to agent switching
Chocothin commentedon Mar 12, 2026
I have a fix for this and will open a PR shortly. It suspends command keybinds while modal prompts are active, using the existing pattern from autocomplete.tsx. Hope it helps!
malventano commentedon Apr 20, 2026
With your PR, how does the user know the agent was switched when pressing tab during a question prompt?
github-actions commentedon Jul 3, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.