From cfc99b228b66f42d21cb08a3ab28c8a5ea40606c Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sat, 6 Jun 2026 01:15:16 -0400 Subject: [PATCH] refac --- cptr/frontend/src/lib/components/chat/ChatPanel.svelte | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cptr/frontend/src/lib/components/chat/ChatPanel.svelte b/cptr/frontend/src/lib/components/chat/ChatPanel.svelte index 42c1359..68b65f8 100644 --- a/cptr/frontend/src/lib/components/chat/ChatPanel.svelte +++ b/cptr/frontend/src/lib/components/chat/ChatPanel.svelte @@ -181,13 +181,16 @@ async function loadChat(id: string) { chatId = id; - loading = true; + // Only show loading spinner on initial load (no messages yet). + // On reloads (e.g. after cancel), keep the DOM intact to preserve scroll position. + const isInitialLoad = allMessages.length === 0; + if (isInitialLoad) loading = true; try { const data = await getChat(id); allMessages = data.messages; currentMessageId = data.chat.current_message_id; } finally { - loading = false; + if (isInitialLoad) loading = false; } }