Skip to content

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

Sign out clears every Cloud session, and a Cloud joining the list leaves the window where it is (#4327)

Milind Soni03c6b16bdb02
diff --git a/electron/account-places.mjs b/electron/account-places.mjs
index 3d5a0e863d..b42d167727 100644
--- a/electron/account-places.mjs
+++ b/electron/account-places.mjs
@@ -12,12 +12,21 @@ const OWN_STORAGE = Object.freeze(["cookies"]);
/** `mine`: My Cloud's verified address, for a My Cloud that was saved by hand before it was known to be one. */
export const accountPlace = (entry, mine = null) => entry?.kind !== "local" && Boolean(entry?.home === true || entry?.team || entry?.cloud || (mine && entry?.origin === mine));
-/** The saved places without the account's, and which those were. The window goes to This computer if it showed one of them. */
+/** The saved places that are the account's. */
+export const accountPlaces = (saved, mine = null) => saved.environments.filter((entry) => accountPlace(entry, mine));
+
+/** The saved places without `left`, by id. The window goes to This computer if it showed one of them. */
+export function withoutPlaces(saved, left) {
+ const ids = new Set(left.map((entry) => entry.id));
+ if (!saved.environments.some((entry) => ids.has(entry.id))) return saved;
+ const active = ids.has(saved.activeId) ? environments.LOCAL_ID : saved.activeId;
+ return { ...saved, environments: saved.environments.filter((entry) => !ids.has(entry.id)), activeId: active };
+}
+
+/** The saved places without the account's, and which those were. */
export function withoutAccountPlaces(saved, mine = null) {
- const left = saved.environments.filter((entry) => accountPlace(entry, mine));
- if (!left.length) return { saved, left };
- const active = left.some((entry) => entry.id === saved.activeId) ? environments.LOCAL_ID : saved.activeId;
- return { saved: { ...saved, environments: saved.environments.filter((entry) => !left.includes(entry)), activeId: active }, left };
+ const left = accountPlaces(saved, mine);
+ return { saved: withoutPlaces(saved, left), left };
}
/** What the window holds for each of these places goes: the next opening signs in with the Admin's one-time code. */
diff --git a/electron/accounts-main.mjs b/electron/accounts-main.mjs
index 59b0f5313d..a3816fb1db 100644
--- a/electron/accounts-main.mjs
+++ b/electron/accounts-main.mjs
@@ -1,7 +1,7 @@
// Who is signed in on this device, for the You menu. The list goes only to this app's own pages: this computer's and the
// rail's. A Cloud's or a server's page never reads it, because it would learn the addresses of the person's other accounts;
// it may only ask main, from the person's click, to open the sheet on the rail's page.
-import { withoutAccountPlaces, clearPlaceStorage } from "./account-places.mjs";
+import { accountPlaces, clearPlaceStorage, withoutPlaces } from "./account-places.mjs";
/** The sign-in as the You menu shows it: never a token, and no account while none is signed in. */
export function accountsView(state) {
@@ -10,14 +10,20 @@ export function accountsView(state) {
return { active: { id: account.id, email: account.email, ...(state.status === "reauth-required" ? { signIn: true } : {}) }, others: [] };
}
-/** Everything of the account this window held: its places leave the list, the window leaves them, and their sessions go. */
-export function createAccountLeave({ saved, persist, session, mine, leaveWindow, log = () => {} }) {
- return async () => {
- const { saved: next, left } = withoutAccountPlaces(saved(), mine());
- if (left.length) persist(next);
- await leaveWindow();
- await clearPlaceStorage(session(), left, log);
- return left;
+/** Everything of the account this window held. `places()` names them while the sign-in still says which Cloud is My Cloud:
+ * a My Cloud saved by hand carries no other mark, and the sign-in names none once it has ended. `finish(left)`, once it has:
+ * they leave the list, the window leaves them, and once nothing is still waiting on them (`settled`) their sessions go. */
+export function createAccountLeave({ saved, persist, session, mine, leaveWindow, settled = async () => {}, log = () => {} }) {
+ return {
+ places: () => accountPlaces(saved(), mine()),
+ async finish(left) {
+ const next = withoutPlaces(saved(), left);
+ if (next !== saved()) persist(next);
+ await leaveWindow();
+ await settled();
+ await clearPlaceStorage(session(), left, log);
+ return left;
+ },
};
}
@@ -31,7 +37,7 @@ export function createAccountLeave({ saved, persist, session, mine, leaveWindow,
* holdSheet(open: boolean): void,
* tellSheet(): void,
* leaving(): void,
- * leave(): Promise<unknown>,
+ * leave: ReturnType<typeof createAccountLeave>,
* show(): Promise<unknown>,
* tell(): void,
* }} deps `ownPage`: this app's own page in the window, or the rail's. `placePage`: the page of a place of the person's own
@@ -49,8 +55,9 @@ export function installAccounts({ ipcMain, ownPage, placePage, account, client,
});
const signOutActive = () => serial(async () => {
leaving();
+ const left = leave.places();
const after = await client().signOut();
- await leave();
+ await leave.finish(left);
await show();
tell();
return after;
diff --git a/electron/accounts-main.node-test.mjs b/electron/accounts-main.node-test.mjs
index 9c299918d0..1270b13c19 100644
--- a/electron/accounts-main.node-test.mjs
+++ b/electron/accounts-main.node-test.mjs
@@ -1,6 +1,7 @@
import assert from "node:assert/strict";
+import { readFileSync } from "node:fs";
import test from "node:test";
-import { accountPlace, clearPlaceStorage, withoutAccountPlaces } from "./account-places.mjs";
+import { accountPlace, accountPlaces, clearPlaceStorage, withoutAccountPlaces, withoutPlaces } from "./account-places.mjs";
import { accountsView, createAccountLeave, installAccounts } from "./accounts-main.mjs";
const signedIn = { status: "connected", account: { id: "a", email: "[email protected]" }, deviceId: "d" };
@@ -11,7 +12,7 @@ function harness({ state = signedIn, placePage = () => true, ownPage = () => tru
const client = { state: () => current, signOut: async () => { calls.push("sign-out"); current = { status: "signed-out" }; return current; } };
const accounts = installAccounts({
ipcMain: { handle: (channel, handler) => handlers.set(channel, handler) }, ownPage, placePage, account: () => client, client: () => client,
- holdSheet: (open) => calls.push(`hold:${open}`), tellSheet: () => calls.push("tell-sheet"), leaving: () => calls.push("leaving"), leave: async () => calls.push("leave"), show: async () => calls.push("show"), tell: () => calls.push("tell"),
+ holdSheet: (open) => calls.push(`hold:${open}`), tellSheet: () => calls.push("tell-sheet"), leaving: () => calls.push("leaving"), leave: { places: () => { calls.push("places"); return []; }, finish: async () => calls.push("leave") }, show: async () => calls.push("show"), tell: () => calls.push("tell"),
});
return { handlers, calls, accounts, call: (channel, ...args) => handlers.get(channel)({}, ...args) };
}
@@ -45,10 +46,24 @@ test("the sheet asked for before the rail's page was up opens once when that pag
assert.deepEqual(f.calls, ["hold:true", "tell-sheet", "hold:false"]);
});
-test("sign out: the window lets go first, the sign-in ends, the account's places leave, then the window goes where it belongs", async () => {
+test("sign out: the window lets go, the account's places are named while the sign-in still names My Cloud, the sign-in ends, they leave, then the window goes where it belongs", async () => {
const f = harness();
assert.deepEqual(await f.call("accounts:sign-out", "a"), { active: null, others: [] });
- assert.deepEqual(f.calls, ["leaving", "sign-out", "leave", "show", "tell"]);
+ assert.deepEqual(f.calls, ["leaving", "places", "sign-out", "leave", "show", "tell"]);
+});
+
+test("a My Cloud saved by hand, which carries no mark of its own, leaves with the account although the sign-in no longer names it by the time its session goes", async () => {
+ const HOME = "https://byhand.example.test";
+ let state = signedIn, saved = { activeId: "h", environments: [{ id: "h", kind: "remote", origin: HOME, name: "My server" }, { id: "s", kind: "remote", origin: "https://other.example", name: "Other" }] };
+ const cleared = [];
+ const client = { state: () => state, signOut: async () => { state = { status: "signed-out" }; return state; } };
+ const leave = createAccountLeave({ saved: () => saved, persist: (next) => { saved = next; }, mine: () => (state.status === "connected" ? HOME : null), leaveWindow: async () => {},
+ session: () => ({ clearStorageData: async ({ origin }) => { cleared.push(origin); } }) });
+ const accounts = installAccounts({ ipcMain: { handle() {} }, ownPage: () => true, placePage: () => true, account: () => client, client: () => client, leave, holdSheet() {}, tellSheet() {}, leaving() {}, show: async () => {}, tell() {} });
+ await accounts.signOutActive();
+ assert.deepEqual(saved.environments.map((entry) => entry.id), ["s"], "the hand-saved My Cloud left the list; the other server stays");
+ assert.equal(saved.activeId, "local");
+ assert.deepEqual(cleared, [HOME]);
});
test("signing out an account that isn't the one here changes nothing", async () => {
@@ -91,7 +106,40 @@ test("leaving: the list changes, then the window leaves, and only then the sessi
const order = [];
const leave = createAccountLeave({ saved: () => places, persist: () => order.push("persist"), mine: () => null, leaveWindow: async () => order.push("window"),
session: () => ({ clearStorageData: async () => { order.push("clear"); } }) });
- const left = await leave();
+ const left = await leave.finish(leave.places());
assert.equal(left.length, 3);
assert.deepEqual(order, ["persist", "window", "clear", "clear", "clear"]);
});
+
+test("sessions go only after what was still waiting on those places has been answered, since a Cloud's answer re-issues its cookie", async () => {
+ const order = [];
+ let answer;
+ const waiting = new Promise((resolve) => { answer = resolve; });
+ const jar = new Map(places.environments.filter((entry) => entry.origin).map((entry) => [entry.origin, "session"]));
+ const leave = createAccountLeave({ saved: () => places, persist: () => order.push("persist"), mine: () => null, leaveWindow: async () => order.push("window"),
+ settled: () => waiting.then(() => { jar.set("https://home-a.test", "re-issued in the disconnect's answer"); order.push("answered"); }),
+ session: () => ({ clearStorageData: async ({ origin }) => { order.push("clear"); jar.delete(origin); } }) });
+ const left = leave.finish(leave.places());
+ await new Promise((resolve) => setImmediate(resolve));
+ assert.deepEqual(order, ["persist", "window"], "nothing is cleared while an answer is on its way");
+ answer();
+ await left;
+ assert.deepEqual(order, ["persist", "window", "answered", "clear", "clear", "clear"]);
+ assert.equal(jar.has("https://home-a.test"), false, "the re-issued cookie went with the rest");
+});
+
+test("the app waits for lending's last answers before it clears a signed-out account's sessions", () => {
+ const main = readFileSync(new URL("./main.mjs", import.meta.url), "utf8");
+ assert.match(main, /createAccountLeave\(\{[^\n]*settled: \(\) => computerSharing\?\.goodbyesDone\(\)/);
+});
+
+test("a My Cloud saved by hand is the account's only while the sign-in names it; what left is removed by id, so a list that changed meanwhile loses nothing else", () => {
+ const byHand = { id: "h", kind: "remote", origin: "https://byhand.example.test", name: "My server" };
+ const saved = { activeId: "h", environments: [byHand, places.environments[3]] };
+ assert.deepEqual(accountPlaces(saved, "https://byhand.example.test").map((entry) => entry.id), ["h"]);
+ assert.deepEqual(accountPlaces(saved, null), [], "once the sign-in has ended, nothing says which server was My Cloud");
+ const changed = { activeId: "h", environments: [...saved.environments, { id: "new", kind: "remote", origin: "https://new.example", name: "New" }] };
+ assert.deepEqual(withoutPlaces(changed, [byHand]).environments.map((entry) => entry.id), ["by-hand", "new"]);
+ assert.equal(withoutPlaces(changed, [byHand]).activeId, "local");
+ assert.equal(withoutPlaces(changed, []), changed, "nothing to remove: the same list");
+});
diff --git a/electron/computer-sharing.d.mts b/electron/computer-sharing.d.mts
index 99717b1e4c..b766e985c9 100644
--- a/electron/computer-sharing.d.mts
+++ b/electron/computer-sharing.d.mts
@@ -144,6 +144,8 @@ export function createComputerSharing(options: {
cloudState(env: Workspace | null | undefined): CloudLendingState;
/** The folders lent to My Cloud, for Files' copies of them (electron/lent-folders.mjs). */
lentToCloud(env: Workspace | null | undefined): { lendingId: string; folders: Array<{ id: string; path: string; name: string; write: boolean }>; protectedPaths: string[]; paused?: true } | { off: true };
+ /** Lending's last requests have been answered or have timed out; a Cloud's answer can re-issue its session cookie. */
+ goodbyesDone(): Promise<unknown>;
lendingToCloud(): boolean;
/** A server is using this computer now: a job running on it, or its browsing going through this computer. */
busy(): boolean;
diff --git a/electron/computer-sharing.mjs b/electron/computer-sharing.mjs
index 8131136eee..b762dcf3db 100644
--- a/electron/computer-sharing.mjs
+++ b/electron/computer-sharing.mjs
@@ -561,10 +561,14 @@ export function createComputerSharing({ file, fetch: fetchImpl, environments, cu
return { enabled: grant?.enabled === true, folders: Array.isArray(grant?.folders) ? grant.folders : [], terminal: grant?.terminal === true, computer: grant?.computer === true, ...status.get(id) };
};
// `resumes`: lending waits (for the Cloud sign-in, say) and resumes by itself, so the server keeps it as lent, not stopped.
+ /** Disconnects still waiting for their Cloud's answer. */
+ const goodbyes = new Set();
const disconnect = (env, grant, resumes = false) => {
stop(env.id);
if (resumes && sleepsHere(env) && sleepGate(env).asleep()) return;
- if (grant?.secret) void request(env, `/api/shared-computers/${grant.id}/disconnect`, resumes ? { paused: true } : {}, undefined, grant.secret).catch(() => {});
+ if (!grant?.secret) return;
+ const told = request(env, `/api/shared-computers/${grant.id}/disconnect`, resumes ? { paused: true } : {}, undefined, grant.secret).catch(() => {}).finally(() => { goodbyes.delete(told); });
+ goodbyes.add(told);
};
const cloudState = env => {
const grant = env ? records[env.id] : undefined;
@@ -773,6 +777,9 @@ export function createComputerSharing({ file, fetch: fetchImpl, environments, cu
if (records[env.id]?.enabled !== true) throw new Error("Lending to My Cloud did not start.");
},
paused: () => paused,
+ /** Lending's last requests have been answered or have timed out (10 s at most). Security: a Cloud re-issues its session
+ * cookie in the answer to any request that carried one, so that answer must land before the window's session is cleared. */
+ goodbyesDone: () => Promise.allSettled([...goodbyes, passing]),
/** Every Cloud of the person's own stops using this computer, across restarts too, until resume(). */
pause() {
if (paused || closed) return;
diff --git a/electron/environments.cjs b/electron/environments.cjs
index 55f8e3df59..711e4fb6c3 100644
--- a/electron/environments.cjs
+++ b/electron/environments.cjs
@@ -202,7 +202,8 @@ function reconcileTeams(state, teams, makeId, homeOrigin = null) {
/** The place on screen that is gone: My Cloud is active again (or this computer, without one). */
function withActiveKept(state, homeOrigin) {
- const activeId = state.environments.some((entry) => entry.id === state.activeId) ? state.activeId : state.environments.find((entry) => entry.origin === homeOrigin)?.id ?? LOCAL_ID;
+ const here = state.activeId === LOCAL_ID || state.environments.some((entry) => entry.id === state.activeId);
+ const activeId = here ? state.activeId : state.environments.find((entry) => entry.origin === homeOrigin)?.id ?? LOCAL_ID;
return activeId === state.activeId ? state : { ...state, activeId };
}
diff --git a/electron/environments.node-test.mjs b/electron/environments.node-test.mjs
index 891322c591..d190b1333f 100644
--- a/electron/environments.node-test.mjs
+++ b/electron/environments.node-test.mjs
@@ -468,3 +468,16 @@ test("with My Cloud as home, the menu still folds its status line into the name
assert.equal(item.label, folded ? "My Cloud · Always on" : "My Cloud", platform);
}
});
+
+test("a Cloud or team joining the list leaves this computer's page the active place, as the window still shows it", () => {
+ const HOME = "https://home.example.test";
+ const saved = { environments: [{ id: "h", kind: "remote", name: "My Cloud", origin: HOME, home: true }], activeId: "local" };
+ const teams = env.reconcileTeams(saved, [{ id: "team-a", role: "member", name: "Acme", machine: { origin: "https://acme.example.test" } }], () => "t", HOME);
+ assert.equal(teams.state.environments.length, 2);
+ assert.equal(teams.state.activeId, "local");
+ const clouds = env.reconcileOwnClouds(saved, [{ id: "c2", role: "owner", name: "Second", origin: "https://second.example.test" }], () => "c", HOME);
+ assert.equal(clouds.environments.length, 2);
+ assert.equal(clouds.activeId, "local");
+ const gone = env.reconcileTeams({ environments: [{ id: "t", kind: "remote", name: "Acme", origin: "https://acme.example.test", team: { id: "team-a", role: "member" } }, saved.environments[0]], activeId: "t" }, [], () => "x", HOME);
+ assert.equal(gone.state.activeId, "h", "a place on screen that's gone still falls back to My Cloud");
+});
diff --git a/electron/lending-goodbyes.node-test.mjs b/electron/lending-goodbyes.node-test.mjs
new file mode 100644
index 0000000000..2621be49c2
--- /dev/null
+++ b/electron/lending-goodbyes.node-test.mjs
@@ -0,0 +1,78 @@
+import assert from "node:assert/strict";
+import { randomUUID } from "node:crypto";
+import { mkdtemp, rm } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import path from "node:path";
+import { test } from "node:test";
+import { createComputerSharing } from "./computer-sharing.mjs";
+
+const until = async (check, what) => { for (let i = 0; i < 400; i++) { if (check()) return; await new Promise((resolve) => setTimeout(resolve, 5)); } assert.fail(`never: ${what}`); };
+const settledYet = async (promise) => { let done = false; void promise.then(() => { done = true; }); await new Promise((resolve) => setTimeout(resolve, 25)); return done; };
+
+/** One Cloud of the person's own, lent to, whose answer to a disconnect is held (`hold`) until the test lets it go, or fails (`fail`). */
+async function fixture(t, { screen = () => false } = {}) {
+ const dir = await mkdtemp(path.join(tmpdir(), "omb-lending-goodbyes-"));
+ const env = { id: "cloud-a", origin: "https://a.fixture.test", name: "A's Cloud", cloud: { id: "c" } };
+ const identity = { sessionId: randomUUID(), environmentId: randomUUID() };
+ const f = { env, status: "connected", polls: 0, disconnects: 0, hold: false, fail: false, answer: Promise.withResolvers() };
+ f.sharing = createComputerSharing({
+ file: path.join(dir, "sharing.json"), environments: () => [env], enabled: async () => false, home: path.join(dir, "home"), screen,
+ cloud: () => ({ status: f.status, accountId: "acct-a", origin: env.origin }), myCloud: () => env, ownClouds: () => [env],
+ hostControl: async () => ({ renew: async () => {}, release: async () => {} }),
+ async fetch(url, { signal }) {
+ const route = new URL(url).pathname;
+ if (route === "/api/auth/session") return Response.json({ kind: "session", id: identity.sessionId, cloudHome: true, scopes: ["admin"] });
+ if (route === "/.well-known/openmausbot/environment") return Response.json({ environmentId: identity.environmentId, capabilities: { sharedComputers: true } });
+ if (route.endsWith("/disconnect")) { f.disconnects++; if (f.fail) throw new Error("no answer"); if (f.hold) await f.answer.promise; return Response.json({ ok: true }); }
+ if (route.endsWith("/poll")) { f.polls++; await new Promise((_resolve, reject) => { signal.throwIfAborted(); signal.addEventListener("abort", () => reject(signal.reason), { once: true }); }); }
+ return Response.json({ ok: true });
+ },
+ });
+ t.after(async () => { f.answer.resolve(); f.sharing.close(); await rm(dir, { recursive: true, force: true }); });
+ return f;
+}
+
+test("signing out: lending's goodbye to each Cloud is waited for, so its answer can't put a session cookie back after the clear", async (t) => {
+ const f = await fixture(t);
+ await f.sharing.saveCloud(f.env, { folders: [], internet: true });
+ f.sharing.cloudChanged();
+ await until(() => f.polls > 0, "the lent connection");
+ await f.sharing.goodbyesDone();
+ f.disconnects = 0; f.hold = true;
+ f.status = "signed-out";
+ f.sharing.cloudChanged();
+ await until(() => f.disconnects > 0, "the disconnect");
+ const done = f.sharing.goodbyesDone();
+ assert.equal(await settledYet(done), false, "still waiting for the Cloud's answer");
+ f.answer.resolve();
+ assert.equal(await settledYet(done), true, "answered: the window's session can go now");
+});
+
+test("a goodbye that fails doesn't hold the sign-out up", async (t) => {
+ const f = await fixture(t);
+ await f.sharing.saveCloud(f.env, { folders: [], internet: true });
+ f.sharing.cloudChanged();
+ await until(() => f.polls > 0, "the lent connection");
+ await f.sharing.goodbyesDone();
+ f.fail = true;
+ f.status = "signed-out";
+ f.sharing.cloudChanged();
+ await until(() => f.disconnects > 0, "the disconnect");
+ assert.equal(await settledYet(f.sharing.goodbyesDone()), true);
+});
+
+test("a lending pass under way is waited for too, since its end is what stops the asks' long poll", async (t) => {
+ const screen = Promise.withResolvers();
+ let held = false;
+ const f = await fixture(t, { screen: () => (held ? screen.promise : false) });
+ await f.sharing.saveCloud(f.env, { folders: [], internet: true });
+ f.sharing.cloudChanged();
+ await until(() => f.polls > 0, "the lent connection");
+ await f.sharing.goodbyesDone();
+ held = true;
+ f.sharing.cloudChanged();
+ const done = f.sharing.goodbyesDone();
+ assert.equal(await settledYet(done), false, "the pass is still reading this computer");
+ screen.resolve(false);
+ assert.equal(await settledYet(done), true);
+});
diff --git a/electron/main.mjs b/electron/main.mjs
index 34525b11ef..5864348509 100644
--- a/electron/main.mjs
+++ b/electron/main.mjs
@@ -2688,7 +2688,7 @@ const chromeRail = createChromeRail({ createView: options => new WebContentsView
chromeRail.install(ipcMain);
function railChanged() { chromeRail.refresh(); rail.changed(); }
const accountPages = [() => (mainWindow && !mainWindow.isDestroyed() && senderIsLocal({ sender: mainWindow.webContents }) ? mainWindow.webContents : null), () => ({ send: channel => chromeRail.send(channel) })];
-const accounts = installAccounts({ ipcMain, ownPage: event => chromeRail.owns(event) || cloudPageAsking(event) === "local", placePage: event => cloudPageAsking(event) !== null || ownCloudPage(event) !== null || homeWindow.homePage(event) || (Boolean(ownHome?.home()) && activeEnvironment(environmentsState)?.origin === ownHome.home().origin && workspaceSenderAllowed(event, mainWindow?.webContents, environmentsState, rendererOrigin())), account: () => (app.isPackaged && !desktopRemoteAccess ? cloudAccount : null), client: ensureCloudAccount, holdSheet: open => chromeRail.holdOpen(open), tellSheet: () => chromeRail.send("accounts:open-sheet"), leaving: () => homeWindow.accountLeaving(), leave: createAccountLeave({ saved: () => environmentsState, persist: persistEnvironments, session: () => session.defaultSession, mine: () => myCloud(), leaveWindow: () => (mainWindow && !mainWindow.isDestroyed() && !senderIsLocal({ sender: mainWindow.webContents }) ? navigateMainWindow(rendererOrigin()) : null), log: slog }), show: () => showHome(), tell: () => { for (const page of accountPages) page()?.send("accounts:changed"); } });
+const accounts = installAccounts({ ipcMain, ownPage: event => chromeRail.owns(event) || cloudPageAsking(event) === "local", placePage: event => cloudPageAsking(event) !== null || ownCloudPage(event) !== null || homeWindow.homePage(event) || (Boolean(ownHome?.home()) && activeEnvironment(environmentsState)?.origin === ownHome.home().origin && workspaceSenderAllowed(event, mainWindow?.webContents, environmentsState, rendererOrigin())), account: () => (app.isPackaged && !desktopRemoteAccess ? cloudAccount : null), client: ensureCloudAccount, holdSheet: open => chromeRail.holdOpen(open), tellSheet: () => chromeRail.send("accounts:open-sheet"), leaving: () => homeWindow.accountLeaving(), leave: createAccountLeave({ saved: () => environmentsState, persist: persistEnvironments, session: () => session.defaultSession, mine: () => myCloud(), leaveWindow: () => (mainWindow && !mainWindow.isDestroyed() && !senderIsLocal({ sender: mainWindow.webContents }) ? navigateMainWindow(rendererOrigin()) : null), settled: () => computerSharing?.goodbyesDone(), log: slog }), show: () => showHome(), tell: () => { for (const page of accountPages) page()?.send("accounts:changed"); } });
const rail = installCloudRail({ ipcMain, clipboard, openCloud: openOwnCloud, account: () => (app.isPackaged && !desktopRemoteAccess ? cloudAccount : null),
guard: handler => (event, ...args) => (chromeRail.owns(event) ? handler(event, ...args) : workspaceOnly(handler)(event, ...args)),
lists: event => chromeRail.owns(event), trusted: event => chromeRail.owns(event) || senderIsLocal(event), beside: () => chromeRail.shown(),