From 0c0491cd490ca2675df25fb945560a3faa1f90e1 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Tue, 9 Dec 2025 13:46:43 +0000 Subject: [PATCH] feat: add updateLLMPreferencesMutationAtom to handle LLM preferences updates --- .../llm-config/llm-config-mutation.atoms.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/surfsense_web/atoms/llm-config/llm-config-mutation.atoms.ts b/surfsense_web/atoms/llm-config/llm-config-mutation.atoms.ts index 9b484e0de..6e0c18d73 100644 --- a/surfsense_web/atoms/llm-config/llm-config-mutation.atoms.ts +++ b/surfsense_web/atoms/llm-config/llm-config-mutation.atoms.ts @@ -6,6 +6,7 @@ import type { UpdateLLMConfigRequest, DeleteLLMConfigRequest, GetLLMConfigsResponse, + UpdateLLMPreferencesRequest, } from "@/contracts/types/llm-config.types"; import { llmConfigApiService } from "@/lib/apis/llm-config-api.service"; import { cacheKeys } from "@/lib/query-client/cache-keys"; @@ -91,3 +92,22 @@ export const deleteLLMConfigMutationAtom = atomWithMutation((get) => { }, }; }); + +export const updateLLMPreferencesMutationAtom = atomWithMutation((get) => { + const searchSpaceId = get(activeSearchSpaceIdAtom); + + return { + mutationKey: cacheKeys.llmConfigs.preferences(searchSpaceId!), + enabled: !!searchSpaceId, + mutationFn: async (request: UpdateLLMPreferencesRequest) => { + return llmConfigApiService.updateLLMPreferences(request); + }, + + onSuccess: () => { + toast.success("LLM preferences updated successfully"); + queryClient.invalidateQueries({ + queryKey: cacheKeys.llmConfigs.preferences(searchSpaceId!), + }); + }, + }; +});