Files
magpie/internal/wslrun
yetone fb9c176756 claudetui: Claude Code in WSL runs in its interactive mode too
A Claude Code found in a WSL distro (Windows has none of its own) was
always claude -p, the entrypoint the plan counts at about twice the
interactive mode's. Many Windows users run it there.

The Windows helper now runs wsl.exe in its pseudo console. The gateway
hands it MAGPIE_CLAUDE_TUI_WSL (claudetui.WSL, claudeCLI.tuiWSL): the
wsl.exe arguments up to Claude Code's (wslrun.Tool.Args, with
MAGPIE_WSL_RUN), the distro's mount, and the projects folder as Windows
reads it. That is the account's config directory, handed in through
CLAUDE_CONFIG_DIR/p, or the distro user's own ~/.claude/projects
through \\wsl$\<distro> (wslrun.Tool.Home, a new line in the probe;
wslrun.Tool.Windows). TERM is added to WSLENV, and an image's path is
pasted as the distro reads it (/mnt/c/…). The helper is the Windows
magpie.exe, not the /mnt/c/… path the MCP helper starts at; the first
real run failed on exactly that (fork/exec /mnt/c/...magpie.exe). The
gate keeps -p for a WSL Claude Code whose home is unknown, and, in the
distro user's own folder, when Windows can't stat \\wsl$\<distro>\<home>
(tuiWSLUnread): over ssh it can't (no 9P redirector), and the helper
would wait for a transcript it can't see. Doc updated.

Run:
- go test ./internal/claudetui ./internal/wslrun on mote and on Windows
  11 (xiaomi-gpu): ok. New: TestShimInWSL (image path, WSLENV),
  TestClaudeTUIWSL (projects folder both ways, wsl args), the home in
  the probe and Windows() in wslrun, the gate's two WSL cases, TestClaudeTUIWSLUnread.
- go test -run 'Claude|Refusal|Thinking' ./internal/gateway on mote: ok.
- go vet of claudetui, gateway, wslrun for darwin, linux, windows
  (-tags nogui, and the main package for windows); gofmt -l clean.
- Real account on xiaomi-gpu: a sandbox HOME gateway (3462) with no
  Windows Claude Code reachable (PATH trimmed, MAGPIE_TEST_SANDBOX so
  the registry PATH isn't read), the Claude Max account, Claude Code
  2.1.289 in magpie-desktop, haiku-5-5. Tree: helper -> wsl.exe ->
  claude on a pts in the distro, TERM=xterm-256color,
  CLAUDE_CONFIG_DIR=/mnt/c/..., no CLAUDE_CODE_ENTRYPOINT. One tool
  call, two in one message, text then a call, and two image turns: all
  right. Every transcript row "entrypoint":"cli", no "-p" line in the
  log, images noted as /mnt/c/.../magpie-claude-images-*/image-N.png
  and no folder left. Killing the gateway ended its four claude
  processes in the distro within 3s. The token wasn't refreshed; the
  copied credentials were deleted.

Broken by hand: shim.path returning the Windows path unchanged,
TestShimInWSL red; tuiWSLUnread ignoring the stat error,
TestClaudeTUIWSLUnread red.

Not tried: a WSL Claude Code run from the distro user's own ~/.claude
for real (only the account config directory ran; over ssh
\\wsl$\magpie-desktop is unreadable, so that run would be -p, and a
desktop session's \\wsl$ wasn't tried), a distro whose default user is root, a distro not sharing
Windows' loopback (wslrun.Tool.Host set), WSL1.
2026-10-31 17:29:01 +08:00
..