Windows support for the embedded Claude session (ConPTY) - #7
Draft
simplaerai-sv wants to merge 1 commit into
Draft
Windows support for the embedded Claude session (ConPTY)#7simplaerai-sv wants to merge 1 commit into
simplaerai-sv wants to merge 1 commit into
Conversation
simplaerai-sv
marked this pull request as draft
August 16, 2026 13:52
simplaerai-sv
force-pushed
the
win32-embedded-claude
branch
from
August 16, 2026 13:58
f71d37d to
934ea30
Compare
The Claude panel was POSIX-only and died on Windows with "File not found" before the CLI even started. Three win32 branches, POSIX path untouched: - which(): resolve via where.exe, preferring .exe/.cmd/.bat — npm puts an extensionless sh shim first, which Windows cannot exec - spawn: no bash watchdog wrapper; .cmd/.bat shims route through cmd.exe /c under ConPTY. Closing the pty tears down the attached console tree, so a hard Electron death still takes claude with it - closeSession(): pty.kill() instead of process.kill(-pid, SIGHUP) — negative-pid group signals throw on Windows Tested on Windows 11 (26200), Node 24, claude CLI 2.1.233: panel opens, all six kadr_* MCP tools reachable from the embedded session. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
simplaerai-sv
force-pushed
the
win32-embedded-claude
branch
from
September 8, 2026 06:06
934ea30 to
41967c9
Compare
lt3-me
added a commit
to lt3-me/kadr
that referenced
this pull request
Sep 9, 2026
…lpFreedom#7 in view PR HelpFreedom#7 (simplaerai-sv, «Windows support for the embedded Claude session») solves the same failure on the v0.3 base. This compares the two and takes the one idea from it worth taking. ### Taken: the explicit cmd.exe route `winLaunch` now starts a `.cmd`/`.bat` launcher — npm's `claude.cmd` shim — through `%ComSpec%` itself instead of letting CreateProcess supply the interpreter. Two things come with that. `/d` skips the registry AutoRun (this machine has clink there; a conda hook is the other usual tenant), which otherwise runs inside the panel's cmd.exe and can print into it. And the quoting becomes ours: `/s` plus an outer pair of quotes around the whole line, which keeps a launcher path with a space in it whole. That last part is where PR HelpFreedom#7's version breaks. It spawns `cmd.exe /c "<shim>" args...` bare, and cmd's parser strips the first and the last quote of its command when the first character is a quote — so `"C:\Users\Jane Doe\AppData\Roaming\npm\claude.cmd" --mcp-config ...` becomes `C:\Users\Jane Doe\...` and cmd stops at `C:\Users\Jane`. A user name with a space is not exotic. Verified with a shim in a directory with a space: bare `/c` fails as described, the outer-quoted form and the implicit CreateProcess form both deliver every argument intact, inner quotes and non-ASCII included. ### Not taken: `where.exe` PR HelpFreedom#7 resolves the CLI with `where.exe` and prefers an `.exe`/`.cmd`/`.bat` hit, falling back to the first line — which is npm's extensionless sh shim, the file ConPTY cannot start. The PATH walk here uses PATHEXT, so that shim is never a candidate; it searches the SESSION's PATH, which claude-env.json may extend; and it checks `~/.local/bin`, the native installer's directory, for an editor launched from a desktop entry whose PATH has not caught up. It also spawns no helper process. Session teardown is the same in both: `pty.kill()` on Windows, node-pty's ConPTY kill enumerating the console's process list. ### Verification, on the real UI this time Windows 11, claude 2.1.265 from npm, the panel driven by hand: - open → one `cmd.exe /d /s /c "…claude.CMD …"` and one claude.exe; - close → nothing left; close-and-reopen in quick succession → exactly one tree; quit the editor with the panel open → nothing left; - `/mcp` inside the panel: kadr connected, 13 tools; the same 13 over a stdio client spawning mcp-bridge.cjs like claude does; kadr_state and kadr_eval answer; /eval refuses a request without the token and one carrying an Origin (403 both); - close/reopen regenerates kadr-mcp.json with a fresh bridge port; - the trust dialog that appears with no project open is the CLI's own: the panel starts in the home directory then, and the CLI does not persist trust for it even when run from a plain terminal. Co-Authored-By: Claude Fable 5.1 <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.
Problem
On Windows the Claude panel dies immediately with
Error: File not found— the session spawn path is POSIX-only:a
/bin/bashwatchdog wrapper,/bin/sh command -v, and negative-pidgroup signals.
Changes
One file,
electron/claude.ts, win32 branches only — the POSIX path isuntouched:
which(): resolve viawhere.exe, preferring.exe/.cmd/.bat. npminstalls an extensionless sh shim next to
claude.cmdand lists itfirst; Windows cannot exec it.
.cmd/.batshims are routed throughcmd.exe /c(a shim cannot beCreateProcess'd directly). Closing thepty tears down the attached ConPTY console tree, so a hard Electron
death still takes claude with it — the guarantee the wrapper provides
on POSIX.
killSession():pty.kill()instead ofprocess.kill(-pid, SIGHUP)—negative-pid group signals are a POSIX concept and throw on Windows.
Tested
Windows 11 (build 26200), Node 24, claude CLI 2.1.233:
kadr_*MCP tools are reachable from the embedded sessionkadr-mcp.jsonwith a fresh bridge portHonest caveat: that run was against the v0.3.0 base. The branch has
since been rebased onto v0.5.1, so it now sits on top of the session
generation/serialization rework and
sessionEnv(). The merge resolutionkeeps both — upstream session identity, plus the win32 spawn branch —
and
tsc -p tsconfig.node.jsonis clean, but the rebased build has notbeen re-run on Windows yet. Happy to confirm before you merge.
No file overlap with the other open Windows PR (#9, which fixes
npm installand the dev-server bind), nor with #3 (macOS) or #5 (NixOS).🤖 Generated with Claude Code