Skip to content

Commit 821d543

Browse files
committed
refactor: Cleanup
1 parent 26e9c18 commit 821d543

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

tools/server/webui/src/lib/components/app/chat/ChatProcessingInfo.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
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
@@ -29,6 +28,7 @@
2928
}
3029
});
3130
31+
// Update processing state from stored timings
3232
$effect(() => {
3333
const conversation = activeConversation();
3434
const messages = activeMessages() as DatabaseMessage[];
@@ -40,6 +40,8 @@
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--) {

tools/server/webui/src/lib/components/app/chat/ChatSidebar/ChatSidebarConversationItem.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
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) {

tools/server/webui/src/lib/services/slots.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

tools/server/webui/src/lib/stores/chat.svelte.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff 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}`);

0 commit comments

Comments
 (0)