With the interactive mode on, Claude Code in WSL was refused with a 502
in two cases: the distro user's own folder unreadable from Windows
(\\wsl$ needs the 9P redirector, which a session over ssh hasn't;
"wslread") and a distro whose home the probe didn't find ("wsl-home").
Both now run interactively: the helper reads the transcript inside the
distro.
- claudetui/wslread.go: before Claude Code starts, a shell run through
wsl.exe notes how much of $HOME/.claude/projects/*/<sid>.jsonl is
there (a resumed session's earlier turns), says "ready", then tail -F's
the rest; the helper copies it to a file of its own and tails that as
any transcript. When Claude Code ends it waits for the copy to stop
growing (settle), then closes the shell's stdin, which ends it.
- claudetui.WSL gets Distro (Projects omitempty); the gateway's tuiWSL
sets it when Windows can't read the folder or the home is unknown.
- the wslread and wsl-home refusals are gone (claudeTUI, claudeWhy,
claudeNotTUIWhy); the GUI's "wsl-home" reason and its 4 strings too.
- docs/subsystems/claude-subscription-bridge.md says how it is read.
Run, at origin/main ff65ebd14 plus this change (the reader through real
wsl.exe and the break-by-hand at 546cdbde6):
- WSL (magpie-desktop, go1.26.8): go vet -tags nogui, GOOS=windows vet,
GOOS=darwin CGO_ENABLED=0 vet of claudetui ok; go test ./internal/claudetui
ok; go test -run 'Claude|WSL' ./internal/gateway ok (51s);
claude-mode.test.cjs chromium + webkit 44/44; i18n-keys 4/4.
- Windows 11 (xiaomi-gpu): go vet ok; go test ./internal/claudetui ok
but TestShimFirstMessageWaitsForTools, red the same at main 2739626c3
(bee3ea675's test, #4810);
go test -run 'Claude|WSL' ./internal/gateway ok with
TestClaudeAsRootEnv skipped: it is red the same at main 546cdbde6 on
Windows (#2425, a root test where magpie is never root), at 546cdbde6.
- the reader through the real wsl.exe into magpie-desktop (a temporary
test, not committed): ready in 93ms, the line already in the file left
out, two lines written after copied, stopped in 9ms, no tail left in
the distro.
Broken by hand: tuiWSL not setting Distro: TestClaudeTUIWSL red ("its
own folder, unread": Distro empty).
Not tried: a real Claude Code turn in WSL over ssh (real runs stay on
this Mac); mote (its disk is full); the full go test ./... .
44 lines
2.0 KiB
Go
44 lines
2.0 KiB
Go
package claudetui
|
|
|
|
// Command is the hidden subcommand that runs it.
|
|
const Command = "claude-tui-helper"
|
|
|
|
// TrustEnv, "1", has the shim tell Claude Code yes when it asks whether
|
|
// to trust the folder it runs in: the bridge sets it for magpie's own
|
|
// folder, and for a caller's in an account folder of magpie's, whose
|
|
// Claude Code no one else runs. Otherwise the question is the user's to
|
|
// answer in their own Claude Code, and the run ends, saying so.
|
|
const TrustEnv = "MAGPIE_CLAUDE_TUI_TRUST"
|
|
|
|
// Untrusted begins what the helper says, on its stderr, as it ends over a
|
|
// folder it wasn't told to trust: the bridge then runs the turn in a
|
|
// folder of magpie's.
|
|
const Untrusted = "Claude Code asks whether to trust the folder"
|
|
|
|
// WSLEnv holds, as JSON (WSL), how to run a Claude Code that is in a WSL
|
|
// distro: the helper, on Windows, runs wsl.exe in its pseudo console.
|
|
const WSLEnv = "MAGPIE_CLAUDE_TUI_WSL"
|
|
|
|
// WSL is a Claude Code in a WSL distro, as the helper runs it.
|
|
type WSL struct {
|
|
// Args are wsl.exe's arguments up to Claude Code's own, its path last
|
|
Args []string `json:"args"`
|
|
// Mount is where the distro mounts Windows' drives ("/mnt/"): an
|
|
// image's path is pasted as Claude Code there reads it
|
|
Mount string `json:"mount"`
|
|
// Projects is Claude Code's projects folder, as Windows reads it; ""
|
|
// with Distro set when Windows can't, or its home is unknown: the
|
|
// transcript is then read inside the distro (wslread.go)
|
|
Projects string `json:"projects,omitempty"`
|
|
// Distro is the distro, as wsl.exe -d names it
|
|
Distro string `json:"distro,omitempty"`
|
|
}
|
|
|
|
// MCPCommand is the hidden subcommand of magpie's tool server, the MCP
|
|
// server a run's --mcp-config names "magpie" (claudebridge.RunMCP). Its
|
|
// arguments are the callback's file, the tools' file and, for the
|
|
// interactive mode, a file it writes once Claude Code has listed its
|
|
// tools: the first message waits for it (MinhuWang on X: a first message
|
|
// sent before then had none of the agent's tools).
|
|
const MCPCommand = "claude-mcp-helper"
|