Skip to content

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

Lending menu and the move card say bots use the computer you type on

AdityaUmale67eab6f2b385
diff --git a/docs/multi-device.md b/docs/multi-device.md
index c1335e6fe9..136cc75f0a 100644
--- a/docs/multi-device.md
+++ b/docs/multi-device.md
@@ -35,6 +35,8 @@ After a move to My Cloud or your own server, the computer you moved from stops r
twice. The computer still lends the new home its folders, screen and Chrome while the desktop app runs and is signed in.
On your own server this happens by itself only when you are its one owner; on a server with other members or admins,
lending also needs `features.sharedComputers` set to `true` (see [feature-flags.md](feature-flags.md)).
+With two or more computers lent to My Cloud, its bots take the computer you are typing on as "my computer": the one
+whose desktop app sent the message. The lending icon's menu on each computer says so while My Cloud can use it.
## Moving bots by hand
diff --git a/electron/computer-sharing.mjs b/electron/computer-sharing.mjs
index 5d8a74d270..c6b64ce028 100644
--- a/electron/computer-sharing.mjs
+++ b/electron/computer-sharing.mjs
@@ -283,9 +283,9 @@ export function createComputerSharing({ file, fetch: fetchImpl, environments, lo
lending: lent.map(env => env.id),
clouds: (paused ? [...ownClouds(), ...environments().filter(env => records[env.id]?.own && records[env.id].enabled === true)] : lent).map(env => env.name),
// Lent, but the Cloud hasn't accepted this computer yet (or lost it): the menu must not say it can use it. A
- // sleeping My Cloud still can; it wakes when a bot needs this computer.
+ // sleeping My Cloud still can; it wakes when a bot needs this computer. Such a Cloud takes it as the one typed on (typing); a server of their own doesn't.
waiting: lent.filter(env => !status.get(env.id)?.connected && status.get(env.id)?.problem !== "asleep").map(env => env.name),
- ...(problems.length ? { problems } : {}),
+ ...(problems.length ? { problems } : {}), ...(lent.some(env => records[env.id]?.cloud && !ownHomeId(env) && (status.get(env.id)?.connected || status.get(env.id)?.problem === "asleep")) ? { typing: true } : {}),
using: using.map(env => env.name),
...(bots.length ? { bots } : {}),
paused,
diff --git a/electron/lend-automatically.node-test.mjs b/electron/lend-automatically.node-test.mjs
index c3b0cf64bf..f563e91801 100644
--- a/electron/lend-automatically.node-test.mjs
+++ b/electron/lend-automatically.node-test.mjs
@@ -159,6 +159,7 @@ test("each Cloud of the person's own is lent this computer by itself: the intern
const kept = JSON.parse(await readFile(mac.file, "utf8")).records[myCloud.id];
assert.deepEqual({ home: kept.folders[0].home, path: kept.folders[0].path, write: kept.folders[0].write }, { home: true, path: home, write: true });
assert.deepEqual(mac.summaries.at(-1).clouds, ["My Cloud"]);
+ await until(() => mac.summaries.at(-1).typing === true, "the menu bar to say bots use this computer while the person types on it");
});
test("a server of the person's own their bots moved to is lent as their Clouds are, only while it is home, says it is theirs alone and is the server the move chose", async t => {
@@ -179,6 +180,8 @@ test("a server of the person's own their bots moved to is lent as their Clouds a
await until(() => server.connects.length === 1, "Garage server to be lent this computer, with no click");
assert.equal(server.connects[0].terminal, false);
assert.deepEqual(mac.summaries.at(-1).clouds, ["Garage server"], "the menu bar says who can use this computer");
+ await until(() => mac.summaries.at(-1).waiting.length === 0, "Garage server to accept this computer");
+ assert.equal(mac.summaries.at(-1).typing, undefined, "a server of the person's own never matches the computer typed on");
mac.sharing.pause();
assert.equal(mac.summaries.at(-1).paused, true);
await mac.sharing.resume();
diff --git a/electron/lending-indicator.mjs b/electron/lending-indicator.mjs
index 64d2271328..a7db1ba478 100644
--- a/electron/lending-indicator.mjs
+++ b/electron/lending-indicator.mjs
@@ -1,5 +1,5 @@
import nativeText from "./native-text.cjs";
-import { screenFixLabel, screenLine } from "./screen-words.mjs";
+import { namedDevice, screenFixLabel, screenLine } from "./screen-words.mjs";
import { dotIcons } from "./color-dot.mjs";
/** The device word the person knows this computer by. */
@@ -78,6 +78,7 @@ export function createLendingIndicator({ Tray, Menu, nativeImage, iconPath, onPa
const { line, title, screen, pending, problems = [], acting = [] } = indicatorText(view, device, t);
const fix = screen ? screenFixLabel(view.screen, t) : null;
const said = [...acting.map(bot => bot.label), ...line ? [line] : []].join(". ");
+ const typing = view.typing && !view.pauseError ? t("native.lendTray.typing", { device: namedDevice(device, t) }) : null;
tray.setToolTip(`OpenMausBot: ${said}${pending ? `. ${pending}` : ""}${screen ? `. ${screen}` : ""}${problems.length ? `. ${problems.join(". ")}` : ""}`);
// Electron shows a tray title beside the icon on macOS only.
tray.setTitle?.(title);
@@ -89,6 +90,7 @@ export function createLendingIndicator({ Tray, Menu, nativeImage, iconPath, onPa
...problems.map(problem => ({ label: problem, enabled: false })),
...screen ? [{ label: screen, enabled: false }] : [],
...fix ? [{ label: fix, click: () => onStartScreen() }] : [],
+ ...typing ? [{ label: typing, enabled: false }] : [],
{ type: "separator" },
...view.pauseError ? [{ label: t("native.lendTray.retryPause"), click: () => onPause() }] : [],
view.paused ? { label: t("native.lendTray.resume"), click: () => onResume() } : { label: t("native.lendTray.pause"), click: () => onPause() },
@@ -100,9 +102,9 @@ export function createLendingIndicator({ Tray, Menu, nativeImage, iconPath, onPa
]));
};
return {
- update({ clouds = [], using = [], bots = [], paused = false, pauseError, terminal = false, terminalSwitch = true, screen = null, waiting = [], problems = [] }) {
+ update({ clouds = [], using = [], bots = [], paused = false, pauseError, terminal = false, terminalSwitch = true, screen = null, waiting = [], problems = [], typing = false }) {
const next = { clouds: [...clouds], using: paused ? [] : [...using], bots: paused ? [] : bots.map(({ name, color, cloud }) => ({ name, color, cloud })), waiting: paused ? [] : [...waiting], problems: paused ? [] : problems.map(({ name, why }) => ({ name, why })), paused: paused === true, ...pauseError ? { pauseError } : {},
- terminal: terminal === true, terminalSwitch: terminalSwitch !== false,
+ terminal: terminal === true, terminalSwitch: terminalSwitch !== false, typing: !paused && typing === true,
screen: screen ? { ready: screen.ready === true, reason: screen.reason ?? null, fix: screen.fix ?? null, ...(screen.message ? { message: screen.message } : {}) } : null };
if (shown && JSON.stringify(next) === JSON.stringify(shown)) return;
shown = next;
diff --git a/electron/lending-typing.node-test.mjs b/electron/lending-typing.node-test.mjs
new file mode 100644
index 0000000000..e939708a1a
--- /dev/null
+++ b/electron/lending-typing.node-test.mjs
@@ -0,0 +1,36 @@
+import assert from "node:assert/strict";
+import { test } from "node:test";
+
+import { createLendingIndicator } from "./lending-indicator.mjs";
+
+const ready = { ready: true, reason: null };
+const TYPING = "When you type on this PC, bots use it";
+
+function trayMenu(device) {
+ const trays = [];
+ class Tray { constructor() { trays.push(this); } on() {} setToolTip(tip) { this.tip = tip; } setTitle() {} setContextMenu(menu) { this.menu = menu; } isDestroyed() { return false; } destroy() {} }
+ const indicator = createLendingIndicator({ Tray, Menu: { buildFromTemplate: items => items }, nativeImage: { createFromPath: () => ({ resize: () => ({}) }) }, iconPath: "",
+ onPause: () => {}, onResume: () => {}, onActivity: () => {}, onTerminal: () => {}, device });
+ return { update: view => indicator.update(view), labels: () => trays[0].menu.filter(item => item.label).map(item => item.label), item: label => trays[0].menu.find(item => item.label === label), tip: () => trays[0].tip };
+}
+
+test("a computer a Cloud can use now says its bots use it while the person types on it", () => {
+ const tray = trayMenu("PC");
+ tray.update({ clouds: ["My Cloud"], screen: ready, typing: true });
+ assert.deepEqual(tray.labels().slice(0, 2), ["My Cloud can use this PC", TYPING]);
+ assert.equal(tray.item(TYPING).enabled, false, "a plain line, not an action");
+ assert.equal(tray.tip(), "OpenMausBot: My Cloud can use this PC", "the tooltip stays short");
+
+ tray.update({ clouds: ["My Cloud"], screen: { ready: false, reason: "desktop-host-stopped", fix: "start" }, typing: true });
+ assert.equal(tray.labels().indexOf(TYPING), tray.labels().indexOf("Pause") - 1, "after the screen line and its fix, so those stay together");
+});
+
+test("the typing line is left out where no Cloud takes this computer as the one typed on", () => {
+ const tray = trayMenu("PC");
+ tray.update({ clouds: ["Garage server"], screen: ready });
+ assert.ok(!tray.labels().includes(TYPING), "a server of the person's own does not match the typing computer");
+ tray.update({ clouds: ["My Cloud"], paused: true, screen: ready, typing: true });
+ assert.ok(!tray.labels().includes(TYPING), "not while paused");
+ tray.update({ clouds: ["My Cloud"], pauseError: "not saved", screen: ready, typing: true });
+ assert.ok(!tray.labels().includes(TYPING), "not while a pause failed to save");
+});
diff --git a/electron/screen-words.mjs b/electron/screen-words.mjs
index a3a5da9c44..193cdeb1ad 100644
--- a/electron/screen-words.mjs
+++ b/electron/screen-words.mjs
@@ -2,7 +2,7 @@
// the person's own Clouds, from computer control's state.
import nativeText from "./native-text.cjs";
-const namedDevice = (device, t) => device === "computer" ? t("native.lendTray.computer") : device;
+export const namedDevice = (device, t) => device === "computer" ? t("native.lendTray.computer") : device;
/** Why apps and screen aren't available, as one plain sentence without a full stop; null when they are. */
export function screenLine(status, device, t = nativeText.englishText.t) {
diff --git a/src/components/AppNotices.test.ts b/src/components/AppNotices.test.ts
index 6ff191f353..32e2aeb04e 100644
--- a/src/components/AppNotices.test.ts
+++ b/src/components/AppNotices.test.ts
@@ -1270,6 +1270,7 @@ describe("bots in two places", () => {
expect(accepted, "one tap never moves anyone").toEqual([]);
expect(asking).toContain("Move this computer's bots to Garage server?");
expect(asking, "the undo switch is My Cloud's only").not.toContain("Keep this computer's bots on this computer");
+ expect(asking, "only My Cloud is sure to keep using this computer").not.toContain("when you type on it");
press("Move bots");
await flush();
expect(accepted).toEqual([GARAGE.key]);
@@ -1285,6 +1286,7 @@ describe("bots in two places", () => {
const asking = await settle();
expect(asking).toContain("Move this computer's bots to My Cloud?");
expect(asking, "My Cloud names the way back").toContain("Keep this computer's bots on this computer");
+ expect(asking, "the move keeps this computer in use").toContain("Bots on My Cloud still use this computer when you type on it.");
press("Cancel");
const after = await settle();
expect(accepted).toEqual([]);
diff --git a/src/components/TwoPlacesCard.tsx b/src/components/TwoPlacesCard.tsx
index 6b484a7f8d..2bed2a16b2 100644
--- a/src/components/TwoPlacesCard.tsx
+++ b/src/components/TwoPlacesCard.tsx
@@ -27,7 +27,10 @@ export function TwoPlacesCard({ suggest, onBring, onDismiss }: { suggest: TwoPla
onKeyDown={event => { if (event.key === "Escape") { event.preventDefault(); event.stopPropagation(); cancel(); } }}>
<p className="text-[13px] font-medium text-ink">{t("twoPlaces.confirmTitle", { place: suggest.name })}</p>
<p className="mt-1 text-[13px] leading-relaxed text-ink-secondary">{t("twoPlaces.confirm", { place: suggest.name })}</p>
- {suggest.kind === "cloud" && <p className="mt-1 text-[13px] leading-relaxed text-ink-secondary">{t("twoPlaces.undo")}</p>}
+ {suggest.kind === "cloud" && <>
+ <p className="mt-1 text-[13px] leading-relaxed text-ink-secondary">{t("twoPlaces.typing", { place: suggest.name })}</p>
+ <p className="mt-1 text-[13px] leading-relaxed text-ink-secondary">{t("twoPlaces.undo")}</p>
+ </>}
<div className="mt-3 flex flex-wrap items-center gap-3">
<button type="button" data-two-places-move className={PRIMARY_BUTTON} disabled={busy} aria-busy={busy || undefined} onClick={bring}>
{busy && <Loader2 aria-hidden="true" className="size-3.5 shrink-0 animate-spin motion-reduce:animate-none" />}
diff --git a/src/locales/en.json b/src/locales/en.json
index ffaa44f058..c8ff926600 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -850,6 +850,7 @@
"twoPlaces.failed": "Your bots didn't start moving. Try again in a moment.",
"twoPlaces.confirmTitle": "Move this computer's bots to {place}?",
"twoPlaces.confirm": "This computer's bots, with their chats and automations, move to {place} and work there from now on.",
+ "twoPlaces.typing": "Bots on {place} still use this computer when you type on it.",
"twoPlaces.undo": "To bring them back later, turn on “Keep this computer's bots on this computer” in Settings → Import & export.",
"twoPlaces.move": "Move bots",
"rail.removeAsk": "Remove “{name}” from your list? You can buy a new Cloud any time.",
@@ -10034,6 +10035,7 @@
"native.lendTray.usingOne": "{clouds} is using this {device}",
"native.lendTray.botUsing": "{bot} on {cloud} is using this {device}",
"native.lendTray.canUse": "{clouds} can use this {device}",
+ "native.lendTray.typing": "When you type on this {device}, bots use it",
"native.lendTray.problem": "{cloud} can't use this {device}: {why}",
"native.lendTray.problemNoticeTitle": "{cloud} can't use this {device}",
"native.lendTray.myCloud": "My Cloud",
diff --git a/src/locales/pt-br.json b/src/locales/pt-br.json
index 58a571d123..5f4c35ba52 100644
--- a/src/locales/pt-br.json
+++ b/src/locales/pt-br.json
@@ -826,6 +826,7 @@
"twoPlaces.failed": "Não foi possível começar a mover seus bots. Tente novamente em instantes.",
"twoPlaces.confirmTitle": "Mover os bots deste computador para {place}?",
"twoPlaces.confirm": "Os bots deste computador vão para {place} com suas conversas e automações e passam a trabalhar lá.",
+ "twoPlaces.typing": "Os bots em {place} ainda usam este computador quando você digita nele.",
"twoPlaces.undo": "Para trazê-los de volta depois, ative “Manter os bots deste computador neste computador” em Configurações → Importar e exportar.",
"twoPlaces.move": "Mover bots",
"rail.removeAsk": "Remover “{name}” da lista? Você pode comprar um novo Cloud quando quiser.",
@@ -9948,6 +9949,7 @@
"native.lendTray.usingOne": "{clouds} está usando este {device}",
"native.lendTray.botUsing": "{bot} em {cloud} está usando este {device}",
"native.lendTray.canUse": "{clouds} com acesso a este {device}",
+ "native.lendTray.typing": "Quando você digita neste {device}, os bots o usam",
"native.lendTray.problem": "{cloud} não pode usar este {device}: {why}",
"native.lendTray.problemNoticeTitle": "{cloud} não pode usar este {device}",
"native.lendTray.myCloud": "My Cloud",
diff --git a/src/locales/source-hashes.json b/src/locales/source-hashes.json
index a9370bf3aa..f80c4ed93b 100644
--- a/src/locales/source-hashes.json
+++ b/src/locales/source-hashes.json
@@ -37473,7 +37473,9 @@
"viewer.stop": "cae7d57bc067a514b8e34c9589631a95c7dc051638ddd2a190773269279a99df",
"sidebar.preview.waitingFor": "bb64342e2466a9319496bbb378b4711b661425abeb68b009163078d4c49524b6",
"handoff.importSignIn": "6472eeb450eea0fc019b9f5d7e02adbb926cfdff1d9c4e43de7a2aaf9b081fd5",
- "handoff.inPanel": "8ffda3f9407104c180c4fe7b48fa2b6903ca43c9eeea2b1b6ec83befed353a86"
+ "handoff.inPanel": "8ffda3f9407104c180c4fe7b48fa2b6903ca43c9eeea2b1b6ec83befed353a86",
+ "twoPlaces.typing": "d582f47c7efff74c953139f441b4b5f50e903723ebbe07ce84344f6eb67b4ce3",
+ "native.lendTray.typing": "5bb860619c3695e8804791c205e27ed08ed8e1f833ed0e63ccb4e8e008471f06"
},
"zh": {
"pro.fromPrice": "a48a04a457d60b08b54fc83e7a6c4584ffedb1e23621859084900c8521a3af7b",