Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(two-places): ask before moving this computer's bots (#4192) (#4216)
Aditya Umale4f5829f1a88d
diff --git a/src/components/AppNotices.test.ts b/src/components/AppNotices.test.tsindex d66a90235a..e02f7f723f 100644--- a/src/components/AppNotices.test.ts+++ b/src/components/AppNotices.test.ts@@ -33,6 +33,7 @@ vi.mock("@/lib/brand", () => ({ brandStatus: () => ({ brand: { name: "OpenMausBovi.mock("@/components/EngineLibrary", () => ({ engineReady: (instance: { snapshot: { state: string; authenticated?: boolean } }) =>instance.snapshot.state === "available" && instance.snapshot.authenticated !== false }));import { AppNotices } from "./AppNotices";+import { TwoPlacesCard } from "./TwoPlacesCard";import { BOAT_OFFER_NOTICE, CLOUD_INTRO, launchNotice, localDay, PRODUCT_HUNT_NOTICE, PRODUCT_HUNT_UNTIL, PRODUCT_HUNT_URL, STAR_NOTICE, WHATS_NEW_NOTICE } from "@/lib/notices";import { BOAT_OFFER, boatClaimMailto } from "@/lib/boat-offer";import { track } from "@/lib/analytics";@@ -1044,7 +1045,7 @@ describe("the Simple mode popup after the update", () => {describe("bots in two places", () => {const GARAGE = { key: "server:https://garage.example.test", name: "Garage server", kind: "server" as const };const BODY = "Your bots live in two places, so they can't work together. Bring them together on Garage server?";- let suggest: typeof GARAGE | null;+ let suggest: { key: string; name: string; kind: "cloud" | "server" } | null;let accepted: string[], dismissed: string[];beforeEach(() => {suggest = GARAGE; accepted = []; dismissed = [];@@ -1053,7 +1054,7 @@ describe("bots in two places", () => {desk.handlers.set("two-places:dismiss", async (_event, key) => { dismissed.push(String(key)); suggest = null; return { suggest }; });});- it("one plain card on this computer's page, before any promotion; its one tap asks main to bring them together there", async () => {+ it("one plain card on this computer's page, before any promotion; bots move there only after the person confirms (#4192)", async () => {returning();storage.delete(PRODUCT_HUNT_NOTICE);const html = await launch();@@ -1062,12 +1063,65 @@ describe("bots in two places", () => {expect(html).toContain(BODY);expect(html).not.toContain(STAR);press("Bring them together");+ const asking = await settle();+ expect(accepted, "one tap never moves anyone").toEqual([]);+ expect(asking).toContain("Move this computer's bots to Garage server?");+ expect(asking, "the undo switch is My Cloud's only").not.toContain("Keep this computer's bots on this computer");+ press("Move bots");await flush();expect(accepted).toEqual([GARAGE.key]);expect(track).toHaveBeenCalledWith("two_places_card", { action: "bring", kind: "server" });expect(await settle()).not.toContain('data-notice="two-places"');});+ it("Cancel on the confirm step moves nothing and keeps the card (#4192)", async () => {+ returning();+ suggest = { key: "cloud:mine", name: "My Cloud", kind: "cloud" };+ await launch();+ press("Bring them together");+ const asking = await settle();+ expect(asking).toContain("Move this computer's bots to My Cloud?");+ expect(asking, "My Cloud names the way back").toContain("Keep this computer's bots on this computer");+ press("Cancel");+ const after = await settle();+ expect(accepted).toEqual([]);+ expect(dismissed).toEqual([]);+ expect(after).toContain('data-notice="two-places"');+ expect(after).not.toContain("Move bots");+ expect(after).toContain("Bring them together");+ expect(tree().find(node => node.props["data-two-places-bring"])?.props.autoFocus, "focus returns to the button Cancel brought back").toBe(true);+ });++ it("Escape on the confirm step works as Cancel and never dismisses the card", async () => {+ returning();+ await launch();+ press("Bring them together");+ await settle();+ const escape = { key: "Escape", preventDefault: vi.fn(), stopPropagation: vi.fn() };+ tree().find(node => node.props.role === "group")!.props.onKeyDown(escape);+ expect(escape.stopPropagation, "the card's own Escape never sees it").toHaveBeenCalled();+ const after = await settle();+ expect(dismissed).toEqual([]);+ expect(accepted).toEqual([]);+ expect(after).toContain('data-notice="two-places"');+ expect(after).not.toContain("Move bots");+ });++ it("a different suggested place starts a fresh card, so a confirm never carries over to it", async () => {+ returning();+ await launch();+ // Children.toArray would re-key, so walk the elements as rendered.+ const find = (value: unknown): Node | undefined => {+ if (Array.isArray(value)) return value.map(find).find(Boolean);+ if (!isValidElement(value)) return undefined;+ const node = value as Node;+ if (node.type === TwoPlacesCard) return node;+ return typeof node.type === "function" ? find((node.type as (props: unknown) => ReactNode)(node.props)) : find(node.props.children);+ };+ f.index = 0; f.effects = [];+ expect(find(AppNotices({ viewer, now: () => now }))?.key).toBe(GARAGE.key);+ });+it("Not now hands main the place to remember, and the card goes", async () => {returning();expect(await launch()).toContain(BODY);diff --git a/src/components/AppNotices.tsx b/src/components/AppNotices.tsxindex 76530c5d47..96c1e2f03e 100644--- a/src/components/AppNotices.tsx+++ b/src/components/AppNotices.tsx@@ -257,7 +257,7 @@ export function AppNotices({ quiet = false, viewer = null, now = Date.now }: { q}if (notice === TWO_PLACES_NOTICE && two.suggest) {const { key, kind } = two.suggest;- return <TwoPlacesCard suggest={two.suggest}+ return <TwoPlacesCard key={key} suggest={two.suggest}onBring={() => { track("two_places_card", { action: "bring", kind }); return two.accept(key).then(close); }}onDismiss={() => { track("two_places_card", { action: "not_now", kind }); two.dismiss(key); close(); }} />;}diff --git a/src/components/TwoPlacesCard.tsx b/src/components/TwoPlacesCard.tsxindex 1d5f26254d..6b484a7f8d 100644--- a/src/components/TwoPlacesCard.tsx+++ b/src/components/TwoPlacesCard.tsx@@ -5,11 +5,16 @@ import { t } from "@/lib/i18n";import type { TwoPlacesSuggestion } from "@/lib/two-places";import { NoticeCard, NotNowButton, PRIMARY_BUTTON } from "./NoticeCard";-/** Bots on this computer and on another place of the person's can't work together: one tap brings them together there- * (the one-time move), Not now or the close button never asks again for that place. */+/** Bots on this computer and on another place of the person's can't work together: the card offers to bring them+ * together there, and the one-time move starts only once the person confirms what it does; Cancel changes nothing.+ * Not now or the close button never asks again for that place. */export function TwoPlacesCard({ suggest, onBring, onDismiss }: { suggest: TwoPlacesSuggestion; onBring: () => Promise<void>; onDismiss: () => void }) {const [busy, setBusy] = useState(false);const [failed, setFailed] = useState<string | null>(null);+ const [confirming, setConfirming] = useState(false);+ // Cancel removes the focused button, so focus goes back to "Bring them together" as it reappears.+ const [cancelled, setCancelled] = useState(false);+ const cancel = () => { if (busy) return; setConfirming(false); setCancelled(true); setFailed(null); };const bring = () => {if (busy) return;setBusy(true); setFailed(null);@@ -18,12 +23,21 @@ export function TwoPlacesCard({ suggest, onBring, onDismiss }: { suggest: TwoPlareturn <NoticeCard titleId="two-places-title" notice="two-places" icon={Merge} title={t("twoPlaces.title")} onDismiss={onDismiss}><p className="mb-3 mt-1 text-[13px] text-ink-secondary">{t("twoPlaces.body", { place: suggest.name })}</p>{failed && <p role="alert" className="mb-3 text-[12px] text-danger">{failed}</p>}- <div className="flex flex-wrap items-center gap-3">- <button type="button" data-two-places-bring className={PRIMARY_BUTTON} disabled={busy} aria-busy={busy || undefined} onClick={bring}>- {busy && <Loader2 aria-hidden="true" className="size-3.5 shrink-0 animate-spin motion-reduce:animate-none" />}- {t("twoPlaces.bring")}- </button>+ {confirming ? <div role="group" aria-label={t("twoPlaces.confirmTitle", { place: suggest.name })} className="rounded-lg border border-hairline/40 p-3"+ onKeyDown={event => { if (event.key === "Escape") { event.preventDefault(); event.stopPropagation(); cancel(); } }}>+ <p className="text-[13px] font-medium text-ink">{t("twoPlaces.confirmTitle", { place: suggest.name })}</p>+ <p className="mt-1 text-[13px] leading-relaxed text-ink-secondary">{t("twoPlaces.confirm", { place: suggest.name })}</p>+ {suggest.kind === "cloud" && <p className="mt-1 text-[13px] leading-relaxed text-ink-secondary">{t("twoPlaces.undo")}</p>}+ <div className="mt-3 flex flex-wrap items-center gap-3">+ <button type="button" data-two-places-move className={PRIMARY_BUTTON} disabled={busy} aria-busy={busy || undefined} onClick={bring}>+ {busy && <Loader2 aria-hidden="true" className="size-3.5 shrink-0 animate-spin motion-reduce:animate-none" />}+ {t("twoPlaces.move")}+ </button>+ <button type="button" autoFocus className="ui-button min-h-9 px-3 py-1.5" disabled={busy} onClick={cancel}>{t("common.cancel")}</button>+ </div>+ </div> : <div className="flex flex-wrap items-center gap-3">+ <button type="button" data-two-places-bring className={PRIMARY_BUTTON} autoFocus={cancelled} onClick={() => setConfirming(true)}>{t("twoPlaces.bring")}</button><NotNowButton onClick={onDismiss} />- </div>+ </div>}</NoticeCard>;}diff --git a/src/locales/en.json b/src/locales/en.jsonindex 92a866a517..9caa8bbe00 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -599,6 +599,10 @@"twoPlaces.body": "Your bots live in two places, so they can't work together. Bring them together on {place}?","twoPlaces.bring": "Bring them together","twoPlaces.failed": "Your bots didn't start moving. Try again in a moment.",+ "twoPlaces.confirmTitle": "Move this computer's bots to {place}?",+ "twoPlaces.confirm": "This computer's bots, with their chats and automations, move to {place} and work there from now on.",+ "twoPlaces.undo": "To bring them back later, turn on “Keep this computer's bots on this computer” in Settings > MausBot Cloud (Advanced mode).",+ "twoPlaces.move": "Move bots","rail.removeAsk": "Remove “{name}” from your list? You can buy a new Cloud any time.","rail.removeServerAsk": "Remove “{name}” from your list? This app signs out of it there; nothing on it changes.","rail.removeYes": "Remove",