Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(llm): usage not reset when opening an empty chat
Elian Doran1a02be7c9136
diff --git a/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.ts b/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.tsindex 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 usageconst 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)