Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(brief): align morning wake deadlines to the minute (#3830)
zicochaos71ce6b8c6c23
diff --git a/server/host/brief-morning.test.ts b/server/host/brief-morning.test.tsindex 40f2a6277d..9e44c61df1 100644--- a/server/host/brief-morning.test.ts+++ b/server/host/brief-morning.test.ts@@ -48,6 +48,26 @@ function setup(options: { zone: string; start: string; morning?: string; overnig}describe("the morning brief", () => {+ it.each([+ ["America/New_York", "2026-10-29T04:00:00.001Z", "2026-10-29T11:50:00Z"],+ ["America/New_York", "2026-10-29T10:59:59.999Z", "2026-10-29T11:50:00Z"],+ ["America/New_York", "2026-10-29T11:14:21.643Z", "2026-10-29T11:50:00Z"],+ ["America/New_York", "2026-10-29T11:35:03.123Z", "2026-10-29T11:50:00Z"],+ ["America/New_York", "2026-10-29T11:49:59.999Z", "2026-10-29T11:50:00Z"],+ ["America/New_York", "2026-10-29T11:50:21.643Z", "2026-10-29T11:50:00Z"],+ ["America/New_York", "2026-10-29T12:19:59.999Z", "2026-10-29T11:50:00Z"],+ ["America/New_York", "2026-10-29T12:20:00.001Z", "2026-10-30T11:50:00Z"],+ ["America/New_York", "2026-10-29T22:35:21.643Z", "2026-10-30T11:50:00Z"],+ ["Europe/Berlin", "2026-10-24T18:35:21.643Z", "2026-10-25T06:50:00Z"],+ ["America/New_York", "2026-10-31T22:35:21.643Z", "2026-11-01T12:50:00Z"],+ ["America/New_York", "2026-03-07T23:35:21.643Z", "2026-03-08T11:50:00Z"],+ ["Asia/Kolkata", "2026-10-29T01:44:21.643Z", "2026-10-29T02:20:00Z"],+ ])("sets an exact morning wake boundary in %s at %s", async (zone, start, wake) => {+ const s = setup({ zone, start });+ await s.brief.active("desktop", zone, "en");+ expect(s.brief.nextWakeAt()).toBe(Date.parse(wake));+ });+it("is posted and pushed at 8:00 in the person's own zone, not a minute before, and once a day", async () => {// 07:59 in New York is 11:59 UTC in October.const s = setup({ zone: "America/New_York", start: "2026-10-22T11:59:00Z" });diff --git a/server/host/brief.test.ts b/server/host/brief.test.tsindex e8f0a42493..7c4c93fbf0 100644--- a/server/host/brief.test.ts+++ b/server/host/brief.test.ts@@ -65,6 +65,19 @@ function setup(options: { hosted?: boolean; needsYou?: NeedsYouItem[]; language?}describe("the brief", () => {+ it.each(["completed", "failed"] as const)("includes a routine %s just after local midnight", async (status) => {+ const s = setup({ needsYou: [{ kind: "signed-out", id: "sign-in", at: 0, instanceId: "claude", botIds: [] }] });+ s.advance(21_643);+ const run = (name: string, finishedAt: number): RoutineRun => ({+ id: name, routineId: name, routineName: name, target: "bot", botId: s.chief.id, runOn: "maus",+ scheduledFor: finishedAt, status, manual: false, createdAt: finishedAt, finishedAt,+ });+ s.runs.push(run("Before midnight", Date.parse("2026-10-22T03:59:59.999Z")), run("After midnight", Date.parse("2026-10-22T04:00:00.001Z")));+ await s.brief.active("desktop", "America/New_York", "en");+ expect(s.shown()).toContain("After midnight");+ expect(s.shown()).not.toContain("Before midnight");+ });+it("counts only the emails it leaves out, and still says how many new ones wait", () => {const emails = Array.from({ length: 8 }, (_, at) => ({ messageId: `m${at}`, threadId: `t${at}`, from: `Sender ${at} <s${at}@x.test>`, subject: `Subject ${at}`, needsReply: false }));const shown = JSON.stringify(briefCard({ now: Date.parse("2026-10-22T08:00:00Z"), timeZone: "UTC", intro: false, needs: [], meetings: null, emails, waiting: 3, routines: [] }).card);diff --git a/server/host/brief.ts b/server/host/brief.tsindex a5df440e5c..4ac958bae5 100644--- a/server/host/brief.ts+++ b/server/host/brief.ts@@ -185,7 +185,7 @@ export function createBrief(deps: BriefDeps) {/** The person's local midnight, to the minute. */const dayStart = (): number => {const zone = timeZone(), day = today();- let start = now();+ let start = Math.floor(now() / MINUTE) * MINUTE;while (localDate(start - HOUR, zone) === day) start -= HOUR;while (localDate(start - MINUTE, zone) === day) start -= MINUTE;return start;