From 4586479852e40f0ce8d4a38b8ec3b98c042d5a04 Mon Sep 17 00:00:00 2001 From: Pascal Date: Thu, 4 Jun 2026 13:09:49 +0200 Subject: [PATCH] webui: fix tool selector toggle/counter, key tools by stable identity (#24065) * webui: fix tool selector toggle/counter, key tools by stable identity Key the disabled set, counts and toggles by a stable per-tool key instead of bare function name, deduped from one canonical list. Per-tool checkboxes become presentational (single row handler, no nested button), category checkboxes drop the tristate (n/total carries partial). One getEnabledToolsForLLM keeps normalized MCP schemas and dedupes by name. * ui: use SvelteSet and SvelteMap for local tool collections to satisfy svelte/prefer-svelte-reactivity --- .../ChatFormActionAddSheet.svelte | 3 +- .../ChatFormActionAddToolsSubmenu.svelte | 39 +- .../SettingsChat/SettingsChatToolsTab.svelte | 18 +- tools/ui/src/lib/constants/storage.ts | 3 + .../src/lib/hooks/use-tools-panel.svelte.ts | 27 +- tools/ui/src/lib/stores/tools.svelte.ts | 349 ++++++++---------- tools/ui/src/lib/types/tools.d.ts | 4 +- 7 files changed, 203 insertions(+), 240 deletions(-) diff --git a/tools/ui/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddSheet.svelte b/tools/ui/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddSheet.svelte index 9adb9eb89d..c4069163f6 100644 --- a/tools/ui/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddSheet.svelte +++ b/tools/ui/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddSheet.svelte @@ -231,7 +231,7 @@
{#each toolsPanel.activeGroups as group (group.label)} - {@const { checked, indeterminate } = toolsPanel.getGroupCheckedState(group)} + {@const checked = toolsPanel.isGroupChecked(group)} {@const enabledCount = toolsPanel.getEnabledToolCount(group)} {@const favicon = toolsPanel.getFavicon(group)} @@ -259,7 +259,6 @@ e.stopPropagation()} onCheckedChange={() => toolsPanel.toggleGroupByLabel(group.label)} diff --git a/tools/ui/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddToolsSubmenu.svelte b/tools/ui/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddToolsSubmenu.svelte index 813227fbce..9a5b0cbe86 100644 --- a/tools/ui/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddToolsSubmenu.svelte +++ b/tools/ui/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddToolsSubmenu.svelte @@ -1,5 +1,5 @@