Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(ai): handle missing provider auth fields gracefully

Steven Enamakel530aa8bdd150
diff --git a/app/src/components/settings/panels/ai/ProviderAuthSection.tsx b/app/src/components/settings/panels/ai/ProviderAuthSection.tsx
index 6a31d08aa1..24a0e4d368 100644
--- a/app/src/components/settings/panels/ai/ProviderAuthSection.tsx
+++ b/app/src/components/settings/panels/ai/ProviderAuthSection.tsx
@@ -17,14 +17,14 @@
* whether connected or not.
*/
import { useState } from 'react';
-import { LuCircleAlert, LuPlus } from 'react-icons/lu';
+import { Plus } from 'lucide-react';
import { useT } from '../../../../lib/i18n/I18nContext';
import type { ProviderAuthError } from '../../../../services/api/aiSettingsApi';
-import Alert from '../../../ui/Alert';
+import Alert, { AlertDescription } from '../../../ui/Alert';
import Badge from '../../../ui/Badge';
import Button from '../../../ui/Button';
-import StatusLine from '../../../ui/StatusLine';
+import { CenteredLoadingState } from '../../../ui/LoadingState';
import Switch from '../../../ui/Switch';
import { routingWithProviderRemoved } from '../aiRouting';
import {
@@ -45,6 +45,7 @@ import {
providerToggleAriaLabel,
} from './aiPanelTypes';
import { ClaudeCodeConnect } from './ClaudeCodeStatusCard';
+import { ProviderCatalog } from './ProviderCatalog';
import { ProviderGroup, ProviderListRow, type ProviderRowAction } from './ProviderListRow';
const LOCAL_RUNTIME_SLUGS = ['lmstudio', 'ollama', 'omlx'] as const;
@@ -79,7 +80,7 @@ export const AddProviderButton = ({ onClick }: { onClick: () => void }) => {
type="button"
variant="primary"
size="sm"
- leadingIcon={<LuPlus className="h-3.5 w-3.5" />}
+ leadingIcon={<Plus className="h-3.5 w-3.5" aria-hidden />}
onClick={onClick}
data-testid="add-provider-open">
{t('settings.ai.providers.addProvider')}
@@ -234,41 +235,38 @@ export const ProviderAuthSection = ({
return (
<>
- <div className="flex w-full flex-col gap-4 py-4">
- <div className="flex w-full flex-col gap-4 px-4">
- {/* ─── Rejected-key notices ───────────────────────────────────────
- A BYO key the provider rejected at runtime (401/403). Surfaced
- here, next to the key editor, because the failing path is often a
- silent background loop and the raw error is demoted from Sentry. */}
- {providerAuthErrors.length > 0 && (
- <div className="flex w-full flex-col gap-2">
- {providerAuthErrors.map(err => (
- <ProviderSetupErrorNotice key={err.provider} error={err.message} />
- ))}
- </div>
- )}
+ <div className="flex w-full flex-col gap-4">
+ {/* ─── Notices ────────────────────────────────────────────────────
+ A BYO key the provider rejected at runtime (401/403) is surfaced
+ here, next to the key editor, because the failing path is often a
+ silent background loop and the raw error is demoted from Sentry. */}
+ {providerAuthErrors.map(err => (
+ <ProviderSetupErrorNotice key={err.provider} error={err.message} />
+ ))}
- {/* #5339: non-fatal "key saved, but provider unreachable" advisory.
- Amber (not coral): the save succeeded, only reachability is in
- question. */}
- {providerSaveNotice && (
- <Alert variant="warning" role="status" className="items-start gap-2 px-3 py-2 text-xs">
- <LuCircleAlert className="mt-0.5 h-3.5 w-3.5 shrink-0" />
- <span className="flex-1">{providerSaveNotice.message}</span>
- <Button
- type="button"
- variant="tertiary"
- size="xs"
- className="shrink-0 font-medium normal-case underline-offset-2 hover:underline"
- onClick={onDismissProviderSaveNotice}>
- {t('common.dismiss')}
- </Button>
- </Alert>
- )}
+ {/* #5339: non-fatal "key saved, but provider unreachable" advisory.
+ Amber (not coral): the save succeeded, only reachability is in
+ question. */}
+ {providerSaveNotice && (
+ <Alert variant="warning" density="compact" role="status" className="items-center">
+ <AlertDescription className="flex-1">{providerSaveNotice.message}</AlertDescription>
+ <Button
+ type="button"
+ variant="tertiary"
+ size="xs"
+ className="shrink-0"
+ onClick={onDismissProviderSaveNotice}>
+ {t('common.dismiss')}
+ </Button>
+ </Alert>
+ )}
- {loading && <div className="text-xs text-content-muted">{t('common.loading')}</div>}
- {error && <StatusLine saving={false} error={error} savedNote={null} savingLabel="" />}
- </div>
+ {error && (
+ <Alert variant="destructive" density="compact">
+ <AlertDescription>{error}</AlertDescription>
+ </Alert>
+ )}
+ {codexAuthError ? <ProviderSetupErrorNotice error={codexAuthError} /> : null}
{!hostControlsAdd && (
<div className="flex justify-end">
@@ -276,12 +274,15 @@ export const ProviderAuthSection = ({
</div>
)}
+ {loading && <CenteredLoadingState label={t('common.loading')} />}
+
{/* ─── Connected ────────────────────────────────────────────────────
Managed leads and is always present. #3760: it renders a badge, not a
disabled toggle — a locked switch reads as switchable-but-broken and
invites a fight the user cannot win. */}
<ProviderGroup
title={t('settings.ai.providers.groupConnected')}
+ description={t('settings.ai.providers.connectedDesc')}
card
data-testid="provider-group-connected">
<ProviderListRow
@@ -441,13 +442,12 @@ export const ProviderAuthSection = ({
</ProviderGroup>
)}
- <div className="flex flex-col gap-3 px-4">
- {codexAuthError ? <ProviderSetupErrorNotice error={codexAuthError} /> : null}
-
- {/* #3760: point users who want a local model at the Routing card
- below, rather than letting them hunt for a Managed off switch. */}
- <p className="text-xs text-content-muted">{t('settings.ai.routing.managedHint')}</p>
- </div>
+ {/* ─── Catalogue: everything not yet connected, as tiles ──────── */}
+ <ProviderCatalog
+ categories={providerCategories}
+ onPick={handlePick}
+ onAddCustom={onAddCustomProvider}
+ />
</div>
{addOpen && (
diff --git a/app/src/components/settings/panels/ai/ProviderCatalog.tsx b/app/src/components/settings/panels/ai/ProviderCatalog.tsx
index c9ab9a81de..461dce9e3e 100644
--- a/app/src/components/settings/panels/ai/ProviderCatalog.tsx
+++ b/app/src/components/settings/panels/ai/ProviderCatalog.tsx
@@ -66,7 +66,7 @@ export const ProviderCatalog = ({
</section>
))}
- <section className="p-4">
+ <section className="grid gap-2 p-4 sm:grid-cols-2 xl:grid-cols-3">
<button
type="button"
className={tileClass}