Skip to content

fix(cli): use spacebar for toggling multi-select items in Question Tool - #12329

Closed
saakshigupta2002 wants to merge 1 commit into
anomalyco:devfrom
saakshigupta2002:fix/question-tool-spacebar-toggle-clean
Closed

saakshigupta2002 wants to merge 1 commit into
anomalyco:devfrom
saakshigupta2002:fix/question-tool-spacebar-toggle-clean

Conversation

@saakshigupta2002

Copy link
Copy Markdown

fix(cli): use spacebar for toggling multi-select items in Question Tool

Summary

  • Resolves an inconsistency in the Question Tool's multi-select keyboard behavior where Enter was used to toggle checkbox items, deviating from the established pattern used across all other toggleable UI elements in the application
  • Maps Spacebar to toggle checkbox items and Enter to advance to the next question/tab in multi-select mode, aligning with the command palette, MCP dialogs, and export options which all use Spacebar for toggling
  • Updates the hint bar at the bottom of the Question Tool to accurately reflect the new keybindings (space toggle, enter next) for multi-select questions

Motivation

The Question Tool is the primary interface through which agents ask users structured questions. In its multiple-choice mode, pressing Enter toggled checkbox items on and off. However, this was inconsistent with:

  1. Every other toggleable element in OpenCode - The command palette, MCP tool authorization dialogs, and export options dialogs all use Spacebar to toggle items and Enter to confirm/submit.
  2. Standard browser behavior - HTML checkboxes are toggled via Spacebar, not Enter. Enter is universally associated with form submission or advancing to the next step.
  3. User expectations - Users familiar with terminal UIs (fzf, lazygit, etc.) expect Spacebar for selection/toggling in multi-select contexts.

This inconsistency caused confusion, particularly for users who switch between the Question Tool and other dialogs frequently.

Changes

All changes are in packages/opencode/src/cli/cmd/tui/routes/session/question.tsx:

Keyboard Handler Logic

Before:

  • Enter in multi-select mode called selectOption() which triggered toggle() on the highlighted item
  • No Spacebar handler existed

After:

  • Spacebar in multi-select mode calls selectOption() which triggers toggle() on the highlighted item
  • Enter in multi-select mode advances to the next tab/question via selectTab((store.tab + 1) % tabs())
  • Single-select behavior is completely unchanged (Enter still picks and advances)
  • Confirm tab behavior is completely unchanged (Enter still submits)

Hint Bar

Before:

enter toggle    (shown in multi-select mode)

After:

space toggle    (shown only in multi-select mode)
enter next      (shown in multi-select mode)

The space toggle hint is conditionally rendered only when the user is on a multi-select question (not on the confirm tab), matching the pattern used in dialog-export-options.tsx which shows Press space to toggle, return to confirm.

Behavioral Matrix

Context Spacebar Enter
Single-select question No change Picks option and submits
Multi-select question Toggles checkbox (new) Advances to next question (changed)
Multi-select custom "Other" Toggles custom answer (new) Advances to next question (changed)
Confirm tab No change Submits all answers
Editing custom text No change (types space) Confirms custom text input

Consistency Reference

This change aligns the Question Tool with the existing toggle pattern in the codebase:

// dialog-export-options.tsx (existing pattern)
if (evt.name === "space") {
  if (store.active === "thinking") setStore("thinking", !store.thinking)
  // ...
}
// Hint: "Press space to toggle, return to confirm"

Test Plan

  • Open a session that triggers a multi-select question from an agent
  • Verify Spacebar toggles checkbox items on/off
  • Verify Enter advances to the next question tab (does not toggle)
  • Verify the hint bar shows space toggle and enter next in multi-select mode
  • Verify single-select questions still work with Enter to pick and advance
  • Verify the Confirm tab still submits with Enter
  • Verify Escape still dismisses the question prompt
  • Verify number keys (1-9) still quick-select options
  • Verify arrow keys and j/k still navigate options
  • Verify Tab/Shift+Tab still cycle between question tabs
  • Verify custom "Type your own answer" editing still works (Enter confirms text, Escape cancels)

closes #12296

The Question Tool's multiple-choice mode used Enter to toggle checkbox
items, which was inconsistent with every other toggleable UI element
in the application (command palette, MCP dialogs, export options) that
uses Spacebar for toggling. This also misaligned with standard browser
behavior where checkboxes are toggled with Spacebar.

- Spacebar now toggles checkbox items in multi-select questions
- Enter advances to the next tab/question in multi-select mode
- Updated hint bar to show "space toggle" and "enter next" for
  multi-select questions
- Single-select and confirm behavior remains unchanged

closes #12296
@github-actions

github-actions Bot commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

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

Potential Duplicate Found:

PR #11476 - feat(tui): space to toggle answers in multi-select and enter for submit in questions tool
#11476

This appears to be directly related or potentially a duplicate. The title and description both describe implementing spacebar toggling for multi-select items and Enter for advancing to the next question - which is exactly what PR #12329 addresses. You should check if #11476 is already merged or if it was closed/abandoned, as it may address the same feature request (issue #12296).

@saakshigupta2002 saakshigupta2002 closed this by deleting the head repository Feb 23, 2026
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.

Question Tool should use spacebar for selecting multiple choice items

1 participant