Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Antigravity: every Google account on one card, as Claude's and ChatGPT's are
laijsg1f924add903b4
diff --git a/server/antigravity-account-api.test.ts b/server/antigravity-account-api.test.tsindex cf5c8171f9..ff6dc1c85b 100644--- a/server/antigravity-account-api.test.ts+++ b/server/antigravity-account-api.test.ts@@ -113,6 +113,22 @@ it("adds independent accounts, switches a bot between their models, and preserveexpect(bots.body.bots.find((bot: any) => bot.id === created.body.bot.id).modelSelection).toMatchObject({ instanceId: ids[1], model: "gemini-fixture" });}, 40_000);+it("renames the original and an added Antigravity account", async () => {+ const created = await api("POST", "/api/instances/antigravity-accounts", { displayName: "Rename me", sourceInstanceId: "google-original" });+ expect(created.status, JSON.stringify(created.body)).toBe(201);+ const id = created.body.instanceId as string;+ for (const [target, name] of [[id, "Client work"], ["google-original", "Personal"]]) {+ const renamed = await api("PATCH", `/api/instances/${target}`, { displayName: name });+ expect(renamed.status, JSON.stringify(renamed.body)).toBe(200);+ expect(renamed.body.instances.find((row: { instanceId: string }) => row.instanceId === target).displayName).toBe(name);+ }+ expect((await api("PATCH", `/api/instances/${id}`, { configDir: "/elsewhere" })).status).toBe(400);+ const saved = JSON.parse(readFileSync(join(home, "config.json"), "utf8"));+ expect(saved.instances[id]).toMatchObject({ displayName: "Client work", config: { cli } });+ expect(saved.instances["google-original"].displayName).toBe("Personal");+ expect(saved.instances[id]).not.toHaveProperty("configDir");+});+it("removes an unused added account but never the original Antigravity account", async () => {const created = await api("POST", "/api/instances/antigravity-accounts", { displayName: "Remove me", sourceInstanceId: "google-original" });expect(created.status, JSON.stringify(created.body)).toBe(201);diff --git a/server/routes/instances.ts b/server/routes/instances.tsindex ab8a8054a0..6232fc87e0 100644--- a/server/routes/instances.ts+++ b/server/routes/instances.ts@@ -496,8 +496,8 @@ export function createInstanceRoutes(deps: InstanceRouteDeps): RouteHandler {const instances = persistableInstanceConfigs(result.config);if (!result.ok || !Object.hasOwn(instances, instanceId)) return json(res, 404, { error: `unknown instance "${instanceId}"` });const entry = instances[instanceId];- if ((body.configDir !== undefined && entry.driver !== "claudeAgent") || (body.displayName !== undefined && !["claudeAgent", "codex"].includes(entry.driver))) {- return json(res, 400, { error: "Account settings are available for Claude and ChatGPT accounts only." });+ if ((body.configDir !== undefined && entry.driver !== "claudeAgent") || (body.displayName !== undefined && !["claudeAgent", "codex", "antigravityAgent"].includes(entry.driver))) {+ return json(res, 400, { error: "Account settings are available for Claude, ChatGPT and Google Gemini (Antigravity) accounts only." });}if (body.hidden === true && providerInUse(instanceId)) {return json(res, 409, { error: "Choose another model for the bots and default model using this provider before hiding it." });diff --git a/src/components/EngineAccounts.tsx b/src/components/EngineAccounts.tsxindex e253887b42..ab596c78a8 100644--- a/src/components/EngineAccounts.tsx+++ b/src/components/EngineAccounts.tsx@@ -11,15 +11,18 @@ import { ClaudeSignIn } from "./ClaudeSignIn";import { DeviceSignIn, deviceSignInProvider } from "./DeviceSignIn";import { ChatGptPlanStatus } from "./ChatGptPlanStatus";import { EngineCard, engineReady, providerName, type EngineCardSummary } from "./EngineLibrary";-import { CommandRow, EngineSetup, EngineUpdateNotice, EngineWarningNotice } from "./EngineSetup";+import { AntigravitySignIn, CommandRow, EngineSetup, EngineUpdateNotice, EngineWarningNotice } from "./EngineSetup";+import { AntigravitySwitchCli } from "./AntigravitySwitchCli";+import { AntigravityFreeSpace } from "./AntigravityFreeSpace";import { MENU_SHEET } from "./menu-recipe";/** Providers whose accounts are listed together on one card, each signed in on its own. */-export type AccountGroup = "claude" | "chatgpt";+export type AccountGroup = "claude" | "chatgpt" | "antigravity";export function accountGroupOf(instance: InstanceInfo): AccountGroup | null {if (instance.readOnly || instance.trialCredit || instance.access === "custom" || instance.access === "api") return null;if (instance.driverKind === "claudeAgent") return "claude";+ if (instance.driverKind === "antigravityAgent") return "antigravity";const method = instance.authentication?.method;return instance.snapshot.chatgptPlan === true || ((method === "device-code" || method === "browser-pkce") && deviceSignInProvider(instance.driverKind) === "codex")? "chatgpt" : null;@@ -35,12 +38,17 @@ function accountState(instance: InstanceInfo): AccountState {const COPY: Record<AccountGroup, Record<"title" | "add" | "removeBody", LocaleKey>> = {claude: { title: "accounts.claude", add: "accounts.addClaude", removeBody: "accounts.removeBodyClaude" },chatgpt: { title: "accounts.chatgpt", add: "accounts.addChatgpt", removeBody: "accounts.removeBodyChatgpt" },+ antigravity: { title: "accounts.antigravity", add: "engineSetup.antigravity.addAccount", removeBody: "accounts.removeBodyAntigravity" },};+export function accountGroupTitle(group: AccountGroup): string {+ return t(COPY[group].title);+}+/** What an account's menu offers. Only accounts added here can be removed; each provider's first account stays, and* ChatGPT's built-in rows (Codex, ChatGPT plan) can be hidden instead. */export function accountActions(group: AccountGroup, instance: InstanceInfo): { signOut: boolean; remove: boolean; hide: boolean } {- const remove = group === "claude" ? instance.instanceId !== "claude" && instance.claudeAccount?.isDefault !== true : instance.instanceId.startsWith("chatgpt-");+ const remove = group === "claude" ? instance.instanceId !== "claude" && instance.claudeAccount?.isDefault !== true : instance.instanceId.startsWith(`${group}-`);return {signOut: accountState(instance) === "signedIn" && instance.authentication?.signOut === true && instance.snapshot.account?.method !== "api-key",remove,@@ -61,7 +69,7 @@ function summaryFor(group: AccountGroup, accounts: InstanceInfo[]): EngineCardSu? t("accounts.count", { count: String(accounts.length), signedIn: String(signedIn.length) }): signedIn[0]?.snapshot.account?.email ?? providerName(accounts[0]!);return {- title: t(COPY[group].title),+ title: accountGroupTitle(group),subtitle,ready,status: ready ? t("onboarding.engines.ready") : installed ? t("model.signInRequired") : t("onboarding.engines.needsSetup"),@@ -205,10 +213,16 @@ function AccountRow({ group, instance, several, signingIn, onSignIn, onSignInDon// This server cannot run the provider's sign-in (a remote browser for a local-only flow): say why, offer nothing.const blocked = instance.snapshot.authenticationUnavailableReason;const detail = blocked && state !== "signedIn" ? blocked : state === "signedIn"- ? account?.method === "api-key" ? t("accounts.apiKey") : [account?.email, account?.organization].filter(Boolean).join(" · ") || t("accounts.signedIn")+ ? account?.method === "api-key" ? t("accounts.apiKey") : [account?.email, account?.organization].filter(Boolean).join(" · ") || t(group === "antigravity" ? "engineSetup.antigravity.signedInGoogle" : "accounts.signedIn"): state === "signedOut" ? t("accounts.notSignedIn"): state === "unknown" ? t("accounts.unknown"): instance.snapshot.reason ?? t("onboarding.engines.needsSetup");+ // An Antigravity account runs on its own runtime, so one of them can need installing while the others work.+ const setsUp = group === "antigravity" && state === "unavailable";+ const signedIn = state === "signedIn";+ useEffect(() => {+ if (group === "antigravity" && signingIn && signedIn) onSignInDone();+ }, [group, signingIn, signedIn, onSignInDone]);return (<li data-account={instance.instanceId} data-account-state={state} className="px-3 py-2.5">@@ -233,7 +247,8 @@ function AccountRow({ group, instance, several, signingIn, onSignIn, onSignInDon</>)}</div>- {signingIn && (+ {setsUp && <div data-account-setup={instance.instanceId} className="pl-9"><EngineSetup instance={instance} unframed /></div>}+ {signingIn && !setsUp && (<div className="pl-9">{group === "claude"? <>@@ -245,6 +260,11 @@ function AccountRow({ group, instance, several, signingIn, onSignIn, onSignInDon</details>)}</>+ : group === "antigravity"+ ? <div data-account-sign-in={instance.instanceId}>+ <AntigravitySignIn instance={instance} />+ <button type="button" onClick={onSignInDone} className="mt-2 rounded-lg px-2.5 py-1.5 text-[12px] text-ink-secondary hover:bg-control">{t("common.cancel")}</button>+ </div>: <>{several && instance.authentication?.method === "device-code" && <p className="mt-2 text-[12px] leading-relaxed text-ink-secondary">{t("accounts.chatgptDeviceHint")}</p>}<DeviceSignIn instanceId={instance.instanceId} provider="codex" browserPkce={instance.authentication?.method === "browser-pkce"} autoStart onDone={onSignInDone} />@@ -254,6 +274,10 @@ function AccountRow({ group, instance, several, signingIn, onSignIn, onSignInDon{group === "chatgpt" && state === "signedIn" && instance.snapshot.chatgptPlan && (<div className="pl-9"><ChatGptPlanStatus instanceId={instance.instanceId} welcome={false} /></div>)}+ {group === "antigravity" && <div className="pl-9">+ <AntigravitySwitchCli instance={instance} />+ {instance.freeUpSpace && <AntigravityFreeSpace instance={instance} />}+ </div>}</li>);}@@ -329,9 +353,12 @@ export function AddAccount({ label, endpoint, extra, folder: offerFolder = false/** One card for a provider's accounts: who is signed in, one button for whoever is not, and one way to add another. */export function AccountsCard({ group, accounts, advanced, bare = false }: { group: AccountGroup; accounts: InstanceInfo[]; advanced?: ReactNode; bare?: boolean }) {- const [signingIn, setSigningIn] = useState<string | null>(null);+ const [signingIn, setSigningIn] = useState<readonly string[]>([]);+ // A Google sign-in waits for its own redirect, so another account's must not end it; the other providers show one.+ const startSignIn = (instanceId: string) => setSigningIn((current) => group === "antigravity" ? [...current.filter((id) => id !== instanceId), instanceId] : [instanceId]);+ const endSignIn = (instanceId: string) => setSigningIn((current) => current.includes(instanceId) ? current.filter((id) => id !== instanceId) : current);const primary = accounts[0]!;- const installed = accounts.some((instance) => instance.snapshot.state === "available");+ const listed = group === "antigravity" || accounts.some((instance) => instance.snapshot.state === "available");const policy = accounts.find((instance) => instance.policy)?.policy;// Only the browser sign-in can be refused by a ChatGPT organization; Codex's own device-code sign-in is not.const browserAccounts = group === "chatgpt" && accounts.some((instance) => instance.snapshot.chatgptPlan === true || instance.authentication?.method === "browser-pkce");@@ -341,19 +368,20 @@ export function AccountsCard({ group, accounts, advanced, bare = false }: { grou{policy && <p className="mb-3 text-[12px] leading-relaxed text-ink-secondary"><span className="font-medium text-ink">{t("policy.managedBy", { organization: policy.organizationName })}</span> · {policy.reason}</p>}- {!installed ? <EngineSetup instance={primary} unframed /> : (+ {!listed ? <EngineSetup instance={primary} unframed /> : (<div className="space-y-2"><ul data-accounts={group} className="divide-y divide-hairline/40 rounded-xl border border-hairline/50 bg-panel/40">{accounts.map((instance) => (<AccountRow key={instance.instanceId} group={group} instance={instance} several={accounts.length > 1}- signingIn={signingIn === instance.instanceId}- onSignIn={() => setSigningIn(instance.instanceId)}- onSignInDone={() => setSigningIn((current) => current === instance.instanceId ? null : current)} />+ signingIn={signingIn.includes(instance.instanceId)}+ onSignIn={() => startSignIn(instance.instanceId)}+ onSignInDone={() => endSignIn(instance.instanceId)} />))}</ul>{!primary.snapshot.authenticationUnavailableReason && <><AddAccount label={t(COPY[group].add)} endpoint={`/api/instances/${group}-accounts`} folder={group === "claude"}- describedBy={browserAccounts ? noteId : undefined} onAdded={setSigningIn} />+ extra={group === "antigravity" ? { sourceInstanceId: primary.instanceId } : undefined}+ describedBy={browserAccounts ? noteId : undefined} onAdded={startSignIn} />{browserAccounts && <p id={noteId} className="px-2 text-[12px] leading-relaxed text-ink-secondary">{t("accounts.addChatgptWorkspaceNote")}</p>}</>}{group === "chatgpt" && <p data-codex-shared-setup className="px-2 text-[12px] leading-relaxed text-ink-secondary">{t("accounts.chatgptSharedSetupNote")}</p>}diff --git a/src/components/EngineSetup.tsx b/src/components/EngineSetup.tsxindex 23dd0874a4..6052220bff 100644--- a/src/components/EngineSetup.tsx+++ b/src/components/EngineSetup.tsx@@ -1,4 +1,4 @@-import { useEffect, useState } from "react";+import { useEffect, useRef, useState } from "react";import { AlertTriangle, Check, Copy, Download, ExternalLink, KeyRound, Loader2, LogIn, TerminalSquare, X } from "lucide-react";import { api, ApiError, type InstanceInfo, useStore } from "@/state/store";import { cn } from "@/lib/cn";@@ -285,7 +285,12 @@ function installsAntigravityCli(instance: InstanceInfo): boolean {return instance.driverKind === "antigravityAgent" && !/^agy_acp_server$/iu.test(instance.cli?.trim() ?? "");}-function ManagedEngineSetup({ instance, signInOnly }: { instance: InstanceInfo; signInOnly: boolean }) {+/** A Google sign-in for one Antigravity account, also when its last check could not tell whether it is signed in. */+export function AntigravitySignIn({ instance }: { instance: InstanceInfo }) {+ return instance.install?.managed ? <ManagedEngineSetup instance={instance} signInOnly autoStart /> : <EngineSetup instance={instance} unframed />;+}++function ManagedEngineSetup({ instance, signInOnly, autoStart = false }: { instance: InstanceInfo; signInOnly: boolean; autoStart?: boolean }) {const { state, refreshInstances, refreshModels } = useStore();const signInStarted = useSignInStarted(instance.instanceId);const [busy, setBusy] = useState<"install" | "signin" | "complete" | "check" | null>(null);@@ -374,6 +379,13 @@ function ManagedEngineSetup({ instance, signInOnly }: { instance: InstanceInfo;await refreshModels(instance.instanceId);});+ const autoStarted = useRef(false);+ useEffect(() => {+ if (!autoStart || !signInOnly || autoStarted.current) return;+ autoStarted.current = true;+ void signIn();+ }, [autoStart, signInOnly, signIn]);+if (!signInOnly) {// The server installs it on its own too (the engine updater): the card says so and waits for it.const installing = busy === "install" || instance.snapshot.installing === true;diff --git a/src/components/EnginesSettings.antigravity-switch.dom.test.ts b/src/components/EnginesSettings.antigravity-switch.dom.test.tsindex 492accef3f..5ce44c1cf7 100644--- a/src/components/EnginesSettings.antigravity-switch.dom.test.ts+++ b/src/components/EnginesSettings.antigravity-switch.dom.test.ts@@ -109,7 +109,9 @@ it("moves the account to the CLI, installs it, and shows the sign-in card with n]);await act(async () => { root.render(createElement(EnginesSettings)); });expect(card().querySelector("[data-antigravity-switch-cli]")).toBeNull();- expect(button("Sign in with Google")).toHaveLength(1);+ expect(button("Sign in")).toHaveLength(1);+ await act(async () => { button("Sign in")[0]!.click(); });+ expect(fixture.calls.at(-1)).toMatchObject({ method: "POST", path: "/api/instances/antigravity/auth/start" });expect(card().querySelector("select")).toBeNull();expect(card().textContent).not.toContain("Classic runtime");});diff --git a/src/components/EnginesSettings.antigravity.dom.test.ts b/src/components/EnginesSettings.antigravity.dom.test.tsindex 5dac452d02..053e5b59c2 100644--- a/src/components/EnginesSettings.antigravity.dom.test.ts+++ b/src/components/EnginesSettings.antigravity.dom.test.ts@@ -1,11 +1,16 @@// @vitest-environment happy-dom+// Settings → AI and the chat's AI sign-in card: every Google Gemini (Antigravity) account on one card, as Claude's and+// ChatGPT's are.import { act, createElement } from "react";import { createRoot, type Root } from "react-dom/client";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import type { Bot, InstanceInfo } from "@/state/store";import { setLocale } from "@/lib/i18n";-const fixture = vi.hoisted(() => ({ state: { instances: [] as InstanceInfo[], bots: [] as Bot[], config: {} as Record<string, unknown> }, posts: [] as Array<{ path: string; body: unknown }> }));+const fixture = vi.hoisted(() => ({+ state: { instances: [] as InstanceInfo[], bots: [] as Bot[], config: {} as Record<string, unknown> },+ calls: [] as Array<{ path: string; method: string; body: unknown }>,+}));vi.mock("@/state/store", async (original) => ({...await original<typeof import("@/state/store")>(),useStore: () => ({@@ -13,62 +18,152 @@ vi.mock("@/state/store", async (original) => ({dispatch: (action: { type: string; instances?: InstanceInfo[] }) => { if (action.type === "instances" && action.instances) fixture.state = { ...fixture.state, instances: action.instances }; },refreshInstances: async () => {}, refreshModels: async () => {},}),- api: async (path: string, init?: { body?: string }) => {- if (path !== "/api/instances/antigravity-accounts") return {};- fixture.posts.push({ path, body: init?.body ? JSON.parse(init.body) : undefined });- const added = google("antigravity-work", "Work", false);- return { instanceId: added.instanceId, instances: [...fixture.state.instances, added] };+ api: async (path: string, init?: { method?: string; body?: string }) => {+ if (init?.method) fixture.calls.push({ path, method: init.method, body: init.body ? JSON.parse(init.body) : undefined });+ if (path === "/api/instances/antigravity-accounts") {+ const added = google("antigravity-work", "Work", { authenticated: false });+ return { instanceId: added.instanceId, instances: [...fixture.state.instances, added] };+ }+ if (path.endsWith("/auth/start")) return { auth: { phase: "waiting", flowId: `flow-${path.split("/")[3]}`, authorizationUrl: "https://accounts.google.com/o/oauth2/v2/auth?state=fixture" } };+ if (path.includes("/auth/status")) return { auth: { phase: "waiting" } };+ return {};},}));-import { EnginesSettings } from "./EnginesSettings";+vi.mock("@/lib/use-owner-or-admin", () => ({ useOwnerOrAdmin: () => true }));+vi.mock("@/state/team-people", async (original) => ({ ...await original<typeof import("@/state/team-people")>(), useTeamPeople: () => null }));+import { AiSignInSettings, EnginesSettings } from "./EnginesSettings";-function google(instanceId: string, displayName: string, authenticated: boolean): InstanceInfo {+function google(instanceId: string, displayName: string, snapshot: Partial<InstanceInfo["snapshot"]> = {}, extra: Partial<InstanceInfo> = {}): InstanceInfo {return {- instanceId, driverKind: "antigravityAgent", displayName, cliDefault: "agy",- snapshot: { state: "available", authenticated }, models: { default: "gemini", options: [] },+ instanceId, driverKind: "antigravityAgent", displayName, cliDefault: "agy_acp_server",+ snapshot: { state: "available", authenticated: true, ...snapshot }, models: { default: "gemini", options: [] },install: { managed: { label: "Install Antigravity", downloadBytes: 1 } },+ authentication: { method: "callback-url", signOut: true }, ...extra,} as InstanceInfo;}+const other = (instanceId: string, displayName: string): InstanceInfo => ({+ instanceId, driverKind: "opencodeGo", displayName, cliDefault: instanceId,+ snapshot: { state: "available", authenticated: true }, models: { default: "m", options: [] },+} as InstanceInfo);let container: HTMLDivElement, root: Root;beforeEach(() => {vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);+ vi.stubGlobal("open", () => null);setLocale("en");- fixture.state = { instances: [google("antigravity", "Google Gemini", true)], bots: [], config: {} };- fixture.posts = [];+ fixture.state = { instances: [google("antigravity", "Google Gemini (Antigravity)", { account: { email: "[email protected]" } })], bots: [], config: {} };+ fixture.calls = [];container = document.createElement("div"); document.body.append(container); root = createRoot(container);});afterEach(async () => { await act(async () => root.unmount()); container.remove(); vi.unstubAllGlobals(); });-const render = async () => { await act(async () => { root.render(createElement(EnginesSettings)); }); };-const button = (label: string) => [...container.querySelectorAll("button")].find((item) => item.textContent === label);-const click = async (target: Element | undefined) => { expect(target).toBeTruthy(); await act(async () => { (target as HTMLElement).click(); }); };-async function addWork() {- await render();- await click(button("Add Google account"));- const input = container.querySelector<HTMLInputElement>("form[data-add-account] input")!;+const more = { id: "more", open: false, onToggle: () => {} };+const render = async (view: "full" | "simple" | "chat" = "full") => {await act(async () => {- Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")!.set!.call(input, "Work");- input.dispatchEvent(new Event("input", { bubbles: true }));+ root.render(view === "chat" ? createElement(AiSignInSettings) : view === "simple" ? createElement(EnginesSettings, { simple: true, more }) : createElement(EnginesSettings));});- await click(button("Add and sign in"));+};+const buttons = (scope: ParentNode, label: string) => [...scope.querySelectorAll("button")].filter((item) => item.textContent === label);+const click = async (target: Element | undefined) => { expect(target).toBeTruthy(); await act(async () => { (target as HTMLElement).click(); }); };+const row = (instanceId: string) => container.querySelector(`[data-account="${instanceId}"]`)!;+const rows = () => [...container.querySelectorAll('[data-accounts="antigravity"] [data-account]')].map((item) => item.getAttribute("data-account"));+const startCalls = () => fixture.calls.filter((call) => call.path.endsWith("/auth/start")).map((call) => call.path);+async function openSimpleCard() {+ await render("simple");+ await click(container.querySelector('[data-simple-engine="antigravity"] button') ?? undefined);}-describe("Settings → Google Gemini → Add Google account", () => {- it("keeps the new account's Google sign-in under the card it was added from", async () => {- await addWork();+describe("Google Gemini (Antigravity) accounts share one card", () => {+ it("lists an added account under the first one, even with other providers between them in the config", async () => {+ fixture.state.instances = [fixture.state.instances[0]!, other("opencodeGo", "OpenCode"), google("antigravity-work", "Work", { account: { email: "[email protected]" } })];+ await openSimpleCard();+ expect([...container.querySelectorAll("[data-simple-engine]")].map((item) => item.getAttribute("data-simple-engine")).filter((id) => id !== "google-ai-studio")).toEqual(["antigravity", "opencodeGo"]);+ expect(rows()).toEqual(["antigravity", "antigravity-work"]);+ expect(row("antigravity-work").textContent).toContain("[email protected]");+ expect(buttons(row("antigravity"), "Remove")).toHaveLength(0);+ expect(buttons(row("antigravity-work"), "Remove")).toHaveLength(1);+ });++ it("keeps the provider's name on its row when the first account is renamed", async () => {+ fixture.state.instances = [google("antigravity", "Personal"), google("antigravity-work", "Work")];+ await render("simple");+ expect(container.querySelector('[data-simple-engine="antigravity"]')?.textContent).toContain("Google Gemini (Antigravity)");+ expect(container.querySelector('[data-simple-engine="antigravity"]')?.textContent).not.toContain("Personal");+ });++ it("adds an account from the card and starts its Google sign-in under its own row, then closes it once signed in", async () => {+ await render();+ await click(buttons(container, "Add Google account")[0]);+ const input = container.querySelector<HTMLInputElement>("form[data-add-account] input")!;+ await act(async () => {+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")!.set!.call(input, "Work");+ input.dispatchEvent(new Event("input", { bubbles: true }));+ });+ await click(buttons(container, "Add and sign in")[0]);+ await render();+ expect(fixture.calls[0]).toEqual({ path: "/api/instances/antigravity-accounts", method: "POST", body: { displayName: "Work", sourceInstanceId: "antigravity" } });+ expect(rows()).toEqual(["antigravity", "antigravity-work"]);+ expect(startCalls()).toEqual(["/api/instances/antigravity-work/auth/start"]);+ expect(row("antigravity-work").querySelector("[data-account-sign-in]")?.textContent).toContain("Open Google sign-in again");++ fixture.state = { ...fixture.state, instances: [fixture.state.instances[0]!, google("antigravity-work", "Work", { account: { email: "[email protected]" } })] };+ await render();+ expect(row("antigravity-work").querySelector("[data-account-sign-in]")).toBeNull();++ fixture.state = { ...fixture.state, instances: [fixture.state.instances[0]!, google("antigravity-work", "Work", { authenticated: false })] };await render();- expect(fixture.posts).toEqual([{ path: "/api/instances/antigravity-accounts", body: { displayName: "Work", sourceInstanceId: "antigravity" } }]);- const added = container.querySelector("[data-antigravity-added]");- expect(added?.getAttribute("data-antigravity-added")).toBe("antigravity-work");- expect([...added!.querySelectorAll("button")].map((item) => item.textContent)).toContain("Sign in with Google");- expect(added!.textContent).toContain("Work");+ expect(buttons(row("antigravity-work"), "Sign in")).toHaveLength(1);+ });++ it("keeps one account's Google sign-in waiting while another account signs in", async () => {+ fixture.state.instances = [google("antigravity", "Personal", { authenticated: false }), google("antigravity-work", "Work", { authenticated: false })];+ await render();+ await click(buttons(row("antigravity"), "Sign in")[0]);+ await click(buttons(row("antigravity-work"), "Sign in")[0]);+ expect(startCalls()).toEqual(["/api/instances/antigravity/auth/start", "/api/instances/antigravity-work/auth/start"]);+ expect(row("antigravity").querySelector("[data-account-sign-in]")?.textContent).toContain("Open Google sign-in again");+ expect(row("antigravity-work").querySelector("[data-account-sign-in]")?.textContent).toContain("Open Google sign-in again");+ });++ it("signs in an account whose status could not be read, rather than offering an install", async () => {+ fixture.state.instances = [google("antigravity", "Google Gemini (Antigravity)", { authenticated: undefined, nativeCli: true })];+ await render();+ expect(row("antigravity").getAttribute("data-account-state")).toBe("unknown");+ await click(buttons(row("antigravity"), "Sign in")[0]);+ expect(startCalls()).toEqual(["/api/instances/antigravity/auth/start"]);+ expect(row("antigravity").textContent).not.toContain("Install");+ });++ it("lists every account when none can run yet, each with its own setup", async () => {+ fixture.state.instances = [+ google("antigravity", "Personal", { state: "unavailable", authenticated: undefined, reason: "Not installed" }),+ google("antigravity-work", "Work", { state: "unavailable", authenticated: undefined, reason: "The custom path is missing" }),+ ];+ await render();+ expect(rows()).toEqual(["antigravity", "antigravity-work"]);+ expect(row("antigravity").querySelector('[data-account-setup="antigravity"]')).toBeTruthy();+ expect(row("antigravity-work").querySelector('[data-account-setup="antigravity-work"]')?.textContent).toContain("The custom path is missing");+ expect(buttons(container, "Add Google account")).toHaveLength(1);+ });++ it("keeps each account's CLI path in reach, in Settings and in the chat's sign-in card", async () => {+ fixture.state.instances = [google("antigravity", "Personal"), google("antigravity-work", "Work", {}, { cli: "/opt/work/agy_acp_server.par" })];+ for (const view of ["full", "chat"] as const) {+ await render(view);+ if (view === "chat") await click(container.querySelector('[data-simple-engine="antigravity"] button') ?? undefined);+ const advanced = [...container.querySelectorAll("details > summary")].map((item) => item.textContent).filter((text) => text?.startsWith("CLI path and updates"));+ expect(advanced).toEqual(["CLI path and updates · Personal", "CLI path and updates · Work"]);+ expect(container.textContent).toContain("/opt/work/agy_acp_server.par");+ expect(container.querySelector('[data-hide-engine="antigravity-work"]')).toBeTruthy();+ }});- it("drops that sign-in from the card once the new account is signed in", async () => {- await addWork();- fixture.state = { ...fixture.state, instances: [google("antigravity", "Google Gemini", true), google("antigravity-work", "Work", true)] };+ it("leaves an account with its own access setting on a card of its own, with its old controls", async () => {+ fixture.state.instances = [fixture.state.instances[0]!, google("antigravity-gw", "Gateway", {}, { access: "custom" })];await render();- expect(container.querySelector("[data-antigravity-added]")).toBeNull();+ expect(rows()).toEqual(["antigravity"]);+ const card = container.querySelector('[data-engine-card="antigravity-gw"]')!;+ expect(card.querySelector("[data-account]")).toBeNull();+ expect(buttons(card, "Add Google account")).toHaveLength(1);});});diff --git a/src/components/EnginesSettings.hidden-providers.dom.test.ts b/src/components/EnginesSettings.hidden-providers.dom.test.tsindex fbbcff8deb..4f64fc57e7 100644--- a/src/components/EnginesSettings.hidden-providers.dom.test.ts+++ b/src/components/EnginesSettings.hidden-providers.dom.test.ts@@ -215,7 +215,8 @@ describe("Settings → AI: Sign out on other CLI sign-ins", () => {fixture.state = { ...fixture.state, instances: [...server.all] };await render();await click(rowButton("antigravity"));- await click([...container.querySelectorAll('[data-engine-card="antigravity"] button')].find((button) => button.textContent === "Sign out"));+ await click(container.querySelector('[data-account="antigravity"] button[aria-label="Options for Antigravity"]'));+ await click([...container.querySelectorAll('[data-account="antigravity"] [role="menuitem"]')].find((item) => item.textContent === "Sign out"));expect(document.body.textContent).toContain("Bots that use this account need it signed in again before their next task.");expect(document.body.textContent).not.toContain("keeps one sign-in");});diff --git a/src/components/EnginesSettings.test.ts b/src/components/EnginesSettings.test.tsindex 161ffd4e93..87569812be 100644--- a/src/components/EnginesSettings.test.ts+++ b/src/components/EnginesSettings.test.ts@@ -228,14 +228,14 @@ describe("Settings → Engines → setup cards", () => {snapshot: { state: "available", authenticated }, models: { default: "gemini", options: [] },authentication: { method: "callback-url", signOut },});- fixture.instances = [account("antigravity", true, true)];- expect(renderToStaticMarkup(createElement(EnginesSettings))).toContain(">Sign out<");- fixture.instances = [account("antigravity-work", true, true)];- expect(renderToStaticMarkup(createElement(EnginesSettings))).toContain(">Sign out<");- fixture.instances = [account("antigravity", false, true)];- expect(renderToStaticMarkup(createElement(EnginesSettings))).not.toContain(">Sign out<");- fixture.instances = [account("antigravity", true, false)];- expect(renderToStaticMarkup(createElement(EnginesSettings))).not.toContain(">Sign out<");+ expect(accountActions("antigravity", account("antigravity", true, true)).signOut).toBe(true);+ expect(accountActions("antigravity", account("antigravity-work", true, true)).signOut).toBe(true);+ expect(accountActions("antigravity", account("antigravity", false, true)).signOut).toBe(false);+ expect(accountActions("antigravity", account("antigravity", true, false)).signOut).toBe(false);+ fixture.instances = [account("antigravity", true, true), account("antigravity-work", true, true)];+ const html = renderToStaticMarkup(createElement(EnginesSettings));+ expect(html.match(/data-account="antigravity[^"]*"/g)).toEqual(['data-account="antigravity"', 'data-account="antigravity-work"']);+ expect(html.match(/aria-label="Options for Google account"/g)).toHaveLength(2);});it("shows every Company provider as read-only while preserving personal controls", () => {@@ -306,11 +306,13 @@ describe("Settings → Engines → setup cards", () => {install: { managed: { label: "Install Antigravity", downloadBytes: 10 } },}];const html = renderToStaticMarkup(createElement(EnginesSettings));- expect(html).toContain("Sign in with Google");- expect(html).toContain("Set up");+ expect(html).toMatch(/data-account="agy"[\s\S]*<button[^>]*>Sign in<\/button>/);+ expect(html).toContain("Sign-in required");expect(html).toContain("CLI path and updates");fixture.instances[0].access = "custom";- expect(renderToStaticMarkup(createElement(EnginesSettings))).not.toContain("Sign in with Google");+ const custom = renderToStaticMarkup(createElement(EnginesSettings));+ expect(custom).not.toContain("Sign in with Google");+ expect(custom).not.toContain("data-account=");});it("keeps an API-key engine listed after its key is saved, with the key masked and Replace beside it", () => {diff --git a/src/components/EnginesSettings.tsx b/src/components/EnginesSettings.tsxindex a47e64fef6..f65720a95a 100644--- a/src/components/EnginesSettings.tsx+++ b/src/components/EnginesSettings.tsx@@ -12,7 +12,8 @@ import { ApiKeyEngineManage, EngineSetup, EngineUpdateNotice, EngineWarningNoticimport { AntigravitySwitchCli } from "./AntigravitySwitchCli";import { AppCopyNotice } from "./EngineAppCopy";import { forgetAppCopySwitches } from "@/state/engine-install";-import { AccountsCard, AddAccount, accountGroupOf, accountsReady, type AccountGroup } from "./EngineAccounts";+import { AccountsCard, AddAccount, accountGroupOf, accountGroupTitle, accountsReady, type AccountGroup } from "./EngineAccounts";+import { engineDisplayName } from "@/lib/engine-name";import { ClaudeEndpoints, CodexEndpoints } from "./ClaudeEndpoints";import { ClaudeBedrockEndpoints } from "./ClaudeBedrock";import { DEVICE_SIGN_IN_COPY, deviceSignInProvider } from "./DeviceSignIn";@@ -196,7 +197,11 @@ function CustomPicker({ instance, cliDefault, onClose, onSaved }: {}/** The executable behind an engine: its path, Claude's self-update, and a reset to the default. */-function EngineAdvanced({ instance }: { instance: InstanceInfo }) {+function EngineAdvanced({ instance, account }: {+ instance: InstanceInfo;+ /** Whose CLI path this is, when one card lists several accounts. */+ account?: string;+}) {const { refreshInstances } = useStoreActions();const showInstances = useShowInstances();const [open, setOpen] = useState(false);@@ -257,7 +262,7 @@ function EngineAdvanced({ instance }: { instance: InstanceInfo }) {return (<details className="mt-4 border-t border-hairline/40 pt-3">- <summary className="cursor-pointer rounded-md py-1 text-[12px] font-medium text-ink-secondary outline-none hover:text-ink focus-visible:ring-2 focus-visible:ring-accent">{t("engines.library.advanced")}</summary>+ <summary className="cursor-pointer rounded-md py-1 text-[12px] font-medium text-ink-secondary outline-none hover:text-ink focus-visible:ring-2 focus-visible:ring-accent">{account ? `${t("engines.library.advanced")} · ${account}` : t("engines.library.advanced")}</summary><p className="mt-2 text-[12px] leading-relaxed text-ink-secondary">{t("engines.footer")}</p><div className="mt-3 flex flex-wrap items-center gap-2 text-[13px]">{instance.cli ? (@@ -460,7 +465,7 @@ function ProviderRow({ instance, ready, open, onToggle, compact, children }: {<div data-simple-engine={instance.instanceId} className={cn("flex items-center gap-3 px-4", compact && !ready && !status.tone ? "min-h-11 py-1.5" : "min-h-16 py-3")}><SettingsMark><InstanceProviderMark instance={instance} size={18} subtle /></SettingsMark><span className="flex min-w-0 flex-1 flex-col gap-0.5">- <span className="truncate text-[14px] leading-5 text-ink">{instance.displayName}</span>+ <span className="truncate text-[14px] leading-5 text-ink">{accountGroupOf(instance) === "antigravity" ? accountGroupTitle("antigravity") : instance.displayName}</span>{!(compact && !ready && !status.tone) && <span className="truncate text-[13px] leading-[18px] text-ink-secondary"><StatusDot tone={status.tone} />{status.text}</span>}</span><button type="button" aria-expanded={open} className="ui-button ml-3 shrink-0" onClick={onToggle}>@@ -530,6 +535,14 @@ function SimpleEngines({ rows, isReady, renderEngine, more, accountsOnly = false);}+/** Each Antigravity account keeps its own CLI path, so each keeps its own way to fix it. */+function accountsAdvanced(group: AccountGroup, accounts: InstanceInfo[]): ReactNode {+ if (group === "antigravity") return accounts.map((account) => (+ <EngineAdvanced key={account.instanceId} instance={account} account={accounts.length > 1 ? engineDisplayName(account) : undefined} />+ ));+ return <>{group === "claude" ? <><ClaudeEndpoints /><ClaudeBedrockEndpoints /></> : <CodexEndpoints />}<EngineAdvanced instance={accounts[0]!} /></>;+}+/** A provider's accounts share one card, which takes the place of its first account. */function groupedAccounts(listed: InstanceInfo[]) {const groups = new Map<AccountGroup, InstanceInfo[]>();@@ -552,7 +565,9 @@ export function AiSignInSettings() {const isReady = (instance: InstanceInfo) => { const group = groupOf(instance); return group ? accountsReady(groups.get(group)!) : engineReady(instance); };const renderEngine = (instance: InstanceInfo, bare = false) => {const group = groupOf(instance);- return group ? <AccountsCard group={group} accounts={groups.get(group)!} bare={bare} /> : <EngineRow instance={instance} bare={bare} />;+ return group+ ? <AccountsCard group={group} accounts={groups.get(group)!} bare={bare} advanced={group === "antigravity" ? accountsAdvanced(group, groups.get(group)!) : undefined} />+ : <EngineRow instance={instance} bare={bare} />;};return <AdminOnly><div data-ai-sign-in=""><SimpleEngines rows={rows} isReady={isReady} renderEngine={renderEngine} accountsOnly more={{ id: "ai-sign-in-more", open: false, onToggle: () => {} }} />@@ -575,7 +590,7 @@ export function EnginesSettings({ simple = false, more }: { simple?: boolean; moconst group = groupOf(instance);return group? <AccountsCard group={group} accounts={groups.get(group)!} bare={bare}- advanced={<>{group === "claude" ? <><ClaudeEndpoints /><ClaudeBedrockEndpoints /></> : <CodexEndpoints />}<EngineAdvanced instance={instance} /></>} />+ advanced={accountsAdvanced(group, groups.get(group)!)} />: <EngineRow instance={instance} bare={bare} />;};diff --git a/src/locales/en.json b/src/locales/en.jsonindex 0efb4ccdd6..24364d4a96 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -4848,6 +4848,7 @@"engines.account.powershell": "Use PowerShell for this command.","accounts.claude": "Claude","accounts.chatgpt": "ChatGPT",+ "accounts.antigravity": "Google Gemini (Antigravity)","accounts.count": "{count} accounts · {signedIn} signed in","accounts.signedIn": "Signed in","accounts.notSignedIn": "Not signed in",