Skip to content

Commit 741610f

Browse files
wesbillmanBrain
andauthored
fix(desktop): onboarding defaults — API key field and model search (#2081)
Signed-off-by: Wes <[email protected]> Co-authored-by: Brain <21994759fc7a6fa6b965551d35cfd7897d262f2495467f2d78694ddcfa6a5c7e@sprout-oss.stage.blox.sqprod.co>
1 parent 463db6d commit 741610f

3 files changed

Lines changed: 90 additions & 33 deletions

File tree

‎desktop/src/features/agents/ui/GlobalAgentConfigFields.tsx‎

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import {
2424
AUTO_PROVIDER_DROPDOWN_VALUE,
2525
BLOCK_BUILD_HIDDEN_PROVIDER_IDS,
2626
CUSTOM_PROVIDER_DROPDOWN_VALUE,
27-
PERSONA_LLM_PROVIDER_OPTIONS,
2827
getPersonaProviderOptions,
2928
getProviderApiKeyEnvVar,
3029
requiredCredentialEnvKeys,
@@ -76,7 +75,6 @@ export type GlobalAgentConfigFieldsProps = {
7675
disableModelSelectDuringDiscovery?: boolean;
7776
effortPlaceholderLabel?: string;
7877
effortLabel?: string;
79-
hideUnconfiguredCredentialProviders?: boolean;
8078
keepSelectedModelValueLabel?: boolean;
8179
modelPlaceholderLabel?: string;
8280
placeholderClassName?: string;
@@ -112,7 +110,6 @@ export function GlobalAgentConfigFields({
112110
disableModelSelectDuringDiscovery = true,
113111
effortPlaceholderLabel,
114112
effortLabel = "Thinking/effort",
115-
hideUnconfiguredCredentialProviders = false,
116113
keepSelectedModelValueLabel = false,
117114
modelPlaceholderLabel = "Select model",
118115
placeholderClassName,
@@ -191,13 +188,6 @@ export function GlobalAgentConfigFields({
191188
() => bakedEnv.map((entry) => entry.key),
192189
[bakedEnv],
193190
);
194-
const configuredCredentialKeys = React.useMemo(() => {
195-
const keys = new Set(bakedEnvKeys);
196-
for (const [key, value] of Object.entries(config.env_vars)) {
197-
if (value.trim().length > 0) keys.add(key);
198-
}
199-
return keys;
200-
}, [bakedEnvKeys, config.env_vars]);
201191
const apiKeyInherited =
202192
apiKeyEnvVar !== null &&
203193
apiKeyValue.length === 0 &&
@@ -355,28 +345,11 @@ export function GlobalAgentConfigFields({
355345
hidden.add(providerId);
356346
}
357347
}
358-
if (hideUnconfiguredCredentialProviders) {
359-
for (const option of PERSONA_LLM_PROVIDER_OPTIONS) {
360-
const requiredKeys = requiredCredentialEnvKeys(
361-
credentialRuntimeId,
362-
option.id,
363-
);
364-
if (requiredKeys.some((key) => !configuredCredentialKeys.has(key))) {
365-
hidden.add(option.id);
366-
}
367-
}
368-
}
369348
if (selectedRuntimeId !== "buzz-agent") {
370349
hidden.add("relay-mesh");
371350
}
372351
return hidden;
373-
}, [
374-
bakedEnvKeys,
375-
configuredCredentialKeys,
376-
credentialRuntimeId,
377-
hideUnconfiguredCredentialProviders,
378-
selectedRuntimeId,
379-
]);
352+
}, [bakedEnvKeys, selectedRuntimeId]);
380353
const providerOptions = getPersonaProviderOptions(
381354
providerValue,
382355
credentialRuntimeId,
@@ -510,7 +483,7 @@ export function GlobalAgentConfigFields({
510483
</div>
511484
) : null}
512485

513-
{showAdvancedFields && providerFieldVisible && apiKeyEnvVar ? (
486+
{providerFieldVisible && apiKeyEnvVar ? (
514487
<div className={blockClassName}>
515488
<PersonaProviderApiKeyField
516489
disabled={false}

‎desktop/src/features/agents/ui/personaProviderModelFields.tsx‎

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* instead of duplicating the picker logic.
66
*/
77
import * as React from "react";
8-
import { Check, ChevronDown } from "lucide-react";
8+
import { Check, ChevronDown, Search } from "lucide-react";
99

1010
import type { AcpRuntimeCatalogEntry } from "@/shared/api/types";
1111
import { cn } from "@/shared/lib/cn";
@@ -47,6 +47,7 @@ export function AgentDropdownSelect({
4747
placeholder = "Select",
4848
placeholderClassName,
4949
placeholderValue,
50+
searchable = false,
5051
selectedLabel,
5152
testId,
5253
value,
@@ -60,20 +61,39 @@ export function AgentDropdownSelect({
6061
placeholder?: string;
6162
placeholderClassName?: string;
6263
placeholderValue?: string;
64+
/** Show a filter input above the options when the list is long. */
65+
searchable?: boolean;
6366
selectedLabel?: React.ReactNode;
6467
testId?: string;
6568
value: string;
6669
}) {
6770
const [open, setOpen] = React.useState(false);
71+
const [query, setQuery] = React.useState("");
6872
const selectedOption = options.find((option) => option.value === value);
6973
const isPlaceholderSelection =
7074
selectedLabel === undefined &&
7175
(selectedOption === undefined ||
7276
(placeholderValue !== undefined &&
7377
selectedOption.value === placeholderValue));
7478

79+
const showSearch = searchable && options.length > 1;
80+
const filteredOptions = React.useMemo(() => {
81+
const trimmed = query.trim().toLowerCase();
82+
if (!showSearch || trimmed === "") return options;
83+
return options.filter((option) =>
84+
(typeof option.label === "string" ? option.label : option.value)
85+
.toLowerCase()
86+
.includes(trimmed),
87+
);
88+
}, [options, query, showSearch]);
89+
90+
function handleOpenChange(next: boolean) {
91+
setOpen(next);
92+
if (!next) setQuery("");
93+
}
94+
7595
return (
76-
<Popover open={open} onOpenChange={setOpen}>
96+
<Popover open={open} onOpenChange={handleOpenChange}>
7797
<PopoverTrigger asChild>
7898
<button
7999
aria-controls={`${id}-listbox`}
@@ -125,7 +145,27 @@ export function AgentDropdownSelect({
125145
id={`${id}-listbox`}
126146
role="listbox"
127147
>
128-
{options.map((option) => {
148+
{showSearch ? (
149+
<div className="relative">
150+
<Search
151+
aria-hidden="true"
152+
className="pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground/45"
153+
/>
154+
<Input
155+
aria-label="Search models"
156+
autoFocus
157+
className="h-9 rounded-xl border-foreground/10 bg-white pl-9 text-sm"
158+
data-testid={testId ? `${testId}-search` : undefined}
159+
onChange={(event) => setQuery(event.target.value)}
160+
placeholder="Search models…"
161+
value={query}
162+
/>
163+
</div>
164+
) : null}
165+
{showSearch && filteredOptions.length === 0 ? (
166+
<p className="px-3 py-2 text-sm text-foreground/55">No matches</p>
167+
) : null}
168+
{filteredOptions.map((option) => {
129169
const selected = option.value === value;
130170
return (
131171
<button
@@ -373,6 +413,7 @@ export function AgentModelField({
373413
options={modelOptions}
374414
placeholder={placeholder}
375415
placeholderClassName={placeholderClassName}
416+
searchable
376417
selectedLabel={stableSelectedModelLabel}
377418
testId={testId ?? id}
378419
value={modelSelectValue}

‎desktop/tests/e2e/onboarding-agent-defaults.spec.ts‎

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,49 @@ test("config page gates stale saved model and effort until provider selection",
804804
await expect(effortSelect).toHaveText("Select effort level");
805805
});
806806

807+
test("config page model dropdown filters options via search", async ({
808+
page,
809+
}) => {
810+
await installMockBridge(
811+
page,
812+
{
813+
globalAgentConfig: {
814+
env_vars: { OPENAI_COMPAT_API_KEY: "sk-test" },
815+
provider: "openai",
816+
model: null,
817+
},
818+
},
819+
{
820+
skipCommunitySeed: true,
821+
skipOnboardingSeed: true,
822+
},
823+
);
824+
await page.goto("/");
825+
826+
await navigateToConfigPage(page);
827+
828+
const modelSelect = page.getByTestId("global-agent-model");
829+
await expect(modelSelect).toBeEnabled();
830+
await modelSelect.click();
831+
const search = page.getByTestId("global-agent-model-search");
832+
await expect(search).toBeVisible();
833+
await expect(
834+
page.getByTestId("global-agent-model-option-gpt-5.5"),
835+
).toBeVisible();
836+
await search.fill("mini");
837+
await expect(
838+
page.getByTestId("global-agent-model-option-gpt-5.4-mini"),
839+
).toBeVisible();
840+
await expect(
841+
page.getByTestId("global-agent-model-option-gpt-5.5"),
842+
).toHaveCount(0);
843+
await search.fill("zzz-no-such-model");
844+
await expect(page.getByText("No matches")).toBeVisible();
845+
await search.fill("");
846+
await page.getByTestId("global-agent-model-option-gpt-5.4-nano").click();
847+
await expect(modelSelect).toHaveAttribute("data-value", "gpt-5.4-nano");
848+
});
849+
807850
test("config page defaults model after provider selection", async ({
808851
page,
809852
}) => {
@@ -1077,7 +1120,7 @@ test("compact default config still persists rapid provider edits", async ({
10771120
await chooseConfigDropdownOption(page, "global-agent-provider", "anthropic");
10781121
await expect(providerSelect).toHaveAttribute("data-value", "anthropic");
10791122

1080-
await expect(page.getByLabel("Anthropic API Key")).toHaveCount(0);
1123+
await expect(page.getByLabel("Anthropic API Key")).toBeVisible();
10811124
await expect(page.getByLabel("OpenAI API Key")).toHaveCount(0);
10821125
await expect(page.getByLabel("Value for DATABRICKS_HOST")).toHaveCount(0);
10831126
});

0 commit comments

Comments
 (0)