Repository navigation
perf: walk slot windows older instead of unbounded re-reads - #13236
Conversation
UX Review (Fable 5) — ✅ PASSUX-level review of UX-Verdict: PASS Verify the 8-page walk cap tradeoff: on an extreme reconnect gap, paged-in scrollback silently leaves the view until the user pages back. [UX-REVIEWED] 0e2e1de Description read[DESCRIPTION-READ] 04803ffae457a06786f9055e984ab2e9281413c754314da52108a38dad7a91c1 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) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS A view with no WatchLegacy (mid-less) transcripts never converge:
Suggestions
[DESIGN-REVIEWED] 0e2e1de Description read[DESCRIPTION-READ] f3a3e78b091aefc5e5871330a96edfdd64413a8a7a7ef96aebfd7208e67db077 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 |
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: |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the cap case: a legacy view whose rows carry no Not justified as shipped
What this change shipsInventory (8 items) — 6 justifiedIntent: stop a long session re-downloading its whole transcript on every turn end, reconnect and slot switch — a FIX, with a measured reproduction (11,134 rows/turn on a 12,178-row session) and the reversed pins' origins (#3240, #6839, #6947, #8574) named with evidence their premises no longer hold.
Sibling unbounded reads ( [FIRST-PRINCIPLES-REVIEWED] 0e2e1de Description read[DESCRIPTION-READ] 1f6f893b2642e8f3a6da72bd56d373f2e2082c077ee2ae888f671b76d15547a7 That sha256 names the PR description this verdict read. Recompute it with |
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: |
|
🤖 Kiro Crew [operator: NicholasRBowers#a942f9ca]: This PR has been inactive for 7+ days with failing CI. I've assessed the blockers and they appear resolvable — I'll push fixes directly to this branch as a co-author. Assessment: GPT, Opus and Design all point at the same fix, so there is no split to arbitrate: the 8-page cap can return a window with no anchor, and the reducer then drops loaded scrollback when the gap exceeds 4000 rows or the rows carry no If you'd prefer I don't touch this PR, add the |
a866b42 to
4721d9e
Compare
4721d9e to
8f4a471
Compare
|
Disposition of the GPT 5.6 review on F2: the walk returns a stale slot status. Fixed. Every page the walk reads is a full slot-detail response, so the walk now reports F1: a capped walk discards loaded scrollback. No code change; this is the cost the PR chose deliberately, and the adjudicator flagged it the same way. Reaching the cap takes a gap of more than 4,000 rows in one absence, or held rows that carry no Also in this push: |
|
GPT 5.6 on |
|
/ai-review override gpt 8f4a471: page cap is the documented cost of not re-reading the whole transcript; window stays contiguous and re-pageable |
Human judgment recorded@buluoray marked the gpt AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
8f4a471 to
a866b42
Compare
|
Opus 5 on 8f4a471: the blocking finding (loosened ratchet in chatSlice.boundedRefetchShrink.test.ts) was real and is fixed in 19c7b1c, which is 8f4a471 plus this one test change. The assertion is now pinned to literal values: messages.length === 100 and { hasMore: true, paneHasMore: true }. Checked by mutation: dropping OLDER_PAGE_LIMIT to 10 makes this test fail. (An intermediate push briefly pointed the branch at a stale pre-port commit, a866b42; ignore that head.) This push voids the GPT override on 8f4a471. |
Rebased onto kirodotdev#13236, which already bounds refreshSlot and switchSlot with a clamp plus an older-walking window. This keeps that walk 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, and a walked or overlapping head still offering a sign-in link reads whole. The refreshSlotBound over-ceiling test is kirodotdev#13236's own.
Rebased onto kirodotdev#13236, which already bounds refreshSlot and switchSlot with a clamp plus an older-walking window. This keeps that walk 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, and a walked or overlapping head still offering a sign-in link reads whole. The refreshSlotBound over-ceiling test is kirodotdev#13236's own.
Rebased onto kirodotdev#13236, which already bounds refreshSlot and switchSlot with a clamp plus an older-walking window. This keeps that walk 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, and a walked or overlapping head still offering a sign-in link reads whole. The refreshSlotBound over-ceiling test is kirodotdev#13236's own.
Rebased onto kirodotdev#13236, which already bounds refreshSlot and switchSlot with a clamp plus an older-walking window. This keeps that walk 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, and a walked or overlapping head still offering a sign-in link reads whole. The refreshSlotBound over-ceiling test is kirodotdev#13236's own.
Rebased onto kirodotdev#13236, which already bounds refreshSlot and switchSlot with a clamp plus an older-walking window. This keeps that walk 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, and a walked or overlapping head still offering a sign-in link reads whole. The refreshSlotBound over-ceiling test is kirodotdev#13236's own.
Rebased onto kirodotdev#13236, which already bounds refreshSlot and switchSlot with a clamp plus an older-walking window. This keeps that walk 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, and a walked or overlapping head still offering a sign-in link reads whole. 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 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 long chat session stops re-downloading its entire history on every turn end, reconnect and session switch, without losing any scrollback the user paged in.
refreshSlotandswitchSlotfall back to an unbounded slot-detail read (limitomitted = the whole chained transcript) whenever a count-matched page cannot be proven to cover the rows the tab already holds:refreshSlotREFRESH_LIMIT_CEILING(500) rowsrefreshSlotswitchSlotslotCoverageShortfall > 0(cached rows the window did not cover)On a long session every one of those is permanently true, so every
chat_doneand every WebSocket reconnect re-reads the entire history. Measured on a 12,178-row session: 11,134 rows fetched per turn,switchSlotre-fetching the full transcript on every switch, never converging. The scroll inspector on that session reportedh=941519px, a single reprice moving 797,415px.Why it matters
Anyone running a long session pays for the whole transcript on every
chat_doneand every reconnect: on the measured 12,178-row session that is 11,134 rows per turn, aswitchSlotthat never converges, and a scroll surface that reprices by hundreds of thousands of pixels. The cost grows with the session, so the sessions people use most are the ones hit hardest.Each fallback was added deliberately (#3240, #6839, #6947, #8574) as the cheapest proof of one invariant: a replacing reducer must not delete scrollback the user paged in. Two premises made the price acceptable then -- 2,644 rows = 6.2MB/1s, and rare triggers -- and neither holds on a session past the ceiling, where the trigger is every turn.
Not a goal
warmSlotCache(the background pane warm) keeps its current shape; perf(chat): keep the pane hydrate and warm bounded while a slot runs #10026 bounds that path separately.refreshSlot.fulfilled,switchSlot.fulfilled) or toslotCoverageShortfall.What changed (motivation → approach → change)
The invariant is kept; the proof is replaced. A window that misses the held rows is extended older, one bounded page at a time (
walkWindowBackTo) until its oldest row anchors a held row -- the exact condition under whicholderHeadAbovePagekeeps the rows above it. The walk pays for the rows the server gained plus one overlapping page. Every request carrieslimit <= SLOT_DETAIL_MAX_LIMIT; the reducers are untouched.refreshSlot:REFRESH_LIMIT_CEILINGbecomes a clamp instead of an unbounded fallback; an empty view asks for the floor instead of the whole transcript; the disjoint-page case walks.switchSlot: an observed coverage shortfall walks instead of refetching unbounded.slotCoverageShortfallitself is unchanged -- it stays the conservative multiset, the walk answers "above the anchor vs. in a hole".walkWindowBackToreaches on either count the reducers accept: the window's oldest row anchors a held row, or the oldest held row anchors a window row (window is a superset). Both go throughidAnchorsOneRow, so a repeatedmiddeclines as the reducer's cut would.normalizeSlotDetail, shared withfetchSlotDetail), so a turn that ends mid-walk is not re-armed by the first page'srunning: true; rows come from every page andtotalstays the first page's.WINDOW_WALK_MAX_PAGES(8) caps the walk -- the reducer then keeps no head and the rows above the window are one page-back away, the documented cost taken instead of a whole-transcript read; and a cursor that fails to move older ends it, so a handler repeatingnext_beforewhile still sayinghas_morecannot keep the loop alive.warmSlotCacheis deliberately left alone: #10026 bounds that path with the same window-plus-verify shape. This PR is the other two halves.Ported onto the chatSlice split (#14665). The walk now lives in
store/chat/windowWalk.ts;refreshSlot(chat/slotRefresh.ts) keepscountMatchedFetchLimitas the rule it shares with the warm, and where that rule declines it clamps to floor/ceiling and only stops trustingspansView, instead of reading unbounded. Four newer test files pinned the old unbounded shape (incl. two assertions inUseWebSocketCoverage.test.tsx, now pinned to the floor page) and were repinned to intent: the two reconnect suites told the active refresh from a pane warm by its missing limit and now tell them apart by slot (plus pin the active slot reads exactly once);abortOlderOnSwitchheld only cursor-less legs, so its mock now also holds the switch's signal-less walk legs.Backwards compatibility
Compatible: client-only change to which
limit/beforethe store sends to the existing slot-detail endpoint; every request shape it now sends is one the handler already accepts (bounded page, and bounded page with a cursor, both used byloadOlderMessagestoday).Tests
chatSlice.windowWalk.test.ts(7, incl. a turn ending mid-walk reports idle): stops at the first page that anchors, not the start; spends exactly the cap on a gap wider than it covers; stalled cursor stops after one page; no walk when the page already reaches; switch closes an observed hole by walking and stops where the cache begins; every request bounded when the cache sits deeper than one page.undefined(unbounded) limit; each was rewritten to pin its intent (view does not shrink, cursor stays consistent, page never shorter than view) and every "no rows lost" assertion still passes unchanged.Manual verification
N/A — store/thunk change; the request sequence and resulting transcript are pinned by the unit suites above against a mocked handler that mirrors the real clamp and cursor semantics.
Ran locally:
tsc -b, eslint on the touched files, the 51 test files that hitchatSlotDetailthrough refresh/switch (1354 passed). Mutation re-checked after the port: refresh walk -> unbounded = 17 red, switch walk -> unbounded = 3 red. Full suite left to CI.Screenshots / video
Why no screenshot: store/thunk change only, no rendered surface differs.
Related Issues
N/A
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement