Skip to content

fix(serve): keep headless runtime alive on desktop Cmd+Q - #15560

Closed
innocarpe wants to merge 0 commit into
stablyai:mainfrom
innocarpe:fix/serve-cmdq-keep-headless
Closed

innocarpe wants to merge 0 commit into
stablyai:mainfrom
innocarpe:fix/serve-cmdq-keep-headless

Conversation

@innocarpe

Copy link
Copy Markdown
Contributor

Description

On macOS, ⌘Q on a desktop window hosted by orca serve no longer tears down the headless runtime or drops paired remotes.

shouldQuitWhenAllWindowsClosed already keeps serve mode alive for window close. before-quit now uses the same contract: desktop Quit becomes window-close unless an update install is in progress.

Focused fix

  • In scope: before-quit in serve mode (⌘Q / app.quit from a hosted window)
  • Out of scope: changing File > Quit for non-serve desktop, SIGTERM, or serve-stop CLI

Preserves

  • Update-install quits still commit (isQuittingForUpdate)
  • Non-serve desktop Cmd+Q still quits
  • Existing window-close serve-alive policy

Evidence

  • Test: pnpm exec vitest run --config config/vitest.config.ts src/main/startup/window-all-closed-quit-policy.test.ts src/main/startup/desktop-startup-ordering.test.ts → 19 passed
  • Quality: 0 findings on 3 files

User-regression-tradeoffs

  • To stop a serve host after this change, stop the launch agent / process rather than ⌘Q on the hosted window. That matches the existing window-close behavior.

Fixes #15537

@coderabbitai

coderabbitai Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 76765ee0-165b-49dd-b630-74c950bb20fa

📥 Commits

Reviewing files that changed from the base of the PR and between 063b804 and af4f2ba313a62389ed56753df54fdba5e8f98dec.

📒 Files selected for processing (3)
  • src/main/index.ts
  • src/main/startup/window-all-closed-quit-policy.test.ts
  • src/main/startup/window-all-closed-quit-policy.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/main/index.ts
  • src/main/startup/window-all-closed-quit-policy.ts
  • src/main/startup/window-all-closed-quit-policy.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The change adds shouldCommitDesktopQuit to determine whether desktop quits can terminate the process. Update-triggered quits always proceed. Non-update quits proceed only outside serve mode. The before-quit handler prevents rejected quits, closes existing windows, and defers teardown. Tests cover serve-mode, normal desktop, and update-install quit decisions.

Merge Risk: 🟡 Moderate · up to af4f2

In serve mode, the new quit handling can keep the runtime alive not only for desktop Cmd+Q but also for signal-driven shutdown paths, so SIGINT or SIGTERM may fail to terminate the process cleanly. This shutdown risk should be fixed or explicitly accepted before merging.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the fix, scope, rationale, linked issue, trade-offs, and tests, but omits the required Visual Proof section and checklist confirmations. Add Visual Proof with screenshots, video, or an exact N/A justification, then complete the required testing and checklist confirmations.
Linked Issues check ⚠️ Warning For [#15537], the PR preserves the serve runtime and update quits, but it does not add the requested lifecycle trace for ordinary serve-mode quit handling. Record a lifecycle event for blocked and committed desktop quits, including the reason and serve/update state.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the serve-mode Cmd+Q fix and its purpose of keeping the headless runtime alive.
Out of Scope Changes check ✅ Passed The changes are limited to serve-mode before-quit handling, its policy helper, and focused tests; no unrelated code changes are present.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.

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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 18347f9a-7d48-427e-897e-5a076d5d0774

📥 Commits

Reviewing files that changed from the base of the PR and between d7a23c8 and 58427116ff3c84bdc68512e364da1875d1a03f88.

📒 Files selected for processing (3)
  • src/main/index.ts
  • src/main/startup/window-all-closed-quit-policy.test.ts
  • src/main/startup/window-all-closed-quit-policy.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@innocarpe
innocarpe force-pushed the fix/serve-cmdq-keep-headless branch from 5842711 to af4f2ba Compare August 23, 2026 02:20
@innocarpe

Copy link
Copy Markdown
Contributor Author

Sync update (af4f2ba313)

Rebased onto current main (063b804). Scope unchanged: desktop Cmd+Q in serve mode does not terminate the headless runtime. SIGINT/SIGTERM remains out of scope. Evidence: window-all-closed-quit-policy tests 8 passed.

@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

This branch had an error being deployed

1 failed deployment
production — 7a912a3a Deployed Oct 22, 2026 by Jinwoo-H via flip-back #60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: macOS — ⌘Q on a serve-hosted desktop window kills the headless runtime

2 participants