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

The agent can edit a reminder's words before sending, and the sent record keeps exactly what was approved #10

opened this

Merged 33d 0h ago, live in production

Opening a draft in a date's sheet or in Reminders for today now shows its subject and body in editable fields, and Send stores exactly what was posted. bun test passes (74 tests) and bun scripts/lint-design.ts is clean. bun x tsc --noEmit could not run: the repo has no tsconfig.json, so tsc only prints its help.

Notes

opened this

Opening a draft in a date's sheet or in Reminders for today now shows its subject and body in editable fields, and Send stores exactly what was posted. bun test passes (74 tests) and bun scripts/lint-design.ts is clean. bun x tsc --noEmit could not run: the repo has no tsconfig.json, so tsc only prints its help.

What changed

  • Migration: src/db.ts adds subject and body to reminder. Rows sent before the migration have empty words and read back as the draft they were sent from.
  • Sending: sendReminder in src/deals.ts takes optional subject and body. Left out, the current draft is stored. Given, they are checked at the boundary:
    • Subject is trimmed to one line, 1 to 150 characters.
    • Body is trimmed, line breaks kept, control characters dropped, 1 to 2000 characters.
    • A failure is invalid with the message "The message is 1 to 2000 characters."
  • Permissions: it still asks permit(who, "deal", "update", deal) and is audited. No cell in contract.json changed.
  • Sent words: a second send changes nothing, and a sent draft in src/reminders.ts reads back its stored words. A rename of the party afterwards does not alter them.
  • Doors:
    • Page: /reminders takes subject and body from a plain form with no script. Each draft is a <details> holding the form, and a sent or read-only draft shows its stored words.
    • API: /api/deals/:id carries the stored words in sent, and contract/openapi.json is re-emitted.
    • MCP: send_reminder takes optional subject and body and answers with the sent record.
    • Terminal: s sends the draft unchanged and stores its words, and enter reads the stored words.
  • Sheet layout: the per-moment "Read the draft" preview is gone, because each party's message is now its own form or record. The inputs are 16px and the textarea is at least 88px tall. I added only a textarea.input rule to static/app.css, no new component class. I have not looked at the sheet in a browser at 360px.
  • Docs: README.md describes the editing and the kept words.

Tests

  • An edited send stores the edited words.
  • An empty body, an empty subject, a 151-character subject, a 2001-character body and an anonymous caller are each refused, and nothing is stored.
  • A second send keeps the first words.
  • Renaming the party leaves a sent reminder's words unchanged.
  • A send with no words stores the draft as it stands.
  • The form route stores edited words, and a blank body flashes the named failure.
  • The terminal test checks that s stored the shown draft.

What I did not do

  • Sending is still simulated, with no email or SMS.
  • I did not backfill words for reminders sent before the migration.

To try it: open any date's sheet, open a draft, change the words, press Send, then reopen it or fetch /api/deals/:id.

🤖 Generated with Claude Code

Closes #5

3 earlier comments
commented

Opening a draft in a date's sheet or in Reminders for today now shows its subject and body in editable fields, and Send stores exactly what was posted. bun test passes (74 tests) and bun scripts/lint-design.ts is clean. bun x tsc --noEmit could not run: the repo has no tsconfig.json, so tsc only prints its help.

What changed

  • Migration: src/db.ts adds subject and body to reminder. Rows sent before the migration have empty words and read back as the draft they were sent from.
  • Sending: sendReminder in src/deals.ts takes optional subject and body. Left out, the current draft is stored. Given, they are checked at the boundary:
    • Subject is trimmed to one line, 1 to 150 characters.
    • Body is trimmed, line breaks kept, control characters dropped, 1 to 2000 characters.
    • A failure is invalid with the message "The message is 1 to 2000 characters."
  • Permissions: it still asks permit(who, "deal", "update", deal) and is audited. No cell in contract.json changed.
  • Sent words: a second send changes nothing, and a sent draft in src/reminders.ts reads back its stored words. A rename of the party afterwards does not alter them.
  • Doors:
    • Page: /reminders takes subject and body from a plain form with no script. Each draft is a <details> holding the form, and a sent or read-only draft shows its stored words.
    • API: /api/deals/:id carries the stored words in sent, and contract/openapi.json is re-emitted.
    • MCP: send_reminder takes optional subject and body and answers with the sent record.
    • Terminal: s sends the draft unchanged and stores its words, and enter reads the stored words.
  • Sheet layout: the per-moment "Read the draft" preview is gone, because each party's message is now its own form or record. The inputs are 16px and the textarea is at least 88px tall. I added only a textarea.input rule to static/app.css, no new component class. I have not looked at the sheet in a browser at 360px.
  • Docs: README.md describes the editing and the kept words.

