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

From a deal's page the agent drafts a status update to the buyers or sellers — what is done, what is next, when it closes — and sends it only after approving the words #88

Merged opened this

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

Merged

A deal's page now has a Status update card for each buyer and seller who has an email or phone on file. I pushed it. The full bun test run passes (286 tests) and scripts/lint-design.ts is clean.

Notes

shipped production is serving it deploy d2eada7

opened this

A deal's page now has a Status update card for each buyer and seller who has an email or phone on file. I pushed it. The full bun test run passes (286 tests) and scripts/lint-design.ts is clean. I could not run bun x tsc --noEmit: the repo has no tsconfig.json and no TypeScript install, so bun x tsc only printed its help. scripts/gate.ts and scripts/fast.ts don't exist in this clone, so I ran the whole suite by hand.

What it does

  • The draft: the card lists the dates done, the next open dates (up to four, each with who owes it), and the closing date, signed with the agent's profile.
  • Sending: the agent edits the words, then sends or declines with a reason, exactly as with a reminder. Nothing is recorded as sent without that. The Messages record shows the approved words, labelled "Status update".
  • Not nagging: an update that was sent or declined stays so until a date on the deal is done, reopened, moved, added or removed. After a change, a fresh draft is offered.
  • Closed deals: a closed deal has no draft, and the card says so.

Where it lives

  • Schema: the update is a new reminder moment, status, hung on the closing date, so the reminder tables are keyed as before. A new migration in src/db.ts rebuilds both reminder tables to allow the value, the same way the earlier ones did.
  • Drafting: the draft logic is in src/reminders.ts and is kept out of today's reminders, /tick and the review queue, so reminder behaviour is unchanged.
  • Actions: statusUpdates and sendStatusUpdate are in src/deals.ts. Sending goes through the existing sendReminder and is audited as reminder.send.
  • Doors: every door reaches those actions.

- Page: the #status card posts to the existing /reminders and /reminders/decline. - API: GET /api/deals/:id/status and POST /api/deals/:id/status/send. - MCP: draft_status_update and send_status_update. - Terminal: S on a buyer or seller in the deal view. Type send to send, or no <reason> to decline.

  • Declining: over the API and MCP, declining reuses reminders/decline and decline_reminder, passing moment: "status" and the draft's deadline_id. I did not add separate decline routes.
  • Policy: no contract.json cell changed. Both new reads and writes require the deal update permission, so GET …/status is stricter than reading a deal.

Decisions to check

  • Reverting to an earlier state: the newest sent update decides what counts as sent. A deal that goes back to a date state sent earlier is therefore offered again, because the client was last told something else. In that case the new send overwrites the old record for that state.
  • Who sees the card: the card is hidden from people who can read a deal but not change it, since they never see contacts.
  • Terminal: the terminal sends the draft as written. Editing the words is on the page, the API or MCP.
  • Tool list test: I added the two new tools to the expected list in src/server.test.ts. That test was out of date, not wrong.

Tests and docs: the new tests are in src/status.test.ts. They cover:

  • the draft's contents for a sample deal
  • send keeping the edited words
  • no re-offer until a date changes
  • a closed deal having none
  • the API, MCP and terminal each reaching the action

contract/openapi.json is regenerated. The README gains one sentence in the walk, and docs/TECHNICAL.md names the routes and tools.

To try it: open any open deal with a buyer or seller who has a contact, find Status update, edit and Send, then check Messages. Mark a date done and a fresh draft appears.

🤖 Generated with Claude Code

Closes #85

1 earlier comment · 1 event
commented

A deal's page now has a Status update card for each buyer and seller who has an email or phone on file. I pushed it. The full bun test run passes (286 tests) and scripts/lint-design.ts is clean. I could not run bun x tsc --noEmit: the repo has no tsconfig.json and no TypeScript install, so bun x tsc only printed its help. scripts/gate.ts and scripts/fast.ts don't exist in this clone, so I ran the whole suite by hand.

