fix(cli): correct backspace handling in Windows Terminal#25862
fix(cli): correct backspace handling in Windows Terminal#25862secreal wants to merge 3 commits intogoogle-gemini:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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 addresses an issue where the backspace key was incorrectly triggering word-deletion behavior in Windows Terminal. By adjusting the input interpretation logic to account for the presence of the Kitty keyboard protocol and Windows Terminal sessions, the change ensures that standard backspace inputs are handled correctly as single-character deletions while maintaining necessary legacy support for other Windows console environments. 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 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 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refines the backspace key handling in KeypressContext.tsx by incorporating checks for the Kitty keyboard protocol and Windows Terminal sessions. It ensures that the \b character is only treated as Ctrl+Backspace in legacy Windows console environments where Kitty is disabled and no WT_SESSION is active. The changes include updated logic in the key emitter and new test cases in KeypressContext.test.tsx to validate the behavior across different terminal configurations. I have no feedback to provide.
|
Tested on v0.41.0-nightly.20260423 (Windows 11, Windows Terminal). I can confirm the backspace bug persists even when manually setting: In this version, the standard Backspace (and Ctrl+H) still incorrectly triggers deleteWordLeft, while Ctrl + Backspace is currently the only way to delete a single character (deleteLeft). It appears the CLI's keyboard handler is defaulting to a legacy \x08 fallback for Windows that forces the Ctrl modifier to true, regardless of the environment variables or the terminal being used (Windows Terminal vs. legacy console). This report is intended to help validate that the logic in this PR. |
|
@TiagoSimoes1990 #25882 fixes the reported input issues by narrowing the scope of the \b (backspace) handler. The previous logic was over-generalizing all Windows environments, forcing ctrl: true even in legacy consoles (CMD/PowerShell) where \b is a standard backspace. |
|
Hey @secreal, thanks for your work on #25862. I've been digging into the root cause and found the key issue is a missing mapping for key code To clarify the context:
Your PR tries to rely on environment variables and Kitty availability to gate the The right solution is to let The key change required is simply: const KITTY_CODE_MAP: Record<number, string> = {
// ... existing mappings
8: 'backspace', // Add this line
};This properly decodes the |
Thanks for digging into this and for the detailed explanation. After upgrading from Node 22 to Node 24.15.0, I can no longer reproduce the keyboard issue on my side. So in my case, this appears to have been tied to the older runtime/environment rather than something I still need to fix with this PR. Your explanation and PR #25943 make sense to me, especially the part about handling I’m going to close this PR for now. Thanks again for the investigation and for working on a cleaner fix |
Summary
Fix incorrect backspace handling in Windows Terminal.
In some Windows Terminal setups, normal
Backspacecould be treated likeCtrl+Backspace, causing it to delete the previous word instead of a single character.Details
This change narrows the Windows fallback that interprets raw
\basCtrl+Backspace.The fallback is now disabled in Windows Terminal (
WT_SESSION) and remains available only for non-Windows-Terminal Windows consoles where that behavior may still be needed.Regression coverage was also added for the Windows Terminal case.
Related Issues
Fixes #25856
How to Validate
npm --workspace @google/gemini-cli test -- src/ui/contexts/KeypressContext.test.tsxPre-Merge Checklist