mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-04 22:02:16 +02:00
refactor: simplify tool visibility logic and update UI labels in the ComposerAction component
This commit is contained in:
parent
526940e9fe
commit
86dce54294
1 changed files with 3 additions and 29 deletions
|
|
@ -897,24 +897,6 @@ const ComposerAction: FC<ComposerActionProps> = ({ isBlockedByOtherUser = false
|
||||||
return result;
|
return result;
|
||||||
}, [filteredTools, connectedTypes]);
|
}, [filteredTools, connectedTypes]);
|
||||||
|
|
||||||
const { visibleTotal, visibleEnabled } = useMemo(() => {
|
|
||||||
let total = 0;
|
|
||||||
let enabled = 0;
|
|
||||||
for (const group of groupedTools) {
|
|
||||||
if (group.connectorIcon) {
|
|
||||||
total += 1;
|
|
||||||
const allDisabled = group.tools.every((t) => disabledTools.includes(t.name));
|
|
||||||
if (!allDisabled) enabled += 1;
|
|
||||||
} else {
|
|
||||||
for (const tool of group.tools) {
|
|
||||||
total += 1;
|
|
||||||
if (!disabledTools.includes(tool.name)) enabled += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return { visibleTotal: total, visibleEnabled: enabled };
|
|
||||||
}, [groupedTools, disabledTools]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
hydrateDisabled();
|
hydrateDisabled();
|
||||||
}, [hydrateDisabled]);
|
}, [hydrateDisabled]);
|
||||||
|
|
@ -963,11 +945,8 @@ const ComposerAction: FC<ComposerActionProps> = ({ isBlockedByOtherUser = false
|
||||||
<Drawer open={toolsPopoverOpen} onOpenChange={setToolsPopoverOpen}>
|
<Drawer open={toolsPopoverOpen} onOpenChange={setToolsPopoverOpen}>
|
||||||
<DrawerContent className="max-h-[60dvh]">
|
<DrawerContent className="max-h-[60dvh]">
|
||||||
<DrawerHandle />
|
<DrawerHandle />
|
||||||
<div className="flex items-center justify-between px-4 py-2">
|
<div className="px-4 py-2">
|
||||||
<DrawerTitle className="text-sm font-medium">Agent Tools</DrawerTitle>
|
<DrawerTitle className="text-sm font-medium">Manage Tools</DrawerTitle>
|
||||||
<span className="text-xs text-muted-foreground">
|
|
||||||
{visibleEnabled}/{visibleTotal} enabled
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="overflow-y-auto pb-6" onScroll={handleToolsScroll}>
|
<div className="overflow-y-auto pb-6" onScroll={handleToolsScroll}>
|
||||||
{groupedTools
|
{groupedTools
|
||||||
|
|
@ -1082,12 +1061,7 @@ const ComposerAction: FC<ComposerActionProps> = ({ isBlockedByOtherUser = false
|
||||||
className="w-[calc(100vw-2rem)] max-w-56 sm:max-w-72 sm:w-72 p-0 select-none"
|
className="w-[calc(100vw-2rem)] max-w-56 sm:max-w-72 sm:w-72 p-0 select-none"
|
||||||
onOpenAutoFocus={(e) => e.preventDefault()}
|
onOpenAutoFocus={(e) => e.preventDefault()}
|
||||||
>
|
>
|
||||||
<div className="flex items-center justify-between px-2.5 py-2 sm:px-3 sm:py-2.5 border-b">
|
<div className="sr-only">Manage Tools</div>
|
||||||
<span className="text-xs sm:text-sm font-medium">Agent Tools</span>
|
|
||||||
<span className="text-[10px] sm:text-xs text-muted-foreground">
|
|
||||||
{visibleEnabled}/{visibleTotal} enabled
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div
|
<div
|
||||||
className="max-h-48 sm:max-h-64 overflow-y-auto py-0.5 sm:py-1"
|
className="max-h-48 sm:max-h-64 overflow-y-auto py-0.5 sm:py-1"
|
||||||
onScroll={handleToolsScroll}
|
onScroll={handleToolsScroll}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue