Skip to content

Commit 4d16e6b

Browse files
authored
fix(web): align provider settings with shared settings rows (pingdotgg#10571)
1 parent 1f73a89 commit 4d16e6b

5 files changed

Lines changed: 386 additions & 327 deletions

File tree

‎apps/web/src/components/settings/ProviderInstanceCard.tsx‎

Lines changed: 94 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -252,93 +252,98 @@ function ProviderEnvironmentSection(props: {
252252
]);
253253

254254
return (
255-
<div className="mt-3 min-w-0 space-y-2">
256-
{rows.map((variable, index) => (
257-
<div key={variable.id} className="flex min-w-0 items-center gap-1.5">
258-
<DraftInput
259-
size="sm"
260-
className="w-44 shrink-0 font-mono"
261-
value={variable.name}
262-
onCommit={(name) => updateVariable(variable.id, { name: name.trim() })}
263-
placeholder="VARIABLE_NAME"
264-
spellCheck={false}
265-
aria-label={`Environment variable name ${index + 1}`}
266-
/>
267-
<span className="text-xs text-muted-foreground" aria-hidden>
268-
=
269-
</span>
270-
<DraftInput
271-
size="sm"
272-
className="min-w-0 flex-1 font-mono"
273-
value={variable.valueRedacted ? "" : variable.value}
274-
onCommit={(value) => updateVariable(variable.id, { value })}
275-
type={variable.sensitive ? "password" : undefined}
276-
autoComplete="off"
277-
placeholder={
278-
variable.valueRedacted ? "Stored secret, enter a new value to replace" : "value"
279-
}
280-
spellCheck={false}
281-
aria-label={`Environment variable value ${index + 1}`}
282-
/>
283-
<Tooltip>
284-
<TooltipTrigger
285-
render={
286-
<Button
287-
type="button"
288-
size="icon-micro"
289-
variant="ghost-muted"
290-
className={cn(
291-
"[--control-icon-color:currentColor]",
292-
variable.sensitive && "text-foreground",
293-
)}
294-
onClick={() => {
295-
const sensitive = !variable.sensitive;
296-
updateVariable(variable.id, {
297-
sensitive,
298-
...(sensitive && variable.valueRedacted === undefined
299-
? {}
300-
: { valueRedacted: sensitive ? variable.valueRedacted : false }),
301-
});
302-
}}
303-
aria-pressed={variable.sensitive}
304-
aria-label={`Mark environment variable ${variable.name || index + 1} as sensitive`}
305-
>
306-
{variable.sensitive ? (
307-
<LockIcon className="size-3" />
308-
) : (
309-
<LockOpenIcon className="size-3" />
310-
)}
311-
</Button>
312-
}
313-
/>
314-
<TooltipPopup side="top">
315-
{variable.sensitive ? "Sensitive, stored separately" : "Plain text"}
316-
</TooltipPopup>
317-
</Tooltip>
318-
<Button
319-
type="button"
320-
size="icon-micro"
321-
variant="ghost-muted"
322-
className="[--control-icon-color:currentColor] hover:text-destructive"
323-
onClick={() => removeVariable(variable.id)}
324-
aria-label={`Remove environment variable ${variable.name || index + 1}`}
325-
>
326-
<XIcon className="size-3" />
327-
</Button>
328-
</div>
329-
))}
330-
<div className="flex min-h-[1.875rem] flex-wrap items-center justify-end gap-x-3 gap-y-1">
331-
{rows.length > 0 ? (
332-
<span className="mr-auto text-xs text-muted-foreground">
333-
Sensitive values are stored separately and never returned to the app.
334-
</span>
335-
) : null}
336-
<Button type="button" size="xs" variant="ghost-muted" onClick={addVariable}>
255+
<SettingsRow
256+
title="Variables"
257+
description="API keys, base URLs, and other per-instance CLI settings."
258+
control={
259+
<Button type="button" size="sm" variant="outline" onClick={addVariable}>
337260
<PlusIcon className="size-3" />
338261
Add variable
339262
</Button>
340-
</div>
341-
</div>
263+
}
264+
>
265+
{rows.length > 0 ? (
266+
<div className="mt-3 min-w-0 space-y-2 pb-2">
267+
{rows.map((variable, index) => (
268+
<div key={variable.id} className="flex min-w-0 flex-wrap items-center gap-1.5">
269+
<DraftInput
270+
size="sm"
271+
className="w-full min-w-0 font-mono sm:w-44 sm:shrink-0"
272+
value={variable.name}
273+
onCommit={(name) => updateVariable(variable.id, { name: name.trim() })}
274+
placeholder="VARIABLE_NAME"
275+
spellCheck={false}
276+
aria-label={`Environment variable name ${index + 1}`}
277+
/>
278+
<span className="hidden text-xs text-muted-foreground sm:inline" aria-hidden>
279+
=
280+
</span>
281+
<DraftInput
282+
size="sm"
283+
className="min-w-0 flex-1 font-mono"
284+
value={variable.valueRedacted ? "" : variable.value}
285+
onCommit={(value) => updateVariable(variable.id, { value })}
286+
type={variable.sensitive ? "password" : undefined}
287+
autoComplete="off"
288+
placeholder={
289+
variable.valueRedacted ? "Stored secret, enter a new value to replace" : "value"
290+
}
291+
spellCheck={false}
292+
aria-label={`Environment variable value ${index + 1}`}
293+
/>
294+
<Tooltip>
295+
<TooltipTrigger
296+
render={
297+
<Button
298+
type="button"
299+
size="icon-micro"
300+
variant="ghost-muted"
301+
className={cn(
302+
"[--control-icon-color:currentColor]",
303+
variable.sensitive && "text-foreground",
304+
)}
305+
onClick={() => {
306+
const sensitive = !variable.sensitive;
307+
updateVariable(variable.id, {
308+
sensitive,
309+
...(sensitive && variable.valueRedacted === undefined
310+
? {}
311+
: { valueRedacted: sensitive ? variable.valueRedacted : false }),
312+
});
313+
}}
314+
aria-pressed={variable.sensitive}
315+
aria-label={`Mark environment variable ${variable.name || index + 1} as sensitive`}
316+
>
317+
{variable.sensitive ? (
318+
<LockIcon className="size-3" />
319+
) : (
320+
<LockOpenIcon className="size-3" />
321+
)}
322+
</Button>
323+
}
324+
/>
325+
<TooltipPopup side="top">
326+
{variable.sensitive ? "Sensitive, stored separately" : "Plain text"}
327+
</TooltipPopup>
328+
</Tooltip>
329+
<Button
330+
type="button"
331+
size="icon-micro"
332+
variant="ghost-muted"
333+
className="[--control-icon-color:currentColor] hover:text-destructive"
334+
onClick={() => removeVariable(variable.id)}
335+
aria-label={`Remove environment variable ${variable.name || index + 1}`}
336+
>
337+
<XIcon className="size-3" />
338+
</Button>
339+
</div>
340+
))}
341+
<p className="text-xs text-muted-foreground">
342+
Sensitive values are stored separately and never returned to the app.
343+
</p>
344+
</div>
345+
) : null}
346+
</SettingsRow>
342347
);
343348
}
344349

@@ -837,11 +842,7 @@ export function ProviderInstanceCard({
837842
/>
838843
</SettingsSection>
839844

840-
{setup ? (
841-
<SettingsSection title="Setup">
842-
<div className="px-3 py-3 sm:px-4">{setup}</div>
843-
</SettingsSection>
844-
) : null}
845+
{setup ? <SettingsSection title="Setup">{setup}</SettingsSection> : null}
845846

846847
<SettingsSection
847848
title="Runtime"
@@ -877,15 +878,10 @@ export function ProviderInstanceCard({
877878
aria-disabled={readOnly || undefined}
878879
className={readOnly ? "opacity-50 select-none" : undefined}
879880
>
880-
<SettingsRow
881-
title="Variables"
882-
description="API keys, base URLs, and other per-instance CLI settings."
883-
>
884-
<ProviderEnvironmentSection
885-
environment={instance.environment ?? []}
886-
onChange={updateEnvironment}
887-
/>
888-
</SettingsRow>
881+
<ProviderEnvironmentSection
882+
environment={instance.environment ?? []}
883+
onChange={updateEnvironment}
884+
/>
889885
</SettingsSection>
890886

891887
{driverOption !== undefined ? (

‎apps/web/src/components/settings/ProviderModelsSection.tsx‎

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ export function ProviderModelsSection({
514514
onChange={(event) => setFilter(event.target.value)}
515515
placeholder="Filter models"
516516
size="sm"
517-
className="w-56"
517+
className="w-56 max-w-full"
518518
spellCheck={false}
519519
aria-label="Filter models"
520520
/>
@@ -540,6 +540,18 @@ export function ProviderModelsSection({
540540
{hiddenCount > 0 ? ` · ${hiddenCount} hidden` : ""}
541541
</span>
542542
</div>
543+
{driverKind !== "antigravity" && !isAdding ? (
544+
<Button
545+
type="button"
546+
size="xs"
547+
variant="ghost-muted"
548+
className="ml-auto"
549+
onClick={() => setIsAdding(true)}
550+
>
551+
<PlusIcon className="size-3" />
552+
Add custom model
553+
</Button>
554+
) : null}
543555
</div>
544556
<div
545557
ref={listRef}
@@ -619,18 +631,7 @@ export function ProviderModelsSection({
619631
</Button>
620632
</div>
621633
</div>
622-
) : (
623-
<Button
624-
type="button"
625-
size="xs"
626-
variant="ghost-muted"
627-
className="mt-2 -ml-2"
628-
onClick={() => setIsAdding(true)}
629-
>
630-
<PlusIcon className="size-3" />
631-
Add custom model
632-
</Button>
633-
)}
634+
) : null}
634635

635636
{driverKind !== "antigravity" && error ? (
636637
<p className="mt-2 text-xs text-destructive">{error}</p>

‎apps/web/src/components/settings/ProviderSetupSection.test.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ function renderSetup(
138138
function button(view: unknown, label: string) {
139139
return visitElements(
140140
view,
141-
(element) => element.props.children === label && typeof element.props.onClick === "function",
141+
(element) =>
142+
(element.props.children === label || element.props["aria-label"] === label) &&
143+
typeof element.props.onClick === "function",
142144
);
143145
}
144146

0 commit comments

Comments
 (0)