Skip to content

fix: orphan-gate pre-GUI mcp-stdio sweep — fix cold-start MCP disconnect (v0.8.2)#142

Merged
iret77 merged 1 commit into
mainfrom
fix/release-082-pre-gui-orphan-gate
Jun 8, 2026
Merged

fix: orphan-gate pre-GUI mcp-stdio sweep — fix cold-start MCP disconnect (v0.8.2)#142
iret77 merged 1 commit into
mainfrom
fix/release-082-pre-gui-orphan-gate

Conversation

@iret77

@iret77 iret77 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

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-stdio and no GUI was running, the child cold-started the GUI; the freshly launched GUI then ran kill_mcp_stdio_started_before_self (v0.4.43) and SIGTERM'd its own bootstrapper:

17:27:19.031  ---- mcp-stdio pid=2483 started ----
17:27:19.034  lifetime: gui channel not ready, launching GUI
17:27:19.076  ---- gui pid=2497 started ----
17:27:19.091  housekeeping: killing pre-GUI mcp-stdio child pid=2483 …
17:27:19.097  startup: killed 1 pre-GUI mcp-stdio child(ren);
              Claude Desktop will respawn them against the current binary

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): add is_orphaned_child as a filter on find_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 errors
  • npm run build — ok
  • Field verification after release: cold-start a Cowork session, confirm no "Server disconnected" toast and trace shows the bootstrapper not SIGTERM'd

🤖 Generated with Claude Code

…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>
@iret77 iret77 force-pushed the fix/release-082-pre-gui-orphan-gate branch from 569cc41 to 116a3cc Compare June 8, 2026 22:37
@iret77 iret77 merged commit b4494c4 into main Jun 8, 2026
3 checks passed
@iret77 iret77 deleted the fix/release-082-pre-gui-orphan-gate branch June 8, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant