Skip to content

Fix: agents archived by the boot-time orphan sweep vanish from every UI tab - #528

Open
UsryAce wants to merge 1 commit into
chaitanyagiri:mainfrom
UsryAce:fix/notify-archive-orphaned-agents
Open

UsryAce wants to merge 1 commit into
chaitanyagiri:mainfrom
UsryAce:fix/notify-archive-orphaned-agents

Conversation

@UsryAce

@UsryAce UsryAce commented Sep 15, 2026

Copy link
Copy Markdown

Summary

archiveOrphanedAgents() (run once at startup to clean up stale archived:false entries with no live PTY) calls the raw hive.setArchived(id, true) directly. Every other archival path in the app — PTY exit teardown, killAgent, the hive:setArchived IPC handler — follows that same call with:

liveWebContents()?.send('hive:agentArchived', { id });

so the renderer's local roster store (a separate cache built from session IPC events, not read from registry.json directly) learns the agent was archived. archiveOrphanedAgents() doesn't send it.

Net effect: an agent can end up archived: true in registry.json while the Command Center's roster never received the event that would let it appear anywhere — not the live strip, not "restorable", not the "ARCHIVED (N)" section. It's simply gone, with no user-visible trace, even though it's still fully present in the backing data.

Repro (what I hit)

Two agents (toby-mtzzd9yw, vic-muoakmx8gx) had archived: true in registry.json but appeared in none of the Command Center's tabs, while ~13 other archived agents (archived through normal paths) showed up correctly in "ARCHIVED" with working restore buttons. Traced it to these two having been swept up by archiveOrphanedAgents() on a prior boot.

Fix

  hive.setArchived(id, true);
+ try { liveWebContents()?.send('hive:agentArchived', { id }); } catch { /* window torn down */ }
  console.log('[migration] archived orphaned agent (no live PTY):', id);

Mirrors exactly what the other archival paths already do a few hundred lines down.

Test plan

  • npm run typecheck passes
  • npm run build succeeds
  • Wrote a small read-only diagnostic script cross-referencing registry.json against roster.json's known ids to confirm this exact orphan condition and find affected agents (happy to share if useful, but it's outside the scope of this diff)

🤖 Generated with Claude Code

Before

Directly observed live: toby-mtzzd9yw and vic-muoakmx8gx both had "archived": true in registry.json, but were absent from every Command Center tab - not in the live agent list, and not in the "ARCHIVED (13)" expandable section either (which correctly listed ~13 other archived agents with working restore buttons). Cross-checked with a small read-only diff script against roster.json:

registry.json agents: 34
roster.json known ids (agents+archived+restorable): 32
orphans (invisible in every Command Center tab): 2
  - toby-mtzzd9yw  name=Toby  provider=codex  archived=true
  - vic-muoakmx8gx  name=Vic  provider=codex  archived=true

After

Same diff script, run immediately after a full mass-archive event on a rebuilt install with this fix applied (44 agents archived at once by archiveOrphanedAgents() on a cold boot):

registry.json agents: 44
roster.json known ids (agents+archived+restorable): 45
orphan count: 0
No orphans found - roster.json fully covers registry.json right now.

Zero orphans, even immediately after an archive sweep that size - versus 2 silently-orphaned agents observed before the fix.

…UI tab

archiveOrphanedAgents() (run once at startup) calls the raw hive.setArchived(id,
true) directly on the Hive class when it finds a registry entry with no live PTY.
Every OTHER archival path in the app - PTY teardown, killAgent, the
hive:setArchived IPC handler - follows that same call with
liveWebContents()?.send('hive:agentArchived', { id }) so the renderer's local
roster store (a separate, session-event-driven cache from registry.json) learns
the agent was archived. This one path didn't.

Net effect: an agent can end up archived:true in registry.json while the
Command Center never received the event that would let it show up in the
'ARCHIVED' section - it silently disappears from the live list, the restorable
list, and the archived list alike, with no user-visible trace it ever existed.

Sending the same notification here closes that gap.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

🚫 This PR is missing its before/after evidence

Every pull request here has to show its work. Screenshots or a short screen recording, before the change and after it.

  • Before — no image or video under that heading
  • After — no image or video under that heading

How to fix it: edit the description, keep the ### Before and ### After headings from the template, and drag an image or video under each. GitHub uploads it inline. This check re-runs the moment you save.

A bug fix with no visible surface still needs it: show the failing behaviour, then the same steps passing. A terminal recording is fine.

Genuinely nothing to show — a CI tweak, a typo, a dependency bump? A maintainer can apply the no-visual-change label. Please don't ask unless it truly has no observable effect.

📖 CONTRIBUTING.md → Evidence is mandatory

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