Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Merge the follow-up's latest into the rail

milind-sonib3fd3c9c4a16
diff --cc electron/accounts-main.mjs
index c5960020b9,a3816fb1db..c04c2f3377
--- a/electron/accounts-main.mjs
+++ b/electron/accounts-main.mjs
@@@ -71,18 -34,21 +71,17 @@@ export function createDesktopRing(deps
* placePage(event: unknown): boolean,
* account(): { state(): any } | null,
* client(): { state(): any, signOut(): Promise<any> },
+ * ring(): ReturnType<typeof import("./cloud-accounts.mjs").createCloudAccounts> | null,
* holdSheet(open: boolean): void,
* tellSheet(): void,
- * leaving(): void,
- * leave: ReturnType<typeof createAccountLeave>,
- * show(): Promise<unknown>,
* tell(): void,
- * clean?(): boolean,
- * }} deps `clean`: the clean workspace runs (clean-workspace.mjs). `ownPage`: this app's own page in the window, or the rail's. `placePage`: the page of a place of the person's own
+ * }} deps `ownPage`: this app's own page in the window, or the rail's. `placePage`: the page of a place of the person's own
- * or their team's, which may offer the sheet. `holdSheet`: the rail's page stays up for the sheet, even for someone who hid
- * the rail. `leaving`: the home window lets go of what it was doing for this account; `leave`: createAccountLeave's;
- * `show`: the window goes where it belongs now; `tell`: this app's pages read the list again.
+ * or their team's, which may offer the sheet. `ring`: the accounts kept on this device. `holdSheet`: the rail's page stays up
+ * for the sheet, even for someone who hid the rail. `tell`: this app's pages read the list again.
*/
- export function installAccounts({ ipcMain, ownPage, placePage, account, client, ring, holdSheet, tellSheet, tell, clean = () => false }) {
-export function installAccounts({ ipcMain, ownPage, placePage, account, client, holdSheet, tellSheet, leaving, leave, show, tell }) {
- let sheetPending = false, queue = Promise.resolve();
++export function installAccounts({ ipcMain, ownPage, placePage, account, client, ring, holdSheet, tellSheet, tell }) {
+ let sheetPending = false;
- const view = () => ({ ...accountsView(account()?.state()), ...(clean() ? { clean: true } : {}) });
+ const view = () => accountsView(account()?.state());
- const serial = (work) => { const run = queue.then(work, work); queue = run.catch(() => {}); return run; };
const own = (channel, handler) => ipcMain.handle(channel, (event, ...args) => {
if (!ownPage(event)) throw new Error(`${channel} is only available on this app's own page`);
return handler(...args);
diff --cc electron/cloud-account.d.mts
index 186a3a18de,ffcfe742b0..50faf71588
--- a/electron/cloud-account.d.mts
+++ b/electron/cloud-account.d.mts
@@@ -174,16 -174,7 +174,15 @@@ export interface CloudAccountBridge
}
/** Who is signed in on this device, as the You menu shows it. `signIn`: this account's sign-in has ended here. */
export interface AccountRow { id: string; email: string; signIn?: true }
- /** `clean`: the clean workspace runs on this computer, whose line asks the person to sign in. */
- export interface AccountsView { active: AccountRow | null; clean?: true }
-export interface AccountsView { active: AccountRow | null; others: AccountRow[] }
++export interface AccountsView { active: AccountRow | null }
+export interface AccountSwitchResult { outcome: "switched" | "signed-out" | "moving" | "sign-in" | "gone" | "failed"; email?: string; view: AccountsView }
+/** What a click on a place of another account answers when it didn't switch: nothing moved. `sign-in`: that sign-in has ended. */
+export interface RailOpenResult { outcome: "switched" | "moving" | "sign-in" | "gone" | "failed"; email?: string }
+/** `added`: kept signed in, not switched to, while this computer's move finishes; `already`: that account is the one signed in. */
+export type AccountAddResult =
+ | { outcome: "switched" | "added" | "already"; email?: string; view: AccountsView }
+ | { outcome: "wrong-code"; triesLeft: number }
+ | { outcome: Exclude<import("./cloud-signin.mjs").CloudSignInVerifyFailure, "wrong-code"> };
/** This app's own pages only: main refuses any other page. Absent on an older app. */
export interface AccountsBridge {
list(): Promise<AccountsView>;
diff --cc electron/main.mjs
index dde97fb576,182e4e4a5f..9997fb24c6
--- a/electron/main.mjs
+++ b/electron/main.mjs
@@@ -2688,8 -2688,8 +2688,8 @@@ const chromeRail = createChromeRail({ c
chromeRail.install(ipcMain);
function railChanged() { chromeRail.refresh(); rail.changed(); }
const accountPages = [() => (mainWindow && !mainWindow.isDestroyed() && senderIsLocal({ sender: mainWindow.webContents }) ? mainWindow.webContents : null), () => ({ send: channel => chromeRail.send(channel) })];
- const accountRing = createDesktopRing({ allowed: () => app.isPackaged && !desktopRemoteAccess, active: cloudAccountStore, savedStore: () => createCloudAccountStore({ file: path.join(app.getPath("userData"), cloudTarget(process.env).saved), encryption: cloudEncryption }), stash: () => jsonFile(path.join(app.getPath("userData"), cloudTarget(process.env).places)), client: ensureCloudAccount, origin: cloudTarget(process.env).origin, makeClient: ({ store, onState }) => createCloudAccountClient({ store, onState, platform: process.platform, deviceName: os.hostname().slice(0, 100) || "My computer", appVersion: app.getVersion(), origin: cloudTarget(process.env).origin, openBrowser: url => shell.openExternal(url) }), saved: () => environmentsState, persist: persistEnvironments, session: () => session.defaultSession, mine: () => myCloud(), leaveWindow: () => (mainWindow && !mainWindow.isDestroyed() && !senderIsLocal({ sender: mainWindow.webContents }) ? navigateMainWindow(rendererOrigin()) : null), rows: () => railList(), holding: () => oneHome.holding(), letGo: id => { homeWindow.accountLeaving(); homePlaces.remember(null); computerSharing?.leaveAccount(id); }, lendingDone: () => computerSharing?.goodbyesDone(), settled: () => showHome(), forgetLending: env => sharingController().forget(env), tell: () => { accounts.tell(); railChanged(); }, log: slog }); const accounts = installAccounts({ ipcMain, clean: () => cleanWorkspace.active(), ownPage: event => chromeRail.owns(event) || cloudPageAsking(event) === "local", placePage: event => cloudPageAsking(event) !== null || ownCloudPage(event) !== null || homeWindow.homePage(event) || (Boolean(ownHome?.home()) && activeEnvironment(environmentsState)?.origin === ownHome.home().origin && workspaceSenderAllowed(event, mainWindow?.webContents, environmentsState, rendererOrigin())), account: () => (app.isPackaged && !desktopRemoteAccess ? cloudAccount : null), client: ensureCloudAccount, ring: accountRing, holdSheet: open => chromeRail.holdOpen(open), tellSheet: () => chromeRail.send("accounts:open-sheet"), tell: () => { for (const page of accountPages) page()?.send("accounts:changed"); } });
-const accounts = installAccounts({ ipcMain, ownPage: event => chromeRail.owns(event) || cloudPageAsking(event) === "local", placePage: event => cloudPageAsking(event) !== null || ownCloudPage(event) !== null || homeWindow.homePage(event) || (Boolean(ownHome?.home()) && activeEnvironment(environmentsState)?.origin === ownHome.home().origin && workspaceSenderAllowed(event, mainWindow?.webContents, environmentsState, rendererOrigin())), account: () => (app.isPackaged && !desktopRemoteAccess ? cloudAccount : null), client: ensureCloudAccount, holdSheet: open => chromeRail.holdOpen(open), tellSheet: () => chromeRail.send("accounts:open-sheet"), leaving: () => homeWindow.accountLeaving(), leave: createAccountLeave({ saved: () => environmentsState, persist: persistEnvironments, session: () => session.defaultSession, mine: () => myCloud(), leaveWindow: () => (mainWindow && !mainWindow.isDestroyed() && !senderIsLocal({ sender: mainWindow.webContents }) ? navigateMainWindow(rendererOrigin()) : null), settled: () => computerSharing?.goodbyesDone(), log: slog }), show: () => showHome(), tell: () => { for (const page of accountPages) page()?.send("accounts:changed"); } });
-const rail = installCloudRail({ ipcMain, clipboard, openCloud: openOwnCloud, account: () => (app.isPackaged && !desktopRemoteAccess ? cloudAccount : null),
++const accountRing = createDesktopRing({ allowed: () => app.isPackaged && !desktopRemoteAccess, active: cloudAccountStore, savedStore: () => createCloudAccountStore({ file: path.join(app.getPath("userData"), cloudTarget(process.env).saved), encryption: cloudEncryption }), stash: () => jsonFile(path.join(app.getPath("userData"), cloudTarget(process.env).places)), client: ensureCloudAccount, origin: cloudTarget(process.env).origin, makeClient: ({ store, onState }) => createCloudAccountClient({ store, onState, platform: process.platform, deviceName: os.hostname().slice(0, 100) || "My computer", appVersion: app.getVersion(), origin: cloudTarget(process.env).origin, openBrowser: url => shell.openExternal(url) }), saved: () => environmentsState, persist: persistEnvironments, session: () => session.defaultSession, mine: () => myCloud(), leaveWindow: () => (mainWindow && !mainWindow.isDestroyed() && !senderIsLocal({ sender: mainWindow.webContents }) ? navigateMainWindow(rendererOrigin()) : null), rows: () => railList(), holding: () => oneHome.holding(), letGo: id => { homeWindow.accountLeaving(); homePlaces.remember(null); computerSharing?.leaveAccount(id); }, lendingDone: () => computerSharing?.goodbyesDone(), settled: () => showHome(), forgetLending: env => sharingController().forget(env), tell: () => { accounts.tell(); railChanged(); }, log: slog }); const accounts = installAccounts({ ipcMain, ownPage: event => chromeRail.owns(event) || cloudPageAsking(event) === "local", placePage: event => cloudPageAsking(event) !== null || ownCloudPage(event) !== null || homeWindow.homePage(event) || (Boolean(ownHome?.home()) && activeEnvironment(environmentsState)?.origin === ownHome.home().origin && workspaceSenderAllowed(event, mainWindow?.webContents, environmentsState, rendererOrigin())), account: () => (app.isPackaged && !desktopRemoteAccess ? cloudAccount : null), client: ensureCloudAccount, ring: accountRing, holdSheet: open => chromeRail.holdOpen(open), tellSheet: () => chromeRail.send("accounts:open-sheet"), tell: () => { for (const page of accountPages) page()?.send("accounts:changed"); } });
+const rail = installCloudRail({ ipcMain, clipboard, openCloud: openOwnCloud, switchAccount: id => accountRing().switchTo(id), account: () => (app.isPackaged && !desktopRemoteAccess ? cloudAccount : null),
guard: handler => (event, ...args) => (chromeRail.owns(event) ? handler(event, ...args) : workspaceOnly(handler)(event, ...args)),
lists: event => chromeRail.owns(event), trusted: event => chromeRail.owns(event) || senderIsLocal(event), beside: () => chromeRail.shown(),
targets: () => [mainWindow && !mainWindow.isDestroyed() ? mainWindow.webContents : null, { send: channel => chromeRail.send(channel), isDestroyed: () => false }],
diff --cc src/components/AccountMenu.test.ts
index ec19b5b538,44deaf9766..7da1a201dd
--- a/src/components/AccountMenu.test.ts
+++ b/src/components/AccountMenu.test.ts
@@@ -42,17 -25,8 +42,16 @@@ it("another place's page shows no addre
expect(openSheet).toHaveBeenCalled();
});
+it("what a click or sign-out that didn't go through says, in plain words", () => {
+ expect(switchNote({ outcome: "moving" })).toContain("moving to the Cloud");
+ expect(switchNote({ outcome: "gone" })).toContain("isn't signed in here");
+ expect(switchNote({ outcome: "failed" })).toContain("Try again");
+ expect(switchNote({ outcome: "switched" })).toBeNull();
+ expect(switchNote({ outcome: "signed-out" })).toBeNull();
+});
+
- it("the MausBot Cloud row says Sign in only while the clean workspace's line asks for it", () => {
- expect(cloudRowLabel({ active: null, clean: true })).toBe("Sign in");
- expect(cloudRowLabel({ active: null })).toBe("MausBot Cloud");
- expect(cloudRowLabel({ active: { id: "b", email: "[email protected]" }, clean: true })).toBe("MausBot Cloud");
+ it("the MausBot Cloud row says Sign in while nobody is signed in here; any other page keeps its name", () => {
- expect(cloudRowLabel({ active: null, others: [] })).toBe("Sign in");
- expect(cloudRowLabel({ active: { id: "b", email: "[email protected]" }, others: [] })).toBe("MausBot Cloud");
++ expect(cloudRowLabel({ active: null })).toBe("Sign in");
++ expect(cloudRowLabel({ active: { id: "b", email: "[email protected]" } })).toBe("MausBot Cloud");
expect(cloudRowLabel(null)).toBe("MausBot Cloud");
});
diff --cc src/components/AccountMenu.tsx
index f22bb08f08,d37a16e12a..ac01050154
--- a/src/components/AccountMenu.tsx
+++ b/src/components/AccountMenu.tsx
@@@ -62,16 -40,14 +62,16 @@@ export function useAccounts(): Accounts
};
}
- /** The You menu's row for the MausBot Cloud page: with the clean workspace open and nobody signed in, the line there asks the person
- * to sign in, and this row is how. */
+ /** The You menu's row for the MausBot Cloud page, on this app's own page: Sign in while nobody is signed in here, so whoever was
+ * told to sign in finds the words. Any other page knows nothing of who is signed in. */
export function cloudRowLabel(view: AccountsView | null): string {
- return t(view?.clean && !view.active ? "accounts.signIn" : "settings.section.cloudAccount");
+ return t(view && !view.active ? "accounts.signIn" : "settings.section.cloudAccount");
}
-/** The You menu's last rows. On another page, one row that opens the sheet. Signed out: nothing, as Settings has the sign-in. */
-export function accountMenuItems({ view, openSheet, signOut }: AccountsAccess): SidebarMenuItem[] {
+/** The You menu's last rows: who is signed in here and Sign out. The other accounts are on the rail, and so is Add another account,
+ * in its +; with no rail beside this page (nothing to list but This computer, or the person hid it) it is here. On another page,
+ * one row that opens the sheet, with no address. Signed out: nothing, as Settings has the sign-in. */
+export function accountMenuItems({ view, openSheet, noRail, signOut, add }: AccountsAccess): SidebarMenuItem[] {
if (openSheet) return [{ key: "accounts-sheet", label: t("accounts.manage"), icon: <UserRound size={18} />, onSelect: openSheet }];
const active = view?.active;
if (!active) return [];
diff --cc src/components/HomeLine.test.ts
index 7eefd42530,2e59ac8648..0b8d990f5a
--- a/src/components/HomeLine.test.ts
+++ b/src/components/HomeLine.test.ts
@@@ -63,10 -63,9 +63,10 @@@ it("the clean workspace's line says th
ais.instances = [{ ready: true, instanceId: "claude", driver: "claudeCode" }];
const line = vi.fn().mockResolvedValue({ kind: "clean" });
await mount(line);
- await vi.waitFor(() => expect(host.querySelector("[data-home-line='clean']")?.textContent).toBe("Your bots are in your Cloud. Sign in to get them."));
+ await vi.waitFor(() => expect(host.querySelector("[data-home-line='clean']")?.textContent).toBe("Your bots are in the Cloud. Sign in to get them."));
expect(host.querySelector("button")).toBeNull();
- expect(homeLineText({ kind: "clean" })).toBe("Your bots are in your Cloud. Sign in to get them.");
+ expect(homeLineText({ kind: "clean" })).toBe("Your bots are in the Cloud. Sign in to get them.");
+ expect(homeLineText({ kind: "clean", saved: true })).toBe("Your bots are in your other account's Cloud. Click its icon at the side to get them.");
});
it("with the new-user setup skipped, the clean workspace still offers connecting an AI while none is ready", async () => {
diff --cc src/locales/en.json
index 987da8dc3a,b5c9b371b1..211d207ba6
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@@ -7067,8 -7056,7 +7067,8 @@@
"homeScreen.planNamed": "{name} isn't running",
"homeScreen.setupNamed": "Setting up {name}…",
"homeLine.left": "You're no longer in {name}.",
- "homeLine.clean": "Your bots are in your Cloud. Sign in to get them.",
+ "homeLine.clean": "Your bots are in the Cloud. Sign in to get them.",
+ "homeLine.cleanSaved": "Your bots are in your other account's Cloud. Click its icon at the side to get them.",
"teamMove.menu": "Move to {team}",
"teamMove.title": "Move {bot} to {team}?",
"teamMove.everyone": "Everyone in {team} can use {bot}. Only {team}'s admins can change it.",