Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

feat(web): clearer ai center capabilities page and action feedback (#17039)

Louai Boumedienee7b6e333134c
diff --git a/brain/knowledge/ai-intelligence/ai-providers.md b/brain/knowledge/ai-intelligence/ai-providers.md
index 1de8aa9e401..71475bc8c86 100644
--- a/brain/knowledge/ai-intelligence/ai-providers.md
+++ b/brain/knowledge/ai-intelligence/ai-providers.md
@@ -269,3 +269,5 @@ Paths verified 2026-07-26.
- **OpenAI, Azure and Meta language models run on the Responses API with `store: false`; everything else OpenAI-shaped stays on Chat Completions.** New OpenAI-shaped vendors default to Responses whenever their API serves an OpenAI-compatible `/responses` (Meta's does; NVIDIA's hosted API serves only `/chat/completions`, so NVIDIA stays on chat). `createLanguageModel` builds OpenAI and Azure with `.responses()`. A Cloudflare Gateway `openai/*` text model goes to the gateway's `/openai` endpoint with `.responses()` on **both** routes: chat and agents use `routing: 'compat'`, which otherwise sends everything to `/compat/chat/completions`, so the OpenAI check has to sit before the compat early return. `withoutServerStorage` wraps them so `store: false` is the default. Chat Completions refuses tools + reasoning from gpt-5.4 on, and the gpt-5.6 family needs Responses for agents and chat (GIT-1848). `store: false` matters because the default `true` makes the SDK replay saved history as `item_reference` ids, which break after OpenAI's 30-day retention, on a key switch, or when compaction drops parts. Azure's Responses model reads `providerOptions.azure` and only falls back to `openai` when that key is absent, so set options under the provider's own key. The vendors (xAI, DeepSeek, ...), Mistral, every non-OpenAI model on the Cloudflare compat route, and Custom keep Chat Completions, because many of them only speak it. Custom offers Responses through `apiStyle: 'responses'`. To test `store: false`, give the saved assistant turn a **text** part with an `itemId`. With `store: true` the SDK swaps only text, reasoning and provider-run tool parts for `item_reference`, and plain function tool calls are always sent in full, so a tool-call-only fixture passes either way.
- **Meta's Model API accepts only `tool_choice: auto`; anything else is a 400.** Two callers force a tool choice: Extract structured data (`required`) and the agent's last step (a named tool, or `none`). `createLanguageModel` wraps Meta in `autoToolChoiceOnly`, which sends `required` as `auto`, a named tool as `auto` with only that tool offered, and `none` as no tools. `auto` alone lets the model answer in text, so a forced call also gets an instruction naming the tool and one retry when the reply has no tool call, and a second text reply throws `ForcedToolNotCalledError` so callers fail instead of completing without the tool output; a forced streamed call (the agent's last step) is served from that retried generate call through `simulateStreamingMiddleware`. Any middleware that calls the model more than once must return the summed `usage` of every attempt (`addUsage` there): `billedLanguageModel` bills only the usage on the returned result, so a dropped attempt is unbilled spend. A middleware that throws after spending tokens has to carry the usage on its error the way `ForcedToolNotCalledError` does, and `reportFailedAttempts` in `activepieces-ai-cost.ts` must recognise it (by `name` and a `usage` field), or the failed call is never billed. Do not `import` the error class into `server-utils`: CI installs two copies of `[email protected]` with different peer hashes, and pulling `ai-providers`' types in first makes the global `AI_SDK_TELEMETRY_INTEGRATIONS` come from the other copy, which fails the `server-utils` build in `agent-ai-utils.ts` (it passes locally, where bun dedupes them). Reuse it for any vendor with the same limit rather than patching callers. The Llama API (`api.llama.com`) that predates it shut down on 2026-07-06; Meta now means the Muse models on `api.meta.ai/v1`.
- **NVIDIA's hosted keys (build.nvidia.com) are for trial and development only, and its `/models` lists classifiers next to chat models.** NVIDIA's terms forbid production use of the hosted catalogue (about 40 RPM, no paid tier), so production users run NIM themselves and connect it through Other (OpenAI Compatible). The catalogue's ids carry no capability field, so the `guard`, `safety`, `reward`, `parse`, `clip`, `detector`, `calibration` and `deplot` fragments in `NON_CHAT_MODEL_ID_FRAGMENTS` are what keep guard, reward and parser models out of chat pickers.
+- **Capability cards draw a service's logo from `AI_TOOL_CATALOG` (`setup/ai-capabilities/catalog.ts`, `logoUrl`), not from a piece.** Tavily, Firecrawl and Apify reuse their piece logos on the CDN; fal.ai has no piece, so `pieces/fal-ai.png` 404s and the card shows an "F" until someone uploads it. A new capability also needs a group in `capabilityGroups()` and a colour in `CAPABILITY_LOOK` (`setup/ai/capabilities-tab`), or it never renders.
+- **Replacing a key's credentials remounts the key page.** `ConfigDetail` is keyed `${id}:${credentialsVersion}` and `onConnected` bumps the version, so any unsaved edit on the page would vanish while the toast says "Saved". The Replace button is therefore disabled while the page is dirty, and `?tab=settings` (read into `initialTab`) brings the admin back to Settings after the remount. It lives in the URL, not state, so leaving by the breadcrumb or Back and reopening the key starts on Models again. Anything else that refreshes the key from outside the page needs the same guard.
diff --git a/brain/knowledge/connections-auth/api-keys.md b/brain/knowledge/connections-auth/api-keys.md
index 7c471f43bf3..0546e6cc3fb 100644
--- a/brain/knowledge/connections-auth/api-keys.md
+++ b/brain/knowledge/connections-auth/api-keys.md
@@ -14,6 +14,7 @@ Long-lived platform service credentials (prefixed `sk-`) for machine-to-machine
- Service: `add` (generates key, stores hashed/truncated), `getByValue` (lookup by SHA-256 hash, updates `lastUsedAt` — used by auth middleware), `list`, `delete`.
### Gotchas
+- **A route is only reachable with an API key if its `security` lists `PrincipalType.SERVICE`.** Otherwise the key gets 403. To publish an endpoint: add `SERVICE` to its `securityAccess` call, give it `tags` and a `description` (no `hide: true`) so Fastify Swagger puts it in the OpenAPI spec, add a `docs/endpoints/<area>/<action>.mdx` page with `openapi: <METHOD> <path>`, and test it with a key. From then on its shape is a public contract. Every AI Center route (providers, tiers, capabilities, usage) is `USER`-only as of 2026-10-29, so none of it is public yet.
- Key generated with `secureApId(61)` + `sk-` prefix = 64 chars; hashed with `cryptoUtils.hashSHA256`.
- Plaintext is only ever available at creation time.
diff --git a/brain/knowledge/engineering/platform-admin-structure.md b/brain/knowledge/engineering/platform-admin-structure.md
index 614ecd39778..0b0ffc11734 100644
--- a/brain/knowledge/engineering/platform-admin-structure.md
+++ b/brain/knowledge/engineering/platform-admin-structure.md
@@ -150,7 +150,7 @@ silently. Worker groups is the last page on the old full-page teaser.
## Gotchas
-- **One purple button per admin page: the header action.** An empty state's own button repeats that action, so it is `variant="outline"` (AI Center Providers "Add key", Tiers "New tier"), and cards below it carry no buttons of their own. Four primaries on one empty Providers page was the complaint that set this.
+- **One purple button per admin page: the header action.** An empty state's own button repeats that action, so it is `variant="outline"` (AI Center Providers "Add key", Tiers "New tier"), and cards below it carry no buttons of their own. Four primaries on one empty Providers page was the complaint that set this. A page locked by plan but still holding data (a downgraded AI Center keeps its keys so they can be deleted) says so in the header, not in a banner: a grey `Read-only` lock pill as the `badge`, the reason as the description, and `Upgrade to …` as the header's primary.
- **`AdminEmpty`'s `icon` is boxed in a 40px tile; anything wider goes in `media`.** `icon` renders inside `EmptyMedia variant="icon"`, which clips a logo row or illustration to one square. `media` renders unboxed (the AI Center providers empty state passes an `AvatarGroup` of provider logos there).
- **A `SettingsPanel` header centres its title against its action only when it has no description.** With a description the title block is two lines, so it stays top-aligned; without one, top alignment left a one-line title floating above a taller button (the AI Center provider cards). Pass no `description` rather than an empty one, or the panel keeps the top alignment.
- **Adding an admin page is three edits**: the sidebar (`components/sidebar/platform`), the route
diff --git a/brain/knowledge/engineering/web-feature-anatomy.md b/brain/knowledge/engineering/web-feature-anatomy.md
index ea6094ddd33..889ad8ca8ad 100644
--- a/brain/knowledge/engineering/web-feature-anatomy.md
+++ b/brain/knowledge/engineering/web-feature-anatomy.md
@@ -80,6 +80,7 @@ way back was to stash the handful of intended edits, `git checkout` the package,
## Gotchas
+- **`ConfirmationDeleteDialog`'s `mutationFn` must return the request's promise (`mutateAsync`), never call `mutate`.** The dialog runs its own mutation: with `mutate` it resolves at once, closes before the request ends, shows no loading and cannot learn of a failure. It also shows no error toast of its own; a failure reaches only its `onError` prop, so the caller's hook must toast it (AI Center capability Reset was silent on both success and failure this way).
- **To style one word inside a translated sentence, translate the whole sentence and split it around a sentinel; nothing in the app uses `Trans`.** Call `t('Type {text} to confirm', { text: SLOT })`, `split(SLOT)`, and render `before`, the styled word, `after`, so translators can still move the word (see `TypeToConfirm` in `components/custom`). Concatenating two separately translated halves fixes the word order to English.
- **Flags are cached with `staleTime: Infinity`, so a setting that feeds a flag must invalidate `flagsHooks.queryKey` after it changes.** Several flags are computed from platform settings (`THIRD_PARTY_AUTH_PROVIDERS_TO_SHOW_MAP` from the Google switch, `EMAIL_AUTH_ENABLED`, `THEME`), and refetching only the platform leaves the flag stale until reload. `ssoMutations.useUpdatePlatformSso` and the appearance section both do `queryClient.invalidateQueries({ queryKey: flagsHooks.queryKey })`.
- **Gate edition-specific UI on the edition you mean, not on "not the other one".** `flagsHooks.useFlag(ApFlagId.EDITION)` is `undefined` until flags load, so `edition !== ApEdition.CLOUD` is true for a moment on Cloud and self-hosted-only copy flashes there. Write `edition === ApEdition.ENTERPRISE` (or the edition you need) so the loading state falls into the safe branch.
diff --git a/packages/web/public/locales/en/translation.json b/packages/web/public/locales/en/translation.json
index 0c7606996a1..aa915179c3f 100644
--- a/packages/web/public/locales/en/translation.json
+++ b/packages/web/public/locales/en/translation.json
@@ -2068,29 +2068,18 @@
"Paste your API key": "Paste your API key",
"Get a {provider} API key": "Get a {provider} API key",
"Web Search": "Web Search",
- "Let the assistant search the live web for current information.": "Let the assistant search the live web for current information.",
"Search API built for AI agents.": "Search API built for AI agents.",
"Web Scraping": "Web Scraping",
- "Let the assistant extract the full clean content of a web page as markdown, including JavaScript-rendered pages.": "Let the assistant extract the full clean content of a web page as markdown, including JavaScript-rendered pages.",
"Clean markdown extraction, handles JS-rendered pages.": "Clean markdown extraction, handles JS-rendered pages.",
"Heavy-duty crawling and content extraction.": "Heavy-duty crawling and content extraction.",
"Image Generation": "Image Generation",
- "Let the assistant generate images — realistic photos, marketing graphics with text, brand logos, and abstract art.": "Let the assistant generate images — realistic photos, marketing graphics with text, brand logos, and abstract art.",
"One key for Flux, Ideogram, Recraft and more — the assistant picks the right model.": "One key for Flux, Ideogram, Recraft and more — the assistant picks the right model.",
"Embeddings": "Embeddings",
- "Index knowledge-base files so agents can search them. Pick one of your AI keys and its embedding model.": "Index knowledge-base files so agents can search them. Pick one of your AI keys and its embedding model.",
- "Assistant capabilities": "Assistant capabilities",
- "Search and images use your AI provider. Scraping needs a service of its own. Connect a service to use it in place of your provider.": "Search and images use your AI provider. Scraping needs a service of its own. Connect a service to use it in place of your provider.",
"AI tools": "AI tools",
- "Using {provider}": "Using {provider}",
"Reset {name}": "Reset {name}",
"Knowledge bases go back to using {provider}.": "Knowledge bases go back to using {provider}.",
"Chat goes back to using {provider}.": "Chat goes back to using {provider}.",
"This removes the saved API key and disables this capability.": "This removes the saved API key and disables this capability.",
- "Knowledge bases can index files": "Knowledge bases can index files",
- "Knowledge bases can't index files yet": "Knowledge bases can't index files yet",
- "Available to the assistant": "Available to the assistant",
- "The assistant can't do this yet": "The assistant can't do this yet",
"Context": "Context",
"Price per 1M": "Price per 1M",
"Selected only": "Selected only",
@@ -2147,11 +2136,27 @@
"Add key": "Add key",
"AI providers": "AI providers",
"Also available": "Also available",
+ "Could not check this key": "Could not check this key",
+ "Could not reset this capability": "Could not reset this capability",
+ "Save or discard your changes first": "Save or discard your changes first",
+ "Default chat model cleared": "Default chat model cleared",
+ "Read-only": "Read-only",
+ "Your plan doesn't include your own AI keys. You can still delete them.": "Your plan doesn't include your own AI keys. You can still delete them.",
+ "Using {provider}": "Using {provider}",
+ "{service} API key": "{service} API key",
+ "or an AI provider key": "or an AI provider key",
+ "an AI provider key": "an AI provider key",
+ "Extra skills for chat, agents and knowledge bases.": "Extra skills for chat, agents and knowledge bases.",
+ "Chat and agents": "Chat and agents",
+ "Knowledge bases": "Knowledge bases",
+ "Works with": "Works with",
+ "Search the live web for current information.": "Search the live web for current information.",
+ "Read any web page as clean text, including JavaScript pages.": "Read any web page as clean text, including JavaScript pages.",
+ "Create images, from photos to graphics with text.": "Create images, from photos to graphics with text.",
+ "Index knowledge-base files so agents can search them.": "Index knowledge-base files so agents can search them.",
"No providers yet": "No providers yet",
"Add an API key to turn on chat, agents and AI steps.": "Add an API key to turn on chat, agents and AI steps.",
"Choose a provider": "Choose a provider",
- "Your plan does not include Bring your own AI keys": "Your plan does not include Bring your own AI keys",
- "You can still delete the keys below. Upgrade your plan to add new keys or change existing ones.": "You can still delete the keys below. Upgrade your plan to add new keys or change existing ones.",
"Keys": "Keys",
"modelsCount": "{count, plural, =1 {1 model} other {# models}}",
"exceptProjectsCount": "{count, plural, =1 {All except 1 project} other {All except # projects}}",
diff --git a/packages/web/src/app/routes/platform/setup/ai-capabilities/ai-capability-dialog.tsx b/packages/web/src/app/routes/platform/setup/ai-capabilities/ai-capability-dialog.tsx
index 28baafa1844..e9509faf08b 100644
--- a/packages/web/src/app/routes/platform/setup/ai-capabilities/ai-capability-dialog.tsx
+++ b/packages/web/src/app/routes/platform/setup/ai-capabilities/ai-capability-dialog.tsx
@@ -16,6 +16,7 @@ import { ExternalLink } from 'lucide-react';
import { useState } from 'react';
import { useForm } from 'react-hook-form';
import { Link } from 'react-router-dom';
+import { toast } from 'sonner';
import { z } from 'zod';
import { adminLayout } from '@/app/components/admin';
@@ -77,16 +78,15 @@ export function AiCapabilityDialog({
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>{children}</DialogTrigger>
- <DialogContent className={adminLayout.dialog.md}>
+ {open && (
<CapabilityForm
- key={open ? 'open' : 'closed'}
capabilityInfo={capabilityInfo}
existingConfig={existingConfig}
defaultProviderId={defaultProviderId}
onClose={() => setOpen(false)}
onSaved={onSaved}
/>
- </DialogContent>
+ )}
</Dialog>
);
}
@@ -188,6 +188,7 @@ function CapabilityForm({
const saveCallbacks: SaveCallbacks = {
onSuccess: () => {
onSaved();
+ toast.success(t('Saved'));
onClose();
},
onError: (error) => {
@@ -204,6 +205,12 @@ function CapabilityForm({
aiToolConfigMutations.useUpsertAiToolConfig(saveCallbacks);
const { mutate: reenable, isPending: isReenabling } =
aiToolConfigMutations.useUpdateAiToolConfig(saveCallbacks);
+ const saving = isPending || isReenabling;
+ const keepOpen = (event: Event) => {
+ if (saving) {
+ event.preventDefault();
+ }
+ };
const handleSubmit = (values: FormValues) => {
form.clearErrors('root.serverError');
@@ -240,181 +247,194 @@ function CapabilityForm({
const sourceCount = aiProviders.length + capabilityInfo.providers.length;
return (
- <Form {...form}>
- <form onSubmit={form.handleSubmit(handleSubmit)} className="space-y-4">
- <DialogHeader>
- <DialogTitle>{capabilityInfo.name}</DialogTitle>
- <DialogDescription>{capabilityInfo.description}</DialogDescription>
- </DialogHeader>
+ <DialogContent
+ className={adminLayout.dialog.md}
+ showCloseButton={!saving}
+ onEscapeKeyDown={keepOpen}
+ onPointerDownOutside={keepOpen}
+ onInteractOutside={keepOpen}
+ >
+ <Form {...form}>
+ <form onSubmit={form.handleSubmit(handleSubmit)} className="space-y-4">
+ <DialogHeader>
+ <DialogTitle>{capabilityInfo.name}</DialogTitle>
+ <DialogDescription>{capabilityInfo.description}</DialogDescription>
+ </DialogHeader>
- {sourceCount > 1 && (
- <FormField
- control={form.control}
- name="source"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t('Source')}</FormLabel>
- <Select
- value={field.value}
- onValueChange={(value) => {
- field.onChange(value);
- form.setValue('modelId', firstEmbeddingModel(value));
- }}
- >
- <FormControl>
- <SelectTrigger>
- <SelectValue />
- </SelectTrigger>
- </FormControl>
- <SelectContent>
- {aiProviders.map((provider) => (
- <SelectItem key={provider.id} value={provider.id}>
- {provider.name}
- </SelectItem>
- ))}
- {capabilityInfo.providers.map((provider) => (
- <SelectItem key={provider.id} value={provider.id}>
- {provider.name}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- <FormMessage />
- </FormItem>
- )}
- />
- )}
+ {sourceCount > 1 && (
+ <FormField
+ control={form.control}
+ name="source"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>{t('Source')}</FormLabel>
+ <Select
+ value={field.value}
+ onValueChange={(value) => {
+ field.onChange(value);
+ form.setValue('modelId', firstEmbeddingModel(value));
+ }}
+ >
+ <FormControl>
+ <SelectTrigger>
+ <SelectValue />
+ </SelectTrigger>
+ </FormControl>
+ <SelectContent>
+ {aiProviders.map((provider) => (
+ <SelectItem key={provider.id} value={provider.id}>
+ {provider.name}
+ </SelectItem>
+ ))}
+ {capabilityInfo.providers.map((provider) => (
+ <SelectItem key={provider.id} value={provider.id}>
+ {provider.name}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ )}
- {selectedAiProvider && needsModel && (
- <FormField
- control={form.control}
- name="modelId"
- render={({ field }) => (
- <FormItem>
- <FormLabel>
- {isEmbeddings ? t('Embedding model') : t('Image model')}
- </FormLabel>
- <Select value={field.value} onValueChange={field.onChange}>
- <FormControl>
- <SelectTrigger>
- <SelectValue placeholder={t('Choose a model')}>
- {selectedModel && (
- <span className="flex min-w-0 items-baseline gap-2">
- <span className="truncate">
- {selectedModel.name}
+ {selectedAiProvider && needsModel && (
+ <FormField
+ control={form.control}
+ name="modelId"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>
+ {isEmbeddings ? t('Embedding model') : t('Image model')}
+ </FormLabel>
+ <Select value={field.value} onValueChange={field.onChange}>
+ <FormControl>
+ <SelectTrigger>
+ <SelectValue placeholder={t('Choose a model')}>
+ {selectedModel && (
+ <span className="flex min-w-0 items-baseline gap-2">
+ <span className="truncate">
+ {selectedModel.name}
+ </span>
+ {selectedModel.name !== selectedModel.id && (
+ <span className="truncate text-xs text-gray-11">
+ {selectedModel.id}
+ </span>
+ )}
</span>
- {selectedModel.name !== selectedModel.id && (
- <span className="truncate text-xs text-gray-11">
- {selectedModel.id}
+ )}
+ </SelectValue>
+ </SelectTrigger>
+ </FormControl>
+ <SelectContent>
+ {modelOptions.map((model) => (
+ <SelectItem key={model.id} value={model.id}>
+ <span className="flex flex-col">
+ <span>{model.name}</span>
+ {model.name !== model.id && (
+ <span className="text-xs text-gray-11">
+ {model.id}
</span>
)}
</span>
- )}
- </SelectValue>
- </SelectTrigger>
- </FormControl>
- <SelectContent>
- {modelOptions.map((model) => (
- <SelectItem key={model.id} value={model.id}>
- <span className="flex flex-col">
- <span>{model.name}</span>
- {model.name !== model.id && (
- <span className="text-xs text-gray-11">
- {model.id}
- </span>
- )}
- </span>
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- <FormMessage />
- </FormItem>
- )}
- />
- )}
-
- {isEmbeddings && sourceCount > 0 && (
- <p className="text-xs text-gray-11">
- {t(
- 'Files already in knowledge bases keep their old vectors. Re-upload them to search with the new key or model.',
- )}
- </p>
- )}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ )}
- {sourceCount === 0 && (
- <div className="flex flex-col items-start gap-2">
- <p className="text-sm text-gray-11">
+ {isEmbeddings && sourceCount > 0 && (
+ <p className="text-xs text-gray-11">
{t(
- 'Add a key that serves all projects and supports embeddings, such as OpenAI, Google, Azure or OpenRouter.',
+ 'Files already in knowledge bases keep their old vectors. Re-upload them to search with the new key or model.',
)}
</p>
- <Button asChild variant="outline" size="sm">
- <Link to="/platform/ai">{t('Add a provider key')}</Link>
- </Button>
- </div>
- )}
+ )}
- {!selectedAiProvider && sourceCount > 0 && (
- <FormField
- control={form.control}
- name="apiKey"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t('API Key')}</FormLabel>
- <FormControl>
- <Input
- {...field}
- type="password"
- autoComplete="off"
- placeholder={
- source === savedKeyProvider
- ? t('Enter a new key to replace the saved one')
- : t('Paste your API key')
- }
- />
- </FormControl>
- {selectedProvider && (
- <a
- href={selectedProvider.signupUrl}
- target="_blank"
- rel="noreferrer"
- className="inline-flex items-center gap-1 text-xs text-gray-11 hover:underline"
- {...adminControl(AdminControl.AI_API_KEY_LINK)}
- >
- {t('Get a {provider} API key', {
- provider: selectedProvider.name,
- })}
- <ExternalLink className="size-3" />
- </a>
+ {sourceCount === 0 && (
+ <div className="flex flex-col items-start gap-2">
+ <p className="text-sm text-gray-11">
+ {t(
+ 'Add a key that serves all projects and supports embeddings, such as OpenAI, Google, Azure or OpenRouter.',
)}
- <FormMessage />
- </FormItem>
- )}
- />
- )}
+ </p>
+ <Button asChild variant="outline" size="sm">
+ <Link to="/platform/ai">{t('Add a provider key')}</Link>
+ </Button>
+ </div>
+ )}
- {form.formState.errors.root?.serverError && (
- <p className="text-sm text-danger-11">
- {form.formState.errors.root.serverError.message}
- </p>
- )}
+ {!selectedAiProvider && sourceCount > 0 && (
+ <FormField
+ control={form.control}
+ name="apiKey"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>{t('API Key')}</FormLabel>
+ <FormControl>
+ <Input
+ {...field}
+ type="password"
+ autoComplete="off"
+ placeholder={
+ source === savedKeyProvider
+ ? t('Enter a new key to replace the saved one')
+ : t('Paste your API key')
+ }
+ />
+ </FormControl>
+ {selectedProvider && (
+ <a
+ href={selectedProvider.signupUrl}
+ target="_blank"
+ rel="noreferrer"
+ className="inline-flex items-center gap-1 text-xs text-gray-11 hover:underline"
+ {...adminControl(AdminControl.AI_API_KEY_LINK)}
+ >
+ {t('Get a {provider} API key', {
+ provider: selectedProvider.name,
+ })}
+ <ExternalLink className="size-3" />
+ </a>
+ )}
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ )}
+
+ {form.formState.errors.root?.serverError && (
+ <p className="text-sm text-danger-11">
+ {form.formState.errors.root.serverError.message}
+ </p>
+ )}
- <DialogFooter>
- <Button type="button" variant="outline" onClick={onClose}>
- {t('Cancel')}
- </Button>
- <Button
- type="submit"
- disabled={sourceCount === 0}
- loading={isPending || isReenabling}
- {...adminControl(AdminControl.AI_CAPABILITY_SUBMIT)}
- >
- {t('Save')}
- </Button>
- </DialogFooter>
- </form>
- </Form>
+ <DialogFooter>
+ <Button
+ type="button"
+ variant="outline"
+ onClick={onClose}
+ disabled={saving}
+ >
+ {t('Cancel')}
+ </Button>
+ <Button
+ type="submit"
+ disabled={sourceCount === 0}
+ loading={saving}
+ {...adminControl(AdminControl.AI_CAPABILITY_SUBMIT)}
+ >
+ {t('Save')}
+ </Button>
+ </DialogFooter>
+ </form>
+ </Form>
+ </DialogContent>
);
}
diff --git a/packages/web/src/app/routes/platform/setup/ai-capabilities/catalog.ts b/packages/web/src/app/routes/platform/setup/ai-capabilities/catalog.ts
index aaa37eb5fb9..d9870dcf41a 100644
--- a/packages/web/src/app/routes/platform/setup/ai-capabilities/catalog.ts
+++ b/packages/web/src/app/routes/platform/setup/ai-capabilities/catalog.ts
@@ -12,6 +12,7 @@ export type AiToolProviderInfo = {
name: string;
description: string;
signupUrl: string;
+ logoUrl: string;
};
export type AiToolCapabilityInfo = {
@@ -25,15 +26,14 @@ export const AI_TOOL_CATALOG: AiToolCapabilityInfo[] = [
{
capability: AiToolCapability.WEB_SEARCH,
name: t('Web Search'),
- description: t(
- 'Let the assistant search the live web for current information.',
- ),
+ description: t('Search the live web for current information.'),
providers: [
{
id: AiToolProvider.TAVILY,
name: 'Tavily',
description: t('Search API built for AI agents.'),
signupUrl: 'https://app.tavily.com',
+ logoUrl: 'https://cdn.activepieces.com/pieces/tavily.jpg',
},
],
},
@@ -41,7 +41,7 @@ export const AI_TOOL_CATALOG: AiToolCapabilityInfo[] = [
capability: AiToolCapability.WEB_SCRAPING,
name: t('Web Scraping'),
description: t(
- 'Let the assistant extract the full clean content of a web page as markdown, including JavaScript-rendered pages.',
+ 'Read any web page as clean text, including JavaScript pages.',
),
providers: [
{
@@ -49,21 +49,21 @@ export const AI_TOOL_CATALOG: AiToolCapabilityInfo[] = [
name: 'Firecrawl',
description: t('Clean markdown extraction, handles JS-rendered pages.'),
signupUrl: 'https://www.firecrawl.dev',
+ logoUrl: 'https://cdn.activepieces.com/pieces/firecrawl.png',
},
{
id: AiToolProvider.APIFY,
name: 'Apify',
description: t('Heavy-duty crawling and content extraction.'),
signupUrl: 'https://console.apify.com',
+ logoUrl: 'https://cdn.activepieces.com/pieces/apify.png',
},
],
},
{
capability: AiToolCapability.IMAGE_GENERATION,
name: t('Image Generation'),
- description: t(
- 'Let the assistant generate images — realistic photos, marketing graphics with text, brand logos, and abstract art.',
- ),
+ description: t('Create images, from photos to graphics with text.'),
providers: [
{
id: AiToolProvider.FAL,
@@ -72,15 +72,14 @@ export const AI_TOOL_CATALOG: AiToolCapabilityInfo[] = [
'One key for Flux, Ideogram, Recraft and more — the assistant picks the right model.',
),
signupUrl: 'https://fal.ai/dashboard/keys',
+ logoUrl: 'https://cdn.activepieces.com/pieces/fal-ai.png',
},
],
},
{
capability: AiToolCapability.EMBEDDINGS,
name: t('Embeddings'),
- description: t(
- 'Index knowledge-base files so agents can search them. Pick one of your AI keys and its embedding model.',
- ),
+ description: t('Index knowledge-base files so agents can search them.'),
providers: [],
},
];
diff --git a/packages/web/src/app/routes/platform/setup/ai/capabilities-tab/index.tsx b/packages/web/src/app/routes/platform/setup/ai/capabilities-tab/index.tsx
index 4ce773da33d..fa7d4f68028 100644
--- a/packages/web/src/app/routes/platform/setup/ai/capabilities-tab/index.tsx
+++ b/packages/web/src/app/routes/platform/setup/ai/capabilities-tab/index.tsx
@@ -7,6 +7,7 @@ import {
} from '@activepieces/shared';
import { t } from 'i18next';
import {
+ ArrowRight,
Database,
Globe,
Image,
@@ -15,15 +16,17 @@ import {
Trash2,
} from 'lucide-react';
import { Link } from 'react-router-dom';
+import { toast } from 'sonner';
import {
AdminPageHeader,
- StatusDot,
+ AdminSection,
adminPageResources,
adminSurface,
} from '@/app/components/admin';
import { DataFetchErrorState } from '@/components/custom/data-fetch-error-state';
import { ConfirmationDeleteDialog } from '@/components/custom/delete-dialog';
+import { LogoPlate } from '@/components/custom/logo-plate';
import { TextWithTooltip } from '@/components/custom/text-with-tooltip';
import { Button } from '@/components/ui/button';
import {
@@ -39,6 +42,7 @@ import {
AI_TOOL_CATALOG,
aiCapabilitySources,
AiToolCapabilityInfo,
+ AiToolProviderInfo,
} from '../../ai-capabilities/catalog';
export function CapabilitiesTab() {
@@ -60,46 +64,57 @@ export function CapabilitiesTab() {
const chatProvider =
providers?.find((provider) => provider.enabledForChat) ?? creditsProvider;
- const { mutate: remove } = aiToolConfigMutations.useDeleteAiToolConfig({
+ const { mutateAsync: remove } = aiToolConfigMutations.useDeleteAiToolConfig({
onSuccess: () => refetchConfigs(),
+ onError: (error) => {
+ const data = error.response?.data;
+ toast.error(
+ t(
+ data?.params?.message ??
+ data?.message ??
+ 'Could not reset this capability',
+ ),
+ );
+ },
});
return (
<>
<AdminPageHeader
- title={t('Assistant capabilities')}
- description={t(
- 'Search and images use your AI provider. Scraping needs a service of its own. Connect a service to use it in place of your provider.',
- )}
+ title={t('Capabilities')}
+ description={t('Extra skills for chat, agents and knowledge bases.')}
resources={adminPageResources.aiCapabilities}
/>
{isError ? (
<DataFetchErrorState entity={t('AI tools')} onRetry={refetch} />
) : (
- <div className="grid grid-cols-1 gap-4 lg:grid-cols-2">
- {AI_TOOL_CATALOG.map((capabilityInfo) => {
- const config = configs?.find(
- (c) => c.capability === capabilityInfo.capability,
- );
- return (
- <CapabilityCard
- key={capabilityInfo.capability}
- capabilityInfo={capabilityInfo}
- config={config}
- providers={providers ?? []}
- chatProviderFallback={fallbackFor({
- capability: capabilityInfo.capability,
- candidates:
- capabilityInfo.capability === AiToolCapability.EMBEDDINGS
- ? [chatProvider, creditsProvider]
- : [chatProvider],
- })}
- onDelete={() => config && remove(config.id)}
- onSaved={() => refetchConfigs()}
- />
- );
- })}
- </div>
+ capabilityGroups().map((group) => (
+ <AdminSection key={group.title} title={group.title}>
+ <div className="grid grid-cols-1 gap-4 lg:grid-cols-2">
+ {AI_TOOL_CATALOG.filter((info) =>
+ group.capabilities.includes(info.capability),
+ ).map((capabilityInfo) => (
+ <CapabilityCard
+ key={capabilityInfo.capability}
+ capabilityInfo={capabilityInfo}
+ config={configs?.find(
+ (c) => c.capability === capabilityInfo.capability,
+ )}
+ providers={providers ?? []}
+ chatProviderFallback={fallbackFor({
+ capability: capabilityInfo.capability,
+ candidates:
+ capabilityInfo.capability === AiToolCapability.EMBEDDINGS
+ ? [chatProvider, creditsProvider]
+ : [chatProvider],
+ })}
+ onDelete={(id) => remove(id)}
+ onSaved={() => refetchConfigs()}
+ />
+ ))}
+ </div>
+ </AdminSection>
+ ))
)}
</>
);
@@ -131,10 +146,10 @@ function CapabilityCard({
config?: AiToolConfigWithoutSensitiveData;
providers: AIProviderWithoutSensitiveData[];
chatProviderFallback?: AIProviderWithoutSensitiveData;
- onDelete: () => void;
+ onDelete: (id: string) => Promise<unknown>;
onSaved: () => void;
}) {
- const Icon = CAPABILITY_ICON[capabilityInfo.capability];
+ const look = CAPABILITY_LOOK[capabilityInfo.capability];
const isEmbeddings =
capabilityInfo.capability === AiToolCapability.EMBEDDINGS;
const needsProviderKey =
@@ -158,104 +173,203 @@ function CapabilityCard({
? providerChoice.data.modelId
: undefined;
const inUse = !isNil(sourceName);
- const status = inUse
- ? t('Using {provider}', { provider: sourceName })
- : t('Not connected');
- const statusText = isNil(chosenModelId)
- ? status
- : `${status} · ${chosenModelId}`;
+ const servedByAiKeys =
+ capabilityInfo.capability !== AiToolCapability.WEB_SCRAPING;
return (
<div className={cn(adminSurface.card, 'group flex flex-col')}>
- <div className="flex items-start gap-4 px-5 pt-5 pb-2">
- <div className="flex size-9 shrink-0 items-center justify-center rounded-lg border bg-gray-1">
- <Icon className="size-4 text-gray-11" />
+ <div className="flex items-start gap-3 p-5">
+ <div
+ className={cn(
+ 'flex size-9 shrink-0 items-center justify-center rounded-lg',
+ look.tile,
+ )}
+ >
+ <look.icon className="size-4" />
</div>
<div className="flex min-w-0 flex-1 flex-col gap-1">
<p className="truncate text-sm font-semibold text-gray-12">
{capabilityInfo.name}
</p>
- <StatusDot
- tone={inUse ? 'success' : 'neutral'}
- className="text-xs text-gray-11"
- >
- <TextWithTooltip tooltipMessage={statusText}>
- <span className="truncate">{statusText}</span>
- </TextWithTooltip>
- </StatusDot>
+ <p className="text-sm text-gray-11">{capabilityInfo.description}</p>
</div>
- {config && (
- <ConfirmationDeleteDialog
- title={t('Reset {name}', { name: capabilityInfo.name })}
- message={
- chatProviderFallback
- ? isEmbeddings
- ? t('Knowledge bases go back to using {provider}.', {
- provider: chatProviderFallback.name,
- })
- : t('Chat goes back to using {provider}.', {
- provider: chatProviderFallback.name,
- })
- : t(
- 'This removes the saved API key and disables this capability.',
- )
- }
- entityName={capabilityInfo.name}
- controlId={AdminControl.AI_CAPABILITY_RESET_CONFIRM}
- mutationFn={async () => onDelete()}
- >
- <Button
- variant="ghost"
- size="icon-sm"
- className="text-gray-11 opacity-0 transition-opacity hover:text-danger-11 group-focus-within:opacity-100 group-hover:opacity-100"
- {...adminControl(AdminControl.AI_CAPABILITY_RESET_OPEN)}
+ <div className="flex shrink-0 items-center gap-1">
+ {config && (
+ <ConfirmationDeleteDialog
+ title={t('Reset {name}', { name: capabilityInfo.name })}
+ message={
+ chatProviderFallback
+ ? isEmbeddings
+ ? t('Knowledge bases go back to using {provider}.', {
+ provider: chatProviderFallback.name,
+ })
+ : t('Chat goes back to using {provider}.', {
+ provider: chatProviderFallback.name,
+ })
+ : t(
+ 'This removes the saved API key and disables this capability.',
+ )
+ }
+ entityName={capabilityInfo.name}
+ showToast
+ onError={() => undefined}
+ controlId={AdminControl.AI_CAPABILITY_RESET_CONFIRM}
+ mutationFn={async () => {
+ await onDelete(config.id);
+ }}
>
- <Trash2 className="size-4" />
+ <Button
+ variant="ghost"
+ size="icon-sm"
+ className="text-gray-11 opacity-0 transition-opacity hover:text-danger-11 group-focus-within:opacity-100 group-hover:opacity-100"
+ {...adminControl(AdminControl.AI_CAPABILITY_RESET_OPEN)}
+ >
+ <Trash2 className="size-4" />
+ </Button>
+ </ConfirmationDeleteDialog>
+ )}
+ {needsProviderKey ? (
+ <Button asChild variant="outline" size="sm">
+ <Link to="/platform/ai">
+ {t('Connect a provider')}
+ <ArrowRight className="size-4" />
+ </Link>
</Button>
- </ConfirmationDeleteDialog>
- )}
+ ) : (
+ <AiCapabilityDialog
+ capabilityInfo={capabilityInfo}
+ existingConfig={config}
+ defaultProviderId={chatProviderFallback?.id}
+ onSaved={onSaved}
+ >
+ <Button
+ variant="outline"
+ size="sm"
+ {...adminControl(AdminControl.AI_CAPABILITY_OPEN)}
+ >
+ {inUse ? t('Change') : t('Set up')}
+ </Button>
+ </AiCapabilityDialog>
+ )}
+ </div>
</div>
- <p className="px-5 pb-5 text-sm text-gray-11">
- {capabilityInfo.description}
- </p>
- <div className="mt-auto flex items-center justify-between gap-4 border-t px-5 py-3">
- <span className="text-xs text-gray-11">
- {isEmbeddings
- ? inUse
- ? t('Knowledge bases can index files')
- : t("Knowledge bases can't index files yet")
- : inUse
- ? t('Available to the assistant')
- : t("The assistant can't do this yet")}
- </span>
- {needsProviderKey ? (
- <Button asChild variant="outline" size="sm">
- <Link to="/platform/ai">{t('Add a provider key')}</Link>
- </Button>
+ <div className="mt-auto flex min-h-11 min-w-0 items-center gap-2 border-t px-5 py-2.5 text-xs text-gray-11">
+ {inUse ? (
+ <CapabilityInUse sourceName={sourceName} modelId={chosenModelId} />
) : (
- <AiCapabilityDialog
- capabilityInfo={capabilityInfo}
- existingConfig={config}
- defaultProviderId={chatProviderFallback?.id}
- onSaved={onSaved}
- >
- <Button
- variant="outline"
- size="sm"
- {...adminControl(AdminControl.AI_CAPABILITY_OPEN)}
- >
- {inUse ? t('Change') : t('Connect')}
- </Button>
- </AiCapabilityDialog>
+ <CapabilityOptions
+ providers={capabilityInfo.providers}
+ servedByAiKeys={servedByAiKeys}
+ />
)}
</div>
</div>
);
}
-const CAPABILITY_ICON: Record<AiToolCapability, LucideIcon> = {
- [AiToolCapability.WEB_SEARCH]: Search,
- [AiToolCapability.WEB_SCRAPING]: Globe,
- [AiToolCapability.IMAGE_GENERATION]: Image,
- [AiToolCapability.EMBEDDINGS]: Database,
+function CapabilityInUse({
+ sourceName,
+ modelId,
+}: {
+ sourceName: string | undefined;
+ modelId: string | undefined;
+}) {
+ const label = t('Using {provider}', { provider: sourceName });
+ return (
+ <>
+ <span
+ aria-hidden
+ className="size-1.5 shrink-0 rounded-full bg-success-10"
+ />
+ <TextWithTooltip tooltipMessage={label}>
+ <span className="truncate font-medium text-gray-12">{label}</span>
+ </TextWithTooltip>
+ {modelId && (
+ <>
+ <span aria-hidden>·</span>
+ <TextWithTooltip tooltipMessage={modelId}>
+ <span className="truncate">{modelId}</span>
+ </TextWithTooltip>
+ </>
+ )}
+ </>
+ );
+}
+
+function CapabilityOptions({
+ providers,
+ servedByAiKeys,
+}: {
+ providers: AiToolProviderInfo[];
+ servedByAiKeys: boolean;
+}) {
+ return (
+ <span className="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1">
+ <span>{t('Works with')}</span>
+ {providers.map((provider, index) => (
+ <span key={provider.id} className="inline-flex items-center gap-1.5">
+ {index > 0 && <span>{t('or')}</span>}
+ <LogoPlate
+ src={provider.logoUrl}
+ alt={provider.name}
+ border
+ className="size-5 rounded-md"
+ innerClassName="p-0.5"
+ />
+ <span className="text-gray-12">
+ {t('{service} API key', { service: provider.name })}
+ </span>
+ </span>
+ ))}
+ {servedByAiKeys && (
+ <span className="text-gray-12">
+ {providers.length > 0
+ ? t('or an AI provider key')
+ : t('an AI provider key')}
+ </span>
+ )}
+ </span>
+ );
+}
+
+function capabilityGroups(): {
+ title: string;
+ capabilities: AiToolCapability[];
+}[] {
+ return [
+ {
+ title: t('Chat and agents'),
+ capabilities: [
+ AiToolCapability.WEB_SEARCH,
+ AiToolCapability.WEB_SCRAPING,
+ AiToolCapability.IMAGE_GENERATION,
+ ],
+ },
+ {
+ title: t('Knowledge bases'),
+ capabilities: [AiToolCapability.EMBEDDINGS],
+ },
+ ];
+}
+
+const CAPABILITY_LOOK: Record<
+ AiToolCapability,
+ { icon: LucideIcon; tile: string }
+> = {
+ [AiToolCapability.WEB_SEARCH]: {
+ icon: Search,
+ tile: 'bg-swatch-11-surface text-swatch-11-ink',
+ },
+ [AiToolCapability.WEB_SCRAPING]: {
+ icon: Globe,
+ tile: 'bg-swatch-8-surface text-swatch-8-ink',
+ },
+ [AiToolCapability.IMAGE_GENERATION]: {
+ icon: Image,
+ tile: 'bg-swatch-4-surface text-swatch-4-ink',
+ },
+ [AiToolCapability.EMBEDDINGS]: {
+ icon: Database,
+ tile: 'bg-swatch-5-surface text-swatch-5-ink',
+ },
};
diff --git a/packages/web/src/app/routes/platform/setup/ai/providers-tab/config-detail.tsx b/packages/web/src/app/routes/platform/setup/ai/providers-tab/config-detail.tsx
index f098d37e66c..7a665d98617 100644
--- a/packages/web/src/app/routes/platform/setup/ai/providers-tab/config-detail.tsx
+++ b/packages/web/src/app/routes/platform/setup/ai/providers-tab/config-detail.tsx
@@ -43,6 +43,11 @@ import {
SelectValue,
} from '@/components/ui/select';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from '@/components/ui/tooltip';
import { AiProviderInfo } from '@/features/agents';
import {
KeyScopeImpact,
@@ -71,6 +76,7 @@ export function ConfigDetail({
onSave,
onDelete,
onReplaceCredentials,
+ initialTab = 'models',
isRechecking,
onRecheck,
onBack,
@@ -82,6 +88,7 @@ export function ConfigDetail({
onSave: (request: UpdateAIProviderRequest) => Promise<{ error: unknown }>;
onDelete: () => Promise<unknown>;
onReplaceCredentials: () => void;
+ initialTab?: ConfigDetailTab;
isRechecking: boolean;
onRecheck: () => void;
onBack: () => void;
@@ -250,7 +257,7 @@ export function ConfigDetail({
</Button>
</AdminPageHeader>
- <Tabs defaultValue="models" className="flex flex-col gap-6">
+ <Tabs defaultValue={initialTab} className="flex flex-col gap-6">
<TabsList
variant="outline"
className="w-full justify-start border-b border-gray-6"
@@ -408,16 +415,28 @@ export function ConfigDetail({
title={t('Credentials')}
description={t('Stored securely')}
>
- <Button
- variant="outline"
- size="sm"
- onClick={onReplaceCredentials}
- {...adminControl(
- AdminControl.AI_PROVIDER_KEY_CREDENTIALS_OPEN,
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span tabIndex={dirty ? 0 : undefined}>
+ <Button
+ variant="outline"
+ size="sm"
+ disabled={dirty}
+ onClick={onReplaceCredentials}
+ {...adminControl(
+ AdminControl.AI_PROVIDER_KEY_CREDENTIALS_OPEN,
+ )}
+ >
+ {t('Replace')}
+ </Button>
+ </span>
+ </TooltipTrigger>
+ {dirty && (
+ <TooltipContent>
+ {t('Save or discard your changes first')}
+ </TooltipContent>
)}
- >
- {t('Replace')}
- </Button>
+ </Tooltip>
</SettingsRow>
</SettingsPanel>
</AdminSection>
@@ -616,3 +635,5 @@ type ConfigDraft = {
projectScope: AiProviderProjectScope;
projectIds: string[];
};
+
+export type ConfigDetailTab = 'models' | 'access' | 'settings';
diff --git a/packages/web/src/app/routes/platform/setup/ai/providers-tab/default-chat-model-card.tsx b/packages/web/src/app/routes/platform/setup/ai/providers-tab/default-chat-model-card.tsx
index 8c47ae48a05..25bda739128 100644
--- a/packages/web/src/app/routes/platform/setup/ai/providers-tab/default-chat-model-card.tsx
+++ b/packages/web/src/app/routes/platform/setup/ai/providers-tab/default-chat-model-card.tsx
@@ -79,6 +79,7 @@ export function DefaultChatModelCard({
variant="ghost"
size="xs"
className="text-warning-11"
+ disabled={isPending}
onClick={() => save(null)}
>
{t('Use default')}
diff --git a/packages/web/src/app/routes/platform/setup/ai/providers-tab/index.tsx b/packages/web/src/app/routes/platform/setup/ai/providers-tab/index.tsx
index b0b2af9b9ca..1b89f554236 100644
--- a/packages/web/src/app/routes/platform/setup/ai/providers-tab/index.tsx
+++ b/packages/web/src/app/routes/platform/setup/ai/providers-tab/index.tsx
@@ -33,8 +33,8 @@ import { DataFetchErrorState } from '@/components/custom/data-fetch-error-state'
import { ConfirmationDeleteDialog } from '@/components/custom/delete-dialog';
import { LogoPlate } from '@/components/custom/logo-plate';
import { TextWithTooltip } from '@/components/custom/text-with-tooltip';
-import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
import { Avatar, AvatarGroup, AvatarGroupCount } from '@/components/ui/avatar';
+import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { Skeleton } from '@/components/ui/skeleton';
import {
@@ -120,6 +120,16 @@ export function ProvidersTab() {
}
toast.error(label ?? t('Could not reach this provider'));
},
+ onError: (error) => {
+ const data = error.response?.data;
+ toast.error(
+ t(
+ data?.params?.message ??
+ data?.message ??
+ 'Could not check this key',
+ ),
+ );
+ },
});
const { mutateAsync: updateProvider, isPending: isSaving } =
aiProviderMutations.useUpdateAiProvider({
@@ -140,11 +150,13 @@ export function ProvidersTab() {
const openConfig = (id: string) => {
const next = new URLSearchParams(searchParams);
next.set('config', id);
+ next.delete(CONFIG_TAB_PARAM);
setSearchParams(next);
};
const closeConfig = () => {
const next = new URLSearchParams(searchParams);
next.delete('config');
+ next.delete(CONFIG_TAB_PARAM);
setSearchParams(next);
};
const openConnect = (provider?: AIProviderName) => {
@@ -169,6 +181,9 @@ export function ProvidersTab() {
openConfig(createdId);
return;
}
+ const next = new URLSearchParams(searchParams);
+ next.set(CONFIG_TAB_PARAM, 'settings');
+ setSearchParams(next, { replace: true });
setCredentialsVersion((version) => version + 1);
};
@@ -203,6 +218,11 @@ export function ProvidersTab() {
}
onDelete={() => deleteProvider(activeConfig.id)}
onReplaceCredentials={() => openReplaceCredentials(activeConfig)}
+ initialTab={
+ searchParams.get(CONFIG_TAB_PARAM) === 'settings'
+ ? 'settings'
+ : 'models'
+ }
isRechecking={isRechecking}
onRecheck={() => recheckProvider(activeConfig.id)}
onBack={closeConfig}
@@ -222,8 +242,20 @@ export function ProvidersTab() {
<>
<AdminPageHeader
title={t('Providers')}
+ badge={
+ locked && configs.length > 0 ? (
+ <Badge variant="secondary" className="gap-1 rounded-full px-2">
+ <Lock className="size-3" />
+ {t('Read-only')}
+ </Badge>
+ ) : undefined
+ }
description={
- configs.length === 0
+ locked && configs.length > 0
+ ? t(
+ "Your plan doesn't include your own AI keys. You can still delete them.",
+ )
+ : configs.length === 0
? t(
'Connect a provider to turn on chat, agents, and AI steps across your platform.',
)
@@ -231,7 +263,9 @@ export function ProvidersTab() {
}
resources={adminPageResources.aiProviders}
>
- {!locked && (
+ {locked ? (
+ configs.length > 0 && <UpgradeButton />
+ ) : (
<Button
onClick={() => openConnect()}
{...adminControl(AdminControl.AI_PROVIDER_KEY_OPEN)}
@@ -255,7 +289,6 @@ export function ProvidersTab() {
<EmptyProviders onConnect={openConnect} />
) : (
<>
- {locked && <LockedProvidersAlert />}
{connectedProviders.map((provider) => (
<ProviderGroup
key={provider}
@@ -300,36 +333,21 @@ export function ProvidersTab() {
return page;
}
-function LockedProvidersAlert() {
+function UpgradeButton() {
const upgradeClick = useUpgradeClick();
const { featureKey, tier } = PLATFORM_FEATURES.aiProviders;
-
return (
- <Alert variant="primary">
- <Lock />
- <AlertTitle>
- {t('Your plan does not include Bring your own AI keys')}
- </AlertTitle>
- <AlertDescription className="flex flex-col items-start gap-3">
- <p>
- {t(
- 'You can still delete the keys below. Upgrade your plan to add new keys or change existing ones.',
- )}
- </p>
- <Button
- size="sm"
- onClick={() =>
- upgradeClick({
- feature: featureKey,
- tier,
- surface: PlatformAdminSurface.SAMPLE,
- })
- }
- >
- {t('Upgrade to {tier}', { tier: TIER_LABELS[tier] })}
- </Button>
- </AlertDescription>
- </Alert>
+ <Button
+ onClick={() =>
+ upgradeClick({
+ feature: featureKey,
+ tier,
+ surface: PlatformAdminSurface.SAMPLE,
+ })
+ }
+ >
+ {t('Upgrade to {tier}', { tier: TIER_LABELS[tier] })}
+ </Button>
);
}
@@ -750,6 +768,8 @@ function providerInfoOf({
);
}
+const CONFIG_TAB_PARAM = 'tab';
+
const PROVIDER_FACES_SHOWN = 5;
const RECOMMENDED_PROVIDERS: AIProviderName[] = [
diff --git a/packages/web/src/features/platform-admin/hooks/ai-provider-hooks.ts b/packages/web/src/features/platform-admin/hooks/ai-provider-hooks.ts
index be4181ab6fe..5103390872d 100644
--- a/packages/web/src/features/platform-admin/hooks/ai-provider-hooks.ts
+++ b/packages/web/src/features/platform-admin/hooks/ai-provider-hooks.ts
@@ -50,12 +50,17 @@ export const aiProviderQueries = {
export const aiProviderMutations = {
useRecheckAiProvider: ({
onSuccess,
+ onError,
}: {
onSuccess: (result: { status: AiProviderKeyStatus }) => void;
+ onError: (
+ error: AxiosError<{ message?: string; params?: { message: string } }>,
+ ) => void;
}) => {
return useMutation({
mutationFn: (providerId: string) => aiProviderApi.recheck(providerId),
onSuccess,
+ onError,
});
},
useDeleteAiProvider: ({
diff --git a/packages/web/src/features/platform-admin/hooks/ai-tool-config-hooks.ts b/packages/web/src/features/platform-admin/hooks/ai-tool-config-hooks.ts
index d35c0f49a5f..8dfc44d8d4c 100644
--- a/packages/web/src/features/platform-admin/hooks/ai-tool-config-hooks.ts
+++ b/packages/web/src/features/platform-admin/hooks/ai-tool-config-hooks.ts
@@ -46,10 +46,11 @@ export const aiToolConfigMutations = {
onSuccess,
onError,
}),
- useDeleteAiToolConfig: ({ onSuccess }: { onSuccess: () => void }) =>
+ useDeleteAiToolConfig: ({ onSuccess, onError }: MutationOptions) =>
useMutation({
mutationFn: (id: string) => aiToolConfigApi.delete(id),
onSuccess,
+ onError,
}),
};
diff --git a/packages/web/src/features/platform-admin/hooks/platform-model-tier-hooks.ts b/packages/web/src/features/platform-admin/hooks/platform-model-tier-hooks.ts
index 7a8f768e7eb..df168c4d235 100644
--- a/packages/web/src/features/platform-admin/hooks/platform-model-tier-hooks.ts
+++ b/packages/web/src/features/platform-admin/hooks/platform-model-tier-hooks.ts
@@ -207,16 +207,19 @@ export const platformModelTierMutations = {
);
return { previous };
},
- onSuccess: (configuration) => {
+ onSuccess: (configuration, defaultChatModel) => {
queryClient.setQueryData(
platformConfigurationHooks.queryKey,
configuration,
);
queryClient.invalidateQueries({ queryKey: aiProviderKeys.configs });
queryClient.invalidateQueries({ queryKey: ['ai-model-options'] });
- toast.success(t('Default chat model updated'), {
- duration: TOAST_SUCCESS_MS,
- });
+ toast.success(
+ defaultChatModel === null
+ ? t('Default chat model cleared')
+ : t('Default chat model updated'),
+ { duration: TOAST_SUCCESS_MS },
+ );
},
onError: (error, _variables, context) => {
if (context?.previous !== undefined) {
diff --git a/packages/web/test/app/routes/platform/setup/ai/providers-tab-locked.test.tsx b/packages/web/test/app/routes/platform/setup/ai/providers-tab-locked.test.tsx
index a557d04b4d0..e920f57d3f5 100644
--- a/packages/web/test/app/routes/platform/setup/ai/providers-tab-locked.test.tsx
+++ b/packages/web/test/app/routes/platform/setup/ai/providers-tab-locked.test.tsx
@@ -133,13 +133,16 @@ beforeEach(() => {
});
describe('providers tab on a plan without aiProvidersEnabled', () => {
- it('lists existing keys with delete only and an upgrade note', () => {
+ it('lists existing keys with delete only and a read-only header', () => {
state.providers = [ANTHROPIC_KEY];
renderTab();
+ expect(screen.getByText('Read-only')).toBeDefined();
expect(
- screen.getByText('Your plan does not include Bring your own AI keys'),
+ screen.getByText(
+ "Your plan doesn't include your own AI keys. You can still delete them.",
+ ),
).toBeDefined();
expect(screen.getAllByText('Trial Anthropic key').length).toBeGreaterThan(
0,