Repository navigation
perf(chat): bound the background warm with the same window walk - #16005
Conversation
UX Review (Fable 5) — ✅ PASSUX-level review of UX-Verdict: PASS Verify a background pane past the walk cap still restores older scrollback via the normal page-back affordance after cache replacement. [UX-REVIEWED] bc47eba Description read[DESCRIPTION-READ] dfe65152c8db8c968b76e501aeba4730996312aacc530866059ddf8520601475 That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Confirm the one UX narrowing: a >4,000-row gap now replaces a background pane's held scrollback with the walked window (page-back recovers it), matching #13236's documented cost. Suggestions
[DESIGN-REVIEWED] bc47eba Description read[DESCRIPTION-READ] a48a9e4268df5c07b9a91da65e0ed6fe0c2297fedb643407287dc5003d5d6b3e That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the one shipped narrowing: a >4,000-row gap now replaces the pane's held history with the newest ~4,500 rows — declared, and the same page-back cost #13236 recorded for the sibling readers. Not justified as shipped
What this change shipsInventory (8 items) — 7 justifiedIntent: stop a background pane's cache warm from re-downloading the whole transcript once it holds more than one page — a FIX, with provenance (measured capture in the description, #15029, and 9 added tests that redden on revert).
Consumer counts: [FIRST-PRINCIPLES-REVIEWED] bc47eba Description read[DESCRIPTION-READ] 7893fe1bcec52747fe2c7a77f0872e890cad6ec0739555dc1adcd2e7f3c359ce That sha256 names the PR description this verdict read. Recompute it with |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
d195500 to
5c519a0
Compare
|
|
|
|
5c519a0 to
1d07cfe
Compare
|
warmSlotCache read a background pane's whole transcript whenever the pane held more than one page (the count-matched limit declines past the handler's 500-row clamp) and whenever the bounded window missed a cached row. It runs on every off-screen chat_done and on every reconnect, so a long session re-downloaded its full history on each background turn end. A cache past the clamp now asks for one clamp-sized page, and a coverage miss is closed with walkWindowBackTo, as refreshSlot and switchSlot do. A miss the walk cannot close (a cached row newer than the window's start: a rewind, a rewrite, or a stale response) is settled with one fresh read of the same bounded page. A walk that spends its page cap without anchoring replaces the cache instead of being spliced onto it, so no hole is published. Every request on the path is bounded, so the retained total is always the collapsed count. The identity guards (no identified row, an unplaceable row) keep the unbounded shape. Co-authored-by: Billy Gerhard <billygerhard@gmail.com>
1d07cfe to
bc47eba
Compare
|
|
|
bolichen97
left a comment
There was a problem hiding this comment.
Approved: PR Readiness green on this head, merges cleanly into current main, no outstanding blocking review.
Rebased onto kirodotdev#13236 and kirodotdev#16005, which bound refreshSlot, switchSlot and warmSlotCache with a clamp plus an older-walking window. This keeps that walk on all three and adds only what a kept head needs on top of it: a marked view or cache (a serving change) reads whole instead of walking, since the walk keeps rows above its anchor verbatim, a walked or overlapping head still offering a sign-in link reads whole, and a background warm that anchors nothing in a cache with a raw retained count reads whole once so a remote clear is still read as a shrink. The refreshSlotBound over-ceiling test is kirodotdev#13236's own.
Rebased onto kirodotdev#13236 and kirodotdev#16005, which bound refreshSlot, switchSlot and warmSlotCache with a clamp plus an older-walking window. This keeps that walk on all three and adds only what a kept head needs on top of it: a marked view or cache (a serving change) reads whole instead of walking, since the walk keeps rows above its anchor verbatim, a walked or overlapping head still offering a sign-in link reads whole, and a background warm that anchors nothing in a cache with a raw retained count reads whole once so a remote clear is still read as a shrink. The refreshSlotBound over-ceiling test is kirodotdev#13236's own.
Rebased onto kirodotdev#13236 and kirodotdev#16005, which bound refreshSlot, switchSlot and warmSlotCache with a clamp plus an older-walking window. This keeps that walk on all three and adds only what a kept head needs on top of it: a marked view or cache (a serving change) reads whole instead of walking, since the walk keeps rows above its anchor verbatim, a walked or overlapping head still offering a sign-in link reads whole, and a background warm that anchors nothing in a cache with a raw retained count reads whole once so a remote clear is still read as a shrink. The refreshSlotBound over-ceiling test is kirodotdev#13236's own.
Rebased onto kirodotdev#13236 and kirodotdev#16005, which bound refreshSlot, switchSlot and warmSlotCache with a clamp plus an older-walking window. This keeps that walk on all three and adds only what a kept head needs on top of it: a marked view or cache (a serving change) reads whole instead of walking, since the walk keeps rows above its anchor verbatim, a walked or overlapping head still offering a sign-in link reads whole, and a background warm that anchors nothing in a cache with a raw retained count reads whole once so a remote clear is still read as a shrink. The refreshSlotBound over-ceiling test is
Rebased onto kirodotdev#13236 and kirodotdev#16005, which bound refreshSlot, switchSlot and warmSlotCache with a clamp plus an older-walking window. This keeps that walk on all three and adds only what a kept head needs on top of it: a marked view or cache (a serving change) reads whole instead of walking, since the walk keeps rows above its anchor verbatim, a walked or overlapping head still offering a sign-in link reads whole, and a background warm that anchors nothing in a cache with a raw retained count reads whole once so a remote clear is still read as a shrink. The refreshSlotBound over-ceiling test is
Rebased onto kirodotdev#13236 and kirodotdev#16005, which bound refreshSlot, switchSlot and warmSlotCache with a clamp plus an older-walking window. This keeps that walk on all three and adds only what a kept head needs on top of it: a marked view or cache (a serving change) reads whole instead of walking, since the walk keeps rows above its anchor verbatim, a walked or overlapping head still offering a sign-in link reads whole, and a background warm that anchors nothing in a cache with a raw retained count reads whole once so a remote clear is still read as a shrink. The refreshSlotBound over-ceiling test is
Rebased onto kirodotdev#13236 and kirodotdev#16005, which bound refreshSlot, switchSlot and warmSlotCache with a clamp plus an older-walking window. This keeps that walk on all three and adds only what a kept head needs on top of it: a marked view or cache (a serving change) reads whole instead of walking, since the walk keeps rows above its anchor verbatim, a walked or overlapping head still offering a sign-in link reads whole, and a background warm that anchors nothing in a cache with a raw retained count reads whole once so a remote clear is still read as a shrink. The refreshSlotBound over-ceiling test is
Rebased onto kirodotdev#13236 and kirodotdev#16005, which bound refreshSlot, switchSlot and warmSlotCache with a clamp plus an older-walking window. This keeps that walk on all three and adds only what a kept head needs on top of it: a marked view or cache (a serving change) reads whole instead of walking, since the walk keeps rows above its anchor verbatim, a walked or overlapping head still offering a sign-in link reads whole, and a background warm that anchors nothing in a cache with a raw retained count reads whole once so a remote clear is still read as a shrink. The refreshSlotBound over-ceiling test is
Rebased onto kirodotdev#13236 and kirodotdev#16005, which bound refreshSlot, switchSlot and warmSlotCache with a clamp plus an older-walking window. This keeps that walk on all three and adds only what a kept head needs on top of it: a marked view or cache (a serving change) reads whole instead of walking, since the walk keeps rows above its anchor verbatim, a walked or overlapping head still offering a sign-in link reads whole, and a background warm that anchors nothing in a cache with a raw retained count reads whole once so a remote clear is still read as a shrink. The refreshSlotBound over-ceiling test is
Rebased onto kirodotdev#13236 and kirodotdev#16005, which bound refreshSlot, switchSlot and warmSlotCache with a clamp plus an older-walking window. This keeps that walk on all three and adds only what a kept head needs on top of it: a marked view or cache (a serving change) reads whole instead of walking, since the walk keeps rows above its anchor verbatim, a walked or overlapping head still offering a sign-in link reads whole, and a background warm that anchors nothing in a cache with a raw retained count reads whole once so a remote clear is still read as a shrink. The refreshSlotBound over-ceiling test is
Rebased onto kirodotdev#13236 and kirodotdev#16005, which bound refreshSlot, switchSlot and warmSlotCache with a clamp plus an older-walking window. This keeps that walk on all three and adds only what a kept head needs on top of it: a marked view or cache (a serving change) reads whole instead of walking, since the walk keeps rows above its anchor verbatim, a walked or overlapping head still offering a sign-in link reads whole, and a background warm that anchors nothing in a cache with a raw retained count reads whole once so a remote clear is still read as a shrink. The refreshSlotBound over-ceiling test is
Rebased onto kirodotdev#13236 and kirodotdev#16005, which bound refreshSlot, switchSlot and warmSlotCache with a clamp plus an older-walking window. This keeps that walk on all three and adds only what a kept head needs on top of it: a marked view or cache (a serving change) reads whole instead of walking, since the walk keeps rows above its anchor verbatim, a walked or overlapping head still offering a sign-in link reads whole, and a background warm that anchors nothing in a cache with a raw retained count reads whole once so a remote clear is still read as a shrink. The refreshSlotBound over-ceiling test is
Rebased onto kirodotdev#13236 and kirodotdev#16005, which bound refreshSlot, switchSlot and warmSlotCache with a clamp plus an older-walking window. This keeps that walk on all three and adds only what a kept head needs on top of it: a marked view or cache (a serving change) reads whole instead of walking, since the walk keeps rows above its anchor verbatim, a walked or overlapping head still offering a sign-in link reads whole, and a background warm that anchors nothing in a cache with a raw retained count reads whole once so a remote clear is still read as a shrink. The refreshSlotBound over-ceiling test is
Problem / Motivation
Goal: a background session's cache warm (
warmSlotCache) stops re-downloading the whole transcript on every background turn end and every reconnect once it holds more than 500 rows.warmSlotCacheruns on every off-screenchat_done(website/src/hooks/websocket/turnCompletion.ts) and on every reconnect. It still read the whole transcript in two cases: when the pane held more than one 500-row page (the count-matched limit declines past the handler's clamp), and when the bounded window missed a cached row. A live capture shows the result:SWITCH short=7546 lim=500 cached=8104 total=8046-- an active session's background cache already held its full history, re-read each turn.The merged #13236 replaced the same unbounded fallback in
refreshSlotandswitchSlotwith a bounded backward walk (walkWindowBackTo), and listed the warm as out of scope. This PR builds on it. Billy Gerhard (@billygerhard) found and measured this same warm problem in #15029; this PR redoes only the warm fix on top of #13236's walk mechanism. Credit for finding and measuring it is his (co-author on the commit).Why it matters
Each unbounded read makes the handler load, redact and serialize the whole session on one worker thread. A long session in a background pane pays that on every turn end, and a reconnect pays it for every pane on screen at once, which stalls other requests and WebSocket frames behind it.
Not a goal
refreshSlot,switchSlotorwalkWindowBackToitself (merged in perf: walk slot windows older instead of unbounded re-reads #13236).meta.mid, so it cannot prove coverage for those rows either.What changed (motivation → approach → change)
The count-matched limit returned
undefinedfor two different reasons: the cache is too wide for the clamp, or its rows cannot be identified. Only the second needs the whole transcript.warmSlotCacheinwebsite/src/store/chat/slotRefresh.tsnow runs the same rule with no ceiling to tell them apart, asks for one 500-row page when the cache is merely wide, and closes a coverage miss withwalkWindowBackTo, exactly asrefreshSlotandswitchSlotcall it. The reducer keeps the cached head above the walk's anchor, so no scrollback is lost.A miss a walk older cannot close is one where the window anchors the cache but lacks a cached row after that anchor. The old unbounded retry doubled as a fresh read for that case, so it gets one fresh read of the same bounded page, and the reducer's existing shrink and same-count-rewrite checks decide what was removed. A walk that spends its 8-page cap without anchoring hands back a window disjoint from the cache; the warm marks it, and the reducer replaces the cache with that window instead of splicing the two with a silent hole between them. That replacement applies only to the exact cache the warm read: if anything wrote to the pane while the warm was in flight (a message sent into the background pane, a streaming chunk landing on an existing row, a newer warm or refresh), the cache's array identity changed, and the warm leaves the pane's rows and paging markers alone for the next warm to reconcile. A walk that stops on a window containing the whole cache is not marked, so rows newer than the page (a just-sent message, a client streaming copy) are still kept. Because every request is now bounded, the retained total is always the collapsed count; the raw-count bookkeeping the unbounded retry needed (
comparableTotal) is gone from this path.website/src/store/chat/windowWalk.tsonly gains a doc line naming the warm as a caller.Backwards compatibility
Compatible: no API or stored shape changes; the warm sends the same request with a smaller
limit. One behavior narrows: when more than 4,000 rows arrived since the last warm (past the walk's 8-page cap), the pane's cache becomes the newest 4,500 rows instead of the whole history; the older rows are one page-back away, the same cost #13236 documents forrefreshSlotandswitchSlot.Tests
website/src/store/chatSlice.windowWalk.test.ts, newwarmSlotCacheblock, on a multi-page fake handler:slotPaneHasMorestays true.website/src/test/chatSlice.warmSlotCacheBound.test.ts: the rewind and same-count-rewrite cases now pin one fresh bounded read ([50, 50]) instead of an unbounded one; the raw-total retry tests are reworded for bounded totals, and mock queues that no longer get consumed are removed.website/src/store/chatSlice.boundedRefetchShrink.test.ts: the oldest-111 cache now pins[111, 500, 500]instead of[111, undefined].slotRefresh.tsreddens 9 of these tests, and dropping the reducer's replace-on-unanchored-walk branch reddens the cap test, including all three new ones. Locally: 192 related store/hook test files (4,201 tests) pass,tsc -p tsconfig.app.jsonand eslint clean.Manual verification
N/A — unit coverage sufficient: the change is the
limitand request sequence the thunk sends, which the tests assert directly against a fake handler with real paging.Screenshots / video
Why no screenshot: store-only change to how many rows a background fetch requests; nothing rendered differs.
Related Issues
no linked issue: builds on the merged #13236; same problem as #15029, which is credited above.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)