commit 4ea43e5a27c03872a20b7c89984e41dc5591c86a
parent 469da9ab9b3caabb6c8c7e5856f9d6d45b7f1351
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 14 Oct 2026 13:17:45 -0400
common, umtool: an edition covers whole days, never one twice; a Tick now with nothing to cover makes none; Delete schedule is a plain button; the board's field keys wait for a redraw (R5 review)
- lib/report/schedule/types.ts editionWindow: start = the previous edition's
end + 1 day (the first: the cadence's length back, floored at the scope's
from), end = the day before the tick. Weekly on Mon covers the Mon … Sun
before it, "week of <start>". An empty window (a Tick now right after a
tick) records no edition: the tick ends no-change, $0, "Nothing to cover
yet — the next edition starts <date>", no Inbox card. Unit-tested
(window.test.ts: daily, weekly, every N, the empty case, DST); the
schedule tests follow. The edition's article is named for the tick's day.
- Create's plan says the first edition's window and its whole days; the
series page says what the next tick's edition will cover (or that there
is nothing to cover yet).
- Delete schedule and its confirm are outline buttons, the plan's border
a seam: a verdict colour is a judgement.
- board.spec's flake, root-caused: the board's list remounts on every
arrangement's answer, so `e`/`n`/`m` pressed while a move was answering
focused an input the answer then replaced, and the typing that followed
landed on the line as commands (s, x, n …). The field now waits for the
redraw and takes the focus then; until it does, no key is a command
(Escape lets go). board.spec presses `e` while the move answers, every run.
- The e2e stub's report-schedule takes a clock (POST /__stub/schedule-clock
{now, quiet}); recurring.spec ticks a Monday, again at once (nothing to
cover), then a week on (quiet).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
13 files changed, 265 insertions(+), 56 deletions(-)
diff --git a/common/controller/reportSchedule.test.ts b/common/controller/reportSchedule.test.ts
@@ -14,6 +14,7 @@ import { listPendingArticles, listArticleDirs } from "../lib/report/registry";
import { createIteration, readIterationFile, updateIteration, writeIterationFile } from "../lib/report/iterations";
import { livingFile, listSchedules, readSchedule, seriesFile } from "../lib/report/schedule/store";
import { parseCadence } from "../lib/report/schedule/cadence";
+import { editionWindow } from "../lib/report/schedule/types";
import {
claimTick,
createSchedule,
@@ -24,7 +25,7 @@ import {
setPaused,
updateSchedule,
} from "./reportSchedule";
-import { editionGenerator, nextWindow, notWiredFetch, notWiredRefresh, runTick, type StepOutcome, type TickDeps, type TickSteps } from "./reportTick";
+import { editionGenerator, notWiredFetch, notWiredRefresh, runTick, type StepOutcome, type TickDeps, type TickSteps } from "./reportTick";
import { scanSchedules } from "./reportScheduleRunner";
import { reportScheduleAction as action } from "./reportScheduleOps";
@@ -102,7 +103,8 @@ test("create: a series in .series/, a living report beside a NEW article that is
assert.equal(p.id, "co-host-updates");
assert.equal(p.firstTick, "2026-10-19T10:00:00.000Z");
assert.equal(p.firstTickWords, "Mon 06:00");
- assert.deepEqual(p.firstWindow, { from: "2026-10-12", to: "2026-10-19" });
+ // The first Monday tick covers the Mon … Sun before it.
+ assert.deepEqual(p.firstWindow, { from: "2026-10-12", to: "2026-10-18" });
assert.equal(p.firstTitle, "Co-host updates · week of 2026-10-12");
assert.equal(p.capUsd, 5);
assert.equal(p.provider, "api");
@@ -287,7 +289,7 @@ test("living with no report yet: its first tick is the article's first sweep, no
assert.deepEqual(asked, [{ article: "fresh", window: { from: "2026-01-01", to: "2026-10-14" }, quiet: false, title: null }]);
});
-test("series: an edition over the window since the last one's end, titled; then a quiet edition: recorded, no article, $0", async () => {
+test("series: an edition over whole days since the last one, titled; then a quiet edition; a Tick now with nothing to cover makes none", async () => {
const paths = store();
const deps = depsOf(paths);
await createSchedule(parseCreate({ shape: "series", topic: "Co-host updates", channels: ["chan-a"], cadence: weekly, tz: TZ }), deps);
@@ -301,24 +303,32 @@ test("series: an edition over the window since the last one's end, titled; then
assert.equal(t1.status, "done");
assert.equal(t1.edition, 1);
assert.equal(t1.article, "co-host-updates-2026-10-14");
- assert.deepEqual(asked[0], { article: "co-host-updates-2026-10-14", window: { from: "2026-10-07", to: "2026-10-14" }, title: "Co-host updates · week of 2026-10-07" });
+ // The cadence's length back, through the day before the tick.
+ assert.deepEqual(asked[0], { article: "co-host-updates-2026-10-14", window: { from: "2026-10-07", to: "2026-10-13" }, title: "Co-host updates · week of 2026-10-07" });
let s = await readSchedule("co-host-updates", paths);
assert.deepEqual(
s?.editions?.map((e) => [e.n, e.status, e.article, e.usd, e.matched]),
[[1, "done", "co-host-updates-2026-10-14", 2.25, 4]],
);
- // A week on: the window starts where the last ended; nothing matches.
+ // A Tick now the same day: nothing to cover -- no edition, $0, said plainly.
+ const again = await runTick("co-host-updates", { trigger: "now", jobId: "j1b" }, depsOf(paths, { generateEdition: async () => assert.fail("nothing to cover") }), ctx());
+ assert.equal(again.status, "no-change");
+ assert.equal(again.usd, 0);
+ assert.equal(again.edition, undefined);
+ assert.equal(again.reason, "Nothing to cover yet — the next edition starts 2026-10-14");
+ assert.equal((await readSchedule("co-host-updates", paths))?.editions?.length, 1);
+ // A week on: the window starts the day after the last ended; nothing matches.
const week = new Date("2026-10-21T12:00:00.000Z");
const t2 = await runTick("co-host-updates", { trigger: "schedule", jobId: "j2" }, depsOf(paths, { generateEdition: async (i) => (asked.push({ article: i.article, window: i.window, title: i.title }), { status: "quiet", usd: 0, matched: 0, reason: "nothing matches" }) }, week), ctx());
assert.equal(t2.status, "quiet");
assert.equal(t2.usd, 0);
assert.equal(t2.edition, 2);
assert.equal(t2.article, undefined);
- assert.deepEqual(asked[1].window, { from: "2026-10-14", to: "2026-10-21" });
+ assert.deepEqual(asked[1].window, { from: "2026-10-14", to: "2026-10-20" });
s = await readSchedule("co-host-updates", paths);
- assert.deepEqual(s?.editions?.[1], { n: 2, at: week.toISOString(), window: { from: "2026-10-14", to: "2026-10-21" }, title: "Co-host updates · week of 2026-10-14", status: "quiet", usd: 0, reason: "nothing matches", matched: 0 });
- // The next window continues from the quiet one's end.
- assert.deepEqual(nextWindow(s!, "2026-10-28"), { from: "2026-10-21", to: "2026-10-28" });
+ assert.deepEqual(s?.editions?.[1], { n: 2, at: week.toISOString(), window: { from: "2026-10-14", to: "2026-10-20" }, title: "Co-host updates · week of 2026-10-14", status: "quiet", usd: 0, reason: "nothing matches", matched: 0 });
+ // The next window continues the day after the quiet one's end.
+ assert.deepEqual(editionWindow(s!, "2026-10-28"), { window: { from: "2026-10-21", to: "2026-10-27" } });
});
test("series held by a cap: no edition (the next tick covers the window), the tick held with its reason and estimate", async () => {
diff --git a/common/controller/reportSchedule.ts b/common/controller/reportSchedule.ts
@@ -22,9 +22,7 @@ import { capFor, type GenerationSettings } from "../lib/generationSettings";
import { providerOf } from "../lib/llm";
import {
CadenceError,
- addDays,
anchorFor,
- cadenceDays,
cadenceWords,
isTimeZone,
localDate,
@@ -41,6 +39,7 @@ import {
SCHEDULE_VERSION,
TICKS_KEPT,
editionTitle,
+ editionWindow,
parseSchedule,
type Edition,
type Schedule,
@@ -270,9 +269,8 @@ export async function planCreate(input: CreateInput, deps: ScheduleDeps): Promis
if (input.shape === "series" && !input.terms) warnings.push("no terms: a window is quiet only when no recording in scope falls in it");
const first = nextTickAfter(input.cadence, now.getTime(), input.tz, null);
const anchor = anchorFor(input.cadence, first, input.tz);
- const day = localDate(first, input.tz);
- const back = addDays(day, -cadenceDays(input.cadence));
- const firstWindow = input.shape === "series" ? { from: input.from && input.from > back ? input.from : back, to: day } : null;
+ const fw = editionWindow({ cadence: input.cadence, editions: [], scope: { channels: input.channels, ...(input.from ? { from: input.from } : {}) } }, localDate(first, input.tz));
+ const firstWindow = input.shape === "series" && "window" in fw ? fw.window : null;
const at = now.toISOString();
const schedule: Schedule = {
format: SCHEDULE_FORMAT,
diff --git a/common/controller/reportTick.ts b/common/controller/reportTick.ts
@@ -19,10 +19,13 @@
// Review card). A living report with no report yet takes its first
// sweep instead of a refresh.
// series fetchAndBuild → an EDITION: a new article
-// `<series>-<YYYY-MM-DD>` over the window since the last edition's
-// window end (the first: the cadence's length back), titled
-// "<topic> · week of <date>" / "<topic> · <date>". A quiet window is
-// recorded, no article, $0.
+// `<series>-<YYYY-MM-DD>` (the tick's day) over whole days — the
+// day after the last edition's window end through the day before
+// the tick (the first: the cadence's length back), never a day
+// twice (lib/report/schedule/types.ts editionWindow) — titled
+// "<topic> · week of <start>" / "<topic> · <date>". A quiet window
+// is recorded, no article, $0; an empty one (a Tick now right after
+// a tick) makes no edition and says so.
//
// Caps: the generation policy's per-job cap (the schedule's own, never above
// caps.max) and the daily cap; a refusal ends the tick `held-by-cap` — the
@@ -48,7 +51,7 @@ import {
} from "../lib/report/iterations";
import { addDays, cadenceDays, localDate } from "../lib/report/schedule/cadence";
import { readSchedule } from "../lib/report/schedule/store";
-import { editionTitle, type Edition, type Schedule, type Tick, type TickStatus } from "../lib/report/schedule/types";
+import { editionTitle, editionWindow, nothingToCover, type Edition, type Schedule, type Tick, type TickStatus } from "../lib/report/schedule/types";
import { dailyCapRefusal, dayUsage, utcDay } from "./generationUsage";
import { enqueueReportDraft, type ReportDraftDeps } from "./reportDraft";
import {
@@ -265,15 +268,6 @@ export async function hasReportToRefresh(article: string, paths: Pick<Paths, "ar
const exists = (p: string) => stat(p).then(() => true, () => false);
-/** The window a series' next edition covers: from the last swept (or quiet) edition's window end, else the cadence's length back. */
-export function nextWindow(s: Schedule, today: string): { from: string; to: string } {
- const covered = [...(s.editions ?? [])].reverse().find((e) => e.status === "done" || e.status === "quiet" || e.status === "running");
- let from = covered ? covered.window.to : addDays(today, -cadenceDays(s.cadence));
- if (!covered && s.scope.from && s.scope.from > from) from = s.scope.from;
- if (from > today) from = today;
- return { from, to: today };
-}
-
/** The edition's article id: `<series>-<date>`, then -2, -3 … when the store has it. */
async function editionArticle(s: Schedule, day: string, paths: Pick<Paths, "articlesDir">): Promise<string> {
const base = `${s.id}-${day}`;
@@ -348,9 +342,15 @@ export async function runTick(id: string, run: TickRun, deps: TickDeps, ctx: Ste
}
if (s.shape !== "series") return await finish({ status: "failed", usd: 0, reason: `a ${s.shape} schedule has no tick yet (R6)` });
- const window = nextWindow(s, today);
+ const w = editionWindow(s, today);
+ if ("empty" in w) {
+ // Nothing between the last edition and today: no edition, $0, no card.
+ return await finish({ status: "no-change", usd: 0, reason: nothingToCover(w.nextFrom) });
+ }
+ const window = w.window;
const n = Math.max(0, ...(s.editions ?? []).map((e) => e.n)) + 1;
- const article = await editionArticle(s, window.to, deps.paths);
+ // Named for the tick's day (the window ends the day before it).
+ const article = await editionArticle(s, today, deps.paths);
const title = editionTitle(s.topic, s.cadence, window);
edition = { n, at: now.toISOString(), window, title, status: "running", article, usd: 0, jobId: run.jobId };
await putEdition(id, edition, deps);
diff --git a/common/lib/report/schedule/types.ts b/common/lib/report/schedule/types.ts
@@ -21,7 +21,7 @@
// Safe for a client component: zod and ./cadence only.
import { z } from "zod";
-import { chipWords, parseCadence, type Cadence } from "./cadence";
+import { addDays, cadenceDays, chipWords, localDate, parseCadence, type Cadence } from "./cadence";
export const SCHEDULE_FORMAT = "archilyzer-schedule";
export const SCHEDULE_VERSION = 1;
@@ -179,3 +179,44 @@ export const spentOf = (s: Pick<Schedule, "ticks">): number => Math.round(s.tick
export function editionTitle(topic: string, cadence: Cadence, window: { from: string; to: string }): string {
return cadence.kind === "weekly" ? `${topic} · week of ${window.from}` : `${topic} · ${window.to}`;
}
+
+// ─── an edition's window (operator ruling, R5 review) ───
+//
+// WHOLE DAYS, AND NO DAY READ TWICE. An edition covers [start, end], local
+// dates in the schedule's zone:
+// end the day BEFORE the tick (the tick's own day is not over)
+// start the previous edition's end + 1 day; the first edition's, the
+// cadence's length back from the tick's day (floored at the
+// scope's `from`)
+// So weekly on Mon 06:00 covers the previous Mon … Sun, 7 days, and "week of
+// <start>" names it. A window that would be empty (start > end — a Tick now
+// right after a tick) makes no edition at all: `{ empty, nextFrom }`.
+//
+// The previous edition is the last one that covered its window: done, quiet
+// or still running. A failed edition (or a held tick, which makes none)
+// leaves its window to the next tick.
+//
+// By PUBLISH date: a recording of an earlier window that only gets its
+// transcript later is missed by a series (R6's tier 0 takes candidates by id,
+// new since the last tick, which closes that gap).
+
+export type EditionWindow = { from: string; to: string };
+
+export function editionWindow(
+ s: Pick<Schedule, "cadence" | "editions" | "scope">,
+ tickDay: string,
+): { window: EditionWindow } | { empty: true; nextFrom: string } {
+ const covered = [...(s.editions ?? [])].reverse().find((e) => e.status === "done" || e.status === "quiet" || e.status === "running");
+ const to = addDays(tickDay, -1);
+ let from = covered ? addDays(covered.window.to, 1) : addDays(tickDay, -cadenceDays(s.cadence));
+ if (!covered && s.scope.from && s.scope.from > from) from = s.scope.from;
+ if (from > to) return { empty: true, nextFrom: from };
+ return { window: { from, to } };
+}
+
+/** The window of an edition ticked at instant `t` (ms), on the schedule's own clock. */
+export const editionWindowAt = (s: Pick<Schedule, "cadence" | "editions" | "scope" | "tz">, t: number) => editionWindow(s, localDate(t, s.tz));
+
+/** "Nothing to cover yet — the next edition starts 2026-10-19". */
+export const nothingToCover = (nextFrom: string) => `Nothing to cover yet — the next edition starts ${nextFrom}`;
+
diff --git a/common/lib/report/schedule/window.test.ts b/common/lib/report/schedule/window.test.ts
@@ -0,0 +1,58 @@
+// An edition's window (R5 review ruling): whole days, the day after the last
+// edition through the day before the tick, never a day twice.
+import { test } from "node:test";
+import assert from "node:assert/strict";
+import { editionWindow, editionWindowAt, nothingToCover, type Edition } from "./types";
+import { nextTickAfter, type Cadence } from "./cadence";
+
+const scope = { channels: ["c"] };
+const ed = (n: number, from: string, to: string, status: Edition["status"] = "done"): Edition => ({ n, at: "2026-01-01T00:00:00.000Z", window: { from, to }, title: "t", status, usd: 0 });
+const daily: Cadence = { kind: "daily", at: "06:00" };
+const weekly: Cadence = { kind: "weekly", dow: 1, at: "06:00" };
+const every3: Cadence = { kind: "every", days: 3, at: "06:00" };
+
+test("daily: yesterday, whole; then the day after the last one", () => {
+ assert.deepEqual(editionWindow({ cadence: daily, scope }, "2026-10-14"), { window: { from: "2026-10-13", to: "2026-10-13" } });
+ assert.deepEqual(editionWindow({ cadence: daily, scope, editions: [ed(1, "2026-10-13", "2026-10-13")] }, "2026-10-15"), { window: { from: "2026-10-14", to: "2026-10-14" } });
+ // Missed days are covered by the next edition, none read twice.
+ assert.deepEqual(editionWindow({ cadence: daily, scope, editions: [ed(1, "2026-10-13", "2026-10-13")] }, "2026-10-18"), { window: { from: "2026-10-14", to: "2026-10-17" } });
+});
+
+test("weekly on Monday: the previous Mon … Sun, seven days; the next week starts the day after", () => {
+ // Mon 2026-10-19 tick.
+ const w1 = editionWindow({ cadence: weekly, scope }, "2026-10-19");
+ assert.deepEqual(w1, { window: { from: "2026-10-12", to: "2026-10-18" } });
+ const w2 = editionWindow({ cadence: weekly, scope, editions: [ed(1, "2026-10-12", "2026-10-18")] }, "2026-10-26");
+ assert.deepEqual(w2, { window: { from: "2026-10-19", to: "2026-10-25" } });
+ // A quiet edition covered its window too; a failed one did not.
+ assert.deepEqual(editionWindow({ cadence: weekly, scope, editions: [ed(1, "2026-10-12", "2026-10-18"), ed(2, "2026-10-19", "2026-10-25", "quiet")] }, "2026-11-02"), { window: { from: "2026-10-26", to: "2026-11-01" } });
+ assert.deepEqual(editionWindow({ cadence: weekly, scope, editions: [ed(1, "2026-10-12", "2026-10-18"), ed(2, "2026-10-19", "2026-10-25", "failed")] }, "2026-11-02"), { window: { from: "2026-10-19", to: "2026-11-01" } });
+});
+
+test("every N days: N whole days back, then the day after; the scope's from floors the first", () => {
+ assert.deepEqual(editionWindow({ cadence: every3, scope }, "2026-10-14"), { window: { from: "2026-10-11", to: "2026-10-13" } });
+ assert.deepEqual(editionWindow({ cadence: every3, scope, editions: [ed(1, "2026-10-11", "2026-10-13")] }, "2026-10-17"), { window: { from: "2026-10-14", to: "2026-10-16" } });
+ assert.deepEqual(editionWindow({ cadence: every3, scope: { ...scope, from: "2026-10-12" } }, "2026-10-14"), { window: { from: "2026-10-12", to: "2026-10-13" } });
+});
+
+test("empty: a Tick now right after a tick (or a from in the future) has nothing to cover", () => {
+ const r = editionWindow({ cadence: weekly, scope, editions: [ed(1, "2026-10-12", "2026-10-18")] }, "2026-10-19");
+ assert.deepEqual(r, { empty: true, nextFrom: "2026-10-19" });
+ assert.equal(nothingToCover("2026-10-19"), "Nothing to cover yet — the next edition starts 2026-10-19");
+ assert.deepEqual(editionWindow({ cadence: daily, scope: { ...scope, from: "2026-12-01" } }, "2026-10-14"), { empty: true, nextFrom: "2026-12-01" });
+});
+
+test("DST: the window is the schedule's local days, whatever the instant's UTC date", () => {
+ const NY = "America/New_York";
+ // New York falls back on Sun 2026-11-01; the Monday tick after it is 06:00 EST.
+ const t = nextTickAfter(weekly, Date.parse("2026-10-31T12:00:00Z"), NY);
+ assert.equal(new Date(t).toISOString(), "2026-11-02T11:00:00.000Z");
+ assert.deepEqual(editionWindowAt({ cadence: weekly, scope, tz: NY, editions: [ed(1, "2026-10-19", "2026-10-25")] }, t), { window: { from: "2026-10-26", to: "2026-11-01" } });
+ // A daily 00:30 tick in Tokyo is the previous UTC date: the window is Tokyo's yesterday.
+ const tokyo = nextTickAfter({ kind: "daily", at: "00:30" }, Date.parse("2026-10-14T00:00:00Z"), "Asia/Tokyo");
+ assert.equal(new Date(tokyo).toISOString(), "2026-10-14T15:30:00.000Z");
+ assert.deepEqual(editionWindowAt({ cadence: daily, scope, tz: "Asia/Tokyo" }, tokyo), { window: { from: "2026-10-14", to: "2026-10-14" } });
+ // Spring forward (Sun 2026-03-08): a 02:30 daily tick lands 03:30 that day; its window is the 7th.
+ const spring = nextTickAfter({ kind: "daily", at: "02:30" }, Date.parse("2026-03-08T00:00:00Z"), NY);
+ assert.deepEqual(editionWindowAt({ cadence: daily, scope, tz: NY }, spring), { window: { from: "2026-03-07", to: "2026-03-07" } });
+});
diff --git a/common/testing/schedule/opsStub.ts b/common/testing/schedule/opsStub.ts
@@ -4,7 +4,9 @@
// `POST /api/ops/report-schedule`. Test-only; synthetic.
//
// tsx common/testing/schedule/opsStub.ts --articles <ARTICLES_DIR> \
-// --channels a,b --generation '<json>' --job <id> (the body on stdin)
+// --channels a,b --generation '<json>' --job <id> [--now <iso>] [--quiet]
+// (the body on stdin; --now is the clock a spec set, --quiet makes the
+// next window quiet)
//
// Prints the action's answer as one JSON line; `tick-now` runs the tick to
// its end in this process (its claim, its record) and answers {jobId, tick}.
@@ -12,8 +14,7 @@
// fetchAndBuild ok ("fetched (stub)")
// refresh no change, $0
// generateEdition terms or question with "held" → held by the daily cap;
-// "fail" → failed; a window that starts where it ends (a
-// second tick the same day), or "quiet" → quiet; else a
+// "fail" → failed; --quiet, or "quiet" → quiet; else a
// done iteration with a two-section report, $0.37
import { mkdir } from "node:fs/promises";
@@ -38,6 +39,8 @@ if (!articlesDir) {
const channels = (flag("channels") ?? "").split(",").filter(Boolean);
const generation = sanitizeGeneration(JSON.parse(flag("generation") ?? "{}"));
const jobId = flag("job") ?? `stub-tick-${Date.now()}`;
+const nowIso = flag("now");
+const quietNext = argv.includes("--quiet");
const root = path.dirname(articlesDir);
const paths = {
articlesDir,
@@ -59,7 +62,7 @@ const steps: TickSteps = {
const w = words(input.schedule);
if (/held/.test(w)) return { status: "held-by-cap", usd: 0, estimateUsd: generation.caps.sweep, reason: `the day's Claude API spend is $${generation.caps.daily.toFixed(2)} (stub), at or past the $${generation.caps.daily.toFixed(2)} daily cap (settings.generation.caps.daily) — refused; it resets at midnight UTC` };
if (/fail/.test(w)) return { status: "failed", usd: 0, reason: "the corpus build is gone (stub)" };
- if (input.quietCheck && (input.window.from === input.window.to || /quiet/.test(w))) {
+ if (input.quietCheck && (quietNext || /quiet/.test(w))) {
return { status: "quiet", usd: 0, matched: 0, reason: `nothing in ${input.window.from} … ${input.window.to} matches (stub)` };
}
const model = input.schedule.model ?? generation.models.api;
@@ -89,6 +92,7 @@ const steps: TickSteps = {
const deps: TickDeps = {
paths,
+ ...(nowIso ? { now: () => new Date(nowIso) } : {}),
settings: () => ({ generation }),
knownChannels: async () => channels,
steps,
diff --git a/umtool/app/series/[id]/page.tsx b/umtool/app/series/[id]/page.tsx
@@ -13,6 +13,7 @@ import { articleHref, workHref } from "@/lib/hrefs";
import { lifecycleOf, readLifecycle } from "@/lib/lifecycle";
import { readScheduleView } from "@/lib/schedules";
import type { Edition, ScheduleView, Tick } from "@/lib/schedule-types";
+import { editionWindowAt, nothingToCover } from "yt-dlp-transcript-common/lib/report/schedule/types";
import { cn } from "@/lib/utils";
export const dynamic = "force-dynamic";
@@ -75,6 +76,10 @@ export default async function SeriesPage({ params }: { params: Promise<{ id: str
const v = read.view;
const life = lifecycleOf(await readLifecycle(), v.piece);
const editions = [...(v.editions ?? [])].sort((a, b) => b.n - a.n);
+ // What the next tick's edition will cover: whole days, from the day after
+ // the last edition through the day before the tick.
+ const nextAt = v.nextTick ? Date.parse(v.nextTick) : NaN;
+ const next = !v.paused && Number.isFinite(nextAt) ? editionWindowAt(v, nextAt) : null;
const ticks = [...v.ticks].reverse();
return (
<div className="flex h-full flex-col">
@@ -106,10 +111,29 @@ export default async function SeriesPage({ params }: { params: Promise<{ id: str
/>
<main className="deck-main flex flex-1 flex-col gap-4 px-4 pb-6 pt-3">
{v.running && !v.running.jobId.startsWith("pending-") && <TickProgress jobId={v.running.jobId} />}
- <Panel title="Editions" aside={<span className="text-muted">newest first</span>} className="w-full max-w-[1100px]" data-series-editions="">
+ <Panel
+ title="Editions"
+ aside={
+ next ? (
+ <span className="text-text-2" data-series-next="">
+ {"window" in next ? (
+ <>
+ next, {v.nextWords}: <span className="font-mono text-[11.5px]">{next.window.from} … {next.window.to}</span>
+ </>
+ ) : (
+ nothingToCover(next.nextFrom)
+ )}
+ </span>
+ ) : (
+ <span className="text-muted">newest first</span>
+ )
+ }
+ className="w-full max-w-[1100px]"
+ data-series-editions=""
+ >
{editions.length === 0 ? (
<p className="m-0 text-[12.5px] text-muted" data-series-empty="">
- No edition yet. The first tick is {v.nextWords ?? "not planned (paused)"}.
+ No edition yet. The first tick is {v.nextWords ?? "not planned (paused)"}; an edition covers whole days, up to the day before its tick.
</p>
) : (
<ol className="m-0 flex list-none flex-col p-0" aria-label="editions">
diff --git a/umtool/components/create/RecurringForm.tsx b/umtool/components/create/RecurringForm.tsx
@@ -55,6 +55,8 @@ const SHAPES = [
] as const;
const usd = (n: number) => `$${n.toFixed(2)}`;
+// Days in a window, both ends counted.
+const wholeDays = (w: { from: string; to: string }) => Math.round((Date.parse(`${w.to}T00:00:00Z`) - Date.parse(`${w.from}T00:00:00Z`)) / 86_400_000) + 1;
// A board's date is YYYYMMDD or YYYY-MM-DD; a schedule's is the latter.
const ymd = (d: string) => (/^\d{8}$/.test(d) ? `${d.slice(0, 4)}-${d.slice(4, 6)}-${d.slice(6)}` : d);
@@ -223,8 +225,9 @@ export default function RecurringForm({ cases, initialCase, onCancel }: { cases:
{plan.model} · {plan.provider === "local" ? "the local model: no API spend" : `up to ${usd(plan.capUsd ?? 0)} a tick`} · daily cap {usd(plan.dailyCapUsd)}
</li>
{plan.firstWindow && plan.firstTitle && (
- <li>
- first edition: {plan.firstTitle} ({plan.firstWindow.from} … {plan.firstWindow.to}); a window nothing matches is quiet, $0
+ <li data-plan-first-window={`${plan.firstWindow.from}/${plan.firstWindow.to}`}>
+ first edition: {plan.firstTitle} ({plan.firstWindow.from} … {plan.firstWindow.to}, {wholeDays(plan.firstWindow)} whole day{wholeDays(plan.firstWindow) === 1 ? "" : "s"}); each next one
+ starts the day after, and ends the day before its tick. A window nothing matches is quiet, $0
</li>
)}
{plan.shape === "living" && <li>{plan.existingArticle ? `keeps ${plan.article} current` : `a new article, ${plan.article}: its first tick is its first sweep`}</li>}
diff --git a/umtool/components/research/BoardView.tsx b/umtool/components/research/BoardView.tsx
@@ -185,6 +185,21 @@ export default function BoardView({ initial }: { initial: CaseView }) {
setQueued(0);
}
}, [arrange]);
+ // A FIELD ASKED FOR WHILE THE LIST IS BEING REDRAWN (e, n, m pressed while a
+ // move or a section write is answering): focusing it now would put the caret
+ // in an input the answer is about to replace (the list remounts on every
+ // arrangement), and the keys typed next would land on the line as commands --
+ // `s` toggling the speaker check, `x` asking to remove the quote. So the
+ // field waits for the redraw and takes the focus then; until it does, the
+ // board's keys are held (Escape lets go).
+ const pendingField = useRef<{ qid: string; field: string } | null>(null);
+ useEffect(() => {
+ const want = pendingField.current;
+ if (!want || busy || queued > 0 || moving.current) return;
+ pendingField.current = null;
+ document.querySelector<HTMLElement>(`[data-quote="${CSS.escape(want.qid)}"] [data-field="${want.field}"]`)?.focus();
+ }, [listKey, busy, queued]);
+
const queueMove = useCallback(
(m: { kind: "quote" | "section"; id: string; dir: number }) => {
moves.current.push(m);
@@ -335,6 +350,12 @@ export default function BoardView({ initial }: { initial: CaseView }) {
if (e.defaultPrevented || e.metaKey || e.ctrlKey) return;
if ((e.target as HTMLElement | null)?.closest?.(TYPING)) return;
if (document.querySelector("dialog[open]")) return;
+ if (pendingField.current) {
+ // A field is waiting for the redraw: no key is a command until it has the focus.
+ if (e.key === "Escape") pendingField.current = null;
+ if (!e.altKey && e.key.length === 1) e.preventDefault();
+ return;
+ }
if (e.altKey) {
const dir = e.code === "KeyJ" || e.key === "ArrowDown" ? 1 : e.code === "KeyK" || e.key === "ArrowUp" ? -1 : 0;
if (!dir) return;
@@ -345,6 +366,11 @@ export default function BoardView({ initial }: { initial: CaseView }) {
}
const focusField = (f: string) => {
if (!litQuote) return;
+ if (busy || moving.current || moves.current.length > 0) {
+ e.preventDefault();
+ pendingField.current = { qid: litQuote.id, field: f };
+ return;
+ }
const el = document.querySelector<HTMLElement>(`[data-quote="${litQuote.id}"] [data-field="${f}"]`);
if (el) {
e.preventDefault();
diff --git a/umtool/components/series/ScheduleControls.tsx b/umtool/components/series/ScheduleControls.tsx
@@ -139,7 +139,9 @@ export default function ScheduleControls({ schedule, part = "all" }: { schedule:
<Button
ref={deleteRef}
size="sm"
- variant={part === "menu" ? "quiet" : "destructive"}
+ // A plain button: a verdict colour is a judgement, and the plan
+ // and its confirm are what guard a delete.
+ variant={part === "menu" ? "quiet" : "outline"}
disabled={!hydrated || busy !== null}
data-schedule-delete=""
onClick={() =>
@@ -153,7 +155,7 @@ export default function ScheduleControls({ schedule, part = "all" }: { schedule:
role="region"
aria-label={`delete schedule ${schedule.id}`}
data-delete-blocked={plan.refused ? "yes" : "no"}
- className="basis-full rounded-[3px] border border-reject-text bg-ink p-3 text-[12px]"
+ className="basis-full rounded-[3px] border border-seam-2 bg-ink p-3 text-[12px]"
onKeyDown={(e) => {
if (e.key === "Escape") {
e.preventDefault();
@@ -178,7 +180,7 @@ export default function ScheduleControls({ schedule, part = "all" }: { schedule:
<Button
ref={confirmRef}
size="sm"
- variant="destructive"
+ variant="outline"
disabled={!!plan.refused || busy !== null}
onClick={() =>
void act("delete", { action: "delete", confirm: true }, () => {
diff --git a/umtool/e2e/board.spec.ts b/umtool/e2e/board.spec.ts
@@ -129,11 +129,16 @@ test("sections and order: a, alt+j/k across sections, the section menu; claim, n
// And back up: alt+k.
await expect(litId(page)).toHaveAttribute("data-lit-id", "q:q1");
await page.keyboard.press("Alt+k");
+ // The claim (e) pressed while that move is still answering (R5: the list
+ // redraws on the answer, which used to take the field's focus away and send
+ // the typing to the line as commands): the field waits for the redraw, then
+ // takes the focus.
+ await page.keyboard.press("e");
await expect.poll(() => caseJson("lighthouse-case").quotes.find((q: { id: string }) => q.id === "q1").section).toBe(null);
+ await expect(page.locator("[data-board-busy]")).toHaveCount(0);
await expect(litId(page)).toHaveAttribute("data-lit-id", "q:q1");
// The claim (e) and the note (n), saved on Enter; the speaker check (s).
- await page.keyboard.press("e");
await expect(b.locator('[data-quote="q1"] [data-field="claim"]')).toBeFocused();
await page.keyboard.type("The budget was never approved");
await page.keyboard.press("Enter");
diff --git a/umtool/e2e/fixtures/editor-stub.mjs b/umtool/e2e/fixtures/editor-stub.mjs
@@ -144,6 +144,7 @@ const generation = {
const presetOf = (routes) =>
Object.keys(PRESETS).find((p) => Object.keys(PRESETS[p]).every((t) => routes[t] === PRESETS[p][t])) ?? "custom";
const draftJobs = new Map();
+const scheduleClock = { now: null, quiet: false };
// THE LIVE JOB LIST, CONTROLLED (P2b). A spec posts `POST /__stub/ops-jobs
// {mode, jobs}` (no token: the stub's own door, like /health) and the editor's
@@ -737,6 +738,8 @@ function generationRoute(req, res, url, auth) {
"--channels", "sitechan,otherchan",
"--generation", JSON.stringify(generation),
"--job", id,
+ ...(scheduleClock.now ? ["--now", scheduleClock.now] : []),
+ ...(scheduleClock.quiet && body?.action === "tick-now" ? ["--quiet"] : []),
],
{ cwd: REPO, input: JSON.stringify(body ?? {}), encoding: "utf8", timeout: 60_000 },
);
@@ -833,6 +836,15 @@ const server = http.createServer((req, res) => {
if (url.pathname === "/health") return json(res, 200, { ok: true });
+ // The recurring reports' clock (R5): the instant the next report-schedule
+ // asks run at, and whether the next tick's window is quiet. {} resets.
+ if (req.method === "POST" && url.pathname === "/__stub/schedule-clock") {
+ return readBody(req, (body) => {
+ scheduleClock.now = typeof body?.now === "string" ? body.now : null;
+ scheduleClock.quiet = body?.quiet === true;
+ return json(res, 200, { ok: true, ...scheduleClock });
+ });
+ }
if (req.method === "POST" && url.pathname === "/__stub/ops-jobs") {
return readBody(req, (body) => {
const mode = body?.mode ?? "ok";
diff --git a/umtool/e2e/recurring.spec.ts b/umtool/e2e/recurring.spec.ts
@@ -1,4 +1,5 @@
-import { test, expect, type Page } from "@playwright/test";
+import { test, expect, type APIRequestContext, type Page } from "@playwright/test";
+import { portFor } from "yt-dlp-transcript-common/lib/ports.mjs";
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
@@ -59,6 +60,13 @@ async function shoot(page: Page, name: string) {
await page.setViewportSize({ width: 1280, height: 720 });
}
+// The stub's clock for the recurring reports: the instant the next asks run at.
+const STUB = `http://127.0.0.1:${portFor("EDITOR_STUB_PORT")}`;
+async function clock(request: APIRequestContext, body: { now?: string; quiet?: boolean }) {
+ const r = await request.post(`${STUB}/__stub/schedule-clock`, { data: body });
+ expect(r.ok()).toBe(true);
+}
+
async function api(page: Page, body: Record<string, unknown>) {
const r = await page.request.post("/api/schedules", { data: body });
const b = (await r.json()) as Record<string, unknown>;
@@ -73,7 +81,10 @@ test.beforeAll(async ({ playwright }) => {
clean();
await warm(playwright, [urls.createHref({ make: "recurring" }), "/api/articles/channels", "/api/schedules", urls.seriesHref("r5-none"), urls.workHref({ recurring: "1" })]);
});
-test.afterAll(clean);
+test.afterAll(async ({ request }) => {
+ await clock(request, {}).catch(() => {});
+ clean();
+});
test("Create → A recurring report: a series, planned (first tick, model, cap), then started; its page opens", async ({ page }) => {
test.setTimeout(90_000);
@@ -93,7 +104,7 @@ test("Create → A recurring report: a series, planned (first tick, model, cap),
await expect(plan).toContainText("Series r5-cohost · weekly · Mon 06:00 · first tick Mon 06:00");
await expect(plan.locator("[data-plan-first-tick]")).toHaveAttribute("data-plan-first-tick", /T\d\d:00:00\.000Z$/);
await expect(plan).toContainText(/up to \$\d+\.\d\d a tick · daily cap \$\d+\.\d\d/);
- await expect(plan).toContainText("first edition: R5 cohost · week of");
+ await expect(plan).toContainText(/first edition: R5 cohost · week of (\d{4}-\d{2}-\d{2}) \(\1 … \d{4}-\d{2}-\d{2}, 7 whole days\)/);
// Nothing written by the plan.
expect(existsSync(path.join(ARTICLES, ".series", "r5-cohost"))).toBe(false);
expect(stubAsked("report-schedule").at(-1)).toMatchObject({ action: "create", dryRun: true, shape: "series", topic: "R5 cohost", channels: ["sitechan"], cadence: { kind: "weekly", dow: 1, at: "06:00" } });
@@ -107,30 +118,45 @@ test("Create → A recurring report: a series, planned (first tick, model, cap),
expect(series("r5-cohost")).toMatchObject({ shape: "series", topic: "R5 cohost", scope: { channels: ["sitechan"] }, paused: false, editions: [] });
});
-test("the series page: Tick now makes an edition, a second the same day is quiet; the tick log; pause, resume, edit cadence", async ({ page }) => {
+test("the series page: Tick now makes an edition over whole days; again at once, nothing to cover; a week on, a quiet one; the tick log", async ({ page, request }) => {
test.setTimeout(90_000);
+ // Monday 2026-10-19, noon UTC (the same date on the stub's clock, whatever its zone).
+ await clock(request, { now: "2026-10-19T12:00:00.000Z" });
await page.goto(urls.seriesHref("r5-cohost"));
await page.getByRole("button", { name: "Tick now" }).click();
await expect(page.locator("[data-schedule-said]")).toContainText(/Tick queued — job stub-tick-\d+/);
const done = page.locator("[data-edition='1']");
await expect(done).toHaveAttribute("data-edition-status", "done");
- const article = series("r5-cohost").editions[0].article as string;
- expect(article).toMatch(/^r5-cohost-\d{4}-\d{2}-\d{2}$/);
- await expect(done.locator(`[data-edition-link='${article}']`)).toHaveText(/^R5 cohost · week of \d{4}-\d{2}-\d{2}$/);
+ // The Mon … Sun before the tick, seven whole days, named for its start.
+ expect(series("r5-cohost").editions[0]).toMatchObject({ article: "r5-cohost-2026-10-19", window: { from: "2026-10-12", to: "2026-10-18" } });
+ await expect(done.locator("[data-edition-link='r5-cohost-2026-10-19']")).toHaveText("R5 cohost · week of 2026-10-12");
+ await expect(done.locator("[data-edition-window]")).toHaveAttribute("data-edition-window", "2026-10-12/2026-10-18");
+ // The scheduled tick (the real clock's next Monday) starts where this edition ended: on 2026-10-19
+ // it has nothing to cover yet; after it, it covers 2026-10-19 … the day before it.
+ await expect(page.locator("[data-series-next]")).toHaveText(/^(Nothing to cover yet — the next edition starts 2026-10-19|next, Mon 06:00: 2026-10-19 … \d{4}-\d{2}-\d{2})$/);
+
+ // At once again: no day is read twice -- no edition, $0, said plainly, no card.
+ await page.getByRole("button", { name: "Tick now" }).click();
+ const ticks = page.getByRole("table", { name: "ticks" });
+ await expect(ticks.locator("tbody tr")).toHaveCount(2);
+ await expect(ticks.locator("tbody tr").first()).toContainText("Nothing to cover yet — the next edition starts 2026-10-19");
+ await expect(page.locator("[data-edition]")).toHaveCount(1);
+
+ // A week on, nothing in the window matches: a quiet edition, dimmed, no link.
+ await clock(request, { now: "2026-10-26T12:00:00.000Z", quiet: true });
await page.getByRole("button", { name: "Tick now" }).click();
const quiet = page.locator("[data-edition='2']");
await expect(quiet).toHaveAttribute("data-edition-status", "quiet");
await expect(quiet).toHaveClass(/opacity-55/);
await expect(quiet.locator("[data-edition-link]")).toHaveCount(0);
- // Newest first, each with its window; the quiet one's starts where the first ended.
+ await expect(quiet.locator("[data-edition-window]")).toHaveAttribute("data-edition-window", "2026-10-19/2026-10-25");
+ await clock(request, {});
+ // Newest first.
await expect(page.locator("[data-edition]")).toHaveCount(2);
await expect(page.locator("[data-edition]").first()).toHaveAttribute("data-edition", "2");
- const w1 = (await done.locator("[data-edition-window]").getAttribute("data-edition-window"))!.split("/");
- await expect(quiet.locator("[data-edition-window]")).toHaveAttribute("data-edition-window", `${w1[1]}/${w1[1]}`);
- const ticks = page.getByRole("table", { name: "ticks" });
- await expect(ticks.locator("tbody tr")).toHaveCount(2);
+ await expect(ticks.locator("tbody tr")).toHaveCount(3);
await expect(ticks.locator("tbody tr").first()).toHaveAttribute("data-tick-status", "quiet");
- await expect(ticks.locator("tbody tr").nth(1)).toContainText("$0.37");
+ await expect(ticks.locator("tbody tr").nth(2)).toContainText("$0.37");
await expect(page.locator("[data-series-spent]")).toHaveAttribute("data-series-spent", "0.37");
await shoot(page, "series-page");