Open-source AI coworkers that each get a computer of their own: a browser, files and tools, with every action decided before it happens and recorded after. Bring any AG-UI agent.
Read 7 as Sunday when describing a routine's schedule, the way the scheduler does (#474)
kevindeb6b57b1b53
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8c37e3a7..b1814703 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,14 @@ Newest first. `Unreleased` is what is on `main` and not yet tagged.## Unreleased+### A routine scheduled for Sunday says Sundays, whichever number it was written with++Crontab has always let Sunday be either 0 or 7, the scheduler here takes both, and a routine written+with 7 is stored and fires on Sunday like any other. Only the 0 spelling was recognised by the+sentence the Routines page draws and the Bot reads back, so a working weekend routine appeared on+that page as `0 9 * * 7` while its neighbour said "Sundays at 09:00" — the same schedule, described+two ways, with the raw one looking like something had gone wrong. Both spellings now read as Sunday,+and a list that names the day under both of its numbers says it once.### A tenant package's theme may carry a commentA package's `theme.css` is checked at start-up against what it is allowed to define: the `:root` anddiff --git a/server/src/routines/schedule.ts b/server/src/routines/schedule.tsindex 269d3fb7..7fae13c7 100644--- a/server/src/routines/schedule.ts+++ b/server/src/routines/schedule.ts@@ -214,6 +214,27 @@ function joinWords(words: string[]): string {return `${rest.join(", ")} and ${last}`;}+/**+ * The days a plain day-of-week field names, or null when it is not one.+ *+ * SUNDAY IS 0 AND IT IS ALSO 7. Both are ordinary crontab, `cron-parser` fires on Sunday for either,+ * and `nextOccurrence` above accepts both — so a routine written `0 9 * * 7` is scheduled, fires on+ * Sunday, and was then described to its owner and back to the model as `0 9 * * 7`, because only the+ * 0 spelling was recognised here. That is not the raw-expression fallback doing its job on a shape+ * this cannot render; it is one of this function's own shapes arriving under the other of the two+ * names its own scheduler takes.+ *+ * De-duplicated, because 7 and 0 are one day and `0,7` would otherwise render as "Sundays and+ * Sundays", which is worse than the raw expression it replaced. Order is left as written, like the+ * weekday list always has been.+ */+function weekdays(field: string): number[] | null {+ if (!/^[0-7](,[0-7])*$/.test(field)) return null;+ return [+ ...new Set(field.split(",").map((digit) => Number.parseInt(digit, 10) % 7)),+ ];+}+function parsePlainInt(field: string, min: number, max: number): number | null {if (!/^\d{1,2}$/.test(field)) return null;const value = Number.parseInt(field, 10);@@ -295,14 +316,12 @@ export function describeCron(cron: string): string {if (dayOfWeekField === "1-5") {return `Weekdays at ${time}`;}- if (/^[0-6]$/.test(dayOfWeekField)) {- const dayIndex = Number.parseInt(dayOfWeekField, 10);- return `${WEEKDAY_NAMES[dayIndex]}s at ${time}`;+ const days = weekdays(dayOfWeekField);+ if (days?.length === 1) {+ return `${WEEKDAY_NAMES[days[0] as number]}s at ${time}`;}- if (/^[0-6](,[0-6])+$/.test(dayOfWeekField)) {- const names = dayOfWeekField- .split(",")- .map((digit) => `${WEEKDAY_NAMES[Number.parseInt(digit, 10)]}s`);+ if (days && days.length > 1) {+ const names = days.map((day) => `${WEEKDAY_NAMES[day]}s`);return `${joinWords(names)} at ${time}`;}}diff --git a/server/tests/routine-schedule.test.ts b/server/tests/routine-schedule.test.tsindex d9ef8b13..8f42bdf2 100644--- a/server/tests/routine-schedule.test.ts+++ b/server/tests/routine-schedule.test.ts@@ -194,6 +194,34 @@ describe("describeCron", () => {expect(describeCron("0 9,17 * * *")).toBe("0 9,17 * * *");});+ /*+ * Sunday is 0 and it is also 7.+ *+ * Both spellings are ordinary crontab, `cron-parser` fires on Sunday for either, and the routine+ * this describes is already scheduled. So this is not a shape the renderer has never been taught:+ * it is one of its own shapes, arriving under the other of the two names its own scheduler accepts.+ */+ test("the scheduler fires on Sunday for either spelling", () => {+ const from = new Date("2026-09-10T00:00:00Z");+ expect(nextOccurrence("0 9 * * 0", "UTC", from).toISOString()).toBe(+ nextOccurrence("0 9 * * 7", "UTC", from).toISOString(),+ );+ // A Sunday, so the assertion above is not two equal wrong answers.+ expect(nextOccurrence("0 9 * * 7", "UTC", from).getUTCDay()).toBe(0);+ });++ test("a single weekday written as 7", () => {+ expect(describeCron("0 9 * * 7")).toBe("Sundays at 09:00");+ });++ test("a listed set of weekdays ending on 7", () => {+ expect(describeCron("0 9 * * 6,7")).toBe("Saturdays and Sundays at 09:00");+ });++ test("one day named under both of its numbers is said once", () => {+ expect(describeCron("0 9 * * 0,7")).toBe("Sundays at 09:00");+ });+test("never throws, even on garbage", () => {expect(describeCron("not a cron expression")).toBe("not a cron expression");});