Repository navigation
Description
Short summary
Orca leaks terminal pty sessions in three distinct ways. On this machine a single cleanup pass reclaimed 4 stale daemons, 64 descendant processes, and 33 orphaned pty sessions. The daemon-side orphaned flag only catches one of the three classes, so neither the UI nor orca terminal list reveals the bulk of the leak.
Class 1 — stale daemons survive app upgrade
After upgrades, previous-generation daemon processes are never reaped. Four generations were alive simultaneously:
| daemon | started | descendant processes |
|---|---|---|
daemon-v23 (pid 978) |
Jul 21 | 0 |
daemon-v25 (pid 50007) |
Jul 23 | 44 |
daemon-v26 (pid 80383) |
Jul 25 | 18 |
daemon-v28 (pid 79714) |
Jul 26 | 317 (current, in use) |
v25 and v26 each still held login -flpq → zsh → claude chains (7 agent sessions total, burning CPU and RAM). These are invisible to the CLI, since orca terminal list only talks to the current runtime (v28). A SIGTERM to the four stale daemons cleanly reclaimed all 64 descendants, and the running Orca was unaffected — confirming nothing needed them.
The daemon/ directory corroborates the leak: daemon-v23.pid and daemon-v23.token were left behind with no matching .sock.
Class 2 — global floating terminal: tab destroyed, pty survives, orphaned stays false
After closing the global floating terminal, 28 global-floating-terminal@@* ptys remained registered across 24 tabIds. Every single one reported:
"orphaned": false,
"connected": true,
"writable": trueBut orca terminal close --terminal <handle> --tab on them returns:
{"ok": false, "error": {"code": "runtime_error", "message": "tab_not_found"}}The tab is genuinely gone from the UI, so orphaned: false is simply wrong here. orca terminal close without --tab reclaims them and reports "ptyKilled": true, confirming the pty was live and unreferenced. 27 of the 28 were reclaimed this way (the 28th was the session issuing the commands).
Class 3 — main window: pty with no pane binding
Six further ptys carried synthesized identifiers, where tabId == leafId == "pty:" + ptyId:
"tabId": "pty:<worktreeId>::<worktreePath>@@b4bf46ff",
"leafId": "pty:<worktreeId>::<worktreePath>@@b4bf46ff",
"ptyId": "<worktreeId>::<worktreePath>@@b4bf46ff",
"orphaned": true,
"title": null,
"lastOutputAt": nullThis class is correctly flagged orphaned: true, and the synthesized pty: prefix makes it detectable read-only. But nothing reclaims them automatically and they surface nowhere in the UI. These appear to be registry residue rather than live processes — killing all six changed the descendant process count not at all.
Why this is painful to clean up from the CLI
- No selector reaps by orphan state.
terminal stop --worktree id:global-floating-terminalwould take the caller's own session down along with the leaked ones. - Every read-only field is identical between healthy and leaked class-2 sessions:
orphaned,connected,writable,paneRuntimeId(always1),rendererGraphEpoch(always0). The only discriminator is a destructive call —close --tabreturningtab_not_found— which closes the tab when one does exist, so it cannot serve as a probe.terminal switchappears usable as a non-destructive stand-in, but it perturbs UI focus. terminal listhandles expire almost immediately. In a loop issuing onlyterminal show, handles went stale by the 5th call (terminal_handle_stale). Every mutation must re-listto re-resolve.tabIdis stable;handleis not. This makes any batch cleanup script fragile.orca-data.jsonon disk is not written live.workspaceSession.tabsByWorktree,unifiedTabs, andterminalLayoutsByTabIdlooked like the right reconciliation source, but the file was 7 days stale and did not contain the current session's tabId at all.
Reproduction
- Use Orca across at least one app upgrade, so a new
daemon-vNgeneration starts. ps -ef | grep daemon-entry.js— previous-generation daemons are still running, with livelogin/zsh/agent descendants.- Open several global floating terminal sessions, then close the global terminal.
orca terminal list --json— theglobal-floating-terminal@@*ptys are still listed, asorphaned: false, connected: true.orca terminal close --terminal <handle> --tab→tab_not_found, proving the tab is gone while the pty remains registered and alive.
Suggested fixes
- On daemon startup, signal previous-generation daemons to drain and exit — the
daemon-vN.pidrecords needed to find them are already on disk. - Reclaim ptys when their owning tab is destroyed, particularly on global-floating-terminal teardown.
- Fix
orphanedfor class 2, or expose a read-only "has live tab binding" field, so cleanup does not require a destructive probe. - Provide a non-destructive reap path, e.g.
orca terminal list --orphanedplusorca terminal reap. - Consider lengthening terminal handle lifetime, or accepting
tabIddirectly on mutating commands.
Environment
- Orca 1.4.159
- macOS 26.5.2, arm64
(Paths in the excerpts above are redacted placeholders; identifiers are otherwise verbatim.)
Activity
Cyb3rN8 commentedon Jul 29, 2026
Follow-up: the runtime already has everything needed to detect this read-only — it's just not reachable from the CLI.
The daemon RPC surface (JSON-RPC over the unix socket in
orca-runtime.json) exposesterminal.resolvePane, which the renderer itself uses to confirm a pty is still bound to a pane:ok, returns the terminal (the renderer then verifieshandle/tabId/leafId/worktreeIdall match){"code": "runtime_error", "message": "terminal_not_found"}That cleanly separates the class-2 leaks from healthy sessions without touching UI state, which none of the fields returned by
terminal listcan do.terminal close --tabcan also detect it, but destroys a live tab when one exists, so it can't be used as a probe — andterminal switchworks but yanks UI focus on every check, which makes sweeping a few dozen tabs unusable in practice.So suggested fixes #3/#4 above are probably cheap: surfacing
resolvePane(or just an--orphanedfilter onterminal listcomputed from it) would be enough for users to clean up without a destructive probe.Also worth noting, both already present in the bundle:
terminal.adoptOrphans— there's apparently already an orphan-adoption path[terminal-retirement]code path that closes handles in bulk bytabId, and warnsskipped unroutable runtime handlesWhatever leaves these ptys behind seems to be a gap in those existing mechanisms rather than a missing one.
One more CLI-level papercut for anyone scripting a cleanup: handles from
terminal listgo stale within a handful of calls (terminal_handle_stale), so every mutation needs a freshlistto re-resolve.tabIdandptyIdare stable;handleis not.Regis-RCR commentedon Aug 24, 2026
A counter-example to "confirming nothing needed them", from three macOS hosts on 1.4.187 and 1.4.188.
The class-1 report here ends with a SIGTERM to four stale daemons cleanly reclaiming 64 descendants, with the running Orca unaffected. On our machines that same reap would not have been safe, and we only found that out because we inventoried before running it.
Two generations stamped
--app-version=1.4.185were alive alongside newer ones. Under them, at the moment of collection:A process 39 seconds old means something was driving that terminal at that moment. The remediation we had already approved would have terminated five generations holding 34 terminals, including those. We cancelled it.
The limit of the claim, since it matters more than the headline: we did not establish that all 28 inventoried terminals were active. A live MCP server process is not proof of a connected client, and a recent
caffeinateproves recent creation rather than continuous activity. Strictly, the 39 seconds is the process's age, not the terminal's. The narrow claim is enough for the decision anyway: at least some carried current work, so a blanket reap is unsafe.So the unreliable
orphanedflag cuts in both directions, and this thread only documents one of them. It under-reports the leak, which is your finding. It also means absence from the current runtime graph is not evidence that a survivor is disposable, which is exactly the safety requirement #9229 asks for. This is a concrete instance of the second.One asymmetry worth adding here, because suggested fix 1 above assumes the records are on disk. On our 28-day host,
daemon-v30anddaemon-v31are running with no.pid,.sockor.tokenfile at all, while the other two hosts carry six.sockfiles with no process behind them. A discovery pass driven by the record files walks past exactly the generations worth preserving. Both directions are needed: livedaemon-entry.jsprocesses whose--socketnames another generation, and record files with no process.Full data across the three hosts, with the evidential status of each claim, in #16278.
farrrr commentedon Nov 3, 2026
Related new report: #37843 — on v1.4.247 (Linux, local host), a terminal started with
orca agent launchisorphaned: trueright after launch (no restart).terminal close --tabthen returnsterminal_handle_staleand leaves the PTY running; plainclosestops it but still returnstab_not_found. Repro steps and code pointers are in that issue.jk1420 commentedon Nov 20, 2026
Windows-specific confirmation on Orca 1.4.265 (Desktop only).
After an upgrade chain from 1.4.245/1.4.248/1.4.257/1.4.262 to 1.4.265, previous-generation terminal daemons remained alive after the parent Orca application had exited. The new protocol-v60 daemon started successfully, but older daemons still accepted client handshakes shortly afterward. Repeating updates leaves multiple versioned daemon generations resident.
Observed
daemon-v*.pidanddaemon-v*.tokenrecords remained after the old processes were no longer needed.cgroupUnit: nullandprocessCeiling.state: offwith reasondisabled, so there was no OS-level lifetime binding or process ceiling to reclaim them when the parent app exited.All paths, usernames, PIDs, socket names, tokens, worktree names, and other machine-specific identifiers are intentionally omitted.
Reproduction
Previous-generation daemons remain resident instead of draining and exiting, so the number of daemon generations grows over time.
Expected
After the new daemon has migrated or reattached all live terminals, an older daemon with no active terminal ownership should drain and exit. Its PID/token metadata should then be removed. If an older daemon is still required, Orca should expose that ownership clearly and perform the cleanup when the final terminal exits.
Impact
This creates redundant long-lived processes and stale metadata, and may contribute to session/profile state conflicts during update and reattach. It also makes manual cleanup necessary after upgrades.
Related: #37909 (older daemons and duplicate/resumed sessions), #41931 (old daemon surviving auto-update).