Skip to content

perf(notifications): stop every Windows notification from freezing Orca - #27731

Merged
brennanb2025 merged 7 commits into
mainfrom
brennanb2025/mainio-dismissal-async
Oct 12, 2026
Merged

brennanb2025 merged 7 commits into
mainfrom
brennanb2025/mainio-dismissal-async

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​311 $\color{#cf222e}{\Huge{\mathbf{−}}}$​58 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​253
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​105 $\color{#cf222e}{\Huge{\mathbf{−}}}$​40 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​65

ELI5

On Windows, Orca freezes for a moment every time an agent sends a notification. While it saves a small bookkeeping file, it waits for Windows' file-permission tool to run about five times, and nothing else in the app can respond until that finishes. This PR saves that file in the background instead, so notifications stop freezing the app.

What Changed

The problem users saw. On Windows, every agent notification (a prompt is waiting, a task finished) froze all Orca windows: typing, clicking and terminal output stopped until it passed. On machines with antivirus or endpoint security, each pause can last seconds (#26027, Linear STA-9692).

Why it happened. Every notification records its id in mobile-notification-dismissals.json, so a paired phone can later learn which alerts were already dismissed. That file was saved with the writer Orca uses for credentials. On Windows, that writer runs icacls.exe synchronously about five times per save to lock down the file's permissions: check, reset and grant on the temporary file, check again, then one more check after the rename. Orca's main process handles every window's input and every terminal, so it was stuck for the whole time. It ran on every notification and every dismissal, whether or not a phone was paired.

What changes for the user. Notifications no longer freeze Orca on Windows. Nothing else changes: phones still get the same dismissal history, and it still survives a restart.

The mechanism.

  • The dismissal store now saves through the existing AtomicSnapshotWriter, the same writer that already saves agent status (last-status.json). It writes a temporary file in the background, then renames it over the old one, with file mode 0600. Several notifications in a row collapse into one save of the latest list.
  • The in-memory list is still updated immediately, so delivering and retiring notifications behave exactly as before. A failed save logs a warning, and the next notification tries again.
  • A save still pending at shutdown is awaited:
    • Normal quit: the quit barrier waits for it after chat and server teardown, which can still retire notifications, under the existing 20-second quit deadline.
    • The renderer's Restart button: it exits without the quit pipeline, so its pre-restart hook waits for the save.
    • Headless servers: their server shutdown waits for it.
  • No new writer, flag or setting.

Why

The file contains notification ids, sequence numbers and session ids. It holds no titles, message text, tokens or keys, so it doesn't need the credential writer's per-file permission lockdown. On Windows the new file inherits the permissions of Orca's user-data folder. That folder is under %APPDATA%, so by default only the current user, SYSTEM and Administrators can open it, which are the same three principals the credential writer grants. The Windows box measurement below shows the file's real permissions after the change. last-status.json, which holds prompt text, has used this writer with the same mode for a long time.

Alternatives considered:

  • An async version of the credential writer (open PR fix(runtime): persist mobile notification dismissals without blocking Windows #26754 takes this route). It would still launch about five icacls processes per notification, only without waiting for them. This file doesn't need them, and this PR doesn't build a second shared writer while that PR is open. Moving actual credential stores (device registry, pairing) off the main thread is separate, held follow-up work.
  • Skipping the save when no phone is paired. Rejected: a phone paired later, or a push reconciled after a restart, needs the earlier dismissal history.

Once Orca is committed to exiting (quit, the Restart button, or a headless server stopping), the store waits for its pending save and then saves any later notification immediately with a plain file write, so notifications recorded during shutdown are saved too. The Restart button waits at most 2 seconds for the pending save, the same cap its other pre-restart step uses. Known gap: the automatic restart after a graphics crash exits without this step, so a save still in progress at that moment is lost and the phone may show that one alert again. Before this PR that save would have completed synchronously.

Linked Issue

Fixes #26027. Refs #20497. Linear: STA-9692 (also STA-7408, the sync-spawn umbrella).

Visual Proof

Measured on a real Windows 11 machine ("Windows high spec", NTFS, Defender on). Both builds came from one checkout and ran back to back in the same session, alternating before, after, before, after.

  • Before: origin/main 9d305f3ce4f. After: final PR head 5e4bbc11dbd.
  • Build and launch: production-bundled electron-vite build --mode e2e, launched through the repo's hidden e2e harness (ORCA_E2E_HEADLESS=1, ORCA_BACKGROUND_LAUNCH=1, isolated user-data and home folders). No window was shown or focused.
  • Each run: 30 agent notifications, one per second, sent through the real notifications:dispatch IPC with desktop banners off, so nothing popped up and the mobile bookkeeping still recorded every one. 3 runs per build, plus one discarded warm-up run per build.
  • Metrics:
    • Notification round trip: that IPC handler is synchronous, so its round trip is how long the main process, and every window, was blocked by one notification.
    • Event-loop delay: Orca's own event-loop-delay probe (event-loop-delay.ndjson, one window per second) gives the main-process delay over the same period.

Main-process time per notification, before vs after

Metric (Windows, 3 runs × 30 notifications) Before After
Main-process block per notification, median of run medians (spread) 92.1 ms (89.4–93.1) 0.5 ms (0.4–0.6)
Per notification, p95 per run 131–422 ms 0.8–1.3 ms
Per notification, worst 677 ms 2.5 ms
Worst main event-loop delay in a run, median (spread) 129 ms (124–667) 11.5 ms (10.4–15.1)
Typical per-second worst delay (median of windows) 80 ms 6.6 ms
Notifications saved to the dismissal file 30/30 every run 30/30 every run
  • One "before" run had a 677 ms stall: the permission tool itself stalled. On machines with third-party endpoint security, this kind of stall is the normal cost of each launch. The "after" path launches no processes.
  • An earlier run at f9011be40b2 (before the review fixes) matched: 89.4 ms → 0.5 ms.

File permissions, read with icacls at the end of a run:

  • Before: an explicit protected list: BUILTIN\Administrators:(F), NT AUTHORITY\SYSTEM:(F), <user>:(F).
  • After: inherited from the folder: BUILTIN\Administrators:(I)(F), NT AUTHORITY\SYSTEM:(I)(F), <user>:(I)(F).

Same three principals, nobody else.

Raw JSON per run, the spec and the runner are kept with the lane's QA notes, outside the repo.

Testing

  • Automated tests updated:
    • The store tests cover burst coalescing (20 records, one save of all 20 entries, nothing written synchronously).
    • A failed save keeps memory authoritative and warns instead of throwing, both before and after shutdown begins.
    • After shutdown begins, records save synchronously, including one made while the last background save is still pending.
    • Restart simulations wait for the pending save, as a real quit does.
    • The quit-pipeline test holds chat teardown and server stop separately and proves the dismissal save starts only after both finish (it fails if the save waits for either one alone, or for neither).
    • The Restart button waits for the dismissal save before exiting, and a save that never finishes releases it after 2 seconds. App restart and profile switches don't take this path; they close through quit.
    • The shared background writer has a new regression test: a save requested just as the previous one finishes is no longer dropped. The test fails on the writer before this fix.
    • Tests that delete their temporary data folder now wait for the pending save first, so they no longer leave folders behind.
  • Focused suites pass locally (macOS): the dismissal store and writer, read failure, structured attention (desktop, relay, host retirement, restore), quit pipeline, app relaunch, core-handler wiring, the headless server's cleanup order, and the other users of the shared writer (agent status, stats). tsc for the node and web projects is clean, the mobile test-typecheck ratchet passes, and the repo's CI static checks pass apart from two local-environment-only failures.
  • Real-app Windows measurement on the final head: see Visual Proof.

Review

Three review rounds plus the readiness checklist and a performance scan; no P0–P2 remain. Details, fixes and deferred items are in the review-summary comment below.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Windows: the fix targets Windows. The file inherits user-data folder permissions instead of getting its own lockdown (see Why).
  • macOS/Linux: same 0600 file as before. The save moves from synchronous to background.
  • SSH/remote and headless servers: the store lives on whichever host dispatches notifications. Headless hosts flush it when their server stops.
  • Mobile and older clients: the file format and wire messages are unchanged.
  • Folder workspaces: not affected.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after measurement attached
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (CI will cover the full suites)

Rendered QA — macOS hidden headless E2E

Independent visual QA on head 5e4bbc11dbd, run through the Electron headless E2E harness (ORCA_E2E_HEADLESS=1, ORCA_BACKGROUND_LAUNCH=1, --use-mock-keychain --password-store=basic, isolated profile/home; every BrowserWindow asserted hidden before any interaction). Desktop banners were turned off through the rendered Settings switch, and the main-side setting was read back as disabled, so all 40 real notifications:dispatch calls returned {delivered:false, reason:"disabled"}. The file read at the end held all 40 records with 40 unique notification ids and the latest sequence retained (one epoch); three notifications:dismiss calls recorded dismissal watermarks 41/42/43. This run did not instrument how many disk writes produced that file, so it makes no claim about write count — only that all 40 records persisted.

Typing overlap was verified from renderer-clock timestamps, not wall-clock inference. 40 bounded dispatches were paced ~15–20 ms apart (median 22 ms) while text was typed into the real rendered settings search field, recording performance.now() at every input event and every dispatch call: 14 dispatch calls landed between the first and last input event (the spec asserts at least 2), and typing spanned ~344 ms, so real notification traffic genuinely overlapped real input. No main-process block was observable on macOS; the Windows icacls stall this PR removes is Windows-only, so its measurement stays in the section above.

A clean quit kept all 30 entries and a relaunch on the same profile reloaded them (31 entries after one new notification, two sequence epochs). That flow waited for the initial write to reach disk before quitting, so it demonstrates retained and reloaded history across restart, not a still-pending-write quit barrier; the unit and shutdown tests cover the quit-time flush itself.

Settings: desktop banners disabled through the rendered switch; search field typed into mid-burst
Real settings search showing typed text mid-burst while dispatches are in flight
After the 40-notification burst and dismissals

Every agent notification recorded its id in mobile-notification-dismissals.json
through the secure-file writer. On Windows that writer runs about five
synchronous icacls launches per write, so each notification froze every Orca
window (STA-9692).

The file holds notification ids, sequence numbers and session ids, not
credentials, so it now goes through the existing AtomicSnapshotWriter: async
temp-plus-rename, mode 0600, bursts coalesced into one write of the latest
entries. Memory stays authoritative, so delivery and retirement are unchanged.
The pending write is flushed in the quit barrier after chat and RPC teardown,
and in the pre-relaunch hook, since renderer relaunch exits without the quit
pipeline.
…ts down

orcad never runs the desktop quit barrier, so its cleanup list awaits the
pending dismissal write after RPC stops.
… ends

AtomicSnapshotWriter cleared its pending-write promise one microtask after
the drain loop saw no more requests. A write() in that gap set
writeRequested, got the settling promise back, and nothing drained it, so
the newest bytes stayed unwritten and waitForPendingWrite() (the dismissal
store's flush) resolved without them. The drain now clears the pending
promise in the same tick its loop exits, on success and failure, so a later
write() always starts a new drain.
…e dirs

Dismissal history now saves asynchronously, and the writer recreates its
directory before each write. Tests that deleted their temp dir with a write
still pending left recreated dirs behind in the system temp folder and could
race the delete on Windows. They now await the controller's flush first.
The shutdown flush only waited for writes already queued. A notification
recorded after it (orcad cleanups still running, or the 150 ms before a
renderer relaunch calls app.exit) started an async write the exit dropped,
so the phone could keep an alert the desktop could no longer withdraw.

The store's flush() becomes close(): it waits for the pending write, and
every later record saves synchronously through the snapshot writer's
existing writeSync (plain fs, no icacls; a failure only warns). It is called
only where the exit can no longer be vetoed: the will-quit teardown, a new
exit-only hook that app:relaunch runs before app.exit(0) (restart and
profile switches share onBeforeRelaunch but quit through will-quit), and
orcad's cleanup after RPC stops.

The quit test now holds chat teardown and RPC stop and proves the close
starts only after both settle, in either order. The orcad push-startup
runtime mock gains the method the entry now calls.
app:relaunch waited on the dismissal store's close with no limit, so a
stalled userData disk left Restart stuck on "Restarting…" with a half-quit
app saving synchronously. The close now races a 2 s cap through the
existing settleWithinMs helper, the same cap the restart path's auth
preservation uses, and logs when it gives up.
…eads

Mid-test disk reads used closeDismissals() as a barrier, which switched
every later record to the exit-only synchronous path. The store gains a
non-closing flush() (close() = mark closed + flush), exposed on the
controller as flushDismissals for tests; mid-test barriers use it, and
close stays only where a test simulates an exit or teardown. Also notes why
the writer's pendingWrite assignment is safe, renames a store test to what
it covers, and groups the orcad cleanup-order test under a describe.
@brennanb2025

brennanb2025 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Every agent notification could freeze all Orca windows on Windows because saving phone dismissal history synchronously launched the file-permission tool about five times. This PR moves that ordinary bookkeeping file to Orca’s existing background snapshot writer, so notifications and dismissals update memory immediately and bursts save the latest history together. Normal quit, the Restart button, and headless shutdown preserve pending history; the file format and phone protocol are unchanged.

The earlier three-round review fixed a dropped-write race in the shared writer, cleanup tests that deleted folders before background saves finished, shutdown ordering and late records, and an unbounded Restart wait. A fresh independent correctness review and issue-first architecture challenge found no new issue and recommended keeping the design; no code changes were needed in this independent loop. The final reviewed commit remains 5e4bbc11dbd, which is also the measured commit. Current-main merge preview is clean and retains headless cleanup ordering, so no branch sync was needed.

Review status: Ready, with the deferred limitations below.

Verified:

  • 308 tests pass on the successful focused, Node-server and mobile routes, with four server skips. Independent filesystem checks exercise rename interleavings, unreadable originals, retry after failure, and the writer’s microtask race; the race reproduces on main and is fixed here. Native Windows rename interleavings were not exercised by those macOS checks.
  • The saved Windows measurements cover three runs of 30 notifications per arm on the same host. Median notification round trip falls from 92.1 ms to 0.5 ms; every run saved all 30 records. Those raw files and the hidden-app harness were independently inspected.
  • GitHub CI: 28 passed, 25 skipped. Local orca-ci-checks passed 24/26; the failures are the installed Bun 1.3.14 lacking the pinned 1.4.2 command and no-cycle warnings in unchanged mobile files. All four projects also pass direct queued TypeScript checks. The additional server sweep has 14 timeouts under installed Bun but passes all 119 non-skipped tests under Node; the Bun root cause was not established.
  • Final readiness and dedicated performance scan passed with no new P0–P2; all six performance questions were covered. Remote hidden Electron QA also passed three checks on the rebuilt reviewed commit. All 40 notification records and dismissal watermarks persisted; quit/relaunch retained and reloaded history. A paced follow-up proves 14 real notification calls overlapped eight rendered input events. I independently read the harness/raw results, recomputed the overlap, and inspected the attached screenshots. That QA did not count disk writes or test quitting with a write still pending; focused shutdown tests cover the latter. It used synthetic identifiers and did not exercise a paired phone, SSH, packaged builds, or visible desktop frames.

Deferred: a graphics-crash restart can lose the last background snapshot and re-show a phone alert; a late shutdown record still performs a synchronous plain file write, so a stalled disk can block exit timers, as synchronous writes did on main. One pending promise handler per event while storage is stalled, duplicate save-failure warnings, one extra retained serialized snapshot (entry count capped at 4096; bytes depend on identifiers), and minor test-maintenance issues remain nonblocking. The pre-existing shared writer’s equality cache can become stale after mixed async/sync writes; it reproduces on main too, and dismissal history does not enable that equality shortcut.

The ordinary asynchronous persistence and atomic replacement follow the common pattern. The memory-first delivery policy, burst coalescing, and committed-exit synchronous fallback are intended choices for this notification history; the fallback’s stalled-disk limitation is explicit above.

The original PR body is preserved with corrected QA evidence appended. All helper tasks are settled, the dedicated remote QA worktree is removed, and the shared QA slot is free. The reviewed commit is unchanged; PR stays open, ready, and unmerged.

@brennanb2025
brennanb2025 marked this pull request as ready for review October 12, 2026 05:45
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The dismissal store now queues snapshot writes while open and provides flush and close operations. Runtime controller APIs expose these operations, and relaunch, quit, and Orcad lifecycle paths invoke dismissal cleanup. Relaunch cleanup waits up to 2,000 ms. The snapshot writer also updates how it drains pending writes. Tests now await persistence and cleanup before checking stored state or removing temporary directories.


Priority: ⬆️ High

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to 5e4bb

The cleanup-order test may need maintenance after a harmless source edit, but no production failure is established. The change is mergeable with that bounded concern understood.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 26 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Issue [#26027] requires removal of synchronous Windows write-path blocking for notification dismissal persistence. MobileNotificationDismissalStore now uses AtomicSnapshotWriter, queues coalesced …
Out of Scope Changes check Passed The changed lifecycle code flushes or closes dismissal persistence during quit, relaunch, headless shutdown, and test cleanup. The AtomicSnapshotWriter race fix protects the new persistence path and…
Title check Passed The title clearly identifies the primary change: preventing Windows notification handling from freezing Orca.
Description check Passed The description follows the required template and explains the user impact, mechanism, rationale, linked issue, testing, visual proof, platform considerations, and known limitations. The unchecked ful…

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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/orcad/orcad-entry.test.ts (1)

174-184: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Source-text assertion is brittle.

The test checks string positions in orcad-entry.ts. A formatter change or an arrow-function rewrite breaks it without a behavior change. The test also passes if either string moves into a comment. The comment on line 175 acknowledges this. Prefer a behavioral test if the cleanup runner can be exercised in isolation.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: abc140ee-6998-4ab0-b520-76e6d8fc3582
📥 Commits

Reviewing files that changed from the base of the PR and between a4da555 and 5e4bbc1.

📒 Files selected for processing (26)
  • mobile/src/notifications/push-original-delivery-retirement.test.ts
  • src/main/ipc/app.test.ts
  • src/main/ipc/app.ts
  • src/main/ipc/notifications-subject-retirement.test.ts
  • src/main/ipc/register-core-handlers/register-core-handlers.test.ts
  • src/main/ipc/register-core-handlers/register-core-handlers.ts
  • src/main/orcad/orcad-entry.test.ts
  • src/main/orcad/orcad-entry.ts
  • src/main/orcad/orcad-push-startup.test.ts
  • src/main/persistence/atomic-snapshot-writer.test.ts
  • src/main/persistence/atomic-snapshot-writer.ts
  • src/main/runtime/mobile-notification-dismissal-read-failure.test.ts
  • src/main/runtime/mobile-notification-dismissal-store.test.ts
  • src/main/runtime/mobile-notification-dismissal-store.ts
  • src/main/runtime/rpc/methods/structured-agent-session-attention-ack.test.ts
  • src/main/runtime/runtime-mobile-notification-controller.ts
  • src/main/runtime/runtime-service-command-surface.ts
  • src/main/runtime/structured-agent-session-mobile-restore.test.ts
  • src/main/runtime/structured-agent-session-mobile-retirement.test.ts
  • src/main/runtime/structured-attention-original-delivery.test-fixture.ts
  • src/main/startup/main-process-quit-pending-writer.test.ts
  • src/main/startup/main-process-quit.ts
  • tests/e2e/structured-attention-host-read-retirement.unit.test.ts
  • tests/e2e/structured-attention-prompt-relay.unit.test.ts
  • tests/e2e/structured-attention-read-retirement.test-fixture.tsx
  • tests/e2e/structured-attention-read-retirement.unit.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

@brennanb2025
brennanb2025 merged commit 3fb4b06 into main Oct 12, 2026
73 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/mainio-dismissal-async branch October 12, 2026 23:55
brennanb2025 added a commit that referenced this pull request Oct 15, 2026
…ca (#27731)

* perf(notifications): save mobile dismissal history off the main thread

Every agent notification recorded its id in mobile-notification-dismissals.json
through the secure-file writer. On Windows that writer runs about five
synchronous icacls launches per write, so each notification froze every Orca
window (STA-9692).

The file holds notification ids, sequence numbers and session ids, not
credentials, so it now goes through the existing AtomicSnapshotWriter: async
temp-plus-rename, mode 0600, bursts coalesced into one write of the latest
entries. Memory stays authoritative, so delivery and retirement are unchanged.
The pending write is flushed in the quit barrier after chat and RPC teardown,
and in the pre-relaunch hook, since renderer relaunch exits without the quit
pipeline.

* perf(notifications): flush dismissal history when a headless host shuts down

orcad never runs the desktop quit barrier, so its cleanup list awaits the
pending dismissal write after RPC stops.

* fix(persistence): drain a snapshot write requested just after a drain ends

AtomicSnapshotWriter cleared its pending-write promise one microtask after
the drain loop saw no more requests. A write() in that gap set
writeRequested, got the settling promise back, and nothing drained it, so
the newest bytes stayed unwritten and waitForPendingWrite() (the dismissal
store's flush) resolved without them. The drain now clears the pending
promise in the same tick its loop exits, on success and failure, so a later
write() always starts a new drain.

* test(notifications): flush dismissal writes before deleting temp state dirs

Dismissal history now saves asynchronously, and the writer recreates its
directory before each write. Tests that deleted their temp dir with a write
still pending left recreated dirs behind in the system temp folder and could
race the delete on Windows. They now await the controller's flush first.

* perf(notifications): close dismissal history at committed exits

The shutdown flush only waited for writes already queued. A notification
recorded after it (orcad cleanups still running, or the 150 ms before a
renderer relaunch calls app.exit) started an async write the exit dropped,
so the phone could keep an alert the desktop could no longer withdraw.

The store's flush() becomes close(): it waits for the pending write, and
every later record saves synchronously through the snapshot writer's
existing writeSync (plain fs, no icacls; a failure only warns). It is called
only where the exit can no longer be vetoed: the will-quit teardown, a new
exit-only hook that app:relaunch runs before app.exit(0) (restart and
profile switches share onBeforeRelaunch but quit through will-quit), and
orcad's cleanup after RPC stops.

The quit test now holds chat teardown and RPC stop and proves the close
starts only after both settle, in either order. The orcad push-startup
runtime mock gains the method the entry now calls.

* fix(notifications): bound the dismissal close before a renderer relaunch

app:relaunch waited on the dismissal store's close with no limit, so a
stalled userData disk left Restart stuck on "Restarting…" with a half-quit
app saving synchronously. The close now races a 2 s cap through the
existing settleWithinMs helper, the same cap the restart path's auth
preservation uses, and logs when it gives up.

* test(notifications): keep async dismissal writes under test between reads

Mid-test disk reads used closeDismissals() as a barrier, which switched
every later record to the exit-only synchronous path. The store gains a
non-closing flush() (close() = mark closed + flush), exposed on the
controller as flushDismissals for tests; mid-test barriers use it, and
close stays only where a test simulates an exit or teardown. Also notes why
the writer's pendingWrite assignment is safe, renames a store test to what
it covers, and groups the orcad cleanup-order test under a describe.

(cherry picked from commit 3fb4b06)

Backport to 1.4.224: this base has no AtomicSnapshotWriter (src/main/persistence/atomic-snapshot-writer.ts, added by #26822, is not on 1.4.224), so the dismissal store saves through the existing StatsSnapshotWriter, its predecessor with the same async temp-plus-rename and writeSync. StatsSnapshotWriter gains an optional fileMode (0o600 for the dismissal file; stats unchanged) and the PR's drain-race fix; the writer regression test moves to a new stats-snapshot-writer.test.ts. The two conflicting e2e tests keep 1.4.224's shape with the PR's async liveDeliveries()/closeDismissals() edits applied, and the same edit is applied to structured-attention-relay-settlement.unit.test.ts, which exists only on this base.
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]: Windows: UI freezes for seconds on every agent prompt — secure file writes run icacls synchronously on the main thread

1 participant