Skip to content

fix(cli): ensure Enter and Spacebar reliably confirm selection list options - #29502

Merged
DavidAPierce merged 10 commits into
google-gemini:mainfrom
ugorla-dev:fix/selection-list-confirmation-keys-28887
Oct 2, 2026
Merged

DavidAPierce merged 10 commits into
google-gemini:mainfrom
ugorla-dev:fix/selection-list-confirmation-keys-28887

Conversation

@ugorla-dev

@ugorla-dev ugorla-dev commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Ensure interactive selection lists (useSelectionList, RadioButtonSelect, ToolConfirmationMessage, and AskUserDialog) reliably confirm options with Enter and Spacebar across terminals (including Windows IDE terminals without Kitty Keyboard Protocol), while preventing InputPrompt from preempting confirmation keystrokes when an interactive prompt or dialog is active.

Details

On terminals where Kitty Keyboard Protocol is unsupported (such as PyCharm on Windows), several input-pipeline behaviors can prevent confirming an option in RadioButtonSelect / useSelectionList (e.g., after /init generates GEMINI.md and prompts to accept the file):

  1. bufferFastReturn (KeypressContext.tsx) converting Enter into Shift+Enter: When Enter (\r) arrives within 30ms of a previous keystroke (such as an arrow-key navigation or batched ConPTY chunk), bufferFastReturn sets shift: true on the enter event. Because Command.RETURN requires shift: false, keyMatchers[Command.RETURN](key) rejects the keypress in useSelectionList.
  2. Standalone \n (LF) and CRLF (\r\n) handling: Terminals or PTY layers that emit \n (resolved as { name: "j", ctrl: true, sequence: "\n" }) or \r\n on Enter either fail to match Command.RETURN or risk double-triggering if both \r and \n are treated as separate confirmations.
  3. Spacebar selection support: Users expect unmodified Spacebar to select/toggle options in interactive selection lists, without triggering AskUserDialog Type-to-Jump to "Other" or interfering with SearchableList / AskUserDialog text inputs.
  4. InputPrompt priority preemption during pending confirmations: InputPrompt previously registered useKeypress(..., { isActive: true, priority: true }) unconditionally and ran handleVoiceInput before checking if (!focus). When InputPrompt remained mounted alongside a confirmation prompt (which used default Normal priority), InputPrompt was invoked before RadioButtonSelect.

Key Changes

  • packages/cli/src/ui/hooks/useSelectionList.ts:
    • Accept Enter in useSelectionList even when bufferFastReturn sets shift: true (keyMatchers[Command.RETURN](key) || (key.name === "enter" && !key.ctrl && !key.alt && !key.cmd)).
    • Accept standalone linefeed (sequence === "\n" && !key.alt && !key.cmd) and debounce a trailing \n arriving within 50ms of \r (CRLF_DEBOUNCE_MS) so CRLF (\r\n) never double-fires SELECT_CURRENT.
    • Accept unmodified Spacebar ((key.name === "space" || sequence === " ") && !key.ctrl && !key.alt && !key.shift && !key.cmd) to select the active item.
  • packages/cli/src/ui/components/shared/SearchableList.tsx:
    • Set priority: !searchBuffer on useSelectionList so <TextInput> (priority: true) always receives Spacebar and printable characters first when a search input is present, while Up, Down, and Enter fall through to useSelectionList.
  • packages/cli/src/ui/components/AskUserDialog.tsx:
    • Exclude unmodified Spacebar from handleExtraKeys ("Type-to-Jump") when a choice option is focused so Spacebar falls through to BaseSelectionList to select/toggle the option instead of jumping to "Other".
    • Pass priority={!isCustomOptionFocused} to <BaseSelectionList> so <TextInput> always retains higher priority while editing the custom "Other" option.
  • packages/cli/src/ui/components/messages/ToolConfirmationMessage.tsx, packages/cli/src/ui/components/Composer.tsx, & packages/cli/src/ui/components/InputPrompt.tsx:
    • Pass priority={isFocused} to <RadioButtonSelect> in ToolConfirmationMessage.tsx.
    • Pass focus={isFocused && !hasPendingActionRequired} to <InputPrompt> in Composer.tsx.
    • Ignore all inputs when unfocused (if (!focus) return false; at the top of handleInput) and set priority: focus on useKeypress in InputPrompt.tsx.
  • Unit Tests:
    • Add/update unit tests in useSelectionList.test.tsx, AskUserDialog.test.tsx, SearchableList.test.tsx, Composer.test.tsx, and InputPrompt.test.tsx.

Related Issues

Fixes #28887

How to Validate

  1. Run the unit test suites for selection lists, dialogs, tool confirmations, and input handling:
    npm test -w @google/gemini-cli -- src/ui/hooks/useSelectionList.test.tsx src/ui/components/AskUserDialog.test.tsx src/ui/components/shared/SearchableList.test.tsx src/ui/components/messages/ToolConfirmationMessage.test.tsx src/ui/components/Composer.test.tsx src/ui/components/InputPrompt.test.tsx
  2. Verify typecheck and linting pass cleanly:
    npm run typecheck && npm run lint

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@ugorla-dev
ugorla-dev requested a review from a team as a code owner September 25, 2026 08:57
@github-actions github-actions Bot added the size/m A medium sized PR label Sep 25, 2026
@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

📊 PR Size: size/M

  • Lines changed: 217
  • Additions: +193
  • Deletions: -24
  • Files changed: 13

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request improves the reliability and consistency of interactive selection lists within the CLI. By refining how keystrokes like Enter and Spacebar are processed and managing component input priorities, it resolves issues where user selections were ignored or preempted in specific terminal environments or complex UI states.

Highlights

  • Enhanced Input Handling: Updated useSelectionList to reliably handle Enter and Spacebar across various terminal environments, including those without Kitty Keyboard Protocol support, by improving key matching and debouncing CRLF sequences.
  • Priority Management: Adjusted input priority logic across SearchableList, InputPrompt, and ToolConfirmationMessage to ensure confirmation keystrokes are correctly routed and not preempted by other active UI components.
  • UX Improvements: Enabled unmodified Spacebar for selection in AskUserDialog and useSelectionList, while ensuring it remains available for text input in SearchableList when a search buffer is active.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@ugorla-dev

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for using the spacebar to select or confirm options in selection lists and dialogs, and handles standalone linefeeds and CRLF sequences gracefully by introducing a CRLF debounce mechanism. It also refactors focus and priority handling for the InputPrompt and SearchableList components to ensure keypresses are routed correctly when actions are pending or when a search buffer is active. Relevant unit tests have been added to verify these keyboard navigation and focus behaviors. No review comments were provided, so I have no additional feedback to offer.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for using the Spacebar to select or toggle items in selection lists and dialogs, and implements CRLF sequence debouncing in the useSelectionList hook. It also refactors keypress handling priorities across several UI components (such as InputPrompt, SearchableList, and ToolConfirmationMessage) to ensure inputs are only processed when the respective component is focused. The review feedback suggests further improving input safety by completely ignoring paste events in InputPrompt when it is unfocused, and preventing Spacebar selection events from bubbling up when typing in a custom option's text input by adjusting the list's priority.

Comment thread packages/cli/src/ui/components/InputPrompt.tsx Outdated
Comment thread packages/cli/src/ui/components/AskUserDialog.tsx
@gemini-cli gemini-cli Bot added priority/p1 Important and should be addressed in the near term. area/core Issues related to User Interface, OS Support, Core Functionality labels Sep 25, 2026
@ugorla-dev

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for spacebar selection and confirmation in selection lists and dialogs, implements CRLF debouncing for terminal input, and refactors input focus handling so that the InputPrompt is unfocused when pending actions are required. Additionally, unfocused paste support has been removed from InputPrompt. The review feedback suggests a performance optimization in InputPrompt.tsx to include the focus state directly in the isActive configuration of useKeypress, which completely unregisters the keypress listener when the prompt is unfocused instead of relying on an early return.

Note: Security Review did not run due to the size of the PR.

Comment thread packages/cli/src/ui/components/InputPrompt.tsx
@ugorla-dev

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances terminal UI keyboard navigation and input handling. It introduces spacebar support for selecting options in lists (while preserving space inputs in search fields), refactors InputPrompt to ignore all inputs (including bracketed paste) when unfocused, updates Composer to unfocus the input prompt when a pending action is required, and implements a 50ms debounce for trailing linefeeds in CRLF sequences within useSelectionList. No review comments were provided, so I have no additional feedback to offer.

Note: Security Review did not run due to the size of the PR.

@ugorla-dev

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances keyboard navigation and input handling across several CLI UI components. Key changes include adding spacebar support for selection lists and choice questions, implementing debouncing for trailing linefeeds in CRLF sequences to prevent double-triggering, and ensuring that the InputPrompt is unfocused when a pending action is required. Additionally, bracketed paste events are now ignored when the input prompt is unfocused, and keypress priorities have been refined for components like SearchableList and ToolConfirmationMessage. I have no further feedback to provide as the changes are well-implemented and thoroughly tested.

Note: Security Review did not run due to the size of the PR.

@DavidAPierce
DavidAPierce enabled auto-merge October 1, 2026 19:58
@DavidAPierce
DavidAPierce disabled auto-merge October 1, 2026 19:58
@ugorla-dev

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves keyboard navigation and input handling within the CLI UI. Key changes include adding support for the spacebar as a selection trigger in lists and dialogs, refining focus management for the InputPrompt component, and implementing debounce logic for CRLF sequences to prevent unintended double-triggering. Additionally, the PR updates SearchableList and ToolConfirmationMessage priority logic and includes comprehensive test coverage for these new interactions. I have no feedback to provide as there were no review comments to assess.

@DavidAPierce
DavidAPierce added this pull request to the merge queue Oct 2, 2026
Merged via the queue into google-gemini:main with commit fb972b2 Oct 2, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality priority/p1 Important and should be addressed in the near term. size/m A medium sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gemini CLI doesnt allow me to aprove Gemini.md creation

2 participants