Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
The move to My Cloud warns in the account area, with Try again, instead of a strip over the page (#3866)
Omkar Satpute238bf4ea6649
diff --git a/docs/verification/cloud-send.md b/docs/verification/cloud-send.mdindex 8c2557f42e..8471724a02 100644--- a/docs/verification/cloud-send.md+++ b/docs/verification/cloud-send.md@@ -87,9 +87,16 @@ My Cloud's welcome (`src/components/cloud-welcome/CloudWelcome.test.ts`): whilethe move runs, or once it has gone, **Bring your stuff** is done by itself, sothe welcome goes straight on to the AI with nothing to press; back on that stepit says so in one line, with a fresh start only behind **More**. Before anything-has come, it offers a fresh start. The line on either page-(`src/components/CloudSendStrip.test.ts`) shows only the move: on its way, Try-again after a day of failing, and on My Cloud's page once what arrived.+has come, it offers a fresh start. The move never shows as a strip over the page+(`src/components/CloudSendStrip.test.ts`): it lives in the account area at the+bottom of the sidebar (`src/components/AccountMove.test.ts`). On its way, the+account line says "Moving to My Cloud…" and so does one row in the account+menu, with the progress in its tooltip; after a day of failing the line says "My+Cloud move needs you" and ends with Try again, the avatar gets a red dot, and the+menu's top row says "Try My Cloud move again", the size of every other row, with+the reason in its tooltip. Both run the one retry, and both wait with a spinner+while it runs. On My Cloud's page the menu says once what arrived, with the phone+to pair and Got it.## The real utility portdiff --git a/docs/verification/evidence/cloud-move-warning/account-line-daylight.png b/docs/verification/evidence/cloud-move-warning/account-line-daylight.pngnew file mode 100644index 0000000000..cb143cc1fdBinary files /dev/null and b/docs/verification/evidence/cloud-move-warning/account-line-daylight.png differdiff --git a/docs/verification/evidence/cloud-move-warning/account-line-midnight.png b/docs/verification/evidence/cloud-move-warning/account-line-midnight.pngnew file mode 100644index 0000000000..a3f74bf257Binary files /dev/null and b/docs/verification/evidence/cloud-move-warning/account-line-midnight.png differdiff --git a/docs/verification/evidence/cloud-move-warning/line-daylight.png b/docs/verification/evidence/cloud-move-warning/line-daylight.pngnew file mode 100644index 0000000000..4dcbfa5afbBinary files /dev/null and b/docs/verification/evidence/cloud-move-warning/line-daylight.png differdiff --git a/docs/verification/evidence/cloud-move-warning/line-midnight.png b/docs/verification/evidence/cloud-move-warning/line-midnight.pngnew file mode 100644index 0000000000..543f067a87Binary files /dev/null and b/docs/verification/evidence/cloud-move-warning/line-midnight.png differdiff --git a/docs/verification/evidence/cloud-move-warning/menu-daylight.png b/docs/verification/evidence/cloud-move-warning/menu-daylight.pngnew file mode 100644index 0000000000..f3679975b6Binary files /dev/null and b/docs/verification/evidence/cloud-move-warning/menu-daylight.png differdiff --git a/docs/verification/evidence/cloud-move-warning/menu-midnight.png b/docs/verification/evidence/cloud-move-warning/menu-midnight.pngnew file mode 100644index 0000000000..1aac5bbbb5Binary files /dev/null and b/docs/verification/evidence/cloud-move-warning/menu-midnight.png differdiff --git a/src/App.tsx b/src/App.tsxindex 50008b6342..30809f8f48 100644--- a/src/App.tsx+++ b/src/App.tsx@@ -303,7 +303,7 @@ function Shell({ viewer }: { viewer: WelcomeViewer | null }) {<div className="flex h-full flex-col"><UpdateBanner sidebarIndicator={!calendarFocus && (sidebarInline || drawerOpen)} /><CloudAsleepStrip />- <CloudSendStrip cloudHome={state.config?.cloudHome === true} onPairPhone={() => dispatch(phonePairingSettingsAction())} />+ <CloudSendStrip cloudHome={state.config?.cloudHome === true} /><HomeLine /><AppNotices quiet={paletteOpen || drawerOpen || Boolean(localVmWorkspaceBotId)} viewer={viewer} /><div className="relative flex min-h-0 flex-1">diff --git a/src/components/AccountMove.test.ts b/src/components/AccountMove.test.tsnew file mode 100644index 0000000000..4f0f9e822b--- /dev/null+++ b/src/components/AccountMove.test.ts@@ -0,0 +1,245 @@+import { createElement, type EffectCallback, type ReactNode } from "react";+import { renderToStaticMarkup } from "react-dom/server";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import type { CloudSendNotice, CloudSendPageBridge } from "../../electron/cloud-send.mjs";+import type { OneHomeView } from "../../electron/one-home.mjs";+import { moveLine } from "@/lib/cloud-send";+import { setLocale } from "@/lib/i18n";+const f = vi.hoisted(() => ({ values: [] as unknown[], index: 0, effects: [] as EffectCallback[] }));+vi.mock("react", async original => ({ ...await original<typeof import("react")>(),+ useState: (initial: unknown) => { const index = f.index++; if (!(index in f.values)) f.values[index] = initial; return [f.values[index], (next: unknown) => { f.values[index] = typeof next === "function" ? (next as (value: unknown) => unknown)(f.values[index]) : next; }]; },+ useEffect: (effect: EffectCallback) => { f.effects.push(effect); },+ useSyncExternalStore: (_subscribe: unknown, snapshot: () => unknown) => snapshot(),+}));+import { AccountMoveStatus, accountMoveWords, moveMenuItems, useAccountMove, useAccountMoveLine, type AccountMoveLine } from "./AccountMove";++const flush = async () => { for (let i = 0; i < 20; i++) await Promise.resolve(); };+const markup = (node: ReactNode) => renderToStaticMarkup(createElement("div", null, node)).replaceAll("'", "'");+const noop = () => {};+const tryAgainTag = (html: string) => html.match(/<button[^>]*data-move-retry[^>]*>/)?.[0] ?? "";+const line = (move: OneHomeView, page: "local" | "cloud" = "local") => moveLine(move, page) as AccountMoveLine;++const notice: CloudSendNotice = { ready: true, bots: ["Ember"], updatedBots: [], skills: 2, logins: 0, onePassword: true, settings: 0, signature: "sig-1", dismissed: false, running: false, last: null, whole: null };+let page: CloudSendPageBridge;+const pair = vi.fn(), open = vi.fn();+const hook = (cloudHome = false) => { f.index = 0; f.effects = []; return useAccountMove(cloudHome, { onOpen: open, onPairPhone: pair }); };+const lineHook = (cloudHome = false) => { f.index = 0; f.effects = []; return useAccountMoveLine(cloudHome); };+async function shown(value: CloudSendNotice, cloudHome = false) {+ page = { notice: vi.fn().mockResolvedValue(value), dismiss: vi.fn().mockResolvedValue({ ...value, move: undefined }), onNotice: vi.fn(() => () => {}) };+ vi.stubGlobal("window", { ogb: { cloudSendPage: page } });+ hook(cloudHome); for (const effect of f.effects) effect(); await flush();+ return hook(cloudHome);+}++beforeEach(() => { f.values = []; f.index = 0; f.effects = []; setLocale("en"); pair.mockReset(); open.mockReset(); });+afterEach(() => { vi.unstubAllGlobals(); });++describe("the move's words on the account", () => {+ it("needs the person once failing, goes quietly while on its way, and says nothing once done", () => {+ expect(accountMoveWords("failed")).toBe("My Cloud move needs you");+ expect(accountMoveWords("sending")).toBe("Moving to My Cloud…");+ expect(accountMoveWords("done")).toBeNull();+ expect(accountMoveWords(null)).toBeNull();+ });++ it("is a button that opens the account menu by the account, and plain words inside a trigger", () => {+ const opened = vi.fn();+ const failed = AccountMoveStatus({ kind: "failed", onOpen: opened }) as ReturnType<typeof createElement>;+ expect(markup(failed)).toContain('data-account-move="failed"');+ expect(markup(failed)).toContain("text-warning");+ expect(markup(failed)).toContain("<button");+ expect(markup(AccountMoveStatus({ kind: "sending", onOpen: opened }))).toContain("Moving to My Cloud…");+ expect(markup(AccountMoveStatus({ kind: "sending", onOpen: opened }))).not.toContain("text-warning");+ expect(markup(AccountMoveStatus({ kind: "failed" }))).not.toContain("<button");+ expect(markup(AccountMoveStatus({ kind: "failed" }))).toContain("My Cloud move needs you");+ expect(AccountMoveStatus({ kind: "done", onOpen: opened })).toBeNull();+ expect(AccountMoveStatus({ kind: null })).toBeNull();+ });++ it("ends with Try again, a button of its own named for the move, that runs the retry", () => {+ const onRetry = vi.fn();+ const status = AccountMoveStatus({ kind: "failed", onOpen: noop, retry: { onRetry, retrying: false, why: "My Cloud did not answer." } }) as ReturnType<typeof createElement>;+ const html = markup(status);+ const tag = tryAgainTag(html);+ expect(html.match(/<button/g)).toHaveLength(2);+ expect(tag).toContain('aria-label="Try again to move to My Cloud"');+ expect(tag).toContain('title="My Cloud did not answer."');+ expect(tag).not.toContain("aria-disabled");+ expect(html).toMatch(/data-move-retry[^>]*>Try again<\/button>/);+ expect(html.indexOf("My Cloud move needs you")).toBeLessThan(html.indexOf(">Try again<"));+ // The words shorten before Try again does.+ expect(html).toContain('<span class="truncate">My Cloud move needs you</span>');+ expect(tag).toMatch(/class="[^"]*\bshrink-0\b/);+ const tryAgain = (status.props as { children: ReturnType<typeof createElement>[] }).children[1]!;+ (tryAgain.props as { onClick: () => void }).onClick();+ expect(onRetry).toHaveBeenCalledOnce();+ });++ it("while Try again runs: disabled and busy, with a spinner", () => {+ const html = markup(AccountMoveStatus({ kind: "failed", onOpen: noop, retry: { onRetry: noop, retrying: true, why: "My Cloud did not answer." } }));+ const tag = tryAgainTag(html);+ expect(tag).toContain('aria-busy="true"');+ expect(tag).toContain('aria-disabled="true"');+ expect(html).toMatch(/data-move-retry[^>]*>.*animate-spin.*Try again<\/button>/);+ });++ it("has no Try again on its way, inside a trigger, or when the move allows none", () => {+ const retry = { onRetry: noop, retrying: false, why: "" };+ expect(markup(AccountMoveStatus({ kind: "sending", onOpen: noop, retry }))).not.toContain("Try again");+ expect(markup(AccountMoveStatus({ kind: "failed", retry }))).not.toContain("Try again");+ expect(markup(AccountMoveStatus({ kind: "failed", onOpen: noop }))).not.toContain("Try again");+ });+});++describe("the move's row in the account menu", () => {+ const rows = (value: AccountMoveLine | null, patch: Partial<Parameters<typeof moveMenuItems>[1]> = {}) =>+ moveMenuItems(value, { onOpen: noop, onRetry: noop, onClose: noop, ...patch });++ it("failing: one row the size of the others that tries again, with why in its tooltip", () => {+ const onOpen = vi.fn(), onRetry = vi.fn();+ const items = rows(line({ phase: "copy", failing: { error: "Some of this computer's things did not reach My Cloud." } }), { onOpen, onRetry });+ expect(items).toHaveLength(1);+ expect(items[0]).toMatchObject({ key: "cloud-move", label: "Try My Cloud move again", title: "Some of this computer's things did not reach My Cloud.", disabled: false, keepOpen: true });+ expect(items[0]).not.toHaveProperty("note");+ expect(items[0]).not.toHaveProperty("wrap");+ expect(markup(items[0]!.icon)).not.toContain("animate-spin");+ items[0]!.onSelect();+ expect(onRetry).toHaveBeenCalledOnce();+ expect(onOpen).not.toHaveBeenCalled();+ // Main gave no reason: the tooltip still says what happened.+ expect(rows(line({ phase: "finishing", failing: { error: null } }))[0]!.title).toBe("Your bots couldn't move to My Cloud yet.");+ });++ it("failing: the same one row, disabled with a spinner, while Try again runs, and main's words when it did not answer", () => {+ const failing = line({ phase: "wait", failing: { error: "My Cloud did not answer." } });+ const busy = rows(failing, { retrying: true });+ expect(busy).toHaveLength(1);+ expect(busy[0]).toMatchObject({ label: "Try My Cloud move again", disabled: true });+ expect(markup(busy[0]!.icon)).toContain("animate-spin");+ expect(rows(failing, { unanswered: "OpenMausBot on this computer did not answer." })[0]!.title).toBe("OpenMausBot on this computer did not answer.");+ // Main gave no words: the reason it had stays.+ expect(rows(failing, { unanswered: "Your bots couldn't move to My Cloud yet." })[0]!.title).toBe("My Cloud did not answer.");+ });++ it("failing with no retry allowed: one row that opens My Cloud's settings", () => {+ const onOpen = vi.fn(), onRetry = vi.fn();+ const items = rows({ kind: "failed", text: "Your bots couldn't move to My Cloud yet.", extra: [], reason: "My Cloud is full." }, { onOpen, onRetry });+ expect(items).toHaveLength(1);+ expect(items[0]).toMatchObject({ key: "cloud-move", label: "My Cloud move needs you", title: "My Cloud is full." });+ items[0]!.onSelect();+ expect(onOpen).toHaveBeenCalledOnce();+ expect(onRetry).not.toHaveBeenCalled();+ });++ it("on its way: one short row, the progress in its tooltip, nothing else to press", () => {+ const onOpen = vi.fn();+ const items = rows(line({ phase: "copy", chats: { done: 34, total: 120 } }), { onOpen });+ expect(items).toHaveLength(1);+ expect(items[0]).toMatchObject({ key: "cloud-move", label: "Moving to My Cloud…", title: "Moving your bots to My Cloud… 34 of 120 chats" });+ expect(items[0]).not.toHaveProperty("wrap");+ expect(markup(items[0]!.icon)).toContain("animate-spin");+ expect(rows(line({ phase: "finishing" }))[0]).toMatchObject({ label: "Moving to My Cloud…", title: "Moving to My Cloud… almost done" });+ items[0]!.onSelect();+ expect(onOpen).toHaveBeenCalledOnce();+ });++ it("done: what arrived and what was held, the phone to pair, and Got it", () => {+ const onPairPhone = vi.fn(), onClose = vi.fn();+ const done = line({ phase: "done", counts: { bots: 4, skills: 2, logins: 2, onePassword: true, chats: 148, routines: 2 }, phone: true, held: ["OPENAI_API_KEY"] }, "cloud");+ const items = rows(done, { onPairPhone, onClose });+ expect(items.map((item) => item.key)).toEqual(["cloud-move", "cloud-move-phone", "cloud-move-close"]);+ expect(items[0]!.label).toBe("Everything from this computer is here: 4 bots, 2 skills, 2 logins, 1Password, 148 chats, and 2 routines.");+ expect(items[0]!.note).toContain("OPENAI_API_KEY");+ expect(items[1]!.label).toBe("Pair your phone with My Cloud");+ expect(items[2]!.label).toBe("Got it");+ items[1]!.onSelect();+ items[2]!.onSelect();+ expect(onPairPhone).toHaveBeenCalledOnce();+ expect(onClose).toHaveBeenCalledOnce();+ expect(rows(done).map((item) => item.key)).toEqual(["cloud-move", "cloud-move-close"]);+ expect(rows(line({ phase: "home-again" })).map((item) => item.key)).toEqual(["cloud-move", "cloud-move-close"]);+ });++ it("no move, no rows", () => {+ expect(rows(null)).toEqual([]);+ });+});++describe("useAccountMove", () => {+ it("says nothing without the one-time move, whatever an older desktop's send did, nor in a browser", async () => {+ expect(await shown(notice)).toEqual({ kind: null, items: [] });+ f.values = [];+ expect(await shown({ ...notice, running: true, runningReason: "first", last: { at: 3, reason: "first", failed: 2, seen: false, sent: { bots: 2, updatedBots: 0, skills: 0, logins: 0, onePassword: false, settings: 0, chats: null },+ reasons: [{ what: { bots: [], skills: 0, logins: 2, onePassword: false, settings: 0, chats: false }, error: "OpenMausBot on this computer did not answer." }] } })).toEqual({ kind: null, items: [] });+ f.values = [];+ vi.stubGlobal("window", {});+ expect(hook()).toEqual({ kind: null, items: [] });+ expect(lineHook()).toEqual({ kind: null, retry: null });+ });++ it("on its way on either page, with nothing to press", async () => {+ const bringing = await shown({ ...notice, move: { phase: "copy", chats: { done: 34, total: 120 } } }, true);+ expect(bringing.kind).toBe("sending");+ expect(bringing.items.map((item) => [item.label, item.title])).toEqual([["Moving to My Cloud…", "Bringing this computer's bots to My Cloud… 34 of 120 chats"]]);+ f.values = [];+ const waiting = await shown({ ...notice, move: { phase: "wait", waitingFor: "Scout" } });+ expect(waiting.items.map((item) => item.title)).toEqual(["Moving your bots to My Cloud… waiting for Scout to finish"]);+ expect(lineHook().retry).toBeNull();+ });++ it("after a day of failing, Try again runs the move's own retry, with a spinner meanwhile", async () => {+ const failing = await shown({ ...notice, move: { phase: "copy", failing: { error: "My Cloud did not answer." } } });+ expect(failing.kind).toBe("failed");+ let answer!: (value: CloudSendNotice) => void;+ page.moveRetry = vi.fn(() => new Promise<CloudSendNotice>((resolve) => { answer = resolve; }));+ failing.items[0]!.onSelect();+ expect(page.moveRetry).toHaveBeenCalledTimes(1);+ expect(hook().items[0]).toMatchObject({ key: "cloud-move", disabled: true });+ answer({ ...notice, move: { phase: "finishing" } }); await flush();+ expect(hook()).toMatchObject({ kind: "sending", items: [{ label: "Moving to My Cloud…" }] });+ });++ it("says main's words in the tooltip when Try again goes unanswered", async () => {+ const failing = await shown({ ...notice, move: { phase: "copy", failing: { error: "My Cloud did not answer." } } });+ page.moveRetry = vi.fn().mockRejectedValue(new Error("Error invoking remote method 'cloud-send:move-retry': Error: OpenMausBot on this computer did not answer."));+ failing.items[0]!.onSelect(); await flush();+ const after = hook();+ expect(after.items[0]).toMatchObject({ title: "OpenMausBot on this computer did not answer.", disabled: false });+ expect(lineHook().retry).toMatchObject({ retrying: false, why: "OpenMausBot on this computer did not answer." });+ });++ it("the line's Try again and the menu's are one: either runs it, both wait for it, and it runs once at a time", async () => {+ await shown({ ...notice, move: { phase: "copy", failing: { error: "My Cloud did not answer." } } });+ let answer!: (value: CloudSendNotice) => void;+ page.moveRetry = vi.fn(() => new Promise<CloudSendNotice>((resolve) => { answer = resolve; }));+ const before = lineHook();+ expect(before).toMatchObject({ kind: "failed", retry: { retrying: false, why: "My Cloud did not answer." } });+ before.retry!.onRetry();+ expect(lineHook().retry).toMatchObject({ retrying: true });+ expect(hook().items[0]).toMatchObject({ disabled: true });+ hook().items[0]!.onSelect();+ before.retry!.onRetry();+ expect(page.moveRetry).toHaveBeenCalledTimes(1);+ answer({ ...notice, move: { phase: "finishing" } }); await flush();+ expect(lineHook()).toEqual({ kind: "sending", retry: null });+ });++ it("My Cloud's page says once what arrived, with the phone to pair, until Got it", async () => {+ const done = await shown({ ...notice, move: { phase: "done", counts: { bots: 4, skills: 2, logins: 2, onePassword: true, chats: 148, routines: 2 }, phone: true, held: [] } }, true);+ expect(done.kind).toBe("done");+ expect(lineHook(true)).toEqual({ kind: "done", retry: null });+ done.items.find((item) => item.key === "cloud-move-phone")!.onSelect();+ expect(pair).toHaveBeenCalledOnce();+ done.items.find((item) => item.key === "cloud-move-close")!.onSelect(); await flush();+ expect(page.dismiss).toHaveBeenCalledWith("one-home");+ expect(hook(true)).toEqual({ kind: null, items: [] });+ // This computer's own page never says what arrived on My Cloud.+ f.values = [];+ expect((await shown({ ...notice, move: { phase: "done", phone: false, held: [] } })).kind).toBeNull();+ });++ it("the move's row opens My Cloud's settings when it does not retry", async () => {+ (await shown({ ...notice, move: { phase: "copy", chats: { done: 1, total: 2 } } })).items[0]!.onSelect();+ expect(open).toHaveBeenCalledOnce();+ });+});diff --git a/src/components/AccountMove.tsx b/src/components/AccountMove.tsxnew file mode 100644index 0000000000..cd7ae54775--- /dev/null+++ b/src/components/AccountMove.tsx@@ -0,0 +1,167 @@+// The one-time move to My Cloud in the account area at the bottom of the sidebar, never as a strip over the page: a+// short segment in the account's name, a line by the account (above it in Simple, under the name in Advanced), a dot+// on the avatar, and the move's own row at the top of the account menu. In the desktop app only, never in a browser.+import { useSyncExternalStore } from "react";+import { CloudAlert, CloudCheck, CloudUpload, Loader2, RefreshCw, Smartphone, X } from "lucide-react";+import type { CloudSendPageBridge } from "../../electron/cloud-send.mjs";+import { MOVE_LINE } from "../../electron/cloud-send-parts.mjs";+import { ipcErrorText, moveLine } from "@/lib/cloud-send";+import { cn } from "@/lib/cn";+import { t } from "@/lib/i18n";+import { useCloudSendNotice } from "./CloudSendStrip";+import type { SidebarMenuItem } from "./SidebarPopoverMenu";++export type AccountMoveLine = NonNullable<ReturnType<typeof moveLine>>;+export type AccountMoveKind = AccountMoveLine["kind"];++const pageBridge = () => (!window.ogb?.remoteClient?.active ? window.ogb?.cloudSendPage : undefined);++/** The account's words for the move: it needs the person once it has failed for a day, goes quietly meanwhile, and+ * says nothing once done (its menu row says what arrived). */+export function accountMoveWords(kind: AccountMoveKind | null): string | null {+ if (kind === "failed") return t("sidebar.account.moveNeedsYou");+ if (kind === "sending") return t("sidebar.account.moving");+ return null;+}++/** Why a failing move failed: main's words when Try again went unanswered, else the move's own reason. */+function failingWhy(line: AccountMoveLine, unanswered: string | null): string {+ const plain = t("cloudSend.move.failingPlain");+ return [unanswered && unanswered !== plain ? unanswered : line.reason, ...line.extra].filter(Boolean).join(" ") || plain;+}++/** The move's rows at the top of the account menu, each the size of every other row there. Failed: Try again, with why+ * in its tooltip and a spinner while it runs. On its way: one row, the progress in its tooltip. Done: what arrived, the+ * phone to pair, and Got it, which closes it for good. A row that does not retry opens My Cloud in Settings. */+export function moveMenuItems(line: AccountMoveLine | null, { retrying = false, unanswered = null, onOpen, onRetry, onPairPhone, onClose }: {+ retrying?: boolean;+ unanswered?: string | null;+ onOpen: () => void;+ onRetry: () => void;+ onPairPhone?: () => void;+ onClose: () => void;+}): SidebarMenuItem[] {+ if (!line) return [];+ if (line.kind === "failed") {+ const title = failingWhy(line, unanswered);+ if (!line.retry) return [{ key: "cloud-move", label: t("sidebar.account.moveNeedsYou"), title, icon: <CloudAlert size={16} className="text-warning" />, onSelect: onOpen }];+ return [{+ key: "cloud-move",+ label: t("sidebar.account.moveRetry"),+ title,+ icon: retrying ? <Loader2 size={16} className="animate-spin" /> : <RefreshCw size={16} className="text-warning" />,+ disabled: retrying,+ keepOpen: true,+ onSelect: onRetry,+ }];+ }+ if (line.kind === "sending") return [{ key: "cloud-move", label: t("sidebar.account.moving"), title: line.text, icon: <Loader2 size={16} className="animate-spin" />, onSelect: onOpen }];+ return [+ { key: "cloud-move", label: line.text, ...(line.extra.length ? { note: line.extra.join(" ") } : {}), wrap: true, icon: <CloudCheck size={16} />, onSelect: onOpen },+ ...(line.phone && onPairPhone ? [{ key: "cloud-move-phone", label: t("cloudSend.move.phone"), icon: <Smartphone size={16} />, onSelect: onPairPhone }] : []),+ { key: "cloud-move-close", label: t("sidebar.account.moveDismiss"), icon: <X size={16} />, onSelect: onClose },+ ];+}++type RetryState = { retrying: boolean; unanswered: string | null };+const IDLE: RetryState = { retrying: false, unanswered: null };++function retryStore() {+ let state = IDLE;+ const listeners = new Set<() => void>();+ return {+ get: () => state,+ set: (next: RetryState) => { state = next; for (const listener of listeners) listener(); },+ subscribe: (listener: () => void) => { listeners.add(listener); return () => { listeners.delete(listener); }; },+ };+}++// The window has one move, so the account's line and every account menu share its one Try again.+const retries = new WeakMap<CloudSendPageBridge, ReturnType<typeof retryStore>>();+const offPage = retryStore();+function retryOf(bridge: CloudSendPageBridge | undefined) {+ if (!bridge) return offPage;+ const known = retries.get(bridge);+ if (known) return known;+ const store = retryStore();+ retries.set(bridge, store);+ return store;+}++function useMove(cloudHome: boolean) {+ const bridge = pageBridge();+ const [notice, setNotice] = useCloudSendNotice(bridge);+ const store = retryOf(bridge);+ const { retrying, unanswered } = useSyncExternalStore(store.subscribe, store.get, store.get);+ const line = bridge && notice?.move ? moveLine(notice.move, cloudHome ? "cloud" : "local") : null;+ if (!bridge || !notice || !line) return null;+ const retry = () => {+ if (store.get().retrying) return;+ store.set({ retrying: true, unanswered: null });+ void (bridge.moveRetry?.() ?? Promise.resolve(notice)).then((next) => { setNotice(next); store.set(IDLE); })+ .catch((cause: unknown) => { store.set({ retrying: false, unanswered: ipcErrorText(cause) ?? t("cloudSend.move.failingPlain") }); });+ };+ const close = () => { void bridge.dismiss(MOVE_LINE).then(setNotice).catch(() => {}); };+ return { line, retrying, unanswered, retry, close };+}++/** The move as the account menu shows it: its kind and its rows, with the move's own Try again and close. */+export function useAccountMove(cloudHome: boolean, { onOpen, onPairPhone }: { onOpen: () => void; onPairPhone?: () => void }): {+ kind: AccountMoveKind | null;+ items: SidebarMenuItem[];+} {+ const move = useMove(cloudHome);+ if (!move) return { kind: null, items: [] };+ const { line, retrying, unanswered, retry, close } = move;+ return { kind: line.kind, items: moveMenuItems(line, { retrying, unanswered, onOpen, onRetry: retry, onPairPhone, onClose: close }) };+}++/** The line's Try again: what it runs, whether it is running, and why the move failed. */+export interface AccountMoveRetry {+ onRetry: () => void;+ retrying: boolean;+ why: string;+}++/** The move as Simple's line above the account shows it: its kind, and Try again while the failing move allows one. */+export function useAccountMoveLine(cloudHome: boolean): { kind: AccountMoveKind | null; retry: AccountMoveRetry | null } {+ const move = useMove(cloudHome);+ if (!move) return { kind: null, retry: null };+ const { line, retrying, unanswered, retry } = move;+ return { kind: line.kind, retry: line.kind === "failed" && line.retry ? { onRetry: retry, retrying, why: failingWhy(line, unanswered) } : null };+}++/** The account's line for the move: amber while it needs the person, quiet while it goes, nothing otherwise. With+ * `onOpen` its words are a button that opens the account menu, followed by Try again when `retry` allows one; without,+ * words inside a trigger. The words shorten before Try again does. */+export function AccountMoveStatus({ kind, retry = null, onOpen, className }: { kind: AccountMoveKind | null; retry?: AccountMoveRetry | null; onOpen?: () => void; className?: string }) {+ const words = accountMoveWords(kind);+ if (!words) return null;+ const Icon = kind === "failed" ? CloudAlert : CloudUpload;+ const look = cn("flex min-w-0 items-center gap-1.5 text-start text-[12px] leading-4", kind === "failed" ? "font-medium text-warning" : "text-ink-secondary");+ const body = <>+ <Icon size={13} aria-hidden="true" className="shrink-0" />+ <span className="truncate">{words}</span>+ </>;+ if (!onOpen) return <span data-account-move={kind} className={cn(look, className)}>{body}</span>;+ return (+ <div role="status" data-account-move={kind} className={cn("flex min-w-0 items-center gap-1.5", className)}>+ <button type="button" onClick={onOpen} className={cn(look, kind === "failed" ? "hover:underline" : "hover:text-ink")}>{body}</button>+ {kind === "failed" && retry && (+ <button+ type="button"+ data-move-retry+ aria-label={t("sidebar.account.moveRetryName")}+ aria-busy={retry.retrying || undefined}+ aria-disabled={retry.retrying || undefined}+ title={retry.why}+ onClick={retry.retrying ? undefined : retry.onRetry}+ className={cn("ui-button ui-button-sm shrink-0", retry.retrying && "cursor-progress")}+ >+ {retry.retrying && <Loader2 aria-hidden="true" className="size-3.5 shrink-0 animate-spin motion-reduce:animate-none" />}+ {t("cloudSend.strip.retry")}+ </button>+ )}+ </div>+ );+}diff --git a/src/components/CloudSendStrip.test.ts b/src/components/CloudSendStrip.test.tsindex 62b8dbe006..ac5b435038 100644--- a/src/components/CloudSendStrip.test.ts+++ b/src/components/CloudSendStrip.test.ts@@ -1,7 +1,8 @@-import { Children, createElement, isValidElement, type EffectCallback, type ReactElement, type ReactNode } from "react";+import { createElement, type EffectCallback, type ReactNode } from "react";import { renderToStaticMarkup } from "react-dom/server";import { afterEach, beforeEach, expect, it, vi } from "vitest";import type { CloudSendNotice, CloudSendPageBridge } from "../../electron/cloud-send.mjs";+import type { OneHomeView } from "../../electron/one-home.mjs";import { setLocale } from "@/lib/i18n";const f = vi.hoisted(() => ({ values: [] as unknown[], index: 0, effects: [] as EffectCallback[] }));vi.mock("react", async original => ({ ...await original<typeof import("react")>(),@@ -10,24 +11,13 @@ vi.mock("react", async original => ({ ...await original<typeof import("react")>(}));import { CloudSendStrip } from "./CloudSendStrip";-type Node = ReactElement<{ children?: ReactNode; onClick?: () => void }>;const flush = async () => { for (let i = 0; i < 20; i++) await Promise.resolve(); };-const deep = (value: ReactNode): Node[] => {- if (!isValidElement(value)) return [];- const node = value as Node;- return [node, ...Children.toArray(node.props.children).flatMap(deep)];-};-const text = (node: Node): string => Children.toArray(node.props.children).map((child) => isValidElement(child) ? text(child as Node) : String(child)).join("");const html = (component: () => ReactNode) => { f.index = 0; f.effects = []; return renderToStaticMarkup(createElement(component)).replaceAll("'", "'"); };-const tree = (component: () => ReactNode) => { f.index = 0; f.effects = []; return deep(component()); };-const button = (component: () => ReactNode, label: string) => tree(component).find((node) => node.type === "button" && text(node) === label);-const counts = { bots: 0, updatedBots: 0, skills: 0, logins: 0, onePassword: false, settings: 0, chats: null };const notice: CloudSendNotice = { ready: true, bots: ["Ember"], updatedBots: [], skills: 2, logins: 0, onePassword: true, settings: 0, signature: "sig-1", dismissed: false, running: false, last: null, whole: null };-let page: CloudSendPageBridge;-const strip = (cloudHome = true, onPairPhone?: () => void) => () => CloudSendStrip({ cloudHome, onPairPhone });-async function shown(value: CloudSendNotice, cloudHome = true) {- page = { notice: vi.fn().mockResolvedValue(value), dismiss: vi.fn().mockResolvedValue({ ...value, move: undefined }), onNotice: vi.fn(() => () => {}) };+const strip = (cloudHome: boolean) => () => CloudSendStrip({ cloudHome });+async function shown(value: CloudSendNotice, cloudHome: boolean) {+ const page: CloudSendPageBridge = { notice: vi.fn().mockResolvedValue(value), dismiss: vi.fn().mockResolvedValue({ ...value, move: undefined }), onNotice: vi.fn(() => () => {}) };vi.stubGlobal("window", { ogb: { cloudSendPage: page } });html(strip(cloudHome)); for (const effect of f.effects) effect(); await flush();}@@ -35,40 +25,48 @@ async function shown(value: CloudSendNotice, cloudHome = true) {beforeEach(() => { f.values = []; f.index = 0; f.effects = []; setLocale("en"); });afterEach(() => { vi.unstubAllGlobals(); });-it("says nothing without the one-time move, whatever an older desktop's send did", async () => {- await shown(notice);- expect(html(strip())).toBe("");- f.values = [];- await shown({ ...notice, running: true, runningReason: "first", last: { at: 3, reason: "first", failed: 2, seen: false, sent: { ...counts, bots: 2 },- reasons: [{ what: { bots: [], skills: 0, logins: 2, onePassword: false, settings: 0, chats: false }, error: "OpenMausBot on this computer did not answer." }] } });- expect(html(strip())).toBe("");-});+// Every state of the one-time move; its words live in the account area at the bottom of the sidebar (AccountMove).+const moves: OneHomeView[] = [+ { phase: "copy" },+ { phase: "copy", chats: { done: 34, total: 120 } },+ { phase: "copy", updating: true },+ { phase: "copy", failing: { error: "Some of this computer's things did not reach My Cloud." } },+ { phase: "wait", waitingFor: "Scout" },+ { phase: "wait", waitingFor: "", waitingWhat: "sign-in" },+ { phase: "wait", failing: { error: null } },+ { phase: "finishing" },+ { phase: "finishing", failing: { error: "My Cloud did not answer." } },+ { phase: "done", counts: { bots: 4, skills: 2, logins: 2, onePassword: true, chats: 148, routines: 2 }, phone: true, held: ["OPENAI_API_KEY"] },+ { phase: "keeping" },+ { phase: "keeping", updating: true },+ { phase: "home-again" },+ { phase: "back" },+ { phase: "back", lost: true },+ { phase: "back", elsewhere: { name: "Ada's MacBook", since: 1_760_000_000_000 } },+ { phase: "back", kept: true },+];-it("shows the move on its way on either page, with nothing to press", async () => {- await shown({ ...notice, move: { phase: "copy", chats: { done: 34, total: 120 } } });- expect(html(strip())).toContain("Bringing this computer's bots to My Cloud… 34 of 120 chats");- expect(tree(strip()).some((node) => node.type === "button")).toBe(false);- f.values = [];- await shown({ ...notice, move: { phase: "wait", waitingFor: "Scout" } }, false);- expect(html(strip(false))).toContain("Moving your bots to My Cloud… waiting for Scout to finish");- expect(tree(strip(false)).some((node) => node.type === "button")).toBe(false);+it("never draws the one-time move over the page, on either page, in any state", async () => {+ for (const move of moves) {+ for (const cloudHome of [false, true]) {+ f.values = [];+ await shown({ ...notice, move }, cloudHome);+ expect(html(strip(cloudHome)), `${move.phase} ${JSON.stringify(move)} on ${cloudHome ? "My Cloud" : "this computer"}`).toBe("");+ }+ }});-it("after a day of failing offers the move's own Try again", async () => {- await shown({ ...notice, move: { phase: "copy", failing: { error: "My Cloud did not answer." } } }, false);- page.moveRetry = vi.fn().mockResolvedValue({ ...notice, move: { phase: "finishing" } });- button(strip(false), "Try again")!.props.onClick!(); await flush();- expect(page.moveRetry).toHaveBeenCalledTimes(1);- expect(html(strip(false))).toContain("Moving to My Cloud… almost done");+it("says nothing without a move, whatever an older desktop's send did, nor in a browser", async () => {+ await shown({ ...notice, running: true, runningReason: "first", last: { at: 3, reason: "first", failed: 2, seen: false, sent: { bots: 2, updatedBots: 0, skills: 0, logins: 0, onePassword: false, settings: 0, chats: null },+ reasons: [{ what: { bots: [], skills: 0, logins: 2, onePassword: false, settings: 0, chats: false }, error: "OpenMausBot on this computer did not answer." }] } }, true);+ expect(html(strip(true))).toBe("");+ f.values = [];+ vi.stubGlobal("window", {});+ expect(html(strip(true))).toBe("");});-it("My Cloud's page says once what arrived, with the phone to pair, until closed", async () => {- const pair = vi.fn();- await shown({ ...notice, move: { phase: "done", counts: { bots: 4, skills: 2, logins: 2, onePassword: true, chats: 148, routines: 2 }, phone: true, held: [] } });- expect(html(strip(true, pair))).toContain("Everything from this computer is here: 4 bots, 2 skills, 2 logins, 1Password, 148 chats, and 2 routines.");- button(strip(true, pair), "Pair your phone with My Cloud")!.props.onClick!();- expect(pair).toHaveBeenCalledTimes(1);- button(strip(true, pair), "Close")!.props.onClick!(); await flush();- expect(page.dismiss).toHaveBeenCalledWith("one-home");- expect(html(strip(true, pair))).toBe("");+it("still shows a bot's move into a team on My Cloud's page while the one-time move has its own line", async () => {+ await shown({ ...notice, move: { phase: "done", phone: false, held: [] }, teamMove: { bot: { id: "scout", name: "Scout" }, team: { id: "team-acme", name: "Acme" }, phase: "moving" } }, true);+ expect(html(strip(true))).toContain("Moving Scout to Acme…");+ expect(html(strip(true))).not.toContain("Everything from this computer is here");});diff --git a/src/components/CloudSendStrip.tsx b/src/components/CloudSendStrip.tsxindex 1aadf55979..6b5f104e4f 100644--- a/src/components/CloudSendStrip.tsx+++ b/src/components/CloudSendStrip.tsx@@ -1,9 +1,6 @@import { useEffect, useState } from "react";-import { CloudUpload, Loader2 } from "lucide-react";-import { MOVE_LINE } from "../../electron/cloud-send-parts.mjs";import type { CloudSendNotice, CloudSendPageBridge } from "../../electron/cloud-send.mjs";-import { ipcErrorText, moveLine, moveQuietUntil } from "@/lib/cloud-send";-import { t } from "@/lib/i18n";+import { moveQuietUntil } from "@/lib/cloud-send";import { TeamMoveLine } from "./MoveToTeam";/** My Cloud's notice from main, kept fresh: undefined until main first answers, null when it can't. */@@ -38,36 +35,11 @@ export function useMoveQuiet(now: () => number = Date.now): boolean | null {return end > now();}-/** In the desktop app, never in a browser: the one-time move's line on either page (on its way, what arrived, coming- * home), and on My Cloud's page a bot's move into a team. Nothing to press while it goes; Try again only after a day of- * failing (a bot's move into a team: as soon as it fails). */-export function CloudSendStrip({ cloudHome, onPairPhone }: { cloudHome: boolean; onPairPhone?: () => void }) {+/** In the desktop app, never in a browser: on My Cloud's page, a bot's move into a team. The one-time move to My Cloud is+ * never a strip over the page: it lives in the account area at the bottom of the sidebar (AccountMove). */+export function CloudSendStrip({ cloudHome }: { cloudHome: boolean }) {const bridge = !window.ogb?.remoteClient?.active ? window.ogb?.cloudSendPage : undefined;const [notice, setNotice] = useCloudSendNotice(bridge);- const [retrying, setRetrying] = useState(false);- const [unanswered, setUnanswered] = useState<string | null>(null);- const move = notice?.move ? moveLine(notice.move, cloudHome ? "cloud" : "local") : null;- if (bridge && !move && notice?.teamMove && cloudHome) return <TeamMoveLine move={notice.teamMove} onChange={(next) => setNotice({ ...notice, teamMove: next ?? undefined })} />;- if (!bridge || !move) return null;- const retry = () => {- setRetrying(true);- setUnanswered(null);- void (bridge.moveRetry?.() ?? Promise.resolve(notice!)).then((next) => { setNotice(next); setRetrying(false); })- .catch((cause: unknown) => { setUnanswered(ipcErrorText(cause) ?? t("cloudSend.move.failingPlain")); setRetrying(false); });- };- const close = () => { void bridge.dismiss(MOVE_LINE).then(setNotice).catch(() => {}); };- return <div role="status" data-cloud-send-strip={move.kind} data-move-line={notice!.move!.phase} className="flex flex-wrap items-center justify-center gap-x-3 gap-y-1 border-b border-hairline/40 bg-panel px-3 py-1.5 text-[13px] text-ink-secondary">- {move.kind === "sending" || retrying ? <Loader2 size={14} aria-hidden="true" className="animate-spin" /> : <CloudUpload size={14} aria-hidden="true" />}- <span dir="auto" data-cloud-send-strip-line>{unanswered ?? move.text}</span>- {move.extra.map((line) => <span key={line} dir="auto" data-move-line-extra>{line}</span>)}- {move.phone && onPairPhone && <>- <button type="button" data-move-phone className="font-medium text-accent-text underline underline-offset-2 hover:text-ink" onClick={onPairPhone}>{t("cloudSend.move.phone")}</button>- <span aria-hidden="true">·</span>- </>}- {move.kind === "failed" && move.retry && !retrying && <>- <button type="button" data-cloud-send-retry className="font-medium text-accent-text underline underline-offset-2 hover:text-ink" onClick={retry}>{t("cloudSend.strip.retry")}</button>- <span aria-hidden="true">·</span>- </>}- {move.kind === "done" && <button type="button" className="hover:text-ink" onClick={close}>{t("cloudSend.strip.close")}</button>}- </div>;+ if (!bridge || !cloudHome || !notice?.teamMove) return null;+ return <TeamMoveLine move={notice.teamMove} onChange={(next) => setNotice({ ...notice, teamMove: next ?? undefined })} />;}diff --git a/src/components/SidebarFooter.tsx b/src/components/SidebarFooter.tsxindex 1f678ddad6..951600ef51 100644--- a/src/components/SidebarFooter.tsx+++ b/src/components/SidebarFooter.tsx@@ -1,7 +1,10 @@+import { useRef } from "react";+import { cn } from "@/lib/cn";import type { SidebarDensity } from "@/lib/sidebar-preferences";import { useStore } from "@/state/store";+import { AccountMoveStatus, useAccountMoveLine } from "./AccountMove";import { CloudUsageCard } from "./CloudUsageMeter";import { endCloudHowTo, useWorkspacePlace, type WorkspacePlace } from "./DesktopWorkspaceSwitcher";import { SidebarConnectApps } from "./SidebarConnectApps";@@ -22,12 +25,18 @@ export function SidebarPlaceStatus({ place, className }: { place: WorkspacePlace}function SimpleSidebarFooter({ owner, archived }: { owner: string | null; archived?: ArchivedBots }) {+ const { state } = useStore();const place = useSimplePlace();const account = useSimpleAccount(place, owner, archived);+ const move = useAccountMoveLine(state.config?.cloudHome === true);+ const footer = useRef<HTMLDivElement>(null);+ // The move's words open the account menu just below them, where the move's row is.+ const openAccount = () => footer.current?.querySelector("[data-sidebar-account]")?.closest("button")?.click();return (- <div data-sidebar-footer="simple" className="px-4 pb-4 pt-2">+ <div ref={footer} data-sidebar-footer="simple" className="px-4 pb-4 pt-2"><CloudUsageCard /><SidebarPlaceStatus place={place} className="mb-2 px-1" />+ <AccountMoveStatus kind={move.kind} retry={move.retry} onOpen={openAccount} className="ps-1" /><div className="flex items-center gap-2 not-first:mt-2"><SidebarProfileMenu simple={account} /><SidebarConnectApps />diff --git a/src/components/SidebarPopoverMenu.test.ts b/src/components/SidebarPopoverMenu.test.tsindex c8d3f1f2e9..290b8415d0 100644--- a/src/components/SidebarPopoverMenu.test.ts+++ b/src/components/SidebarPopoverMenu.test.ts@@ -35,3 +35,29 @@ it("draws an item's attention dot on the item itself, in its tone", () => {expect(item("Settings")).not.toMatch(/rounded-full bg-(accent|danger)/);expect(html.split('role="menu"')[0]).not.toMatch(/rounded-full bg-(accent|danger)/);});++it("lets a sentence wrap instead of cutting it short, with its icon on the first line", () => {+ const html = render([+ { key: "arrived", label: "Everything from this computer is here: 4 bots and 148 chats.", note: "OPENAI_API_KEY stayed on this computer.", wrap: true, icon: "!", onSelect: () => {} },+ { key: "sentence", label: "Everything from this computer is here: 4 bots, 2 skills and 148 chats.", wrap: true, onSelect: () => {} },+ { key: "plain", label: "Settings", onSelect: () => {} },+ ]);+ expect(html).toContain('<span class="break-words">Everything from this computer is here: 4 bots and 148 chats.</span>');+ expect(html).toContain('<span class="flex-1 min-w-0 break-words">Everything from this computer is here: 4 bots, 2 skills and 148 chats.</span>');+ expect(html).toMatch(/self-start[^"]*">!<\/span>/);+ expect(html).toContain('<span class="flex-1 truncate">Settings</span>');+});++it("puts what a one-line row leaves out in its tooltip, drawn the same as every other row", () => {+ const html = render([+ { key: "cloud-move", label: "Try My Cloud move again", title: "My Cloud did not answer.", icon: "!", keepOpen: true, onSelect: () => {} },+ { key: "settings", label: "Settings", icon: "!", onSelect: () => {} },+ ]);+ const row = (key: string) => html.match(new RegExp(`<button[^>]*data-menu-key="${key}"[^>]*>.*?</button>`))?.[0] ?? "";+ expect(row("cloud-move")).toContain('title="My Cloud did not answer."');+ expect(row("settings")).not.toContain("title=");+ const look = (key: string) => row(key).match(/ class="([^"]*)"/)?.[1];+ expect(look("settings")).toMatch(/\bitems-center\b/);+ expect(look("cloud-move")).toBe(look("settings"));+ expect(row("cloud-move")).toContain('<span class="flex-1 truncate">Try My Cloud move again</span>');+});diff --git a/src/components/SidebarPopoverMenu.tsx b/src/components/SidebarPopoverMenu.tsxindex c668510fde..2be786b2b5 100644--- a/src/components/SidebarPopoverMenu.tsx+++ b/src/components/SidebarPopoverMenu.tsx@@ -24,6 +24,10 @@ export interface SidebarMenuItem {keepOpen?: boolean;submenu?: SidebarMenuItem[];chevron?: boolean;+ /** a sentence that wraps instead of being cut short */+ wrap?: boolean;+ /** the row's tooltip, for what its one line leaves out */+ title?: string;onSelect: () => void;tourId?: string;}@@ -104,6 +108,7 @@ function MenuRows({role="menuitem"data-tour={item.tourId}data-menu-key={item.key}+ title={item.title}disabled={item.disabled}aria-haspopup={item.submenu ? "menu" : undefined}aria-expanded={item.submenu ? openSubmenu === item.key : undefined}@@ -117,19 +122,19 @@ function MenuRows({>{item.icon && (<span- className={cn("flex size-4 shrink-0 items-center justify-center [&>svg]:size-4", item.active ? "text-accent" : "text-ink-secondary")}+ className={cn("flex size-4 shrink-0 items-center justify-center [&>svg]:size-4", item.wrap && "h-[18px] self-start", item.active ? "text-accent" : "text-ink-secondary")}>{item.icon}</span>)}{item.subtitle || item.note ? (<span className="flex min-w-0 flex-1 flex-col">- <span className="truncate">{item.label}</span>+ <span className={item.wrap ? "break-words" : "truncate"}>{item.label}</span>{item.subtitle && <span className="truncate text-[12px] font-normal leading-4 text-ink-secondary">{item.subtitle}</span>}{item.note && <span className="text-[12px] font-normal leading-snug text-ink-tertiary">{item.note}</span>}</span>) : (- <span className="flex-1 truncate">{item.label}</span>+ <span className={cn("flex-1", item.wrap ? "min-w-0 break-words" : "truncate")}>{item.label}</span>)}{item.value && <span className="shrink-0 text-[13px] font-normal leading-[18px] tabular-nums text-ink-secondary">{item.value}</span>}{item.trailing}diff --git a/src/components/SidebarProfileMenu.test.ts b/src/components/SidebarProfileMenu.test.tsindex 4b3237c39d..0d9a0d6b76 100644--- a/src/components/SidebarProfileMenu.test.ts+++ b/src/components/SidebarProfileMenu.test.ts@@ -12,6 +12,7 @@ import {resetsIn,simplePhoneItems,simpleUpdateTop,+ accountDot,accountLabel,toolMenuItems,type PlanUsageWindows,@@ -37,6 +38,8 @@ import type { CloudMachine } from "../../electron/cloud-home.mjs";import { PHONE_APPS, PhoneAppDialog, type PhoneAppConnect } from "./PhoneAppDialog";import type { UpdaterState } from "@/lib/updater";import type { SidebarMenuItem } from "./SidebarPopoverMenu";+import { moveMenuItems } from "./AccountMove";+import { moveLine } from "@/lib/cloud-send";import { InitialsAvatar } from "./Avatar";const state = (patch: Partial<UpdaterState>): UpdaterState => ({ status: "idle", ...patch }) as UpdaterState;@@ -490,6 +493,61 @@ describe("Simple mode's account menu", () => {expect(accountLabel("Ada", { automationsNeedYou: true, update: "Update failed — try again" })).toBe("Ada · Automations need you · Update failed — try again");});+ it("adds the move to My Cloud: a short warning once failing, shared with automations, and a quiet segment on its way", () => {+ expect(accountLabel("Omkar", { automationsNeedYou: false, update: null, move: "failed" })).toBe("Omkar · My Cloud move needs you");+ expect(accountLabel("Omkar", { automationsNeedYou: true, update: null, move: "failed" })).toBe("Omkar · My Cloud move and automations need you");+ expect(accountLabel("Omkar", { automationsNeedYou: true, update: "Update ready", move: "failed" })).toBe("Omkar · My Cloud move and automations need you · Update ready");+ expect(accountLabel("Omkar", { automationsNeedYou: false, update: null, move: "sending" })).toBe("Omkar · Moving to My Cloud…");+ expect(accountLabel("Omkar", { automationsNeedYou: true, update: null, move: "sending" })).toBe("Omkar · Automations need you · Moving to My Cloud…");+ expect(accountLabel("Omkar", { automationsNeedYou: false, update: null, move: "done" })).toBe("Omkar");+ expect(accountLabel("Omkar", { automationsNeedYou: true, update: null, move: "done" })).toBe("Omkar · Automations need you");+ expect(accountLabel("Omkar", { automationsNeedYou: false, update: null, move: null })).toBe("Omkar");+ });++ it("raises the avatar's dot red for a failing move like automations, and none on its way or once done", () => {+ expect(accountDot({ automationsNeedYou: false, update: null, move: "failed" })).toBe("danger");+ expect(accountDot({ automationsNeedYou: true, update: null, move: "failed" })).toBe("danger");+ expect(accountDot({ automationsNeedYou: false, update: "news", move: "failed" })).toBe("danger");+ expect(accountDot({ automationsNeedYou: false, update: null, move: "sending" })).toBeNull();+ expect(accountDot({ automationsNeedYou: false, update: null, move: "done" })).toBeNull();+ expect(accountDot({ automationsNeedYou: false, update: "news", move: "done" })).toBe("accent");+ expect(accountDot({ automationsNeedYou: false, update: null, move: null })).toBeNull();+ expect(accountDot({ automationsNeedYou: true, update: null, move: null })).toBe("danger");+ expect(accountDot({ automationsNeedYou: false, update: "failed", move: null })).toBe("danger");+ expect(accountDot({ automationsNeedYou: false, update: "news", move: "sending" })).toBe("accent");+ });++ it("puts the move's row first, in its own group, above a raised update", () => {+ const move = [{ key: "cloud-move", label: "Try My Cloud move again", title: "My Cloud did not answer.", onSelect: noop }];+ const update = { key: "update", label: "OpenMausBot 0.2.0 ready, restart", onSelect: noop };+ expect(groups(build({ move }))).toEqual([+ ["cloud-move"],+ ["usage", "phone-app", "support", "settings"],+ ["automations", "team-map"],+ ["place", "switch-place", "account"],+ ]);+ expect(groups(build({ move, update, updateTop: { label: "Update ready", action: "Restart" } })).slice(0, 2)).toEqual([["cloud-move"], ["update"]]);+ expect(groups(build({ move: [] }))[0]).toEqual(["usage", "phone-app", "support", "settings"]);+ });++ it("gives a failing or moving move one row shaped like Usage and Settings: a label and an icon, no second line", () => {+ const shape = (item: SidebarMenuItem) => ({ lines: [item.subtitle, item.note].filter(Boolean).length, wrap: item.wrap === true, icon: Boolean(item.icon) });+ const failing = moveMenuItems(moveLine({ phase: "copy", failing: { error: "Some of this computer's things did not reach My Cloud." } }, "local"), { onOpen: noop, onRetry: noop, onClose: noop });+ const moving = moveMenuItems(moveLine({ phase: "copy", chats: { done: 34, total: 120 } }, "local"), { onOpen: noop, onRetry: noop, onClose: noop });+ for (const move of [failing, moving]) {+ const items = build({ move });+ expect(groups(items)[0]).toEqual(["cloud-move"]);+ const settings = items.find((item) => item.key === "settings")!;+ expect(shape(items[0]!)).toEqual(shape(settings));+ }+ });++ it("puts the move's row first in Advanced's account menu too, under its own divider", () => {+ const move = [{ key: "cloud-move", label: "Moving to My Cloud…", title: "Moving your bots to My Cloud… 34 of 120 chats", onSelect: noop }];+ expect(groups(build({ simple: undefined, move }))).toEqual([["cloud-move"], ["usage", "phone-app", "support", "settings", "update"], ["account"]]);+ expect(groups(build({ simple: undefined }))).toEqual([["usage", "phone-app", "support", "settings", "update"], ["account"]]);+ });+it("draws a person instead of a question mark for someone with no name, at the trigger's own size", () => {const glyph = createElement("svg", { "data-glyph": "" });const nameless = renderToStaticMarkup(createElement(InitialsAvatar, { initials: profileInitials({}), size: 36, fallback: glyph, fontSize: 14 }));diff --git a/src/components/SidebarProfileMenu.tsx b/src/components/SidebarProfileMenu.tsxindex 8214e437e8..fa7b43e2fc 100644--- a/src/components/SidebarProfileMenu.tsx+++ b/src/components/SidebarProfileMenu.tsx@@ -23,6 +23,7 @@ import {Zap,} from "lucide-react";+import { AccountMoveStatus, useAccountMove, type AccountMoveKind } from "./AccountMove";import { InitialsAvatar } from "./Avatar";import { DiscordIcon } from "./DiscordIcon";import { AboutDialog } from "./AboutDialog";@@ -346,9 +347,23 @@ export function toolMenuItems({ activeView, automationsNeedYou, onAutomations, o];}-/** The Simple account button's name: the person, then whatever its dot is raised for. */-export function accountLabel(name: string, { automationsNeedYou, update }: { automationsNeedYou: boolean; update: string | null }): string {- return [name, automationsNeedYou ? t("sidebar.account.automationsNeedYou") : "", update ?? ""].filter(Boolean).join(" · ");+/** The account button's name: the person, then whatever its dot is raised for, then the move to My Cloud while it goes.+ * A failing move and automations that need the person share one segment. */+export function accountLabel(name: string, { automationsNeedYou, update, move = null }: { automationsNeedYou: boolean; update: string | null; move?: AccountMoveKind | null }): string {+ const needsYou = move === "failed"+ ? t(automationsNeedYou ? "sidebar.account.moveAndAutomationsNeedYou" : "sidebar.account.moveNeedsYou")+ : automationsNeedYou ? t("sidebar.account.automationsNeedYou") : "";+ return [name, needsYou, move === "sending" ? t("sidebar.account.moving") : "", update ?? ""].filter(Boolean).join(" · ");+}++export type AccountDot = "danger" | "accent";+const DOT_COLOR: Record<AccountDot, string> = { danger: "bg-danger", accent: "bg-accent" };++/** The avatar's dot: red while automations, a failed update or the failing move to My Cloud need the person, the accent+ * for an update; none for the move on its way or done (what it brought waits in the menu). */+export function accountDot({ automationsNeedYou, update, move }: { automationsNeedYou: boolean; update: "failed" | "news" | null; move: AccountMoveKind | null }): AccountDot | null {+ if (automationsNeedYou || update === "failed" || move === "failed") return "danger";+ return update ? "accent" : null;}/** `besideRail`: the window's rail of places stands beside the page and switches places, so Switch to… isn't offered twice. */@@ -436,6 +451,7 @@ export function profileMenuItems({usageSummary = null,update,updateTop = null,+ move = [],account,simple,onUsage,@@ -451,6 +467,8 @@ export function profileMenuItems({usageSummary?: UsageSummary | null;update: SidebarMenuItem | null;updateTop?: { label: string; action: string } | null;+ /** the move to My Cloud's own rows, first of all (AccountMove) */+ move?: SidebarMenuItem[];account: string | null;simple?: { tools: SidebarMenuItem[]; places: SidebarMenuItem[] };onUsage: () => void;@@ -486,7 +504,10 @@ export function profileMenuItems({const settings: SidebarMenuItem = { key: "settings", label: t("sidebar.menu.settings"), icon: <SettingsIcon size={18} />, onSelect: onSettings };const accountItem: SidebarMenuItem | null = account ? { key: "account", label: account, icon: <CircleUserRound size={18} />, onSelect: onAccount } : null;const present = (...items: Array<SidebarMenuItem | null | false>) => items.filter((item): item is SidebarMenuItem => Boolean(item));- if (!simple) return [...present(usageItem), ...phone, support, settings, ...present(update), ...(accountItem ? [{ ...accountItem, separatorBefore: true }] : [])];+ if (!simple) {+ const rest = [...present(usageItem), ...phone, support, settings, ...present(update), ...(accountItem ? [{ ...accountItem, separatorBefore: true }] : [])];+ return [...move, ...rest.map((item, index) => (move.length && index === 0 ? { ...item, separatorBefore: true } : item))];+ }const raised: SidebarMenuItem | null = update && updateTop ? {...update,label: updateTop.label,@@ -495,6 +516,7 @@ export function profileMenuItems({trailing: <span className="flex h-6 shrink-0 items-center rounded-full bg-ink px-2.5 text-[12px] font-medium text-app">{updateTop.action}</span>,} : null;const groups = [+ move,present(raised),[...present(usageItem), ...phone, { ...support, submenu: raised ? help : [...help, ...present(update)] }, settings],simple.tools,@@ -555,6 +577,8 @@ export function SidebarProfileMenu({ iconOnly = false, rail = false, circle = faconst besideRail = railShown(usePlaces());const filesReady = useCloudFilesReady();const cloudAccount = !remote && Boolean(window.ogb?.cloudAccount || (window.ogb?.cloudPlan && state.config?.cloudHome === true));+ const openCloudAccount = () => dispatch({ type: "toggleAppSettings", open: true, section: "cloudAccount" });+ const move = useAccountMove(state.config?.cloudHome === true, { onOpen: openCloudAccount, onPairPhone: () => dispatch(phonePairingSettingsAction()) });const items = profileMenuItems({phone: simple@@ -569,6 +593,7 @@ export function SidebarProfileMenu({ iconOnly = false, rail = false, circle = fausageSummary: cloudUsage ?? engineUsage,update: update?.item ?? null,updateTop: simple ? simpleUpdateTop(update) : null,+ move: move.items,account: cloudAccount ? t("settings.section.cloudAccount") : null,...(account ? { simple: {tools: toolMenuItems({@@ -579,7 +604,7 @@ export function SidebarProfileMenu({ iconOnly = false, rail = false, circle = faonFiles: filesReady ? () => dispatch({ type: "showFiles" }) : undefined,archived: account.archived,}),- places: placeMenuItems(account.place, { owner: account.owner, besideRail, onCloudSettings: () => dispatch({ type: "toggleAppSettings", open: true, section: "cloudAccount" }) }),+ places: placeMenuItems(account.place, { owner: account.owner, besideRail, onCloudSettings: openCloudAccount }),} } : {}),onUsage: () => dispatch({ type: "toggleAppSettings", open: true, section: "usage" }),onSettings: () => dispatch({ type: "toggleAppSettings" }),@@ -590,13 +615,16 @@ export function SidebarProfileMenu({ iconOnly = false, rail = false, circle = faonAbout: () => setAboutOpen(true),onHelp: () => void openExternalLink(HELP_CENTER_URL),onFeedback: () => void openExternalLink(FEEDBACK_URL),- onAccount: () => dispatch({ type: "toggleAppSettings", open: true, section: "cloudAccount" }),+ onAccount: openCloudAccount,});const noteworthy = update && updateNoteworthy(update.phase, update.pending) && !updateHasButton(update.phase);const needsYou = account?.automationsNeedYou === true;const initials = profileInitials(profile);const nameless = simple && initials === "?" ? <UserRound size={18} strokeWidth={1.75} aria-hidden /> : undefined;- const label = simple ? accountLabel(name, { automationsNeedYou: needsYou, update: noteworthy && update ? update.label : null }) : name;+ const label = accountLabel(name, { automationsNeedYou: needsYou, update: simple && noteworthy && update ? update.label : null, move: move.kind });+ const dot = accountDot({ automationsNeedYou: needsYou, update: noteworthy ? (update.phase === "error" ? "failed" : "news") : null, move: move.kind });+ // Advanced's full row has its own update badge: its avatar's dot is the move's alone.+ const moveDot = accountDot({ automationsNeedYou: false, update: null, move: move.kind });return (<>@@ -615,15 +643,7 @@ export function SidebarProfileMenu({ iconOnly = false, rail = false, circle = faclassName={cn("relative flex size-9 items-center justify-center rounded-full ring-2 transition-shadow", open ? "ring-ink/15" : "ring-transparent hover:ring-ink/10")}><InitialsAvatar initials={initials} avatarUrl={profile?.avatarUrl} size={36} fallback={nameless} fontSize={14} className="ring-1 ring-inset ring-ink/[0.04]" />- {(noteworthy || needsYou) && (- <span- aria-hidden- className={cn(- "absolute -right-0.5 -top-0.5 size-2.5 rounded-full ring-2 ring-panel",- needsYou || update?.phase === "error" ? "bg-danger" : "bg-accent",- )}- />- )}+ {dot && <span aria-hidden data-account-dot={dot} className={cn("absolute -right-0.5 -top-0.5 size-2.5 rounded-full ring-2 ring-panel", DOT_COLOR[dot])} />}</span>) : iconOnly ? (<span@@ -636,15 +656,7 @@ export function SidebarProfileMenu({ iconOnly = false, rail = false, circle = fa)}><InitialsAvatar initials={initials} avatarUrl={profile?.avatarUrl} size={rail ? 30 : circle ? 26 : 28} />- {(noteworthy || needsYou) && (- <span- aria-hidden- className={cn(- "absolute end-1 top-1 size-2.5 rounded-full ring-2 ring-app",- needsYou || update?.phase === "error" ? "bg-danger" : "bg-accent",- )}- />- )}+ {dot && <span aria-hidden data-account-dot={dot} className={cn("absolute end-1 top-1 size-2.5 rounded-full ring-2 ring-app", DOT_COLOR[dot])} />}</span>) : (<span@@ -654,8 +666,14 @@ export function SidebarProfileMenu({ iconOnly = false, rail = false, circle = faopen ? "bg-raised" : "hover:bg-raised/50",)}>- <InitialsAvatar initials={profileInitials(profile)} avatarUrl={profile?.avatarUrl} size={28} />- <span className="min-w-0 flex-1 truncate text-[14px] font-medium leading-5 text-ink">{name}</span>+ <span className="relative flex shrink-0">+ <InitialsAvatar initials={profileInitials(profile)} avatarUrl={profile?.avatarUrl} size={28} />+ {moveDot && <span aria-hidden data-account-dot={moveDot} className={cn("absolute -right-0.5 -top-0.5 size-2 rounded-full ring-2 ring-app", DOT_COLOR[moveDot])} />}+ </span>+ <span className="flex min-w-0 flex-1 flex-col">+ <span className="truncate text-[14px] font-medium leading-5 text-ink">{name}</span>+ <AccountMoveStatus kind={move.kind} />+ </span>{noteworthy && (<spantitle={update.label}diff --git a/src/lib/cloud-send.ts b/src/lib/cloud-send.tsindex 47c8e8eb37..1437685254 100644--- a/src/lib/cloud-send.ts+++ b/src/lib/cloud-send.ts@@ -55,8 +55,8 @@ export function moveQuietUntil(move: OneHomeView | null | undefined): number {/** The one-time move's line on either page: on its way (with progress, or who it waits for), almost done, failing for a* day (with Try again), what arrived (on My Cloud's page, once), coming home, where the bots came home instead, or this* computer's bots on their way home and home because the person keeps them here.- * `page`: which page shows it. */-export function moveLine(move: OneHomeView, page: "local" | "cloud"): { kind: "sending" | "failed" | "done"; text: string; extra: string[]; phone?: true; retry?: true } | null {+ * `page`: which page shows it; `reason`: why a failing move failed, in main's words, when it said. */+export function moveLine(move: OneHomeView, page: "local" | "cloud"): { kind: "sending" | "failed" | "done"; text: string; extra: string[]; phone?: true; retry?: true; reason?: string } | null {if (move.phase === "done") {if (page !== "cloud") return null;const list = move.counts ? arrivedList(move.counts) : [];@@ -77,7 +77,10 @@ export function moveLine(move: OneHomeView, page: "local" | "cloud"): { kind: "s}if (move.phase === "copy" && move.updating) return { kind: "sending", text: t("cloudSend.move.updating"), extra: [] };const failing = "failing" in move ? move.failing : undefined;- if (failing) return { kind: "failed", text: failing.error ? t("cloudSend.move.failing", { error: failing.error }) : t("cloudSend.move.failingPlain"), extra: [], retry: true };+ if (failing) {+ return failing.error ? { kind: "failed", text: t("cloudSend.move.failing", { error: failing.error }), extra: [], retry: true, reason: failing.error }+ : { kind: "failed", text: t("cloudSend.move.failingPlain"), extra: [], retry: true };+ }if (move.phase === "finishing") return { kind: "sending", text: t("cloudSend.move.finishing"), extra: [] };// Who holds the move, by name, or what it is; nothing is claimed while it only waits for a quiet moment.if (move.phase === "wait" && move.waitingFor !== undefined) {diff --git a/src/locales/en.json b/src/locales/en.jsonindex 6a14fbe0c9..a4cf6a12a0 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -1836,6 +1836,12 @@"sidebar.section.deleteAria": "Delete {name} department","sidebar.profile.you": "You","sidebar.account.automationsNeedYou": "Automations need you",+ "sidebar.account.moveNeedsYou": "My Cloud move needs you",+ "sidebar.account.moveAndAutomationsNeedYou": "My Cloud move and automations need you",+ "sidebar.account.moving": "Moving to My Cloud…",+ "sidebar.account.moveDismiss": "Got it",+ "sidebar.account.moveRetry": "Try My Cloud move again",+ "sidebar.account.moveRetryName": "Try again to move to My Cloud","sidebar.menu.connectPhone": "Connect your phone","sidebar.menu.connectPhone.team": "to {team}","sidebar.menu.connectPhone.computer": "to this computer",