Skip to content

Commit 3bbfa17

Browse files
committed
fix(web): preserve setup descriptions and stable download rows
1 parent fcee104 commit 3bbfa17

2 files changed

Lines changed: 106 additions & 83 deletions

File tree

‎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

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

Lines changed: 103 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
type ServerProvider,
1313
} from "@t3tools/contracts";
1414
import { useRef, useState } from "react";
15+
import { Trash2Icon } from "lucide-react";
1516

1617
import { writeTextToClipboard } from "../../hooks/useCopyToClipboard";
1718
import { ensureLocalApi } from "../../localApi";
@@ -20,6 +21,7 @@ import { serverEnvironment } from "../../state/server";
2021
import { useAtomCommand } from "../../state/use-atom-command";
2122
import { Button } from "../ui/button";
2223
import { Input } from "../ui/input";
24+
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
2325
import { SettingsRow } from "./settingsLayout";
2426

2527
interface ProviderSetupSectionProps {
@@ -69,16 +71,25 @@ export function readAntigravityAuthMethod(config: unknown): AntigravityAuthMetho
6971
/** Setup state belongs to the selected environment and is never saved in client settings. */
7072
export function ProviderSetupSection(props: ProviderSetupSectionProps) {
7173
return (
72-
<section aria-label="Antigravity setup" className="divide-y divide-border/50 text-xs">
74+
<section
75+
aria-label="Antigravity setup"
76+
className="@container/setup divide-y divide-border/50 text-xs"
77+
>
7378
<SettingsRow
79+
className="@max-lg/setup:[&>div:first-child]:flex @max-lg/setup:[&>div:first-child]:items-stretch @max-lg/setup:[&>div:first-child]:gap-3"
7480
title="Environment"
75-
description={props.environmentLabel}
81+
description="Device that runs this provider."
7682
control={
77-
!props.enabled && !props.readOnly ? (
78-
<Button size="sm" variant="outline" onClick={props.onEnable}>
79-
Enable Antigravity
80-
</Button>
81-
) : undefined
83+
<div className="flex min-w-0 flex-col gap-2 sm:items-end">
84+
<span className="text-muted-foreground [overflow-wrap:anywhere]">
85+
{props.environmentLabel}
86+
</span>
87+
{!props.enabled && !props.readOnly ? (
88+
<Button size="sm" variant="outline" onClick={props.onEnable}>
89+
Enable Antigravity
90+
</Button>
91+
) : null}
92+
</div>
8293
}
8394
/>
8495
{props.readOnly ? (
@@ -184,7 +195,9 @@ function ProviderSetupActions({
184195
? enabled
185196
? "The configured Antigravity runtime is unavailable."
186197
: "The configured Antigravity runtime has not been checked."
187-
: "Not installed.";
198+
: installation?.totalBytes
199+
? `${Math.ceil(installation.totalBytes / 1_000_000)} MB download.`
200+
: "Not installed.";
188201

189202
async function runCommand<A, E>(
190203
label: string,
@@ -267,18 +280,15 @@ function ProviderSetupActions({
267280
<div className="divide-y divide-border/50">
268281
<SettingsRow
269282
title="Runtime"
283+
className="@max-lg/setup:[&>div:first-child]:flex @max-lg/setup:[&>div:first-child]:items-stretch @max-lg/setup:[&>div:first-child]:gap-3"
284+
description="Install and manage Antigravity."
270285
status={
271286
<div className="space-y-2">
272287
{usesCustomBinary ? (
273288
<p className="text-muted-foreground">
274289
Uses the custom binary path below. Installation keeps that path.
275290
</p>
276291
) : null}
277-
{!installed && !usesCustomBinary && !installActive && installation?.totalBytes ? (
278-
<p className="text-muted-foreground">
279-
{Math.ceil(installation.totalBytes / 1_000_000)} MB download.
280-
</p>
281-
) : null}
282292
{!installed && !provider.setup?.canInstall ? (
283293
<p className="text-muted-foreground">
284294
Automatic installation unavailable. Set a binary path or use another environment.
@@ -287,77 +297,86 @@ function ProviderSetupActions({
287297
</div>
288298
}
289299
control={
290-
<div className="flex min-w-0 flex-col gap-2 sm:max-w-56 sm:items-end sm:text-right xl:max-w-72">
291-
<p
292-
role="status"
293-
className={
294-
!installed && !usesCustomBinary && !installActive
295-
? "sr-only"
296-
: "text-muted-foreground"
297-
}
298-
>
300+
<div className="flex w-full min-w-0 flex-col gap-2 sm:w-56 sm:text-right">
301+
<p role="status" className="min-h-4 text-muted-foreground tabular-nums">
299302
{installationStatusMessage}
300303
</p>
301-
{installation?.phase === "downloading" &&
302-
installation.totalBytes !== null &&
303-
installation.totalBytes > 0 ? (
304-
<progress
305-
aria-label="Antigravity download"
306-
className="h-1 w-full accent-foreground"
307-
value={installation.downloadedBytes}
308-
max={installation.totalBytes}
309-
/>
310-
) : null}
311-
{installation?.message && installation.message !== installationStatusMessage ? (
304+
<div className="h-1">
305+
{installation?.phase === "downloading" &&
306+
installation.totalBytes !== null &&
307+
installation.totalBytes > 0 ? (
308+
<progress
309+
aria-label="Antigravity download"
310+
className="block h-1 w-full accent-foreground"
311+
value={installation.downloadedBytes}
312+
max={installation.totalBytes}
313+
/>
314+
) : null}
315+
</div>
316+
{!installActive &&
317+
installation?.message &&
318+
installation.message !== installationStatusMessage ? (
312319
<p className="text-muted-foreground [overflow-wrap:anywhere]">
313320
{installation.message}
314321
</p>
315322
) : null}
316-
<div className="flex flex-wrap gap-2 sm:justify-end">
317-
{installActive && installation.operationId ? (
318-
<Button
319-
size="sm"
320-
variant="outline"
321-
disabled={actionsDisabled}
322-
onClick={() => {
323-
const operationId = installation.operationId;
324-
if (!operationId) return;
325-
void runCommand("Cancelling installation", () =>
326-
cancelInstall({ environmentId, input: { instanceId, operationId } }),
327-
);
328-
}}
329-
>
330-
Cancel installation
331-
</Button>
332-
) : !installActive && provider.setup?.canInstall ? (
333-
<Button
334-
size="sm"
335-
variant="outline"
336-
disabled={actionsDisabled || installation === null || authActive}
337-
onClick={() =>
338-
void runCommand("Starting installation", () => startInstall(target))
339-
}
340-
>
341-
{installation?.installedVersion
342-
? installation.version && installation.version !== installation.installedVersion
343-
? "Update Antigravity"
344-
: "Reinstall Antigravity"
345-
: installation?.phase === "failed" || installation?.phase === "cancelled"
346-
? "Retry installation"
347-
: installed
348-
? "Install managed runtime"
349-
: "Install Antigravity"}
350-
</Button>
351-
) : null}
323+
<div className="grid min-h-7 grid-cols-[1.75rem_minmax(0,1fr)] gap-2">
324+
<div className="col-start-2 row-start-1 grid">
325+
{installActive && installation.operationId ? (
326+
<Button
327+
size="sm"
328+
variant="outline"
329+
disabled={actionsDisabled}
330+
onClick={() => {
331+
const operationId = installation.operationId;
332+
if (!operationId) return;
333+
void runCommand("Cancelling installation", () =>
334+
cancelInstall({ environmentId, input: { instanceId, operationId } }),
335+
);
336+
}}
337+
>
338+
Cancel installation
339+
</Button>
340+
) : !installActive && provider.setup?.canInstall ? (
341+
<Button
342+
size="sm"
343+
variant="outline"
344+
disabled={actionsDisabled || installation === null || authActive}
345+
onClick={() =>
346+
void runCommand("Starting installation", () => startInstall(target))
347+
}
348+
>
349+
{installation?.installedVersion
350+
? installation.version &&
351+
installation.version !== installation.installedVersion
352+
? "Update Antigravity"
353+
: "Reinstall Antigravity"
354+
: installation?.phase === "failed" || installation?.phase === "cancelled"
355+
? "Retry installation"
356+
: installed
357+
? "Install managed runtime"
358+
: "Install Antigravity"}
359+
</Button>
360+
) : null}
361+
</div>
352362
{installation?.canRemove && !installActive ? (
353-
<Button
354-
size="sm"
355-
variant="ghost"
356-
disabled={actionsDisabled || authActive}
357-
onClick={() => void removeRuntime()}
358-
>
359-
Remove downloaded runtime
360-
</Button>
363+
<Tooltip>
364+
<TooltipTrigger
365+
render={
366+
<Button
367+
size="icon-sm"
368+
variant="ghost"
369+
className="col-start-1 row-start-1"
370+
aria-label="Remove downloaded runtime"
371+
disabled={actionsDisabled || authActive}
372+
onClick={() => void removeRuntime()}
373+
/>
374+
}
375+
>
376+
<Trash2Icon className="size-3.5" />
377+
</TooltipTrigger>
378+
<TooltipPopup>Remove downloaded runtime</TooltipPopup>
379+
</Tooltip>
361380
) : null}
362381
</div>
363382
</div>
@@ -366,6 +385,10 @@ function ProviderSetupActions({
366385

367386
<SettingsRow
368387
title={methodLabel}
388+
className="@max-lg/setup:[&>div:first-child]:flex @max-lg/setup:[&>div:first-child]:items-stretch @max-lg/setup:[&>div:first-child]:gap-3"
389+
description={
390+
usesBrowser ? "Connect your Google account." : "Connect with the credentials below."
391+
}
369392
control={
370393
<div className="flex min-w-0 flex-col gap-2 sm:max-w-56 sm:items-end sm:text-right xl:max-w-72">
371394
<p
@@ -494,11 +517,9 @@ function ProviderSetupActions({
494517
) : null}
495518
</SettingsRow>
496519

497-
{pendingLabel ? (
498-
<p className="px-3 py-3 sm:px-4" role="status">
499-
{pendingLabel}.
500-
</p>
501-
) : null}
520+
<p className="sr-only" role="status">
521+
{pendingLabel ? `${pendingLabel}.` : null}
522+
</p>
502523
{error || queryError ? (
503524
<div className="grid gap-2 px-3 py-3 sm:px-4">
504525
<p role="alert" className="text-destructive [overflow-wrap:anywhere]">

0 commit comments

Comments
 (0)