Skip to content

feat(cli): update undo/redo keybindings to Cmd+Z/Alt+Z and Shift+Cmd+Z/Shift+Alt+Z#17800

Merged
scidomino merged 1 commit intomainfrom
tomm_undoredo
Jan 28, 2026
Merged

feat(cli): update undo/redo keybindings to Cmd+Z/Alt+Z and Shift+Cmd+Z/Shift+Alt+Z#17800
scidomino merged 1 commit intomainfrom
tomm_undoredo

Conversation

@scidomino
Copy link
Copy Markdown
Collaborator

@scidomino scidomino commented Jan 28, 2026

Summary

This PR updates the keyboard shortcuts for Undo and Redo in the Gemini CLI. The new shortcuts are:

  • Undo: Cmd + Z or Alt/Opt + Z
  • Redo: Shift + Cmd + Z or Shift + Alt/Opt + Z

Details

We need to free up Ctrl+z for suspending.

Also: Increase warning toast from 1s to 3s.

Related Issues

References #5018

How to Validate

  1. Run the CLI: npm start
  2. Type some text in the prompt.
  3. Press Cmd + Z or Alt + Z to undo.
  4. Press Shift + Cmd + Z or Alt + Shift + Z to redo.
  5. Verify that the actions are performed correctly and the UI remains responsive.
  6. Run unit tests: npm test -w @google/gemini-cli -- src/ui/keyMatchers.test.ts

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

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @scidomino, 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 introduces a significant update to the Gemini CLI's Undo and Redo keyboard shortcuts. By transitioning from Ctrl+Z to Cmd+Z/Alt+Z for Undo and Shift+Cmd+Z/Shift+Alt+Z for Redo, the CLI now offers a more intuitive and consistent editing experience, particularly for macOS users, while also resolving conflicts with standard terminal job control commands.

Highlights

  • Keybinding Update: Changed Undo/Redo shortcuts to Cmd+Z/Alt+Z and Shift+Cmd+Z/Shift+Alt+Z respectively.
  • macOS Standard Alignment: Aligns CLI editing with standard macOS keyboard conventions.
  • Conflict Resolution: Addresses issues where the previous Ctrl+Z binding conflicted with terminal job control.
  • Alt Key Handling: Enhanced MAC_ALT_KEY_CHARACTER_MAP to correctly interpret macOS-specific character sequences for Alt+Z and Shift+Alt+Z.
  • Documentation & Tests: Updated user documentation and unit tests to reflect the new keybindings.
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
Copy Markdown

github-actions bot commented Jan 28, 2026

Size Change: +433 B (0%)

Total Size: 23.5 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 23.5 MB +433 B (0%)
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB 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-closed.sb 3.29 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

compressed-size-action

Copy link
Copy Markdown
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 updates the undo/redo keybindings to be more idiomatic for macOS users (Cmd+Z/Alt+Z), while also resolving the common terminal conflict with Ctrl+Z. The changes are comprehensive, covering not only the keybinding configuration but also the necessary low-level keypress handling for special Alt key characters on macOS. The documentation, user-facing tips, and tests have all been updated consistently. The refactoring in KeypressContext.tsx to handle complex key combinations with modifiers is a solid improvement. Overall, this is a well-executed enhancement.

@scidomino scidomino marked this pull request as ready for review January 28, 2026 19:07
@scidomino scidomino requested review from a team as code owners January 28, 2026 19:07
@gemini-cli gemini-cli bot added priority/p2 Important but can be addressed in a future release. 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! labels Jan 28, 2026
@jacob314 jacob314 self-requested a review January 28, 2026 19:54
Copy link
Copy Markdown
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.

Can we add showing a Toast when users press ctrl-Z or ctrl-shift-z as part of this PR?
That way existing users won't be confused. Make the toasts like the one shown for ctrl-C but probably tweak the timing so it shows for a couple seconds. All the toasts currently show for a bit too short a time.

@scidomino scidomino force-pushed the tomm_undoredo branch 3 times, most recently from 0255db3 to 80fd057 Compare January 28, 2026 22:02
- **Undo:**
- **Keyboard shortcut:** Press **Ctrl+z** to undo the last action in the input
prompt.
- **Keyboard shortcut:** Press **Cmd+z** or **Alt+z** to undo the last action
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.

Nit: mention that Alt-Z is not supported on mac.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Eh. I figured, on mac they call it the "opt" key instead of "alt".

setShowErrorDetails((prev) => !prev);
return true;
} else if (keyMatchers[Command.SUSPEND_APP](key)) {
handleWarning('Undo has been moved to Cmd + Z or Alt/Opt + Z');
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.

Nit: show a consistent message for redo.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Actually, instead I will just contrinue to support ctrl+shift+Z

Copy link
Copy Markdown
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 added this pull request to the merge queue Jan 28, 2026
Merged via the queue into main with commit 553ae3a Jan 28, 2026
25 checks passed
@scidomino scidomino deleted the tomm_undoredo branch January 28, 2026 23:06
sidwan02 pushed a commit to sidwan02/gemini-cli-gemma that referenced this pull request Feb 6, 2026
kuishou68 pushed a commit to iOfficeAI/aioncli that referenced this pull request Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. priority/p2 Important but can be addressed in a future release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants