diff --git a/surfsense_web/components/assistant-ui/thread.tsx b/surfsense_web/components/assistant-ui/thread.tsx index 2cf0393da..0d0163d8a 100644 --- a/surfsense_web/components/assistant-ui/thread.tsx +++ b/surfsense_web/components/assistant-ui/thread.tsx @@ -834,6 +834,7 @@ const ComposerAction: FC = ({ isBlockedByOtherUser = false const { data: agentTools } = useAtomValue(agentToolsAtom); const disabledTools = useAtomValue(disabledToolsAtom); + const disabledToolsSet = useMemo(() => new Set(disabledTools), [disabledTools]); const toggleTool = useSetAtom(toggleToolAtom); const setDisabledTools = useSetAtom(disabledToolsAtom); const hydrateDisabled = useSetAtom(hydrateDisabledToolsAtom); @@ -846,18 +847,18 @@ const ComposerAction: FC = ({ isBlockedByOtherUser = false const toggleToolGroup = useCallback( (toolNames: string[]) => { - const allDisabled = toolNames.every((name) => disabledTools.includes(name)); + const allDisabled = toolNames.every((name) => disabledToolsSet.has(name)); if (allDisabled) { setDisabledTools((prev) => prev.filter((t) => !toolNames.includes(t))); } else { setDisabledTools((prev) => [...new Set([...prev, ...toolNames])]); } }, - [disabledTools, setDisabledTools] + [disabledToolsSet, setDisabledTools] ); const hasWebSearchTool = agentTools?.some((t) => t.name === "web_search") ?? false; - const isWebSearchEnabled = hasWebSearchTool && !disabledTools.includes("web_search"); + const isWebSearchEnabled = hasWebSearchTool && !disabledToolsSet.has("web_search"); const filteredTools = useMemo( () => agentTools?.filter((t) => t.name !== "web_search"), [agentTools] @@ -957,7 +958,7 @@ const ComposerAction: FC = ({ isBlockedByOtherUser = false {group.label} {group.tools.map((tool) => { - const isDisabled = disabledTools.includes(tool.name); + const isDisabled = disabledToolsSet.has(tool.name); const ToolIcon = getToolIcon(tool.name); return (
= ({ isBlockedByOtherUser = false const iconKey = group.connectorIcon ?? ""; const iconInfo = CONNECTOR_TOOL_ICON_PATHS[iconKey]; const toolNames = group.tools.map((t) => t.name); - const allDisabled = toolNames.every((n) => disabledTools.includes(n)); + const allDisabled = toolNames.every((n) => disabledToolsSet.has(n)); return (
= ({ isBlockedByOtherUser = false {group.label}
{group.tools.map((tool) => { - const isDisabled = disabledTools.includes(tool.name); + const isDisabled = disabledToolsSet.has(tool.name); const ToolIcon = getToolIcon(tool.name); const row = (
@@ -1115,7 +1116,7 @@ const ComposerAction: FC = ({ isBlockedByOtherUser = false const iconKey = group.connectorIcon ?? ""; const iconInfo = CONNECTOR_TOOL_ICON_PATHS[iconKey]; const toolNames = group.tools.map((t) => t.name); - const allDisabled = toolNames.every((n) => disabledTools.includes(n)); + const allDisabled = toolNames.every((n) => disabledToolsSet.has(n)); const groupDef = TOOL_GROUPS.find((g) => g.label === group.label); const row = (