diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts index 44570203c..3663beb8f 100644 --- a/packages/core/src/config/config.ts +++ b/packages/core/src/config/config.ts @@ -96,6 +96,7 @@ import { // Utils import { shouldAttemptBrowserLaunch } from '../utils/browser.js'; import { FileExclusions } from '../utils/ignorePatterns.js'; +import { shouldDefaultToNodePty } from '../utils/shell-utils.js'; import { WorkspaceContext } from '../utils/workspaceContext.js'; import { isToolEnabled, type ToolName } from '../utils/tool-utils.js'; import { getErrorMessage } from '../utils/errors.js'; @@ -636,7 +637,8 @@ export class Config { this.webSearch = params.webSearch; this.useRipgrep = params.useRipgrep ?? true; this.useBuiltinRipgrep = params.useBuiltinRipgrep ?? true; - this.shouldUseNodePtyShell = params.shouldUseNodePtyShell ?? true; + this.shouldUseNodePtyShell = + params.shouldUseNodePtyShell ?? shouldDefaultToNodePty(); this.skipNextSpeakerCheck = params.skipNextSpeakerCheck ?? true; this.shellExecutionConfig = { terminalWidth: params.shellExecutionConfig?.terminalWidth ?? 80, diff --git a/packages/core/src/utils/shell-utils.ts b/packages/core/src/utils/shell-utils.ts index 1f0476866..1c839530f 100644 --- a/packages/core/src/utils/shell-utils.ts +++ b/packages/core/src/utils/shell-utils.ts @@ -913,3 +913,13 @@ export function isCommandNeedsPermission(command: string): { reason: 'Command requires permission to execute.', }; } + +// ConPTY on Windows builds <= 19041 has known reliability issues (missing +// output, hangs). VS Code uses the same cutoff: microsoft/vscode#123725. +const CONPTY_MIN_WINDOWS_BUILD = 19042; + +export function shouldDefaultToNodePty(): boolean { + if (os.platform() !== 'win32') return true; + const build = parseInt(os.release().split('.')[2] ?? '', 10); + return !isNaN(build) && build >= CONPTY_MIN_WINDOWS_BUILD; +}