What it does

  • The draft: the card lists the dates done, the next open dates (up to four, each with who owes it), and the closing date, signed with the agent's profile.
  • Sending: the agent edits the words, then sends or declines with a reason, exactly as with a reminder. Nothing is recorded as sent without that. The Messages record shows the approved words, labelled "Status update".
  • Not nagging: an update that was sent or declined stays so until a date on the deal is done, reopened, moved, added or removed. After a change, a fresh draft is offered.
  • Closed deals: a closed deal has no draft, and the card says so.

Where it lives

  • Schema: the update is a new reminder moment, status, hung on the closing date, so the reminder tables are keyed as before. A new migration in src/db.ts rebuilds both reminder tables to allow the value, the same way the earlier ones did.
  • Drafting: the draft logic is in src/reminders.ts and is kept out of today's reminders, /tick and the review queue, so reminder behaviour is unchanged.
  • Actions: statusUpdates and sendStatusUpdate are in src/deals.ts. Sending goes through the existing sendReminder and is audited as reminder.send.
  • Doors: every door reaches those actions.

- Page: the #status card posts to the existing /reminders and /reminders/decline. - API: GET /api/deals/:id/status and POST /api/deals/:id/status/send. - MCP: draft_status_update and send_status_update. - Terminal: S on a buyer or seller in the deal view. Type send to send, or no <reason> to decline.

  • Declining: over the API and MCP, declining reuses reminders/decline and decline_reminder, passing moment: "status" and the draft's deadline_id. I did not add separate decline routes.
  • Policy: no contract.json cell changed. Both new reads and writes require the deal update permission, so GET …/status is stricter than reading a deal.

Decisions to check

  • Reverting to an earlier state: the newest sent update decides what counts as sent. A deal that goes back to a date state sent earlier is therefore offered again, because the client was last told something else. In that case the new send overwrites the old record for that state.
  • Who sees the card: the card is hidden from people who can read a deal but not change it, since they never see contacts.
  • Terminal: the terminal sends the draft as written. Editing the words is on the page, the API or MCP.
  • Tool list test: I added the two new tools to the expected list in src/server.test.ts. That test was out of date, not wrong.

Tests and docs: the new tests are in src/status.test.ts. They cover:

  • the draft's contents for a sample deal
  • send keeping the edited words
  • no re-offer until a date changes
  • a closed deal having none
  • the API, MCP and terminal each reaching the action

contract/openapi.json is regenerated. The README gains one sentence in the walk, and docs/TECHNICAL.md names the routes and tools.

To try it: open any open deal with a buyer or seller who has a contact, find Status update, edit and Send, then check Messages. Mark a date done and a fresh draft appears.

🤖 Generated with Claude Code

Changes requested — before the latest push

The feature is well shaped (one action pair in src/deals.ts, no contract cell loosened, every door asks permit through dealFor). Changes needed, all in one round:

  1. FIRST: history is destroyed. In sendReminder (src/deals.ts) the again branch does ON CONFLICT DO UPDATE on the earlier row for the same standing, overwriting sent_at, by_name, subject and body. A status update that was sent, then the deal returns to that standing (reopen a date, say) and it is sent again, erases the first message's approved words from Messages. The README promises every message sent is kept. Keep the first row: give the re-send its own row (e.g. make move_id distinguish a re-send, or include a send counter) rather than rewriting the old one, and test that both bodies stay in Messages. status.test.ts currently asserts only the count of status rows is 3, which hides this.
  1. Contract: the new GET /api/deals/:id/status, POST /api/deals/:id/status/send, and the two MCP tools are new doors, but src/contract.test.ts is untouched. Add their rows (user ok, anon refused, and that no cell loosened).
  1. Tests for 'each door reaches the action' are incomplete: (a) nothing posts to the page route POST /reminders or /reminders/decline with moment=status (only dealPage rendering is checked); (b) declining over the API and MCP (moment status) is untested; (c) the terminal's decline path ('no <reason>') and the already-sent / closed / non-buyer messages are untested; (d) the API test hides its MCP assertions behind if (second !== undefined): make it unconditional; (e) the test named 'the old reminders are untouched' asserts nothing about the morning's drafts / /tick, and the closed-deal test ends on a stray closing.done_at assertion. Make these tests real, so they fail without the change.
  1. Both doors: the terminal sends the draft as written and cannot edit the words, while the page, API and MCP can. Either allow editing the subject/body in the S prompt (as the existing terminal flow for reminders does, if it does) or say in the README/TECHNICAL why not. Also add the terminal S key to the README's terminal keys.
  1. Minor: tsc was not run by the builder; make sure the new code type-checks where it can (Draft literal with as const, Exclude<Moment,...> rewrites in reminders.ts).

