@@ -6,6 +6,7 @@ import { filterByLeafNodeId, findLeafNode, findDescendantMessages } from '$lib/u
66import { browser } from '$app/environment' ;
77import { goto } from '$app/navigation' ;
88import { toast } from 'svelte-sonner' ;
9+ import { SvelteMap } from 'svelte/reactivity' ;
910import type { ExportedConversations } from '$lib/types/database' ;
1011
1112/**
@@ -51,10 +52,8 @@ class ChatStore {
5152 isInitialized = $state ( false ) ;
5253 isLoading = $state ( false ) ;
5354 // Track loading and streaming state per conversation
54- conversationLoadingStates = $state < Map < string , boolean > > ( new Map ( ) ) ;
55- conversationStreamingStates = $state < Map < string , { response : string ; messageId : string } > > (
56- new Map ( )
57- ) ;
55+ conversationLoadingStates = new SvelteMap < string , boolean > ( ) ;
56+ conversationStreamingStates = new SvelteMap < string , { response : string ; messageId : string } > ( ) ;
5857 titleUpdateConfirmationCallback ?: ( currentTitle : string , newTitle : string ) => Promise < boolean > ;
5958
6059 constructor ( ) {
@@ -471,7 +470,7 @@ class ChatStore {
471470
472471 // Update database with the message's conversation ID (not activeConversation which may have changed)
473472 await DatabaseStore . updateCurrentNode ( assistantMessage . convId , assistantMessage . id ) ;
474-
473+
475474 // Only update activeConversation.currNode if this is still the active conversation
476475 if ( this . activeConversation ?. id === assistantMessage . convId ) {
477476 this . activeConversation . currNode = assistantMessage . id ;
@@ -631,7 +630,7 @@ class ChatStore {
631630 }
632631
633632 this . errorDialogState = null ;
634-
633+
635634 // Set loading state for this specific conversation
636635 this . setConversationLoading ( this . activeConversation . id , true ) ;
637636 this . clearConversationStreaming ( this . activeConversation . id ) ;
@@ -1284,12 +1283,12 @@ class ChatStore {
12841283 clearActiveConversation ( ) : void {
12851284 this . activeConversation = null ;
12861285 this . activeMessages = [ ] ;
1287-
1286+
12881287 // Clear global UI state since there's no active conversation
12891288 // Background streaming will continue but won't affect the UI
12901289 this . isLoading = false ;
12911290 this . currentResponse = '' ;
1292-
1291+
12931292 // Clear active conversation in slots service
12941293 slotsService . setActiveConversation ( null ) ;
12951294 }
0 commit comments