Public: anyone can read this; the crew can change it.

An overdue date on This week says when it was due and how late it is, so the agent knows what to chase first #211

Closed opened this
Closed without merging

mason/deal-clock:mason/209-an-overdue-date-on-this-week-says-when-i → main 1 commit fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
5 files changed +38 −4
src/pages/clock.ts +2 −2
@@ -14,7 +14,7 @@ import { todaysDrafts, unsent, type Agent } from "../reminders.ts";
1414 import type { Who } from "../who.ts";
1515 import { conflictShort } from "../order.ts";
1616 import { clashLine, clashesLine } from "../overlap.ts";
17 import { byDay, thisWeek, whereNote } from "../week.ts";
17 import { byDay, lateNote, thisWeek, whereNote } from "../week.ts";
1818 import { layout } from "./layout.ts";
1919 import { mayRestore } from "../actions.ts";
2020 import { badge, draftLink, opens, owedBy, URGENCY_LABEL } from "./sheet.ts";
@@ -112,7 +112,7 @@ export function weekCard(deals: readonly DealView[], on: string, q = "", side: S
112112 (g) => `<h3 class="week-day">${escape(g.heading)}</h3>
113113 <ul class="week-list">${g.items
114114 .map(({ deal, deadline: d }) =>
115 weekRows(`${on}|${print(deal)}|${d.id}`, () => `<li><a class="week-row" ${opens(deal, d)}><span class="week-what"><b>${escape(d.label)}${whereNote(deal, d) === "" ? "" : ` · ${escape(whereNote(deal, d))}`}</b><small class="muted">${escape(deal.address)} · ${sideLabel(deal.side)} · ${owedBy(deal, d)}</small>${d.kind === "closing" ? clashLine(deal.closingConflicts, "small", false) : ""}${clashesLine(d.clashes, "small", false)}${d.nonBusinessDay === null ? "" : `<small class="muted">Not a business day · next is ${escape(spoken(d.nonBusinessDay.next))}</small>`}${d.note === "" ? "" : `<small class="muted">${escape(d.note)}</small>`}</span>${badge(d, on)}</a></li>`),
115 weekRows(`${on}|${print(deal)}|${d.id}`, () => `<li><a class="week-row" ${opens(deal, d)}><span class="week-what"><b>${escape(d.label)}${whereNote(deal, d) === "" ? "" : ` · ${escape(whereNote(deal, d))}`}</b><small class="muted">${escape(deal.address)} · ${sideLabel(deal.side)} · ${owedBy(deal, d)}</small>${d.kind === "closing" ? clashLine(deal.closingConflicts, "small", false) : ""}${clashesLine(d.clashes, "small", false)}${d.nonBusinessDay === null ? "" : `<small class="muted">Not a business day · next is ${escape(spoken(d.nonBusinessDay.next))}</small>`}${lateNote(d.due, on) === "" ? "" : `<small class="muted">${escape(lateNote(d.due, on))}</small>`}${d.note === "" ? "" : `<small class="muted">${escape(d.note)}</small>`}</span>${badge(d, on)}</a></li>`),
116116 )
117117 .join("")}</ul>`,
118118 )
src/pages/week.ts +2 −1
@@ -12,7 +12,7 @@ import { agent as defaults } from "../env.ts";
1212 import { asset, escape } from "../http.ts";
1313 import { STATUS } from "../timeline.ts";
1414 import type { Who } from "../who.ts";
15 import { byDay, owner, whereNote, thisWeek } from "../week.ts";
15 import { byDay, lateNote, owner, whereNote, thisWeek } from "../week.ts";
1616 import { clashLine, clashesLine } from "../overlap.ts";
1717 import { layout } from "./layout.ts";
1818 import { sideLabel } from "./side.ts";
@@ -46,6 +46,7 @@ export function weekPage(input: { who: Who; agent?: Agent | undefined; deals: re
4646 <p class="timeline-label"><b>${escape(d.label)}${closingAt(deal, d)}</b></p>
4747 <p class="timeline-owner">${escape(role)}${name === undefined ? "" : ` · ${escape(name)}`}</p>
4848 ${d.kind === "closing" ? clashLine(deal.closingConflicts) : ""}${clashesLine(d.clashes)}
49 ${lateNote(d.due, on) === "" ? "" : `<p class="timeline-owner">${escape(lateNote(d.due, on))}</p>`}
4950 ${d.note === "" ? "" : `<p class="timeline-owner">${escape(d.note)}</p>`}
5051 <p class="timeline-status"><span aria-hidden="true">${s.mark}</span> ${s.word}</p>
5152 </li>`;
src/week.page.test.ts +19
@@ -96,3 +96,22 @@ test("a place with markup in it is escaped on the sheet", async () => {
9696 expect(html).toContain("8:00 am at &lt;b&gt;Title&lt;/b&gt; &amp; Co");
9797 expect(html).not.toContain("<b>Title</b>");
9898 });
99
100 test("an overdue row on /week and on the clock carries its due date and how late it is", async () => {
101 forgetRationing();
102 const { lateNote } = await import("./week.ts");
103 const { spoken } = await import("./dates.ts");
104 const deals = (await (await get("/api/deals")).json()) as { closed?: boolean; fell_through?: boolean; deadlines: { due: string; done_at: string | null; waived_at: string | null }[] }[];
105 const { dayOf } = await import("./dates.ts");
106 const { agent } = await import("./env.ts");
107 const on = dayOf(agent);
108 const late = deals
109 .filter((d) => d.closed !== true && d.fell_through !== true)
110 .flatMap((d) => d.deadlines)
111 .find((d) => d.done_at === null && d.waived_at === null && d.due < on);
112 expect(late).toBeDefined();
113 const words = lateNote(late!.due, on);
114 expect(words).toContain(`due ${spoken(late!.due)} · `);
115 expect(await (await get("/week")).text()).toContain(words);
116 expect(await (await get("/")).text()).toContain(words);
117 });
src/week.test.ts +8
@@ -47,3 +47,11 @@ test("on one day timed closings come first by time, then the other rows as befor
4747 const rows = thisWeek([other, c("Z Street", "15:00"), c("Y Street", null), c("X Street", "09:30")], on);
4848 expect(rows.map((i) => i.deal.address)).toEqual(["X Street", "Z Street", "A Street", "Y Street"]);
4949 });
50
51 test("lateNote says when an overdue date was due and how late it is", async () => {
52 const { lateNote } = await import("./week.ts");
53 expect(lateNote("2026-11-06", "2026-11-08")).toBe("due Fri, Nov 6 · 2 days late");
54 expect(lateNote("2026-11-07", "2026-11-08")).toBe("due Sat, Nov 7 · 1 day late");
55 expect(lateNote("2026-11-08", "2026-11-08")).toBe("");
56 expect(lateNote("2026-11-09", "2026-11-08")).toBe("");
57 });
src/week.ts +7 −1
@@ -3,7 +3,7 @@
33 * within the next seven days, oldest first, then by address.
44 */
55
6 import { addDays, spoken } from "./dates.ts";
6 import { addDays, daysBetween, spoken } from "./dates.ts";
77 import { appointmentLine, isAppointment } from "./appointment.ts";
88 import { closingWhere } from "./closing.ts";
99 import { isOpen, PARTY_LABEL, type PartyRole } from "./deadlines.ts";
@@ -77,6 +77,12 @@ export function owner(
7777 return { name: deal.parties.find((p) => p.role === d.owes)?.name, role: PARTY_LABEL[d.owes] };
7878 }
7979
80 /** "due Fri, Nov 6 · 2 days late" for a date overdue on `on`; "" for one due today or later. */
81 export function lateNote(due: string, on: string): string {
82 const days = daysBetween(due, on);
83 return days < 1 ? "" : `due ${spoken(due)} · ${days} ${days === 1 ? "day" : "days"} late`;
84 }
85
8086 /** The day heading a date sits under: overdue ones share one. */
8187 const dayHeading = (due: string, on: string): string =>
8288 due < on ? "Overdue" : due === on ? "Today" : spoken(due);

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs