Skip to content

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

feat(rail): anyone with a Cloud of their own sees the rail, with its + to buy another (#3774)

Milind Soni6500a0d8c654
diff --git a/electron/cloud-rail.mjs b/electron/cloud-rail.mjs
index 0d9ebac9e7..e0748f37da 100644
--- a/electron/cloud-rail.mjs
+++ b/electron/cloud-rail.mjs
@@ -47,7 +47,8 @@ function circle(entry, { activeId, mine, state }) {
* A server of theirs that signed in with their account comes next: one saved here already is that saved place (online
* or not), one not connected to this app yet shows how to connect it, and one only reachable on its own network has
* nothing to open. A Cloud of theirs the Admin is still making (no address yet) is there too, not yet to open. Fewer
- * than RAIL_MIN_PLACES places in all, This computer counted while it is one: no rail at all, the window as it was.
+ * than RAIL_MIN_PLACES places in all, This computer counted while it is one: no rail at all, the window as it was, unless
+ * the person has a Cloud of their own: then its one circle is the rail, for the + that buys another.
* @param {{ saved: { environments: any[], activeId: string }, home?: string | null, mine?: string | null, state?: any }} input
*/
export function railPlaces({ saved, home = null, mine = null, state = null }) {
@@ -68,7 +69,7 @@ export function railPlaces({ saved, home = null, mine = null, state = null }) {
...(cloud.origin ? { pairs: true } : { ownNetwork: true }), ...serverState(cloud, connected?.latestVersion ?? null) }));
const places = [...remote, ...servers, ...making];
const all = home ? places : [{ id: environments.LOCAL_ID, name: "This computer", color: null, kind: "computer", opens: true, ...(saved.activeId === environments.LOCAL_ID ? { active: true } : {}) }, ...places];
- return all.length < RAIL_MIN_PLACES ? [] : all;
+ return all.length < (clouds.some(ownCloud) ? 1 : RAIL_MIN_PLACES) ? [] : all;
}
/** What buying another Cloud looks like from a page: no account, address or checkout page, only what the sheet says. */
diff --git a/electron/cloud-rail.node-test.mjs b/electron/cloud-rail.node-test.mjs
index eabba7a18f..71a3dc47b1 100644
--- a/electron/cloud-rail.node-test.mjs
+++ b/electron/cloud-rail.node-test.mjs
@@ -38,9 +38,11 @@ test("the rail: My Cloud, the person's Clouds and teams' Clouds in the session's
assert.equal(before.length, 5);
});
-test("one place, or none: no rail, the window as it was", () => {
+test("a Cloud of your own is a rail even alone, for its +; otherwise one place, or none: no rail, the window as it was", () => {
const alone = { activeId: "home", environments: [{ id: "home", kind: "remote", name: "My Cloud", origin: HOME, home: true }] };
- assert.deepEqual(railPlaces({ saved: alone, home: HOME, mine: HOME, state: session({ teams: [], clouds: parseCloudList([PRIMARY]) }) }), []);
+ assert.deepEqual(railPlaces({ saved: alone, home: HOME, mine: HOME, state: session({ teams: [], clouds: parseCloudList([PRIMARY]) }) }).map(place => place.id), ["home"],
+ "My Cloud alone, after the move: its circle, so the + that buys another is there");
+ assert.deepEqual(railPlaces({ saved: alone, home: HOME, mine: HOME, state: null }), [], "signed out of Cloud: one saved place is no rail");
assert.deepEqual(railPlaces({ saved: alone, home: null, mine: HOME, state: session({ teams: [], clouds: parseCloudList([PRIMARY]) }) }).map(place => place.id), ["local", "home"],
"before the move, This computer and My Cloud are two places: two circles");
assert.deepEqual(railPlaces({ saved: { activeId: "local", environments: [] }, state: null }), []);