Skip to content

undo#18147

Merged
jacob314 merged 3 commits intomainfrom
undo
Feb 5, 2026
Merged

undo#18147
jacob314 merged 3 commits intomainfrom
undo

Conversation

@jacob314
Copy link
Contributor

@jacob314 jacob314 commented Feb 2, 2026

Summary

We recently switched to option-z instead of ctrl-z for und. Unfortunately this breaks vscode and iterm.

  • Handle option-Z
  • Fix undo in vscode and iterm2.

Details

Fixed by adding iterm2 handling for alt-Z and shift+alt-Z that works as long as the language is not Greek as these are common letters in greek.

Removed check for ITERM_SESSION_ID that was making us think vscode terminals where iterm2 terminals if vscode was launched from iterm2.

Related Issues

Fixes #18148

@jacob314 jacob314 requested review from a team as code owners February 2, 2026 23:56
@gemini-cli
Copy link
Contributor

gemini-cli bot commented Feb 2, 2026

Hi @jacob314, thank you so much for your contribution to Gemini CLI! We really appreciate the time and effort you've put into this.

We're making some updates to our contribution process to improve how we track and review changes. Please take a moment to review our recent discussion post: Improving Our Contribution Process & Introducing New Guidelines.

Key Update: Starting January 26, 2026, the Gemini CLI project will require all pull requests to be associated with an existing issue. Any pull requests not linked to an issue by that date will be automatically closed.

Thank you for your understanding and for being a part of our community!

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jacob314, 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 delivers significant improvements to the undo and redo functionality, making it more robust and user-friendly across different environments. It specifically addresses challenges with Option+Z key combinations in various terminal emulators, including a critical fix for Greek locale users to prevent unintended undo actions when typing the Omega character. Additionally, it streamlines the setup process for VSCode users by automatically configuring essential undo/redo keybindings and refines iTerm2 detection for more accurate user feedback.

Highlights

  • Enhanced Undo/Redo Keybinding Recognition: Improved the KeypressContext to accurately interpret Option+Z and Option+Shift+Z across various terminal emulators (iTerm2, VSCode, Ghostty, MacTerminal), ensuring consistent undo/redo functionality.
  • Greek Locale Compatibility for Option+Z: Introduced specific logic to prevent Option+Z from triggering an undo action when a Greek locale is detected and the input character is Ω, allowing users to type the Omega character naturally.
  • Automated VSCode Undo/Redo Keybinding Setup: The terminalSetup utility now automatically configures Cmd+Z, Alt+Z, Shift+Cmd+Z, and Shift+Alt+Z keybindings in VSCode to ensure native undo/redo behavior.
  • Refined iTerm2 Detection and User Feedback: Simplified the isITerm2 detection mechanism and updated the SUSPEND_APP warning message to provide iTerm2-specific guidance for the undo shortcut.
  • Documentation and Tip Alignment: Updated user-facing documentation and in-app tips to reflect the correct Alt+Z / Cmd+Z order for undo/redo shortcuts.
Changelog
  • docs/cli/commands.md
    • Reordered keyboard shortcuts for undo/redo in the CLI commands documentation.
  • packages/cli/src/ui/AppContainer.tsx
    • Updated the warning message for the SUSPEND_APP command to provide iTerm2-specific guidance for the undo shortcut.
  • packages/cli/src/ui/constants/tips.ts
    • Adjusted the order of keyboard shortcuts for undo/redo in informative tips.
  • packages/cli/src/ui/contexts/KeypressContext.greek.test.tsx
    • Added a new test file to validate the correct handling of Option+Z in Greek locales.
  • packages/cli/src/ui/contexts/KeypressContext.test.tsx
    • Expanded existing keypress tests to include Alt+Z and Shift+Alt+Z scenarios across different terminal types.
  • packages/cli/src/ui/contexts/KeypressContext.tsx
    • Modified the MAC_ALT_KEY_CHARACTER_MAP to include Option+Z and Option+Shift+Z mappings.
    • Implemented locale-aware logic to prevent Option+Z from triggering undo in Greek locales.
  • packages/cli/src/ui/utils/snapshots/terminalSetup.test.ts.snap
    • Updated the snapshot for VSCode keybindings to reflect the addition of undo/redo shortcuts.
  • packages/cli/src/ui/utils/terminalSetup.test.ts
    • Modified tests to verify the automatic configuration of new undo/redo keybindings in VSCode.
  • packages/cli/src/ui/utils/terminalSetup.ts
    • Enhanced the VSCode terminal setup to automatically add keybindings for Cmd+Z, Alt+Z, Shift+Cmd+Z, and Shift+Alt+Z.
  • packages/cli/src/ui/utils/terminalUtils.test.ts
    • Removed the ITERM_SESSION_ID environment variable check from iTerm2 detection tests.
  • packages/cli/src/ui/utils/terminalUtils.ts
    • Simplified the isITerm2 utility function to rely solely on the TERM_PROGRAM environment variable.
