refactor(desktop): enforce a metadata-free renderer startup boundary - #2176
Conversation
d197de3 to
2fcb7e0
Compare
|
Thanks for this — I verified the headline claims by rebuilding both trees: the startup JS drops ~32% (1,974KB → 1,339KB on my fresh build), the metadata-name markers go from 266 matches to 0 across all 27 startup chunks, Merge blocker — the branch conflicts with P2 — the claimed contract test for the startup boundary doesn't exist. The PR body says "A contract test keeps it aligned with the first four recommended providers at test time", but P2 — the snapshot payload has no runtime contract pin. The renderer consumes P3 (optional): the The design and the refactor itself are sound — happy to approve once rebased and the boundary test lands (or is explicitly deferred). |
cd30b8c to
59be1c6
Compare
Keep full model metadata behind the main-process and lazy-settings boundaries, and project only first-screen data through onboarding snapshots. Refs apache#2063 Relates to apache#2084
Lock sessions when user messages are appended and migrate legacy unlocked sessions once, keeping read paths pure.
59be1c6 to
30c68c9
Compare
|
Thanks for the follow-up — both P2s are closed with verified enforcement, and I confirmed by mutation rather than inference:
Five optional notes, none blocking:
Merging now — the boundary finally has teeth. |
Summary
onboarding:getSnapshotto project only first-screen model choices, thinking levels, provider labels, and session send outcomesCloses #2063
Relates to #2084
sequenceDiagram participant R as Renderer Main Thread participant IPC as IPC Bridge participant M as Main Process participant MM as model-metadata 520KB Note over R,MM: BEFORE R->>MM: parse + eval 520 KB (5 import paths) Note right of R: BLOCKED — not needed for first screen R->>R: build choices / thinking / menu / display / hero R->>IPC: hasSecret per connection IPC-->>R: secret presence R->>R: re-derive projection Note over R: first screen ready Note over R,MM: AFTER M->>MM: parse 520 KB (already loaded) M->>M: buildChatModelChoices + projectSessionSendOutcome M->>IPC: onboarding:getSnapshot (existing channel) IPC-->>R: chatModelChoices + sessionSendOutcomes R->>R: render first screen (snapshot + local + constant) Note over R: no metadata on main thread Note over M: SettingsModal lazy-loads on user clickMeasured result
The artifact and isolated parse cost improved materially. End-to-end cold start and Chromium script duration were unchanged within run-to-run noise, so this PR does not claim a user-visible wall-clock startup improvement.
Architecture boundary
The main process remains the metadata authority. The renderer startup path consumes a lightweight projection; full catalog data remains available only to main-process code and lazy-loaded Settings paths. Explicit core subpaths make that boundary independent of barrel reachability, with
sideEffects: falseand tree-shaking as a second defense.FIRST_RUN_PROVIDER_TYPESis intentionally a metadata-free product constant. A contract test keeps it aligned with the first four recommended providers at test time rather than reintroducing a runtime registry dependency.Review follow-up
Verification
npm --workspace @maka/desktop run typecheck— passednpm --workspace @maka/desktop test— 1,751 passednpm --workspace @maka/storage test— passednpm --workspace @maka/desktop run build:renderer— passed, including third-party notice verificationgit diff --check— passed