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

A deal prints as a one-page broker file: price, earnest money, commission, every party, every date with the day it was done, waived or moved, and every message the agent approved #159

Merged opened this

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

Merged

mason/deal-clock:mason/152-a-deal-prints-as-a-one-page-broker-file → main 2 commits fork 1 thread · 1 unresolved

  • Merged. mason/152-a-deal-prints-as-a-one-page-broker-file was merged into main as 8ce3366.

Review

Sign in to review this change.
10 files changed +349 −24
README.md +1
@@ -167,6 +167,7 @@ Signed out, `/` shows what deal-clock does, three short points, a still picture
167167 under the date and the MCP tool returns it as the date's `todo` list. Tap Print to make the one-page handout
168168 for a buyer or seller (the browser's own print works too). In the terminal, open the deal with o and press
169169 t; over MCP, an agent asks for the `client_timeline` tool.
170 When a deal closes, Print broker file on its page makes the one page for the brokerage's transaction file: price, earnest money, commission, every party, every date with the day it was done, waived or moved, and every message you approved or declined, in your words; it is yours alone, not the client's handout. In the terminal, open the deal with o and press f.
170171 14. **Fix an address.** On a deal's page, Edit address corrects a typo in
171172 place: the clock, the client timeline, the calendar file and unsent drafts
172173 carry the new address, and reminders already sent keep their words. In the
src/contract.test.ts +15
@@ -229,3 +229,18 @@ test("the spreadsheet, at GET /deals/csv and GET /api/deals.csv, answers as deal
229229 expect(anon.status).toBe(401);
230230 }
231231 });
232
233 test("the broker file, at GET /deals/:id/file, answers as deal read says, as every identity", async () => {
234 const route = routes.find((r) => r.method === "GET" && r.path === "/deals/:id/file")!;
235 const id = dealBy("someone-else");
236 for (const identity of identities(contract)) {
237 const who = whoIs(identity);
238 const said = `/deals/:id/file as ${identity}`;
239 const url = new URL(`http://app.test/deals/${id}/file`);
240 const res = await route.handle({ request: new Request(url), url, db, who, params: { id: String(id) } });
241 expect([said, res.status === 200]).toEqual([said, permit(who, "deal", "read") !== "no"]);
242 }
243 const url = new URL(`http://app.test/deals/${id}/file`);
244 const anon = await route.handle({ request: new Request(url), url, db, who: { role: "anon" }, params: { id: String(id) } });
245 expect(anon.status).toBe(401);
246 });
src/file.test.ts added +125
@@ -0,0 +1,125 @@
1 /** The broker file: the agent's whole record of a deal on one page, signed-in only, no controls in print. */
2 import { afterAll, expect, test } from "bun:test";
3 import { mkdtempSync } from "node:fs";
4 import { tmpdir } from "node:os";
5 import { join } from "node:path";
6 import { addDeadline, addParty, createDeal, declineReminder, getDeal, markFellThrough, moveDeadline, removeDeadline, sendReminder, waiveDate } from "./deals.ts";
7 import { openDb } from "./db.ts";
8 import { terminal } from "./terminal.ts";
9 import { filePage } from "./pages/file.ts";
10 import { forgetRationing } from "./security.ts";
11 import { serve } from "./server.ts";
12 import { sign, type Who } from "./who.ts";
13
14 const db = openDb(mkdtempSync(join(tmpdir(), "app-file-")));
15 const alice: Who = { role: "user", id: "u1", name: "alice" };
16
17 const made = createDeal(db, alice, { openAnyway: true, address: "9 <b>Oak</b> Rd", buyer: "Ann Buyer", seller: "Sam Seller", contractDate: "2026-10-01", closingDate: "2026-11-06" });
18 if (!made.ok) throw new Error(made.message);
19 const id = made.value.id;
20 const lender = addParty(db, alice, { dealId: id, role: "lender", name: "Lena Lender", contact: "[email protected]" });
21 if (!lender.ok) throw new Error(lender.message);
22 const buyer = getDeal(db, alice, { id });
23 if (!buyer.ok) throw new Error(buyer.message);
24 const ann = buyer.value.parties.find((p) => p.role === "buyer")!;
25 const gone = addDeadline(db, alice, { dealId: id, label: "Gone repair date", due: "2026-10-23", owes: "seller", what: "" });
26 if (!gone.ok) throw new Error("setup");
27 const hoa = addDeadline(db, alice, { dealId: id, label: "HOA review ends", due: "2026-10-20", owes: "buyer", what: "" });
28 const survey = addDeadline(db, alice, { dealId: id, label: "Survey back", due: "2026-10-22", owes: "seller", what: "" });
29 const repair = addDeadline(db, alice, { dealId: id, label: "Repair request", due: "2026-10-24", owes: "buyer", what: "" });
30 if (!hoa.ok || !survey.ok || !repair.ok) throw new Error("setup");
31 moveDeadline(db, alice, { id: hoa.value.id, due: "2026-10-27", reason: "Seller asked for time" });
32 waiveDate(db, alice, { id: survey.value.id, waived: true });
33 const sent = sendReminder(db, alice, { deadlineId: hoa.value.id, partyId: ann.id, moment: "moved", subject: "HOA date moved", body: "Hello Ann,\nthe HOA date is now Oct 27." });
34 if (!sent.ok) throw new Error(sent.message);
35 const goneSent = sendReminder(db, alice, { deadlineId: gone.value.id, partyId: getDeal(db, alice, { id }).ok ? ann.id : 0, moment: "day_of", subject: "Gone", body: "x" });
36 if (!goneSent.ok) throw new Error(goneSent.message);
37 removeDeadline(db, alice, { dealId: id, id: gone.value.id });
38 const declined = declineReminder(db, alice, { deadlineId: repair.value.id, partyId: ann.id, moment: "day_of", reason: "Called her instead" });
39 if (!declined.ok) throw new Error(declined.message);
40
41 const page = (): string => {
42 const deal = getDeal(db, alice, { id });
43 if (!deal.ok) throw new Error(deal.message);
44 return filePage({ who: alice, deal: deal.value });
45 };
46
47 test("holds the figures, parties, every date's state and the words approved and declined", () => {
48 const html = page();
49 expect(html).toContain("Commission rate");
50 expect(html).toContain("Earnest money");
51 expect(html).toContain("Lena Lender");
52 expect(html).toContain("[email protected]");
53 expect(html).toContain("HOA review ends");
54 expect(html).toContain("Seller asked for time");
55 expect(html).toContain("Waived");
56 expect(html).toContain("HOA date moved");
57 expect(html).toContain("the HOA date is now Oct 27.");
58 expect(html).toContain("Called her instead");
59 });
60
61 test("a removed date is a row marked Removed, with the day it was due", () => {
62 const html = page();
63 expect(html).toContain("Gone repair date · due");
64 expect(html).toMatch(/Gone repair date · due [^<]*· Removed/);
65 });
66
67 test("escapes every value and has no forms", () => {
68 const html = page();
69 expect(html).toContain("9 &lt;b&gt;Oak&lt;/b&gt; Rd");
70 expect(html).not.toContain("<b>Oak</b>");
71 expect(html).not.toContain("<form");
72 });
73
74 test("a fell-through deal shows its reason", () => {
75 const fell = markFellThrough(db, alice, { id, fell: true, reason: "Financing collapsed" });
76 if (!fell.ok) throw new Error(fell.message);
77 expect(page()).toContain("Financing collapsed");
78 expect(markFellThrough(db, alice, { id, fell: false }).ok).toBe(true);
79 });
80
81 test("the print rules hide navigation and stay scoped to the file page", async () => {
82 const css = await Bun.file(join(import.meta.dir, "..", "static", "app.css")).text();
83 const print = css.slice(css.indexOf("/* The broker file"));
84 const media = print.slice(print.indexOf("@media print"));
85 expect(media).toMatch(/\.file-page \.head[\s\S]*display: none/);
86 const selectors = [...media.matchAll(/^\s*([^{}@\n]+)\{/gm)].map((m) => m[1]!.trim());
87 for (const sel of selectors) for (const part of sel.split(",")) expect(part.trim()).toStartWith(".file-page");
88 });
89
90 test("answers a signed-in visitor, refuses a signed-out one", async () => {
91 const KEY = "a-key-only-the-forge-holds";
92 const server = serve({ port: 0, dataDir: mkdtempSync(join(tmpdir(), "app-filesrv-")), identityKey: KEY });
93 afterAll(() => server.stop(true));
94 const base = `http://${server.hostname}:${server.port}`;
95 const ident = `u1|alice|user|${Date.now() + 600_000}`;
96 const headers = { "x-forge-identity": ident, "x-forge-signature": sign(ident, KEY) };
97 forgetRationing();
98 const out = await fetch(`${base}/deals/1/file`, { headers });
99 expect(out.status).toBe(200);
100 expect(await out.text()).toContain("Broker file");
101 const anon = await fetch(`${base}/deals/1/file`);
102 expect([401, 403]).toContain(anon.status);
103 });
104
105 test("the terminal's f on an open deal shows the broker file, and a guest sees none", () => {
106 const agent = { name: "Dana", brokerage: "HP", phone: "555", email: "[email protected]" };
107 const t = terminal(db, alice, { title: "deal-clock", where: "test", agent, on: () => "2026-10-25" });
108 const row = (): string => t.screen().join("\n").split("\n").find((l) => l.startsWith("▸")) ?? "";
109 for (let i = 0; i < 300 && !row().includes("Repair request"); i++) t.press("j");
110 t.press("o");
111 t.press("f");
112 const screen = t.screen().join("\n").replace(/\x1b\[[0-9;]*m/g, "");
113 expect(screen).toContain("Broker file");
114 expect(screen).toContain("Commission rate");
115 expect(screen).toContain("Gone repair date");
116 expect(screen).toContain("Called her instead");
117 t.press("b");
118 expect(t.screen().join("\n")).not.toContain("Broker file");
119 const guest = terminal(db, { role: "anon" }, { title: "deal-clock", where: "test", agent, on: () => "2026-10-25" });
120 guest.press("o");
121 guest.press("f");
122 const seen = guest.screen().join("\n");
123 expect(seen).not.toContain("Commission rate");
124 expect(seen).not.toContain("Lena Lender");
125 });
src/pages/deal.ts +1 −1
@@ -333,7 +333,7 @@ export function dealPage(input: {
333333 ${editFigures}
334334 ${editClosing}
335335 </div>
336 <div class="row"><a class="button button-quiet" href="${path}/timeline">Client timeline</a> <a class="button button-quiet" href="${path}/ics" download>Add to calendar</a></div>
336 <div class="row"><a class="button button-quiet" href="${path}/timeline">Client timeline</a> <a class="button button-quiet" href="${path}/file">Print broker file</a> <a class="button button-quiet" href="${path}/ics" download>Add to calendar</a></div>
337337 </section>
338338 <div id="deal" data-live="deal.changed">
339339 <p class="progress">${progressLine(deal, on)}</p>
src/pages/file.ts added +107
@@ -0,0 +1,107 @@
1 /**
2 * A deal's broker file at `/deals/:id/file`: one printed page for the
3 * brokerage's transaction file. The agent's own figures (commission), every
4 * party with contact, every date with its due day and state, every message
5 * approved and every one declined. It is the agent's page, not the client's:
6 * the client timeline leaves these out on purpose. Built only from the
7 * DealView the deal page already reads; `fileRecord` is the plain data both
8 * this page and the terminal print from.
9 */
10
11 import { doneLine, short, spoken } from "../dates.ts";
12 import { closedOn, fellOn, type DealView, type Party } from "../deals.ts";
13 import { PARTY_LABEL } from "../deadlines.ts";
14 import { closingLine } from "../closing.ts";
15 import { commission, dollars, percent } from "../money.ts";
16 import { agent as defaults } from "../env.ts";
17 import { asset, escape } from "../http.ts";
18 import { sentLabel, type Agent } from "../reminders.ts";
19 import { SIDE_LABEL } from "../side.ts";
20 import type { Who } from "../who.ts";
21 import { layout } from "./layout.ts";
outdated

Duplicate import from ../http.ts: merge with escape on line 16.

22
23 const contactOf = (p: Party): string => {
24 const parts = [p.email, p.phone].filter((v) => v !== "");
25 return parts.length > 0 ? parts.join(" · ") : p.contact;
26 };
27
28 /** Where one date stands, in words: done on (and how early or late), waived, or open. */
29 export function fileState(d: DealView["deadlines"][number]): string {
30 if (d.waived_at !== null)
31 return `Waived ${spoken(d.waived_at.slice(0, 10))}${d.waived_by === null ? "" : ` by ${d.waived_by}`}`;
32 if (d.done_at !== null) return d.done_on === null ? "Done" : doneLine(d.due, d.done_on);
33 return "Open";
34 }
35
36 export interface FileRecord {
37 readonly facts: readonly (readonly [string, string])[];
38 readonly parties: readonly string[];
39 /** One entry per date, live or removed: its line, then one line per move. */
40 readonly dates: readonly { readonly line: string; readonly moves: readonly string[] }[];
41 readonly sent: readonly { readonly head: string; readonly subject: string; readonly body: string }[];
42 readonly declined: readonly string[];
43 }
44
45 /** Everything the broker file says, as plain unescaped text. */
46 export function fileRecord(deal: DealView): FileRecord {
47 const outcome = deal.fell_through
48 ? `Fell through on ${spoken(fellOn(deal))}${deal.fell_reason ? ` · ${deal.fell_reason}` : ""}${deal.fell_by ? ` (${deal.fell_by})` : ""}`
49 : deal.closed
50 ? `Closed on ${spoken(closedOn(deal))}`
51 : "Open";
52 const live = new Set(deal.deadlines.map((d) => d.id));
53 const live_dates = deal.deadlines.map((d) => ({
54 line: `${d.label} · due ${spoken(d.due)} · ${fileState(d)}`,
55 moves: d.moves.map((m) => `Moved ${short(m.from_due)} → ${short(m.to_due)}: ${m.reason} (${m.by_name}, ${short(m.at.slice(0, 10))})`),
56 }));
57 // A removed date leaves no row of its own; what remains of it is in the messages sent or declined about it.
58 const gone = new Map<number, { label: string; due: string }>();
59 for (const m of [...deal.sent, ...deal.declined])
60 if (!live.has(m.deadline_id) && !gone.has(m.deadline_id)) gone.set(m.deadline_id, { label: m.label, due: m.due });
61 const removed = [...gone.values()].map((g) => ({ line: `${g.label} · due ${spoken(g.due)} · Removed`, moves: [] as string[] }));
62 return {
63 facts: [
64 ["Status", outcome],
65 ["Side", SIDE_LABEL[deal.side]],
66 ["Sale price", deal.sale_price === null ? "not set" : dollars(deal.sale_price)],
67 ["Earnest money", deal.earnest_amount === null ? "not set" : dollars(deal.earnest_amount)],
68 ["Commission rate", deal.commission_rate === null ? "not set" : percent(deal.commission_rate)],
69 [
70 "Commission at closing",
71 deal.commission_rate === null || deal.sale_price === null ? "not set" : dollars(commission(deal.sale_price, deal.commission_rate)),
72 ],
73 ["Under contract", spoken(deal.contract_date)],
74 ["Closing", closingLine(deal).replace(/^Closing /, "")],
75 ],
76 parties: deal.parties.map((p) => `${PARTY_LABEL[p.role]} · ${p.name}${contactOf(p) === "" ? "" : ` · ${contactOf(p)}`}`),
77 dates: [...live_dates, ...removed],
78 sent: deal.sent.map((m) => ({
79 head: `${m.party_name}${m.party_role === "" ? "" : ` · ${PARTY_LABEL[m.party_role]}`} · ${m.label}${live.has(m.deadline_id) ? "" : " (date removed)"}, due ${short(m.due)} · ${sentLabel(m.moment)} · approved by ${m.by_name} on ${spoken(m.sent_at.slice(0, 10))}`,
80 subject: m.subject,
81 body: m.body,
82 })),
83 declined: deal.declined.map(
84 (m) => `${m.party_name} · ${m.label}${live.has(m.deadline_id) ? "" : " (date removed)"}, due ${short(m.due)} · ${sentLabel(m.moment)} · declined by ${m.by_name} on ${spoken(m.at.slice(0, 10))}: ${m.reason}`,
85 ),
86 };
87 }
88
89 export function filePage(input: { who: Who; agent?: Agent | undefined; waiting?: number | undefined; deal: DealView }): string {
90 const { who, deal } = input;
91 const agent = input.agent ?? defaults;
92 const path = `/deals/${deal.id}/file`;
93 const r = fileRecord(deal);
94 const list = (items: string): string => (items === "" ? `<p>None.</p>` : `<ul class="file-list">${items}</ul>`);
95 const body = `<p class="crumb file-tools"><a href="/deals/${deal.id}">← Back to the deal</a> · <button type="button" class="button button-small" data-print hidden>Print</button> <span class="muted">or your browser's print (Ctrl/Cmd+P)</span></p>
96 <section class="file">
97 <h1>${escape(deal.address)}</h1>
98 <p class="summary">Broker file, prepared by ${escape(agent.name)}, ${escape(agent.brokerage)}</p>
99 <dl class="file-facts">${r.facts.map(([k, v]) => `<div><dt>${escape(k)}</dt><dd>${escape(v)}</dd></div>`).join("")}</dl>
100 <h2>Parties</h2>${list(r.parties.map((p) => `<li>${escape(p)}</li>`).join(""))}
101 <h2>Dates</h2><ol class="file-list">${r.dates.map((d) => `<li>${escape(d.line)}${d.moves.map((m) => `<br><span class="file-move">${escape(m)}</span>`).join("")}</li>`).join("")}</ol>
102 <h2>Messages approved</h2>${list(r.sent.map((m) => `<li>${escape(m.head)}${m.subject === "" ? `<p>The words were not kept for this one.</p>` : `<p><b>${escape(m.subject)}</b></p><p class="file-words">${escape(m.body)}</p>`}</li>`).join(""))}
103 <h2>Messages declined</h2>${list(r.declined.map((d) => `<li>${escape(d)}</li>`).join(""))}
104 </section>
105 <script src="${asset("print.js")}"></script>`;
106 return layout({ body, who, agent, waiting: input.waiting, path, heading: `Broker file · ${deal.address}`, plain: true, bodyClass: "file-page" });
107 }
src/routes.ts +23 −16
@@ -102,6 +102,7 @@ import { peoplePage } from "./pages/people.ts";
102102 import { activityPage } from "./pages/activity.ts";
103103 import { ACTIVITY_PAGE, addresses } from "./activity.ts";
104104 import { weekPage } from "./pages/week.ts";
105 import { filePage } from "./pages/file.ts";
105106 import { timelinePage } from "./pages/timeline.ts";
106107 import { welcomePage } from "./pages/welcome.ts";
107108 import { dueOn, remindsLine, todaysDrafts, unsent, waitingCount, type Agent, type Draft } from "./reminders.ts";
@@ -460,6 +461,17 @@ const STATUS: Record<Failure, number> = {
460461 const missingDeal = (c: Context) =>
461462 html(missingPage({ who: c.who, waiting: waitingFor(c), path: c.url.pathname, deal: true }), 404);
462463
464 /** The deal a page under `/deals/:id` shows, read through `permit`; else the response that refuses or says it is missing. */
465 function dealOrRefusal(c: Context): DealView | Response {
466 const found = getDeal(c.db, c.who, { id: Number(c.params.id) });
467 if (found.ok) return found.value;
468 if (found.error !== "signin_required" && found.error !== "forbidden") return missingDeal(c);
469 return html(
470 refusedPage({ who: c.who, agent: agentFor(c), path: c.url.pathname, heading: "A deal", error: found.error, message: found.message }),
471 STATUS[found.error],
472 );
473 }
474
463475 /** Whether a client wants JSON: anything under the API, or an `accept` that asks for it. */
464476 const wantsJson = (request: Request, url: URL): boolean =>
465477 url.pathname === "/api" ||
@@ -841,22 +853,17 @@ export const routes: readonly Route[] = [
841853 method: "GET",
842854 path: "/deals/:id/timeline",
843855 handle: (c) => {
844 const found = getDeal(c.db, c.who, { id: Number(c.params.id) });
845 if (!found.ok && found.error !== "signin_required" && found.error !== "forbidden")
846 return missingDeal(c);
847 if (!found.ok)
848 return html(
849 refusedPage({
850 who: c.who,
851 agent: agentFor(c),
852 path: c.url.pathname,
853 heading: "A deal",
854 error: found.error,
855 message: found.message,
856 }),
857 STATUS[found.error],
858 );
859 return html(timelinePage({ who: c.who, waiting: waitingFor(c), agent: agentFor(c), deal: found.value, on: today() }));
856 const found = dealOrRefusal(c);
857 return found instanceof Response ? found : html(timelinePage({ who: c.who, waiting: waitingFor(c), agent: agentFor(c), deal: found, on: today() }));
858 },
859 },
860 {
861 method: "GET",
862 path: "/deals/:id/file",
863 // The broker file: read as `deal` is read, and never the client's page.
864 handle: (c) => {
865 const found = dealOrRefusal(c);
866 return found instanceof Response ? found : html(filePage({ who: c.who, waiting: waitingFor(c), agent: agentFor(c), deal: found }));
860867 },
861868 },
862869 {
src/speed.test.ts +1
@@ -110,6 +110,7 @@ const routes: [string, () => string][] = [
110110 ["the deal list", () => "/api/deals"],
111111 ["a deal page", () => `/deals/${firstId}`],
112112 ["the client timeline", () => `/deals/${firstId}/timeline`],
113 ["the broker file", () => `/deals/${firstId}/file`],
113114 ["the printed week", () => "/week"],
114115 ["the reminder review", () => "/reminders/today"],
115116 ];
src/terminal.ts +27 −5
@@ -8,6 +8,7 @@
88 * reminders what goes out today; enter reads a draft, e edits its words, s sends it; h holds it until tomorrow, H lists the held ones and B brings one back
99 * people each person on the deals with every open date they owe (P)
1010 * timeline a deal's dates as a client would get them (t on a deal)
11 * file a deal's broker file: figures, parties, every date and message (f on a deal)
1112 * activity who approved, declined or changed what, newest first (L, admins); m only messages, o older, y newer
1213 * profile your name, brokerage, phone, email and own line (I); e edits them, U goes back to the defaults
1314 * deal one deal's dates and parties; a adds a date, p a party, A corrects the address, C sets the closing time and place, M amends the contract, S drafts a status update for the party under the cursor, D removes it, F marks it fell through (or brings it back), Y changes the side (buyer, listing or both)
@@ -23,6 +24,7 @@ import type { Database } from "bun:sqlite";
2324 import { bookLine, tally } from "./book.ts";
2425 import { closingLine } from "./closing.ts";
2526 import { timelineRows } from "./timeline.ts";
27 import { fileRecord } from "./pages/file.ts";
2628 import { isDate, relative, spoken, today, urgencyOf, type Urgency } from "./dates.ts";
2729 import {
2830 addDeadline,
@@ -88,7 +90,7 @@ const ACTIVITY_ROWS = 20;
8890 const COLOUR: Readonly<Record<Urgency, string>> = { overdue: "31", soon: "33", later: "36", done: "2", waived: "2" };
8991 const tint = (u: Urgency, s: string): string => `${esc}${COLOUR[u]}m${s}${esc}0m`;
9092
91 type View = "dates" | "week" | "people" | "reminders" | "deal" | "messages" | "timeline" | "profile" | "activity";
93 type View = "dates" | "week" | "people" | "reminders" | "deal" | "messages" | "timeline" | "file" | "profile" | "activity";
9294 interface Row {
9395 readonly deal: DealView;
9496 readonly date: DeadlineView;
@@ -562,7 +564,7 @@ export function terminal(
562564 }
563565 if (key === "j") cursor = Math.min(cursor + 1, Math.max(0, rowCount() - 1));
564566 else if (key === "k") cursor = Math.max(cursor - 1, 0);
565 else if ((view === "messages" || view === "timeline") && (key === "b" || key === "\x1b")) {
567 else if ((view === "messages" || view === "timeline" || view === "file") && (key === "b" || key === "\x1b")) {
566568 view = "deal";
567569 cursor = 0;
568570 reading = undefined;
@@ -570,6 +572,9 @@ export function terminal(
570572 else if (view === "deal" && key === "t") {
571573 view = "timeline";
572574 cursor = 0;
575 } else if (view === "deal" && key === "f") {
576 view = "file";
577 cursor = 0;
573578 } else if (view === "deal" && key === "s") {
574579 view = "messages";
575580 cursor = 0;
@@ -670,7 +675,7 @@ export function terminal(
670675 } else if (view === "reminders") onReminder(key);
671676 else if (view === "profile") onProfile(key);
672677 else if (view === "activity") onActivity(key);
673 else if (view === "messages" || view === "timeline") return;
678 else if (view === "messages" || view === "timeline" || view === "file") return;
674679 else if (!(view === "deal" && onDeal(key))) onDate(key);
675680 cursor = Math.min(cursor, Math.max(0, rowCount() - 1));
676681 }
@@ -807,6 +812,23 @@ export function terminal(
807812 r.todo.forEach((g) => lines.push(` ${dim(`${g.label === "" ? "" : `${g.label}: `}${g.line}`)}`));
808813 });
809814 }
815 } else if (view === "file") {
816 const deal = openDeal();
817 if (deal === undefined) lines.push(dim("That deal is gone."));
818 else {
819 const r = fileRecord(deal);
820 lines.push(bold(`Broker file — ${deal.address}`), dim(`${agentNow().name}, ${agentNow().brokerage}`), "");
821 r.facts.forEach(([k, v]) => lines.push(` ${k.padEnd(22)} ${v}`));
822 lines.push("", bold("Parties"), ...r.parties.map((p) => ` ${p}`));
823 lines.push("", bold("Dates"));
824 r.dates.forEach((d) => lines.push(` ${d.line}`, ...d.moves.map((m) => dim(` ${m}`))));
825 lines.push("", bold("Messages approved"));
826 if (r.sent.length === 0) lines.push(" None.");
827 r.sent.forEach((m) => lines.push(` ${m.head}`, ...(m.subject === "" ? [dim(" (words not kept)")] : [` ${m.subject}`, ...m.body.split("\n").map((l) => ` ${l}`)])));
828 lines.push("", bold("Messages declined"));
829 if (r.declined.length === 0) lines.push(" None.");
830 r.declined.forEach((d) => lines.push(` ${d}`));
831 }
810832 } else if (view === "deal") {
811833 const deal = openDeal();
812834 if (deal === undefined) lines.push(dim("That deal is gone."));
@@ -854,10 +876,10 @@ export function terminal(
854876 : "j/k move · enter read · e edit · s send · n don't send · h tomorrow · u undo · H held · / find · d dates · q quit"
855877 : view === "messages"
856878 ? "j/k move · enter read · b back to the deal · d dates · q quit"
857 : view === "timeline"
879 : view === "timeline" || view === "file"
858880 ? "b back to the deal · d dates · q quit"
859881 : view === "deal"
860 ? "j/k move · t client timeline · s messages · x done · W waive · u reopen/un-waive · m move · N next business day · l remind lead · T note · a add date · p add party · e edit party · A edit address · C closing time and place · M amend the contract · S status update to the party · X remove date/party · D remove deal · b back · q quit"
882 ? "j/k move · t client timeline · f broker file · s messages · x done · W waive · u reopen/un-waive · m move · N next business day · l remind lead · T note · a add date · p add party · e edit party · A edit address · C closing time and place · M amend the contract · S status update to the party · X remove date/party · D remove deal · b back · q quit"
861883 : `j/k move · x done · W waive · u reopen · m move · N next business day · l lead · T note · 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 · L activity · q quit`;
862884 lines.push(dim(me.role === "anon" ? `${keys} · sign in with a key the forge knows to change anything` : keys));
863885 }
src/timeline.test.ts +2 −2
@@ -56,7 +56,7 @@ test("has no forms, scripts, contacts or removed dates, and escapes the address"
5656
5757 test("the print rules are scoped to the timeline page", async () => {
5858 const css = await Bun.file(join(import.meta.dir, "..", "static", "app.css")).text();
59 const print = css.slice(css.indexOf("@media print"));
59 const print = css.slice(css.indexOf("@media print"), css.indexOf("/* The broker file"));
6060 const selectors = [...print.matchAll(/^\s*([^{}@\n]+)\{/gm)].map((m) => m[1]!.trim());
6161 expect(selectors.length).toBeGreaterThan(0);
6262 for (const sel of selectors) for (const part of sel.split(",")) expect(part.trim()).toStartWith(".timeline-page");
@@ -89,7 +89,7 @@ test("offers Print from a static script, with no inline script or handler", asyn
8989 const js = await Bun.file(join(import.meta.dir, "..", "static", "print.js")).text();
9090 expect(js).toContain("window.print()");
9191 const css = await Bun.file(join(import.meta.dir, "..", "static", "app.css")).text();
92 const print = css.slice(css.indexOf("@media print"));
92 const print = css.slice(css.indexOf("@media print"), css.indexOf("/* The broker file"));
9393 expect(print).toContain("break-inside: avoid");
9494 expect(print).toContain(".timeline-tools");
9595 expect(print).toContain(".toast");
static/app.css +47
@@ -1028,3 +1028,50 @@ a.marker {
10281028 margin: 15mm;
10291029 }
10301030 }
1031
1032 /* The broker file: plain figures and lists on the screen; on paper, black on white with no tools. */
1033 .file-facts {
1034 display: grid;
1035 grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
1036 gap: var(--space-2);
1037 margin: var(--space-3) 0;
1038 }
1039 .file-facts dt {
1040 font-weight: 600;
1041 }
1042 .file-facts dd {
1043 margin: 0;
1044 }
1045 .file-list {
1046 padding-inline-start: var(--space-3);
1047 }
1048 .file-list li {
1049 margin-bottom: var(--space-2);
1050 }
1051 .file-words {
1052 white-space: pre-wrap;
1053 }
1054 @media print {
1055 .file-page {
1056 background: white;
1057 color: black;
1058 font-size: 10pt;
1059 }
1060 .file-page .head,
1061 .file-page footer,
1062 .file-page .file-tools,
1063 .file-page .toast {
1064 display: none;
1065 }
1066 .file-page .page {
1067 max-width: none;
1068 padding: 0;
1069 }
1070 .file-page .file-list li {
1071 break-inside: avoid;
1072 }
1073 .file-page h2 {
1074 break-after: avoid;
1075 font-size: 1rem;
1076 }
1077 }

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs