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_chat): start a new sidebar chat without the old chat's grants
Elian Doran55dbe1dd8d8d
diff --git a/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.spec.tsx b/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.spec.tsxindex 66f38d697e..cf9981153b 100644--- a/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.spec.tsx+++ b/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.spec.tsx@@ -681,6 +681,18 @@ describe("useLlmChat", () => {api().loadFromContent({ version: 1, messages: [] });});expect(api().allowedTools).toEqual([]);++ // A chat emptied for a new one, as the sidebar's "New chat" does, keeps none of the old chat's grants.+ await act(async () => {+ api().loadFromContent({ version: 1, messages: [], allowedTools: [ "get_note" ], permissionMode: "dont_ask" });+ });+ permissionModeOption.value = "always_ask";+ await act(async () => {+ api().clearMessages();+ });+ expect(api().allowedTools).toEqual([]);+ expect(api().getContent().allowedTools).toBeUndefined();+ expect(api().getContent().permissionMode).toBe("always_ask");});it("keeps the chat's permission mode, sends it with each turn and saves it, and remembers the last one picked", async () => {permissionModeOption.value = "always_ask";diff --git a/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.ts b/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.tsindex 557024fa18..8b49077c1a 100644--- a/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.ts+++ b/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.ts@@ -610,6 +610,8 @@ export function useLlmChat(setMessages([]);setLastPromptTokens(0);setLastCompletionTokens(0);+ setAllowedTools([]);+ setPermissionMode(rememberedPermissionMode());}, [setMessages]);/**