Repository navigation
fix(app): bound the wake/quit paths implicated in the phone-session-ended freeze (#9447) - #9853
Conversation
…nded freeze (#9447) - relay-transport: waitForClose now times out (5s) so a half-open post-sleep socket can't wedge runtimeRpc.stop() - will-quit: race teardown against a 20s deadline so app.quit() always runs (Force Quit was the only escape when any teardown member never settled) - terminal-fit-restore: local restoreTerminalFit invoke gets the same 15s bound as the remote path so the held-fit modal buttons can't pin disabled
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds bounded timeout handling for relay socket closure, application quit teardown, renderer quit acknowledgement, and terminal fit restoration. Main-process shutdown races teardown completion against a fixed deadline. Relay transport shutdown resolves when sockets close or time out. Renderer close requests receive acknowledgement before a bounded force-destroy fallback. Local and remote terminal restoration share a deadline, including bulk restores. Concurrent terminal restore IPC requests are deduplicated by PTY. Tests cover settled and hanging operations with fake timers. 🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
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 |
…s-app-freezes-on-the-phone-session-ended
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8899809a-fab4-48a0-ad56-6f12cb4908e5
📒 Files selected for processing (11)
src/main/index.tssrc/main/quit-teardown-deadline.test.tssrc/main/quit-teardown-deadline.tssrc/main/runtime/rpc/relay-transport.test.tssrc/main/runtime/rpc/relay-transport.tssrc/main/window/createMainWindow.test.tssrc/main/window/createMainWindow.tssrc/main/window/window-close-decision.tssrc/preload/index.tssrc/renderer/src/components/terminal-pane/terminal-fit-restore.test.tssrc/renderer/src/components/terminal-pane/terminal-fit-restore.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- src/main/quit-teardown-deadline.test.ts
- src/main/index.ts
- src/renderer/src/components/terminal-pane/terminal-fit-restore.ts
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8e50a73c-0d07-4714-b2fb-ba2c48859ade
📒 Files selected for processing (4)
src/main/ipc/runtime.test.tssrc/main/ipc/runtime.tssrc/main/runtime/rpc/relay-transport.test.tssrc/main/runtime/rpc/relay-transport.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/runtime/rpc/relay-transport.ts
…s-app-freezes-on-the-phone-session-ended
…s-app-freezes-on-the-phone-session-ended
…s-app-freezes-on-the-phone-session-ended # Conflicts: # src/main/ipc/worktree-common-git-directory.ts # src/main/skills/skill-installation-topology.ts
…s-app-freezes-on-the-phone-session-ended
…s-app-freezes-on-the-phone-session-ended
…s-app-freezes-on-the-phone-session-ended # Conflicts: # resources/skills/release-mapping.json
…s-app-freezes-on-the-phone-session-ended # Conflicts: # src/main/runtime/relay/relay-control-origin.ts # src/main/runtime/relay/relay-session-broker.test.ts # src/main/runtime/rpc/mobile-socket-wiring.ts # src/main/runtime/rpc/relay-transport.ts
…s-app-freezes-on-the-phone-session-ended
This reverts commit 8f40ddf (#10179). Rebased on current main. The revert applied cleanly across the vast majority of the 1,626-file PR; the remaining work was preserving PRs that had been built on top of #10179 after it merged. All are preserved: - #9990 perf(terminal): cold-restore replay - #10213 fix(codex): TUI settings promotion - #10135 fix(mobile): images in native chat - #9387 fix(status-bar): Resource Manager badge + concurrent listSessions - #9853 fix(app): bound wake/quit paths (phone-session-ended freeze) - #10237 fix(claude-accounts): quote claude path for Windows (kept shell:false) Because those PRs were written against helper modules/APIs that #10179 introduced, the minimal, typecheck-verified closure they depend on is kept so the tree builds and every later-PR test passes: - bounded file/JSON readers used by #10213/#9990 (agent-state-file-reader, node-bounded-file-reader, json-text-structure-limit, terminal-history limits) - claimed-agent-pty-owner cap API + pty:listSessions admission (#9990/#9387) - the mobile-E2EE outbound-memory-budget subsystem #9853 builds on (e2ee-channel, mobile-e2ee-*, ws-outbound-backpressure-queue, remote-runtime-request-frames/-memory-limits, map-with-concurrency, e2ee-crypto) Everything else #10179 added (~555 files) is deleted; every file it modified elsewhere is restored to its pre-#10179 state. Verified: root typecheck (node+cli+web), mobile typecheck, full root test suite, full mobile test suite, oxlint, localization catalog + coverage, reliability gates, max-lines ratchet, and the CLI emit build all pass. Two checks fail only locally and fail identically on clean origin/main (this clone's git-tag namespace for verify:skill-bundle-manifest; an inherited GIT_CONFIG_* env for one relay test) — both pass on a clean CI environment. Co-authored-by: Orca <[email protected]>
…nded freeze (stablyai#9447) (stablyai#9853) * fix(app): bound the wake/quit paths implicated in the phone-session-ended freeze (stablyai#9447) - relay-transport: waitForClose now times out (5s) so a half-open post-sleep socket can't wedge runtimeRpc.stop() - will-quit: race teardown against a 20s deadline so app.quit() always runs (Force Quit was the only escape when any teardown member never settled) - terminal-fit-restore: local restoreTerminalFit invoke gets the same 15s bound as the remote path so the held-fit modal buttons can't pin disabled * fix(app): close wake recovery timeout gaps * fix(relay): drop late frames after forced teardown * fix(relay): fence detached socket callbacks * fix(app): close timeout resource gaps * fix(relay): detach retired mobile transports * fix(types): exclude absent stat overloads * fix(runtime): expire wedged terminal restore dedupe * fix(runtime): keep restore retries on one reclaim * chore(skills): refresh bundled skill manifests * fix(window): fence quit acknowledgements by request * fix(relay): bound revoked device socket cleanup
Bounds every wait and handshake reachable from #9447: macOS could wake onto the phone-session-ended restore modal with a frozen renderer, restore actions that never settled, and a quit path that never reached teardown.
What changed
will-quituntil renderer-backed windows close. Each app-wide close request now carries a per-window identity token, and preload acknowledges that exact request immediately. Responsive renderers retain dirty-file prompts and synchronous checkpoint behavior; stale acknowledgements from earlier or duplicate close attempts cannot disarm the active deadline; and an already-unresponsive renderer is destroyed after 10s so normal main-process cleanup can proceed. Ordinary window closes are unchanged.CloudRelayTransport.stop()installs close waiters beforeterminate(), handles synchronous close, and finalizes connection metadata/callback ownership on timeout. Expired attach handshakes now release that ownership immediately even when a half-open socket never emitsclose, so stale connection IDs and listeners cannot survive until origin shutdown.app.quit().The branch also contains the merged #9847 wake-reconnect coalescing fix from
main, which removes the independently confirmed renderer freeze caused by staggered reconnect refresh storms.Reliability contract
window.quit.bounded-exit— app-wide quit cannot wait forever before or duringwill-quit; a responsive renderer still owns save/checkpoint decisions.terminal-geometry.visible-convergence— explicit phone-to-desktop restore either converges or returns control within one 15s action budget, with no unbounded provider fanout.mobile-relay.cleanup— stopped or attach-expired relay sockets release connection identity and close callbacks even when the OS never supplies a close event.terminal-geometry.visible-convergencegate passed. Window-quit acknowledgement and relay-stop timeout have deterministic unit coverage here; no matching manifest gate exists yet, so promotion/soak history remains an accepted gap.Verification
pnpm run typecheck— passed.terminal-geometry.visible-convergencegate — 1,393 tests passed.mobile-banner.spec.ts— 5 passed, including hidden-workspace restore-all.oxfmt --check, touched-file oxlint, max-lines ratchet, and reliability manifest validation — passed.pnpm testunder the locally installed, unsupported Node 26 completed with 34,692 passed, 46 unrelated environment-sensitive failures, and 58 skipped (primarily unavailablelocalStorage, subprocess timeouts, and inherited process-environment contamination); focused and reliability gates were green.pnpm run lintpasses oxlint, switch exhaustiveness, reliability, max-lines, and bundled-skill checks, then reaches unrelated localization keys missing fromen.jsonon currentmain. Touched-file lint and format checks pass.Residual gap
The exact real-sleep renderer freeze trigger from 1.4.138-rc.7 was not reproduced in three paired iOS-simulator runs. Current
mainnow includes #9847 for the proven wake reconnect freeze, while this PR makes restore and quit bounded if another renderer or transport stall remains. Reporter retest on the resulting build is still required before claiming the original hardware-specific trigger is fully reproduced.Fixes #9447.
ELI5
Think of the app as several people waiting for answers after the Mac wakes up: the phone connection, terminal resize, window, and quit cleanup. Before this change, one part that never answered could make everyone wait forever, leaving the app frozen and Cmd+Q stuck. Now each wait has a reasonable deadline, stale connections are cleaned up, and wake-up reconnect requests are grouped so they cannot overwhelm the UI. Responsive sessions still follow the normal save and shutdown flow; this only provides an escape when something is genuinely stuck.