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 name in add provider dialog

Steven Enamakelb76f719f5d37
diff --git a/app/src/components/settings/panels/ai/AddProviderDialog.tsx b/app/src/components/settings/panels/ai/AddProviderDialog.tsx
index f986423caa..0fa53efc41 100644
--- a/app/src/components/settings/panels/ai/AddProviderDialog.tsx
+++ b/app/src/components/settings/panels/ai/AddProviderDialog.tsx
@@ -1,19 +1,24 @@
/*
- * "Add a provider" — a modal listing every provider that is NOT yet connected,
- * grouped by kind.
+ * "Add a provider" — a modal holding one scrollable, grouped select box of
+ * every provider that is NOT yet connected.
*
- * 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.
+ * WHY A MODAL AND NOT 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.
*
- * 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.
+ * WHY ONE SCROLLING BOX AND NOT FOUR STACKED SECTIONS. Sections that each grow
+ * to fit push the dialog past the viewport and hand the scroll to the page
+ * behind it, so the group you were reading can leave the screen while its
+ * heading stays. A single bounded listbox scrolls its own content, and the
+ * group headings stick to the top edge while their own group is in view, so
+ * "which category am I in" survives the scroll.
+ *
+ * THE OPTIONS ARE `<button>`s IN A `<ul>`, NOT `role="listbox"`. This picks an
+ * action and closes: the chosen provider hands off to its connect flow and
+ * nothing stays selected. A real listbox would promise a selected value that
+ * this component never holds, and would need roving focus to deliver what tab
+ * order already gives us here.
*/
import { LuChevronRight } from 'react-icons/lu';
@@ -32,6 +37,8 @@ export interface ProviderOption {
}
export interface ProviderOptionGroup {
+ /** Stable id, used for the React key so two groups may share a title. */
+ id: string;
/** Already-translated heading. */
title: string;
options: ProviderOption[];
@@ -50,8 +57,9 @@ const ProviderOptionRow = ({
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'
+ 'flex w-full items-center gap-3 px-3 py-2 text-left transition-colors',
+ 'hover:bg-surface-hover focus:outline-none focus-visible:bg-surface-hover',
+ 'focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary-500/40'
)}>
<span
aria-hidden
@@ -78,7 +86,7 @@ export const AddProviderDialog = ({
onClose,
}: {
groups: ProviderOptionGroup[];
- /** Called with the chosen slug. The caller closes this dialog and opens the
+ /** Called with the chosen slug. The caller closes this dialog and starts the
* provider's own connect flow. */
onPick: (slug: string) => void;
onClose: () => void;
@@ -98,13 +106,17 @@ export const AddProviderDialog = ({
{t('settings.ai.providers.allConnected')}
</p>
) : (
- <div className="flex flex-col gap-4">
+ /* The box owns the scroll. `overscroll-contain` stops a flick at the
+ end of the list from continuing into the page behind the modal. */
+ <div
+ data-testid="add-provider-list"
+ className="max-h-[22rem] w-full overflow-y-auto overscroll-contain rounded-xl border border-line bg-surface-subtle">
{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">
+ <section key={group.id}>
+ <h3 className="sticky top-0 z-10 border-b border-line-subtle bg-surface-subtle/95 px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wide text-content-faint backdrop-blur">
{group.title}
</h3>
- <ul className="flex flex-col">
+ <ul className="flex flex-col divide-y divide-line-subtle bg-surface">
{group.options.map(option => (
<ProviderOptionRow key={option.slug} option={option} onPick={onPick} />
))}