fix(web): avoid duplicate Antigravity install status (#9419)

This commit is contained in:
Rakshith Bhat authored and GitHub committed 2026-09-03 09:36:09 -07:00
1 parent cfddb4201d
commit 2120fbc185
2 files changed
+51 -15

No files matched your search

@@ -1,4 +1,4 @@
import type { FunctionComponent, ReactElement } from "react";
import { isValidElement, type FunctionComponent, type ReactElement } from "react";
import {
EnvironmentId,
ProviderDriverKind,
@@ -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}`);
@@ -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 = {
@@ -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,
@@ -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 &&
@@ -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 ? (