mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-03 14:46:46 -07:00
fix(windows): resolve interactive shell arrow-key navigation on Windows (#23505)
This commit is contained in:
@@ -980,6 +980,7 @@ export class ShellExecutionService {
|
||||
cwd: finalCwd,
|
||||
} = prepared;
|
||||
|
||||
const isWindowsPlatform = os.platform() === 'win32';
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const ptyProcess = ptyInfo.module.spawn(finalExecutable, finalArgs, {
|
||||
cwd: finalCwd,
|
||||
@@ -987,7 +988,16 @@ export class ShellExecutionService {
|
||||
cols,
|
||||
rows,
|
||||
env: finalEnv,
|
||||
handleFlowControl: true,
|
||||
// handleFlowControl intercepts XON/XOFF (Ctrl+S/Q) and prevents them
|
||||
// from reaching the child. On Windows, the flag can interfere with
|
||||
// ConPTY's internal input routing and cause interactive TUI tools to
|
||||
// miss key events, so we disable it there.
|
||||
handleFlowControl: !isWindowsPlatform,
|
||||
// On Windows, explicitly request ConPTY (introduced in Windows 10 1809).
|
||||
// Without this, @lydell/node-pty may silently fall back to WinPTY, which
|
||||
// has known incompatibilities with interactive Node.js TUI applications
|
||||
// that rely on VT-sequence-based arrow-key navigation.
|
||||
...(isWindowsPlatform ? { useConpty: true } : {}),
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
@@ -1027,6 +1037,13 @@ export class ShellExecutionService {
|
||||
}).catch(() => {});
|
||||
},
|
||||
isActive: () => {
|
||||
// On Windows, process.kill(pid, 0) can return false negatives
|
||||
// for ConPTY-managed shell wrappers (powershell.exe), causing
|
||||
// writeToPty to silently discard input (including arrow keys).
|
||||
// Check the internal activePtys map first for reliable status.
|
||||
if (ShellExecutionService.activePtys.has(ptyPid)) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
return process.kill(ptyPid, 0);
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user