From 67adde31936d1d2e656140f9edd898b1fbb18a1c Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sat, 19 Sep 2026 17:26:40 -0400 Subject: [PATCH] refac Co-Authored-By: G30 <50341825+silentoplayz@users.noreply.github.com> --- src/lib/components/chat/Chat.svelte | 10 +++++++--- src/lib/components/chat/MessageInput.svelte | 4 ++-- src/lib/components/chat/Navbar.svelte | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 6b4f8e2e07..7f41251e23 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -2033,6 +2033,10 @@ } } + if ($page.url.searchParams.get('temporary-chat') === 'true') { + await temporaryChatEnabled.set(true); + } + if ($user?.role !== 'admin' && !$user?.permissions?.chat?.temporary) { await temporaryChatEnabled.set(false); } @@ -2133,7 +2137,7 @@ await showArtifacts.set(false); if (!embedded && $page.url.pathname.includes('/c/')) { - window.history.replaceState(history.state, '', `/`); + window.history.replaceState(window.history.state, '', `/`); } autoScroll = true; @@ -3672,7 +3676,7 @@ }); await chatId.set(res.chat_id); if (!$temporaryChatEnabled && !embedded) { - window.history.replaceState(history.state, '', `/c/${res.chat_id}`); + window.history.replaceState(window.history.state, '', `/c/${res.chat_id}`); await refreshChatList(localStorage.token); // Persist chat-level params (system prompt, advanced @@ -3958,7 +3962,7 @@ await chatId.set(_chatId); if (!embedded) { - window.history.replaceState(history.state, '', `/c/${_chatId}`); + window.history.replaceState(window.history.state, '', `/c/${_chatId}`); } await tick(); diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte index a85dafeac2..b1129a7564 100644 --- a/src/lib/components/chat/MessageInput.svelte +++ b/src/lib/components/chat/MessageInput.svelte @@ -579,9 +579,9 @@ } if ($temporaryChatEnabled) { - window.history.replaceState(null, '', '?temporary-chat=true'); + window.history.replaceState(window.history.state, '', '?temporary-chat=true'); } else { - window.history.replaceState(null, '', location.pathname); + window.history.replaceState(window.history.state, '', location.pathname); } }; diff --git a/src/lib/components/chat/Navbar.svelte b/src/lib/components/chat/Navbar.svelte index f572d14b4d..061bb1ef0f 100644 --- a/src/lib/components/chat/Navbar.svelte +++ b/src/lib/components/chat/Navbar.svelte @@ -184,9 +184,9 @@ // add 'temporary-chat=true' to the URL if ($temporaryChatEnabled) { - window.history.replaceState(null, '', '?temporary-chat=true'); + window.history.replaceState(window.history.state, '', '?temporary-chat=true'); } else { - window.history.replaceState(null, '', location.pathname); + window.history.replaceState(window.history.state, '', location.pathname); } }} aria-label={$i18n.t(`Temporary Chat`)}