Skip to content

fix(windows): resolve interactive shell arrow-key navigation on Windows#23505

Open
KumarADITHYA123 wants to merge 3 commits intogoogle-gemini:mainfrom
KumarADITHYA123:fix/windows-pty-arrow-keys
Open

fix(windows): resolve interactive shell arrow-key navigation on Windows#23505
KumarADITHYA123 wants to merge 3 commits intogoogle-gemini:mainfrom
KumarADITHYA123:fix/windows-pty-arrow-keys

Conversation

@KumarADITHYA123
Copy link
Copy Markdown
Contributor

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.

@KumarADITHYA123 KumarADITHYA123 requested a review from a team as a code owner March 23, 2026 03:18
@gemini-code-assist
Copy link
Copy Markdown
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 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 node-pty configurations specifically for Windows, ensuring proper handling of input and reliable process status detection. These adjustments aim to provide a stable and functional interactive terminal experience on Windows platforms.

Highlights

  • PowerShell Configuration: Added the -NonInteractive flag to PowerShell arguments on Windows to prevent PSReadLine interference, which caused interactive CLI tools to crash or become unresponsive.
  • Node-PTY Options for Windows: Disabled handleFlowControl and explicitly enabled useConpty for node-pty spawns on Windows to resolve issues with input routing and silent fallbacks to WinPTY.
  • Process Activity Check Reliability: Improved the isActive check for PTY processes on Windows by first consulting an internal map (activePtys) to avoid false negatives when process.kill(pid, 0) is unreliable for ConPTY-managed shells.
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.

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
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 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.

Comment thread packages/core/src/utils/shell-utils.test.ts Outdated
Comment thread packages/core/src/utils/shell-utils.test.ts Outdated
Comment thread packages/core/src/utils/shell-utils.test.ts Outdated
Comment thread packages/core/src/utils/shell-utils.test.ts Outdated
Comment thread packages/core/src/utils/shell-utils.test.ts Outdated
@gemini-cli gemini-cli bot added priority/p2 Important but can be addressed in a future release. area/core Issues related to User Interface, OS Support, Core Functionality help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! labels Mar 23, 2026
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
@KumarADITHYA123 KumarADITHYA123 force-pushed the fix/windows-pty-arrow-keys branch from e366617 to 514547b Compare March 23, 2026 13:28
@KumarADITHYA123
Copy link
Copy Markdown
Contributor Author

/gemini review'

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Acknowledged. I am now performing a detailed code review of the pull request. I will post my findings and suggestions shortly.

@KumarADITHYA123
Copy link
Copy Markdown
Contributor Author

/gemini review'

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

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.

@KumarADITHYA123
Copy link
Copy Markdown
Contributor Author

Hi
@spencer426,@jacob314
PTAL , resolved all the issues.
Please rerun CI checks and review the PR.

@KumarADITHYA123
Copy link
Copy Markdown
Contributor Author

Hii @cocosheng-g
PTAL,resolved all the issue.
Please run cl checks and review the PR.

@cocosheng-g
Copy link
Copy Markdown
Contributor

@KumarADITHYA123 have you done thorough testing on windows by npm run start and interact with it?

@KumarADITHYA123
Copy link
Copy Markdown
Contributor Author

Hi @cocosheng-g,

Yes, I have tested this thoroughly on Windows.

I ran npm run start and verified interactive behavior, including arrow-key navigation, and everything is working as expected.

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 help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! priority/p2 Important but can be addressed in a future release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Interactive shell does not show properly on Windows 10 when using arrow keys in external subshell prompts (v0.31.0)

2 participants