Skip to content

remove wildcard behavior on keybindings#21315

Merged
jacob314 merged 1 commit intomainfrom
tomm_keybinding
Mar 5, 2026
Merged

remove wildcard behavior on keybindings#21315
jacob314 merged 1 commit intomainfrom
tomm_keybinding

Conversation

@scidomino
Copy link
Collaborator

@scidomino scidomino commented Mar 5, 2026

Summary

Remove wildcard behavior on keybindings

Details

This change is necessary to support clear customizable key bindings.

This change revealed some bugs in KeypressContext which are fixed here. I also narrowed fastEnter buffering to be more discriminating.

Also: Update docs about shift+enter support on Windows Terminal.

Related Issues

For #21294

How to Validate

Try out all the various hotkeys.

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

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

Size Change: -826 B (0%)

Total Size: 26 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 25.5 MB -826 B (0%)
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 221 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 227 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 11.5 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/types.js 132 B 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B
./bundle/sandbox-macos-strict-open.sb 4.82 kB 0 B
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB 0 B

compressed-size-action

@scidomino scidomino marked this pull request as ready for review March 5, 2026 21:10
@scidomino scidomino requested review from a team as code owners March 5, 2026 21:10
@gemini-code-assist
Copy link
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 fundamentally changes how keybindings are interpreted by removing wildcard behavior for modifiers. This ensures that key combinations are matched precisely, enhancing the customizability and predictability of keyboard shortcuts. The implementation involved refining the KeypressContext to handle keypresses more accurately and updating documentation and tests to reflect these stricter rules.

Highlights

  • Strict Keybinding Modifier Matching: The keybinding system now enforces strict matching for modifiers (Shift, Alt, Ctrl, Cmd). Previously, an undefined modifier in a keybinding would act as a wildcard, matching both true and false states. Now, undefined or false explicitly means the modifier must not be pressed, making keybindings more precise and customizable.
  • KeypressContext Bug Fixes: This change exposed and subsequently fixed several bugs within the KeypressContext related to how keypresses, especially escape sequences and fast returns, were processed.
  • Refined fastEnter Buffering: The logic for buffering fastEnter has been narrowed to be more discriminating, ensuring it only buffers when the preceding key was an "insertable" character, improving input predictability.
  • Documentation and Test Updates: The keyboard shortcuts reference documentation was updated to remove redundant "no Shift, Ctrl" annotations, and numerous unit and snapshot tests were adjusted to align with the new strict keybinding behavior.
Changelog
  • docs/reference/keyboard-shortcuts.md
    • Updated keybinding descriptions by removing explicit "no Shift, Alt, Ctrl, Cmd" annotations.
    • Clarified shift+enter support on Windows Terminal.
  • packages/cli/src/config/keyBindings.test.ts
    • Removed specific tests for modifier exclusions that are now implicitly handled by the strict keybinding logic.
  • packages/cli/src/config/keyBindings.ts
    • Simplified default keybinding definitions by removing explicit shift: false, alt: false, ctrl: false, and cmd: false properties.
    • Added Shift + R as an alternative key for restarting the application.
  • packages/cli/src/ui/components/snapshots/AskUserDialog.test.tsx.snap
    • Removed several outdated snapshot tests related to choice question placeholders and scroll arrow rendering.
  • packages/cli/src/ui/components/snapshots/ExitPlanModeDialog.test.tsx.snap
    • Removed multiple outdated snapshot tests concerning feedback input and plan mode interactions.
  • packages/cli/src/ui/components/snapshots/InputPrompt.test.tsx.snap
    • Removed outdated snapshot tests related to paste expansion behavior.
  • packages/cli/src/ui/contexts/KeypressContext.test.tsx
    • Adjusted test assertions for escape key handling to correctly reflect the alt: false state.
  • packages/cli/src/ui/contexts/KeypressContext.tsx
    • Modified the bufferFastReturn function to restrict buffering to only occur after insertable keys.
    • Corrected the alt modifier detection for escape sequences.
  • packages/cli/src/ui/keyMatchers.test.ts
    • Updated key matcher tests to align with the new strict modifier matching logic, specifically by moving previously positive matches with implicit modifiers to negative test cases.
  • packages/cli/src/ui/keyMatchers.ts
    • Refactored the matchKeyBinding function to implement strict modifier matching, where false or undefined for a modifier explicitly means it must not be pressed.
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 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 counter productive. 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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

Copy link
Contributor

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

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 successfully removes the wildcard behavior from keybindings by updating the matching logic in keyMatchers.ts. This improves clarity and makes keybindings more explicit. The changes are consistently applied across the keybinding configurations and tests. The PR also includes valuable bug fixes in KeypressContext.tsx related to escape sequence handling. However, the removal of wildcard matching might cause regressions for some commands that previously matched with modifiers. I've added a comment with a suggestion to address this potential breaking change.

@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 Mar 5, 2026
@jacob314 jacob314 self-requested a review March 5, 2026 21:16
@scidomino scidomino enabled auto-merge March 5, 2026 21:23
@scidomino scidomino disabled auto-merge March 5, 2026 21:31
Copy link
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

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

lgtm

@jacob314 jacob314 added this pull request to the merge queue Mar 5, 2026
Merged via the queue into main with commit 19c9508 Mar 5, 2026
27 of 28 checks passed
@jacob314 jacob314 deleted the tomm_keybinding branch March 5, 2026 22:24
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants