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

This commit is contained in:
adithya32
2026-05-21 03:11:34 +05:30
committed by GitHub
parent 96903d50a1
commit 64cb88d50e
4 changed files with 64 additions and 12 deletions
@@ -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 {