From 1a02be7c9136a2f1997e94cc177aaeba3e6ef497 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Mon, 30 Mar 2026 19:23:42 +0300 Subject: [PATCH] fix(llm): usage not reset when opening an empty chat --- apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.ts b/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.ts index a6931299e6..b3088db20b 100644 --- a/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.ts +++ b/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.ts @@ -170,9 +170,7 @@ export function useLlmChat( } // Restore last prompt tokens from the most recent message with usage const lastUsage = [...(content.messages || [])].reverse().find(m => m.usage)?.usage; - if (lastUsage) { - setLastPromptTokens(lastUsage.promptTokens); - } + setLastPromptTokens(lastUsage?.promptTokens ?? 0); }, [supportsExtendedThinking]); // Get current state as content object (uses refs to avoid stale closures)