Skip to content

fix(hub): run .cmd/.bat shims in PTY sessions on Windows - #465

Open
huang-julien wants to merge 1 commit into
devframes:mainfrom
huang-julien:fix/windows-pty-cmd-shims
Open

huang-julien wants to merge 1 commit into
devframes:mainfrom
huang-julien:fix/windows-pty-cmd-shims

Conversation

@huang-julien

Copy link
Copy Markdown

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.

@vercel

vercel Bot commented Oct 27, 2026

Copy link
Copy Markdown

@huang-julien is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown

👁️‍🗨️ Review this pull request with grouped, summarized diffs at:
👉 https://pulls.review/gh/devframes/devframe/465?from=github-actions[bot]

raw result

💭 analyzed by vercel-ai-gateway/anthropic/claude-sonnet-5
🕰️ 2026-10-27 16:48 UTC
🔗 head 2cef80a
🤖 automated by pulls.review

{
  "headSha": "2cef80a80bb32481947754d63018df3c4ea7b446",
  "result": {
    "overallSummary": "Fixes PTY sessions on Windows failing to launch `.cmd`/`.bat` shims (pnpm, npx, yarn) because the native terminal API only spawns real `.exe` binaries. A new `resolvePtyCommand()` helper detects such shims and reroutes them through `cmd.exe`, matching the existing child-process spawning logic, with accompanying unit and integration tests.",
    "groups": [
      {
        "key": "pty-cmd-fix",
        "label": "PTY .cmd/.bat shim fix",
        "summary": "Adds `resolvePtyCommand()` to detect Windows `.cmd`/`.bat` shims (e.g. pnpm, npx, yarn) that ConPTY cannot spawn directly, and routes them through `cmd.exe /d /c` with proper metacharacter escaping, mirroring the existing `startChildProcess()` behavior. `host-terminals.ts` now resolves cwd/env once and passes them through this new resolver before spawning the PTY process.",
        "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 real executable via PATH/PATHEXT to decide whether to wrap the command in cmd.exe, and double-escapes metacharacters for batch shims since they reparse their arguments.",
            "critical": true
          }
        ]
      },
      {
        "key": "tests",
        "label": "Tests for PTY shim handling",
        "summary": "Unit tests for `resolvePtyCommand()` covering shim detection, escaping and edge cases, plus a Windows-only integration test verifying an actual `.cmd` shim runs correctly in a PTY session.",
        "category": "tests",
        "filePaths": [
          "packages/hub/src/node/__tests__/pty-command.test.ts",
          "packages/hub/src/node/__tests__/host-terminals.test.ts"
        ]
      }
    ],
    "schemaVersion": 1,
    "source": "llm",
    "generatedAt": "2026-10-27T16:48:04.453Z",
    "model": "vercel-ai-gateway/anthropic/claude-sonnet-5",
    "locale": "en"
  }
}

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

startPtySession fails on Windows for .cmd shims

1 participant