Skip to content

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

Secret cards keep their field on a page reached through a paired desktop

milind-soni16837609147e
diff --git a/electron/home-window.node-test.mjs b/electron/home-window.node-test.mjs
index 93084e6929..915b3c34fe 100644
--- a/electron/home-window.node-test.mjs
+++ b/electron/home-window.node-test.mjs
@@ -358,10 +358,10 @@ test("the window's IPC: the screen reads and retries, My Cloud's page renews its
});
const PRELOAD = readFileSync(new URL("./preload.cjs", import.meta.url), "utf8");
-function preload(origin, { home = false, activation = false } = {}) {
+function preload(origin, { home = false, activation = false, pairedElsewhere = false } = {}) {
let bridge; const invoked = [], synced = [], listeners = new Map();
vm.runInNewContext(PRELOAD, {
- process: { platform: "darwin", argv: [`--omb-local-origin=${LOCAL}`, "--omb-company-desktop=1"] },
+ process: { platform: "darwin", argv: [`--omb-local-origin=${LOCAL}`, ...(pairedElsewhere ? ["--openmausbot-remote-client"] : ["--omb-company-desktop=1"])] },
location: { origin }, navigator: { userActivation: { isActive: activation } }, TextEncoder, localStorage: { getItem: () => null },
queueMicrotask,
require: () => ({ webUtils: {}, contextBridge: { exposeInMainWorld: (_name, value) => { bridge = value; } },
@@ -372,6 +372,12 @@ function preload(origin, { home = false, activation = false } = {}) {
return { bridge, invoked, synced, tell };
}
+test("My Cloud's page in the app is the Cloud's own page, never a remote client: only a desktop paired to another computer is one", () => {
+ assert.equal(preload(CLOUD, { home: true }).bridge.remoteClient, undefined, "a Cloud's own page isn't told it is remote at all");
+ assert.equal(preload(LOCAL).bridge.remoteClient?.active, false);
+ assert.equal(preload(LOCAL, { pairedElsewhere: true }).bridge.remoteClient?.active, true);
+});
+
test("My Cloud's own page, once it is home, gets this app's chat links, diagnostics and its session renewal; any other server's page doesn't", async () => {
const keys = ["home", "onChatLink", "onPackageInstall", "exportDiagnostics", "openLogsFolder"];
const home = preload(CLOUD, { home: true });
diff --git a/src/components/SecretRequestCard.test.ts b/src/components/SecretRequestCard.test.ts
index 2ec687a936..98fff5b3d8 100644
--- a/src/components/SecretRequestCard.test.ts
+++ b/src/components/SecretRequestCard.test.ts
@@ -73,6 +73,30 @@ describe("SecretRequestCard superseded requests", () => {
});
});
+describe("SecretRequestCard on a page reached through a desktop paired to another computer", () => {
+ const remote = (secret: Record<string, unknown>) => {
+ vi.stubGlobal("window", { ogb: { remoteClient: { active: true } } });
+ return view(secret);
+ };
+
+ it("offers the field for a secret the server keeps: a custom one, or a provider key", () => {
+ for (const secret of [
+ { target: "customSecret", label: "Mailbox password", delivery: "ref", placeholder: "", helpUrl: "" },
+ { target: "openaiApiKey", label: "OpenAI API key" },
+ ]) {
+ const html = remote(secret);
+ expect(html, secret.target).toContain('type="password"');
+ expect(html, secret.target).not.toContain("must be saved on the host computer");
+ }
+ });
+
+ it("sends a key the host computer keeps in its own encrypted store to that computer", () => {
+ const html = remote({ target: "boxToken", label: "Boat token" });
+ expect(html).toContain("must be saved on the host computer");
+ expect(html).not.toContain('type="password"');
+ });
+});
+
describe("SecretRequestCard ask card", () => {
it("waits as a compact ask card with a masked field", () => {
const html = view({});
diff --git a/src/components/SecretRequestCard.tsx b/src/components/SecretRequestCard.tsx
index d8d1814bca..d4e2e0ab14 100644
--- a/src/components/SecretRequestCard.tsx
+++ b/src/components/SecretRequestCard.tsx
@@ -25,7 +25,6 @@ export function SecretRequestCard({
}) {
const { dispatch } = useStore();
const secret = message.secret!;
- const remoteClient = window.ogb?.remoteClient?.active === true;
const [value, setValue] = useState("");
const [saving, setSaving] = useState(false);
const [savedLocally, setSavedLocally] = useState(false);
@@ -33,6 +32,9 @@ export function SecretRequestCard({
const endpoint = `/api/bots/${encodeURIComponent(botId)}/secret-cards/${encodeURIComponent(message.id)}`;
const error = localError ?? secret.error;
const custom = secret.target === CUSTOM_SECRET_TARGET;
+ // A page reached through a desktop paired to another computer: a key that computer keeps in its own encrypted store can
+ // only be typed there. Anything its server keeps, a custom secret or a provider key, is typed here like on any page.
+ const onlyOnHost = window.ogb?.remoteClient?.active === true && secret.target !== CUSTOM_SECRET_TARGET && desktopCredentialSlot(secret.target) !== null;
const outcome = credentialResumeOutcome(secret);
const provided = outcome === "provided";
const declined = outcome === "dismissed";
@@ -196,7 +198,7 @@ export function SecretRequestCard({
onDismiss={dismiss}
dismissLabel="Not now"
>
- {remoteClient ? (
+ {onlyOnHost ? (
<div className="text-[13px] leading-relaxed text-ink-secondary">
This key must be saved on the host computer. Open this conversation on the host to continue securely.
</div>