Public: anyone can read this; the crew can change it.
Pressed Send by mistake? For one minute after, one tap takes it back to a draft #91
Merged 26d 23h ago, live in production
For 60 seconds after a message is approved, the lead's page shows Undo send beside it, and one tap puts the message and the lead back as they were. The new tests pass, as do the star, db and openapi tests.
-
Reviews
Changes requested — before the latest pushThe undo itself is well built. It snapshots the lead, restores it whole, uses server time, is a same-origin POST that goes through
permit, and is audited. It loosens no cell. One thing blocks it.Fix first: the terminal is missing (both doors). The review list says anything a person can do on the page they can do in
src/tty.tstoo. The README says outright that "MCP and the terminal do not have it". Add an undo command tosrc/tty.tsthat callsundoSendwith the terminal'swho, so it goes throughpermitand the audit like the page. It must emitlead.changedso web viewers update live. Add a test for it, and change the README sentence to say the terminal has it. Say in the README whether MCP has it. The list has no exception for leaving a door out on purpose.Smaller points to fix in the same round:
reply()insrc/actions.tsrunscapture, the send andkeepas separate statements. Wrap them in one transaction so a failure between them cannot leave a send with no way back, or a stale snapshot.src/star.test.tsnow pins the migration at> 0. Pin it to the migration's real position, or check that the star migration comes before the undo table, so the test can still fail.- Mason did not run
tsc. Runbun x tsc --noEmitand say what happened.
I did not open the preview for this review; this comes from reading the diff.
ApprovedEarlier asks are met: undo is on the terminal (z, gated by permit and audited), MCP (undo_send) is added, capture, send and keep run in one transaction, and the MCP tool list test is fixed. The preview answers 200. I could not diff against f06971d894ee because the commit is not in the clone, so I read the full change. No contract.json cell is loosened. The route is a same-origin POST through permit, with anon refused. The undo is audited as unsent. Tests cover restore, expiry, anon, audit, resend without duplicates, held texts, terminal and MCP. Non-blocking: the Activity filter for messages sent still omits undos.
-
Checks
shipped production is serving it deploy 231a7fb
-
History
- The MCP tool list in the server test names undo_send f617600
- Undo send reaches the terminal (z) and MCP (undo_send); the send and its way back share one transaction fec4f62
- Undo send: for one minute after a message is approved, one tap puts the message and the lead back as they were f06971d
- When a lead's last follow-up has gone out with no answer, the desk says so and one tap marks them lost (never answered) (#88) eac5100
- The agent stars the leads they want to keep close, and starred leads lead the desk (#87) 42ab7a5
- After an open house, paste the sign-in sheet and every visitor lands on the desk with a thank-you draft naming the house (#84) 3816539
- The agent keeps a few saved replies (lender intro, open-house details) and drops one into any draft before approving it (#83) 25511d4
- A lead who says "not until spring" can be put away until a date: follow-ups stop, and that morning a check-in draft waits on the desk (#80) 910bc7b
- The day before a showing, a "see you tomorrow" confirmation naming the time and address waits on the desk for the agent to approve (#79) b8e67ea
- The desk lists the agent's upcoming showings in time order, each linked to its lead (#76) 17f2de3
- The agent chooses the days their follow-ups go out (default 1, 3, 7, 14, 30) from their profile, and new leads follow it (#75) 83f4956
- The desk and a lead's page work on a phone: no sideways scroll, readable text, buttons a thumb can hit (#72) e567413
- The morning after a showing, a "how did you like it?" follow-up naming the address waits on the desk for the agent to approve (#71) c2a92b7
- Times on the lead page and the Activity page read in the agent's time zone, not the server's (#67) 8003750
- Showings are booked and shown in the agent's own time zone, not UTC (#66) c2f5a23
- The browser tab says how many leads are waiting on the agent, and a lead's page is titled with the lead's name (#63) efeafb7
- Mark a lead lost with a reason (bought with another agent, not ready, never answered) and the desk counts why leads are lost (#61) 3cdba72
- An approved message opens ready to send in the agent's own Mail or Messages app, from the lead's page (#62) 7b27035
- Realtor.com is its own lead source: its leads get their own opener, their own row in the response record, and a sample lead (#57) 77ce7d2
- Skip one upcoming follow-up on a lead, or bring it back, from the lead's page (#54) 6e5036e
3 earlier comments
For 60 seconds after a message is approved, the lead's page shows Undo send beside it, and one tap puts the message and the lead back as they were. The new tests pass, as do the star, db and openapi tests. In the last full run of the src/ tests, src/live.test.ts ("a write from another process on the same file reaches the bus") failed, and it fails the same way without my changes. I could not run a TypeScript check, because the repo has no tsconfig.json. scripts/gate.ts does not exist here. bun scripts/lint-design.ts printed nothing, which I took as clean.
What changed
- Snapshot: each approval keeps a snapshot of the lead's state,
replied_atandback_on, plus all its messages as they stood just before. It is stored in a newundo_sendtable, kept to one row per lead. The logic is insrc/undo.ts, called fromreply()insrc/actions.ts. - Undo: the message returns to a draft with the words as sent. The lead's state and clock go back, so a first reply undone leaves the lead new with its clock running and out of the response record. Follow-ups the send created are deleted, so sending again does not duplicate them.
- Route:
POST /leads/:id/undogoes through the same-origin check andpermitas an update of the lead. Anon gets 401. - Window: the 60 seconds are measured on the server's clock. After that, or when there is nothing to undo, the route answers 409 with a plain sentence.
- Page: the button shows in the history entry of the message just sent, and in the held-text pane. The "desk confirmation after approving" is this same lead page: the approval redirects there with "Sent."
- Held texts: undo applies to them within the minute of approval, restoring the pre-approval state.
- Audit: the send was already recorded. The undo is a new
unsentrow, shown on Activity as "took back the message to … (undo send)", with who and when. - README: a new "Undo send" paragraph sits next to Quiet hours.
- Contract:
contract/openapi.jsonis regenerated, since the route added an entry. - Tests:
src/undo.test.tscovers undo restoring draft, state and clock, the refusal after the minute, anon refused, both audit rows, resend without duplicate follow-ups, held texts, the page button, and the route over HTTP including a cross-site POST.
Choices
- Changed since the send: if the lead's
updated_atchanged after the send, undo answers 409 rather than overwriting the newer change. This also covers a held text that has already gone out at 8:00. - Star test:
src/star.test.tsasserted that its migration was the last one. I loosened that to> 0because the new table migration comes after it. The test was wrong to pin the order; its behaviour check is unchanged.
Not done
- Undo is not in the MCP tools or the terminal, only the page and the JSON route.
- The "Messages sent only" filter on Activity still shows only sends, not undos.
- No
contract.jsoncell was loosened.
To try it: approve a reply on a lead and press Undo send on the lead page within a minute.
🤖 Generated with Claude Code
I've fixed all four review points and pushed; tsc still can't run here, as explained under the last point. The new and touched tests pass: src/undo.test.ts, src/star.test.ts, src/terminal.test.ts, src/contract.test.ts, src/quiet.test.ts and src/openapi.test.ts. I did not re-run the whole src/ suite after this round.
- Terminal: pressing
zon a lead now callsundoSendwith the terminal'swho, so it goes throughpermitand the audit like the page, and it emitslead.changed. The hint "z undo send (for a minute)" shows only while the minute lasts. After the minute the key does nothing. A new test covers the key, the audit row and the expired case. - Terminal file: the review said
src/tty.ts, but the terminal's commands are insrc/terminal.ts;tty.tsis only a 36-line launcher. I made the change insrc/terminal.ts. - MCP: I added an
undo_sendtool as well, so no door is left out. A test covers it, and the README now says the page, the JSON door, MCP (undo_send) and the terminal all have undo. - Transaction:
capture, the send (or hold) andkeepnow run in onedb.transactioninreply(), so a failure rolls all three back together. - Star test: it still asserts the starred migration's position is greater than 0. It now also asserts that the
undo_sendmigration comes after it, so it can still fail. I did not pin an exact index, since every later migration would break it. tsc:bun x tsc --noEmitdoes not type-check this repo. There is notsconfig.jsonand notypescriptdependency, so it resolves to an unrelated package and prints its help text. I did not add a config or a dependency just to get a check. The Bun test run still loads every changed file.
🤖 Generated with Claude Code
The preview's one failing test was my miss, and it's fixed and pushed. src/server.test.ts lists every MCP tool by name, and I had added undo_send last round without adding it to that list. I added it. src/server.test.ts now passes (37 passed, 0 failed). I did not re-run the full suite.
This is the same pull as before: the Undo send button on the lead page, the POST /leads/:id/undo route, z in the terminal and the undo_send MCP tool. Nothing else changed this round.
🤖 Generated with Claude Code
Left #74 open: 1 unticked item remain (For 60 seconds after a message is marked sent, the lead's page (and the desk's confirmation after approving) shows "Undo send" beside it. Pressing it returns the message to a draft with its words as sent, and the lead's clock and state go back to what they were before the send (a first reply undone leaves the lead new and its clock running again).).
For 60 seconds after a message is approved, the lead's page shows Undo send beside it, and one tap puts the message and the lead back as they were. The new tests pass, as do the star, db and openapi tests. In the last full run of the
src/tests,src/live.test.ts("a write from another process on the same file reaches the bus") failed, and it fails the same way without my changes. I could not run a TypeScript check, because the repo has notsconfig.json.scripts/gate.tsdoes not exist here.bun scripts/lint-design.tsprinted nothing, which I took as clean.What changed
replied_atandback_on, plus all its messages as they stood just before. It is stored in a newundo_sendtable, kept to one row per lead. The logic is insrc/undo.ts, called fromreply()insrc/actions.ts.POST /leads/:id/undogoes through the same-origin check andpermitas an update of the lead. Anon gets 401.unsentrow, shown on Activity as "took back the message to … (undo send)", with who and when.contract/openapi.jsonis regenerated, since the route added an entry.src/undo.test.tscovers undo restoring draft, state and clock, the refusal after the minute, anon refused, both audit rows, resend without duplicate follow-ups, held texts, the page button, and the route over HTTP including a cross-site POST.Choices
updated_atchanged after the send, undo answers 409 rather than overwriting the newer change. This also covers a held text that has already gone out at 8:00.src/star.test.tsasserted that its migration was the last one. I loosened that to> 0because the new table migration comes after it. The test was wrong to pin the order; its behaviour check is unchanged.Not done
contract.jsoncell was loosened.To try it: approve a reply on a lead and press Undo send on the lead page within a minute.
🤖 Generated with Claude Code
Closes #74