diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte index 2f3983a3..93b50a32 100644 --- a/src/routes/(app)/+page.svelte +++ b/src/routes/(app)/+page.svelte @@ -80,6 +80,11 @@ ////////////////////////// const initNewChat = async () => { + if (currentRequestId !== null) { + await cancelChatCompletion(localStorage.token, currentRequestId); + currentRequestId = null; + } + window.history.replaceState(history.state, '', `/`); console.log('initNewChat'); diff --git a/src/routes/(app)/c/[id]/+page.svelte b/src/routes/(app)/c/[id]/+page.svelte index 9a073935..412c332e 100644 --- a/src/routes/(app)/c/[id]/+page.svelte +++ b/src/routes/(app)/c/[id]/+page.svelte @@ -705,7 +705,12 @@ 0} - initNewChat={() => { + initNewChat={async () => { + if (currentRequestId !== null) { + await cancelChatCompletion(localStorage.token, currentRequestId); + currentRequestId = null; + } + goto('/'); }} />