fix: orphan-gate pre-GUI mcp-stdio sweep — fix cold-start MCP disconnect (v0.8.2)#142
Merged
Merged
Conversation
…l the bootstrapper (v0.8.2)
When Cowork / Claude Code spawned aiui --mcp-stdio with no GUI running,
that child cold-started the GUI, and the freshly launched GUI then ran
kill_mcp_stdio_started_before_self (v0.4.43) and SIGTERM'd its own
bootstrapper — the trace even named the killer:
housekeeping: killing pre-GUI mcp-stdio child pid=2483 …
startup: killed 1 pre-GUI mcp-stdio child(ren);
Claude Desktop will respawn them against the current binary
Claude Desktop respawn was the old assumption; Cowork / Claude Code
don't respawn, so the bootstrapper just died → user saw "MCP aiui:
Server disconnected" on the first MCP call after every cold start.
Same fix pattern as v0.4.46's Bug A (kill_orphaned_mcp_stdio_children):
add is_orphaned_child as a filter — the pre-GUI sweep still reaps
older mcp-stdio children, but only when their parent wrapper is also
gone (genuine leak). The live bootstrapper has a live parent, so it
is now spared.
Regression tests cover both cases:
- pre_gui_kill_spares_bootstrapper_with_live_parent
- pre_gui_kill_reaps_orphaned_older_child
cargo test 131/0, clippy clean (-D warnings), svelte-check 0 errors,
vite build ok.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
569cc41 to
116a3cc
Compare
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.
Summary
Fixes the 2026-06-08 field report: every cold start of Cowork / Claude Code shows "MCP aiui: Server disconnected" on the first MCP call.
Root cause (from the user's
/tmp/aiui-trace.log)When Cowork spawned
aiui --mcp-stdioand no GUI was running, the child cold-started the GUI; the freshly launched GUI then rankill_mcp_stdio_started_before_self(v0.4.43) and SIGTERM'd its own bootstrapper:Claude Desktop might respawn; Cowork / Claude Code don't. So the bootstrapper just dies on every cold start. Once the GUI is warm, subsequent children attach fine (no new GUI start → no sweep) — which is exactly why the bug presents as "happens sometimes, then works fine for a while".
Fix
Same pattern as v0.4.46's Bug A (
kill_orphaned_mcp_stdio_children): addis_orphaned_childas a filter onfind_pre_gui_mcp_stdio_to_kill. The sweep still reaps older mcp-stdio children, but only when their parent wrapper is gone (real leak). A live bootstrapper has a live parent → spared.Test plan
cargo test --lib— 131/0 (new:pre_gui_kill_spares_bootstrapper_with_live_parent,pre_gui_kill_reaps_orphaned_older_child)cargo clippy --lib --all-targets— clean (-D warnings)svelte-check— 0 errorsnpm run build— ok🤖 Generated with Claude Code