From 85f00bd3641091399aa08d9c566a613f73c62039 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Wed, 10 Dec 2025 07:46:15 +0000 Subject: [PATCH] refactor: migrate llm-role-manager to jotai + tanstack query pattern - Replace useLLMConfigs hook with llmConfigsAtom - Map properties correctly (data, isFetching, isError, refetch) - Fix onClick handler for refreshConfigs to use arrow function - Fix TypeScript issue with is_global property check - Maintain backward compatibility with existing functionality - Keep useGlobalLLMConfigs and useLLMPreferences unchanged as requested --- .../components/settings/llm-role-manager.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/surfsense_web/components/settings/llm-role-manager.tsx b/surfsense_web/components/settings/llm-role-manager.tsx index c8057ef08..6bdc07926 100644 --- a/surfsense_web/components/settings/llm-role-manager.tsx +++ b/surfsense_web/components/settings/llm-role-manager.tsx @@ -27,8 +27,10 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select"; -import { useGlobalLLMConfigs, useLLMConfigs, useLLMPreferences } from "@/hooks/use-llm-configs"; +import { useGlobalLLMConfigs, useLLMPreferences } from "@/hooks/use-llm-configs"; +import { useAtomValue } from "jotai"; +import { llmConfigsAtom } from "@/atoms/llm-config/llm-config-query.atoms"; const ROLE_DESCRIPTIONS = { long_context: { icon: Brain, @@ -62,11 +64,11 @@ interface LLMRoleManagerProps { export function LLMRoleManager({ searchSpaceId }: LLMRoleManagerProps) { const { - llmConfigs, - loading: configsLoading, - error: configsError, - refreshConfigs, - } = useLLMConfigs(searchSpaceId); + data: llmConfigs = [], + isFetching: configsLoading, + isError: configsError, + refetch: refreshConfigs + } = useAtomValue(llmConfigsAtom); const { globalConfigs, loading: globalConfigsLoading, @@ -203,7 +205,7 @@ export function LLMRoleManager({ searchSpaceId }: LLMRoleManagerProps) {