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

Each date carries its own "remind me N days before", so a lender hears about the financing deadline a week out, not three days #76

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

mason/deal-clock:mason/68-each-date-carries-its-own-remind-me-n-da → main 2 commits fork

  • Merged. mason/68-each-date-carries-its-own-remind-me-n-da was merged into main as f757096.

Review

Sign in to review this change.
18 files changed +484 −38
README.md +7 −4
@@ -47,10 +47,12 @@ Signed out, `/` shows what deal-clock does, three short points, a still picture
4747 still ahead).
4848 2. **Open a marker.** Tap the red inspection marker on Harbor View. A sheet
4949 opens with the date, who owes it (the buyer), what is owed, and the reminders
50 for each party, grouped as three days before, the morning of, and an
50 for each party, grouped as 3 days before, the morning of, and an
5151 Overdue follow-up to the buyer, because the date passed without being marked
5252 done (it waits under Reminders for today until you send or decline it). It
53 also has two buttons: Mark done, and Move this date. The clock itself
53 also has two buttons: Mark done, and Move this date. Each date has a
54 Reminds N days before setting (1 to 30; Financing starts at 7), which you
55 can change on its sheet. The clock itself
5456 stays small: a deal's sheets are fetched the first time you tap one of its
5557 dates, a blink later.
5658 3. **Read and edit a reminder.** In the sheet, tap a party's reminder. You
@@ -123,8 +125,9 @@ Signed out, `/` shows what deal-clock does, three short points, a still picture
123125 its reminders stop, and its page says "Closed on …". Everything on it still
124126 opens; reopen the Closing date and the deal is back on the clock.
125127 12. **Download the calendar file.** On a deal's page, tap Add to calendar.
126 You get a calendar file with every date of the deal and an alarm three days
127 before and the morning of, to open in your own calendar app. On the clock,
128 You get a calendar file with every date of the deal and two
129 alarms for each: one as many days ahead as that date's Reminds N days
130 before setting, and one the morning of. Open it in your own calendar app. On the clock,
128131 Add all to calendar does the same for every open date of every open deal.
129132 13. **Print the client timeline.** On a sample deal's page, tap Client
130133 timeline: its dates in order, who owes each and whether it is done,
contract/openapi.json +81
@@ -1064,6 +1064,87 @@
10641064 }
10651065 },
10661066 "/api/deals/{id}/deadlines/{deadline}": {
1067 "patch": {
1068 "summary": "Set how many days before it is due a date's first reminder goes out (a whole number, 1 to 30; 400 with field lead_days otherwise). An unsent draft is drafted again for the new day; a sent one keeps its words.",
1069 "operationId": "patchApiDealsIdDeadlinesDeadline",
1070 "parameters": [
1071 {
1072 "name": "id",
1073 "in": "path",
1074 "required": true,
1075 "schema": {
1076 "type": "integer"
1077 }
1078 },
1079 {
1080 "name": "deadline",
1081 "in": "path",
1082 "required": true,
1083 "schema": {
1084 "type": "integer"
1085 }
1086 }
1087 ],
1088 "requestBody": {
1089 "required": true,
1090 "content": {
1091 "application/json": {
1092 "schema": {
1093 "type": "object",
1094 "properties": {
1095 "lead_days": {
1096 "type": "integer",
1097 "minimum": 1,
1098 "maximum": 30
1099 }
1100 },
1101 "required": [
1102 "lead_days"
1103 ]
1104 }
1105 }
1106 }
1107 },
1108 "responses": {
1109 "200": {
1110 "description": "Set how many days before it is due a date's first reminder goes out (a whole number, 1 to 30; 400 with field lead_days otherwise). An unsent draft is drafted again for the new day; a sent one keeps its words.",
1111 "content": {
1112 "application/json": {
1113 "schema": {
1114 "type": "object",
1115 "properties": {
1116 "id": {
1117 "type": "integer"
1118 },
1119 "lead_days": {
1120 "type": "integer"
1121 }
1122 },
1123 "required": [
1124 "id",
1125 "lead_days"
1126 ]
1127 }
1128 }
1129 }
1130 },
1131 "default": {
1132 "description": "{ error, message }: why not",
1133 "content": {
1134 "application/json": {
1135 "schema": {
1136 "$ref": "#/components/schemas/Error"
1137 }
1138 }
1139 }
1140 }
1141 },
1142 "x-contract": {
1143 "resource": "deal",
1144 "verb": "update",
1145 "least": "user"
1146 }
1147 },
10671148 "delete": {
10681149 "summary": "Remove a custom date the contract dropped, and its unsent reminders. A standard contract date is refused (422): move it or mark it done.",
10691150 "operationId": "deleteApiDealsIdDeadlinesDeadline",
docs/TECHNICAL.md +14 −2
@@ -23,6 +23,18 @@ Removing a party or a date drops the reminders not yet sent; reminders already
2323 marked sent stay on record. Over the API: `PATCH` or `DELETE
2424 /api/deals/:id/parties/:party` and `DELETE /api/deals/:id/deadlines/:deadline`.
2525
26 Lead time: every date has `lead_days` (1 to 30, column `deadline.lead_days`,
27 default 3; new Financing dates and the sample deals start at 7, see `leadOf` in
28 `src/deadlines.ts`). The `before` reminder goes out that many days before the due
29 date (`sendOn`), its label reads "N days before" (`momentLabel`), its words say
30 "in N days", and the calendar file's early alarm and This week's reminders follow
31 it; an unsent draft is redrafted, a sent one keeps its approved words. Set it with
32 `setReminderLead` (`src/deals.ts`, audited as an update of the deal): the sheet form
33 `POST /deadlines/:id/lead`, `PATCH /api/deals/:id/deadlines/:deadline` with
34 `{"lead_days": n}` (a bad value is a 400 with field `lead_days`), MCP
35 `set_reminder_lead`, and `l` on a date in the terminal. Every door reads it as
36 `lead_days` on the date.
37
2638 Reminder moments (`MOMENTS`, `src/reminders.ts`): `before`, `day_of`, `late`
2739 and `moved` (*Date changed*). `moved` is drafted for the latest move of an open
2840 date, to the parties a `day_of` reminder goes to, dated the day of the move; its
@@ -80,7 +92,7 @@ tools at `POST /mcp` (`list_deals`, `get_deal`, `client_timeline`, `reminders_to
8092 `open_deal`, `add_date`, `update_address`, `add_party`, `edit_party`, `remove_party`,
8193 `remove_date` — custom dates only — `remove_deal` — its author or an admin —
8294 `mark_done` — with `done: false` to
83 reopen a date — `move_date`, `amend_deal` (several dates, one reason), `send_reminder`, `restore_samples` — admin only: puts the
95 reopen a date — `move_date`, `set_reminder_lead`, `amend_deal` (several dates, one reason), `send_reminder`, `restore_samples` — admin only: puts the
8496 four sample deals back and leaves every other deal alone). `send_reminder` takes an
8597 optional `subject` and `body` to send edited words; without them the draft
8698 goes as it is.
@@ -130,7 +142,7 @@ decide nothing themselves. `AGENTS.md` says how to add to it.
130142
131143 | file | what it is |
132144 | ---------------------------------- | -------------------------------------------------------------- |
133 | `src/deals.ts` | deals: open, read, move a date, mark done, parties, reminders sent |
145 | `src/deals.ts` | deals: open, read, move a date, set its reminder lead, mark done, parties, reminders sent |
134146 | `src/dates.ts`, `src/deadlines.ts` | calendar math; the standard contract dates and who owes them |
135147 | `src/reminders.ts`, `src/ics.ts` | reminder drafts and `/tick`; the calendar file |
136148 | `src/outbox.ts` | a sent reminder's mailto:/sms: link |
src/db.ts +3
@@ -310,6 +310,9 @@ export const migrations: string[] = [
310310 // number, so the parties get one "dates changed" notice for them; 0 is a
311311 // move made on its own.
312312 `ALTER TABLE deadline_move ADD COLUMN amendment INTEGER NOT NULL DEFAULT 0`,
313 // How many days before it is due a date's first reminder goes out; the
314 // dates a deal already has keep the three days they always had.
315 `ALTER TABLE deadline ADD COLUMN lead_days INTEGER NOT NULL DEFAULT 3 CHECK (lead_days BETWEEN 1 AND 30)`,
313316 // The agent's own name, brokerage, phone and email: at most one row, and
314317 // with none the environment's values stand (src/profile.ts).
315318 `CREATE TABLE IF NOT EXISTS profile (
src/deadlines.ts +7
@@ -41,6 +41,13 @@ export type Kind = (typeof KINDS)[number];
4141 export const isClosed = (deadlines: readonly { kind: Kind; done_at: string | null }[]): boolean =>
4242 deadlines.some((d) => d.kind === "closing" && d.done_at !== null);
4343
44 /** How many days before its due date a date's first reminder goes out, unless the agent says otherwise. */
45 export const DEFAULT_LEAD = 3;
46 export const LEAD_MIN = 1;
47 export const LEAD_MAX = 30;
48 /** The lead a new date of this kind starts from: a loan commitment needs a week's warning. */
49 export const leadOf = (kind: Kind): number => (kind === "financing" ? 7 : DEFAULT_LEAD);
50
4451 export interface KindInfo {
4552 readonly label: string;
4653 /** Two or three letters for a marker on the clock. */
src/deals.test.ts +1 −1
@@ -204,7 +204,7 @@ test("reminders: three days before and the morning of, drafted in words, marked
204204 ]);
205205 const buyer = mine[0]!;
206206 expect(buyer.body).toContain("Hi Ann,");
207 expect(buyer.body).toContain("in three days");
207 expect(buyer.body).toContain("in 3 days");
208208 expect(buyer.body).toContain("This one is yours");
209209 expect(buyer.body).toContain("Dana Whitfield, Harbor & Pine Realty");
210210 expect(mine[1]!.body).toContain("Ann Buyer (buyer) is on it");
src/deals.ts +31 −2
@@ -14,6 +14,9 @@ import {
1414 isClosed,
1515 isPartyRole,
1616 KIND,
17 LEAD_MAX,
18 LEAD_MIN,
19 leadOf,
1720 schedule,
1821 type Kind,
1922 type Lengths,
@@ -105,6 +108,8 @@ export interface Deadline {
105108 readonly owes: PartyRole;
106109 readonly what: string;
107110 readonly done_at: string | null;
111 /** Days before it is due that its first reminder goes out. */
112 readonly lead_days: number;
108113 }
109114 export interface DeadlineView extends Deadline {
110115 readonly moves: readonly Move[];
@@ -469,11 +474,11 @@ export function insertDeal(
469474 party.run(deal.id, "buyer", p.buyer);
470475 party.run(deal.id, "seller", p.seller);
471476 const deadline = db.query(
472 "INSERT INTO deadline (deal_id, kind, label, due, owes, what) VALUES (?1, ?2, ?3, ?4, ?5, ?6)",
477 "INSERT INTO deadline (deal_id, kind, label, due, owes, what, lead_days) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)",
473478 );
474479 for (const { kind, due } of schedule(p)) {
475480 const k = KIND[kind];
476 deadline.run(deal.id, kind, k.label, due, k.owes, k.what);
481 deadline.run(deal.id, kind, k.label, due, k.owes, k.what, leadOf(kind));
477482 }
478483 return deal;
479484 })();
@@ -596,6 +601,30 @@ export function markDone(
596601 return within(db, who, dealId, ok(reread(db, input.id)));
597602 }
598603
604 /** Whether `value` is a lead time: a whole number of days, 1 to 30. */
605 const isLead = (value: unknown): value is number =>
606 typeof value === "number" && Number.isInteger(value) && value >= LEAD_MIN && value <= LEAD_MAX;
607
608 /**
609 * Set how many days before it is due a date's first reminder goes out. An
610 * unsent "before" draft is drafted again for the new day; a sent one keeps
611 * the words it went with.
612 */
613 export function setReminderLead(
614 db: Database,
615 who: Who,
616 input: { id: number; dealId?: number; leadDays: unknown },
617 ): Result<Deadline> {
618 const { dealId, found } = deadlineFor(db, who, input.id, input.dealId);
619 if (!found.ok) return within(db, who, dealId, found);
620 // A form or a terminal sends text: a whole number written out is a whole number.
621 const days = typeof input.leadDays === "string" && /^\s*\d{1,3}\s*$/.test(input.leadDays) ? Number(input.leadDays) : input.leadDays;
622 if (!isLead(days))
623 return within(db, who, dealId, fail("invalid", `Days before is a whole number from ${LEAD_MIN} to ${LEAD_MAX}.`, "lead_days"));
624 db.query("UPDATE deadline SET lead_days = ?1 WHERE id = ?2").run(days, input.id);
625 return within(db, who, dealId, ok(reread(db, input.id)));
626 }
627
599628 /** Move one date, and only that one; the reason is kept beside it. */
600629 export function moveDeadline(
601630 db: Database,
src/ics.ts +4 −3
@@ -1,6 +1,7 @@
11 /**
22 * A deal's dates as a calendar file (RFC 5545): one all-day event per date,
3 * each with two alarms — three days before, and 9 a.m. the day of — so the
3 * each with two alarms — the date's lead time before (three days unless
4 * set), and 9 a.m. the day of — so the
45 * agent's own calendar keeps the clock too. Pure text out.
56 */
67
@@ -60,8 +61,8 @@ function events(deal: DealView, host: string, now: string, openOnly: boolean): s
6061 lines.push(
6162 "BEGIN:VALARM",
6263 "ACTION:DISPLAY",
63 `DESCRIPTION:${icsText(`${d.label} in three days`)}`,
64 "TRIGGER:-P3D",
64 `DESCRIPTION:${icsText(`${d.label} in ${d.lead_days} ${d.lead_days === 1 ? "day" : "days"}`)}`,
65 `TRIGGER:-P${d.lead_days}D`,
6566 "END:VALARM",
6667 "BEGIN:VALARM",
6768 "ACTION:DISPLAY",
src/lead.test.ts added +240
@@ -0,0 +1,240 @@
1 /**
2 * A date's own lead time: how many days before it is due its first reminder
3 * goes out — through the action, then the page, the API, MCP and the terminal.
4 */
5 import { afterAll, beforeEach, expect, test } from "bun:test";
6 import { mkdtempSync } from "node:fs";
7 import { tmpdir } from "node:os";
8 import { join } from "node:path";
9 import { Database } from "bun:sqlite";
10 import { addDays, today } from "./dates.ts";
11 import { openDb } from "./db.ts";
12 import { createDeal, getDeal, sendReminder, setReminderLead, type DealView } from "./deals.ts";
13 import { calendar } from "./ics.ts";
14 import { drafts, momentLabel, sentLabel } from "./reminders.ts";
15 import { serve } from "./server.ts";
16 import { forgetRationing } from "./security.ts";
17 import { terminal } from "./terminal.ts";
18 import { sign, type Who } from "./who.ts";
19
20 const db = openDb(mkdtempSync(join(tmpdir(), "app-lead-")));
21 const alice: Who = { role: "user", id: "u1", name: "alice" };
22 const anon: Who = { role: "anon" };
23 const agent = { name: "Dana", brokerage: "Harbor", phone: "555", email: "[email protected]" };
24
25 const open = (): DealView => {
26 const made = createDeal(db, alice, { address: "5 Lead Lane", buyer: "Ann Buyer", seller: "Sam Seller", contractDate: "2026-10-01", closingDate: "2026-12-01" });
27 if (!made.ok) throw new Error(made.message);
28 return made.value;
29 };
30 const fresh = (id: number): DealView => {
31 const got = getDeal(db, alice, { id });
32 if (!got.ok) throw new Error(got.message);
33 return got.value;
34 };
35 const kind = (deal: DealView, k: string) => deal.deadlines.find((d) => d.kind === k)!;
36 const before = (deal: DealView, id: number) => drafts(deal, agent).filter((d) => d.deadline_id === id && d.moment === "before");
37
38 test("standard dates start at three days; financing starts at seven", () => {
39 const deal = open();
40 expect(deal.deadlines.map((d) => [d.kind, d.lead_days])).toContainEqual(["financing", 7]);
41 for (const d of deal.deadlines.filter((d) => d.kind !== "financing")) expect(d.lead_days).toBe(3);
42 const financing = kind(deal, "financing");
43 expect(before(deal, financing.id)[0]!.on).toBe(addDays(financing.due, -7));
44 expect(before(deal, kind(deal, "inspection").id)[0]!.on).toBe(addDays(kind(deal, "inspection").due, -3));
45 });
46
47 test("a 7-day lead drafts its reminder on due-7 and not on due-3, in words and label", () => {
48 const deal = open();
49 const inspection = kind(deal, "inspection");
50 expect(setReminderLead(db, alice, { id: inspection.id, leadDays: 7 }).ok).toBe(true);
51 const after = fresh(deal.id);
52 const mine = before(after, inspection.id);
53 expect(mine.length).toBeGreaterThan(0);
54 for (const d of mine) {
55 expect(d.on).toBe(addDays(inspection.due, -7));
56 expect(d.on).not.toBe(addDays(inspection.due, -3));
57 expect(d.body).toContain("in 7 days");
58 expect(d.lead_days).toBe(7);
59 }
60 expect(momentLabel("before", 7)).toBe("7 days before");
61 expect(momentLabel("before", 1)).toBe("1 day before");
62 expect(momentLabel("before")).toBe("3 days before");
63 });
64
65 test("a sent reminder keeps its words when the lead changes; an unsent one is redrafted", () => {
66 const deal = open();
67 const inspection = kind(deal, "inspection");
68 const first = before(deal, inspection.id)[0]!;
69 const sent = sendReminder(db, alice, { deadlineId: first.deadline_id, partyId: first.party_id, moment: "before", subject: "Approved subject", body: "Approved words in 3 days", agent });
70 expect(sent.ok).toBe(true);
71 setReminderLead(db, alice, { id: inspection.id, leadDays: 10 });
72 const mine = before(fresh(deal.id), inspection.id);
73 const kept = mine.find((d) => d.party_id === first.party_id)!;
74 expect(kept.sent_at).not.toBeNull();
75 expect(kept.subject).toBe("Approved subject");
76 expect(kept.body).toBe("Approved words in 3 days");
77 const other = mine.find((d) => d.party_id !== first.party_id)!;
78 expect(other.sent_at).toBeNull();
79 expect(other.body).toContain("in 10 days");
80 });
81
82 test("the calendar file's early alarm follows the lead", () => {
83 const deal = open();
84 const financing = kind(deal, "financing");
85 expect(calendar(fresh(deal.id), "h.example")).toContain("TRIGGER:-P7D");
86 setReminderLead(db, alice, { id: financing.id, leadDays: 14 });
87 const file = calendar(fresh(deal.id), "h.example");
88 expect(file).toContain("TRIGGER:-P14D");
89 expect(file).toContain(`${financing.label} in 14 days`);
90 });
91
92 test("a bad lead is refused by the action, naming the field, and nothing changes", () => {
93 const deal = open();
94 const id = kind(deal, "inspection").id;
95 for (const leadDays of [0, 31, -1, 2.5, "x", "", null, undefined, "1e1", NaN]) {
96 const r = setReminderLead(db, alice, { id, leadDays });
97 expect(r.ok).toBe(false);
98 if (!r.ok) {
99 expect(r.error).toBe("invalid");
100 expect(r.field).toBe("lead_days");
101 }
102 }
103 expect(setReminderLead(db, anon, { id, leadDays: 5 }).ok).toBe(false);
104 expect(setReminderLead(db, alice, { id: 999_999, leadDays: 5 }).ok).toBe(false);
105 expect(kind(fresh(deal.id), "inspection").lead_days).toBe(3);
106 expect(setReminderLead(db, alice, { id, leadDays: "30" }).ok).toBe(true);
107 expect(setReminderLead(db, alice, { id, leadDays: 1 }).ok).toBe(true);
108 });
109
110 test("a database from before the column gains it in place, at three days", () => {
111 const dir = mkdtempSync(join(tmpdir(), "app-lead-old-"));
112 const old = openDb(dir);
113 const made = createDeal(old, alice, { address: "1 Old Rd", buyer: "A", seller: "B", contractDate: "2026-10-01", closingDate: "2026-12-01" });
114 expect(made.ok).toBe(true);
115 old.close();
116 const again = new Database(join(dir, "app.db"));
117 const column = again.query<{ name: string; dflt_value: string }, []>("PRAGMA table_info(deadline)").all().find((c) => c.name === "lead_days");
118 expect(column?.dflt_value).toBe("3");
119 });
120
121 // ---- the doors ----
122
123 const KEY = "a-key-only-the-forge-holds";
124 const server = serve({ port: 0, dataDir: mkdtempSync(join(tmpdir(), "app-lead-srv-")), identityKey: KEY });
125 const base = `http://${server.hostname}:${server.port}`;
126 afterAll(() => server.stop(true));
127 beforeEach(forgetRationing);
128 const as = (id: string, name: string): Record<string, string> => {
129 const identity = `${id}|${name}|user|${Date.now() + 60_000}`;
130 return { "x-forge-identity": identity, "x-forge-signature": sign(identity, KEY) };
131 };
132 const me = as("u7", "mia");
133 const get = (path: string) => fetch(base + path, { headers: me });
134 const sendJson = (method: string, path: string, body: unknown) =>
135 fetch(base + path, { method, headers: { ...me, "content-type": "application/json" }, body: JSON.stringify(body) });
136 const served = async (): Promise<DealView> => {
137 const made = await sendJson("POST", "/api/deals", { address: "9 Door Lane", buyer: "A", seller: "B", contract_date: "2026-10-01", closing_date: "2026-12-01" });
138 return (await made.json()) as DealView;
139 };
140
141 test("the sheet shows the lead and its form, and the form sets it without JavaScript", async () => {
142 const deal = await served();
143 const financing = kind(deal, "financing");
144 const page = await (await get(`/deals/${deal.id}`)).text();
145 expect(page).toContain("Reminds 7 days before");
146 expect(page).toContain(`action="/deadlines/${financing.id}/lead"`);
147 const body = new FormData();
148 body.set("lead_days", "10");
149 body.set("to", `/deals/${deal.id}`);
150 const ok = await fetch(`${base}/deadlines/${financing.id}/lead`, { method: "POST", body, headers: me, redirect: "manual" });
151 expect(ok.status).toBe(303);
152 const after = (await (await get(`/api/deals/${deal.id}`)).json()) as DealView;
153 expect(kind(after, "financing").lead_days).toBe(10);
154 expect(await (await get(`/deals/${deal.id}`)).text()).toContain("Reminds 10 days before");
155 const bad = new FormData();
156 bad.set("lead_days", "99");
157 bad.set("to", `/deals/${deal.id}`);
158 const refused = await fetch(`${base}/deadlines/${financing.id}/lead`, { method: "POST", body: bad, headers: me, redirect: "manual" });
159 expect(refused.status).toBe(303);
160 expect(kind((await (await get(`/api/deals/${deal.id}`)).json()) as DealView, "financing").lead_days).toBe(10);
161 });
162
163 test("the API reads and sets it; a bad lead is a 400 naming lead_days", async () => {
164 const deal = await served();
165 const inspection = kind(deal, "inspection");
166 expect(inspection.lead_days).toBe(3);
167 const path = `/api/deals/${deal.id}/deadlines/${inspection.id}`;
168 const good = await sendJson("PATCH", path, { lead_days: 6 });
169 expect(good.status).toBe(200);
170 expect(((await good.json()) as { lead_days: number }).lead_days).toBe(6);
171 for (const lead_days of [0, 31, 2.5, "3", null]) {
172 const bad = await sendJson("PATCH", path, { lead_days });
173 expect(bad.status).toBe(400);
174 expect(((await bad.json()) as { field: string }).field).toBe("lead_days");
175 }
176 const guest = await fetch(base + path, { method: "PATCH", headers: { "content-type": "application/json" }, body: JSON.stringify({ lead_days: 5 }) });
177 expect([401, 403]).toContain(guest.status);
178 expect(kind((await (await get(`/api/deals/${deal.id}`)).json()) as DealView, "inspection").lead_days).toBe(6);
179 });
180
181 test("MCP set_reminder_lead sets it and refuses a bad one", async () => {
182 const deal = await served();
183 const id = kind(deal, "title").id;
184 const call = async (args: unknown) =>
185 (await (await sendJson("POST", "/mcp", { jsonrpc: "2.0", id: 1, method: "tools/call", params: { name: "set_reminder_lead", arguments: args } })).json()) as any;
186 expect((await call({ id, lead_days: 0 })).result.isError).toBe(true);
187 expect((await call({ id, lead_days: 45 })).result.isError).toBe(true);
188 expect((await call({ id, lead_days: 2.5 })).result.isError).toBe(true);
189 expect((await call({ id, lead_days: 12 })).result.isError).not.toBe(true);
190 expect(kind((await (await get(`/api/deals/${deal.id}`)).json()) as DealView, "title").lead_days).toBe(12);
191 });
192
193 test("the terminal shows the lead and sets it with l; a bad one is refused", () => {
194 const made = createDeal(db, alice, { address: "7 Tty Row", buyer: "A", seller: "B", contractDate: today(), closingDate: addDays(today(), 45) });
195 if (!made.ok) throw new Error(made.message);
196 const t = terminal(db, alice, { title: "deal-clock", where: "test", agent });
197 const plain = (s: string): string => s.replace(/\x1b\[[0-9;]*m/g, "");
198 const under = (): string => t.screen().map(plain).find((l) => l.startsWith("▸")) ?? "";
199 t.press("d");
200 for (let i = 0; i < 200 && !under().includes(`${kind(made.value, "financing").label} — 7 Tty Row`); i++) t.press("j");
201 expect(under()).toContain("reminds 7d before");
202 for (const c of ["l", "99", "\r"]) t.press(c);
203 expect(t.screen().map(plain).join("\n")).toContain("whole number from 1 to 30");
204 expect(kind(fresh(made.value.id), "financing").lead_days).toBe(7);
205 for (const c of ["l", "5", "\r"]) t.press(c);
206 expect(kind(fresh(made.value.id), "financing").lead_days).toBe(5);
207 for (const c of ["l", "1", "\r"]) t.press(c);
208 const said = t.screen().map(plain).join("\n");
209 expect(said).toContain("reminds 1 day before");
210 expect(said).not.toContain("reminds 1 days");
211 });
212
213 test("a sent record's label names no number of days", () => {
214 expect(sentLabel("before")).toBe("Ahead of the date");
215 expect(sentLabel("before")).not.toMatch(/\d/);
216 expect(sentLabel("day_of")).toBe(momentLabel("day_of"));
217 });
218
219 test("the deal page names a sent record by its moment, not by the date's current lead", async () => {
220 const deal = await served();
221 const inspection = kind(deal, "inspection");
222 const party = deal.parties[0]!;
223 const form = (fields: Record<string, string>): FormData => {
224 const body = new FormData();
225 for (const [k, v] of Object.entries(fields)) body.set(k, v);
226 return body;
227 };
228 const sent = await fetch(`${base}/reminders`, {
229 method: "POST",
230 headers: me,
231 redirect: "manual",
232 body: form({ deadline: String(inspection.id), party: String(party.id), moment: "before", subject: "S", body: "B", to: `/deals/${deal.id}` }),
233 });
234 expect(sent.status).toBe(303);
235 await fetch(`${base}/deadlines/${inspection.id}/lead`, { method: "POST", headers: me, redirect: "manual", body: form({ lead_days: "20", to: `/deals/${deal.id}` }) });
236 const page = await (await get(`/deals/${deal.id}`)).text();
237 const record = page.slice(page.indexOf("Ahead of the date") - 200, page.indexOf("Ahead of the date") + 40);
238 expect(record).toContain("Ahead of the date");
239 expect(record).not.toContain("20 days before");
240 });
src/mcp.ts +11
@@ -27,6 +27,7 @@ import {
2727 removeDeadline,
2828 removeParty,
2929 sendReminder,
30 setReminderLead,
3031 declineReminder,
3132 undoDecline,
3233 } from "./deals.ts";
@@ -144,6 +145,16 @@ export const tools: readonly Tool[] = [
144145 return moved.ok ? ok({ ...moved.value, conflicts: conflictsOf(db, who, moved.value.deal_id) }) : moved;
145146 },
146147 },
148 {
149 name: "set_reminder_lead",
150 description: "Set how many days before it is due a date's first reminder goes out (a whole number, 1 to 30). An unsent draft is drafted again for the new day; a sent one keeps its words.",
151 inputSchema: {
152 type: "object",
153 properties: { id: { type: "integer" }, lead_days: { type: "integer", minimum: 1, maximum: 30 } },
154 required: ["id", "lead_days"],
155 },
156 run: (db, who, args) => setReminderLead(db, who, { id: Number(args.id), leadDays: args.lead_days }),
157 },
147158 {
148159 name: "amend_deal",
149160 description:
src/pages/clock.ts +1 −1
@@ -247,7 +247,7 @@ function render(input: {
247247 ? `<p class="muted">Nothing goes out today.</p>`
248248 : `<ul class="drafts">${today.map((t) => t.html).join("")}</ul>`
249249 }
250 <p class="muted small">Each date reminds its parties three days before and the morning of, and the one who owes a date is asked for an update the morning after it slips. Send records your approval and opens your own Mail or Messages with the words.</p>
250 <p class="muted small">Each date reminds its parties a few days before (three unless you set another, per date) and the morning of, and the one who owes a date is asked for an update the morning after it slips. Send records your approval and opens your own Mail or Messages with the words.</p>
251251 </section>`}`;
252252 return layout({ body, who, agent, path: "/", notice, open: opened?.href });
253253 }
src/pages/deal.ts +2 −2
@@ -9,7 +9,7 @@ import { canChange, canRemove, closedOn, type DealView, type Party, type Plan, t
99 import { standard } from "../env.ts";
1010 import { DEFAULT_LENGTHS, PARTY_LABEL, PARTY_ROLES } from "../deadlines.ts";
1111 import { escape } from "../http.ts";
12 import { MOMENT_LABEL, type Agent } from "../reminders.ts";
12 import { sentLabel, type Agent } from "../reminders.ts";
1313 import type { Who } from "../who.ts";
1414 import { amendForm, type AmendState } from "./amend.ts";
1515 import { confirmRemove } from "./confirm.ts";
@@ -55,7 +55,7 @@ function messages(deal: DealView, may: boolean): string {
5555 m.subject === ""
5656 ? `<p class="muted">The words were not kept for this one.</p>`
5757 : `<div class="draft-text"><p><b>${escape(m.subject)}</b></p><p class="draft-body">${escape(m.body)}</p></div>${outboxLine(m.href, may)}`;
58 return `<li class="draft"><details><summary><span><b>${escape(m.party_name)}</b> <span class="muted">${role} · ${escape(m.label)}${removed}, ${escape(short(m.due))} · ${escape(MOMENT_LABEL[m.moment])}</span><br>${escape(m.subject === "" ? "(no subject kept)" : m.subject)}</span><span class="state" data-sent>Sent ${escape(short(m.sent_at.slice(0, 10)))}</span></summary>${words}</details></li>`;
58 return `<li class="draft"><details><summary><span><b>${escape(m.party_name)}</b> <span class="muted">${role} · ${escape(m.label)}${removed}, ${escape(short(m.due))} · ${escape(sentLabel(m.moment))}</span><br>${escape(m.subject === "" ? "(no subject kept)" : m.subject)}</span><span class="state" data-sent>Sent ${escape(short(m.sent_at.slice(0, 10)))}</span></summary>${words}</details></li>`;
5959 };
6060 return `<ul class="drafts">${deal.sent.map(item).join("")}</ul>`;
6161 }
src/pages/review.ts +2 −2
@@ -11,7 +11,7 @@ import { BODY_MAX, REASON_MAX, SUBJECT_MAX } from "../deals.ts";
1111 import { spoken } from "../dates.ts";
1212 import { PARTY_LABEL } from "../deadlines.ts";
1313 import { escape } from "../http.ts";
14 import { MOMENT_LABEL, type Draft } from "../reminders.ts";
14 import { momentLabel, type Draft } from "../reminders.ts";
1515 import type { Who } from "../who.ts";
1616 import { layout } from "./layout.ts";
1717 import { hidden } from "./sheet.ts";
@@ -87,7 +87,7 @@ function form(
8787 <p class="eyebrow">${s.position} of ${s.total}</p>
8888 <h1>Review today's reminders</h1>
8989 <p><a href="/deals/${draft.deal_id}">${escape(draft.address)}</a></p>
90 <p><b>${escape(draft.label)}</b> <span class="muted">· ${escape(spoken(draft.due))} · ${escape(MOMENT_LABEL[draft.moment])}</span></p>
90 <p><b>${escape(draft.label)}</b> <span class="muted">· ${escape(spoken(draft.due))} · ${escape(momentLabel(draft.moment, draft.lead_days))}</span></p>
9191 <p>To <b>${escape(draft.party_name)}</b> <span class="muted">· ${escape(PARTY_LABEL[draft.party_role])} · ${escape(draft.contact === "" ? "no contact on file" : draft.contact)}</span></p>
9292 <form class="move" method="post" action="${REVIEW_PATH}/send">${hidden(keys)}
9393 ${problem("subject")}
src/pages/sheet.ts +8 −4
@@ -7,14 +7,14 @@
77
88 import { BODY_MAX, canChange, REASON_MAX, SUBJECT_MAX, type DealView, type DeadlineView } from "../deals.ts";
99 import { relative, short, spoken, urgency, type Urgency } from "../dates.ts";
10 import { PARTY_LABEL } from "../deadlines.ts";
10 import { LEAD_MAX, LEAD_MIN, PARTY_LABEL } from "../deadlines.ts";
1111 import { escape } from "../http.ts";
1212 import { confirmRemove } from "./confirm.ts";
1313 import { memoizer, print } from "../memo.ts";
1414 import { labelOf, NO_CONTACT, outbox } from "../outbox.ts";
1515 import { conflictLine } from "../order.ts";
1616 import { agent as defaults } from "../env.ts";
17 import { draftsFor, MOMENT_LABEL, MOMENTS, type Agent, type Draft } from "../reminders.ts";
17 import { draftsFor, momentLabel, MOMENTS, remindsLine, type Agent, type Draft } from "../reminders.ts";
1818 import type { Who } from "../who.ts";
1919 import { owner } from "../week.ts";
2020
@@ -150,7 +150,7 @@ export function sheet(deal: DealView, d: DeadlineView, who: Who, on: string, to:
150150 : MOMENTS.map((m) => {
151151 const these = drafts.filter((r) => r.moment === m);
152152 if (these.length === 0) return "";
153 const head = `<h4>${MOMENT_LABEL[m]} <span class="muted">· ${escape(spoken(these[0]!.on))}</span></h4>`;
153 const head = `<h4>${momentLabel(m, d.lead_days)} <span class="muted">· ${escape(spoken(these[0]!.on))}</span></h4>`;
154154 return `${head}<ul class="drafts">${these.map((r) => draftItem(r, on, may, to)).join("")}</ul>`;
155155 }).join("");
156156 const moves =
@@ -173,6 +173,10 @@ export function sheet(deal: DealView, d: DeadlineView, who: Who, on: string, to:
173173 <button class="button button-quiet">Move this date</button>
174174 </form>
175175 <p class="muted small">Moving a date moves nothing else; the reason is kept.</p>
176 <form class="move" method="post" action="/deadlines/${d.id}/lead">${hidden({ to })}
177 <label>Remind me this many days before<input class="input" type="number" name="lead_days" min="${LEAD_MIN}" max="${LEAD_MAX}" step="1" value="${d.lead_days}" required></label>
178 <button class="button button-quiet">Set reminder</button>
179 </form>
176180 ${
177181 d.kind === "custom"
178182 ? `${confirmRemove({
@@ -199,7 +203,7 @@ export function sheet(deal: DealView, d: DeadlineView, who: Who, on: string, to:
199203 <section><h3>Who owes what</h3><p>${owedBy(deal, d)}</p>${d.what === "" ? "" : `<p>${escape(d.what)}</p>`}</section>
200204 ${conflictLines(deal, d)}
201205 ${moves}
202 <section><h3>Reminders</h3>${reminders}</section>
206 <section><h3>Reminders</h3>${d.done_at === null ? `<p class="muted">${remindsLine(d.lead_days)}</p>` : ""}${reminders}</section>
203207 ${actions}
204208 </div>`;
205209 }
src/reminders.ts +24 −8
@@ -1,6 +1,7 @@
11 /**
22 * Reminders, drafted. Every open date of a deal reminds each party it
3 * concerns three days before and the morning of; a date that slips past due
3 * concerns its lead time before (three days unless the agent sets another)
4 * and the morning of; a date that slips past due
45 * while still open gets a third, the morning after, to the party who owes it
56 * alone. A draft is plain data — who, when, the words — computed from a deal;
67 * nothing is sent anywhere. `sendReminder` (`deals.ts`) records that the agent
@@ -9,7 +10,7 @@
910
1011 import { addDays, spoken, today } from "./dates.ts";
1112 import { memoizer, print } from "./memo.ts";
12 import { KIND, PARTY_LABEL, type PartyRole } from "./deadlines.ts";
13 import { DEFAULT_LEAD, KIND, PARTY_LABEL, type PartyRole } from "./deadlines.ts";
1314 import type { DealView, DeadlineView, Move, Moment, Party } from "./deals.ts";
1415
1516 export interface Agent {
@@ -34,6 +35,8 @@ export interface Draft {
3435 readonly party_role: PartyRole;
3536 readonly contact: string;
3637 readonly moment: Moment;
38 /** Days before the due date the "before" reminder goes out: the date's own lead time. */
39 readonly lead_days: number;
3740 /** The move a "date changed" notice is about (for an amendment, its first); 0 for every other moment. */
3841 readonly move_id: number;
3942 /** The morning it goes out. */
@@ -47,15 +50,27 @@ export interface Draft {
4750 }
4851
4952 export const MOMENTS: readonly Moment[] = ["before", "day_of", "late", "moved"];
50 export const MOMENT_LABEL: Readonly<Record<Moment, string>> = {
51 before: "3 days before",
53 const MOMENT_LABEL: Readonly<Record<Exclude<Moment, "before">, string>> = {
5254 day_of: "Morning of",
5355 late: "Overdue follow-up",
5456 moved: "Date changed",
5557 };
56 const OFFSET: Readonly<Record<Exclude<Moment, "moved">, number>> = { before: -3, day_of: 0, late: 1 };
58 /** "1 day", "7 days": the one way a lead time is said everywhere. */
59 export const days = (n: number): string => `${n} ${n === 1 ? "day" : "days"}`;
60 /** "Reminds 7 days before": what a date's lead time reads as, on its sheet and after it is set. */
61 export const remindsLine = (lead: number): string => `Reminds ${days(lead)} before`;
62 /** "N days before", "Morning of", …: what a moment is called, given the lead time of its date. */
63 export const momentLabel = (moment: Moment, lead: number = DEFAULT_LEAD): string =>
64 moment === "before" ? `${days(lead)} before` : MOMENT_LABEL[moment];
65 /**
66 * What a sent record calls its moment. It went out on the lead its date had
67 * then, which the record does not keep, so the "before" one is not numbered.
68 */
69 export const sentLabel = (moment: Moment): string => (moment === "before" ? "Ahead of the date" : MOMENT_LABEL[moment]);
70 const OFFSET: Readonly<Record<Exclude<Moment, "before" | "moved">, number>> = { day_of: 0, late: 1 };
5771 /** The morning a reminder goes out; a "date changed" notice goes the day of the move instead. */
58 export const sendOn = (due: string, moment: Exclude<Moment, "moved">): string => addDays(due, OFFSET[moment]);
72 export const sendOn = (due: string, moment: Exclude<Moment, "moved">, lead: number = DEFAULT_LEAD): string =>
73 addDays(due, moment === "before" ? -lead : OFFSET[moment]);
5974
6075 /** The move a "date changed" notice is about: the latest, if the agent is to tell people of it. */
6176 const lastMove = (deadline: DeadlineView): Move | undefined => {
@@ -143,7 +158,7 @@ function words(
143158 body: `Hi ${first(party.name)}, the ${deadline.label.toLowerCase()} for ${deal.address} was due ${spoken(deadline.due)} and has passed without being marked done. ${owed}Could you send me an update today on where it stands and when it will be done?\n\n${signOff(agent)}`,
144159 };
145160 }
146 const when = moment === "before" ? `in three days, on ${spoken(deadline.due)}` : `today, ${spoken(deadline.due)}`;
161 const when = moment === "before" ? `in ${days(deadline.lead_days)}, on ${spoken(deadline.due)}` : `today, ${spoken(deadline.due)}`;
147162 const yours = party.role === deadline.owes;
148163 const ask = yours
149164 ? "This one is yours — please let me know right away if anything could hold it up."
@@ -194,8 +209,9 @@ export function draftsFor(deal: DealView, deadline: DeadlineView, agent: Agent):
194209 party_role: party.role,
195210 contact: party.contact,
196211 moment,
212 lead_days: deadline.lead_days,
197213 move_id: key,
198 on: moment === "moved" ? today(new Date(lastMove(deadline)!.at)) : sendOn(deadline.due, moment),
214 on: moment === "moved" ? today(new Date(lastMove(deadline)!.at)) : sendOn(deadline.due, moment, deadline.lead_days),
199215 // A sent reminder keeps the words it went with, whatever the deal says now.
200216 subject: sent !== undefined && sent.subject !== "" ? sent.subject : drafted.subject,
201217 body: sent !== undefined && sent.subject !== "" ? sent.body : drafted.body,
src/routes.ts +31 −1
@@ -59,6 +59,7 @@ import {
5959 removeDeadline,
6060 removeParty,
6161 sendReminder,
62 setReminderLead,
6263 declineReminder,
6364 undoDecline,
6465 updateDeal,
@@ -80,7 +81,7 @@ import { reviewHref, reviewPage, type ReviewField } from "./pages/review.ts";
8081 import { peoplePage } from "./pages/people.ts";
8182 import { timelinePage } from "./pages/timeline.ts";
8283 import { welcomePage } from "./pages/welcome.ts";
83 import { dueOn, todaysDrafts, unsent, type Draft } from "./reminders.ts";
84 import { dueOn, remindsLine, todaysDrafts, unsent, type Draft } from "./reminders.ts";
8485 import { token, tokensCss } from "./tokens.ts";
8586 import type { Who } from "./who.ts";
8687
@@ -786,6 +787,16 @@ export const routes: readonly Route[] = [
786787 return done(moved, backTo(f.to), moved.ok ? withConflicts(c.db, c.who, moved.value.deal_id, "Date moved; nothing else did.") : undefined);
787788 },
788789 },
790 {
791 method: "POST",
792 path: "/deadlines/:id/lead",
793 handle: async (c) => {
794 const f = await form(c);
795 if (f instanceof Response) return f;
796 const set = setReminderLead(c.db, c.who, { id: Number(c.params.id), leadDays: f.lead_days });
797 return done(set, backTo(f.to), set.ok ? `${remindsLine(set.value.lead_days)}.` : undefined);
798 },
799 },
789800 {
790801 method: "POST",
791802 path: "/deadlines/:id/remove",
@@ -1076,6 +1087,25 @@ export const routes: readonly Route[] = [
10761087 answer: DEAL,
10771088 },
10781089 },
1090 {
1091 method: "PATCH",
1092 path: "/api/deals/:id/deadlines/:deadline",
1093 handle: async (c) => {
1094 const body = await readJson(c.request);
1095 if (body === undefined) return json({ error: "too_large" }, 413);
1096 const lead = fields(body).lead_days;
1097 const set = setReminderLead(c.db, c.who, { id: Number(c.params.deadline), dealId: Number(c.params.id), leadDays: typeof lead === "number" ? lead : Number.NaN });
1098 // A lead outside 1–30 is a bad field: 400, naming it.
1099 if (!set.ok && set.field !== undefined) return json({ error: set.error, message: set.message, field: set.field }, 400);
1100 return answer(set);
1101 },
1102 api: {
1103 summary:
1104 "Set how many days before it is due a date's first reminder goes out (a whole number, 1 to 30; 400 with field lead_days otherwise). An unsent draft is drafted again for the new day; a sent one keeps its words.",
1105 body: { type: "object", properties: { lead_days: { type: "integer", minimum: 1, maximum: 30 } }, required: ["lead_days"] },
1106 answer: { type: "object", properties: { id: { type: "integer" }, lead_days: { type: "integer" } }, required: ["id", "lead_days"] },
1107 },
1108 },
10791109 {
10801110 method: "DELETE",
10811111 path: "/api/deals/:id/deadlines/:deadline",
src/server.test.ts +1
@@ -176,6 +176,7 @@ test("the MCP server lists the tools and calls them as the caller", async () =>
176176 "list_people",
177177 "mark_done",
178178 "move_date",
179 "set_reminder_lead",
179180 "amend_deal",
180181 "send_reminder",
181182 "decline_reminder",
src/terminal.ts +16 −8
@@ -12,7 +12,7 @@
1212 * deal one deal's dates and parties; a adds a date, p a party, A corrects the address, M amends the contract, D removes it
1313 *
1414 * On a date (dates or deal view): x marks it done, u reopens it, m moves it
15 * (a new date, then the reason). o or enter opens its deal; n opens a new
15 * (a new date, then the reason), l sets how many days before it reminds. o or enter opens its deal; n opens a new
1616 * deal (address, buyer, seller, contract and closing dates); d, r and b move
1717 * between views; esc cancels a prompt; q leaves. / finds a deal by address or
1818 * party and narrows dates, week and reminders to it; / then enter clears it.
@@ -42,6 +42,7 @@ import {
4242 moveDeadline,
4343 withConflicts,
4444 removeDeadline,
45 setReminderLead,
4546 removeParty,
4647 sendReminder,
4748 declineReminder,
@@ -56,7 +57,7 @@ import { conflictLine } from "./order.ts";
5657 import { PARTY_LABEL, PARTY_ROLES, type PartyRole } from "./deadlines.ts";
5758 import { agentOf, getProfile, setProfile, useDefaults } from "./profile.ts";
5859 import { permit } from "./contract.ts";
59 import { drafts, MOMENT_LABEL, pending, unsent, type Agent, type Draft } from "./reminders.ts";
60 import { drafts, momentLabel, pending, remindsLine, sentLabel, unsent, type Agent, type Draft } from "./reminders.ts";
6061 import type { Result } from "./result.ts";
6162 import type { Who } from "./who.ts";
6263 import { people } from "./people.ts";
@@ -167,7 +168,7 @@ export function terminal(
167168
168169 function onDate(key: string): boolean {
169170 const row = dateRows()[cursor];
170 if (!["x", "u", "m", "o", "\r"].includes(key)) return false;
171 if (!["x", "u", "m", "l", "o", "\r"].includes(key)) return false;
171172 if (row === undefined) {
172173 said = "No date here.";
173174 return true;
@@ -179,6 +180,12 @@ export function terminal(
179180 ask(deal, [`New date for ${date.label} (YYYY-MM-DD, now ${date.due})`, "Why it moved"], ([due, reason]) =>
180181 report(moveDeadline(db, me, { id: date.id, due, reason }), () => withConflicts(db, me, deal.id, `Moved ${date.label} to ${isDate(due) ? spoken(due!) : due}; nothing else moved.`)),
181182 );
183 if (key === "l")
184 ask(deal, [`Remind how many days before ${date.label} (1 to 30, now ${date.lead_days})`], ([days]) => {
185 const set = setReminderLead(db, me, { id: date.id, leadDays: days });
186 return report(set, () => `${date.label}: ${remindsLine(set.ok ? set.value.lead_days : 0).toLowerCase()}.`);
187 },
188 );
182189 if ((key === "o" || key === "\r") && view === "dates") {
183190 view = "deal";
184191 dealId = deal.id;
@@ -499,7 +506,8 @@ export function terminal(
499506 const label = view === "week" ? `${date.label} — ${deal.address} · ${who.name ?? who.role}` : withDeal ? `${date.label} — ${deal.address}` : date.label;
500507 const text = label + (deal.closed && withDeal ? dim(" (closed)") : "");
501508 const moved = date.moves.length > 0 ? dim(` moved: ${date.moves.at(-1)!.reason}`) : "";
502 return `${i === cursor ? "▸" : " "} ${when} ${i === cursor ? bold(text) : text}${moved}`;
509 const lead = date.done_at === null ? dim(` reminds ${date.lead_days}d before`) : "";
510 return `${i === cursor ? "▸" : " "} ${when} ${i === cursor ? bold(text) : text}${lead}${moved}`;
503511 };
504512
505513 function screen(): string[] {
@@ -575,7 +583,7 @@ export function terminal(
575583 if (deal.sent.length === 0) lines.push(dim("Nothing sent yet"));
576584 deal.sent.forEach((m, i) => {
577585 const role = m.party_role === "" ? "" : ` (${PARTY_LABEL[m.party_role].toLowerCase()})`;
578 const text = `${m.party_name}${role} · ${m.label}, ${spoken(m.due)} · ${MOMENT_LABEL[m.moment].toLowerCase()}`;
586 const text = `${m.party_name}${role} · ${m.label}, ${spoken(m.due)} · ${sentLabel(m.moment).toLowerCase()}`;
579587 lines.push(`${i === cursor ? "▸" : " "} ${dim(`sent ${m.sent_at.slice(0, 10)}`.padEnd(16))} ${i === cursor ? bold(text) : text}`);
580588 if (reading === i && canChange(me, deal)) {
581589 const to = deal.parties.find((p) => p.id === m.party_id)?.contact ?? "";
@@ -611,7 +619,7 @@ export function terminal(
611619 if (rows.length === 0) lines.push(dim("Nothing goes out today."));
612620 rows.forEach(({ draft }, i) => {
613621 const state = draft.sent_at !== null ? dim("sent") : draft.declined !== null ? dim("not sent") : draft.on < day ? tint("overdue", "late") : tint("soon", "to send");
614 const text = `${draft.party_name} (${PARTY_LABEL[draft.party_role].toLowerCase()}) · ${draft.label}, ${draft.address} · ${MOMENT_LABEL[draft.moment].toLowerCase()}`;
622 const text = `${draft.party_name} (${PARTY_LABEL[draft.party_role].toLowerCase()}) · ${draft.label}, ${draft.address} · ${momentLabel(draft.moment, draft.lead_days).toLowerCase()}`;
615623 lines.push(`${i === cursor ? "▸" : " "} ${state.padEnd(16)} ${i === cursor ? bold(text) : text}`);
616624 if (reading === i) {
617625 const words = edited(draft);
@@ -638,8 +646,8 @@ export function terminal(
638646 : view === "timeline"
639647 ? "b back to the deal · d dates · q quit"
640648 : view === "deal"
641 ? "j/k move · t client timeline · s messages · x done · u reopen · m move · a add date · p add party · e edit party · A edit address · M amend the contract · X remove date/party · D remove deal · b back · q quit"
642 : `j/k move · x done · u reopen · m move · o open deal · n new deal · c check dates · / find · R restore samples · h ${showDone ? "hide" : "show"} done · w this week · r reminders · P people · I profile · q quit`;
649 ? "j/k move · t client timeline · s messages · x done · u reopen · m move · l remind lead · a add date · p add party · e edit party · A edit address · M amend the contract · X remove date/party · D remove deal · b back · q quit"
650 : `j/k move · x done · u reopen · m move · l lead · o open deal · n new deal · c check dates · / find · R restore samples · h ${showDone ? "hide" : "show"} done · w this week · r reminders · P people · I profile · q quit`;
643651 lines.push(dim(me.role === "anon" ? `${keys} · sign in with a key the forge knows to change anything` : keys));
644652 }
645653 return lines;

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs