Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(first-hour): read the shown branch; only a bot turn's reply (text or rich) releases the recap hold
AdityaUmale9047b0db7e32
diff --git a/server/host/first-hour.test.ts b/server/host/first-hour.test.tsindex f28f883a99..0b68618398 100644--- a/server/host/first-hour.test.ts+++ b/server/host/first-hour.test.ts@@ -260,7 +260,10 @@ describe("a new Cloud's first hour", () => {s.write("Every couple in both movies and Friends");fh.tick();expect(s.texts().filter((text) => text?.startsWith("So far"))).toEqual([]);- s.reply("Here they are.");+ s.store.appendMessage(s.thread(), { role: "bot", kind: "text", text: "A server notice." });+ fh.tick();+ expect(s.texts().filter((text) => text?.startsWith("So far"))).toEqual([]);+ s.store.appendMessage(s.thread(), { role: "bot", kind: "widget", text: "Pick one", turnId: "turn-1" });fh.tick();expect(s.texts().at(-1)).toBe("So far I've sorted 29 emails: about 30 minutes back.");});diff --git a/server/host/first-hour.ts b/server/host/first-hour.tsindex ab6005e827..bf431e3099 100644--- a/server/host/first-hour.ts+++ b/server/host/first-hour.ts@@ -198,9 +198,12 @@ export function createFirstHour(deps: FirstHourDeps) {};const said = (threadId: string, from: number): boolean =>deps.store.messagesFor(threadId).some((message) => message.role === "user" && message.kind === "text" && message.at >= from);- /** The person's newest message has no answer yet: a server line now would read as that answer. */+ /** The person's newest message on the shown branch has no answer from a bot turn yet (text or a rich reply such as a+ * widget): a server line now would read as that answer. Server-written lines (no turnId) are not answers. */const personUnanswered = (threadId: string): boolean =>- deps.store.messagesFor(threadId).findLast((message) => message.kind === "text" && (message.role === "user" || message.role === "bot"))?.role === "user";+ deps.store.activePath(threadId).findLast((message) =>+ message.role === "user" ? message.kind === "text" : Boolean(message.turnId) && message.kind !== "activity" && message.kind !== "digest" && message.kind !== "compaction",+ )?.role === "user";const answered = (threadId: string, from: number): boolean =>deps.store.messagesFor(threadId).some((message) => message.role === "bot" && message.kind === "text" && message.at >= from);const soon = (step: () => Promise<void>): void => { setTimeout(() => void step(), SOON_MS).unref?.(); };