Repository navigation
fix(chat): retain warm startup receipts after deferred mount - #175883
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@clawsweeper re-review The final diff and proof are current. Twelve concurrent paired candidate warm reloads preserve all three receipt hashes and return 306 bytes with zero messages and no history fill. Median FCP difference is 0 ms; deferred-mount final-message visibility is neutral across eight pairs. Independent review and 40 focused tests pass; broader CI is running. |
|
🦞👀 Re-review progress:
|
What Problem This Solves
Fixes full-history downloads on warm reload when the chat pane mounts after the Gateway is ready. Follow-up to #175816: startup can no longer outrun retained cursor and metadata hydration.
User Impact
Warm reloads reuse the conversation and receipt hashes while retaining the earlier first paint. Missing, invalid, or unavailable caches still fall back to a full request. No configuration or migration is required.
Why This Change Was Made
The history owner previously joined snapshot hydration only before applying the response, after sending an empty
knownStatewithout a cursor. Move that existing bounded wait before request construction, after stream admission. The frame handoff is unchanged. The existing two-second cache timeout now bounds request issuance, so unavailable storage still fails open.Production change: −1 line net, with no new owner, state, timer, or cache. Consolidated the now-impossible history-before-initial-cache test ordering while preserving cached row identity and widget-height assertions.
Evidence
All 12 unprofiled candidate warm reloads: retained cursor plus all three receipt hashes, 306 framed bytes / 224 payload bytes, zero messages and no
chat.history. Failing baseline runs returned 154,318 framed bytes / 80 messages. The baseline reproduced the race in 4/4 fast-connection and 7/8 deferred-mount runs.Concurrent pairs on an isolated Linux sandbox use separate 16-core CPU sets, state, and ports, swap core halves each pair, and hold an exclusive measurement lock. Actual warm starts differ by at most 2 ms; per-pair outside load was recorded. Values below are median candidate minus baseline within each pair:
Deferred restore blocking remains 0 ms on both sides in all eight pairs. Final-message mean difference is +7.88 ms, range −39.4…+100.4 ms. The +100.4 ms outlier remains included; four extra pairs checked the distribution. Cold FCP medians are +4/0 ms and cold final-message medians +11.7/+2.75 ms respectively. Final row counts and ordered sidebar keys match, with no browser errors.
Two separate traced pairs confirm an actual Chrome Paint between sidebar restoration and pane mounting, with retained data still pending. Example candidate: sidebar task ends 223.977 ms, Paint 234.417–234.939 ms, pane starts 236.164 ms, retained-record delivery 336.4 ms. Traced timings are excluded from the comparison above.
The headless fixture uses 80 retained messages, 80 sidebar sessions, five pending inputs, session info, and 150 commands. Deferred mode releases hello after the sidebar frame boundary and adds 120 ms only to retained chat-record delivery; subscription is immediate. It proves avoided full-page resend and no candidate history fill, but does not model the reported larger-session pagination cascade. Synthetic data only. Chromium 155 actually paints, verified by trace Paint events and filmstrip. Identical measurement-only dependency deviations on both sides: Vite 8.3.2 versus 8.3.4, Playwright 1.63 versus 1.64, CodeMirror language 6.12.4 versus 6.13.1 and view 6.43.13 versus 6.43.14; Solid runtime/compiler match the pinned version. Owned sandbox and processes are removed.
The deferred-mount regression fails on the base with
knownState: {}and no cursor, then passes with retained data. Focused checks: warm startup 26/26, persistent snapshot hydration 7/7, stream admission 7/7, changed-file lint/format and diff checks pass. Independent autoreview is clean through P2 after correcting a sibling test's obsolete immediate-request expectation. PR CI passed all required checks on9b542203ba906c26137ccccb0803a082a6eed2ec, including UI tests, E2E, performance, types, lint, and the final CI/security gates; no Testbox lease or local broad gate was used.Inspected synthetic before/after final-content screenshots are byte-identical: