From 7dc21f08a188cefe346d12faa45cdcceeb2ca1fa Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Tue, 14 Jul 2026 16:37:54 -0400 Subject: [PATCH] fix(desktop): clear the transcript on every cold resume so sessions can't share one MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../src/app/session/hooks/use-session-actions/index.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/desktop/src/app/session/hooks/use-session-actions/index.ts b/apps/desktop/src/app/session/hooks/use-session-actions/index.ts index d8a7e0bd15d1..96c8c913b56c 100644 --- a/apps/desktop/src/app/session/hooks/use-session-actions/index.ts +++ b/apps/desktop/src/app/session/hooks/use-session-actions/index.ts @@ -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)