Skip to content

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

fix(first-hour): hold the day-two recap while the person's message is unanswered

AdityaUmalee0df9d32e3ef
diff --git a/server/host/first-hour.test.ts b/server/host/first-hour.test.ts
index e41ec1c0b2..f28f883a99 100644
--- a/server/host/first-hour.test.ts
+++ b/server/host/first-hour.test.ts
@@ -251,6 +251,20 @@ describe("a new Cloud's first hour", () => {
expect(fh.tally()).toEqual({ sorted: 40, drafted: 6, prepped: 4, routines: 0 });
});
+ it("holds the recap while the person's newest message is still unanswered, so it never reads as the answer", () => {
+ const s = setup({ start: "2026-10-27T09:00:00Z" });
+ const fh = s.make();
+ fh.begin();
+ s.ledger.add("sorted", 29);
+ s.set("2026-10-28T09:00:00Z");
+ 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.");
+ fh.tick();
+ expect(s.texts().at(-1)).toBe("So far I've sorted 29 emails: about 30 minutes back.");
+ });
+
it("counts a routine's posted results in the recap, and says nothing at all when nothing was done", () => {
const s = setup({ start: "2026-10-27T09:00:00Z" });
const fh = s.make();
diff --git a/server/host/first-hour.ts b/server/host/first-hour.ts
index 4ad045ab23..ab6005e827 100644
--- a/server/host/first-hour.ts
+++ b/server/host/first-hour.ts
@@ -198,6 +198,9 @@ 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. */
+ const personUnanswered = (threadId: string): boolean =>
+ deps.store.messagesFor(threadId).findLast((message) => message.kind === "text" && (message.role === "user" || message.role === "bot"))?.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?.(); };
@@ -378,7 +381,7 @@ export function createFirstHour(deps: FirstHourDeps) {
const at = now(), zone = deps.timeZone();
if (at - state.startedAt < RECAP_AFTER_MS || localDate(at, zone) === localDate(state.startedAt, zone) || localMinutes(at, zone) < clockMinutes(MORNING)) return;
const place = home();
- if (!place || deps.threadBusy(place.bot.id, place.threadId)) return;
+ if (!place || deps.threadBusy(place.bot.id, place.threadId) || personUnanswered(place.threadId)) return;
const counts = tally();
if (!anyValue(counts)) {
mark({ recapAt: at, recapQuiet: true });