fix(windows): resolve interactive shell arrow-key navigation on Windows#23505
fix(windows): resolve interactive shell arrow-key navigation on Windows#23505KumarADITHYA123 wants to merge 3 commits intogoogle-gemini:mainfrom
Conversation
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 critical issues on Windows where interactive CLI tools, particularly those relying on arrow-key navigation, would become unresponsive or crash when run through the Gemini CLI's PTY shell. The changes involve fine-tuning PowerShell launch arguments and 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 effectively addresses the interactive shell arrow-key navigation issues on Windows by correctly configuring PowerShell arguments and PTY options. The changes to shellExecutionService.ts and shell-utils.ts implement the necessary platform-specific adjustments for handleFlowControl and useConpty, and introduce the -NonInteractive flag for PowerShell. The corresponding test updates ensure that these new configurations are correctly applied and verified. The improved isPtyActive check in shellExecutionService.ts also enhances the reliability of process status detection on Windows. The tests should be updated to avoid directly modifying process.env and use hardcoded literal values instead of importing constants.
Three compounding issues caused interactive TUI tools (pnpm create vite, npm create, etc.) to crash on arrow-key press when running through Gemini CLI's PTY shell on Windows 10/11. Root Causes: 1. PSReadLine intercepting ConPTY console input - PowerShell was launched without -NonInteractive, leaving PSReadLine active inside the ConPTY session. 2. handleFlowControl: true interfering with ConPTY input routing - The XON/XOFF interception performed by handleFlowControl in @lydell/node-pty disrupts ConPTY's internal input pipeline on Windows. 3. isPtyActive false-negative on Windows - process.kill(pid, 0) behaves inconsistently for ConPTY-managed shell wrappers (powershell.exe). Changes: - shell-utils.ts: Added -NonInteractive to PowerShell argsPrefix - shellExecutionService.ts: Set handleFlowControl to false on Windows; added useConpty: true on Windows; check activePtys map before process.kill(pid, 0) for reliable process status detection Closes google-gemini#20675
e366617 to
514547b
Compare
|
/gemini review' |
|
Acknowledged. I am now performing a detailed code review of the pull request. I will post my findings and suggestions shortly. |
|
/gemini review' |
There was a problem hiding this comment.
Code Review
The pull request effectively addresses the issues with interactive shell arrow-key navigation on Windows. The changes correctly implement the necessary adjustments for handleFlowControl, useConpty, and PSReadLine interference, as well as improving the reliability of isPtyActive checks. The updated tests reflect these changes and align with the project's testing conventions for environment variables, which is a good improvement for test maintainability and reliability.
|
Hi |
|
Hii @cocosheng-g |
|
@KumarADITHYA123 have you done thorough testing on windows by npm run start and interact with it? |
|
Hi @cocosheng-g, Yes, I have tested this thoroughly on Windows. I ran |
Problem On Windows 10/11, pressing arrow keys inside interactive CLI tools (e.g., pnpm create vite) through Gemini CLI's PTY shell caused the interactive window to crash and the CLI to become unresponsive. Closes #20675.
Root Causes & Changes
PSReadLine interference: PowerShell was launching without -NonInteractive, allowing PSReadLine hooks to intercept VT key events meant for child process TUI libraries (@clack/prompts, etc.). -> Fix: Added -NonInteractive to Windows powershellArgsPrefix.
Flow Control interception: handleFlowControl: true in node-pty disrupts ConPTY's input pipeline on Windows, causing missed key events. -> Fix: Set handleFlowControl: false on Windows.
WinPTY fallback: Missing useConpty flag allowed silent fallbacks to WinPTY on older builds. -> Fix: Added useConpty: true on Windows.
isPtyActive false-negatives: process.kill(pid, 0) is unreliable for ConPTY wrappers, causing writeToPty to silently discard arrow-key writes. -> Fix: Check activePtys.has(pid) first for reliable status detection.
Testing
Validated pnpm create vite on Windows 10 works with Up/Down arrow navigation.
All 118 unit tests passing.