Skip to content

Fix recipe serve desktop promotion - #8646

Merged
AmethystLiang merged 3 commits into
mainfrom
fix-recipe-serve-desktop-promotion
Jul 14, 2026
Merged

AmethystLiang merged 3 commits into
mainfrom
fix-recipe-serve-desktop-promotion

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

Summary

Describe the user-visible change.

Screenshots

  • Add screenshots or a screen recording for any new or changed UI behavior.
  • If there is no visual change, say No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

AI Review Report

Summarize the code review you ran with your AI coding agent. Include the main risks it checked, what it flagged, and what you changed or verified as a result.
Confirm that the review explicitly checked cross-platform compatibility for macOS, Linux, and Windows, including shortcuts, labels, paths, shell behavior, and any Electron-specific platform differences touched by this PR.

Security Audit

Provide a basic security audit summary from your AI coding agent. Call out any input handling, command execution, path handling, auth, secrets, dependency, or IPC risks that were reviewed, plus any follow-up needed.

Notes

Call out any platform-specific behavior, risks, or follow-up work.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@AmethystLiang, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 7 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4d668cc6-d225-4598-ac6a-edcf547b9f1f

📥 Commits

Reviewing files that changed from the base of the PR and between a4fea5b9acd52519a37a4608df5a34fc8028125b and 6ad6e84.

📒 Files selected for processing (20)
  • config/reliability-gates.jsonc
  • src/cli/format.ts
  • src/cli/runtime-client.test.ts
  • src/cli/runtime/client.ts
  • src/cli/runtime/status.ts
  • src/cli/runtime/websocket-transport.test.ts
  • src/main/index.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/ssh/ssh-remote-cli-format.ts
  • src/main/ssh/ssh-remote-orca-cli.ts
  • src/main/startup/serve-desktop-activation-wiring.test.ts
  • src/main/startup/serve-desktop-activation.test.ts
  • src/main/startup/serve-desktop-activation.ts
  • src/main/startup/single-instance-lock.test.ts
  • src/main/startup/single-instance-lock.ts
  • src/main/startup/window-all-closed-quit-policy.test.ts
  • src/main/startup/window-all-closed-quit-policy.ts
  • src/shared/runtime-types.ts
  • tests/e2e/headless-serve-desktop-activation.spec.ts
📝 Walkthrough

Walkthrough

Adds a gated headless-to-desktop activation flow that reports desktop window availability, preserves runtime and PTY identity during promotion, and blocks activation when local PTY support is unavailable. CLI clients now propagate and display desktop status while polling for activation. Startup, runtime, single-instance, quit-policy, unit, wiring, Electron lifecycle, and reliability-gate coverage are added or updated.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is only the template skeleton and lacks actual summary, screenshots, testing, review, security, and notes details. Replace the placeholder template with completed sections: describe the change, add screenshots or say no visual change, list tests run, summarize review/security, and note platform-specific follow-up.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and clearly related to the main change: preserving desktop promotion behavior during serve mode.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

Actionable comments posted: 3

🧹 Nitpick comments (2)
src/cli/runtime/client.ts (2)

118-121: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consistently resolve desktop window status.

For remote status, this code only checks response.result.desktopWindowStatus and misses the fallback for older runtimes that rely on authoritativeWindowId. Consider exporting and reusing resolveDesktopWindowStatus from status.ts to ensure consistent reporting across local and remote connections.

♻️ Proposed fix

You will also need to export resolveDesktopWindowStatus from src/cli/runtime/status.ts and import it in this file.

-            ...(response.result.desktopWindowStatus
-              ? { desktopWindowStatus: response.result.desktopWindowStatus }
-              : {})
+            ...(() => {
+              const resolved = resolveDesktopWindowStatus(response.result)
+              return resolved ? { desktopWindowStatus: resolved } : {}
+            })()

179-182: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Check for blocked status before launching the app.

If the app is already known to be blocked (i.e. running headlessly and cannot open a window), calling launchOrcaApp() unnecessarily spawns a detached process that will simply hit the single-instance lock and exit. Moving this check before the launch avoids the unnecessary process spawn.

⚡ Proposed fix
-    launchOrcaApp()
-    if (initial.result.app.desktopWindowStatus === 'blocked') {
-      throwDesktopActivationBlocked()
-    }
+    if (initial.result.app.desktopWindowStatus === 'blocked') {
+      throwDesktopActivationBlocked()
+    }
+    launchOrcaApp()

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f5b81bce-5f61-4c70-b1b6-20780d26ad23

📥 Commits

Reviewing files that changed from the base of the PR and between 67fdb1c and a4fea5b9acd52519a37a4608df5a34fc8028125b.

