From 03eb7b3d4c31896f91ba3bbc6c8749157bc0706a Mon Sep 17 00:00:00 2001 From: Aleksander Grygier Date: Sun, 6 Sep 2026 00:16:48 +0200 Subject: [PATCH] ui : drop unused currentResponse reactive writes Nothing reads chatStore.currentResponse, but setChatStreaming reassigned it on every streamed chunk, so each token paid a reactive write and string assignment for nothing. Remove the field and the clearUIState wrapper that only reset it. Assisted-by: pi:zai-org/GLM-5.3 --- tools/ui/src/lib/stores/chat/index.svelte.ts | 11 ----------- tools/ui/src/routes/(chat)/+page.svelte | 3 +-- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/tools/ui/src/lib/stores/chat/index.svelte.ts b/tools/ui/src/lib/stores/chat/index.svelte.ts index 296c2cca58..4bdcc68456 100644 --- a/tools/ui/src/lib/stores/chat/index.svelte.ts +++ b/tools/ui/src/lib/stores/chat/index.svelte.ts @@ -55,7 +55,6 @@ class ChatStore implements ChatStreamHost, ChatFlowsHost { string, { response: string; messageId: string; model?: string | null } >(); - currentResponse = $state(''); errorDialogState = $state(null); // true while the active conversation has a local pipe (send, attach or resume-wait) isLoading = $derived(this.activity.isLocal(conversationsStore.activeConversation?.id ?? '')); @@ -256,8 +255,6 @@ class ChatStore implements ChatStreamHost, ChatFlowsHost { } this.chatStreamingStates.delete(convId); - - if (convId === conversationsStore.activeConversation?.id) this.currentResponse = ''; } clearEditMode(): void { this.isEditModeActive = false; @@ -272,11 +269,6 @@ class ChatStore implements ChatStreamHost, ChatFlowsHost { this.pendingMessages.delete(convId); } - /** Reset per-view state when (re)mounting the empty chat screen. */ - clearUIState(): void { - this.currentResponse = ''; - } - consumePendingDraft(): { message: string; files: ChatUploadedFile[] } | null { if (!this.pendingDraftMessage && this.pendingDraftFiles.length === 0) return null; @@ -766,8 +758,6 @@ class ChatStore implements ChatStreamHost, ChatFlowsHost { model: model ?? this.chatStreamingStates.get(convId)?.model, response }); - - if (convId === conversationsStore.activeConversation?.id) this.currentResponse = response; } setEditModeActive(handler: (files: File[]) => void): void { @@ -1244,7 +1234,6 @@ class ChatStore implements ChatStreamHost, ChatFlowsHost { syncLoadingStateForChat(convId: string): void { const s = this.chatStreamingStates.get(convId); - this.currentResponse = s?.response || ''; this.processing.setActiveConversation(convId); // Sync streaming content to activeMessages so UI displays current content diff --git a/tools/ui/src/routes/(chat)/+page.svelte b/tools/ui/src/routes/(chat)/+page.svelte index 08a6b11ad5..53975d7b3d 100644 --- a/tools/ui/src/routes/(chat)/+page.svelte +++ b/tools/ui/src/routes/(chat)/+page.svelte @@ -3,7 +3,7 @@ import { page } from '$app/state'; import { DialogModelNotAvailable } from '$lib/components/app'; import { APP_NAME, URL_PARAMS } from '$lib/constants'; - import { chatStore, conversationsStore, modelsStore, serverStore } from '$lib/stores'; + import { conversationsStore, modelsStore, serverStore } from '$lib/stores'; import { onMount } from 'svelte'; let qParam = $derived(page.url.searchParams.get(URL_PARAMS.QUERY)); @@ -77,7 +77,6 @@ } conversationsStore.clearActiveConversation(); - chatStore.clearUIState(); await modelsStore.fetch();