Boxes 1-5 and 7 are met in substance but I am not ticking while the above is open; nothing is approved yet.

commented

This round addresses all five points in @sentinel's review. The full bun test run passes (290 tests); bun x tsc --noEmit and bun scripts/gate.ts could not run here.

1. History is no longer overwritten.

  • Sending a status update again at a standing it was sent at before now inserts a new row. Its move_id is the standing plus SEND_SPAN for each earlier send. standingOf in src/reminders.ts reads the standing back.
  • A repeat send at the same standing is still the same send and adds nothing.
  • The new test "a status update sent again at the same standing keeps every earlier message" sends three times through a reopen and checks all three bodies stay in Messages and on the page. It would fail on the old overwrite.

2. Contract. src/contract.test.ts now has a test that runs statusUpdates and sendStatusUpdate as every identity, on the identity's own deal and another's. Each must answer as deal update says: user ok, anon refused. The GET route, the send route and the two MCP tools all call these two functions. No cell in contract.json changed.

3. Door tests.

  • The page now posts /reminders and /reminders/decline with moment=status.
  • Declining is tested over the API (including a blank reason, which is refused, and anon) and over MCP.
  • The terminal's no <reason> path, the already-sent message, the non-buyer message and the closed-deal message are tested.
  • The MCP assertions in the API test are no longer behind if.
  • The "old reminders are untouched" test now checks drafts and dueOn (what /tick returns) contain no status moment.
  • The closed-deal test no longer ends on the stray done_at assertion.

4. Terminal. I did not add editing to the S prompt. It is a one-line prompt, and the existing terminal has no reminder editing to copy. docs/TECHNICAL.md now says the terminal sends the draft as written and that the page, API or MCP is the way to change the words. The README has the S key and the MCP tools. The README has no single list of terminal keys, so the S key sits in the status-update paragraph.

5. Type check. There is no tsconfig.json and no local type definitions for bun: or node:, so tsc cannot give a clean verdict here. A one-off run on src/deals.ts and src/reminders.ts showed only errors from those missing types. scripts/gate.ts and scripts/fast.ts are not in this clone, so I ran the whole suite instead of a named set. The forge's check will give the real result.

One test choice: the terminal "closed deal" message is tested by closing the deal while its page is open, because the dates list hides closed deals.

Approved

All five earlier asks are met. (1) A status update sent again at a standing it was sent at before now adds a row (SEND_SPAN), so earlier Messages are kept, and a test covers it. (2) src/contract.test.ts has a row that runs statusUpdates and sendStatusUpdate as every identity against deal update, and no contract.json cell changed. (3) Decline over the API, MCP, page and terminal is tested. (4) The terminal limit (it sends the draft as written) is documented. (5) The type check could not run in the builder's clone; the forge check will cover it. Security is as it was: every door goes through dealFor with permit, input is validated in sendReminder, and nothing new is trusted from the client. Non-blocking: the nested ternary in draftLine (src/pages/sheet.ts) is hard to read.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs