Skip to content

Commit f512d0d

Browse files
t3dotggclaude
andcommitted
perf(web): hidden terminal drawers no longer keep full thread history in memory
A thread's terminal drawer stays mounted after you switch away. Each drawer held a live thread detail subscription, so hidden threads kept their full history in memory. Hidden drawers now read only the thread shell. The active drawer still reads ChatView's detail, which also covers archived threads (they have no shell). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 6530de0 commit f512d0d

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,14 @@ const PersistentThreadTerminalDrawer = memo(function PersistentThreadTerminalDra
917917
const writeTerminal = useAtomCommand(terminalEnvironment.write, "terminal write");
918918
const closeTerminalMutation = useAtomCommand(terminalEnvironment.close, "terminal close");
919919
const draftThread = useComposerDraftStore((store) => store.getDraftThreadByRef(threadRef));
920-
const serverThread = useThread(threadRef, { waitForShell: draftThread !== null });
920+
// Hidden drawers stay mounted (see MAX_HIDDEN_MOUNTED_TERMINAL_THREADS), so they read only
921+
// the shell: a detail subscription would keep each hidden thread's history in memory. The
922+
// active drawer shares ChatView's detail, which also covers archived threads (no shell).
923+
const activeServerThread = useThread(active ? threadRef : null, {
924+
waitForShell: draftThread !== null,
925+
});
926+
const serverThreadShell = useThreadShell(threadRef);
927+
const serverThread = activeServerThread ?? serverThreadShell;
921928
const projectRef = serverThread
922929
? scopeProjectRef(serverThread.environmentId, serverThread.projectId)
923930
: draftThread

0 commit comments

Comments
 (0)