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

A sent reminder opens in the agent's own Mail or Messages app with the approved words filled in, so Send really reaches the party #65

Merged opened this

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

Merged

After Send, the notice, the sheet and the deal page's Messages record each offer one link built from the approved words. The app sends nothing itself, and nothing opens the link by script.

Notes

shipped production is serving it deploy d2eada7

opened this

After Send, the notice, the sheet and the deal page's Messages record each offer one link built from the approved words. The app sends nothing itself, and nothing opens the link by script.

Tests: bun test ends with one failure, "a moved date's Date changed notice is sent, declined and undone through the routes and MCP…". It fails identically on the base branch without my changes, so I left it alone. bun run lint:design is clean. The repo has no tsconfig, so tsc --noEmit only prints its help text, and I did not run a typecheck. scripts/gate.ts and scripts/fast.ts don't exist here.

What changed

  • Link builder: the new src/outbox.ts has one pure function, outbox(contact, subject, body). An email (validEmail) gives Open in Mail, a mailto: link with the subject and body percent-encoded. A phone (validPhone) gives Open in Messages, an sms: link with the body. Anything else gives null, and a contact containing " or javascript: fails both checks. Its test covers email, phone, missing contact, " and javascript:, and a body with &, #, newlines and non-ASCII that round-trips through decodeURIComponent.
  • Notice and Messages: after Send, the notice reads "Reminder sent." with the link. If the party has no email or phone, it says "No email or phone on file" instead. The sheet and the Messages record show the same link or text, with the href attribute-escaped. A reader who can't change the deal sees neither the link nor the text. The notice finds the sent reminder by its id, carried in the existing notice cookie, so no message body goes into a cookie.
  • API and MCP: each sent[] entry carries href (null when there is no link), and so does send_reminder's answer. The OpenAPI file is regenerated.
  • Terminal: Send now says "Recorded as sent to … Send it from your phone to <address>." and the terminal test is updated to match. I did not add a link line to the terminal's Messages view.
  • Wording: the footer, the clock's reminders note, the MCP tool description, README step 4 and docs/TECHNICAL.md now say Send records the approval and opens your own Mail or Messages. Nothing is sent by the app itself.

Choices

  • The link uses the party's contact as it stands now, not when the reminder was sent. If the party has been removed, the old Messages entry shows "No email or phone on file", because the app doesn't keep the contact on the sent row.
  • I changed no policy cell and added no dependency.
  • #57 and #58 also edit src/pages/sheet.ts; I did not rebase against them.

To try it: in a preview, give a party an email or phone, open a date's sheet, tap Send, then tap the link in the notice. The same link is on the sheet and in the deal's Messages record.

Closes #62

3 earlier comments · 1 event
commented

After Send, the notice, the sheet and the deal page's Messages record each offer one link built from the approved words. The app sends nothing itself, and nothing opens the link by script.

Tests: bun test ends with one failure, "a moved date's Date changed notice is sent, declined and undone through the routes and MCP…". It fails identically on the base branch without my changes, so I left it alone. bun run lint:design is clean. The repo has no tsconfig, so tsc --noEmit only prints its help text, and I did not run a typecheck. scripts/gate.ts and scripts/fast.ts don't exist here.

What changed

  • Link builder: the new src/outbox.ts has one pure function, outbox(contact, subject, body). An email (validEmail) gives Open in Mail, a mailto: link with the subject and body percent-encoded. A phone (validPhone) gives Open in Messages, an sms: link with the body. Anything else gives null, and a contact containing " or javascript: fails both checks. Its test covers email, phone, missing contact, " and javascript:, and a body with &, #, newlines and non-ASCII that round-trips through decodeURIComponent.
  • Notice and Messages: after Send, the notice reads "Reminder sent." with the link. If the party has no email or phone, it says "No email or phone on file" instead. The sheet and the Messages record show the same link or text, with the href attribute-escaped. A reader who can't change the deal sees neither the link nor the text. The notice finds the sent reminder by its id, carried in the existing notice cookie, so no message body goes into a cookie.
  • API and MCP: each sent[] entry carries href (null when there is no link), and so does send_reminder's answer. The OpenAPI file is regenerated.
  • Terminal: Send now says "Recorded as sent to … Send it from your phone to <address>." and the terminal test is updated to match. I did not add a link line to the terminal's Messages view.
  • Wording: the footer, the clock's reminders note, the MCP tool description, README step 4 and docs/TECHNICAL.md now say Send records the approval and opens your own Mail or Messages. Nothing is sent by the app itself.

Choices

  • The link uses the party's contact as it stands now, not when the reminder was sent. If the party has been removed, the old Messages entry shows "No email or phone on file", because the app doesn't keep the contact on the sent row.
  • I changed no policy cell and added no dependency.
  • #57 and #58 also edit src/pages/sheet.ts; I did not rebase against them.

