The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(settings): handle missing provider in picker and dialog
Steven Enamakel6c6511e62c0a
diff --git a/app/src/components/settings/panels/ai/AddProviderDialog.tsx b/app/src/components/settings/panels/ai/AddProviderDialog.tsxnew file mode 100644index 0000000000..f986423caa--- /dev/null+++ b/app/src/components/settings/panels/ai/AddProviderDialog.tsx@@ -0,0 +1,120 @@+/*+ * "Add a provider" — a modal listing every provider that is NOT yet connected,+ * grouped by kind.+ *+ * WHY A MODAL AND NOT A SELECT OR AN INLINE LIST. There are ~15 providers and+ * a user connects one or two. Listing all fifteen inline spends the section on+ * the ones nobody chose and buries the ones actually configured, so the panel+ * lists only what is connected and this dialog owns the catalogue. A modal is+ * the right container for it over a dropdown because picking a provider is the+ * first step of a task, not the setting of a value: the choice immediately+ * hands off to that provider's connect dialog, and nothing here is left+ * "selected" afterwards. It also has room to say what each provider is, which+ * a select item does not.+ *+ * Rows are real `<button>`s inside a `<ul>`, so the whole row is the target and+ * keyboard order follows reading order without any roving-focus machinery.+ */+import { LuChevronRight } from 'react-icons/lu';++import { cn } from '../../../../lib/cn';+import { useT } from '../../../../lib/i18n/I18nContext';+import { ModalShell } from '../../../ui/ModalShell';++export interface ProviderOption {+ slug: string;+ label: string;+ tone: string;+ /** Second line: the endpoint host for a cloud provider, a short line about+ * where it runs for the others. Deliberately not a translated per-provider+ * blurb, which would be ~15 strings per locale to say what the host says. */+ detail: string;+}++export interface ProviderOptionGroup {+ /** Already-translated heading. */+ title: string;+ options: ProviderOption[];+}++const ProviderOptionRow = ({+ option,+ onPick,+}: {+ option: ProviderOption;+ onPick: (slug: string) => void;+}) => (+ <li>+ <button+ type="button"+ onClick={() => onPick(option.slug)}+ data-testid={`add-provider-option-${option.slug}`}+ className={cn(+ 'flex w-full items-center gap-3 rounded-lg px-2.5 py-2 text-left transition-colors',+ 'hover:bg-surface-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40'+ )}>+ <span+ aria-hidden+ className={cn(+ 'flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg text-xs font-semibold ring-1',+ option.tone+ )}>+ {option.label.trim().charAt(0).toUpperCase() || '?'}+ </span>+ <span className="flex min-w-0 flex-1 flex-col gap-0.5">+ <span className="truncate text-sm font-medium text-content">{option.label}</span>+ <span className="truncate font-mono text-[11px] leading-4 text-content-muted">+ {option.detail}+ </span>+ </span>+ <LuChevronRight aria-hidden className="h-4 w-4 flex-shrink-0 text-content-faint" />+ </button>+ </li>+);++export const AddProviderDialog = ({+ groups,+ onPick,+ onClose,+}: {+ groups: ProviderOptionGroup[];+ /** Called with the chosen slug. The caller closes this dialog and opens the+ * provider's own connect flow. */+ onPick: (slug: string) => void;+ onClose: () => void;+}) => {+ const { t } = useT();+ const populated = groups.filter(group => group.options.length > 0);++ return (+ <ModalShell+ title={t('settings.ai.providers.addProvider')}+ titleId="add-provider-dialog-title"+ subtitle={t('settings.ai.providers.addProviderSubtitle')}+ onClose={onClose}+ maxWidthClassName="max-w-lg">+ {populated.length === 0 ? (+ <p className="py-6 text-center text-sm text-content-muted" data-testid="add-provider-empty">+ {t('settings.ai.providers.allConnected')}+ </p>+ ) : (+ <div className="flex flex-col gap-4">+ {populated.map(group => (+ <section key={group.title} className="flex flex-col gap-1">+ <h3 className="px-2.5 text-[10px] font-semibold uppercase tracking-wide text-content-faint">+ {group.title}+ </h3>+ <ul className="flex flex-col">+ {group.options.map(option => (+ <ProviderOptionRow key={option.slug} option={option} onPick={onPick} />+ ))}+ </ul>+ </section>+ ))}+ </div>+ )}+ </ModalShell>+ );+};++export default AddProviderDialog;diff --git a/app/src/components/settings/panels/ai/ProviderPicker.tsx b/app/src/components/settings/panels/ai/ProviderPicker.tsxdeleted file mode 100644index 8ab2146706..0000000000--- a/app/src/components/settings/panels/ai/ProviderPicker.tsx+++ /dev/null@@ -1,113 +0,0 @@-/*- * "Add a provider" — a rich select over every provider that is NOT yet- * connected.- *- * WHY A SELECT AND NOT A LIST. There are ~15 providers and a user connects one- * or two. Rendering all fifteen as rows spends the whole section on the ones- * nobody chose, and buries the two that are actually configured. Inverting it- * puts the answer to "what am I using" at the top level and demotes "what- * could I use" to the moment the user asks for it.- *- * WHY Radix `Select` AND NOT `NativeSelect`. `Select`'s own doc note draws the- * line: `NativeSelect` for long or unbounded lists of plain text, `Select` for- * a short list (<= ~20) that needs custom item rendering. Fifteen items each- * carrying a swatch, a name and a second line is that case exactly; an- * `<option>` holds text and nothing else.- *- * IT PICKS AN ACTION, NOT A VALUE. `value` is pinned to `''` so the trigger- * always shows its placeholder: choosing an item opens that provider's connect- * dialog and the control returns to rest. A select that kept the last pick- * would be claiming a selection this component does not own — the connection- * state lives in `draft.cloudProviders`, and only the dialog can change it.- */-import { cn } from '../../../../lib/cn';-import { useT } from '../../../../lib/i18n/I18nContext';-import {- SelectContent,- SelectGroup,- SelectItem,- SelectLabel,- SelectRoot,- SelectTrigger,- SelectValue,-} from '../../../ui/Select';--export interface ProviderOption {- slug: string;- label: string;- tone: string;- /** Second line: the endpoint host for a cloud provider, a short line about- * where it runs for the others. Never a translated provider blurb — that- * would be ~15 strings per locale to say what the host already says. */- detail: string;-}--export interface ProviderOptionGroup {- /** Already-translated heading. */- title: string;- options: ProviderOption[];-}--export const ProviderPicker = ({- groups,- onPick,-}: {- groups: ProviderOptionGroup[];- onPick: (slug: string) => void;-}) => {- const { t } = useT();- const empty = groups.every(g => g.options.length === 0);-- if (empty) {- return (- <p className="text-xs text-content-muted" data-testid="provider-picker-empty">- {t('settings.ai.providers.allConnected')}- </p>- );- }-- return (- <SelectRoot value="" onValueChange={onPick}>- <SelectTrigger- inputSize="sm"- className="max-w-sm"- aria-label={t('settings.ai.providers.addProvider')}- data-testid="provider-picker">- <SelectValue placeholder={t('settings.ai.providers.addProviderPlaceholder')} />- </SelectTrigger>- {/* Wider than the trigger: the trigger is a compact control, the menu has- two lines per item to show. */}- <SelectContent className="w-[min(24rem,calc(100vw-2rem))]">- {groups- .filter(group => group.options.length > 0)- .map(group => (- <SelectGroup key={group.title}>- <SelectLabel>{group.title}</SelectLabel>- {group.options.map(option => (- <SelectItem key={option.slug} value={option.slug}>- <span className="flex min-w-0 items-center gap-2">- <span- aria-hidden- className={cn(- 'flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md text-[10px] font-semibold ring-1',- option.tone- )}>- {option.label.trim().charAt(0).toUpperCase() || '?'}- </span>- <span className="flex min-w-0 flex-col">- <span className="truncate text-sm text-content">{option.label}</span>- <span className="truncate font-mono text-[10px] leading-3 text-content-muted">- {option.detail}- </span>- </span>- </span>- </SelectItem>- ))}- </SelectGroup>- ))}- </SelectContent>- </SelectRoot>- );-};--export default ProviderPicker;