Skip to content

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

Train fix: Move everything leaves a choice at its switch to finish

milind-soni6e4557a5e832
diff --git a/electron/bot-move-main.mjs b/electron/bot-move-main.mjs
index 8de553c64f..c1dcb67f22 100644
--- a/electron/bot-move-main.mjs
+++ b/electron/bot-move-main.mjs
@@ -141,9 +141,11 @@ export function createBotMove({ journal, local, send, session, lease = null, rea
retry: () => engine.retry(),
/** The bots on their way now, by id. */
moving: () => moves().filter((move) => move.phase !== "done").flatMap((move) => list(move.bots).map((bot) => bot.id)),
- /** Everything is moving now instead: a choice still on its way stops, and its bots go on here until that move takes them. */
+ /** Everything is moving now instead: a choice still on its way stops, and its bots go on here until that move takes them.
+ * One at its switch is past the point of no return (My Cloud has switched its automations on), so it finishes: let go
+ * here, its bots would run in both places. */
async drop() {
- for (const move of moves().filter((entry) => entry.phase !== "done")) {
+ for (const move of moves().filter((entry) => entry.phase !== "done" && entry.phase !== "switch")) {
for (const bot of list(move.bots)) await local.call("DELETE", `/api/bot-moves/${bot.id}`).catch(() => null);
const left = parseTeamMoves(journal.read());
journal.write({ ...left, moves: left.moves.filter((entry) => entry.bot.id !== move.bot.id) });
diff --git a/electron/bot-move-main.node-test.mjs b/electron/bot-move-main.node-test.mjs
index 0ff6bc7bea..14fc1982bb 100644
--- a/electron/bot-move-main.node-test.mjs
+++ b/electron/bot-move-main.node-test.mjs
@@ -156,6 +156,18 @@ test("Move everything stops a choice still on its way, and its bots go on here u
answering = null;
});
+test("Move everything leaves a choice at its switch to finish: My Cloud already runs its bots", async () => {
+ const w = world();
+ w.move.start(bots(2));
+ await settle(w);
+ w.journal = { ...w.journal, moves: w.journal.moves.map((move) => ({ ...move, phase: "switch" })) };
+ w.holds.set("b0", "moving"); w.holds.set("b1", "moving");
+ await w.move.drop();
+ assert.equal(w.holds.get("b0"), "moving", "not let go here while My Cloud runs it");
+ assert.equal(w.journal.moves.length, 1);
+ assert.equal(w.journal.moves[0].phase, "switch");
+});
+
test("it waits its turn at My Cloud behind another computer's move, and lets go when it is done", async () => {
let asks = 0;
const released = [];