Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(antigravity): start the new account's Google sign-in after Add Google account
AdityaUmalec3093b725543
diff --git a/src/components/EnginesSettings.antigravity.dom.test.ts b/src/components/EnginesSettings.antigravity.dom.test.tsnew file mode 100644index 0000000000..5dac452d02--- /dev/null+++ b/src/components/EnginesSettings.antigravity.dom.test.ts@@ -0,0 +1,74 @@+// @vitest-environment happy-dom+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 }> }));+vi.mock("@/state/store", async (original) => ({+ ...await original<typeof import("@/state/store")>(),+ useStore: () => ({+ state: fixture.state,+ 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] };+ },+}));+import { EnginesSettings } from "./EnginesSettings";++function google(instanceId: string, displayName: string, authenticated: boolean): InstanceInfo {+ return {+ instanceId, driverKind: "antigravityAgent", displayName, cliDefault: "agy",+ snapshot: { state: "available", authenticated }, models: { default: "gemini", options: [] },+ install: { managed: { label: "Install Antigravity", downloadBytes: 1 } },+ } as InstanceInfo;+}++let container: HTMLDivElement, root: Root;+beforeEach(() => {+ vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);+ setLocale("en");+ fixture.state = { instances: [google("antigravity", "Google Gemini", true)], bots: [], config: {} };+ fixture.posts = [];+ 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")!;+ await act(async () => {+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")!.set!.call(input, "Work");+ input.dispatchEvent(new Event("input", { bubbles: true }));+ });+ await click(button("Add and sign in"));+}++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();+ 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");+ });++ 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)] };+ await render();+ expect(container.querySelector("[data-antigravity-added]")).toBeNull();+ });+});diff --git a/src/components/EnginesSettings.tsx b/src/components/EnginesSettings.tsxindex 5648fcea7f..6662d8463e 100644--- a/src/components/EnginesSettings.tsx+++ b/src/components/EnginesSettings.tsx@@ -359,6 +359,17 @@ function AntigravityAccountAction({ instance, action }: { instance: InstanceInfo</>;}+/** Adds another Google account and keeps its sign-in under this card until it is signed in; on its own, an unsigned account only shows among the providers still to set up. */+function AntigravityAddAccount({ source }: { source: InstanceInfo }) {+ const { state } = useStore();+ const [addedId, setAddedId] = useState<string | null>(null);+ const added = addedId ? state.instances.find((instance) => instance.instanceId === addedId && instance.snapshot.authenticated !== true) : undefined;+ return <>+ <AddAccount label={t("engineSetup.antigravity.addAccount")} endpoint="/api/instances/antigravity-accounts" extra={{ sourceInstanceId: source.instanceId }} onAdded={setAddedId} />+ {added && <div data-antigravity-added={added.instanceId}><EngineSetup instance={added} unframed /></div>}+ </>;+}+function EngineRow({ instance, bare = false }: { instance: InstanceInfo; bare?: boolean }) {const policyNote = instance.policy && <p className="mb-2 text-[12px] leading-relaxed text-ink-secondary"><span className="font-medium text-ink">{t("policy.managedBy", { organization: instance.policy.organizationName })}</span> · {instance.policy.reason}@@ -393,7 +404,7 @@ function EngineRow({ instance, bare = false }: { instance: InstanceInfo; bare?:{instance.driverKind === "antigravityAgent" && (<div className="mt-3 space-y-3">{instance.snapshot.authenticated && <p className="break-words text-[12px] text-ink-secondary">{instance.snapshot.account?.email ?? t("engineSetup.antigravity.emailUnavailable")}</p>}- <AddAccount label={t("engineSetup.antigravity.addAccount")} endpoint="/api/instances/antigravity-accounts" extra={{ sourceInstanceId: instance.instanceId }} onAdded={() => {}} />+ <AntigravityAddAccount source={instance} />{instance.snapshot.authenticated === true && instance.authentication?.signOut === true && <AntigravityAccountAction instance={instance} action="signOut" />}{instance.instanceId.startsWith("antigravity-") && <AntigravityAccountAction instance={instance} action="remove" />}</div>