Skip to content

refactor: migrate to useKeyMatchers hook#21753

Merged
scidomino merged 1 commit intomainfrom
tomm_matcher
Mar 9, 2026
Merged

refactor: migrate to useKeyMatchers hook#21753
scidomino merged 1 commit intomainfrom
tomm_matcher

Conversation

@scidomino
Copy link
Collaborator

@scidomino scidomino commented Mar 9, 2026

Summary

Refactors the code to use the useKeyMatchers hook.

Related Issues

For #21294

How to Validate

Verify that hotkeys still work.

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

@scidomino scidomino marked this pull request as ready for review March 9, 2026 19:28
@scidomino scidomino requested a review from a team as a code owner March 9, 2026 19:28
@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 undertakes a significant refactoring effort to modernize how keyboard shortcuts and key matchers are handled within the application. By introducing a dedicated useKeyMatchers hook, the codebase centralizes the logic for retrieving key binding functions, improving maintainability and setting the stage for more flexible and customizable keybindings in the future. This change involved migrating numerous components to adopt the new hook-based approach, ensuring a consistent pattern for handling user input.

Highlights

  • New Hook Introduced: A new React hook, useKeyMatchers, has been added to centralize the retrieval of key binding matchers. This prepares the codebase for future dynamic or custom key binding configurations.
  • Key Matcher Migration: Existing components and hooks across the application have been refactored to use the new useKeyMatchers hook instead of directly importing the keyMatchers constant. This includes various dialogs, prompts, and utility hooks.
  • Shortcuts Help Refactoring: The shouldDismissShortcutsHelpOnHotkey utility function has been refactored into a new hook, useIsHelpDismissKey, which now internally utilizes useKeyMatchers for consistency.
Changelog
  • packages/cli/src/ui/AppContainer.tsx
    • Removed direct import of keyMatchers and shouldDismissShortcutsHelpOnHotkey.
    • Added imports for useKeyMatchers and useIsHelpDismissKey.
    • Instantiated and utilized the new isHelpDismissKey and keyMatchers hooks.
    • Updated the call to shouldDismissShortcutsHelpOnHotkey to use isHelpDismissKey.
    • Adjusted useCallback dependency arrays to include keyMatchers and isHelpDismissKey.
  • packages/cli/src/ui/auth/ApiAuthDialog.tsx
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
  • packages/cli/src/ui/components/AdminSettingsChangedDialog.tsx
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
  • packages/cli/src/ui/components/AskUserDialog.tsx
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook in multiple sub-components.
    • Adjusted useCallback dependency arrays to include keyMatchers.
  • packages/cli/src/ui/components/BackgroundShellDisplay.tsx
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
  • packages/cli/src/ui/components/ExitPlanModeDialog.test.tsx
    • Changed import of keyMatchers to defaultKeyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook within test setup.
  • packages/cli/src/ui/components/ExitPlanModeDialog.tsx
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
  • packages/cli/src/ui/components/FooterConfigDialog.tsx
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
  • packages/cli/src/ui/components/HooksDialog.tsx
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
  • packages/cli/src/ui/components/InputPrompt.test.tsx
    • Changed import of keyMatchers to defaultKeyMatchers.
    • Updated usage of keyMatchers[Command.CLEAR_INPUT] to defaultKeyMatchers[Command.CLEAR_INPUT].
  • packages/cli/src/ui/components/InputPrompt.tsx
    • Removed direct import of keyMatchers and shouldDismissShortcutsHelpOnHotkey.
    • Added imports for useKeyMatchers and useIsHelpDismissKey.
    • Instantiated and utilized the new isHelpDismissKey and keyMatchers hooks.
    • Updated the call to shouldDismissShortcutsHelpOnHotkey to use isHelpDismissKey.
    • Adjusted useCallback dependency arrays to include keyMatchers and isHelpDismissKey.
  • packages/cli/src/ui/components/PolicyUpdateDialog.tsx
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
  • packages/cli/src/ui/components/RewindConfirmation.tsx
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
  • packages/cli/src/ui/components/RewindViewer.tsx
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
  • packages/cli/src/ui/components/ShellInputPrompt.tsx
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
    • Adjusted useCallback dependency arrays to include keyMatchers.
  • packages/cli/src/ui/components/ValidationDialog.tsx
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
  • packages/cli/src/ui/components/messages/ToolConfirmationMessage.tsx
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
  • packages/cli/src/ui/components/shared/BaseSettingsDialog.tsx
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
  • packages/cli/src/ui/components/shared/Scrollable.tsx
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
  • packages/cli/src/ui/components/shared/ScrollableList.tsx
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
  • packages/cli/src/ui/components/shared/SearchableList.tsx
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
  • packages/cli/src/ui/components/shared/TextInput.tsx
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
    • Adjusted useCallback dependency arrays to include keyMatchers.
  • packages/cli/src/ui/components/shared/text-buffer.ts
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
    • Adjusted useCallback dependency arrays to include keyMatchers.
  • packages/cli/src/ui/components/triage/TriageDuplicates.tsx
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
  • packages/cli/src/ui/components/triage/TriageIssues.tsx
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
  • packages/cli/src/ui/hooks/useApprovalModeIndicator.ts
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
  • packages/cli/src/ui/hooks/useKeyMatchers.ts
    • Added a new React hook, useKeyMatchers, to provide access to key matcher functions.
  • packages/cli/src/ui/hooks/useSelectionList.ts
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
    • Adjusted useCallback dependency arrays to include keyMatchers.
  • packages/cli/src/ui/hooks/useTabbedNavigation.ts
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
    • Adjusted useCallback dependency arrays to include keyMatchers.
  • packages/cli/src/ui/hooks/vim.ts
    • Removed direct import of keyMatchers.
    • Added import for useKeyMatchers.
    • Instantiated and utilized the keyMatchers hook.
    • Adjusted useCallback dependency arrays to include keyMatchers.
  • packages/cli/src/ui/keyMatchers.test.ts
    • Changed import of keyMatchers to defaultKeyMatchers.
    • Updated usage of keyMatchers[command] to defaultKeyMatchers[command].
  • packages/cli/src/ui/keyMatchers.ts
    • Renamed the exported keyMatchers constant to defaultKeyMatchers.
Activity
  • No human activity has been recorded on this pull request yet.
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.

@github-actions
Copy link

github-actions bot commented Mar 9, 2026

Size Change: +1.79 kB (+0.01%)

Total Size: 26.1 MB

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

compressed-size-action

@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 9, 2026
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 introduces a new useKeyMatchers hook and refactors numerous UI components to use it, centralizing the logic for keybinding matching. The changes are consistent and correctly applied across the codebase, including updating hook dependency arrays where necessary. The tests have also been updated to align with the refactoring. I have reviewed the changes and found no issues; the refactoring is well-executed and improves the codebase for future enhancements to keybindings.

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

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

@scidomino scidomino enabled auto-merge March 9, 2026 20:34
@scidomino scidomino added this pull request to the merge queue Mar 9, 2026
Merged via the queue into main with commit ab64b15 Mar 9, 2026
27 checks passed
@scidomino scidomino deleted the tomm_matcher branch March 9, 2026 21:04
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