fix(desktop): clear the transcript on every cold resume so sessions can't share one

resumeSession hand-rolls $messages (it paints before a runtime id is bound), and
only cleared the old transcript on the cold path at entry. But a warm-cache hit
can bail down to the full resume — an empty-transcript drop, or the cache being
purged during the profile-swap await — without ever clearing, so the previous
session's array leaked into the next one. Symptom: switching sessions kept
showing the same messages (deterministic once tiling pre-warms the cache on
boot). Clear $messages at the single point every cold/bail path converges, so
carryover is structurally impossible; the warm fast-path still repaints in place.
This commit is contained in:
Brooklyn Nicholson 2026-07-14 16:37:54 -04:00
parent 5f37c9e85c
commit 7dc21f08a1

View file

@ -536,6 +536,16 @@ export function useSessionActions({
setFreshDraftReady(false)
setActiveSessionId(null)
activeSessionIdRef.current = null
// A warm-cache hit at entry skipped the cold-path transcript clear, but the
// warm path can still bail down to here — an empty-transcript drop, or the
// cache getting purged during the profile-swap await — so the PREVIOUS
// session's transcript would leak into this cold resume ("switching
// sessions shows the same messages"). Clear it so the loader/prefetch
// paints fresh; guarded so the normal cold path (already cleared) no-ops.
if ($messages.get().length > 0) {
setMessages([])
}
busyRef.current = true
setBusy(true)
setAwaitingResponse(false)