Skip to content

⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.

improvement(web): select several tools at once when adding tools (#186)

Croff5f95ca1c9951
diff --git a/apps/web/messages/ar/settings.json b/apps/web/messages/ar/settings.json
index 67b23bd7..d3558d95 100644
--- a/apps/web/messages/ar/settings.json
+++ b/apps/web/messages/ar/settings.json
@@ -323,7 +323,13 @@
"chooseCredential": "اختيار بيانات اعتماد",
"noCredential": "مفيش بيانات اعتماد {integration} لسه. ضيف واحدة من صفحة التكاملات الأول.",
"deleteMessage": "تشيل {tool}؟ الوكلاء اللي بيستخدموها هيبطّلوا يوصلوا للأداة دي.",
- "scopesUpper": "النطاقات"
+ "scopesUpper": "النطاقات",
+ "selectGroup": "تحديد الكل",
+ "clearGroup": "مسح",
+ "selectedCount": "{count, plural, zero {مفيش أدوات محددة} one {أداة واحدة محددة} two {أداتين محددين} few {# أدوات محددة} many {# أداة محددة} other {# أداة محددة}}",
+ "oneIntegration": "اختار أدوات تكامل واحد — بتشتغل على بيانات اعتماد واحدة.",
+ "continue": "متابعة",
+ "alreadyAdded": "{count, plural, zero {مفيش أدوات مضافة قبل كده.} one {أداة واحدة مضافة على بيانات الاعتماد دي وهيتم تخطيها.} two {أداتين مضافين على بيانات الاعتماد دي وهيتم تخطيهم.} few {# أدوات مضافة على بيانات الاعتماد دي وهيتم تخطيها.} many {# أداة مضافة على بيانات الاعتماد دي وهيتم تخطيها.} other {# أداة مضافة على بيانات الاعتماد دي وهيتم تخطيها.}}"
},
"notifications": {
"title": "الإشعارات",
diff --git a/apps/web/messages/en/settings.json b/apps/web/messages/en/settings.json
index 91deca49..4baeb7c9 100644
--- a/apps/web/messages/en/settings.json
+++ b/apps/web/messages/en/settings.json
@@ -323,7 +323,13 @@
"chooseCredential": "Choose a credential",
"noCredential": "No {integration} credential yet. Add one on the Integrations page first.",
"deleteMessage": "Remove {tool}? Agents using it will lose access to this tool.",
- "scopesUpper": "Scopes"
+ "scopesUpper": "Scopes",
+ "selectGroup": "Select all",
+ "clearGroup": "Clear",
+ "selectedCount": "{count, plural, one {# tool selected} other {# tools selected}}",
+ "oneIntegration": "Pick tools of one integration — they run on one credential.",
+ "continue": "Continue",
+ "alreadyAdded": "{count, plural, one {# tool is already on this credential and is skipped.} other {# tools are already on this credential and are skipped.}}"
},
"notifications": {
"title": "Notifications",
diff --git a/apps/web/messages/ru/settings.json b/apps/web/messages/ru/settings.json
index ee8eb9a8..e83bdf56 100644
--- a/apps/web/messages/ru/settings.json
+++ b/apps/web/messages/ru/settings.json
@@ -323,7 +323,13 @@
"chooseCredential": "Выберите учётные данные",
"noCredential": "Учётных данных {integration} пока нет. Сначала добавьте их на странице «Интеграции».",
"deleteMessage": "Убрать {tool}? Агенты, которые его используют, потеряют доступ к этому инструменту.",
- "scopesUpper": "Скоупы"
+ "scopesUpper": "Скоупы",
+ "selectGroup": "Выбрать все",
+ "clearGroup": "Снять",
+ "selectedCount": "{count, plural, one {Выбран # инструмент} few {Выбрано # инструмента} many {Выбрано # инструментов} other {Выбрано # инструмента}}",
+ "oneIntegration": "Выбирайте инструменты одной интеграции — они работают на одних учётных данных.",
+ "continue": "Далее",
+ "alreadyAdded": "{count, plural, one {# инструмент уже добавлен на эти учётные данные и будет пропущен.} few {# инструмента уже добавлены на эти учётные данные и будут пропущены.} many {# инструментов уже добавлены на эти учётные данные и будут пропущены.} other {# инструмента уже добавлены на эти учётные данные и будут пропущены.}}"
},
"notifications": {
"title": "Уведомления",
diff --git a/apps/web/messages/uk/settings.json b/apps/web/messages/uk/settings.json
index 4f46ece1..e90455fd 100644
--- a/apps/web/messages/uk/settings.json
+++ b/apps/web/messages/uk/settings.json
@@ -323,7 +323,13 @@
"chooseCredential": "Виберіть облікові дані",
"noCredential": "Облікових даних {integration} ще немає. Спершу додайте їх на сторінці «Інтеграції».",
"deleteMessage": "Прибрати {tool}? Агенти, що ним користуються, втратять до нього доступ.",
- "scopesUpper": "Скоупи"
+ "scopesUpper": "Скоупи",
+ "selectGroup": "Вибрати всі",
+ "clearGroup": "Зняти",
+ "selectedCount": "{count, plural, one {Вибрано # інструмент} few {Вибрано # інструменти} many {Вибрано # інструментів} other {Вибрано # інструмента}}",
+ "oneIntegration": "Вибирайте інструменти однієї інтеграції — вони працюють на одних облікових даних.",
+ "continue": "Далі",
+ "alreadyAdded": "{count, plural, one {# інструмент уже додано до цих облікових даних, його буде пропущено.} few {# інструменти вже додано до цих облікових даних, їх буде пропущено.} many {# інструментів уже додано до цих облікових даних, їх буде пропущено.} other {# інструмента вже додано до цих облікових даних, їх буде пропущено.}}"
},
"notifications": {
"title": "Сповіщення",
diff --git a/apps/web/messages/zh-CN/settings.json b/apps/web/messages/zh-CN/settings.json
index 7d630624..89a4adb8 100644
--- a/apps/web/messages/zh-CN/settings.json
+++ b/apps/web/messages/zh-CN/settings.json
@@ -323,7 +323,13 @@
"chooseCredential": "选择凭据",
"noCredential": "尚无 {integration} 凭据。请先在集成页面添加。",
"deleteMessage": "移除 {tool}?使用它的代理将无法再访问此工具。",
- "scopesUpper": "权限范围"
+ "scopesUpper": "权限范围",
+ "selectGroup": "全选",
+ "clearGroup": "清除",
+ "selectedCount": "{count, plural, other {已选择 # 个工具}}",
+ "oneIntegration": "请选择同一集成的工具,它们使用同一份凭据。",
+ "continue": "继续",
+ "alreadyAdded": "{count, plural, other {其中 # 个工具已在该凭据上配置,将被跳过。}}"
},
"notifications": {
"title": "通知",
diff --git a/apps/web/src/features/settings/components/agent-tools/SettingsAgentTools.tsx b/apps/web/src/features/settings/components/agent-tools/SettingsAgentTools.tsx
index 86857589..868c4249 100644
--- a/apps/web/src/features/settings/components/agent-tools/SettingsAgentTools.tsx
+++ b/apps/web/src/features/settings/components/agent-tools/SettingsAgentTools.tsx
@@ -12,8 +12,9 @@ import { integrationLabel } from '../../utils/integrationLabels';
import { useTranslations } from 'next-intl';
// Project settings for configured tools: a catalog tool bound to an integration
-// credential. Adding picks a tool and a credential of its integration; deleting
-// confirms first. Enabling a configured tool on an agent is done on the agent editor.
+// credential. Adding picks one or more tools of one integration and a credential of
+// that integration; deleting confirms first. Enabling a configured tool on an agent is
+// done on the agent editor.
export default function SettingsAgentTools({ project }: { project: ProjectDetail }) {
const t = useTranslations('settings.tools');
const tCommon = useTranslations('common');
diff --git a/apps/web/src/features/settings/components/agent-tools/ToolConfigDialog.tsx b/apps/web/src/features/settings/components/agent-tools/ToolConfigDialog.tsx
index 80a37e6a..a4b39476 100644
--- a/apps/web/src/features/settings/components/agent-tools/ToolConfigDialog.tsx
+++ b/apps/web/src/features/settings/components/agent-tools/ToolConfigDialog.tsx
@@ -16,9 +16,9 @@ export interface ToolOption {
integrationLabel: string;
}
-// Add a configured tool in two steps: pick a tool from the searchable, grouped catalog
-// (ToolPicker), then pick a credential of its integration to run it on
-// (ToolCredentialStep).
+// Add configured tools in two steps: pick one or more tools of the same integration from
+// the searchable, grouped catalog (ToolPicker), then pick a credential of that
+// integration to run them on (ToolCredentialStep).
export function ToolConfigDialog({
projectKey,
catalog,
@@ -36,11 +36,11 @@ export function ToolConfigDialog({
catalog
.filter((i) => i.kind === 'tool')
.flatMap((i) =>
- i.tools.map((t) => ({
- toolKey: t.key,
- label: t.label,
- description: t.description,
- scopes: t.scopes ?? [],
+ i.tools.map((tool) => ({
+ toolKey: tool.key,
+ label: tool.label,
+ description: tool.description,
+ scopes: tool.scopes ?? [],
integrationKey: i.key,
integrationLabel: i.label,
})),
@@ -48,21 +48,20 @@ export function ToolConfigDialog({
[catalog],
);
- const [toolKey, setToolKey] = useState<string | null>(null);
- const tool = toolOptions.find((t) => t.toolKey === toolKey);
+ const [tools, setTools] = useState<ToolOption[]>([]);
return (
<Modal title={t('add')} projectKey={projectKey} onClose={onClose} wide>
- {tool ? (
+ {tools.length > 0 ? (
<ToolCredentialStep
projectKey={projectKey}
- tool={tool}
+ tools={tools}
credentials={credentials}
- onBack={() => setToolKey(null)}
+ onBack={() => setTools([])}
onDone={onClose}
/>
) : (
- <ToolPicker options={toolOptions} onSelect={setToolKey} />
+ <ToolPicker options={toolOptions} onSubmit={setTools} />
)}
</Modal>
);
diff --git a/apps/web/src/features/settings/components/agent-tools/ToolCredentialStep.tsx b/apps/web/src/features/settings/components/agent-tools/ToolCredentialStep.tsx
index b43c59b9..a946bbf6 100644
--- a/apps/web/src/features/settings/components/agent-tools/ToolCredentialStep.tsx
+++ b/apps/web/src/features/settings/components/agent-tools/ToolCredentialStep.tsx
@@ -11,7 +11,7 @@ import {
SelectValue,
} from '@/components/ui/select';
import { Badge } from '@/components/ui/badge';
-import { useCreateConfiguredTool } from '@/services/customTools.service';
+import { useConfiguredToolsQuery, useCreateConfiguredTool } from '@/services/customTools.service';
import { IntegrationIcon } from '../integrations/IntegrationIcon';
import type { ToolOption } from './ToolConfigDialog';
import { useTranslations } from 'next-intl';
@@ -20,36 +20,50 @@ import { useTranslations } from 'next-intl';
// can still be told apart.
const credLabel = (c: IntegrationOption) => c.label ?? `Credential #${c.id}`;
-// Step two of adding a tool: pick the credential the tool runs on. The credential list
-// is narrowed to the tool's integration; if none exists yet, the user is pointed at the
-// Integrations page. `onBack` returns to the tool picker.
+// Step two of adding tools: pick the credential they run on. All picked tools belong to
+// one integration, so one credential covers them; the list is narrowed to that
+// integration, and if none exists yet, the user is pointed at the Integrations page.
+// Tools already configured on the chosen credential are skipped, because the API answers
+// 409 for a duplicate and that would abort the rest of the batch. `onBack` returns to the
+// tool picker.
export function ToolCredentialStep({
projectKey,
- tool,
+ tools,
credentials,
onBack,
onDone,
}: {
projectKey: string;
- tool: ToolOption;
+ tools: ToolOption[];
credentials: IntegrationOption[];
onBack: () => void;
onDone: () => void;
}) {
const t = useTranslations('settings.tools');
const tCommon = useTranslations('common');
- const matching = credentials.filter((c) => c.integrationKey === tool.integrationKey);
+ const { integrationKey, integrationLabel } = tools[0];
+ const matching = credentials.filter((c) => c.integrationKey === integrationKey);
const [credentialId, setCredentialId] = useState<number | null>(matching[0]?.id ?? null);
const [busy, setBusy] = useState(false);
+ const configured = useConfiguredToolsQuery(projectKey).data ?? [];
+ const pending = tools.filter(
+ (tool) =>
+ !configured.some((c) => c.toolKey === tool.toolKey && c.credentialId === credentialId),
+ );
+ const skipped = tools.length - pending.length;
+ const scopes = [...new Set(tools.flatMap((tool) => tool.scopes))];
+
const create = useCreateConfiguredTool(projectKey);
- const canSubmit = credentialId != null && !busy;
+ const canSubmit = credentialId != null && pending.length > 0 && !busy;
async function submit() {
if (!canSubmit || credentialId == null) return;
setBusy(true);
try {
- await create.mutateAsync({ toolKey: tool.toolKey, credentialId });
+ for (const tool of pending) {
+ await create.mutateAsync({ toolKey: tool.toolKey, credentialId });
+ }
onDone();
} catch {
setBusy(false);
@@ -69,22 +83,31 @@ export function ToolCredentialStep({
<ChevronLeft className="size-4" />
</Button>
<IntegrationIcon
- integration={{ label: tool.integrationLabel, kind: 'tool' }}
+ integration={{ label: integrationLabel, kind: 'tool' }}
className="size-8"
/>
<div className="min-w-0">
- <span className="block text-sm font-medium text-foreground">{tool.label}</span>
- <span className="block text-xs text-muted-foreground">{tool.integrationLabel}</span>
+ <span className="block text-sm font-medium text-foreground">{integrationLabel}</span>
+ <span className="block text-xs text-muted-foreground">
+ {t('selectedCount', { count: tools.length })}
+ </span>
</div>
</div>
- <p className="text-xs text-muted-foreground">{tool.description}</p>
+ <div className="max-h-40 space-y-2 overflow-y-auto">
+ {tools.map((tool) => (
+ <div key={tool.toolKey}>
+ <span className="block text-sm text-foreground">{tool.label}</span>
+ <span className="block text-xs text-muted-foreground">{tool.description}</span>
+ </div>
+ ))}
+ </div>
- {tool.scopes.length > 0 && (
+ {scopes.length > 0 && (
<div className="space-y-1.5">
<Label>{t('scopesLabel')}</Label>
<div className="flex flex-wrap gap-1">
- {tool.scopes.map((s) => (
+ {scopes.map((s) => (
<Badge key={s} variant="secondary" className="font-mono text-[10px] font-normal">
{s}
</Badge>
@@ -97,7 +120,7 @@ export function ToolCredentialStep({
<Label>{t('credential')}</Label>
{matching.length === 0 ? (
<p className="text-xs text-muted-foreground">
- {t('noCredential', { integration: tool.integrationLabel })}
+ {t('noCredential', { integration: integrationLabel })}
</p>
) : (
<Select
@@ -116,6 +139,9 @@ export function ToolCredentialStep({
</SelectContent>
</Select>
)}
+ {skipped > 0 && (
+ <p className="text-xs text-muted-foreground">{t('alreadyAdded', { count: skipped })}</p>
+ )}
</div>
<div className="flex justify-end gap-2">
diff --git a/apps/web/src/features/settings/components/agent-tools/ToolPicker.tsx b/apps/web/src/features/settings/components/agent-tools/ToolPicker.tsx
index e0de84d0..06b17e87 100644
--- a/apps/web/src/features/settings/components/agent-tools/ToolPicker.tsx
+++ b/apps/web/src/features/settings/components/agent-tools/ToolPicker.tsx
@@ -2,22 +2,27 @@ import { useMemo, useState } from 'react';
import { Search } from 'lucide-react';
import { Input } from '@/components/ui/input';
import { Badge } from '@/components/ui/badge';
+import { Button } from '@/components/ui/button';
+import { Checkbox } from '@/components/ui/checkbox';
+import { cn } from '@/lib/utils';
import { IntegrationIcon } from '../integrations/IntegrationIcon';
import type { ToolOption } from './ToolConfigDialog';
import { useTranslations } from 'next-intl';
-// Step one of adding a tool: pick the tool. The catalog tools are grouped by their
+// Step one of adding tools: pick them. The catalog tools are grouped by their
// integration (Jina, Firecrawl, Telegram) in a full-width searchable list, matching the
-// integration picker. Selecting a tool advances to the credential step.
+// integration picker. The selection stays inside one integration because step two binds
+// it to a single credential of that integration.
export function ToolPicker({
options,
- onSelect,
+ onSubmit,
}: {
options: ToolOption[];
- onSelect: (toolKey: string) => void;
+ onSubmit: (tools: ToolOption[]) => void;
}) {
const t = useTranslations('settings.tools');
const [query, setQuery] = useState('');
+ const [selected, setSelected] = useState<string[]>([]);
const matches = useMemo(() => {
const q = query.trim().toLowerCase();
@@ -31,13 +36,32 @@ export function ToolPicker({
);
}, [options, query]);
- // The distinct integrations present in the matches, in first-seen catalog order.
+ // The matches split by integration, in first-seen catalog order.
const groups = useMemo(() => {
- const seen: string[] = [];
- for (const o of matches) if (!seen.includes(o.integrationKey)) seen.push(o.integrationKey);
- return seen;
+ const byIntegration = new Map<string, ToolOption[]>();
+ for (const o of matches) {
+ const items = byIntegration.get(o.integrationKey);
+ if (items) items.push(o);
+ else byIntegration.set(o.integrationKey, [o]);
+ }
+ return [...byIntegration.values()];
}, [matches]);
+ const lockedTo = options.find((o) => o.toolKey === selected[0])?.integrationKey ?? null;
+
+ function toggle(toolKey: string, on: boolean) {
+ setSelected((prev) => (on ? [...prev, toolKey] : prev.filter((k) => k !== toolKey)));
+ }
+
+ // The group toggle acts on the tools the search leaves on screen, so it never selects
+ // a tool the user is not looking at.
+ function toggleGroup(items: ToolOption[], allSelected: boolean) {
+ const keys = items.map((o) => o.toolKey);
+ setSelected((prev) =>
+ allSelected ? prev.filter((k) => !keys.includes(k)) : [...new Set([...prev, ...keys])],
+ );
+ }
+
return (
<div className="space-y-4">
<div className="relative">
@@ -57,11 +81,12 @@ export function ToolPicker({
{t('noMatches', { query: query.trim() })}
</p>
)}
- {groups.map((integrationKey) => {
- const items = matches.filter((o) => o.integrationKey === integrationKey);
- const integrationLabel = items[0].integrationLabel;
+ {groups.map((items) => {
+ const { integrationKey, integrationLabel } = items[0];
+ const disabled = lockedTo != null && lockedTo !== integrationKey;
+ const allSelected = items.every((o) => selected.includes(o.toolKey));
return (
- <div key={integrationKey} className="space-y-1.5">
+ <div key={integrationKey} className={cn('space-y-1.5', disabled && 'opacity-50')}>
<div className="flex items-center gap-2 px-1">
<IntegrationIcon
integration={{ label: integrationLabel, kind: 'tool' }}
@@ -70,40 +95,71 @@ export function ToolPicker({
<h3 className="text-xs font-semibold tracking-wide text-foreground uppercase">
{integrationLabel}
</h3>
+ <button
+ type="button"
+ disabled={disabled}
+ onClick={() => toggleGroup(items, allSelected)}
+ className="ms-auto text-xs font-medium text-muted-foreground transition-colors hover:text-foreground disabled:pointer-events-none"
+ >
+ {allSelected ? t('clearGroup') : t('selectGroup')}
+ </button>
</div>
<div className="space-y-1">
{items.map((o) => (
- <button
+ <label
key={o.toolKey}
- type="button"
- onClick={() => onSelect(o.toolKey)}
- className="block w-full rounded-lg border border-transparent px-3 py-2 text-start transition-colors hover:bg-muted/60 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none"
+ className={cn(
+ 'flex w-full items-start gap-2.5 rounded-lg border border-transparent px-3 py-2 transition-colors',
+ disabled ? 'cursor-not-allowed' : 'cursor-pointer hover:bg-muted/60',
+ )}
>
- <span className="block text-sm font-medium text-foreground">{o.label}</span>
- <span className="block text-xs text-muted-foreground">{o.description}</span>
- {o.scopes.length > 0 && (
- <span className="mt-1.5 flex flex-wrap items-center gap-1">
- <span className="text-[10px] tracking-wide text-muted-foreground uppercase">
- {t('scopesUpper')}
+ <Checkbox
+ className="mt-0.5"
+ disabled={disabled}
+ checked={selected.includes(o.toolKey)}
+ onCheckedChange={(v) => toggle(o.toolKey, v === true)}
+ />
+ <span className="min-w-0">
+ <span className="block text-sm font-medium text-foreground">{o.label}</span>
+ <span className="block text-xs text-muted-foreground">{o.description}</span>
+ {o.scopes.length > 0 && (
+ <span className="mt-1.5 flex flex-wrap items-center gap-1">
+ <span className="text-[10px] tracking-wide text-muted-foreground uppercase">
+ {t('scopesUpper')}
+ </span>
+ {o.scopes.map((s) => (
+ <Badge
+ key={s}
+ variant="secondary"
+ className="font-mono text-[10px] font-normal"
+ >
+ {s}
+ </Badge>
+ ))}
</span>
- {o.scopes.map((s) => (
- <Badge
- key={s}
- variant="secondary"
- className="font-mono text-[10px] font-normal"
- >
- {s}
- </Badge>
- ))}
- </span>
- )}
- </button>
+ )}
+ </span>
+ </label>
))}
</div>
</div>
);
})}
</div>
+
+ <div className="flex items-center justify-between gap-3 border-t pt-3">
+ <span className="text-xs text-muted-foreground">
+ {selected.length > 0
+ ? t('selectedCount', { count: selected.length })
+ : t('oneIntegration')}
+ </span>
+ <Button
+ disabled={selected.length === 0}
+ onClick={() => onSubmit(options.filter((o) => selected.includes(o.toolKey)))}
+ >
+ {t('continue')}
+ </Button>
+ </div>
</div>
);
}