File tree Expand file tree Collapse file tree 4 files changed +9
-7
lines changed
tools/server/webui/src/lib Expand file tree Collapse file tree 4 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 77
88 const processingState = useProcessingState ();
99
10- let processingDetails = $derived (processingState .getProcessingDetails ());
11-
1210 let isCurrentConversationLoading = $derived (isLoading ());
13-
11+ let processingDetails = $derived ( processingState . getProcessingDetails ());
1412 let showSlotsInfo = $derived (isCurrentConversationLoading || config ().keepStatsVisible );
1513
14+ // Track loading state reactively by checking if conversation ID is in loading conversations array
1615 $effect (() => {
1716 const keepStatsVisible = config ().keepStatsVisible ;
1817
2928 }
3029 });
3130
31+ // Update processing state from stored timings
3232 $effect (() => {
3333 const conversation = activeConversation ();
3434 const messages = activeMessages () as DatabaseMessage [];
4040 return ;
4141 }
4242
43+ // Search backwards through messages to find most recent assistant message with timing data
44+ // Using reverse iteration for performance - avoids array copy and stops at first match
4345 let foundTimingData = false ;
4446
4547 for (let i = messages .length - 1 ; i >= 0 ; i -- ) {
Original file line number Diff line number Diff line change 2525 let renderActionsDropdown = $state (false );
2626 let dropdownOpen = $state (false );
2727
28- // Track loading state reactively by checking if conversation ID is in loading conversations array
2928 let isLoading = $derived (getAllLoadingConversations ().includes (conversation .id ));
3029
3130 function handleEdit(event : Event ) {
Original file line number Diff line number Diff line change @@ -172,6 +172,7 @@ export class SlotsService {
172172
173173 if ( processingState === null ) {
174174 console . warn ( 'Failed to parse timing data - skipping update' ) ;
175+
175176 return ;
176177 }
177178
@@ -200,6 +201,7 @@ export class SlotsService {
200201 ...( apiKey ? { Authorization : `Bearer ${ apiKey } ` } : { } )
201202 }
202203 } ) ;
204+
203205 if ( response . ok ) {
204206 const slotsData = await response . json ( ) ;
205207 if ( Array . isArray ( slotsData ) && slotsData . length > 0 ) {
@@ -236,6 +238,7 @@ export class SlotsService {
236238
237239 if ( contextTotal === null ) {
238240 console . warn ( 'No context total available - cannot calculate processing state' ) ;
241+
239242 return null ;
240243 }
241244
@@ -276,6 +279,7 @@ export class SlotsService {
276279 async getCurrentState ( ) : Promise < ApiProcessingState | null > {
277280 if ( this . activeConversationId ) {
278281 const conversationState = this . conversationStates . get ( this . activeConversationId ) ;
282+
279283 if ( conversationState ) {
280284 return conversationState ;
281285 }
Original file line number Diff line number Diff line change @@ -97,14 +97,11 @@ class ChatStore {
9797 this . activeConversation = conversation ;
9898 this . activeMessages = [ ] ;
9999
100- // Set this conversation as active for statistics display
101100 slotsService . setActiveConversation ( conversation . id ) ;
102101
103- // Sync global isLoading state - new conversation is not loading
104102 const isConvLoading = this . isConversationLoading ( conversation . id ) ;
105103 this . isLoading = isConvLoading ;
106104
107- // Clear global currentResponse state - new conversation has no streaming
108105 this . currentResponse = '' ;
109106
110107 await goto ( `#/chat/${ conversation . id } ` ) ;
You can’t perform that action at this time.
0 commit comments