Files
magpie/internal
yetoneandggbdpq 703eec4ee7 gateway: the interactive mode's starts take turns (#5579)
Several Claude subscription calls asked at once each start a full
Claude Code, and the more start with it the longer each takes to show
its prompt: on a Windows machine of cold starts none of six showed one
in the 45s a start alone fits in, so each was ended at the deadline and
answered 502, and every caller's next try started the pile again -- 531
interactive starts in an hour, 420 of them ending "showed no prompt"
(#5579). One start at a time: a run's Claude Code is started only once
the one before it has shown its prompt, its helper having answered
magpie's initialize request. A start that missed the wait holds the
turn until magpie has given up on it (its stop is under way, not waited
out), so the retries behind it land on a machine with one start to do,
not a pile. -p runs and the one-off interactive runs in
claude_warmup.go (model test, /usage read) take no turn.

A start waiting for another's prompt says so in the log, as a run
waiting for room does: the pile was read out of app.log, so the waits
it leaves behind say themselves too.

Review edit: the tuiStarts comment said a missed start is not followed
until it has ended; startRun calls run.abort() without waiting on the
stop it returns, so the comment now says what the code does.

Run (wsl-run, magpie-desktop, at this tree on ef81b7ad1):
- go test ./internal/gateway -run TestClaude: ok (74s)
- go test -race -count=3 -run TestClaudeTUI ./internal/gateway: ok
- gofmt -l on both files: clean
Broken by hand: tuiStartTurn replaced by a no-op turn,
TestClaudeTUIStartsTakeTurns red ("a start began while another was
still starting"); restored, green.
Not tried: the new test skips on Windows (win-run: SKIP), so it ran on
Linux only; no real Windows Claude Code pile was started.

Reported-by: hustneverland
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-07 21:47:24 +08:00
..
…
…
…
…
…
…