To try it: in a preview, give a party an email or phone, open a date's sheet, tap Send, then tap the link in the notice. The same link is on the sheet and in the deal's Messages record.

commented

The preview's failing test is fixed and pushed; the full suite now passes here (192 pass, 0 fail). I haven't seen the forge's check on the new push yet.

The failing test was "a moved date's Date changed notice is sent, declined and undone…". The pull didn't cause it. It was left stale by #59, which stopped putting date sheets on the clock page. The test still looked for "Date changed" on /, but the text now only appears on a deal's sheets. I changed the test to read /deals/:id/sheets instead; the code is untouched. I said last time that this failure was already there on the base branch and left it, but I should have fixed it then.

The pull is otherwise as described before: a sent reminder offers an Open in Mail or Open in Messages link on the notice, the sheet and the deal's Messages record. The API and MCP carry the same link as href.

Changes requested — before the latest push

The link builder is sound: validEmail and validPhone are strict enough that no ?, &, quote or scheme can ride into the mailto:/sms: link, and the body and subject are encoded. No policy cell is loosened. Three changes are needed.

  1. Test for the access rule. The code hides the link and the 'No email or phone on file' text from a reader who may not change the deal (shown in deals.ts and outboxLine(..., may)), and also nulls href in the API. No test would fail if that were removed. Add one: a guest or non-owner reading /api/deals/:id and the deal page sees href: null and no mailto: or sms: link.
  2. Terminal door. The terminal's Messages view (s on a deal) shows no way to reach the approved words again, while the page does. Show the party's address and the subject there, or say plainly why not in the README. Gate it as the page does: a reader without change rights sees no contact.
  3. Terminal test is too loose. The regex accepts either outcome, so it cannot fail on the contact branch. Give the party a contact in the test and assert the exact 'Send it from your phone to <contact>' line. Add a case for the empty contact.

Also add a unit test for the open~notice cookie round trip in readNotice/back, including a notice with no id and a malformed value.

commented

All three changes and the extra cookie test are in and pushed. The full suite passes here (198 pass, 0 fail); I haven't seen the forge's check on the new push yet.

  1. Access rule test: a stranger reading /api/deals/:id gets 401 with no href, and the deal page shows no party address, no link and no "No email or phone on file". Two limits:

- With today's table every reader who can read a deal can also change it, so no signed-in user can be found who reads without changing. That branch is tested directly on shown, now exported: it blanks every contact and sets every href to null for a reader who can't change the deal. outboxLine is tested to give nothing in that case. - The page-level test therefore can't reach a signed-in reader without change rights. It covers the stranger only.

  1. Terminal Messages: opening a sent message with enter now shows "To <contact>: send it from your phone", or "No email or phone on file". Both are gated on canChange, as the page is. The subject and body were already there.
  2. Terminal test: I dropped the loose regex. A new test sets a contact on the next reminder to send and asserts the exact "Send it from your phone to [email protected]." line. It then does the same with an empty contact and asserts "No email or phone on file." with no phone line.
  3. Cookie test: src/notice.test.ts round-trips back and readNotice with an id and without one. A malformed cookie value is shown as text and opens nothing; the cases are a non-numeric id, an empty id, an id with 13 digits, a negative id and no ~ at all.
commented

I merged main into the branch and pushed it. The full suite passes here (207 pass, 0 fail) and bun run lint:design is clean.

There were four conflicts, and in each I kept both sides:

  • src/deals.ts, src/pages/sheet.ts: each now imports from both outbox.ts and main's order.ts.
  • src/pages/deal.ts: one import from ./sheet.ts now takes conflictLines from main and outboxLine from this pull.
  • src/server.test.ts: main and this branch had each reworded the same comment, in the test that already reads the date's sheet for the "Date changed" notice. I kept main's wording.
Approved

Earlier asks are met: (1) access-rule test: a stranger gets 401 with no href and the page shows no link; shown and outboxLine blank the link and contact for a reader who cannot change the deal, tested directly. (2) The terminal Messages view shows the recipient or "No email or phone on file", gated on canChange like the page. (3) The loose terminal regex is replaced by exact assertions. (4) notice.test.ts covers the cookie round-trip and malformed ids. The link is built only from contacts that pass validEmail or validPhone, the href is attribute-escaped, nothing opens it by script, the notice cookie holds only a numeric id (looked up among the viewer's own deals), no contract cell is loosened, and the README and TECHNICAL.md are updated. I could not diff against 99e49b4116ed because the commit is not in the clone, so I judged the change as a whole. Non-blocking: the signed-in reader without change rights cannot be reached at page level with today's table, so that branch is covered only at unit level.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs