Repository navigation
fix(cli): ensure Enter and Spacebar reliably confirm selection list options - #29502
DavidAPierce merged 10 commits into
Conversation
|
📊 PR Size: size/M
|
Summary of ChangesHello, 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
Using Gemini Code AssistThe 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
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 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
|
|
/gemini review |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
/gemini review |
There was a problem hiding this comment.
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.
|
/gemini review |
There was a problem hiding this comment.
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.
|
/gemini review |
There was a problem hiding this comment.
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.
|
/gemini review |
There was a problem hiding this comment.
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.
Summary
Ensure interactive selection lists (
useSelectionList,RadioButtonSelect,ToolConfirmationMessage, andAskUserDialog) reliably confirm options withEnterandSpacebaracross terminals (including Windows IDE terminals without Kitty Keyboard Protocol), while preventingInputPromptfrom 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/initgeneratesGEMINI.mdand prompts to accept the file):bufferFastReturn(KeypressContext.tsx) convertingEnterintoShift+Enter: WhenEnter(\r) arrives within 30ms of a previous keystroke (such as an arrow-key navigation or batched ConPTY chunk),bufferFastReturnsetsshift: trueon theenterevent. BecauseCommand.RETURNrequiresshift: false,keyMatchers[Command.RETURN](key)rejects the keypress inuseSelectionList.\n(LF) and CRLF (\r\n) handling: Terminals or PTY layers that emit\n(resolved as{ name: "j", ctrl: true, sequence: "\n" }) or\r\nonEntereither fail to matchCommand.RETURNor risk double-triggering if both\rand\nare treated as separate confirmations.Spacebarselection support: Users expect unmodifiedSpacebarto select/toggle options in interactive selection lists, without triggeringAskUserDialogType-to-Jump to"Other"or interfering withSearchableList/AskUserDialogtext inputs.InputPromptpriority preemption during pending confirmations:InputPromptpreviously registereduseKeypress(..., { isActive: true, priority: true })unconditionally and ranhandleVoiceInputbefore checkingif (!focus). WhenInputPromptremained mounted alongside a confirmation prompt (which used defaultNormalpriority),InputPromptwas invoked beforeRadioButtonSelect.Key Changes
packages/cli/src/ui/hooks/useSelectionList.ts:EnterinuseSelectionListeven whenbufferFastReturnsetsshift: true(keyMatchers[Command.RETURN](key) || (key.name === "enter" && !key.ctrl && !key.alt && !key.cmd)).sequence === "\n" && !key.alt && !key.cmd) and debounce a trailing\narriving within50msof\r(CRLF_DEBOUNCE_MS) so CRLF (\r\n) never double-firesSELECT_CURRENT.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:priority: !searchBufferonuseSelectionListso<TextInput>(priority: true) always receivesSpacebarand printable characters first when a search input is present, whileUp,Down, andEnterfall through touseSelectionList.packages/cli/src/ui/components/AskUserDialog.tsx:SpacebarfromhandleExtraKeys("Type-to-Jump") when a choice option is focused soSpacebarfalls through toBaseSelectionListto select/toggle the option instead of jumping to"Other".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:priority={isFocused}to<RadioButtonSelect>inToolConfirmationMessage.tsx.focus={isFocused && !hasPendingActionRequired}to<InputPrompt>inComposer.tsx.if (!focus) return false;at the top ofhandleInput) and setpriority: focusonuseKeypressinInputPrompt.tsx.useSelectionList.test.tsx,AskUserDialog.test.tsx,SearchableList.test.tsx,Composer.test.tsx, andInputPrompt.test.tsx.Related Issues
Fixes #28887
How to Validate
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.tsxnpm run typecheck && npm run lintPre-Merge Checklist