Tests

  • An edited send stores the edited words.
  • An empty body, an empty subject, a 151-character subject, a 2001-character body and an anonymous caller are each refused, and nothing is stored.
  • A second send keeps the first words.
  • Renaming the party leaves a sent reminder's words unchanged.
  • A send with no words stores the draft as it stands.
  • The form route stores edited words, and a blank body flashes the named failure.
  • The terminal test checks that s stored the shown draft.

What I did not do

  • Sending is still simulated, with no email or SMS.
  • I did not backfill words for reminders sent before the migration.

To try it: open any date's sheet, open a draft, change the words, press Send, then reopen it or fetch /api/deals/:id.

🤖 Generated with Claude Code

commented

I've addressed all three of sentinel's points and pushed to the same branch. bun test passes (78 tests). The first push of this round included a failing terminal test. I fixed it in the next commit (60e64e8), so only the latest push is green. bun x tsc --noEmit still can't run, because the repo has no tsconfig.json.

Terminal edit (src/terminal.ts)

  • e on an unsent reminder asks for a subject, then a message. An empty answer keeps that part of the draft, and \n in the message is a line break.
  • The message can be up to 2000 characters, the same limit as the page.
  • Edited words are held in the terminal until s sends them. Enter shows the edited words before sending, and a sent reminder always shows its stored words.
  • Anon sees no deals in the terminal, so e never opens a prompt for them, and e goes through the same canChange check as the other prompts. With the current table any signed-in user may work a deal, so only anon is gated. A reminder already sent says so and cannot be edited.
  • The same subject and body limits apply at send as on the page, because the terminal calls the same sendReminder.

Tests added

  • MCP:
    • send_reminder refuses an empty body, an empty subject, a 151-character subject and a 2001-character body.
    • It refuses an anonymous caller.
    • It stores edited words and answers with them.
    • A re-send keeps the first words.
    • get_deal shows the sent words.
  • Page:
    • An unsent draft renders the subject input and the body textarea; a guest sees no form.
    • After a send, the sent words appear escaped and the raw <script> does not.
  • Terminal:
    • e stores words that s then sends.
    • An empty answer keeps that part of the draft.
    • A guest gets no edit prompt.
  • The new server tests use their own identity, editor, because the shared write limit of 20 for alice was being used up and returning 429s.

README: the terminal paragraph now describes e and s. I also reflowed the MCP tools sentence. I did not touch the Send paragraph the review may have meant. If the line you meant is a different one, point me at it.

Not done: the terminal prompt has no prefill, so you retype the part you change (or press enter to keep it) rather than editing in place.

🤖 Generated with Claude Code

commented

I merged main into the branch, resolved the two conflicts (src/db.ts and README.md), and pushed. bun test passes (82 tests).

  • src/db.ts: both migrations are kept. main's sample_anchor migration stays in its original position, because it may already have run in production. My ALTER TABLE reminder migrations for subject and body come after it, so no migration that has run was reordered or edited.
  • README.md: the MCP tools sentence now lists main's new tools (open_deal, add_date, add_party, and mark_done with done: false to reopen). It also keeps my note that send_reminder takes an optional subject and body.

I did not re-run scripts/lint-design.ts after the merge, since main's changes touched no files in src/web/ or static/.

🤖 Generated with Claude Code

commented

The preview should now start. bun test passes (83 tests), but I haven't seen the preview deploy itself yet.

Cause: the preview's database had already run my two ALTER TABLE reminder migrations at their old positions in the list. The merge put main's sample_anchor migration ahead of them, so the preview's recorded version was one short and the body migration ran a second time. SQLite rejected it with "duplicate column name: body".

Why not reorder: production has already run sample_anchor at its position, so reordering would break production instead.

Fix: in migrate() in src/db.ts, an ALTER TABLE … ADD COLUMN that fails with "duplicate column name" now counts as already applied. Any other migration failure still throws.

Test: a new test in src/db.test.ts removes the last recorded version from a migrated database and reopens it. The database opens and the migration count is correct.

Side effect: the preview database never ran main's sample_anchor migration, so its sample deals keep their old dates. This affects the preview only.

🤖 Generated with Claude Code

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs