Repository navigation
fix(hub): run .cmd/.bat shims in PTY sessions on Windows - #465
Merged
Merged
Conversation
|
@huang-julien is attempting to deploy a commit to the NuxtLabs Team on Vercel. A member of the Team first needs to authorize it. |
|
👁️🗨️ Review this pull request with grouped, summarized diffs at: raw result💭 analyzed by {
"headSha": "6ed7cfe7bf871b343077b6ca02702d21d9c23d7c",
"result": {
"overallSummary": "Fixes a Windows bug where PTY sessions failed to launch `.cmd`/`.bat` shims (pnpm, npx, yarn, etc.) because the native terminal API only spawns real `.exe` programs. The fix adds a `resolvePtyCommand()` helper that detects shim commands and routes them through `cmd.exe`, matching the existing non-PTY `startChildProcess()` path, with careful argument escaping and accompanying tests.",
"groups": [
{
"key": "pty-cmd-shim-fix",
"label": "PTY .cmd/.bat shim support",
"summary": "Adds `resolvePtyCommand()` to detect when a PTY command resolves to a `.cmd`/`.bat` shim (e.g. pnpm, npx, yarn) that ConPTY can't spawn directly, and routes it through `cmd.exe` instead, mirroring the existing `startChildProcess()` behavior. Also handles argument escaping so metacharacters survive `cmd.exe`'s double parsing for batch shims.",
"category": "core",
"filePaths": [
"packages/hub/src/node/pty-command.ts",
"packages/hub/src/node/host-terminals.ts"
],
"fileNotes": [
{
"path": "packages/hub/src/node/pty-command.ts",
"text": "Core logic: resolves the executable via PATH/PATHEXT, decides whether to wrap with `cmd.exe /d /c`, and escapes arguments for cmd metacharacters (with double-escaping for `.bat`/`.cmd` shims). Subtle quoting/escaping rules are documented inline but worth double-checking given known limits noted in comments.",
"critical": true
}
]
},
{
"key": "tests",
"label": "Tests for PTY shim resolution",
"summary": "Adds unit tests for `resolvePtyCommand()` covering shim detection, escaping and platform fallbacks, plus a Windows-only PTY integration test spawning a real `.cmd` shim.",
"category": "tests",
"filePaths": [
"packages/hub/src/node/__tests__/host-terminals.test.ts",
"packages/hub/src/node/__tests__/pty-command.test.ts"
]
}
],
"schemaVersion": 1,
"source": "llm",
"generatedAt": "2026-10-30T22:10:52.851Z",
"model": "vercel-ai-gateway/anthropic/claude-sonnet-5",
"locale": "en"
}
} |
- Skip `^` escaping for args with a backslash or tab too, since zigpty quotes those and `cmd.exe` keeps quoted text as-is. - Lower-case PATHEXT so the lookup works on case-sensitive filesystems (the unit tests failed on Linux). - Note the known limit for shims passed by path with quoted args. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix #463
descirption
On Windows, PTY sessions could not start commands like pnpm, npx or yarn that are .cmd scripts and the Windows terminal API only launches real .exe programs.
The change detects that case and runs the command through cmd.exe instead, the way
startChildProcess()already does.