Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Accounts: nothing of the old sign-in runs mid-switch, and a failed switch recovers
milind-soni44966748a6d5
diff --git a/electron/accounts-main.mjs b/electron/accounts-main.mjsindex f28aa2e8c7..2d4d9d25a3 100644--- a/electron/accounts-main.mjs+++ b/electron/accounts-main.mjs@@ -98,6 +98,7 @@ export function installAccounts({ ipcMain, ownPage, placePage, account, client,});own("accounts:add-browser", () => ring().addBrowser());own("accounts:add-reopen", () => ring().addReopen());+ own("accounts:add-result", () => ring().addResult());own("accounts:add-cancel", () => ring().addCancel());own("accounts:sheet-pending", () => { const pending = sheetPending; sheetPending = false; return pending; });own("accounts:sheet-closed", () => { sheetPending = false; holdSheet(false); });diff --git a/electron/cloud-account.d.mts b/electron/cloud-account.d.mtsindex 9619e92aa9..50faf71588 100644--- a/electron/cloud-account.d.mts+++ b/electron/cloud-account.d.mts@@ -193,6 +193,8 @@ export interface AccountsBridge {addVerify(code: string): Promise<AccountAddResult>;addBrowser(): Promise<{ outcome: "browser" | "failed"; code?: string }>;addReopen(): Promise<void>;+ /** How the browser's way ended, asked once the list changes: null until it has. */+ addResult(): Promise<{ outcome: "switched" | "added" | "already" | "failed"; email?: string } | null>;addCancel(): Promise<void>;sheetPending(): Promise<boolean>;sheetClosed(): Promise<void>;diff --git a/electron/cloud-account.mjs b/electron/cloud-account.mjsindex cce535664e..7d96956564 100644--- a/electron/cloud-account.mjs+++ b/electron/cloud-account.mjs@@ -144,7 +144,10 @@ export function createCloudAccountClient({ store, openBrowser, platform, deviceNif (!closed) { timer = setTimer(() => { timer = null; void work().catch(() => {}); }, Math.max(1, delay)); timer?.unref?.(); }};const reset = () => { generation++; stopTimer(); controller.abort(); controller = new AbortController(); pending = null; emailed = null; verifiedUntil = 0; failures = 0; return generation; };- const current = stamp => !closed && generation === stamp;+ // `quiet`: another account is taking over (quiesce to reload): this sign-in's grant is still in memory, and nothing may ask for+ // it or write it over the one taking its place, whoever asks (a window coming to the front, Settings' Refresh).+ let quiet = false;+ const current = stamp => !closed && !quiet && generation === stamp;const versionHeader = text(appVersion, 40) && /^[0-9A-Za-z][0-9A-Za-z.+-]{0,39}$/.test(appVersion) ? { "x-openmausbot-version": appVersion } : {};async function request(route, { method = "GET", body, token, signal = controller.signal, path = `/api/cloud/desktop/${route}`, timeoutMs = 20_000 } = {}) {const response = await fetcher(`${origin}${path}`, {@@ -925,9 +928,10 @@ export function createCloudAccountClient({ store, openBrowser, platform, deviceNif (result?.ok !== true) throw new Error("Invalid Cloud consent response.");},/** Another account takes over: nothing more is asked or written for this sign-in. */- quiesce() { reset(); },+ quiesce() { quiet = true; reset(); },/** Reads the sign-in saved in `store` afresh: nothing of the one before stays. Told once, when the Admin has answered. */reload() {+ quiet = false;reset();grant = null; issued = null; cleanup = null; cleanupNeeded = false; plan = null; savedHint = null; opened = null; adding = null; renewalCloud = null; offerCache = null; waking = false;confirmations.clear();diff --git a/electron/cloud-accounts.mjs b/electron/cloud-accounts.mjsindex d7289fbfa5..0f5455d186 100644--- a/electron/cloud-accounts.mjs+++ b/electron/cloud-accounts.mjs@@ -20,7 +20,7 @@ const memoryStore = () => { let held = null; return { read: async () => held, wr* @param {{* active: { read(): Promise<any>, write(value: unknown): Promise<void> },* saved: { read(): Promise<any>, write(value: unknown): Promise<void> },- * client(): { state(): any, quiesce(): void, reload(): Promise<any>, signOut(): Promise<any>, refresh(): Promise<any>, revokeSaved(record: unknown): Promise<void> },+ * client(): { state(): any, quiesce(): void, reload(): Promise<any>, signOut(): Promise<any>, revokeSaved(record: unknown): Promise<void> },* makeClient(options: { store: any, onState(state: any): void }): any,* origin: string,* holding?(): string | null,@@ -41,7 +41,7 @@ const memoryStore = () => { let held = null; return { read: async () => held, wr* active account running until it succeeds.*/export function createCloudAccounts({ active, saved, client, makeClient, origin, holding = () => null, leaving = async () => {}, left = async () => {}, arriving = async () => {}, settled = async () => {}, removed = async () => {}, changed = () => {}, now = Date.now, log = () => {} }) {- let rows = [], known = false, queue = Promise.resolve(), adder = null;+ let rows = [], known = false, queue = Promise.resolve(), adder = null, browserResult = null;const serial = (work) => { const run = queue.then(work, work); queue = run.catch(() => {}); return run; };/** An unreadable file stays when the keychain is only locked (it throws here), and is replaced once it can never be read. */@@ -75,15 +75,19 @@ export function createCloudAccounts({ active, saved, client, makeClient, origin,const waiting = keep && usable(current, origin) ? current : null;await saved.write({ v: VERSION, accounts: [...list.filter((record) => record.account.id !== waiting?.account.id), ...(waiting ? [waiting] : [])] });client().quiesce();- try { await active.write(next); }- catch (error) { void client().refresh().catch(() => {}); throw error; }- await writeSaved([...list, ...(waiting ? [waiting] : [])], next.account.id);- await leaving(leavingId);- await left(leavingId);- await arriving(next.account.id);- await client().reload();- await settled();- changed();+ // Whatever fails from here, the sign-in reads its file again and the window goes where it belongs: a client left quiet would+ // do nothing until the app restarts.+ try {+ await active.write(next);+ await writeSaved([...list, ...(waiting ? [waiting] : [])], next.account.id);+ await leaving(leavingId);+ await left(leavingId);+ await arriving(next.account.id);+ } finally {+ await client().reload().catch((error) => log(`accounts: ${error?.message ?? error}`));+ await settled().catch((error) => log(`accounts: ${error?.message ?? error}`));+ changed();+ }}async function switchTo(id) {@@ -155,7 +159,10 @@ export function createCloudAccounts({ active, saved, client, makeClient, origin,endAdding();const store = memoryStore();const entry = { store, finished: null, client: null };- entry.client = makeClient({ store, onState: (state) => { if (state?.status === "connected" && store.held() && adder === entry) void finish(entry); } });+ entry.client = makeClient({ store, onState: (state) => {+ if (state?.status !== "connected" || !store.held() || adder !== entry || entry.finished) return;+ void finish(entry).catch((error) => { log(`accounts: ${error?.message ?? error}`); return { outcome: "failed" }; }).then((result) => { if (entry.browser) { browserResult = result; changed(); } });+ } });adder = entry;return entry;}@@ -199,9 +206,14 @@ export function createCloudAccounts({ active, saved, client, makeClient, origin,* account: its own page says which, and lets them change it. */addBrowser() {const entry = startAdding();+ entry.browser = true;+ browserResult = null;return entry.client.begin().then((state) => ({ outcome: state.status === "connecting" ? "browser" : "failed", ...(state.enrollment ? { code: state.enrollment.userCode } : {}) }));},addReopen: () => adder?.client.reopen().then(() => {}) ?? Promise.resolve(),+ /** How the browser's way ended, once: that account is in use now, was kept while a move finishes, or was in use already, so+ * the sheet waiting on it can say so. */+ addResult() { const result = browserResult; browserResult = null; return result; },addCancel() { if (adder && !adder.finished) { const entry = adder; adder = null; void entry.client.cancel().catch(() => {}).finally(() => entry.client.close()); } },close() { endAdding(); },};diff --git a/electron/cloud-accounts.node-test.mjs b/electron/cloud-accounts.node-test.mjsindex be9a24173d..eeb1d4ecc9 100644--- a/electron/cloud-accounts.node-test.mjs+++ b/electron/cloud-accounts.node-test.mjs@@ -45,7 +45,7 @@ async function world(t, { active = null, saved = null } = {}) {w.ring = createCloudAccounts({ active: activeStore, client: () => w.client, origin, now: () => w.now,saved: { read: async () => { if (w.readSaved) throw w.readSaved; return w.savedFile; }, write: async (value) => { w.writes.push(["saved", (value?.accounts ?? []).map((entry) => entry.account.id)]); w.savedFile = structuredClone(value); } },makeClient: ({ store, onState }) => createCloudAccountClient({ ...options, store, onState }),- holding: () => w.holding, leaving: async (id) => { w.calls.push(`leaving:${id}`); }, arriving: async (id) => { w.calls.push(`arriving:${id}`); }, settled: async () => { w.calls.push("settled"); }, removed: async (id) => { w.calls.push(`removed:${id}`); }, changed: () => w.calls.push("changed") });+ holding: () => w.holding, leaving: async (id) => { w.calls.push(`leaving:${id}`); await w.duringLeave?.(); }, arriving: async (id) => { w.calls.push(`arriving:${id}`); }, settled: async () => { w.calls.push("settled"); }, removed: async (id) => { w.calls.push(`removed:${id}`); }, changed: () => w.calls.push("changed") });return w;};w.boot = async () => { w.make(); await w.client.start(); await w.ring.start(); return w; };@@ -336,3 +336,102 @@ test("until the saved accounts have been read, there may be more than one: nothiawait w.ring.start();assert.equal(w.ring.count(), 1);});++test("while a switch is under way nothing of the old sign-in runs: a window coming to the front or Settings' Refresh can't write it over the new one", async (t) => {+ const w = await world(t);+ w.activeFile = w.grant("a"); w.savedFile = { v: 1, accounts: [w.grant("b")] };+ await w.boot();+ w.requests.length = 0;+ let during = null;+ w.duringLeave = async () => {+ assert.equal(w.activeFile.account.id, "acct-b", "the new sign-in is in the file by now");+ during = await w.client.refresh();+ assert.equal(w.activeFile.account.id, "acct-b", "and stays there");+ };+ assert.equal((await w.ring.switchTo("acct-b")).outcome, "switched");+ assert.ok(during, "a refresh mid-switch still answers");+ assert.deepEqual(w.requests.filter((row) => row.token === tokenOf("a")), [], "nothing was asked with the old token");+ assert.equal(w.activeFile.account.id, "acct-b");+ assert.deepEqual(w.ring.others().map((row) => row.id), ["acct-a"]);+ assert.equal(w.signedInAs(), "acct-b");+ assert.equal(w.client.state().status, "connected", "it runs again once the new sign-in is read");+});++test("a change of account that fails partway never leaves the sign-in stopped: it reads its file again, and the window goes where it belongs", async (t) => {+ const w = await world(t);+ w.activeFile = w.grant("a"); w.savedFile = { v: 1, accounts: [w.grant("b")] };+ await w.boot();+ w.calls.length = 0;+ w.duringLeave = async () => { throw new Error("the window wouldn't move"); };+ await assert.rejects(w.ring.switchTo("acct-b"), /wouldn't move/);+ assert.equal(w.signedInAs(), "acct-b", "the file says b, and the sign-in reads it");+ assert.equal(w.client.state().status, "connected");+ assert.ok(w.calls.includes("settled"), JSON.stringify(w.calls));+ await w.client.refresh();+ assert.equal(w.client.state().status, "connected", "a refresh works again");+});++test("a sign-in that can't be written stays the old account's, running again", async (t) => {+ const w = await world(t);+ w.activeFile = w.grant("a"); w.savedFile = { v: 1, accounts: [w.grant("b")] };+ await w.boot();+ w.failActive = true;+ await assert.rejects(w.ring.switchTo("acct-b"), /no keychain/);+ assert.equal(w.signedInAs(), "acct-a");+ assert.equal(w.client.state().status, "connected");+ assert.deepEqual(w.savedFile.accounts.map((record) => record.account.id).sort(), ["acct-a", "acct-b"], "neither sign-in is lost");+});++/** A ring whose Add another account runs through a fake browser sign-in: `w.browserFinished(letter)` is the browser coming back. */+function browserRing({ active = "a", holding = null } = {}) {+ const w = { active, changes: 0, signOuts: 0, activeFile: null, savedFile: null };+ const record = (letter) => ({ origin: "https://admin.test", token: tokenOf(letter), expiresAt: Date.now() + DAY, device: { id: `device-${letter}` }, account: person(letter) });+ w.activeFile = record(active);+ const state = () => ({ status: "connected", account: person(w.activeFile.account.id.at(-1)) });+ const client = { state, quiesce() {}, reload: async () => {}, signOut: async () => {}, revokeSaved: async () => {} };+ let fire = null, held = null;+ w.ring = createCloudAccounts({ origin: "https://admin.test", client: () => client, holding: () => holding, changed: () => { w.changes++; },+ active: { read: async () => w.activeFile, write: async (value) => { w.activeFile = value; } }, saved: { read: async () => w.savedFile, write: async (value) => { w.savedFile = value; } },+ makeClient: ({ store, onState }) => { fire = onState; held = store; return { begin: async () => ({ status: "connecting" }), signOut: async () => { w.signOuts++; }, close() {} }; } });+ w.browserFinished = async (letter) => { await held.write(record(letter)); fire({ status: "connected" }); for (let i = 0; i < 20; i++) await new Promise((resolve) => setImmediate(resolve)); };+ return w;+}++test("the browser's way says how it ended: the account in use already, one kept during a move, one switched to, once each", async () => {+ const already = browserRing();+ await already.ring.start();+ await already.ring.addBrowser();+ assert.equal(already.ring.addResult(), null, "nothing yet");+ await already.browserFinished("a");+ assert.deepEqual(already.ring.addResult(), { outcome: "already", email: "[email protected]" }, "the sheet isn't left waiting");+ assert.equal(already.ring.addResult(), null, "told once");+ assert.equal(already.signOuts, 1, "the extra sign-in ends at once");+ assert.ok(already.changes > 0, "the page is told to look");+ const moving = browserRing({ holding: "moving" });+ await moving.ring.start();+ await moving.ring.addBrowser();+ await moving.browserFinished("b");+ assert.deepEqual(moving.ring.addResult(), { outcome: "added", email: "[email protected]" });+ const fresh = browserRing();+ await fresh.ring.start();+ await fresh.ring.addBrowser();+ await fresh.browserFinished("b");+ assert.deepEqual(fresh.ring.addResult(), { outcome: "switched", email: "[email protected]" });+});++test("the browser's way failing says so rather than leaving the sheet waiting", async () => {+ const w = browserRing();+ await w.ring.start();+ await w.ring.addBrowser();+ w.savedFile = { v: 99, accounts: [] };+ await w.browserFinished("b");+ assert.deepEqual(w.ring.addResult(), { outcome: "failed" });+});++test("the emailed code's way answers directly, and leaves nothing for the browser's way to say", async (t) => {+ const w = await world(t);+ w.activeFile = w.grant("a");+ await w.boot();+ assert.equal((await w.addByCode("b")).outcome, "switched");+ assert.equal(w.ring.addResult(), null);+});diff --git a/electron/included-x.mjs b/electron/included-x.mjsindex b655092529..def96f606f 100644--- a/electron/included-x.mjs+++ b/electron/included-x.mjs@@ -52,7 +52,9 @@ export function createIncludedXSync({ fetchAccess, send, device = paidDevice })if (access) { held = { deviceId, access }; refused = null; send(access); }else { held = null; refused = key; send(null, { offered: false }); }} catch {- // Offline or the Admin is down: the next state change tries again.+ // Offline or the Admin is down: the next state change tries again. Another sign-in's token never stays with the server+ // meanwhile: the account in use just changed, and its bots would run on the one before.+ if (held && held.deviceId !== deviceId && planKey(latest) === key) { held = null; send(null); }} finally {inflight = null;}diff --git a/electron/included-x.test.mjs b/electron/included-x.test.mjsindex 2020c82fee..517305bdb8 100644--- a/electron/included-x.test.mjs+++ b/electron/included-x.test.mjs@@ -44,6 +44,17 @@ describe("included X research access on the desktop", () => {expect(sent).toEqual([access, access]);});+ it("a change of account with the Admin down: the account before's token doesn't stay with the server", async () => {+ const fetchAccess = vi.fn(async () => access);+ const { x, sent } = sync(fetchAccess);+ await x.onState(paid("device-a"));+ fetchAccess.mockRejectedValueOnce(new Error("offline"));+ await x.onState(paid("device-b"));+ expect(sent).toEqual([access, null]);+ await x.onState(paid("device-b"));+ expect(sent).toEqual([access, null, access]);+ });+it("sends nothing for a free account, and null when the Admin says the plan is not active", async () => {const free = sync();await free.x.onState({ status: "connected", deviceId: "d", entitlement: { plan: "free", status: "inactive", tier: null } });diff --git a/electron/preload.cjs b/electron/preload.cjsindex af002a394b..cae58c3995 100644--- a/electron/preload.cjs+++ b/electron/preload.cjs@@ -505,6 +505,7 @@ const bridge = {addVerify: code => ipcRenderer.invoke("accounts:add-verify", String(code)),addBrowser: () => ipcRenderer.invoke("accounts:add-browser"),addReopen: () => ipcRenderer.invoke("accounts:add-reopen"),+ addResult: () => ipcRenderer.invoke("accounts:add-result"),addCancel: () => ipcRenderer.invoke("accounts:add-cancel"),sheetPending: () => ipcRenderer.invoke("accounts:sheet-pending"),sheetClosed: () => ipcRenderer.invoke("accounts:sheet-closed"),diff --git a/src/components/AccountMenu.tsx b/src/components/AccountMenu.tsxindex 9b0d9f9cb6..d35c96b5d4 100644--- a/src/components/AccountMenu.tsx+++ b/src/components/AccountMenu.tsx@@ -109,17 +109,20 @@ function AddAccount({ start, onDone, onBack }: { start: string; onDone: (note: selse { setCode(""); setPhase({ ...at, problem: result.outcome, triesLeft: result.outcome === "wrong-code" ? result.triesLeft : null }); }}, () => setPhase({ ...at, problem: "failed", triesLeft: null })).finally(() => setBusy(false));};- // The browser's way ends in main; the sheet closes once the account it brought is the one in use.+ // The browser's way ends in main, which says how once the list changes: the account in use now, kept for after a move, or the+ // one in use already. Nothing else tells the sheet, and it would wait on "Finish signing in" for ever.useEffect(() => {if (!browser || !bridge) return;- let before: AccountsView["active"] | undefined;- const look = () => { void bridge.list().then((view) => {- if (before === undefined) { before = view.active; return; }- if (view.active && !view.active.signIn && (view.active.id !== before?.id || before?.signIn)) onDone(null);+ const look = () => { void bridge.addResult().then((result) => {+ if (!result) return;+ if (result.outcome === "switched") onDone(null);+ else if (result.outcome === "added") onDone(t("accounts.added", { email: result.email ?? email }));+ else if (result.outcome === "already") onDone(t("accounts.already", { email: result.email ?? email }));+ else { setBrowser(false); setPhase({ step: "email", intent: false, problem: "failed" }); }}).catch(() => {}); };look();return bridge.onChanged(look);- }, [browser, bridge, onDone]);+ }, [browser, bridge, onDone, email]);if (browser) return <div data-accounts-browser className={SCREEN}><Heading title={t("accounts.browserTitle")} sub={t("accounts.browserBody")} /><button type="button" className={QUIET} onClick={() => { void bridge?.addReopen().catch(() => {}); }}>{t("accounts.browserOpen")}</button>diff --git a/src/components/PlacesRail.test.ts b/src/components/PlacesRail.test.tsindex 291afa25c8..5b7848f77e 100644--- a/src/components/PlacesRail.test.ts+++ b/src/components/PlacesRail.test.ts@@ -443,3 +443,84 @@ it("a server of the person's own that main offers as home: its menu's one tap stawait settle();expect(host.querySelector("[data-rail-menu]"), "started: the menu closes, and the account says how it goes").toBeNull();});++const ALICE = "[email protected]", BOB = "[email protected]";+const accounts = { list: vi.fn(async () => ({ active: { id: "a", email: ALICE } })), onChanged: vi.fn(() => () => {}), signOut: vi.fn(), addStart: vi.fn(), addVerify: vi.fn(), addBrowser: vi.fn(), addReopen: vi.fn(), addCancel: vi.fn(async () => {}) };+const TWO_ACCOUNTS: RailPlace[] = [+ place("local", "This computer", { kind: "computer", active: true }),+ place("a1", "My Cloud", { color: "purple", group: "active", email: ALICE }),+ place("a2", "Acme", { kind: "team", group: "active", email: ALICE }),+ place("b1", "My Cloud", { color: "teal", group: "b", email: BOB }),+ place("account:c", "[email protected]", { kind: "account", group: "c", email: "[email protected]" }),+ place("vps", "Office", { kind: "server", group: "hand" }),+];++it("one account: no divider and no address, exactly as before", async () => {+ await mount(createElement(PlacesRail));+ expect(host.querySelector("[data-rail-divider]")).toBeNull();+ expect(host.innerHTML).not.toContain("@");+});++it("several accounts: a thin divider between groups, This computer first, and each tooltip names the account, so two called My Cloud can be told apart", async () => {+ rail = { places: TWO_ACCOUNTS, add: { cloud: true, link: true, address: false } };+ await mount(createElement(PlacesRail));+ expect(host.querySelectorAll("[data-rail-divider]").length).toBe(4);+ const items = [...host.querySelectorAll("nav li")].map((row) => [row.querySelector("[data-rail-divider]") !== null, row.querySelector("[data-rail-place]")?.getAttribute("data-rail-place")]);+ expect(items).toEqual([[false, "local"], [true, "a1"], [false, "a2"], [true, "b1"], [true, "account:c"], [true, "vps"]]);+ expect(host.querySelector('[data-rail-place="a1"]')?.getAttribute("title")).toBe(`My Cloud · ${ALICE}`);+ expect(host.querySelector('[data-rail-place="b1"]')?.getAttribute("title")).toBe(`My Cloud · ${BOB}`);+ expect(host.querySelector('[data-rail-place="vps"]')?.getAttribute("title")).toBe("Office");+ expect(host.querySelector('[data-rail-place="account:c"]')?.getAttribute("title")).toBe("[email protected]");+});++it("a click on another account's place asks main by its id; a refusal shows the plain line, and nothing else moves", async () => {+ rail = { places: TWO_ACCOUNTS, add: { cloud: true, link: true, address: false } };+ Object.assign(window, { ogb: { workspaces, cloudAdd, accounts } });+ workspaces.open.mockResolvedValueOnce({ outcome: "moving" } as never);+ await mount(createElement(PlacesRail));+ await click(host.querySelector('[data-rail-place="b1"]'));+ await act(async () => { await Promise.resolve(); });+ expect(workspaces.open.mock.calls).toEqual([["b1"]]);+ expect(host.querySelector("[data-accounts-note]")?.textContent).toContain("moving to the Cloud");+ expect(host.querySelector("[data-accounts-sign-out]")).toBeNull();+});++it("a saved account whose sign-in ended: its tile says so, and a click opens the emailed code for that address", async () => {+ const ended = TWO_ACCOUNTS.map((row) => (row.id === "b1" ? { ...row, signIn: true as const } : row));+ rail = { places: ended, add: { cloud: true, link: true, address: false } };+ Object.assign(window, { ogb: { workspaces, cloudAdd, accounts } });+ workspaces.open.mockResolvedValueOnce({ outcome: "sign-in", email: BOB } as never);+ await mount(createElement(PlacesRail));+ expect(host.querySelector('[data-rail-place="b1"]')?.getAttribute("title")).toBe(`My Cloud · ${BOB} · Sign in again`);+ await click(host.querySelector('[data-rail-place="b1"]'));+ await act(async () => { await Promise.resolve(); });+ expect((host.querySelector("#cloud-add-email") as HTMLInputElement | null)?.value).toBe(BOB);+});++it("+ offers Add another account while someone is signed in, and it opens the sign-in over the window", async () => {+ rail = { places: TWO_ACCOUNTS, add: { cloud: true, link: true, address: false, account: true } };+ Object.assign(window, { ogb: { workspaces, cloudAdd, accounts } });+ await mount(createElement(PlacesRail));+ await click(host.querySelector("[data-rail-add]"));+ await click(host.querySelector('[data-place-add-choice="account"]'));+ await act(async () => { await Promise.resolve(); });+ expect(host.querySelector("[data-place-add-sheet]")).toBeNull();+ expect((host.querySelector("#cloud-add-email") as HTMLInputElement | null)?.value).toBe("");+});++it("past eight, ⋯ keeps the groups, each under its address, and search finds a place by its account's address", async () => {+ const many = [place("local", "This computer", { kind: "computer" }), ...Array.from({ length: 5 }, (_, at) => place(`a${at}`, `A ${at}`, { group: "active", email: ALICE })), ...Array.from({ length: 5 }, (_, at) => place(`b${at}`, `B ${at}`, { group: "b", email: BOB }))];+ rail = { places: many, add: { cloud: false, link: false, address: false } };+ await mount(createElement(PlacesRail));+ await click(host.querySelector("[data-rail-more-button]"));+ const groups = [...host.querySelectorAll("[data-rail-more] [data-rail-group]")].map((row) => row.textContent);+ expect(groups).toEqual([ALICE, BOB]);+ expect(matchingPlaces(many, "bob@").map((row) => row.id)).toEqual(["b0", "b1", "b2", "b3", "b4"]);+});++it("colours stay per Cloud, whichever account it belongs to", async () => {+ rail = { places: TWO_ACCOUNTS, add: { cloud: false, link: false, address: false } };+ await mount(createElement(PlacesRail));+ const fill = (id: string) => (host.querySelector(`[data-rail-place="${id}"] [aria-hidden="true"][style]`) as HTMLElement | null)?.getAttribute("style");+ expect(fill("a1")).not.toEqual(fill("b1"));+});