Repository navigation
fix(chat): keep a chat's loaded history when New Chat or a resume leaves it - #15934
Conversation
|
Intent: A chat left through New Chat or a history resume comes back with the transcript the reader had loaded, by caching it on every path that moves the active chat. |
UX Review (Fable 5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS Verify in the real app that scroll position, not only the loaded message set, is restored when landing back on the old chat. [UX-REVIEWED] 950afd0 Description read[DESCRIPTION-READ] 3c05031b2c019954dd1b30e2c0a6f61e5bfbe95ceefa4a6dcde50bf09d004b1e That sha256 names everything this verdict read: the PR description, plus the 5 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 (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify no Suggestions
[DESIGN-REVIEWED] 950afd0 Description read[DESCRIPTION-READ] 533e6b1b1c157fde88f71e9f4ca1cb70e601302d7a995b3991450f04d98592d7 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, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the relocated What this change shipsInventory (5 items) — 5 justifiedIntent: FIX — a chat left via New Chat or a history resume returns with the history the reader had loaded (issue #15933; three tests fail on base).
Counts run: writers of [FIRST-PRINCIPLES-REVIEWED] 950afd0 Description read[DESCRIPTION-READ] e050efabc0b7519213d8d866e2767cf0d033dec819e88fe35058e309e84abb5c That sha256 names the PR description this verdict read. Recompute it with |
Opus 5 Review (fork) — ✅ no blocking findingsReviewed |
30d9949 to
a438863
Compare
|
Pushed a438863. CI shard Frontend Tests (2) caught a real regression on 30d9949: |
|
Rebased: main moved in |
a438863 to
81f5fe8
Compare
Leaving the active chat through New Chat (setActiveSlot(null) then createSlot) or a history resume never wrote its on-screen transcript to slotMessages; only switchSlot.pending did. Returning to it (closing the new chat lands back through switchSlot) painted whatever the cache held from the last switch: the first page of an earlier visit, missing the history paged in or streamed since. The bounded switch read then kept that short view whenever its window covered the stale cache. parkActiveTranscript is now the one writer of that cache entry, called by switchSlot.pending, setActiveSlot, createSlot.fulfilled and resumeFromHistory.fulfilled.
81f5fe8 to
950afd0
Compare
|
self-added: yes
|
|
Rebased onto main 55d6539 and pushed 950afd0. Same fix, plus the First Principles subtraction (the unused |
|
self-added: no
|
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.
Problem / Motivation
Goal: A chat you leave through New Chat or a history resume comes back with all the history you had loaded.
Open a long chat and scroll back through its history. Click New Chat, then close the new chat. The dashboard lands back on the first chat, but the transcript jumps and only the newest page of 100 messages is left. The "Load earlier messages" bar is back and the history has to be paged in again. When the chat grew while it was open, the landing first repaints an older snapshot that is missing the recent turns. A later turn's refresh can bring the rest back, which makes it look like the history loads in late.
Why it matters
New Chat and reopening a chat from history are everyday ways to leave a chat. Each one silently throws away the scroll-back the reader built up. On a long session that means paging hundreds of messages in again, and the reader loses their place.
Not a goal
What changed (motivation → approach → change)
Leaving a chat through New Chat or a history resume no longer throws away the history you had loaded in it. Coming back shows the same transcript you left.
The per-chat cache
slotMessages[key]is what a switch paints the moment you return to a chat. OnlyswitchSlot.pendingwrote it when the active chat changed. New Chat clears the selection withsetActiveSlot(null)and thencreateSlotactivates the new chat. A resume activates its chat inresumeFromHistory.fulfilled. None of those three wrote the cache, so the chat being left kept whatever the cache held from its last switch. Closing the new chat runsdeleteSlot, which returns throughswitchSlot(X). That paints the stale entry, and the bounded switch read, sized to the stale entry, keeps it.parkActiveTranscriptinwebsite/src/store/chat/slotCache.tsis now the one writer of the outgoing chat's cache entry.switchSlot.pending,setActiveSlot,createSlot.fulfilledandresumeFromHistory.fulfilledall call it before the selection moves. It writes the has-more marker from the open view, and it keeps the existing marker for a view whose own switch has not landed. That is the ruleswitchSlot.pendingalready used, so the switch path behaves as before.Backwards compatibility
Compatible: the change only adds cache writes on the paths that leave a chat. No request, response, setting or stored value changes.
Tests
website/src/store/chatSlice.leaveViaOpen.test.tsdrives the real reducers with a mocked slot-detail endpoint that slices like the server. Each case pages in all 600 messages of a chat first.All three fail on main and pass with this change.
Manual verification
Real browser, headless Chromium at 1400x900, against isolated gateways built from main
996b4506912dand from this branch. Chat X was a real slot whose slot-detail reads were answered with a synthetic 600-message history. The steps were to open X, press "Load earlier messages" until the transcript starts at "X message 0", click New chat session, then close the new chat from its sidebar row.limit=100limit=500, then one unbounded readScreenshots / video
Landing after closing the New Chat, main:
Landing after closing the New Chat, this branch:
Related Issues
Fixes #15933
Pattern harvest
Rule candidate: review-prompt
Pattern: a reducer that moves
activeSlotwithout caching the outgoing chat's transcript. Every writer of the active selection has to go through the same park step thatswitchSlot.pendinguses.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)