Repository navigation
Preserve live PTYs during daemon resolver refresh - #2974
Merged
Merged
Conversation
Co-authored-by: Orca <[email protected]>
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.
Summary
This PR fixes the P0 class of failures where live terminal child processes can be killed even though Orca's detached terminal daemon is expected to survive app restarts.
The important correction from the investigation is that this is not Codex-specific. Codex was just the most visible workload because we keep many long-running Codex processes in Orca terminals. The failure mode is at the local daemon / PTY lifecycle layer, so it can affect any long-running terminal process.
Root cause
PR #2835 added macOS system resolver-health detection for daemon reuse. That was directionally correct, but it introduced two replacement paths that could tear down a live daemon:
createOutOfProcessLauncher()calledcleanupDaemonForProtocol(runtimeDir, PROTOCOL_VERSION).DaemonPtyAdapter.replaceUnhealthyMacResolverDaemonBeforeNewPty()could respawn the daemon before creating a new PTY.Both replacement paths ultimately shut down or respawn the daemon. For the current daemon, that means live PTY child processes can be killed with
killSessions: true. From the user's perspective, the terminal surface may still appear to persist, but the actual process inside it is gone.That matches the clarified report: the issue is not primarily that Orca cannot find old session records. It is that the child processes themselves can exit despite the terminal daemon having a separate lifecycle from the app.
Fix
This PR makes resolver-health replacement non-destructive for daemons that may own live work:
listSessionsbefore cleanup.activeSessionIds, because after an app restart a fresh adapter can have an empty local set while the daemon still owns live sessions.Why the protocol bump matters
Without the v10 bump, users who already have a v9 daemon from an affected build could relaunch into this patched build and still have that daemon treated as the current daemon. The launcher/adapters would then continue evaluating resolver health against it.
By making v10 current and v9 legacy:
Regression coverage
Added/updated tests for:
Verification
Ran locally:
Results:
Local environment note: commands emit the existing engine warning because this shell is Node v26 while the repo wants Node 24.
Review notes
I asked subagents to review this specifically for daemon lifecycle, regression risk, and cross-platform/SSH implications.
They found one real blocker in the first version of the patch: checking only
activeSessionIdswas insufficient after app restart because a fresh adapter may not yet know about sessions owned by the daemon. This PR now fixes that by querying daemonlistSessionsbefore adapter-side replacement and includes the corresponding regression test.Cross-platform/SSH review did not find blockers: resolver-health replacement is macOS-only (
unknownelsewhere), and the touched paths are local daemon paths rather than SSH provider paths.Made with Orca 🐋