Repository navigation
Commit f2151b6
fix(desktop): client-only boots drain restore and launch intent
## What Changed
- **Drain module:** startup restore and launch intents move to `DesktopStartupDrain.fork.ts`.
- Bounded queue: capacity 8, drops newest with a log line, never blocks.
- Renderer readiness and backend readiness share one drain.
- The drain opens the restore first, then each intent in arrival order, once.
- It re-polls until empty, so an intent queued mid-drain still opens.
- One winner claims the drain; later callers await it.
- A failed open is a typed `ElectronWindowCreateError`.
- `markNotReady` re-arms it after a backend restart.
- **Second-instance buffer:** `DesktopSecondInstanceBuffer.fork.ts` listens from single-instance lock acquisition.
- It holds launches that arrive before `DesktopClerk.configure` registers the real listener.
- It replays them after the first launch's argv, in order.
- **Client-only snapshot:** client-only bootstrap now runs `snapShot.initialize`.
## Why
- **Client-only readiness:** client-only desktop never called `handleBackendReady`, so restore and launch intents only drained in managed mode.
- An update relaunch dropped every window.
- A `--project` cold start opened the hub.
- **Early second launch:** a second launch arriving within about 0.1s of the first was dropped.
- Electron emitted `second-instance` before any app listener existed.
## Close conditions
- [x] Relaunch: client-only update restores windows. Live client-only Electron relaunch with a recorded `window-session.json` reopened exactly `zmux` and `solar`, with no hub. Fork test "opens the restore before an intent queued during it".
- [x] Cold start: client-only `--project` opens it. Live: `--project <solar>` cold start produced one page, the solar project route, with no hub.
- [x] Order: queued intents drain once, in order. Live: second-instance launches at 0.05s ×3, 0.1s ×3 and 0.4s ×2 each opened both windows, A then B, with no duplicate; before the buffer, 0.05–0.1s dropped B in 8 of 8 trials. Fork tests: straggler during an open, followers admitted mid-open, buffer replay once.
- [x] Bound: the queue is bounded. `STARTUP_INTENT_QUEUE_CAPACITY = 8`; the second-instance buffer shares the cap (test "holds at most the startup queue capacity").
- [x] Tests: both backend modes covered. Both readiness paths call the same drain; drain and buffer fork tests are mode-agnostic, and live proof ran in client-only mode.
Live proof ran at `ccde0e21a7`, off-screen on an agent workspace.
## Checklist
- [x] This PR is small and focused
- [x] I explained what changed and why
- [ ] I included before/after screenshots for any UI changes
- [ ] I included a video for animation/interaction changes
No UI changes: startup window-open behavior only; no screenshots.
Closes #1340
## Fork trailers
Squashes:
- d9d39f7 fix(desktop): client-only boots drain restore and launch intent
- faa53bd refactor(multi-window): createWindow seams become marked insertions (#1811) (#1811)
Fork-Domain: multi-window
Fork-Tier: core1 parent cfa2968 commit f2151b6
5 files changed
Lines changed: 490 additions & 0 deletions
File tree
- apps/desktop/src
- app
- window
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
245 | 246 | | |
246 | 247 | | |
247 | 248 | | |
| 249 | + | |
248 | 250 | | |
249 | 251 | | |
250 | 252 | | |
| |||
425 | 427 | | |
426 | 428 | | |
427 | 429 | | |
| 430 | + | |
428 | 431 | | |
429 | 432 | | |
430 | 433 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
0 commit comments