fix: reap closed agents from the sidebar - #57
Open
vimeh wants to merge 2 commits into
Open
Conversation
Closed agents stayed in the agents panel until a server restart because every removal path was unwired (Ataraxy-Labs#48): - AgentTracker::prune_terminal was never called. Invoke it on every snapshot so terminal entries (done/error/interrupted/stale) without a live pane expire: 5 min after being seen, 30 min while unseen so the notification dot isn't reaped before it can be noticed. It now also clears unseen markers for pruned keys and reports whether it changed anything. - The sidebar's D key sends dismiss-agent, but the server had no handler, so manual dismissal was silently dropped. Wire it to AgentTracker::dismiss and broadcast the updated snapshot. - pi's session_shutdown posts /api/runtime/pi/delete, which only touched the write-only PiRuntimeRegistry. Resolve the pid back to its session via the registry's cwd and dismiss the tracker entry, pushing a fresh snapshot. - /pane-exited now broadcasts a snapshot (which re-syncs pane presence and prunes) instead of waiting for the next poll tick, and the already-installed pane-died hook is accepted by is_ok_hook_path and handled the same way. prune_stuck stays unwired on purpose: reaping running entries by timestamp alone risks deleting agents that are mid-turn but quiet; the agent watcher already downgrades killed agents to the terminal stale status within 15s, which prune_terminal then reaps. Fixes Ataraxy-Labs#48
There was a problem hiding this comment.
inspect review
Triage: 53 entities analyzed | 0 critical, 0 high, 17 medium, 36 low
Verdict: standard_review
Findings (0)
Reviewed by inspect | Entity-level triage found 0 high-risk changes
claude/codex watchers already downgrade Waiting to Stale after 15s of file silence; pi and droid only did so for Running. An agent killed while waiting froze in a non-terminal status the reaper ignores.
There was a problem hiding this comment.
inspect review
Triage: 57 entities analyzed | 0 critical, 0 high, 20 medium, 37 low
Verdict: standard_review
Findings (0)
Reviewed by inspect | Entity-level triage found 0 high-risk changes
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.
Fixes #48.
Closed agents stayed in the agents panel until a server restart because every removal path was unwired:
prune_terminalwas dead code — implemented but never called. It now runs on every snapshot: terminal entries (done/error/interrupted/stale) without a live pane expire 5 min after being seen, or 30 min while unseen (so the notification dot isn't reaped before it can be noticed). It also clears unseen markers for pruned keys.dismiss-agenthad no server handler — the sidebar'sDkey sent the command,handle_client_commanddropped it. Wired toAgentTracker::dismisswith a snapshot broadcast.session_shutdownposts/api/runtime/pi/delete, which only mutated the write-onlyPiRuntimeRegistry. The pid is now resolved back to its session (via the registered cwd) and the tracker entry dismissed, broadcasting a fresh snapshot./pane-exitednow broadcasts immediately (the snapshot path re-syncs pane presence and prunes) instead of waiting for the next 2s poll tick, and the already-installedpane-diedhook is accepted byis_ok_hook_pathand handled identically (Agents not removed from sidebar when closed —prune_terminal/prune_stucknever called +/pane-exitedskips tracker update #48 items 2 and 3).Waitingthreads now stale out after 15s of file silence, matching claude/codex — an agent killed while waiting no longer freezes in a non-terminal status the reaper ignores.prune_stuckstays unwired on purpose: reaping running entries by timestamp alone risks deleting agents that are mid-turn but quiet; the agent watcher already downgrades killed agents to the terminalstalestatus within ~15s, whichprune_terminalthen reaps.Tests: 5 new tracker tests covering the TTL/liveness/unseen matrix, plus a server-side test harness (
FakeProvider) with 4 tests for the dismiss handler and the pi-delete bridge, and a watcher test for the pi Waiting→Stale transition.cargo test --workspacegreen (tmux E2E included, one pre-existing env-dependent flake on my machine).