Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(cloud): show the home Cloud's own name in the top bar and keep it in sync after a rename
AdityaUmalee4b424bcf5cd
diff --git a/electron/home-places.mjs b/electron/home-places.mjsindex c17e1f4f42..98716f60a3 100644--- a/electron/home-places.mjs+++ b/electron/home-places.mjs@@ -5,7 +5,15 @@// Admin's session's, read by main. Who can see a team's private chats is said by the team's own page, in the chat (T2's// TeamPrivateChatsLine), not here.import environments from "./environments.cjs";-import { listedColors, ownCloudPlaces } from "./cloud-list.mjs";+import { homeLook, listedColors, ownCloudPlaces } from "./cloud-list.mjs";++/** My Cloud's saved place under the name the Admin lists it by now, so a rename there (Settings → Name and colour) reaches+ * the switcher and the top bar too, not only at setup (cloud-home.mjs withCloudHome). Only the entry that is home. */+function withHomeName(state, session) {+ const look = homeLook(session), origin = environments.normalizeOrigin(session?.machine?.origin);+ if (!look || !origin || !state.environments.some((entry) => entry.home === true && entry.origin === origin)) return state;+ return environments.withEnvironmentLook(state, origin, { name: look.name });+}const idOf = (value) => (typeof value === "string" && value ? value : null);/** What home-place.json may name: a team's Cloud, another Cloud of the person's own, a workspace of this computer's own@@ -91,7 +99,8 @@ export function createHomePlaces({ store, environments: read, persist, makeId, hconst { state: withTeams, left } = environments.reconcileTeams(read(), teams, makeId, homeOrigin());const clouds = Array.isArray(state.clouds) ? ownCloudPlaces(state.clouds) : null;const owned = environments.reconcileOwnClouds(withTeams, clouds, makeId, homeOrigin());- const next = clouds ? environments.withListedColors(owned, listedColors(state.clouds), homeOrigin()) : owned;+ const coloured = clouds ? environments.withListedColors(owned, listedColors(state.clouds), homeOrigin()) : owned;+ const next = withHomeName(coloured, state);if (next !== read()) persist(next);for (const name of left) places.left(name);if (current().team && !teams.some((team) => team?.id === current().team)) places.remember(null);diff --git a/electron/home-places.node-test.mjs b/electron/home-places.node-test.mjsindex 94ac78f406..4865938194 100644--- a/electron/home-places.node-test.mjs+++ b/electron/home-places.node-test.mjs@@ -1,6 +1,7 @@import assert from "node:assert/strict";import test from "node:test";+import { parseCloudList } from "./cloud-list.mjs";import environments from "./environments.cjs";import { createHomePlaces } from "./home-places.mjs";@@ -93,3 +94,24 @@ test("a workspace of this computer's own or a server saved by hand is rememberedassert.deepEqual(world({ saved: { profile: "work", team: "team-acme" } }).places.remembered(), { team: "team-acme" }, "a file naming two: the first kind wins");assert.equal(world({ saved: { profile: 7 } }).places.remembered(), null, "an id that isn't one: nothing");});++const listedHome = (name) => parseCloudList([{ id: "c-home", name, color: null, role: "owner", tier: "pro", runsOn: "cloud", status: "ready", origin: HOME, teamId: null, primary: true }]);+const withHome = (name, clouds = listedHome(name)) => ({ ...connected([]), machine: { status: "ready", origin: HOME }, ...(clouds ? { clouds } : {}) });++test("My Cloud renamed in the Admin (Settings → Name and colour) is renamed here on the next session check; nothing else is", () => {+ const w = world({ state: { environments: [{ id: "c", kind: "remote", name: "My Cloud", origin: HOME, home: true }, { id: "s", kind: "remote", name: "Lab", origin: "https://lab.example.com" }], activeId: "c" } });+ w.places.sync(withHome("My Cloud"));+ assert.deepEqual(w.persisted, [], "the same name: nothing written");+ w.places.sync(withHome("Freedom Fox"));+ assert.deepEqual(w.state.environments.map((entry) => [entry.name, entry.home ?? false]), [["Freedom Fox", true], ["Lab", false]]);+ w.places.sync(withHome("Freedom Fox"));+ assert.equal(w.persisted.length, 1, "and once only");+ w.places.sync(withHome("Other", null));+ assert.equal(w.state.environments[0].name, "Freedom Fox", "an Admin without the list leaves the name as it was");+});++test("a listed name never renames a place that isn't home at the machine's address", () => {+ const w = world({ state: { environments: [{ id: "s", kind: "remote", name: "Saved by hand", origin: HOME }], activeId: "s" } });+ w.places.sync(withHome("Freedom Fox"));+ assert.equal(w.state.environments[0].name, "Saved by hand");+});diff --git a/src/components/WindowPlaceTitle.test.ts b/src/components/WindowPlaceTitle.test.tsindex f06de54b00..3d0a5050cc 100644--- a/src/components/WindowPlaceTitle.test.ts+++ b/src/components/WindowPlaceTitle.test.ts@@ -6,13 +6,19 @@ import { windowPlaceName } from "./WindowPlaceTitle";beforeEach(() => setLocale("en"));afterEach(() => { delete window.ogb; });-it("the top bar names the place as the rail does: This computer, This Mac (or This PC) in a profile, My Cloud while it is home", () => {+it("the top bar names the place as the rail does: This computer, This Mac (or This PC) in a profile, My Cloud while home keeps that name", () => {expect(windowPlaceName({ local: true, name: "This computer" }, undefined)).toBe("This computer");window.ogb = { platform: "darwin" } as unknown as typeof window.ogb;expect(windowPlaceName({ local: true, name: "This computer", profile: "default" }, undefined)).toBe("This Mac");window.ogb = { platform: "win32" } as unknown as typeof window.ogb;expect(windowPlaceName({ local: true, name: "This computer", profile: "default" }, undefined)).toBe("This PC");- expect(windowPlaceName({ local: false, name: "Studio", home: true }, undefined)).toBe("My Cloud");+ expect(windowPlaceName({ local: false, name: "My Cloud", home: true }, undefined)).toBe("My Cloud");+});++it("home renamed by its owner (Settings → Name and colour) is called by that name in the top bar, as on the rail", () => {+ expect(windowPlaceName({ local: false, name: "Freedom Fox", home: true }, undefined)).toBe("Freedom Fox");+ expect(windowPlaceName({ local: false, name: "Freedom Fox", home: true }, "Acme"), "a team's Cloud keeps the team's name").toBe("Acme");+ expect(windowPlaceName({ local: false, name: "", home: true }, undefined)).toBe("My Cloud");});it("a workspace added from + is called by its own name in the top bar", () => {diff --git a/src/components/WindowPlaceTitle.tsx b/src/components/WindowPlaceTitle.tsxindex bd65d5badc..e8566145b6 100644--- a/src/components/WindowPlaceTitle.tsx+++ b/src/components/WindowPlaceTitle.tsx@@ -22,10 +22,14 @@ export function useWindowPlace(): WorkspaceState | null {return place;}-/** What the window's top bar calls the place: This computer (This Mac in a profile), My Cloud while it is the window's only- * home (a team's name on a team's Cloud), else the name it was saved under. */+/** The name My Cloud is saved under until its owner picks another (electron/cloud-home.mjs CLOUD_HOME_NAME). */+const CLOUD_HOME_NAME = "My Cloud";++/** What the window's top bar calls the place: This computer (This Mac in a profile), the window's home by the name its+ * owner gave it (My Cloud, in the app's language, until they rename it; a team's name on a team's Cloud), else the name it+ * was saved under. */export function windowPlaceName(place: WorkspaceState, team: string | undefined): string {- if (place.home) return team || t("cloudSetup.myCloud");+ if (place.home) return team || (place.name && place.name !== CLOUD_HOME_NAME ? place.name : t("cloudSetup.myCloud"));if (place.profile) return place.profileName || computerName({ profile: place.profile });if (place.local && !place.localPath) return t("rail.thisComputer");return place.name;