📒 Files selected for processing (20)
  • config/reliability-gates.jsonc
  • src/cli/format.ts
  • src/cli/runtime-client.test.ts
  • src/cli/runtime/client.ts
  • src/cli/runtime/status.ts
  • src/cli/runtime/websocket-transport.test.ts
  • src/main/index.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/ssh/ssh-remote-cli-format.ts
  • src/main/ssh/ssh-remote-orca-cli.ts
  • src/main/startup/serve-desktop-activation-wiring.test.ts
  • src/main/startup/serve-desktop-activation.test.ts
  • src/main/startup/serve-desktop-activation.ts
  • src/main/startup/single-instance-lock.test.ts
  • src/main/startup/single-instance-lock.ts
  • src/main/startup/window-all-closed-quit-policy.test.ts
  • src/main/startup/window-all-closed-quit-policy.ts
  • src/shared/runtime-types.ts
  • tests/e2e/headless-serve-desktop-activation.spec.ts

Comment thread src/main/runtime/orca-runtime.ts Resolved
bbingz and others added 3 commits July 13, 2026 19:11
- Check desktopWindowStatus before spawning the Orca app so a blocked
  runtime no longer launches a doomed second instance.
- Reuse resolveDesktopWindowStatus for remote runtime status so it
  honors the same authoritativeWindowId fallback as local status.
- Re-check the authoritative window at spawn time instead of trusting
  a possibly-stale snapshot, since it can be destroyed mid-await.
- Harden the e2e activation spec against silent spawn failures.
@AmethystLiang
AmethystLiang force-pushed the fix-recipe-serve-desktop-promotion branch from c521442 to 6ad6e84 Compare July 14, 2026 02:11
@AmethystLiang
AmethystLiang merged commit 1d2aaf1 into main Jul 14, 2026
6 checks passed
@AmethystLiang AmethystLiang added the orca-remote-server Remote Orca Server / orca serve / paired remote runtime label Jul 22, 2026
Jinwoo-H added a commit that referenced this pull request Aug 5, 2026
…esktop promotion (#12666)

STA-1716 reported that a packaged `orca serve` could become the single-instance owner after the desktop app exits, leaving Dock/Finder unable to restore a window — and that forcing a reopen made the headless process hydrate a renderer that interrupted and DUPLICATED live agent sessions.

Verification against main found every criterion already fixed (#8646 for desktop promotion and the fail-closed CLI, #12212 for duplicate serve activation, #12574 + #9729 for the resume/ownership guards). The genuine gap was criterion 6: the ticket's own automated regression never existed. An existing reliability gate asserted PTY identity survives promotion, but nothing asserted what the incident was actually about — how many agents the promoted renderer resumes.

This adds that coverage: a unit/service-level journey that drives the real single-instance lock, activation gate, settle and focus paths, then runs the real resume logic against a store seeded as a renderer freshly mounted inside the serve process, asserting zero duplicate resumes.

`settleServeDesktopActivation` moved from `index.ts` into its own module with identical semantics, so the test drives the real decision rather than re-implementing it — the earlier repro had to mirror that logic locally, which is the "test passes without running the scenario" failure mode.

Proven to be a real oracle: breaking each guard individually turns it red, and reverting the pre-#12574 pane form reproduces the incident exactly (two duplicate `codex resume` tabs).
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* fix(runtime): preserve terminals during headless desktop activation

* rm design doc

* Fix desktop activation launch ordering and blocked-window status resolut

- Check desktopWindowStatus before spawning the Orca app so a blocked
  runtime no longer launches a doomed second instance.
- Reuse resolveDesktopWindowStatus for remote runtime status so it
  honors the same authoritativeWindowId fallback as local status.
- Re-check the authoritative window at spawn time instead of trusting
  a possibly-stale snapshot, since it can be destroyed mid-await.
- Harden the e2e activation spec against silent spawn failures.

---------

Co-authored-by: bbingz <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…esktop promotion (stablyai#12666)

STA-1716 reported that a packaged `orca serve` could become the single-instance owner after the desktop app exits, leaving Dock/Finder unable to restore a window — and that forcing a reopen made the headless process hydrate a renderer that interrupted and DUPLICATED live agent sessions.

Verification against main found every criterion already fixed (stablyai#8646 for desktop promotion and the fail-closed CLI, stablyai#12212 for duplicate serve activation, stablyai#12574 + stablyai#9729 for the resume/ownership guards). The genuine gap was criterion 6: the ticket's own automated regression never existed. An existing reliability gate asserted PTY identity survives promotion, but nothing asserted what the incident was actually about — how many agents the promoted renderer resumes.

This adds that coverage: a unit/service-level journey that drives the real single-instance lock, activation gate, settle and focus paths, then runs the real resume logic against a store seeded as a renderer freshly mounted inside the serve process, asserting zero duplicate resumes.

`settleServeDesktopActivation` moved from `index.ts` into its own module with identical semantics, so the test drives the real decision rather than re-implementing it — the earlier repro had to mirror that logic locally, which is the "test passes without running the scenario" failure mode.

Proven to be a real oracle: breaking each guard individually turns it red, and reverting the pre-stablyai#12574 pane form reproduces the incident exactly (two duplicate `codex resume` tabs).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

orca-remote-server Remote Orca Server / orca serve / paired remote runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants