Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion apps/web/src/components/settings/ProviderSetupSection.test.tsx
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
import type { FunctionComponent, ReactElement } from "react";
import { isValidElement, type FunctionComponent, type ReactElement } from "react";
import {
EnvironmentId,
ProviderDriverKind,
Expand DownExpand Up@@ -142,6 +142,23 @@ function button(view: unknown, label: string) {
);
}

function countElements(
node: unknown,
predicate: (element: ReactElement<Record<string, unknown>>) => boolean,
): number {
if (Array.isArray(node)) {
return node.reduce((total, child) => total + countElements(child, predicate), 0);
}
if (!isValidElement<Record<string, unknown>>(node)) return 0;
return (
Number(predicate(node)) +
Object.values(node.props).reduce<number>(
(total, value) => total + countElements(value, predicate),
0,
)
);
}

function click(view: unknown, label: string) {
const target = button(view, label);
if (!target) throw new Error(`Missing button: ${label}`);
Expand DownExpand Up@@ -285,6 +302,23 @@ describe("Antigravity setup", () => {
await flushPromises();
});

it("shows a repeated runtime status message only once", () => {
setup.installation = {
...setup.installation!,
operationId: "install-1",
phase: "verifying",
message: "Checking the downloaded runtime.",
};

const view = renderSetup();
expect(
countElements(
view,
(element) => element.props.children === "Checking the downloaded runtime.",
),
).toBe(1);
});

it("removes an owned damaged runtime only after confirmation", async () => {
setup.auth = authState({ phase: "idle", flowId: null, authorizationUrl: null });
setup.installation = {
Expand Down
30 changes: 16 additions & 14 deletions apps/web/src/components/settings/ProviderSetupSection.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -169,6 +169,20 @@ function ProviderSetupActions({
const authorizationUrl = auth?.phase === "waiting" ? auth.authorizationUrl : null;
const queryError = authQuery.error ?? installQuery.error;
const actionsDisabled = pendingLabel !== null || queryError !== null;
const installationStatusMessage =
installation?.phase === "downloading"
? `Downloading ${(installation.downloadedBytes / 1_000_000).toFixed(1)} MB${installation.totalBytes === null ? "" : ` of ${(installation.totalBytes / 1_000_000).toFixed(1)} MB`}.`
: installation?.phase === "extracting"
? "Extracting Antigravity."
: installation?.phase === "verifying"
? "Checking the downloaded runtime."
: installed
? "Antigravity is installed."
: usesCustomBinary
? enabled
? "The configured Antigravity runtime is unavailable."
: "The configured Antigravity runtime has not been checked."
: "Install the official Antigravity runtime before signing in.";

async function runCommand<A, E>(
label: string,
Expand DownExpand Up@@ -252,19 +266,7 @@ function ProviderSetupActions({
<div className="grid gap-2">
<p className="font-medium">Runtime</p>
<p role="status" className="text-muted-foreground">
{installation?.phase === "downloading"
? `Downloading ${(installation.downloadedBytes / 1_000_000).toFixed(1)} MB${installation.totalBytes === null ? "" : ` of ${(installation.totalBytes / 1_000_000).toFixed(1)} MB`}.`
: installation?.phase === "extracting"
? "Extracting Antigravity."
: installation?.phase === "verifying"
? "Checking the downloaded runtime."
: installed
? "Antigravity is installed."
: usesCustomBinary
? enabled
? "The configured Antigravity runtime is unavailable."
: "The configured Antigravity runtime has not been checked."
: "Install the official Antigravity runtime before signing in."}
{installationStatusMessage}
</p>
{installation?.phase === "downloading" &&
installation.totalBytes !== null &&
Expand All@@ -276,7 +278,7 @@ function ProviderSetupActions({
max={installation.totalBytes}
/>
) : null}
{installation?.message ? (
{installation?.message && installation.message !== installationStatusMessage ? (
<p className="text-muted-foreground [overflow-wrap:anywhere]">{installation.message}</p>
) : null}
{usesCustomBinary ? (
Expand Down
Loading