Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

Merge branch 'pr-159' into integration/v0.4.5

Chaitanya Giri6e4540b41dea
diff --cc src/main/index.ts
index 2a5a62c5,487857f2..803b18d8
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@@ -413,16 -382,20 +413,20 @@@ const preservedWorktrees = new Map<stri
* per dead PTY.
*
* Idempotent: guarded on map presence and the already-idempotent
- * `hive.setArchived`, so the second call (kill() also makes node-pty fire
- * onExit) is a harmless no-op. Best-effort — every step is wrapped so a teardown
- * error can never crash the caller (an IPC handler or node-pty's onExit).
+ * `hive.setArchived`, so a double call is a harmless no-op. NOTE: an explicit
+ * `ptyManager.kill()` does NOT reach here via onExit — kill() deletes the
+ * session synchronously, so node-pty's later async exit callback fails the
+ * session-identity guard and is swallowed. Every kill site must therefore call
+ * teardownPty itself right after the kill (all of them do). Best-effort — every
+ * step is wrapped so a teardown error can never crash the caller (an IPC
+ * handler or node-pty's onExit).
*/
function teardownPty(id: string): void {
- // Ephemeral-worker flag, read BEFORE the cleanup below deletes the entry. All
- // worker deaths (done-release, idle/token reap, crash) funnel through here,
- // so this is the one place their floor card gets archived (workers now card
- // via the hive:agentSpawned broadcast in processSpawnRequest). pty id ==
- // worker id == agent id for workers.
+ // Main cards an ephemeral worker on the floor when it spawns, so main has to
+ // un-card it too — otherwise a released worker leaves a ghost the renderer's
+ // nudge/drain loops keep polling. Read the flag before the branches below
+ // clear it. Renderer-owned agents are deliberately untouched: the renderer
+ // owns those cards and keeps a dead one so the user can Restart & Continue.
const wasWorker = liveWorkers.has(id);
// 0) Revoke this id's broker capability (if any). Idempotent + harmless for a
// non-worker PTY; ensures a dead worker's token can never reach an integration.