Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Rail: Rename a server saved by hand, a name kept on this computer only
AdityaUmaled28734b5df0d
diff --git a/electron/cloud-rail.d.mts b/electron/cloud-rail.d.mtsindex db54a6737f..f8bb173ec3 100644--- a/electron/cloud-rail.d.mts+++ b/electron/cloud-rail.d.mts@@ -50,6 +50,8 @@ export interface RailPlace {removable?: true;/** A server connected by hand: Remove from list forgets it on this computer (this app signs out of it there). */forget?: true;+ /** A server connected by hand: its menu offers Rename, a name kept on this computer only. */+ renames?: true;/** A server of the person's own, theirs alone by its own word, that this computer's bots may move to: its menu offers* Make … my home. */makeHome?: true;diff --git a/electron/cloud-rail.mjs b/electron/cloud-rail.mjsindex 999e1e8220..0fc67107c5 100644--- a/electron/cloud-rail.mjs+++ b/electron/cloud-rail.mjs@@ -45,7 +45,7 @@ function circle(entry, { activeId, mine, state, offers, waiting }) {const paint = railPaint(placeLook(entry, { clouds: connected?.clouds ?? null, homeOrigin: mine }), color);return { id: entry.id, name: entry.name, color, kind, opens: true, ...(paint ? { paint } : {}), ...(entry.id === activeId ? { active: true } : {}),...(progress !== null ? { progress } : {}), ...(problem || waiting(entry.id) ? { attention: true } : {}), ...(listed?.managed === false ? serverState(listed, connected?.latestVersion ?? null) : {}),- ...(kind === "cloud" && cloudState(listed) === "ended" ? { ended: true } : {}), ...(listed?.removable && kind === "cloud" ? { removable: true, cloudId: listed.id } : {}), ...(kind === "server" ? { removable: true, forget: true } : {}),+ ...(kind === "cloud" && cloudState(listed) === "ended" ? { ended: true } : {}), ...(listed?.removable && kind === "cloud" ? { removable: true, cloudId: listed.id } : {}), ...(kind === "server" ? { removable: true, forget: true, renames: true } : {}),...(kind === "server" && offers(entry) ? { makeHome: true } : {}) };}@@ -155,11 +155,12 @@ const CHOICES = Object.freeze(["cloud", "link", "address"]);* `places()` is railPlaces' list now; `open(id)` main's own switch; `add` the + sheet's fixed actions; `account()` the* MausBot Cloud sign-in; `targets()` the pages told when something changed; `makeHome(id)` starts the move to a server* of the person's own (own-home-main.mjs `start`). `switchAccount(id)`: that account becomes the one in use (cloud-accounts.mjs).+ * `rename(id, name)`: a server saved by hand takes that name on this computer: true when saved, false for a name that is blank; a throw is a failed save.* `openProfile(id)`: the window shows that workspace of this computer's own (local-profiles.mjs `open`). `local`: those* workspaces' +, names, colours and removal (local-profiles.mjs), and the end of a switch still waiting when another place opens.* `ask(id, run)`: a circle's click, listed at once, `run` told when a newer one came (place-switch.mjs); `switching()`: the place it opens, or null.*/-export function installCloudRail({ ipcMain, guard, trusted, lists = trusted, beside = () => false, places, open, add, account, clipboard, openCloud, targets, makeHome = null, forget = null, switchAccount = null, openProfile = null, local = null, ask = (_id, run) => run(() => false), switching = () => null, t = nativeText.englishText.t }) {+export function installCloudRail({ ipcMain, guard, trusted, lists = trusted, beside = () => false, places, open, add, account, clipboard, openCloud, targets, makeHome = null, forget = null, rename = null, switchAccount = null, openProfile = null, local = null, ask = (_id, run) => run(() => false), switching = () => null, t = nativeText.englishText.t }) {let sheetOpen = false, sent = "";const allowed = (channel, handler) => guard((event, ...args) => {if (!trusted(event)) throw new Error(`${channel} is only available in this app's window`);@@ -206,6 +207,13 @@ export function installCloudRail({ ipcMain, guard, trusted, lists = trusted, besconst client = account();return { outcome: client?.hideCloud ? (await client.hideCloud(place.cloudId)).outcome : "unsupported" };});+ // Rename, from a circle's menu: only a server saved by hand that main listed with it; its new name is this app's own.+ listed("workspaces:rename", (_event, id, name) => {+ const place = places().find(entry => entry.id === plain(id) && entry.renames);+ if (!place) throw new Error(t("native.places.noLongerHere"));+ if (!rename) return { outcome: "unsupported" };+ try { return { outcome: rename(place.id, plain(name)) ? "saved" : "name" }; } catch { return { outcome: "failed" }; }+ });// Make … my home, from a circle's menu or Settings → Phone & devices on this computer's own page (`trusted`): only a server// main listed with it, by main's own word for it.handle("workspaces:make-home", (_event, id) => {diff --git a/electron/cloud-rail.node-test.mjs b/electron/cloud-rail.node-test.mjsindex 7b484b4ddb..aef0a3730a 100644--- a/electron/cloud-rail.node-test.mjs+++ b/electron/cloud-rail.node-test.mjs@@ -30,7 +30,7 @@ test("the rail: My Cloud, the person's Clouds and teams' Clouds in the session's{ id: "home", name: "Studio", color: "purple", kind: "cloud", opens: true, paint: { swatch: "violet" }, active: true },{ id: "a", name: "Client A", color: "teal", kind: "cloud", opens: true, paint: { swatch: "green" } },{ id: "acme", name: "Acme", color: "yellow", kind: "team", opens: true, paint: { swatch: "amber", locked: "member" } },- { id: "vps", name: "Office", color: null, kind: "server", opens: true, paint: { swatch: null }, removable: true, forget: true },+ { id: "vps", name: "Office", color: null, kind: "server", opens: true, paint: { swatch: null }, removable: true, forget: true, renames: true },], "each colour changed from the rail, but a team's by its admins alone");for (const origin of [HOME, CLIENT_A, TEAM, VPS, "/Users/person/lab"]) assert.equal(JSON.stringify(places).includes(origin), false, origin);const before = railPlaces({ saved: saved("local"), home: null, mine: HOME, state: session() });@@ -84,7 +84,7 @@ test("a server of the person's own that signed in with their account: one savedentry({ id: "s-render", name: "Render VPS", color: "rose", tier: null, runsOn: "server", managed: false, status: "offline", origin: RENDER, lastSeenAt: 1_761_000_100_000 })]);const state = session({ clouds });const places = railPlaces({ saved: saved(), home: HOME, mine: HOME, state });- assert.deepEqual(places.find(place => place.id === "vps"), { id: "vps", name: "Office", color: null, kind: "server", opens: true, paint: { swatch: null }, removable: true, forget: true, server: true },+ assert.deepEqual(places.find(place => place.id === "vps"), { id: "vps", name: "Office", color: null, kind: "server", opens: true, paint: { swatch: null }, removable: true, forget: true, renames: true, server: true },"saved by hand at its address: the same circle, marked as theirs, online, opening as it always did");assert.deepEqual(places.slice(-2), [{ id: "signed-in:s-mini", name: "Mac mini", color: null, kind: "server", opens: false, paint: { swatch: null }, ownNetwork: true, server: true, offline: true, lastSeenAt: 1_761_000_000_000 },@@ -365,7 +365,7 @@ function preload(origin, { activation = false } = {}) {test("a Cloud's page gets the rail and the add sheet's narrow bridges; a circle, + and checkout open only from the person's click", async () => {const page = preload(HOME);- assert.deepEqual(Object.keys(page.bridge.workspaces), ["state", "menu", "line", "places", "open", "add", "probe", "look", "color", "recolor", "remove", "makeHome", "homeOffers", "onChanged", "local", "onNewLocal"]);+ assert.deepEqual(Object.keys(page.bridge.workspaces), ["state", "menu", "line", "places", "open", "add", "probe", "look", "color", "recolor", "remove", "rename", "makeHome", "homeOffers", "onChanged", "local", "onNewLocal"]);assert.deepEqual(Object.keys(page.bridge.cloudAdd), ["state", "start", "reopen", "copyLink", "open", "interest", "sheet", "organization"]);await page.bridge.workspaces.places();await page.bridge.cloudAdd.state();@@ -379,6 +379,7 @@ test("a Cloud's page gets the rail and the add sheet's narrow bridges; a circle,await assert.rejects(page.bridge.workspaces.color("rose"), /Choose a color/, "a page changes its place's colour only from the person's click");await assert.rejects(page.bridge.workspaces.recolor("vps", "rose"), /Choose a color/);await assert.rejects(page.bridge.workspaces.remove("old"), /Choose Remove from list/, "Remove from list only from the person's click");+ await assert.rejects(page.bridge.workspaces.rename("vps", "Office"), /Choose Rename/, "Rename only from the person's click");await assert.rejects(page.bridge.workspaces.makeHome("vps"), /Choose Make my home/, "a move starts only from the person's click");await assert.rejects(page.bridge.workspaces.local.create("Work", "rose"), /Choose a name/, "a workspace of this computer's own only from the person's click");await assert.rejects(page.bridge.workspaces.local.edit("profile:work", { name: "Office" }), /Choose a change/);@@ -420,6 +421,20 @@ test("Remove from list on a server saved by hand: main forgets it here, by its oassert.deepEqual(await rail().call("workspaces:remove", "vps"), { outcome: "unsupported" }, "a main without forget says so");});+test("Rename on a server saved by hand: main names it on this computer, by its own word for which one", async () => {+ const named = [];+ const installed = rail({ rename: (id, name) => { named.push([id, name]); return name !== ""; } });+ const places = (await installed.call("workspaces:places")).places;+ assert.deepEqual(places.filter(place => place.renames).map(place => place.id), ["vps"], "only a server saved by hand offers Rename");+ assert.deepEqual(await installed.call("workspaces:rename", "vps", "Office"), { outcome: "saved" });+ assert.deepEqual(installed.call("workspaces:rename", "vps", { toString: () => "Evil" }), { outcome: "name" }, "only plain text is a name");+ named.pop();+ for (const id of ["home", "a", "acme", "lab", "https://evil.example.test"]) assert.throws(() => installed.call("workspaces:rename", id, "Office"), /isn't here/, id);+ assert.deepEqual(named, [["vps", "Office"]], "never a Cloud, a team's Cloud or this computer's own");+ assert.deepEqual(rail({ rename: () => { throw new Error("disk full"); } }).call("workspaces:rename", "vps", "Office"), { outcome: "failed" }, "a save that throws says so");+ assert.deepEqual(rail().call("workspaces:rename", "vps", "Office"), { outcome: "unsupported" }, "a main without rename says so");+});+test("a place with inbox lines waiting says so on its circle, this computer's too; the Admin's payment problem still does", () => {const places = railPlaces({ saved: saved("home"), mine: HOME, state: session(), waiting: id => id === "a" || id === "local" });assert.equal(places.find(place => place.id === "a").attention, true);diff --git a/electron/environments.cjs b/electron/environments.cjsindex 0163bfb709..bad6811b2c 100644--- a/electron/environments.cjs+++ b/electron/environments.cjs@@ -365,6 +365,16 @@ function withPlaceColor(state, id, color) {return { ...state, environments: state.environments.map((entry) => (entry === existing ? next : entry)) };}+/** A server saved here under a name the person chose on this computer (its rail's Rename): only this app's own record+ * changes, never the server or its own name for itself. Null for no such server or no name left once tidied. */+function withPlaceName(state, id, name) {+ const existing = state.environments.find((entry) => entry.id === id && entry.kind !== "local");+ const next = existing ? cleanName(name, "") : "";+ if (!next) return null;+ if (next === existing.name) return state;+ return { ...state, environments: state.environments.map((entry) => (entry === existing ? { ...entry, name: next } : entry)) };+}+/** The place `id` names (the one on screen by default): a saved entry, or This computer as one, named and coloured. */function savedPlace(state, id = state.activeId) {if (id === LOCAL_ID) return { id: LOCAL_ID, kind: "local", name: "This computer", ...(cleanColor(state.localColor) ? { color: state.localColor } : {}) };@@ -483,6 +493,7 @@ module.exports = {withEnvironmentLook,withListedColors,withPlaceColor,+ withPlaceName,withLocalEnvironment,withMicrophone,withoutEnvironment,diff --git a/electron/environments.node-test.mjs b/electron/environments.node-test.mjsindex 290548e107..a1d7e5796c 100644--- a/electron/environments.node-test.mjs+++ b/electron/environments.node-test.mjs@@ -476,3 +476,15 @@ test("the Server menu lists the workspaces of this computer's own and offers a nassert.deepEqual(calls, [["local", "work"], ["new"], ["local", "default"]]);assert.equal(env.workspaceMenuTemplate(state, { onSwitch() {}, onConnect() {}, onForget() {} }).some((item) => String(item.id).startsWith("workspace-new-local")), false, "only where main offers it");});++test("withPlaceName gives a saved server a name kept on this computer; this computer's own, an unknown id or a blank name change nothing", () => {+ const state = { environments: [{ id: "vps", kind: "remote", name: "ubuntu-lan", origin: "https://vps.example" },+ { id: "lab", kind: "local", name: "Lab", dataDir: "/tmp/lab" }], activeId: "vps" };+ const named = env.withPlaceName(state, "vps", " Home server ");+ assert.deepEqual(named.environments[0], { id: "vps", kind: "remote", name: "Home server", origin: "https://vps.example" }, "trimmed, spaces folded, origin kept");+ assert.equal(named.activeId, "vps");+ assert.equal(named.environments[1], state.environments[1]);+ assert.equal(env.withPlaceName(named, "vps", "Home server"), named, "the same state when nothing changes");+ assert.equal(env.withPlaceName(state, "vps", "x".repeat(80)).environments[0].name.length, 60, "capped like every saved name");+ for (const [id, name] of [["vps", " "], ["lab", "Office"], ["gone", "Office"]]) assert.equal(env.withPlaceName(state, id, name), null, `${id} ${JSON.stringify(name)}`);+});diff --git a/electron/main.mjs b/electron/main.mjsindex cf9dc9c154..aac59c0145 100644--- a/electron/main.mjs+++ b/electron/main.mjs@@ -1409,7 +1409,7 @@ ipcMain.on("desktop:unread-count", (event, value) => {applyUnreadBadge(sender);});-const { LOCAL_ID, activeEnvironment, activeRemote, allowedOrigins, bootEnvironmentDir, otherPlaces, savedPlace, startupEnvironmentDir, withActive, withEnvironment, withEnvironmentLook, withLocalEnvironment, withMicrophone, withPlaceColor, withoutEnvironment, withOwnCloud, withTeam, placesMenuOptions, workspaceMenuTemplate, workspaceNavigationAllowed, workspaceSenderAllowed, workspaceSummary, workspaceWindowTitle } = environmentsModule;+const { LOCAL_ID, activeEnvironment, activeRemote, allowedOrigins, bootEnvironmentDir, otherPlaces, savedPlace, startupEnvironmentDir, withActive, withEnvironment, withEnvironmentLook, withLocalEnvironment, withMicrophone, withPlaceColor, withPlaceName, withoutEnvironment, withOwnCloud, withTeam, placesMenuOptions, workspaceMenuTemplate, workspaceNavigationAllowed, workspaceSenderAllowed, workspaceSummary, workspaceWindowTitle } = environmentsModule;let environmentsState = { environments: [], activeId: LOCAL_ID };let computerSharing;@@ -2610,7 +2610,7 @@ const rail = installCloudRail({ t: nativeT, ipcMain, clipboard, openCloud: openOguard: handler => (event, ...args) => (chromeRail.owns(event) ? handler(event, ...args) : workspaceOnly(handler)(event, ...args)),lists: event => chromeRail.owns(event), trusted: event => chromeRail.owns(event) || senderIsLocal(event), beside: () => chromeRail.shown(),targets: () => [mainWindow && !mainWindow.isDestroyed() ? mainWindow.webContents : null, { send: channel => chromeRail.send(channel), isDestroyed: () => false }],- places: railList, ask: placeSwitch.ask, switching: placeSwitch.target, open: openPlace, makeHome: id => ownHome.start(id), forget: id => forgetEnvironment(id, false, true), openProfile: (id, stale = () => false) => workspaceMenuAction(async () => { await cleanWorkspace.settled(); if (stale()) return; const opened = await localProfiles.open(id); railChanged(); if (opened === false) throw new Error(nativeT("native.places.profileFailed")); }), local: localProfiles,+ places: railList, ask: placeSwitch.ask, switching: placeSwitch.target, open: openPlace, makeHome: id => ownHome.start(id), forget: id => forgetEnvironment(id, false, true), rename: (id, name) => { const next = withPlaceName(environmentsState, id, name); if (next) persistEnvironments(next); return Boolean(next); }, openProfile: (id, stale = () => false) => workspaceMenuAction(async () => { await cleanWorkspace.settled(); if (stale()) return; const opened = await localProfiles.open(id); railChanged(); if (opened === false) throw new Error(nativeT("native.places.profileFailed")); }), local: localProfiles,add: { choices: () => ({ cloud: cloudOffersAllowed(), link: !desktopRemoteAccess, address: !desktopRemoteAccess && !homeWindow.cloudOrigin(), account: !desktopRemoteAccess && Boolean(accounts.view().active) }),probe: serverConnect.probe, run: (choice, link, code) => (choice === "link" ? (link ? (code === null ? connectHostedWorkspace(link) : serverConnect.connect(link, code)) : addServerFromClipboard()) : choice === "address" ? openWorkspaceSettings() : homeWindow.cloudOrigin() ? undefined : openCloudAdd("app_menu")) } });const announceAddedCloud = createAddedCloudNotice({ t: nativeT, Notification, focused: () => Boolean(mainWindow && !mainWindow.isDestroyed() && mainWindow.isFocused()), sheetOpen: rail.sheetOpen,diff --git a/electron/preload.cjs b/electron/preload.cjsindex a4a9b4ec32..20f2ea947b 100644--- a/electron/preload.cjs+++ b/electron/preload.cjs@@ -185,6 +185,9 @@ const bridge = {// Remove from list, for a Cloud the window's rail lists as removable, from a click on the rail's own page (main refuses any other page).remove: (id) => isLocalPage || navigator.userActivation?.isActive === true? ipcRenderer.invoke("workspaces:remove", String(id)) : Promise.reject(new Error("Choose Remove from list.")),+ // Rename a server saved by hand, from a click on the rail's own page (main refuses any other page).+ rename: (id, name) => isLocalPage || navigator.userActivation?.isActive === true+ ? ipcRenderer.invoke("workspaces:rename", String(id), String(name)) : Promise.reject(new Error("Choose Rename.")),// Make a server of the person's own their bots' home, from a click on the rail's own page (main refuses any other page).makeHome: (id) => isLocalPage || navigator.userActivation?.isActive === true? ipcRenderer.invoke("workspaces:make-home", String(id)) : Promise.reject(new Error("Choose Make my home.")),diff --git a/src/components/PlacesRail.test.ts b/src/components/PlacesRail.test.tsindex 8419a170c2..0383be8f38 100644--- a/src/components/PlacesRail.test.ts+++ b/src/components/PlacesRail.test.ts@@ -893,3 +893,34 @@ it("two quick clicks: the place still marked can be clicked to stay, so the lastawait click(host.querySelector('[data-rail-place="profile:work"]'));expect(workspaces.open.mock.calls).toEqual([["profile:default"], ["profile:work"]]);});++it("a server saved by hand: its menu offers Rename, saved by main on this computer only; a Cloud's menu does not", async () => {+ const rename = vi.fn(async (_id: string, _name: string): Promise<{ outcome: "saved" | "name" | "failed" | "unsupported" }> => ({ outcome: "failed" }));+ rail = { places: [+ place("home", "My Cloud", { active: true, paint: { swatch: null } }),+ place("vps", "ubuntu-lan", { kind: "server", renames: true, removable: true, forget: true, paint: { swatch: null } }),+ ], add: { cloud: false, link: true, address: false } };+ Object.assign(window, { ogb: { workspaces: { ...workspaces, rename }, cloudAdd, rail: { expand: vi.fn(async () => {}), onSkin: () => () => {} } } });+ await mount(createElement(PlacesRail, { chrome: true }));+ const settle = () => act(async () => { for (let i = 0; i < 6; i++) await Promise.resolve(); });+ const menuOf = async (id: string) => {+ await act(async () => { host.querySelector(`[data-rail-place="${id}"]`)!.dispatchEvent(new MouseEvent("contextmenu", { bubbles: true, cancelable: true })); });+ return host.querySelector(`[data-rail-menu="${id}"]`)!;+ };+ expect((await menuOf("home")).querySelector("[data-rail-rename]"), "a Cloud keeps the name its Admin gives it").toBeNull();+ await act(async () => { host.querySelector("[data-rail-menu]")!.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true })); });+ const menu = await menuOf("vps");+ expect(document.activeElement, "Rename is the first row").toBe(menu.querySelector("[data-rail-rename]"));+ await click(menu.querySelector("[data-rail-rename]"));+ const field = menu.querySelector<HTMLInputElement>("[data-rail-rename-form] input")!;+ expect(field.value, "starts from the name it has").toBe("ubuntu-lan");+ await type(field, " 家里的服务器 ");+ await submit(menu.querySelector("[data-rail-rename-form]"));+ await settle();+ expect(menu.querySelector("[data-rail-rename-form] [role='alert']")?.textContent).toBe("That didn't work. Try again in a moment.");+ rename.mockResolvedValueOnce({ outcome: "saved" });+ await submit(menu.querySelector("[data-rail-rename-form]"));+ await settle();+ expect(rename.mock.calls, "by the circle's own id, which main listed").toEqual([["vps", "家里的服务器"], ["vps", "家里的服务器"]]);+ expect(host.querySelector("[data-rail-menu]"), "saved: the menu closes").toBeNull();+});diff --git a/src/components/PlacesRail.tsx b/src/components/PlacesRail.tsxindex f5bc92c8a7..6c65eec91b 100644--- a/src/components/PlacesRail.tsx+++ b/src/components/PlacesRail.tsx@@ -3,7 +3,7 @@// the person's own a server and a workspace of this computer's own with a name of its own a laptop, so each reads at a// glance. Main lists the places and opens one by its id; the rail never names an address. A right-click on a tile (or its// row past eight) opens that place's menu: a workspace of this computer's own is renamed, recoloured or removed there (asked-// first); for the rest, its colour, changed+// first); a server saved by hand is renamed there too (on this computer only); for the rest, its colour, changed// here for every place whatever its server runs, Remove from list for a Cloud of the person's own that ended or was// never paid for (asked first; main takes it off their list on the Admin), and Make … my home for a server of theirs that// main says this computer's bots may move to (one tap: main starts the move). With several accounts signed in here, the tiles@@ -19,7 +19,7 @@ import { activeLocale, t } from "@/lib/i18n";import { localizedRelativeTime } from "@/lib/relative-time";import { useAdvancedMode } from "@/lib/interface-mode";import { useBesideFramed } from "@/lib/chrome-rail";-import { computerName, editLocal, makeHome, placeInitials, recolorPlace, removeLocal, removePlace, usePlaces, type RailPlace } from "@/lib/places";+import { computerName, editLocal, makeHome, placeInitials, recolorPlace, removeLocal, removePlace, renamePlace, usePlaces, type RailPlace } from "@/lib/places";import { AccountsSheet, switchNote } from "./AccountMenu";import { useDesktopCapabilities, windowFramed } from "./DesktopCapabilities";import { MENU_ROW, MENU_SHEET } from "./menu-recipe";@@ -231,8 +231,8 @@ function ListedMenu({ place, top, onClose }: { place: RailPlace; top: number; onconst [pending, setPending] = useState<CloudSwatch | null>(null);const [outcome, setOutcome] = useState<PlaceColorOutcome | null>(null);const ref = useRef<HTMLDivElement>(null);- useEffect(() => { (ref.current?.querySelector<HTMLElement>("[role='radio'][tabindex='0']") ?? ref.current?.querySelector<HTMLElement>("[data-rail-remove-ask], [data-rail-make-home-start]"))?.focus(); }, []);- if (!paint && !place.removable && !place.makeHome) return null;+ useEffect(() => { (ref.current?.querySelector<HTMLElement>("[data-rail-rename], [role='radio'][tabindex='0']") ?? ref.current?.querySelector<HTMLElement>("[data-rail-remove-ask], [data-rail-make-home-start]"))?.focus(); }, []);+ if (!paint && !place.removable && !place.makeHome && !place.renames) return null;const name = place.kind === "computer" ? computerName(place) : place.name;const choose = (swatch: CloudSwatch) => {if (!paint || paint.locked || pending || swatch === paint.swatch) return;@@ -247,6 +247,7 @@ function ListedMenu({ place, top, onClose }: { place: RailPlace; top: number; on<PlaceMark place={place} size={22} /><span className="min-w-0 flex-1 truncate text-[13px] font-semibold text-ink">{name}</span></div>+ {place.renames && <div className="px-0.5 pt-1"><RenameRow current={place.name} save={(next) => renamePlace(place.id, next)} onSaved={onClose} /></div>}{paint && <><p className="px-2 pt-1 text-[12px] text-ink-secondary">{t("placeLook.title")}</p><div className="px-2 pb-1.5 pt-0.5">@@ -262,19 +263,20 @@ function ListedMenu({ place, top, onClose }: { place: RailPlace; top: number; onconst rowText = (place: RailPlace) => [placeStatus(place, Date.now()), place.signIn && t("accounts.needsSignIn")].filter(Boolean).join(" · ");-/** Rename in a workspace's menu: its name in a field, saved on Enter or Save; Escape or Cancel leaves it as it was. */-function RenameRow({ place, onSaved }: { place: RailPlace; onSaved: () => void }) {+/** Rename in a place's menu (a workspace of this computer's own, or a server saved by hand): its name in a field, saved on+ * Enter or Save by `save`; Escape or Cancel leaves it as it was. */+function RenameRow({ current, save: saveName, onSaved }: { current: string; save: (name: string) => Promise<"saved" | "name" | "taken" | "failed">; onSaved: () => void }) {const [editing, setEditing] = useState(false);const [name, setName] = useState("");const [busy, setBusy] = useState(false);const [said, setSaid] = useState<"taken" | "failed" | null>(null);- const start = () => { setName(computerName(place)); setSaid(null); setEditing(true); };+ const start = () => { setName(current); setSaid(null); setEditing(true); };const save = () => {const next = name.trim();if (!next || busy) return;- if (next === computerName(place)) { setEditing(false); return; }+ if (next === current) { setEditing(false); return; }setBusy(true); setSaid(null);- void editLocal(place.id, { name: next }).then((outcome) => {+ void saveName(next).then((outcome) => {setBusy(false);if (outcome === "saved") { setEditing(false); onSaved(); return; }setSaid(outcome === "taken" ? "taken" : "failed");@@ -344,7 +346,7 @@ function LocalMenu({ place, top, onClose }: { place: RailPlace; top: number; onC<PlaceMark place={place} size={22} /><span className="min-w-0 flex-1 truncate text-[13px] font-semibold text-ink">{name}</span></div>- <div className="px-0.5 pt-1"><RenameRow place={place} onSaved={onClose} /></div>+ <div className="px-0.5 pt-1"><RenameRow current={computerName(place)} save={(next) => editLocal(place.id, { name: next })} onSaved={onClose} /></div><p className="px-2 pt-1 text-[12px] text-ink-secondary">{t("placeLook.title")}</p><div className="px-2 pb-1.5 pt-0.5" data-rail-local-color><SwatchRadios value={(pending === undefined ? swatch : pending) ?? "slate"} onChange={choose} label={t("placeLook.aria", { name })} offset="menu" none />diff --git a/src/lib/places.ts b/src/lib/places.tsindex 2c3d1b877a..0e04145d9c 100644--- a/src/lib/places.ts+++ b/src/lib/places.ts@@ -68,6 +68,15 @@ export async function removePlace(id: string): Promise<CloudRemoveOutcome> {return answer.outcome;}+/** Rename, from a server's menu: main saves the name for that server on this computer only. An older app (no such channel)+ * answers `failed`. */+export async function renamePlace(id: string, name: string): Promise<"saved" | "name" | "failed"> {+ const answer = await bridge()?.rename?.(id, name).catch(() => null);+ if (!answer) return "failed";+ if (answer.outcome === "saved") void refreshPlaces();+ return answer.outcome === "saved" || answer.outcome === "name" ? answer.outcome : "failed";+}+/** Make … my home, from a server's menu: main starts moving this computer's bots there. True once it started, else main's* own words for why not. */export async function makeHome(id: string): Promise<true | string> {diff --git a/src/types/ogb.d.ts b/src/types/ogb.d.tsindex 2bcf3b3df2..b7a74439c2 100644--- a/src/types/ogb.d.ts+++ b/src/types/ogb.d.ts@@ -206,6 +206,9 @@ const __APP_VERSION__: string;/** Remove from list: a Cloud the window's rail lists as `removable`, by its circle's id, once the person said yes on* the rail's own page (refused on any other page). Absent on an older app. */remove?: (id: string) => Promise<{ outcome: import("../../electron/cloud-account.mjs").CloudRemoveOutcome }>;+ /** Rename: a server the window's rail lists with `renames`, by its circle's id, under a name kept on this computer+ * only. Absent on an older app. */+ rename?: (id: string, name: string) => Promise<{ outcome: "saved" | "name" | "failed" | "unsupported" }>;/** Make a server of the person's own, which the rail lists with `makeHome`, their bots' home: the move starts. */makeHome?: (id: string) => Promise<{ started: true }>;/** The ids of the servers main offers Make … my home for now (none once a move is done). Absent on an older app. */