fix(wta): surface first-ever copilot sessions live in session management#182
Open
yeelam-gordon wants to merge 3 commits into
Open
fix(wta): surface first-ever copilot sessions live in session management#182yeelam-gordon wants to merge 3 commits into
yeelam-gordon wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes session-management UI failing to surface a user's first-ever agent CLI session by closing two live-update gaps: a one-shot wtcli listen reader that goes silent on any transient failure, and a master-side registry that only scans disk once at boot (missing sessions whose hook payload was dropped at the synthetic-key gate).
Changes:
- Wrap
wtcli listenin a respawn loop with exponential backoff, stderr draining, healthy-lifetime gating, andkill_on_dropto keep WT event subscription alive across child exits. - Add a 30 s periodic
history_loader::load_allrescan inserve_masterthat broadcastssessions/changedwhenever previously-unseen on-disk sessions are surfaced. - Introduce
SessionRegistry::insert_if_absentso the rescan never clobbers live hook-tracked state (status=Working,current_tool) under a single lock guard.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tools/wta/src/shell/wt_channel/cli_channel.rs | Reworks start_reader into a self-healing respawn loop with backoff, stderr logging, and child reaping. |
| tools/wta/src/session_registry.rs | Adds race-free insert_if_absent trait method + InMemoryRegistry impl for non-clobbering inserts. |
| tools/wta/src/master/mod.rs | Adds 30 s periodic disk rescan task that uses insert_if_absent and broadcasts sessions/changed on new finds. |
This comment has been minimized.
This comment has been minimized.
e8576eb to
a4c1c3b
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This was referenced Jun 2, 2026
wtcli --json listen was a one-shot subprocess: any silent exit (COM blip, transient RPC, WT restart) permanently silenced the helper's push-event path until IT restart, so the first copilot/agent session never surfaced in session-mgmt. Respawn on exit, but only ONCE. If the retry also exits, give up (loud error log) — at that point something is fundamentally broken and a tight respawn loop would just spam logs. Session-management freshness is independently covered by the master-side 30s disk rescan, so the worst-case tradeoff is autofix and agent_event hooks going dark for that helper's lifetime. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Hooks fire SessionStart with empty session_id on the very first run of a copilot/agent session (the agent hasn't allocated one yet), so the resulting synthetic pane:<guid> key was dropped at the helper edge and master never learned about the session. Add a 30s ticker in serve_master that rescans the session-discovery dirs and back-fills any sessions registry doesn't already know about. Also add InMemoryRegistry::insert_if_absent for a race-free check+insert under one lock, so the rescan and a concurrent hook delivery can't double-insert. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
13fb665 to
655cb9b
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.
Symptom
The session management view stays empty after a user starts their first-ever
copilot(or other agent) session inside Intelligent Terminal, even though the session uuid dir is being written to~/.copilot/session-state/<uuid>/. The row only appears after IT is restarted (which triggers the cold-starthistory_loader::load_allscan from master boot).Reproduces in a fresh new tab too — confirming master''s registry is empty, not a per-helper UI staleness issue.
Root cause
Two independent gaps in the live-update pipeline:
SessionStarthook observably fires with an emptysession_idon first run.route_agent_event_to_registry_with_hook_sink(app.rs:704) maps that to a syntheticpane:<guid>key, which is intentionally local-only and never published to master. Master''s registry therefore never learns about the new uuid.wtcli --json listenis one-shot.start_readerspawns the child once and returns silently on spawn failure or child exit. If that channel dies, the helper goes deaf to every subsequent WT broadcast (autofix classification,agent.tool.starting, etc.) with no log and no recovery until helper restart.Neither path self-heals, so the only currently-shipping workaround is "restart IT".
Fixes (two commits, independently reviewable)
1.
fix(wta): retry wtcli listen once on unexpected exit(cli_channel.rs)start_readernow retries thewtcli --json listenchild exactly once if it exits unexpectedly, then gives up with a loud error log.agent.tool.*push events go dark for the lifetime of that helper. Session management still recovers via the master-side 30 s disk rescan below.kill_on_drop(true)+start_killbeforewaitso the dying child is reaped, not orphaned.2.
fix(wta-master): periodic disk rescan to surface missed hook sessions(master/mod.rs+session_registry.rs)serve_masterthat re-runshistory_loader::load_alland inserts any uuid dir not already in master''s registry, then broadcastssessions/changediffadded > 0.SessionRegistry::insert_if_absent— race-free check+insert under one lock guard so the rescan never clobbers a live row with disk-inferred state (history_loadercan''t observestatus=Working/Attention/current_tool).session/listtick). This is the load-bearing fix for the user''s reported symptom.