Repository navigation
fix(runtime): degrade focused terminal create on a windowless host (STA-2585) - #12791
Merged
Merged
Conversation
`orca serve` publishes a ready graph under HEADLESS_RUNTIME_WINDOW_ID with no BrowserWindow behind it. `shouldCreateInBackground` only degraded when the create was renderer-backed, so any focus-requested create fell through to getAuthoritativeWindow() and threw "No renderer window available" — leaving `terminal create --focus` with no workaround on a remote server (#10333). With a worktree selector and no renderer window, a background spawn is the only usable path, so collapse the renderer-backed window check into a plain "no window" check. That is the existing rendererBacked clause plus exactly the missing focus case, and it drops the confusing `rendererWindow === null` indirection (rendererWindow is already gated on rendererBacked). Focus is not lost by the degrade: the spawned pane is still published to the session-tab model and revealed with `activate: true`, which is how a paired client learns about it. Mirrors the in-tree precedent in runCreateMobileSessionTerminal. Headed hosts are unaffected — the clause only fires when no window exists.
This was referenced Aug 5, 2026
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe runtime now creates terminals in the background when no authoritative window exists. Headless focused terminal and agent-session creation preserves pane publication and activation behavior. Renderer-backed creation continues to request a focused tab without spawning a PTY. Runtime tests and an end-to-end test cover these cases through direct and RPC-based flows. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
…ve (stablyai#12791) `orca serve` publishes a ready graph under HEADLESS_RUNTIME_WINDOW_ID with no BrowserWindow behind it. `shouldCreateInBackground` only degraded when the create was renderer-backed, so any focus-requested create fell through to getAuthoritativeWindow() and threw "No renderer window available" — leaving `terminal create --focus` with no workaround on a remote server (stablyai#10333). With a worktree selector and no renderer window, a background spawn is the only usable path, so collapse the renderer-backed window check into a plain "no window" check. That is the existing rendererBacked clause plus exactly the missing focus case, and it drops the confusing `rendererWindow === null` indirection (rendererWindow is already gated on rendererBacked). Focus is not lost by the degrade: the spawned pane is still published to the session-tab model and revealed with `activate: true`, which is how a paired client learns about it. Mirrors the in-tree precedent in runCreateMobileSessionTerminal. Headed hosts are unaffected — the clause only fires when no window exists. Co-authored-by: Jinwoo-H <[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.
Fixes GitHub #10333 / Linear STA-2585 (STA-2498 is its duplicate — one fix closes both).
Symptom
A focus-requested
terminal createagainst a headlessorca servehost throws "No renderer window available". P0, reported with no workaround.Reproduction — red on
origin/main(ae1ed5e886)Against a real headless
orca servehost, driving the exact RPC the remote CLI puts on the wire:In-process, same state (
orca servepublishes a ready graph underHEADLESS_RUNTIME_WINDOW_ID = 0with noBrowserWindow,src/main/index.ts:2862):Change —
orca-runtime.ts:25056Rather than bolt on a fourth clause, this collapses the window check, because
rendererWindow === nullwas alreadyavailableAuthoritativeWindow === nullin disguise (rendererWindowis itself gated onrendererBacked):That is provably the old clause plus exactly the missing focus case — the difference set is
no window && !rendererBacked, where non-focus creates already went background via clause 2. So it removes a footgun at zero extra behavior change.Focus is degraded in placement, not dropped: the background path already honors it, publishing with
activate: presentation === 'focused'(:25336) and revealing withactivate/presentation(:25360) — the in-tree precedent at:25757.The reported Mac UI
+half no longer reproduces — scoped out with evidenceWorth stating, because closing #10333 on a fix for the UI half would be wrong. On current main the desktop client never asks the host for focus, at two independent layers:
runtime-agent-background-create.ts:52andremote-runtime-pty-transport.ts:1988sendpresentation: 'background'/focus: falseoutright (fix(terminal): make remote agent sessions host-authoritative #9687).withExecutionHostAgentPresentation(rpc/methods/agent-session.ts:218) downgradesfocused→backgroundfor any client reporting aclientKind— every paired socket — from fix(remote): create paired agent sessions without host focus #10193, landed after the reporter's v1.4.152.So the surviving P0 is the CLI/RPC half. The runtime-layer hole is still reachable by any caller with no
clientKind(loopback CLI, orchestration internals), so it is closed at the runtime layer regardless.On the two existing community PRs — neither should merge as-is
Both diagnose the bug correctly. Verified individually:
orca-runtime.tscall site and keep the helper, and all 7 tests still pass. Nothing in it constructs a runtime, callscreateTerminal, or observes the throw.syncWindowGraph/attachWindow), sographStatusstays'unavailable'. Replicating its test shape against unfixed main yieldsError: runtime_unavailable, notNo renderer window available— red on main for the wrong reason, never demonstrating the reported bug. It also has no headed-host regression test, which is the stated main risk.Mutation evidence
Caused by: Error: No renderer window available; the E2E goes red with the same error over the wire. Restored by re-applying the edit.true(unconditional degrade) → the headed testkeeps focus-requested terminal creates on the renderer when a window existsgoes red, plus two pre-existing renderer-path tests. The headed guard is real, not decorative.src/main/runtimesuite: 241 files, 3694 tests green.pnpm typecheckclean,oxlintclean.Risk
Headed desktop: none. The clause fires only when
getAvailableAuthoritativeWindow()returns null; with a window the renderer IPC path is byte-identical, proven by the second mutation. Renderer reload is unaffected — the window still exists.One deliberate behavior change beyond the bug: a headed host with all windows closed (macOS app alive) previously threw
runtime_unavailableon a focused create and now spawns in background. That is correct rather than a regression — a non-focus create in that state already does exactly this, andpersistWindowlessPtyBindingsForDesktopAttach(:5369) exists precisely because "a promoted serve can close and later reopen its window while new background PTYs keep arriving."Pre-existing, deliberately not touched
The degraded create returns a misleading warning ("could not make it discoverable") even though the terminal is published to the session tabs; and
terminal.createwith noworktreestill throws raw on a headless host — unreachable from the remote CLI, which hard-requires--worktree(src/cli/handlers/terminal.ts:130).