Activity
  • No human activity has been recorded on this pull request since its creation.
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 introduces fixes for the undo/redo functionality, particularly for VSCode and iTerm2 users, and adds better support for non-English keyboard layouts like Greek. The changes include updating keybinding documentation, adding specific key handling for Option+Z on macOS, and automatically configuring VSCode keybindings to ensure undo/redo works correctly. The addition of new tests, including for the Greek locale, is a great improvement.

My review focuses on two areas for improvement: reducing code duplication in the VSCode setup script for better maintainability, and restoring a more robust method for detecting iTerm2 to avoid potential regressions.

cachedIsITerm2 =
process.env['TERM_PROGRAM'] === 'iTerm.app' ||
!!process.env['ITERM_SESSION_ID'];
cachedIsITerm2 = process.env['TERM_PROGRAM'] === 'iTerm.app';
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The check for ITERM_SESSION_ID has been removed from the isITerm2 detection logic. While TERM_PROGRAM works for local sessions, ITERM_SESSION_ID is a more robust check that also works in other scenarios, such as over SSH where TERM_PROGRAM may not be forwarded. Removing this check could be a regression, making iTerm2 detection less reliable. Unless there was a specific reason to remove it, it would be best to restore this check for more robust terminal detection.

Suggested change
cachedIsITerm2 = process.env['TERM_PROGRAM'] === 'iTerm.app';
cachedIsITerm2 =
process.env['TERM_PROGRAM'] === 'iTerm.app' ||
!!process.env['ITERM_SESSION_ID'];

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is intentional because otherwise if you run VSCode launching it from iterm2 we believe the vscode terminal is an iterm2 terminal which is not what we want.

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

Size Change: +896 B (0%)

Total Size: 23.7 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 23.7 MB +896 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

@jacob314
Copy link
Contributor Author

jacob314 commented Feb 3, 2026

I've reviewed the PR and made some optimizations and refactorings:

  1. KeypressContext.tsx: Optimized the Greek locale check by moving it outside the loop and making it more robust ().
  2. terminalSetup.ts: Refactored the repetitive VS Code keybinding validation and configuration logic into a more maintainable loop-based structure.
  3. Terminal Utils: Simplified iTerm2 detection by removing the redundant check.

All tests are passing.

@jacob314
Copy link
Contributor Author

jacob314 commented Feb 3, 2026

Fyi @scidomino when you are back take a look at this to make sure there is nothing we need to fix.

@jacob314 jacob314 removed the request for review from jackwotherspoon February 3, 2026 00:35
@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 Feb 3, 2026
With the fix option-z works in both and cmd+z works in vscode (after running /terminal-setup)
@jacob314 jacob314 enabled auto-merge February 5, 2026 18:36
@jacob314 jacob314 added this pull request to the merge queue Feb 5, 2026
Merged via the queue into main with commit 258643d Feb 5, 2026
25 of 26 checks passed
@jacob314 jacob314 deleted the undo branch February 5, 2026 19:14
sidwan02 pushed a commit to sidwan02/gemini-cli-gemma that referenced this pull request Feb 6, 2026
aswinashok44 pushed a commit to aswinashok44/gemini-cli that referenced this pull request Feb 9, 2026
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.

Undo is broken in iterm2 and vscode

2 participants