Skip to content

fix(runtime): degrade focused terminal create on headless serve - #10557

Closed
innocarpe wants to merge 1 commit into
stablyai:mainfrom
innocarpe:fix/headless-focused-agent-create
Closed

innocarpe wants to merge 1 commit into
stablyai:mainfrom
innocarpe:fix/headless-focused-agent-create

Conversation

@innocarpe

@innocarpe innocarpe commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #10553 — agent creates from a paired desktop client against headless orca serve no longer fail with No renderer window available.

Since terminal.createAgentSession, clients send presentation: 'focused' for user-initiated agent creates. On a windowless serve host, that took the renderer-IPC path and called getAuthoritativeWindow(), which throws when BrowserWindow.fromId is null.

Fix

If presentation/focus requires a renderer window but none is available, use the existing headless/background createTerminal path (same as non-focused CLI creates and rendererBacked without a window). The PTY still spawns; surface is returned as background with the usual optional reveal warning when no notifier can promote a tab.

Test plan

  • orca-runtime.test.ts — focused create without window → background surface
  • orca-runtime.test.ts — focused createAgentSession without window
  • existing renderer-backed-without-window case still passes
  • Manual: desktop client paired to headless orca serve can create agents without error

ELI5

Creating a focused agent from a paired client against headless orca serve failed with "No renderer window." Focused creates now degrade gracefully to a windowless path so remote agents still start.

Paired desktop clients send presentation:'focused' for agent creates.
On windowless orca serve that hit getAuthoritativeWindow() and failed
with "No renderer window available". Route focused creates without a
BrowserWindow through the existing headless/background spawn path
(fixes stablyai#10553).
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Expanded runtime fallback handling allows focused presentation requests to proceed through headless spawning when no renderer window or authoritative window exists. Added tests covering focused terminal creation and focused agent-session creation in a headless setup, including background surfaces, generated terminal handles, successful creation, and persistent host-session binding for PTY spawning.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning It includes Summary and Test plan, but omits several required template sections like Screenshots, AI Review Report, Security Audit, and Notes. Add the missing sections, complete the testing checklist, and include the required AI review and security audit details.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: degrading focused terminal creates on headless serve.
Linked Issues check ✅ Passed The code and tests implement the requested headless fallback for focused creates, matching issue #10553's expected behavior.
Out of Scope Changes check ✅ Passed The changes stay focused on headless focused-create fallback behavior and its regression tests, with no obvious unrelated scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main/runtime/orca-runtime.ts (1)

21625-21628: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Shorten the inline rationale.

This four-line comment is more verbose than the TypeScript guideline permits. Keep only the non-obvious reason, for example:

Proposed revision
-        // Why (`#10553`): paired desktop clients send presentation:'focused' for
-        // agent creates. Without a BrowserWindow (headless `orca serve`), fall
-        // through to the headless spawn path instead of getAuthoritativeWindow()
-        // hard-erroring with "No renderer window available".
+        // Paired clients may request focused presentation on headless hosts.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 94172dbc-7d1c-4a29-842b-baff5c6db184

📥 Commits

Reviewing files that changed from the base of the PR and between 505967e and d23c1e1.

📒 Files selected for processing (2)
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts

@innocarpe

Copy link
Copy Markdown
Contributor Author

Status ping: focused headless-serve fix so presentation: 'focused' agent creates degrade cleanly without a renderer window (tests included). No open threads — ready for a maintainer look when convenient.

@Jinwoo-H

Jinwoo-H commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Thanks for this, and for the diagnosis — it was correct, and it made the fix straightforward to confirm.

We reproduced #10333 against a real headless orca serve host (not a mock) and it fails exactly where you identified: a focus-requested create falls through to getAuthoritativeWindow() and throws. That part of your analysis held up completely.

We've opened #12791 with the fix. Two reasons we went with a separate PR rather than merging here, both about test coverage rather than your diagnosis:

  • fix(runtime): headless terminal create --focus without renderer window #10370 — the production change is logically equivalent to ours. But reverting the orca-runtime.ts call site while keeping the extracted helper leaves all 7 tests passing, because they only exercise the pure function's own truth table; nothing constructs a runtime, calls createTerminal, or observes the throw. So the tests can't catch a regression in the thing being fixed.
  • fix(runtime): degrade focused terminal create on headless serve #10557 — the one-clause change is correct. But the tests never wire the headless-serve state (no syncWindowGraph/attachWindow), so graphStatus stays 'unavailable'. Replicating that test shape against unfixed main gives Error: runtime_unavailable, not No renderer window available — it goes red on main for a different reason, so it never demonstrates the reported bug.

One thing worth knowing that neither PR could have anticipated: the Mac UI + half of this issue no longer reproduces on current main. #9687 and #10193 landed after the original report and now send presentation: 'background' for paired clients. So the surviving defect is the CLI/RPC path only — which is what #12791 closes at the runtime layer, since it stays reachable for any caller without a clientKind.

Genuinely appreciate the work here; the fix in #12791 is the shape you both proposed. Closing these in favour of it, but the credit for finding it is yours.

@innocarpe

innocarpe commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor Author

@Jinwoo-H appreciate the write-up. Fair call on the tests — if they go red on main for runtime_unavailable instead of the actual window error, they never really pin the bug we claimed to fix.

I'll close this out for #12791. Thanks for the credit on the diagnosis; that means a lot after the PR sat a while.

@innocarpe

innocarpe commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor Author

Closing — tracked on #12791 instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Headless serve: agent create from desktop client fails with 'No renderer window available' since ~v1.4.153

3 participants