Skip to content

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

Together: the + asks where a new bot lives (this computer or My Cloud) (#6099)

Milind Soni5c919b7adb10
diff --git a/electron/main.mjs b/electron/main.mjs
index 6c70770ca3..73e78a9bdc 100644
--- a/electron/main.mjs
+++ b/electron/main.mjs
@@ -2622,7 +2622,7 @@ function showHome(options) {
return homeWindow.show(options).catch(error => slog(`home: ${error?.message ?? error}`));
}
const showStartPlace = () => openStartPlace({ home: homeWindow, places: homePlaces, profiles: localProfiles, log: slog, server: id => { const entry = environmentsState.environments.find(candidate => candidate.id === id && handSaved(candidate)); return entry ? reopenSavedServer(entry, { saved: () => environmentsState.environments.filter(handSaved), fetch: (...args) => session.defaultSession.fetch(...args), opened: async (found) => { if (!mainWindow || mainWindow.isDestroyed()) createWindow({ deferNavigation: true }); persistEnvironments(withActive(environmentsState, found.id)); return navigateMainWindow(activeOrigin()); } }) : Promise.resolve(false); } }).catch(error => slog(`start: ${error?.message ?? error}`)); const openOwnCloud = id => { homeWindow.cancel(); return showHome({ place: { cloud: id, name: environmentsState.environments.find(entry => entry.cloud?.id === id)?.name } }); };
-const placeInbox = createPlaceInboxWatch({ places: () => [{ id: LOCAL_ID, local: true }, ...environmentsState.environments.filter(entry => entry.kind !== "local" && entry.origin)], activeId: () => environmentsState.activeId, local: localServerRequest, cloudFetch: (...args) => session.defaultSession.fetch(...args), asleep: origin => homeWindow.asleepAt(origin), shown: () => !desktopRemoteAccess && serverReady && Boolean(mainWindow && !mainWindow.isDestroyed() && mainWindow.isVisible()), changed: () => railChanged() }); const homeOfUrl = url => { let at = null; try { at = new URL(url); } catch { return null; } return at.origin === rendererOrigin() ? (at.pathname === HOME_SCREEN_PATH ? null : "computer") : at.origin === myCloud() ? "cloud" : null; }; const shownHome = () => { const page = mainWindow && !mainWindow.isDestroyed() ? mainWindow.webContents : null; return page && !page.isLoadingMainFrame() ? homeOfUrl(page.getURL()) : null; }; const placesTogether = installPlacesTogether({ ipcMain, asking: cloudPageAsking, together: createPlacesTogether({ pref: jsonFile(path.join(app.getPath("userData"), PLACES_TOGETHER_FILE)), cloud: () => ({ origin: myCloud(), account: cloudAccount?.state().account?.id ?? null, asleep: cloudPower.asleep() }), powerChecked: async () => { const account = cloudAccount; if (!account) return false; await account.refresh(); return Date.now() - (account.state().verifiedAt ?? 0) < 5_000; }, computer: () => !(homeWindow.cloudOrigin() ?? ownHome?.origin()), local: localServerRequest, cloudFetch: (...args) => session.defaultSession.fetch(...args), napped: () => cloudPower.hold(), shown: shownHome, focused: () => powerMonitor.getSystemIdleState(60) !== "locked" && Boolean(mainWindow && !mainWindow.isDestroyed() && mainWindow.isFocused()), openPlace: home => { const entry = home === "cloud" ? environmentsState.environments.find(candidate => candidate.origin === myCloud()) : null; return home === "cloud" && (!entry || myCloud() === homeWindow.cloudOrigin()) ? showHome({ place: "cloud" }) : workspaceMenuAction(() => switchEnvironment(entry?.id ?? LOCAL_ID)); }, send: (channel, value) => { if (shownHome()) mainWindow.webContents.send(channel, value); }, changed: () => { if (shownHome()) mainWindow.webContents.send("places-together:changed"); } }) });
+const placeInbox = createPlaceInboxWatch({ places: () => [{ id: LOCAL_ID, local: true }, ...environmentsState.environments.filter(entry => entry.kind !== "local" && entry.origin)], activeId: () => environmentsState.activeId, local: localServerRequest, cloudFetch: (...args) => session.defaultSession.fetch(...args), asleep: origin => homeWindow.asleepAt(origin), shown: () => !desktopRemoteAccess && serverReady && Boolean(mainWindow && !mainWindow.isDestroyed() && mainWindow.isVisible()), changed: () => railChanged() }); const homeOfUrl = url => { let at = null; try { at = new URL(url); } catch { return "other"; } return at.origin === rendererOrigin() ? (at.pathname === HOME_SCREEN_PATH ? "waking" : "computer") : at.origin === myCloud() ? "cloud" : "other"; }; const placeShown = () => { const page = mainWindow && !mainWindow.isDestroyed() ? mainWindow.webContents : null; return page && !page.isLoadingMainFrame() ? homeOfUrl(page.getURL()) ?? "other" : null; }; const shownHome = () => { const place = placeShown(); return place === "computer" || place === "cloud" ? place : null; }; const placesTogether = installPlacesTogether({ ipcMain, asking: cloudPageAsking, together: createPlacesTogether({ pref: jsonFile(path.join(app.getPath("userData"), PLACES_TOGETHER_FILE)), cloud: () => ({ origin: myCloud(), account: cloudAccount?.state().account?.id ?? null, asleep: cloudPower.asleep() }), powerChecked: async () => { const account = cloudAccount; if (!account) return false; await account.refresh(); return Date.now() - (account.state().verifiedAt ?? 0) < 5_000; }, computer: () => !(homeWindow.cloudOrigin() ?? ownHome?.origin()), local: localServerRequest, cloudFetch: (...args) => session.defaultSession.fetch(...args), napped: () => cloudPower.hold(), shown: placeShown, focused: () => powerMonitor.getSystemIdleState(60) !== "locked" && Boolean(mainWindow && !mainWindow.isDestroyed() && mainWindow.isFocused()), openPlace: home => { const entry = home === "cloud" ? environmentsState.environments.find(candidate => candidate.origin === myCloud()) : null; return home === "cloud" && (!entry || myCloud() === homeWindow.cloudOrigin()) ? showHome({ place: "cloud" }) : workspaceMenuAction(() => switchEnvironment(entry?.id ?? LOCAL_ID)); }, send: (channel, value) => { if (shownHome()) mainWindow.webContents.send(channel, value); }, changed: () => { if (shownHome()) mainWindow.webContents.send("places-together:changed"); } }) });
const localProfiles = createLocalProfiles({ registry: createProfileRegistry({ dataDir: desktopDataDir }), clean: cleanWorkspace, dataDir: desktopDataDir, allowed: () => app.isPackaged && !desktopRemoteAccess, home: () => (homeWindow.cloudOrigin() ? "cloud" : ownHome?.origin() || cleanWorkspace.marker().frozen ? null : "local"), window: { openProfile: id => homeWindow.openProfile(id), profile: () => homeWindow.profile(), showCloud: () => showHome({ place: "cloud" }) }, showLocal: () => { homeWindow.cancel(); persistEnvironments(withActive(environmentsState, LOCAL_ID)); return navigateMainWindow(rendererOrigin()); }, onLocal: () => Boolean(mainWindow && !mainWindow.isDestroyed() && senderIsLocal({ sender: mainWindow.webContents })), busy: async () => { const said = await (await localServerRequest("/api/move/freeze", { signal: AbortSignal.timeout(5_000) })).json(); return typeof said?.busy === "string" ? { name: said.busy, what: said.what } : null; }, trash: dir => shell.trashItem(dir), reserved: () => nativeT(process.platform === "darwin" ? "rail.thisMac" : "rail.thisPc"), remember: homePlaces.remember, changed: () => railChanged(), log: slog }); const railList = () => { ownHome?.refresh(); const settling = localProfiles.settling(); return railPlaces({ saved: environmentsState, waiting: placeInbox.waiting, home: homeWindow.cloudOrigin() ?? ownHome?.origin() ?? null, mine: myCloud(), state: desktopRemoteAccess ? null : cloudAccount?.state(), offers: entry => !desktopRemoteAccess && ownHome?.offers(entry) === true, accounts: accountRing.waiting(), profiles: localProfiles.places({ activeLocal: environmentsState.activeId === LOCAL_ID }), computerSettling: settling && settling.id === null ? settling.name : null }); };
// The rail as the window's own chrome (chrome-rail.mjs): this app's page beside every place's page, the one that lists.
const placeSwitch = createPlaceSwitch({ changed: () => railChanged(), stop: () => homeWindow.stopOpening(), kept: () => homePlaces.remembered(), pageSettled: () => { const page = mainWindow && !mainWindow.isDestroyed() ? mainWindow.webContents : null; if (page?.isLoadingMainFrame()) return new Promise(done => { page.once("did-stop-loading", done); page.once("destroyed", done); }); } }); const openPlace = (id, stale) => workspaceMenuAction(async () => { if (id === LOCAL_ID) await cleanWorkspace.settled(); if (!stale()) await switchEnvironment(id, stale); }); const chromeRail = createChromeRail({ createView: options => new WebContentsView(options), preload: path.join(__dirname, "preload.cjs"), log: slog, prefs: () => desktopPrefs, changed: () => rail.changed(), openComputer: (page) => openComputerSettings({ window: () => mainWindow, onLocal: (win) => senderIsLocal({ sender: win.webContents }), showLocal: () => placeSwitch.ask(LOCAL_ID, stale => { localProfiles.cancel(); return openPlace(LOCAL_ID, stale); }) }, page),
diff --git a/electron/places-together.d.mts b/electron/places-together.d.mts
index b0cbbf5980..2cbfd2cb11 100644
--- a/electron/places-together.d.mts
+++ b/electron/places-together.d.mts
@@ -26,7 +26,7 @@ export interface PlacesTogetherState {
here: BotHome;
/** The other place's bots while the switch is on. `state`: how that place is doing: asleep, waking and offline keep the
* bots it gave last; "signin" is a My Cloud this window has not signed in to yet, which lists none. */
- other: { home: BotHome; state: "ready" | "loading" | "asleep" | "waking" | "offline" | "signin"; bots: PlaceBotRow[] } | null;
+ other: { home: BotHome; state: "ready" | "loading" | "asleep" | "waking" | "offline" | "signin"; bots: PlaceBotRow[]; newBot?: boolean } | null;
}
/** `window.ogb.placesTogether`: this computer's page and My Cloud's own page. */
@@ -37,6 +37,20 @@ export interface PlacesTogetherBridge {
/** Opens the other place at one of its listed bots. False when main does not list that bot. */
open(botId: string): Promise<boolean>;
onChanged(callback: () => void): () => void;
+ /** The other place as the + shows it: how it is doing and the AIs ready there (null while it can't be asked). Null with the switch off. */
+ newBotChoice(): Promise<NewBotChoice | null>;
+ /** Opens the other place, which makes a new bot there by its own rules. False with the switch off, and for a place
+ * whose page would not hear it (`other.newBot` false: it runs a version from before this). */
+ newBot(): Promise<boolean>;
+ /** The other place asked this one to make a new bot. */
+ onNewBot(callback: () => void): () => void;
+}
+
+export interface NewBotChoice {
+ home: BotHome;
+ state: NonNullable<PlacesTogetherState["other"]>["state"];
+ /** Each ready AI's name as the person sees it there, and its kind. */
+ ais: Array<{ name: string; kind: string }> | null;
}
export const PLACES_TOGETHER_FILE: string;
diff --git a/electron/places-together.mjs b/electron/places-together.mjs
index f38c8b6026..d78284fbc6 100644
--- a/electron/places-together.mjs
+++ b/electron/places-together.mjs
@@ -19,6 +19,10 @@ export const FRESH_MS = 4_000;
export const CLOUD_EVERY_MS = 60_000;
/** A row's click waits this long for its place to open (a Cloud may have to wake), and no longer. */
export const OPEN_WAIT_MS = 2 * 60_000;
+/** A new bot asked for in the other place waits only as long as a wake takes (a stopped Cloud answers in about 20 s). */
+export const NEW_BOT_WAIT_MS = 45_000;
+/** The page that was told to make a new bot says it heard within this long, or is told to forget it. */
+export const NEW_BOT_ACK_MS = 10_000;
const TIMEOUT_MS = 10_000;
const MAX_BOTS = 500;
const ID = /^[\w-]{1,128}$/;
@@ -55,6 +59,20 @@ export function botRow(bot, home) {
...(body ? { mascotBody: body } : {}), ...(face ? { mascotFaceColor: face } : {}), ...(bot.chiefOfStaff === true ? { chief: true } : {}), ...rowState(bot) };
}
+/** The AIs a place's `GET /api/instances` answer says are ready to use: installed and signed in, never one that only
+ * works through free no-login models. Each as its name and its kind; the page words them. */
+export function readyAis(body) {
+ const instances = record(body) && Array.isArray(body.instances) ? body.instances : [];
+ const ready = (instance) => record(instance) && record(instance.snapshot) && instance.snapshot.state === "available" && instance.snapshot.freeFallback !== true
+ && (instance.driverKind === "clineAgent" ? instance.snapshot.authenticated === true : instance.access === "custom" || instance.snapshot.authenticated !== false);
+ const seen = new Set();
+ return instances.filter(ready).map((instance) => ({ name: text(instance.displayName, 60), kind: text(instance.driverKind, 40) }))
+ .filter((ai) => ai.name && !seen.has(ai.name) && seen.add(ai.name)).slice(0, 20);
+}
+
+/** Whether a place's `GET /api/bots` answer says its page makes a new bot when the person's other place asks. */
+export const makesNewBots = (body) => record(body) && record(body.together) && body.together.newBot === true;
+
/** A place's `GET /api/bots` answer as rows, in that place's own order. */
export function botRows(body, home) {
const bots = record(body) && Array.isArray(body.bots) ? body.bots : [];
@@ -73,7 +91,7 @@ const needsSignIn = (response) => response?.status === 401 || response?.status =
* local(route: string, init?: RequestInit): Promise<Response>,
* cloudFetch(url: string, init?: RequestInit): Promise<Response>,
* napped?(): void,
- * shown(): "computer" | "cloud" | null,
+ * shown(): "computer" | "cloud" | "waking" | "other" | null,
* focused(): boolean,
* openPlace(home: "computer" | "cloud"): unknown,
* send(channel: string, value: unknown): void,
@@ -86,7 +104,8 @@ const needsSignIn = (response) => response?.status === 401 || response?.status =
* }} deps `cloud()`: My Cloud's address and the signed-in account while the person has one, and whether the Admin last
* said it sleeps. `powerChecked()`: asks the Admin again whether My Cloud sleeps, true once it answered just now.
* `computer()`: this computer is a place of its own (its bots did not move away). `napped()`: My Cloud answered that it
- * is going to sleep. `shown()`: the place whose page the window shows, null while one loads or another screen is up.
+ * is going to sleep. `shown()`: the place whose page the window shows; "waking" for this app's own screen while My Cloud
+ * wakes, "other" for any other place or screen, null while a page loads.
* `focused()`: the window is the one the person is using: in front, and the screen not locked. `openPlace(home)`: main's
* own switch to that place, waking My Cloud as opening it always does. `send`: to the page on screen. `changed()`: the
* list or the switch changed, so a page that draws it asks again.
@@ -101,9 +120,12 @@ export function createPlacesTogether({ pref, cloud, powerChecked, computer, loca
/** What each place gave last: its rows, when, and how the last read went. */
const kept = new Map();
const reading = new Map();
+ /** The places whose ready AIs the + asked about: read with that place's next list, and not otherwise. */
+ const aisWanted = new Set();
/** Moves whenever the lists are dropped; a read that started before it moved is thrown away. */
let epoch = 0;
- let on = null, timer = null, pending = null, scope = null, cloudAskedAt = -Infinity, signIn = false;
+ let on = null, timer = null, pending = null, scope = null, cloudAskedAt = -Infinity, signIn = false, unheard = null;
+ const placeShown = () => { const place = shown(); return place === "computer" || place === "cloud" ? place : null; };
const isOn = () => { if (on === null) { try { on = parseTogether(pref.read()); } catch { on = false; } } return on; };
const available = () => Boolean(cloud().origin) && computer();
@@ -114,11 +136,14 @@ export function createPlacesTogether({ pref, cloud, powerChecked, computer, loca
epoch += 1;
kept.clear();
reading.clear();
+ aisWanted.clear();
cloudAskedAt = -Infinity;
signIn = false;
drop();
}
function drop() {
+ cancelLater(unheard);
+ unheard = null;
if (!pending) return false;
cancelLater(pending.timer);
pending = null;
@@ -137,11 +162,11 @@ export function createPlacesTogether({ pref, cloud, powerChecked, computer, loca
if (had) tell();
}
- async function ask(home) {
+ async function ask(home, route = "/api/bots?messages=0") {
const signal = AbortSignal.timeout(TIMEOUT_MS);
- if (home === "computer") return local("/api/bots?messages=0", { signal, headers: { accept: "application/json" } });
+ if (home === "computer") return local(route, { signal, headers: { accept: "application/json" } });
const { origin } = cloud();
- return cloudFetch(`${origin}/api/bots?messages=0`, { credentials: "include", cache: "no-store", redirect: "error", signal, headers: { accept: "application/json", ...BACKGROUND_HEADERS } });
+ return cloudFetch(`${origin}${route}`, { credentials: "include", cache: "no-store", redirect: "error", signal, headers: { accept: "application/json", ...BACKGROUND_HEADERS } });
}
/** Whether My Cloud may be asked now, and what its list says when it may not. */
@@ -153,9 +178,24 @@ export function createPlacesTogether({ pref, cloud, powerChecked, computer, loca
return cloud().asleep ? "asleep" : "ask";
}
+ const aisFresh = (entry) => entry?.aisAt !== undefined && now() - entry.aisAt < CLOUD_EVERY_MS;
+
+ /** The AIs ready in `home`, read with its bots once the + asked, at most once a minute; what it said last otherwise. */
+ async function aisOf(home, last) {
+ if (!aisWanted.has(home) || aisFresh(last)) return last?.aisAt === undefined ? {} : { ais: last.ais, aisAt: last.aisAt };
+ aisWanted.delete(home);
+ try {
+ const response = await ask(home, "/api/instances");
+ if (home === "cloud" && needsSignIn(response)) { await response.body?.cancel?.(); return "signin"; }
+ if (!response?.ok) { await response?.body?.cancel?.(); return { ais: last?.ais ?? null, aisAt: now() }; }
+ return { ais: readyAis(await response.json()), aisAt: now() };
+ } catch { return { ais: last?.ais ?? null, aisAt: now() }; }
+ }
+
async function read(home) {
- const mine = epoch, last = kept.get(home), before = JSON.stringify([last?.state, last?.bots]);
- const held = (state) => ({ bots: last?.bots ?? [], state });
+ const mine = epoch, last = kept.get(home), said = (entry) => JSON.stringify([entry?.state, entry?.bots, entry?.newBot, entry?.ais]);
+ const held = (state) => ({ ...last, bots: last?.bots ?? [], state });
+ const signedOut = () => { signIn = true; return { bots: [], state: "signin" }; };
let next;
try {
const may = home === "cloud" ? await cloudMayBeAsked(mine) : "ask";
@@ -164,14 +204,17 @@ export function createPlacesTogether({ pref, cloud, powerChecked, computer, loca
else {
const response = await ask(home);
if (home === "cloud" && asleepAnswer(response)) { napped(); next = held("asleep"); }
- else if (home === "cloud" && needsSignIn(response)) { await response.body?.cancel?.(); signIn = true; next = { bots: [], state: "signin" }; }
+ else if (home === "cloud" && needsSignIn(response)) { await response.body?.cancel?.(); next = signedOut(); }
else if (!response?.ok) { await response?.body?.cancel?.(); next = held("offline"); }
- else next = { bots: botRows(await response.json(), home), state: "ready" };
+ else {
+ const body = await response.json(), ais = await aisOf(home, last);
+ next = ais === "signin" ? signedOut() : { bots: botRows(body, home), state: "ready", newBot: makesNewBots(body), ...ais };
+ }
}
} catch { next = held("offline"); }
if (mine !== epoch || !active()) return;
kept.set(home, { ...next, at: now() });
- if (JSON.stringify([next.state, next.bots]) !== before) tell();
+ if (said(next) !== said(last)) tell();
}
/** Reads `home`'s bots again when it is due. My Cloud is due at most once a minute, never while the person is not
@@ -183,7 +226,7 @@ export function createPlacesTogether({ pref, cloud, powerChecked, computer, loca
if (home === "cloud") {
if (signIn || !focused() || now() - cloudAskedAt < CLOUD_EVERY_MS) return Promise.resolve();
cloudAskedAt = now();
- } else if (kept.has(home) && now() - kept.get(home).at < FRESH_MS) return Promise.resolve();
+ } else if (kept.has(home) && now() - kept.get(home).at < FRESH_MS && !(aisWanted.has(home) && !aisFresh(kept.get(home)))) return Promise.resolve();
const mine = epoch;
const work = read(home).finally(() => { if (mine === epoch && reading.get(home) === work) reading.delete(home); });
reading.set(home, work);
@@ -194,7 +237,7 @@ export function createPlacesTogether({ pref, cloud, powerChecked, computer, loca
if (timer !== null || !active()) return;
timer = setTimer(() => {
sameScope();
- const place = shown();
+ const place = placeShown();
if (active() && place && focused()) void refresh(otherHome(place));
}, LOOK_EVERY_MS);
timer?.unref?.();
@@ -204,26 +247,28 @@ export function createPlacesTogether({ pref, cloud, powerChecked, computer, loca
timer = null;
}
- /** `home` opens, and its page is sent `channel` once it has loaded. A wait that ends any other way sends nothing:
- * it ran out, the switch ended with the window still on another page, or the person went back to the page they left. */
- function go(home, channel, value) {
+ /** `home` opens, and its page is sent `channel` once it has loaded, as the direct result of the click and nothing
+ * else: the wait is over when it runs out, when main's switch fails or ends with the window on another page, and
+ * when the window goes anywhere but `home` or the screen shown while My Cloud wakes. */
+ function go(home, channel, value, waitMs) {
drop();
- const mine = { home, channel, value, at: now(), timer: null };
- mine.timer = later(() => { if (pending === mine) { pending = null; tell(); } }, OPEN_WAIT_MS);
+ const mine = { home, channel, value, timer: null };
+ const over = () => { if (pending === mine && drop()) tell(); };
+ mine.timer = later(over, waitMs);
mine.timer?.unref?.();
pending = mine;
tell();
- void Promise.resolve().then(() => openPlace(home)).catch(() => {}).then(() => {
+ void Promise.resolve().then(() => openPlace(home)).then(() => {
const place = shown();
- if (pending === mine && place !== null && place !== home && drop()) tell();
- });
+ if (place !== null && place !== home && place !== "waking") over();
+ }, over);
}
function otherOf(asking) {
const home = otherHome(asking), known = kept.get(home);
const state = home === "cloud" && pending?.home === home && (cloud().asleep || known?.state !== "ready") ? "waking"
: home === "cloud" && cloud().asleep ? "asleep" : known?.state ?? "loading";
- return { home, state, bots: known?.bots ?? [] };
+ return { home, state, bots: known?.bots ?? [], ...(typeof known?.newBot === "boolean" ? { newBot: known.newBot } : {}) };
}
return {
@@ -255,25 +300,56 @@ export function createPlacesTogether({ pref, cloud, powerChecked, computer, loca
if (!active()) return false;
const home = otherHome(asking), row = kept.get(home)?.bots.find((bot) => bot.id === botId);
if (!row) return false;
- go(home, "desktop-notifications:open", { botId: row.id, threadId: row.threadId });
+ go(home, "desktop-notifications:open", { botId: row.id, threadId: row.threadId }, OPEN_WAIT_MS);
return true;
},
+ /** What the + shows about the other place before a bot is made there: how it is doing, and the AIs ready there
+ * (null while it has not said). The AIs are read with the list's own next read, under the list's rules and its
+ * once-a-minute limit for My Cloud, so opening the + again and again asks nothing more. */
+ async newBotChoice(asking) {
+ sameScope();
+ if (!active()) return null;
+ const home = otherHome(asking);
+ if (!aisFresh(kept.get(home))) { aisWanted.add(home); await refresh(home); }
+ if (!active()) return null;
+ return { home, state: otherOf(asking).state, ais: kept.get(home)?.ais ?? null };
+ },
+ /** The +'s choice of the other place: that place opens and makes the bot itself, by its own rules and limits.
+ * Refused for a place whose page said it would not hear the request. */
+ newBot(asking) {
+ sameScope();
+ const home = otherHome(asking);
+ if (!active() || kept.get(home)?.newBot === false) return false;
+ go(home, "places-together:new-bot", null, NEW_BOT_WAIT_MS);
+ return true;
+ },
+ /** The page that was told to make a new bot heard it. */
+ newBotHeard() {
+ cancelLater(unheard);
+ unheard = null;
+ },
/** The window finished loading a page: a click that was waiting for this place lands now. My Cloud on screen is
- * signed in, so it may be asked again. */
+ * signed in, so it may be asked again. A page told to make a new bot that does not say it heard is told to forget it. */
arrived() {
sameScope();
- const place = shown();
+ const place = placeShown();
if (place === "cloud" && signIn) { signIn = false; cloudAskedAt = -Infinity; }
if (!pending || place !== pending.home) return;
const { channel, value } = pending;
drop();
- if (active()) send(channel, value);
+ if (active()) {
+ send(channel, value);
+ if (channel === "places-together:new-bot") {
+ unheard = later(() => { unheard = null; send("places-together:new-bot-cancel", null); }, NEW_BOT_ACK_MS);
+ unheard?.unref?.();
+ }
+ }
tell();
},
- /** The window's page moved to `place` (null for any other screen). Back on the place the click left, the click is
- * over, so opening the other place later by another route opens it as it is. */
+ /** The window's page moved to `place`. Anywhere but the place the click asked for, or the screen shown while My
+ * Cloud wakes, and the click is over: that place opened later, by any route, opens as it is. */
navigated(place) {
- if (pending && place !== null && place !== pending.home && drop()) tell();
+ if (pending && place !== null && place !== pending.home && place !== "waking" && drop()) tell();
},
close() { stopWatch(); forget(); },
};
@@ -297,5 +373,8 @@ export function installPlacesTogether({ ipcMain, asking, together }) {
return together.set(page, value === true);
});
ipcMain.handle("places-together:open", (event, botId) => together.open(side(event), String(botId)));
+ ipcMain.handle("places-together:new-bot-choice", (event) => together.newBotChoice(side(event)));
+ ipcMain.handle("places-together:new-bot", (event) => together.newBot(side(event)));
+ ipcMain.handle("places-together:new-bot-heard", (event) => { side(event); together.newBotHeard(); });
return together;
}
diff --git a/electron/places-together.node-test.mjs b/electron/places-together.node-test.mjs
index cd69ace363..a935e477d3 100644
--- a/electron/places-together.node-test.mjs
+++ b/electron/places-together.node-test.mjs
@@ -2,14 +2,16 @@ import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import test from "node:test";
+import { createRequire } from "node:module";
import { fileURLToPath } from "node:url";
-import { botRow, botRows, CLOUD_EVERY_MS, createPlacesTogether, FRESH_MS, installPlacesTogether, LOOK_EVERY_MS, OPEN_WAIT_MS, otherHome, parseTogether } from "./places-together.mjs";
+import { botRow, botRows, CLOUD_EVERY_MS, createPlacesTogether, FRESH_MS, installPlacesTogether, LOOK_EVERY_MS, OPEN_WAIT_MS, makesNewBots, NEW_BOT_ACK_MS, NEW_BOT_WAIT_MS, otherHome, parseTogether, readyAis } from "./places-together.mjs";
const HERE = dirname(fileURLToPath(import.meta.url));
const CLOUD = "https://mine.cloud.test";
const answer = (status, body, headers = {}) => ({ ok: status < 400, status, headers: { get: (name) => headers[name] ?? null }, json: async () => body, body: { cancel: async () => {} } });
const bot = (id, name, over = {}) => ({ id, threadId: `t-${id}`, name, title: "", color: "blue", mascotBody: "classic", ...over });
+const ai = (displayName, snapshot = {}) => ({ instanceId: displayName.toLowerCase(), driverKind: "claude", displayName, snapshot: { state: "available", ...snapshot } });
const settle = () => new Promise((done) => setImmediate(done));
function setup(over = {}) {
@@ -18,13 +20,14 @@ function setup(over = {}) {
cloud: { origin: CLOUD, account: "acct-a", asleep: false }, computer: true, shown: "computer", focused: true, napped: 0, checks: 0, admin: true, timeouts: [], opening: new Promise(() => {}),
bots: { computer: [bot("scout", "Scout")], cloud: [bot("scout", "Scout"), bot("nova", "Nova", { unread: true })] },
reply: { computer: null, cloud: null },
+ instances: { computer: [ai("Claude"), ai("Codex")], cloud: [ai("Claude"), ai("Included AI")] }, makes: { computer: true, cloud: true },
};
f.together = createPlacesTogether({
pref: { read: () => f.saved, write: (value) => { f.saved = value; } },
cloud: () => f.cloud, computer: () => f.computer,
powerChecked: async () => { f.checks += 1; f.asked.push(["admin"]); return typeof f.admin === "function" ? f.admin() : f.admin; },
- local: async (route, init) => { f.asked.push(["computer", route, init]); return f.reply.computer ?? answer(200, { bots: f.bots.computer }); },
- cloudFetch: async (url, init) => { f.asked.push(["cloud", url, init]); return typeof f.reply.cloud === "function" ? f.reply.cloud() : f.reply.cloud ?? answer(200, { bots: f.bots.cloud }); },
+ local: async (route, init) => { f.asked.push(["computer", route, init]); return f.reply.computer ?? answer(200, route === "/api/instances" ? { instances: f.instances.computer } : { bots: f.bots.computer, ...(f.makes.computer ? { together: { newBot: true } } : {}) }); },
+ cloudFetch: async (url, init) => { f.asked.push(["cloud", url, init]); return typeof f.reply.cloud === "function" ? f.reply.cloud() : f.reply.cloud ?? answer(200, url.endsWith("/api/instances") ? { instances: f.instances.cloud } : { bots: f.bots.cloud, ...(f.makes.cloud ? { together: { newBot: true } } : {}) }); },
napped: () => { f.napped += 1; },
shown: () => f.shown, focused: () => f.focused, openPlace: (home) => { f.opened.push(home); return f.opening; },
send: (channel, value) => { f.sent.push([channel, value]); },
@@ -36,7 +39,7 @@ function setup(over = {}) {
});
/** The next read of My Cloud is due: a minute has passed. */
f.later = () => { f.clock += CLOUD_EVERY_MS; };
- f.cloudAsked = () => f.asked.filter(([side]) => side === "cloud").length;
+ f.cloudAsked = (route = "") => f.asked.filter(([side, url]) => side === "cloud" && url.endsWith(route)).length;
return f;
}
@@ -61,7 +64,7 @@ test("on: this computer's page lists My Cloud's bots, asked as background work w
assert.deepEqual(state.other, { home: "cloud", state: "ready", bots: [
{ home: "cloud", id: "scout", threadId: "t-scout", name: "Scout", color: "blue", mascotBody: "classic" },
{ home: "cloud", id: "nova", threadId: "t-nova", name: "Nova", color: "blue", mascotBody: "classic", unread: true },
- ] });
+ ], newBot: true });
assert.deepEqual(f.asked.map(([side]) => side), ["admin", "cloud"], "the Admin is asked whether it sleeps first, then My Cloud, once");
const [, url, init] = f.asked[1];
assert.deepEqual([url, init.headers["x-omb-background"], init.credentials, init.redirect], [`${CLOUD}/api/bots?messages=0`, "1", "include", "error"]);
@@ -389,7 +392,7 @@ test("only this computer's page and My Cloud's own page are answered", async ()
const handlers = new Map();
const f = setup();
installPlacesTogether({ ipcMain: { handle: (channel, handler) => handlers.set(channel, handler) }, asking: (event) => event.page, together: f.together });
- assert.deepEqual([...handlers.keys()], ["places-together:state", "places-together:set", "places-together:open"]);
+ assert.deepEqual([...handlers.keys()], ["places-together:state", "places-together:set", "places-together:open", "places-together:new-bot-choice", "places-together:new-bot", "places-together:new-bot-heard"]);
for (const handler of handlers.values()) assert.throws(() => handler({ page: null }, "nova"), /Only this computer's page and My Cloud's page/);
assert.equal(handlers.get("places-together:state")({ page: "local" }).here, "computer");
assert.equal(handlers.get("places-together:state")({ page: "cloud" }).here, "cloud");
@@ -412,5 +415,236 @@ test("main wires it to the one rule for this app's own pages, and the preload of
const preload = readFileSync(join(HERE, "preload.cjs"), "utf8");
assert.match(preload.match(/const REMOTE_SAFE = new Set\(\[([^\]]*)\]\)/)[1], /"placesTogether"/);
const bridge = preload.slice(preload.indexOf(" placesTogether: "), preload.indexOf(" twoPlaces: {"));
- assert.deepEqual(bridge.match(/"places-together:[a-z]+"/g), ['"places-together:state"', '"places-together:set"', '"places-together:open"', '"places-together:changed"', '"places-together:changed"']);
+ assert.deepEqual(bridge.match(/"places-together:[a-z-]+"/g), ['"places-together:state"', '"places-together:set"', '"places-together:open"', '"places-together:changed"', '"places-together:changed"', '"places-together:new-bot-choice"', '"places-together:new-bot"']);
+});
+
+test("the +'s other place: that place opens and is told to make the bot itself, once its page has loaded", async () => {
+ const f = setup();
+ assert.equal(f.together.newBot("computer"), true);
+ await settle();
+ assert.deepEqual([f.opened, f.sent], [["cloud"], []]);
+ assert.deepEqual(f.asked, [], "main never makes the bot, nor asks either place for anything");
+ assert.equal(f.timeouts.at(-1).ms, NEW_BOT_WAIT_MS);
+ f.shown = "cloud";
+ f.together.arrived();
+ assert.deepEqual(f.sent, [["places-together:new-bot", null]]);
+ f.sent.length = 0;
+ assert.equal(f.together.newBot("cloud"), true);
+ await settle();
+ f.shown = "computer";
+ f.together.arrived();
+ assert.deepEqual([f.opened, f.sent], [["cloud", "computer"], [["places-together:new-bot", null]]]);
+ const off = setup({ saved: { v: 1, on: false } });
+ assert.equal(off.together.newBot("computer"), false);
+ assert.equal(await off.together.newBotChoice("computer"), null);
+ await settle();
+ assert.deepEqual([off.opened, off.asked], [[], []]);
+});
+
+test("a new bot is made only as the direct result of the click: a detour to any other place ends it", async () => {
+ for (const detour of ["other", "computer"]) {
+ const f = setup();
+ f.cloud = { ...f.cloud, asleep: true };
+ f.together.newBot("computer");
+ f.together.navigated("waking");
+ assert.equal(f.timeouts.at(-1).cancelled, false, "the screen shown while My Cloud wakes is on the way");
+ f.together.navigated(detour);
+ assert.equal(f.timeouts.at(-1).cancelled, true);
+ f.shown = "cloud";
+ f.together.navigated("cloud");
+ f.together.arrived();
+ assert.deepEqual(f.sent, [], `after ${detour}, My Cloud opened later makes no bot`);
+ }
+});
+
+test("a new bot asked for is forgotten when main's switch fails, when it ends on another page, and after the time a wake takes", async () => {
+ const failed = setup();
+ failed.opening = Promise.reject(new Error("could not open"));
+ failed.together.newBot("computer");
+ await settle();
+ failed.shown = "cloud";
+ failed.together.arrived();
+ assert.deepEqual(failed.sent, []);
+
+ const elsewhere = setup();
+ elsewhere.opening = Promise.resolve();
+ elsewhere.shown = "other";
+ elsewhere.together.newBot("computer");
+ await settle();
+ elsewhere.shown = "cloud";
+ elsewhere.together.arrived();
+ assert.deepEqual(elsewhere.sent, []);
+
+ const waking = setup();
+ waking.opening = Promise.resolve();
+ waking.shown = "waking";
+ waking.together.newBot("computer");
+ await settle();
+ assert.equal(waking.timeouts.at(-1).cancelled, false, "the waking screen keeps the click");
+ waking.timeouts.at(-1).run();
+ waking.shown = "cloud";
+ waking.together.arrived();
+ assert.deepEqual(waking.sent, [], "a wake that took longer than a wake takes makes no bot");
+});
+
+test("the same detours end a bot's open too", async () => {
+ const f = setup();
+ await f.together.refresh("cloud");
+ f.together.open("computer", "nova");
+ f.together.navigated("other");
+ f.shown = "cloud";
+ f.together.arrived();
+ assert.deepEqual(f.sent, []);
+});
+
+test("a page that does not say it heard is told to forget the new bot; one that heard is left alone", async () => {
+ const f = setup();
+ f.together.newBot("computer");
+ f.shown = "cloud";
+ f.together.arrived();
+ const wait = f.timeouts.at(-1);
+ assert.equal(wait.ms, NEW_BOT_ACK_MS);
+ wait.run();
+ assert.deepEqual(f.sent, [["places-together:new-bot", null], ["places-together:new-bot-cancel", null]]);
+
+ const g = setup();
+ g.together.newBot("computer");
+ g.shown = "cloud";
+ g.together.arrived();
+ g.together.newBotHeard();
+ assert.equal(g.timeouts.at(-1).cancelled, true);
+ assert.deepEqual(g.sent, [["places-together:new-bot", null]]);
+});
+
+test("a place whose page would not hear it is never asked to make a bot: its list says so, and main refuses", async () => {
+ const f = setup();
+ f.makes.cloud = false;
+ await f.together.refresh("cloud");
+ assert.equal(f.together.state("computer").other.newBot, false);
+ assert.equal(f.together.newBot("computer"), false);
+ await settle();
+ assert.deepEqual(f.opened, []);
+ f.makes.cloud = true;
+ f.later();
+ await f.together.refresh("cloud");
+ assert.equal(f.together.state("computer").other.newBot, true);
+ assert.equal(f.together.newBot("computer"), true);
+ assert.equal(makesNewBots({ bots: [] }), false);
+ assert.equal(makesNewBots({ together: { newBot: "yes" } }), false);
+});
+
+test("a later click replaces the one still waiting: a new bot asked for, then a bot opened, opens only the bot", async () => {
+ const f = setup();
+ await f.together.refresh("cloud");
+ f.together.newBot("computer");
+ f.together.open("computer", "nova");
+ f.shown = "cloud";
+ f.together.arrived();
+ assert.deepEqual(f.sent, [["desktop-notifications:open", { botId: "nova", threadId: "t-nova" }]]);
+});
+
+test("the + learns which AIs are ready in the other place with the list's own read: once a minute however often it opens", async () => {
+ const f = setup();
+ const first = await f.together.newBotChoice("computer");
+ assert.deepEqual(first, { home: "cloud", state: "ready", ais: [{ name: "Claude", kind: "claude" }, { name: "Included AI", kind: "claude" }] });
+ assert.deepEqual(f.asked.map(([side, url]) => (side === "cloud" ? new URL(url).pathname : side)), ["admin", "/api/bots", "/api/instances"]);
+ assert.equal(f.asked.at(-1)[2].headers["x-omb-background"], "1");
+ for (let i = 0; i < 5; i += 1) { f.clock += 5_000; assert.deepEqual(await f.together.newBotChoice("computer"), first); }
+ assert.deepEqual([f.checks, f.cloudAsked("/api/instances"), f.cloudAsked()], [1, 1, 2], "five more opens ask the Admin and My Cloud nothing");
+ f.later();
+ f.instances.cloud = [ai("Claude")];
+ assert.deepEqual((await f.together.newBotChoice("computer")).ais, [{ name: "Claude", kind: "claude" }]);
+ assert.deepEqual([f.checks, f.cloudAsked("/api/instances")], [2, 2]);
+});
+
+test("a list that nobody opened the + for never reads the AIs", async () => {
+ const f = setup();
+ for (let i = 0; i < 3; i += 1) { await f.together.refresh("cloud"); f.later(); }
+ assert.equal(f.cloudAsked("/api/instances"), 0);
+ f.shown = "cloud";
+ await f.together.refresh("computer");
+ assert.equal(f.asked.some(([side, route]) => side === "computer" && route === "/api/instances"), false);
+ assert.deepEqual((await f.together.newBotChoice("cloud")).ais, [{ name: "Claude", kind: "claude" }, { name: "Codex", kind: "claude" }]);
+});
+
+test("the + asks My Cloud under the list's own rules: never asleep, never unfocused, only after the Admin's word, and a refusal is the sign-in state", async () => {
+ const asleep = setup();
+ asleep.admin = () => { asleep.cloud = { ...asleep.cloud, asleep: true }; return true; };
+ assert.deepEqual(await asleep.together.newBotChoice("computer"), { home: "cloud", state: "asleep", ais: null });
+ assert.equal(asleep.cloudAsked(), 0);
+
+ const away = setup();
+ away.focused = false;
+ assert.equal((await away.together.newBotChoice("computer")).ais, null);
+ assert.deepEqual(away.asked, []);
+
+ const silent = setup();
+ silent.admin = false;
+ assert.equal((await silent.together.newBotChoice("computer")).ais, null);
+ assert.equal(silent.cloudAsked(), 0);
+
+ const refused = setup();
+ let calls = 0;
+ refused.reply.cloud = () => ((calls += 1) === 1 ? answer(200, { bots: refused.bots.cloud }) : answer(401, { error: "unauthorized" }));
+ assert.deepEqual(await refused.together.newBotChoice("computer"), { home: "cloud", state: "signin", ais: null });
+ assert.deepEqual(refused.together.state("computer").other.bots, []);
+ refused.later();
+ await refused.together.newBotChoice("computer");
+ assert.equal(refused.cloudAsked(), 2, "and it is not asked again until My Cloud has been opened");
+});
+
+test("an AI counts as ready only when it is installed and signed in, never through free no-login models alone", () => {
+ assert.deepEqual(readyAis({ instances: [ai("Claude"), ai("Codex", { authenticated: false }), ai("Gemini", { state: "unavailable" }), ai("OpenCode", { freeFallback: true }),
+ { ...ai("Cline"), driverKind: "clineAgent" }, { ...ai("Cline 2", { authenticated: true }), driverKind: "clineAgent" }, { ...ai("Own endpoint", { authenticated: false }), access: "custom" }, ai("Claude")] }),
+ [{ name: "Claude", kind: "claude" }, { name: "Cline 2", kind: "clineAgent" }, { name: "Own endpoint", kind: "claude" }]);
+ assert.deepEqual(readyAis(null), []);
+});
+
+function loadPreload() {
+ const require = createRequire(import.meta.url);
+ const channels = new Map(), invoked = [];
+ let api = null;
+ const electron = require.resolve("electron");
+ const held = require.cache[electron];
+ require.cache[electron] = { id: electron, filename: electron, loaded: true, exports: {
+ ipcRenderer: { on: (channel, run) => channels.set(channel, run), removeListener: () => undefined, invoke: async (...args) => { invoked.push(args); return true; }, send: () => undefined, sendSync: () => undefined },
+ contextBridge: { exposeInMainWorld: (_name, exposed) => { api = exposed; } }, webUtils: { getPathForFile: () => "" },
+ } };
+ const preload = require.resolve("./preload.cjs");
+ delete require.cache[preload];
+ process.argv.push("--omb-company-desktop=1");
+ try { require(preload); } finally { process.argv.pop(); if (held) require.cache[electron] = held; else delete require.cache[electron]; delete require.cache[preload]; }
+ return { api, channels, invoked };
+}
+
+test("the preload holds a new bot asked for before the page has listened, and tells main the page heard", async () => {
+ const { api, channels, invoked } = loadPreload();
+ channels.get("places-together:new-bot")({});
+ assert.deepEqual(invoked, [], "nothing heard it yet");
+ let made = 0;
+ const stop = api.placesTogether.onNewBot(() => { made += 1; });
+ assert.equal(made, 1);
+ assert.deepEqual(invoked, [["places-together:new-bot-heard"]]);
+ channels.get("places-together:new-bot")({});
+ assert.equal(made, 2);
+ stop();
+ assert.equal(await api.placesTogether.newBot(), true);
+ assert.deepEqual(invoked.at(-1), ["places-together:new-bot"]);
+});
+
+test("the preload forgets a new bot nobody listened for: when main says so, and by itself after ten seconds", async (t) => {
+ const told = loadPreload();
+ told.channels.get("places-together:new-bot")({});
+ told.channels.get("places-together:new-bot-cancel")({});
+ let made = 0;
+ told.api.placesTogether.onNewBot(() => { made += 1; });
+ assert.equal(made, 0);
+
+ t.mock.timers.enable({ apis: ["Date"], now: 1_000_000 });
+ const late = loadPreload();
+ late.channels.get("places-together:new-bot")({});
+ t.mock.timers.setTime(1_000_000 + 10_001);
+ late.api.placesTogether.onNewBot(() => { made += 1; });
+ assert.equal(made, 0, "a page that starts listening later, such as after a sign-in, makes no bot");
+ assert.deepEqual(late.invoked, []);
});
diff --git a/electron/preload.cjs b/electron/preload.cjs
index e1cb47db55..8330723f07 100644
--- a/electron/preload.cjs
+++ b/electron/preload.cjs
@@ -23,6 +23,21 @@ ipcRenderer.on("chat:open", (_event, link) => {
for (const listener of chatLinkListeners) listener(link);
});
+// A new bot asked for from the person's other place is made only by a page that is listening soon after: held for a
+// page still starting, then forgotten, so a sign-in document or an older page never makes one later.
+const NEW_BOT_HELD_MS = 10_000;
+let pendingNewBotAt = null;
+const newBotListeners = new Set();
+const hearNewBot = () => {
+ pendingNewBotAt = null;
+ void ipcRenderer.invoke("places-together:new-bot-heard").catch(() => {});
+ for (const listener of newBotListeners) listener();
+};
+ipcRenderer.on("places-together:new-bot", () => {
+ if (!newBotListeners.size) { pendingNewBotAt = Date.now(); return; }
+ hearNewBot();
+});
+ipcRenderer.on("places-together:new-bot-cancel", () => { pendingNewBotAt = null; });
let pendingNotificationOpen = null;
const notificationOpenListeners = new Set();
ipcRenderer.on("desktop-notifications:open", (_event, target) => {
@@ -579,6 +594,15 @@ const bridge = {
ipcRenderer.on("places-together:changed", handler);
return () => ipcRenderer.removeListener("places-together:changed", handler);
},
+ newBotChoice: () => ipcRenderer.invoke("places-together:new-bot-choice"),
+ newBot: () => isLocalPage || navigator.userActivation?.isActive === true
+ ? ipcRenderer.invoke("places-together:new-bot") : Promise.reject(new Error("Choose where the new bot lives.")),
+ onNewBot: cb => {
+ newBotListeners.add(cb);
+ if (pendingNewBotAt !== null && Date.now() - pendingNewBotAt <= NEW_BOT_HELD_MS) hearNewBot();
+ pendingNewBotAt = null;
+ return () => newBotListeners.delete(cb);
+ },
} : undefined,
// This computer's page only (never in REMOTE_SAFE, and main refuses any other): bots in two places, brought together on one.
twoPlaces: {
diff --git a/packages/phone-protocol/src/responses.ts b/packages/phone-protocol/src/responses.ts
index 3c2696ffed..cc877e1104 100644
--- a/packages/phone-protocol/src/responses.ts
+++ b/packages/phone-protocol/src/responses.ts
@@ -96,6 +96,8 @@ export interface BotsResponse<Message = WireMessage> {
groups: Array<WireGroup & WireMessagePage<Message>>;
/** By bot id. */
computerControl: Record<string, WireComputerControl>;
+ /** What this place's page does when the person's other place asks: `newBot`, it makes a new bot. */
+ together?: { newBot: true };
}
/** One match in GET /api/search, in a bot's conversation (`botId`) or a room's (`groupId`). */
diff --git a/server/routes/threads.ts b/server/routes/threads.ts
index c32ae0e832..e41773c883 100644
--- a/server/routes/threads.ts
+++ b/server/routes/threads.ts
@@ -126,6 +126,7 @@ export function createThreadRoutes(deps: ThreadRouteDeps): RouteHandler {
return [bot.id, { held: snapshot.held, helpReason: snapshot.helpReason, ...(snapshot.help ? { help: snapshot.help } : {}) }];
}),
),
+ together: { newBot: true },
} satisfies BotsResponse<MessagePage["messages"][number]>);
}
diff --git a/src/App.tsx b/src/App.tsx
index 5eb68e09b1..df6aabf37e 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -72,7 +72,7 @@ import { botUnreadCount, showBrowserUnread } from "@/lib/bot-unread";
import { phonePairingSettingsAction, takePhonePairingRequest } from "@/lib/phone-pairing"; import { useConnectLink } from "@/lib/use-connect-link";
import { isSettingsPage } from "@/components/settings/settings-index";
import { useBotListDrawer } from "@/hooks/use-bot-list-drawer";
-import { useDesktopNotificationOpens, useExternalChatLinks } from "@/hooks/use-external-chat-links";
+import { useDesktopNotificationOpens, useExternalChatLinks } from "@/hooks/use-external-chat-links"; import { useNewBotFromOtherPlace } from "@/lib/places-together";
import { useUsageSnapshot } from "@/hooks/use-usage-snapshot";
import { useReadShownChatOnFocus } from "@/hooks/use-read-shown-chat";
import { usePresence } from "@/hooks/use-presence";
@@ -140,7 +140,7 @@ function Shell({ viewer }: { viewer: WelcomeViewer | null }) {
dispatch(phonePairingSettingsAction());
}, [dispatch]);
useConnectLink(dispatch, Boolean(state.config?.team));
- useExternalChatLinks(state, dispatch); useDesktopNotificationOpens(state, dispatch);
+ useExternalChatLinks(state, dispatch); useDesktopNotificationOpens(state, dispatch); useNewBotFromOtherPlace(state.hydrated === true, useCallback(() => dispatch({ type: "newBot" }), [dispatch]));
usePresence(state, dispatch); useTeamPresence(state);
usePageLanguage(effectiveLanguage(useLanguageChoice(), state.config?.language), true);
const [paletteOpen, setPaletteOpen] = useState(false);
diff --git a/src/components/NewBotPlaceItems.dom.test.ts b/src/components/NewBotPlaceItems.dom.test.ts
new file mode 100644
index 0000000000..f62fe0d718
--- /dev/null
+++ b/src/components/NewBotPlaceItems.dom.test.ts
@@ -0,0 +1,110 @@
+// @vitest-environment happy-dom
+import { act, createElement } from "react";
+import { createRoot, type Root } from "react-dom/client";
+import { afterEach, beforeEach, expect, it, vi } from "vitest";
+
+import type { NewBotChoice, PlacesTogetherState } from "@/lib/places-together";
+
+const store = vi.hoisted(() => ({ instances: [] as Array<{ displayName: string; driverKind: string; snapshot: { state: string; freeFallback?: boolean } }> }));
+vi.mock("@/state/store-select", () => ({ useStoreSelector: (select: (state: unknown) => unknown) => select(store) }));
+
+import { resetPlacesTogetherForTest } from "@/lib/places-together";
+import { NewBotOtherPlaceItem, useNewBotHereLabel } from "./NewBotPlaceItems";
+
+let container: HTMLDivElement, root: Root, said: PlacesTogetherState, choice: NewBotChoice | null;
+const joined = (here: "computer" | "cloud"): PlacesTogetherState => ({ v: 1, available: true, on: true, here, other: { home: here === "cloud" ? "computer" : "cloud", state: "ready", bots: [] } });
+const page = {
+ state: vi.fn(async () => said), set: vi.fn(), open: vi.fn(), onChanged: vi.fn(() => () => {}),
+ newBotChoice: vi.fn(async () => choice), newBot: vi.fn(async () => true), onNewBot: vi.fn(() => () => {}),
+};
+const onHere = vi.fn(), onClose = vi.fn();
+const items = () => [...document.body.querySelectorAll<HTMLElement>("[role=menuitem]")];
+function Menu() {
+ const here = useNewBotHereLabel();
+ return createElement("div", null,
+ createElement("button", { role: "menuitem", "data-new-bot-home": "here", onClick: onHere }, here ?? "New bot"),
+ here && createElement(NewBotOtherPlaceItem, { itemClass: "item", onClose }));
+}
+const render = async () => { await act(async () => root.render(createElement(Menu))); await act(async () => {}); };
+
+beforeEach(() => {
+ vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
+ said = joined("computer");
+ choice = { home: "cloud", state: "ready", ais: [{ name: "Claude", kind: "claudeAgent" }, { name: "Included AI", kind: "included" }] };
+ store.instances = [{ displayName: "Claude", driverKind: "claude", snapshot: { state: "available" } }, { displayName: "Codex", driverKind: "codex", snapshot: { state: "available" } }];
+ window.ogb = { placesTogether: page } as never;
+ for (const fn of [...Object.values(page), onHere, onClose]) fn.mockClear();
+ container = document.createElement("div"); document.body.append(container); root = createRoot(container);
+});
+afterEach(async () => { await act(async () => root.unmount()); container.remove(); resetPlacesTogetherForTest(); vi.unstubAllGlobals(); delete (window as { ogb?: unknown }).ogb; });
+
+it("with the switch off it is the one New bot item, and main is asked nothing about the other place", async () => {
+ said = { v: 1, available: true, on: false, here: "computer", other: null };
+ await render();
+ expect(items().map((item) => item.textContent)).toEqual(["New bot"]);
+ await act(async () => items()[0]!.click());
+ expect(onHere).toHaveBeenCalledTimes(1);
+ expect(page.newBotChoice).not.toHaveBeenCalled();
+ expect(page.newBot).not.toHaveBeenCalled();
+});
+
+it("on: asks only where the bot lives, the place on screen first, and says what differs there", async () => {
+ await render();
+ expect(items().map((item) => item.getAttribute("data-new-bot-home"))).toEqual(["here", "cloud"]);
+ expect(items()[0]!.textContent).toBe("New bot on this computer");
+ expect(items()[1]!.textContent).toBe("New bot on My CloudSigned in only there: Included AI. Signed in only here: Codex.");
+ await act(async () => items()[0]!.click());
+ expect(onHere).toHaveBeenCalledTimes(1);
+ expect(page.newBot).not.toHaveBeenCalled();
+ await act(async () => items()[1]!.click());
+ expect(page.newBot).toHaveBeenCalledTimes(1);
+ expect(onClose).toHaveBeenCalledTimes(1);
+ expect(onHere).toHaveBeenCalledTimes(1);
+ expect(document.body.querySelector("[role=dialog], [role=alert]")).toBeNull();
+});
+
+it("on My Cloud's page the Cloud comes first; a sleeping Cloud and a place with no AI are said plainly", async () => {
+ said = joined("cloud");
+ choice = { home: "computer", state: "ready", ais: [] };
+ await render();
+ expect(items().map((item) => item.textContent)).toEqual(["New bot on My Cloud", "New bot on this computerNo AI is signed in there yet."]);
+ expect(document.body.querySelector("[data-new-bot-differs]")!.textContent).toBe("No AI is signed in there yet.");
+ await act(async () => root.unmount());
+ resetPlacesTogetherForTest();
+ root = createRoot(container);
+ said = joined("computer");
+ choice = { home: "cloud", state: "asleep", ais: null };
+ await render();
+ expect(document.body.querySelector("[data-new-bot-differs]")!.textContent).toBe("My Cloud is asleep. This wakes it.");
+});
+
+it("says nothing extra when both places have the same AIs", async () => {
+ choice = { home: "cloud", state: "ready", ais: [{ name: "Codex", kind: "codex" }, { name: "Claude", kind: "claudeAgent" }] };
+ await render();
+ expect(document.body.querySelector("[data-new-bot-differs]")).toBeNull();
+});
+
+it("counts an AI that only works through free no-login models on neither side", async () => {
+ store.instances = [{ displayName: "Claude", driverKind: "claude", snapshot: { state: "available" } }, { displayName: "OpenCode", driverKind: "opencode", snapshot: { state: "available", freeFallback: true } }];
+ choice = { home: "cloud", state: "ready", ais: [{ name: "Claude", kind: "claudeAgent" }] };
+ await render();
+ expect(document.body.querySelector("[data-new-bot-differs]")).toBeNull();
+});
+
+it("never shows an account's email address in the line: the engine's name stands in", async () => {
+ store.instances = [{ displayName: "Claude", driverKind: "claude", snapshot: { state: "available" } }];
+ choice = { home: "cloud", state: "ready", ais: [{ name: "Claude", kind: "claudeAgent" }, { name: "[email protected]", kind: "codex" }] };
+ await render();
+ expect(document.body.querySelector("[data-new-bot-differs]")!.textContent).toBe("Signed in only there: OpenAI.");
+});
+
+it("a Cloud whose page would not hear the request shows the item disabled with one plain line, and a click does nothing", async () => {
+ said = { ...joined("computer"), other: { home: "cloud", state: "ready", bots: [], newBot: false } };
+ await render();
+ const item = items()[1] as HTMLButtonElement;
+ expect(item.disabled).toBe(true);
+ expect(item.textContent).toBe("New bot on My CloudMy Cloud needs its next update for this.");
+ await act(async () => item.click());
+ expect(page.newBot).not.toHaveBeenCalled();
+ expect(onClose).not.toHaveBeenCalled();
+});
diff --git a/src/components/NewBotPlaceItems.tsx b/src/components/NewBotPlaceItems.tsx
new file mode 100644
index 0000000000..c1886714f0
--- /dev/null
+++ b/src/components/NewBotPlaceItems.tsx
@@ -0,0 +1,61 @@
+// The + menu's New bot, with "This computer and My Cloud together" on: it asks one thing, where the bot lives. The menu's
+// own item names the place on screen; the item here is the other place, which makes the bot itself once main has opened it.
+import { useEffect, useState } from "react";
+import { Bot as BotIcon, Cloud } from "lucide-react";
+import { t } from "@/lib/i18n";
+import { aiLabel, newBotDifference, newBotInOtherPlace, readNewBotChoice, usePlacesTogether, type BotHome, type NewBotChoice } from "@/lib/places-together";
+import type { InstanceInfo } from "@/state/store";
+import { useStoreSelector } from "@/state/store-select";
+import { engineReady, providerName } from "./EngineLibrary";
+import { SIMPLE_MENU_META } from "./menu-recipe";
+
+const label = (home: BotHome): string => t(home === "cloud" ? "sidebar.newBotOn.cloud" : "sidebar.newBotOn.computer");
+const list = (names: readonly string[]): string => new Intl.ListFormat(undefined, { style: "short", type: "conjunction" }).format(names);
+
+const engineName = (kind: string): string => providerName({ driverKind: kind } as InstanceInfo);
+
+/** An AI a new bot could run on: installed and signed in, never one that only works through free no-login models. The
+ * same rule main applies to the other place's AIs. */
+export const readyForNewBot = (instance: InstanceInfo): boolean => engineReady(instance) && instance.snapshot.freeFallback !== true;
+
+function differenceLine(hereAis: readonly string[], choice: NewBotChoice | null): string | null {
+ const differs = newBotDifference(hereAis, choice && { ...choice, ais: choice.ais?.map((ai) => aiLabel(ai.name, ai.kind, engineName)) ?? null });
+ if (!differs) return null;
+ if (differs.kind === "asleep") return t("sidebar.newBotOn.asleep");
+ if (differs.kind === "noAi") return t("sidebar.newBotOn.noAi");
+ return [differs.onlyThere.length ? t("sidebar.newBotOn.onlyThere", { ais: list(differs.onlyThere) }) : "",
+ differs.onlyHere.length ? t("sidebar.newBotOn.onlyHere", { ais: list(differs.onlyHere) }) : ""].filter(Boolean).join(" ");
+}
+
+/** The New bot item's words while the + asks where: it names the place on screen. Null with the switch off. */
+export function useNewBotHereLabel(): string | null {
+ const together = usePlacesTogether();
+ return together?.on && together.other ? label(together.here) : null;
+}
+
+/** The +'s second New bot item, for the other place, with the one line that says what differs there. */
+export function NewBotOtherPlaceItem({ itemClass, onClose }: { itemClass: string; onClose(): void }) {
+ const together = usePlacesTogether();
+ const other = together?.on ? together.other?.home ?? null : null;
+ const hereAis = useStoreSelector((state) => state.instances.filter(readyForNewBot).map((instance) => aiLabel(instance.displayName, instance.driverKind, engineName)), (a, b) => a.join("\n") === b.join("\n"));
+ const [choice, setChoice] = useState<NewBotChoice | null>(null);
+ useEffect(() => {
+ if (!other) return;
+ let alive = true;
+ void readNewBotChoice().then((next) => { if (alive) setChoice(next); });
+ return () => { alive = false; };
+ }, [other]);
+ if (!other) return null;
+ const unable = together?.other?.newBot === false;
+ const line = unable ? t("sidebar.newBotOn.needsUpdate") : differenceLine(hereAis, choice);
+ return (
+ <button type="button" role="menuitem" data-new-bot-home={other} disabled={unable} className={`${itemClass} disabled:cursor-default disabled:opacity-50 disabled:hover:bg-transparent`}
+ onClick={() => { onClose(); newBotInOtherPlace(); }}>
+ {other === "cloud" ? <Cloud size={16} className="shrink-0 text-ink-secondary" /> : <BotIcon size={16} className="shrink-0 text-ink-secondary" />}
+ <span className="flex min-w-0 flex-1 flex-col">
+ <span>{label(other)}</span>
+ {line && <span data-new-bot-differs="" className={`${SIMPLE_MENU_META} whitespace-normal`}>{line}</span>}
+ </span>
+ </button>
+ );
+}
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index 1a3ab11863..8d5f13a84f 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -74,7 +74,7 @@ import { SidebarProfileMenu } from "./SidebarProfileMenu";
import { PHONE_LAYOUT, useMediaQuery } from "@/lib/use-media-query";
import { GlassBar, GlassScrollFrame, GlassScroller } from "./GlassScrollFrame";
import { DesktopWorkspaceSwitcher, endCloudHowTo } from "./DesktopWorkspaceSwitcher"; import { PlaceTint } from "./PlaceTint"; import { ChromeRailToggle } from "./ChromeRailToggle";
-import { useCloudOwner } from "./CloudOwner"; import { OtherPlaceBots, OwnBotHomeMark } from "./OtherPlaceBots";
+import { useCloudOwner } from "./CloudOwner"; import { OtherPlaceBots, OwnBotHomeMark } from "./OtherPlaceBots"; import { NewBotOtherPlaceItem, useNewBotHereLabel } from "./NewBotPlaceItems";
import { SidebarSectionHeader } from "./SidebarSectionHeader";
import { NeedsYouButton, OwnerPickerHost } from "./TeamOwner"; import { SidebarPeople } from "./SidebarPeople"; import { SidebarInboxRow } from "./SidebarInboxRow"; import { TeamSideSwitch, useTeamSideLists } from "./TeamSideSwitch"; import { SidebarActiveThreads } from "./SidebarActiveThreads"; import { setAttentionPinned, useAttentionPinned } from "./inbox/attention-pinned"; import { useInboxSupport } from "@/state/inbox";
import { TeamMenuItems } from "./SidebarTeamMenu";
@@ -1144,7 +1144,7 @@ export const Sidebar = memo(function Sidebar({ open, onClose, collapseToIcons =
setSearchOpen(true);
toggleCollapsed();
};
- const plusItem = cn(MENU_ITEM, "text-ink hover:bg-menu-hover"), plusBot = state.activeView === "chat" ? state.bots.find((candidate) => candidate.id === state.selectedId) : undefined;
+ const plusItem = cn(MENU_ITEM, "text-ink hover:bg-menu-hover"), plusBot = state.activeView === "chat" ? state.bots.find((candidate) => candidate.id === state.selectedId) : undefined, newBotHere = useNewBotHereLabel();
const plusControl = (
<div ref={plusMenuRef} className="contents">
<button
@@ -1184,9 +1184,9 @@ export const Sidebar = memo(function Sidebar({ open, onClose, collapseToIcons =
className={plusItem}
>
<BotIcon size={16} className="text-ink-secondary" />
- <span className="flex-1">{advanced ? t("sidebar.newBot") : t("sidebar.newBotSimple")}</span>
+ <span className="flex-1">{newBotHere ?? (advanced ? t("sidebar.newBot") : t("sidebar.newBotSimple"))}</span>
{advanced && <ShortcutHint id="new-bot" />}
- </button>}
+ </button>}{(teamSettingsAllowed !== false || state.config?.team) && newBotHere && <NewBotOtherPlaceItem itemClass={plusItem} onClose={() => setPlusOpen(false)} />}
<button
onClick={() => {
setPlusOpen(false);
diff --git a/src/lib/places-together.test.ts b/src/lib/places-together.test.ts
index 76b6300227..865146dd26 100644
--- a/src/lib/places-together.test.ts
+++ b/src/lib/places-together.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
-import { matchingRows, placedKey, type PlaceBotRow } from "./places-together";
+import { aiLabel, matchingRows, newBotDifference, placedKey, type NewBotChoice, type PlaceBotRow } from "./places-together";
const row = (home: "computer" | "cloud", id: string, name: string, over: Partial<PlaceBotRow> = {}): PlaceBotRow => ({ home, id, threadId: `t-${id}`, name, ...over });
@@ -18,3 +18,31 @@ describe("the other place's bots beside this page's own", () => {
expect(matchingRows(rows, "zzz")).toEqual([]);
});
});
+
+describe("what differs about making a bot in the other place", () => {
+ const there = (ais: string[] | null, state: NewBotChoice["state"] = "ready", home: NewBotChoice["home"] = "cloud") => ({ home, state, ais });
+
+ it("says which AIs are signed in on one side only", () => {
+ expect(newBotDifference(["Claude", "Codex"], there(["claude", "Included AI"]))).toEqual({ kind: "ais", onlyThere: ["Included AI"], onlyHere: ["Codex"] });
+ expect(newBotDifference(["Claude"], there(["Claude", "Codex"]))).toEqual({ kind: "ais", onlyThere: ["Codex"], onlyHere: [] });
+ });
+
+ it("says nothing when both sides match, or the other place could not be asked", () => {
+ expect(newBotDifference(["Claude"], there(["Claude"]))).toBeNull();
+ expect(newBotDifference(["Claude"], there(null))).toBeNull();
+ expect(newBotDifference(["Claude"], null)).toBeNull();
+ });
+
+ it("says a sleeping Cloud will be woken, and that a place has no AI yet", () => {
+ expect(newBotDifference(["Claude"], there(null, "asleep"))).toEqual({ kind: "asleep" });
+ expect(newBotDifference(["Claude"], there([]))).toEqual({ kind: "noAi" });
+ expect(newBotDifference([], there(null, "offline", "computer"))).toBeNull();
+ });
+
+ it("never words an AI by a name that holds an email address: its engine's name stands in", () => {
+ const engine = (kind: string) => `engine:${kind}`;
+ expect(aiLabel("Claude", "claudeAgent", engine)).toBe("Claude");
+ expect(aiLabel("[email protected]", "codex", engine)).toBe("engine:codex");
+ expect(aiLabel("Work ([email protected])", "codex", engine)).toBe("engine:codex");
+ });
+});
diff --git a/src/lib/places-together.ts b/src/lib/places-together.ts
index 15108eefa8..a89c4d847d 100644
--- a/src/lib/places-together.ts
+++ b/src/lib/places-together.ts
@@ -1,6 +1,6 @@
// This computer and My Cloud together (electron/places-together.mjs), as a page sees it: the other place's bots, listed
// beside its own. Every row carries its `home`, and ids are unique only within a place, so rows are keyed by home and id.
-import { useEffect, useSyncExternalStore } from "react";
+import { useEffect, useState, useSyncExternalStore } from "react";
import type { BotHome, PlaceBotRow, PlacesTogetherState } from "../../electron/places-together.mjs";
export type { BotHome, PlaceBotRow, PlacesTogetherState };
@@ -62,3 +62,46 @@ export function resetPlacesTogetherForTest(): void {
known = null;
listeners.clear();
}
+
+export type NewBotChoice = import("../../electron/places-together.mjs").NewBotChoice;
+
+/** What differs about making a bot in the other place, as facts: it sleeps, no AI is ready there, or which AIs are
+ * ready on one side only. Nothing when the two sides match or the other place could not be asked. */
+export function newBotDifference(hereAis: readonly string[], choice: (Pick<NewBotChoice, "home" | "state"> & { ais: readonly string[] | null }) | null):
+ { kind: "asleep" } | { kind: "noAi" } | { kind: "ais"; onlyThere: string[]; onlyHere: string[] } | null {
+ if (!choice) return null;
+ if (choice.home === "cloud" && (choice.state === "asleep" || choice.state === "waking")) return { kind: "asleep" };
+ if (!choice.ais) return null;
+ if (!choice.ais.length) return { kind: "noAi" };
+ const fold = (name: string) => name.trim().toLowerCase();
+ const here = new Set(hereAis.map(fold)), there = new Set(choice.ais.map(fold));
+ const onlyThere = [...choice.ais].filter((name) => !here.has(fold(name))), onlyHere = hereAis.filter((name) => !there.has(fold(name)));
+ return onlyThere.length || onlyHere.length ? { kind: "ais", onlyThere, onlyHere } : null;
+}
+
+/** An AI's name for a line the person reads: the name they gave it, or its engine's name when that name holds an
+ * email address, which is never shown beside another place. */
+export function aiLabel(name: string, kind: string, engineName: (kind: string) => string): string {
+ return /\S@\S/.test(name) ? engineName(kind) : name;
+}
+
+/** The other place as the + shows it, asked each time the menu opens. */
+export function readNewBotChoice(): Promise<NewBotChoice | null> {
+ return bridge()?.newBotChoice?.().catch(() => null) ?? Promise.resolve(null);
+}
+
+/** Makes the new bot in the other place: main opens it, and that place makes the bot. */
+export function newBotInOtherPlace(): void {
+ void bridge()?.newBot?.().catch(() => {});
+}
+
+/** The other place asked for a new bot here: `make` runs once this page is ready for it. */
+export function useNewBotFromOtherPlace(ready: boolean, make: () => void): void {
+ const [asked, setAsked] = useState(false);
+ useEffect(() => bridge()?.onNewBot?.(() => setAsked(true)), []);
+ useEffect(() => {
+ if (!asked || !ready) return;
+ setAsked(false);
+ make();
+ }, [asked, ready, make]);
+}
diff --git a/src/locales/en.json b/src/locales/en.json
index 721b0bfdaf..85ab39d615 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -10944,5 +10944,12 @@
"together.switch.title": "This computer and My Cloud together",
"together.switch.line": "Off by default. The Cloud's bots and this computer's bots show in one list, and each opens where it lives.",
"together.switch.failed": "That couldn't be saved. Try again.",
- "together.state.signin": "Open My Cloud once to sign in."
+ "together.state.signin": "Open My Cloud once to sign in.",
+ "sidebar.newBotOn.computer": "New bot on this computer",
+ "sidebar.newBotOn.cloud": "New bot on My Cloud",
+ "sidebar.newBotOn.asleep": "My Cloud is asleep. This wakes it.",
+ "sidebar.newBotOn.noAi": "No AI is signed in there yet.",
+ "sidebar.newBotOn.onlyThere": "Signed in only there: {ais}.",
+ "sidebar.newBotOn.onlyHere": "Signed in only here: {ais}.",
+ "sidebar.newBotOn.needsUpdate": "My Cloud needs its next update for this."
}
diff --git a/src/locales/pt-br.json b/src/locales/pt-br.json
index 99eb7ae562..5f5ace01ce 100644
--- a/src/locales/pt-br.json
+++ b/src/locales/pt-br.json
@@ -10944,5 +10944,12 @@
"together.switch.title": "Este computador e o My Cloud juntos",
"together.switch.line": "Desativado por padrão. Os bots do Cloud e os deste computador aparecem em uma só lista, e cada um abre onde está.",
"together.switch.failed": "Não foi possível salvar. Tente de novo.",
- "together.state.signin": "Abra o My Cloud uma vez para entrar."
+ "together.state.signin": "Abra o My Cloud uma vez para entrar.",
+ "sidebar.newBotOn.computer": "Novo bot neste computador",
+ "sidebar.newBotOn.cloud": "Novo bot no My Cloud",
+ "sidebar.newBotOn.asleep": "O My Cloud está em repouso. Isto o ativa.",
+ "sidebar.newBotOn.noAi": "Nenhuma IA está conectada lá ainda.",
+ "sidebar.newBotOn.onlyThere": "Conectada só lá: {ais}.",
+ "sidebar.newBotOn.onlyHere": "Conectada só aqui: {ais}.",
+ "sidebar.newBotOn.needsUpdate": "O My Cloud precisa da próxima atualização para isso."
}
diff --git a/src/locales/source-hashes.json b/src/locales/source-hashes.json
index 8ef3cf2950..b59f088825 100644
--- a/src/locales/source-hashes.json
+++ b/src/locales/source-hashes.json
@@ -37031,7 +37031,14 @@
"together.switch.title": "2829f92e4a9012d2265d7a82806d5750743ca14c0600d688485825dd4272938a",
"together.switch.line": "f1da9a3fe37ffcb0273f52889240d8e3d13709220eca9c08b5b923f9def19409",
"together.switch.failed": "ad8287436402edb5c91ee0cc4bfe88f3301bac459a7d49e4cd2c564fa20aa1b8",
- "together.state.signin": "010c70e3503b8907767eb9dd465788bb7698d05ccddc383e0685031935a70db2"
+ "together.state.signin": "010c70e3503b8907767eb9dd465788bb7698d05ccddc383e0685031935a70db2",
+ "sidebar.newBotOn.computer": "176820cb9508e2bea1ff6e6fc3682f0fd1f40432ea13da222725fb7d7666cd13",
+ "sidebar.newBotOn.cloud": "73bae32207d218e788c314dd82fdf2bf2d1a6e80febdb0101a3d897c0bd269db",
+ "sidebar.newBotOn.asleep": "8f27c03517f86b5fedc5cbdf7bc50e8d761809c4a9f3ab3e277cbca202b47fc8",
+ "sidebar.newBotOn.noAi": "90560bfa52da1eeef7f9a7e212ab43b68e8a9104bf02cff500b08e8440d3e86a",
+ "sidebar.newBotOn.onlyThere": "ee143ffe98b9c13337df5499526fa6b85e2df7f1b595a43f94dd907a74ab3789",
+ "sidebar.newBotOn.onlyHere": "5fa107188d3ebf59545c5522c3540371a95d16a3625a4f57e84f093849baabc4",
+ "sidebar.newBotOn.needsUpdate": "2fe10ee88189ee8ef942992b455e968fed8af782c1e7353b5a1ac4c54365c1b0"
},
"zh": {
"pro.fromPrice": "a48a04a457d60b08b54fc83e7a6c4584ffedb1e23621859084900c8521a3af7b",
@@ -47269,7 +47276,14 @@
"together.switch.title": "2829f92e4a9012d2265d7a82806d5750743ca14c0600d688485825dd4272938a",
"together.switch.line": "f1da9a3fe37ffcb0273f52889240d8e3d13709220eca9c08b5b923f9def19409",
"together.switch.failed": "ad8287436402edb5c91ee0cc4bfe88f3301bac459a7d49e4cd2c564fa20aa1b8",
- "together.state.signin": "010c70e3503b8907767eb9dd465788bb7698d05ccddc383e0685031935a70db2"
+ "together.state.signin": "010c70e3503b8907767eb9dd465788bb7698d05ccddc383e0685031935a70db2",
+ "sidebar.newBotOn.computer": "176820cb9508e2bea1ff6e6fc3682f0fd1f40432ea13da222725fb7d7666cd13",
+ "sidebar.newBotOn.cloud": "73bae32207d218e788c314dd82fdf2bf2d1a6e80febdb0101a3d897c0bd269db",
+ "sidebar.newBotOn.asleep": "8f27c03517f86b5fedc5cbdf7bc50e8d761809c4a9f3ab3e277cbca202b47fc8",
+ "sidebar.newBotOn.noAi": "90560bfa52da1eeef7f9a7e212ab43b68e8a9104bf02cff500b08e8440d3e86a",
+ "sidebar.newBotOn.onlyThere": "ee143ffe98b9c13337df5499526fa6b85e2df7f1b595a43f94dd907a74ab3789",
+ "sidebar.newBotOn.onlyHere": "5fa107188d3ebf59545c5522c3540371a95d16a3625a4f57e84f093849baabc4",
+ "sidebar.newBotOn.needsUpdate": "2fe10ee88189ee8ef942992b455e968fed8af782c1e7353b5a1ac4c54365c1b0"
},
"zh-tw": {
"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",
diff --git a/src/locales/zh.json b/src/locales/zh.json
index e09ab10a14..75eb14c3ea 100644
--- a/src/locales/zh.json
+++ b/src/locales/zh.json
@@ -10237,5 +10237,12 @@
"together.switch.title": "这台电脑和 My Cloud 合在一起",
"together.switch.line": "默认关闭。Cloud 上的机器人和这台电脑上的机器人显示在同一个列表中,各自在所在的位置打开。",
"together.switch.failed": "未能保存。请重试。",
- "together.state.signin": "打开一次 My Cloud 以登录。"
+ "together.state.signin": "打开一次 My Cloud 以登录。",
+ "sidebar.newBotOn.computer": "在这台电脑上新建机器人",
+ "sidebar.newBotOn.cloud": "在 My Cloud 上新建机器人",
+ "sidebar.newBotOn.asleep": "My Cloud 已休眠。这会唤醒它。",
+ "sidebar.newBotOn.noAi": "那里还没有登录任何 AI。",
+ "sidebar.newBotOn.onlyThere": "只在那里登录:{ais}。",
+ "sidebar.newBotOn.onlyHere": "只在这里登录:{ais}。",
+ "sidebar.newBotOn.needsUpdate": "My Cloud 需要下一次更新才能这样做。"
}