Repository navigation
Description
createWindow() is the last statement of app.whenReady() (electron/main.js:449). Everything in the 234 lines above it runs before a single pixel exists, and most of it does not need a window to be absent.
What sits in front of first paint
Measured on the live workspace (2026-08-20, 545 threads, 170 MB store):
new Store(storePath) main.js:293
fs.readFileSync 170 MB 234 ms sync
JSON.parse 330 ms sync
fs.copyFileSync → .bak (170 MB) 62 ms sync
------
626 ms of blocking main-process work
await memorySupervisor.start() main.js:284
probeHealth on an existing server, HEALTH_TIMEOUT_MS = 1000 ms budget
(memory-sup.js:12, awaited at main.js:284 despite the "never block app start" comment)
lastStatus Map build over 545 threads main.js:296-299
await import(core) main.js:248
legacy userData migration probes main.js:255-268
grok/user MCP config sync main.js:430-447
None of that produces UI. The window is created with backgroundColor: "#0b0e14" and no ready-to-show gate, so the user gets a dark rectangle only after the whole chain completes.
The .bak copy deserves its own mention: 170 MB is read and re-written to disk on every single launch, synchronously, on the critical path, purely as a rolling backup (store.js:1086).
Fix
createWindow()first. Create and load the window at the top ofwhenReady, then do the store load and supervisor start. The renderer already handles an empty initial state (it fetches lists on mount); aboot:readypush when the store is up is the only wiring needed.- Do not await
memorySupervisor.start(). The comment atmain.js:283already says "Never block or fail app start on memory supervision" — theawaiton the next line contradicts it. Fire it and let it settle; every consumer already tolerates memory being absent. - Move the
.bakcopy off the critical path. It is a rolling backup of a file that was just read successfully; doing it after first paint (or on the first idle flush) loses nothing.
#225 removes the largest chunk of this by shrinking the blob, and should land first — but the ordering is wrong independently of size, and 1 and 2 are a handful of lines that hold under any future store shape.
While in there: waitForHealth (memory-sup.js:803) has no callers anywhere in electron/. Either the spawn path was meant to wait on it and does not, or it is dead and should go.
Tests
- A boot with a deliberately slow store load still creates the window before the load resolves (assert ordering via the existing main-process seams).
memorySupervisor.start()rejecting or hanging does not delaycreateWindow().- Store load still writes the
.bakexactly once per boot, just not before the window.
Related
#225 (shrinks the 626 ms, does not fix the ordering), #418 (startup umbrella — enableCompileCache, Slack-style boot data; module.enableCompileCache() is still absent from electron/), #617 (the other end: what the renderer does once it is up), #124.
Activity
currentbits commentedon Aug 21, 2026
Implemented in this worktree:
createWindow()runs at the top ofwhenReadyviabootFirstPaint(menu first, then the window, then a yield so Chromium can paint).memorySupervisor.start()is no longer awaited; hang/reject cannot stall first paint..bakcopy issetImmediateafter a successful load, not on the constructor’s sync path.boot:readypush once IPC handlers exist.waitForHealthremoved; spawn already polls inline because the port can move.Tests:
electron/test/boot.test.js, store.bakdeferral,appWiringrefetch.currentbits commentedon Aug 22, 2026
Landed on
mainin the 2026-08-22 backlog merge (2d33d30..bf7c4dc, released as nightlynightly-202608220926-bf7c4dc).Evidence on main: electron/boot.js bootFirstPaint; window paints before store load
The branch had been finished for a while but was never merged; verification after landing: typecheck clean,
vite buildok, core 38/38, renderer 1468/1468, memory 204/204, electron 1848/1848.