With Settings' Detect agents in WSL off (noWSLAgents), every Claude
request still reached wsl.exe: wslReady (wslClaudeStandIn,
wslCodexStandIn) and wslClaudeClassifier listed the running distros
without asking wslLooks, the gate #1264 put on wslAgents, wslHomes and
WSLRunning. wslrun's Up, In and running weren't gated either (only
Find was). On a computer without WSL, Windows' inbox wsl.exe answers
each ask with a window offering to install WSL, one per request.
The fix is at the one choke point every command magpie starts goes
through (TestNoCommandBypassesProc): proc.Command and CommandContext
(and so ProbeContext, wslrun.Tool.Command/Probe, the Claude TUI
helper's ConPTY start, which checks cmd.Err) refuse wsl.exe by any
name or path (wsl, WSL.EXE, C:\Windows\System32\wsl.exe) with
proc.ErrWSLOff while the setting is off, as a probe of an app's own
program is refused. The paths that reach it: agent's wslRun/wslExec
(lists, probes, links, chmod, reach), wslrun.Run/Find/In/Up/Stop,
library's cmdvars, mcp_wsl, mcp_check and rtk_wsl, claudetui's
wslread, the gateway's Claude Code in WSL. The settings read is
settings.Shared() and only for a wsl name. Not gated: the Sessions
page's resume line for a WSL session (a string a terminal runs on the
user's click), whose sessions aren't listed with detection off.
skygunner/vincent's stand-in fix is kept as well, so the stand-in and
classifier return before taking wsl's lock or recording a failed list.
Run:
- mote-run: go vet ./internal/proc ./internal/agent ./internal/wslrun;
GOOS=windows go vet of proc, agent, wslrun, claudetui, library,
gateway; GOOS=linux go vet of proc, agent, wslrun, claudetui: clean.
go test -count=1 ./internal/proc ./internal/wslrun ./internal/claudetui:
ok; -run 'WSL|Wsl|Dsh' ./internal/agent ./internal/library
./internal/sessions: ok. gofmt -l: nothing.
- win-run on xiaomi-gpu (Windows 11, real wsl.exe present): the four new
tests plus TestWSLDetectionOff, TestWSLClaudeStandIn,
TestWSLCodexStandIn, TestNoCommandBypassesProc: ok; -v shows each new
test PASS; go test ./internal/proc ./internal/wslrun whole: ok.
TestWSLRunnerRefusedWhenOff runs agent's real wslRun there.
Broken by hand (wslOff's check made `if false && …`, agent/wsl.go at
origin/main, new tests kept), on mote: TestWSLOffStartsNoWSL red for
every name and maker, TestRunRefusedWhenOff "Run ran wsl.exe: exit
status 1", TestWSLRunnerRefusedWhenOff red, TestWSLStandInAsksNothing
WhenOff red with three "-l --running -q" asks.
Not tried: the reporter's own Windows without WSL (the install window
itself); the full suite runs after the push under the suite lock.
Reported-by: 陌离 (Discord)
Co-authored-by: vincent <vincent@users.noreply.github.com>
On Windows magpie lists the running distros and probes each one for agents,
their sessions and Claude Code. Etsuya233 asked for a way to turn that off.
settings.NoWSLAgents (per machine, kept by KeepOwn) now gates every
auto-discovery path: agent.wslAgents/wslHomes/WSLRunning, sessions'
wslFiles/wslDirs (via the new sessions.WSLOff hook), and wslrun.Find, which
the Claude subscription uses to run Claude Code in WSL. The toggle is shown on
Windows only and is on by default.
Verified:
- red without the change: TestWSLDetectionOff (1 WSL agent with detection
off; with only sessions reverted, a distro's session is listed),
TestFindWithDetectionOff (Find returned Ubuntu after asking wsl.exe).
- go test -tags nogui ./... in a sandbox HOME: every package ok except
TestPluginLoginTakesTheLapseOff, which timed out at 63.7s under the full run
and passes alone (-count=3) and with its package (-count=1); it doesn't
reach WSL.
- go vet -tags nogui on agent, wslrun, sessions, settings and gui for darwin,
linux and windows.
- GUI: wsl-agents-setting (en/zh/zh-TW/ja/de, 900 and 440px) 30/30;
gui-ja, gui-de, gui-zh-tw, i18n-keys, keep-awake, lightweight,
settings-sections, settings-groups 44/44 in Chromium and 44/44 in WebKit.
- Windows box (10.0.0.132), nogui magpie.exe in a sandbox profile with a
logging wsl.exe first on PATH: on, `magpie agents` listed Claude Code · WSL
magpie-desktop after 3 wsl.exe calls; off, `agents`, `ls` and `sessions`
made no wsl.exe call and wrote no wsl.json.
Not tried: the toggle in the real Windows GUI window, and Claude Code in WSL
through the Claude subscription with the setting off (unit-tested only).