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

An agent fixes a typo in a deal's address from its page, and the clock, timeline, calendar file and every new reminder carry the new address #45

Merged opened this

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

Merged

The deal page now has an Edit address control, so a typo in an address is fixed in place without removing the deal. src/server.test.ts passes (38 tests) and the design lint is clean.

Notes

shipped production is serving it deploy d2eada7

opened this

The deal page now has an Edit address control, so a typo in an address is fixed in place without removing the deal. src/server.test.ts passes (38 tests) and the design lint is clean. I ran no other test files, and bun x tsc --noEmit printed only tsc's help text because the repo has no tsconfig.json, so there was no type check. The repo has no scripts/design-lint.ts, so I ran scripts/lint-design.ts instead.

  • The control (src/pages/deal.ts): a <details> holding one form that posts to /deals/:id/address. It shows only to a viewer permit lets update the deal, through the existing canChange.
  • The route (src/routes.ts): it calls the existing updateDeal, with no new rules. A 3–200 character address saves and redirects to the deal page with an "Address corrected." notice. Anything else re-renders the page with status 422. The <details> opens, and the error sits beside the field with the typed value escaped. The security floor's same-origin check covers the post.
  • Where the new address shows: the clock, timeline, .ics and drafts not yet sent all read the stored address, and a test confirms the clock, timeline and .ics. I did not test the drafts, and I did not touch the code that keeps sent reminders as approved.
  • Samples: src/sample.ts finds a sample deal by its address, so an edited sample deal counts as changed. The boot-time date shift skips it, and Restore treats it as a deal you opened. I did not add a test for this.
  • Tests (src/server.test.ts): one route test covers the following.

- The edit shows up on /, in the timeline and in the .ics. - A too-short address is refused with the deal unchanged and the typed value escaped. - A signed-out viewer gets no form and their post changes nothing. - A cross-site post gets 403.

  • README: "Try it on the sample deals" gains a new step 14, "Fix an address". I renumbered Put the samples back to 15.

I did not touch contract.json or loosen any permission cell. The README sentence says unsent drafts carry the new address and sent reminders keep their words; only the first half is exercised by a test.

To try it, sign in, open any deal, tap Edit address, and save a new address.

🤖 Generated with Claude Code

Closes #42

2 earlier comments · 2 events
commented

The deal page now has an Edit address control, so a typo in an address is fixed in place without removing the deal. src/server.test.ts passes (38 tests) and the design lint is clean. I ran no other test files, and bun x tsc --noEmit printed only tsc's help text because the repo has no tsconfig.json, so there was no type check. The repo has no scripts/design-lint.ts, so I ran scripts/lint-design.ts instead.

  • The control (src/pages/deal.ts): a <details> holding one form that posts to /deals/:id/address. It shows only to a viewer permit lets update the deal, through the existing canChange.
  • The route (src/routes.ts): it calls the existing updateDeal, with no new rules. A 3–200 character address saves and redirects to the deal page with an "Address corrected." notice. Anything else re-renders the page with status 422. The <details> opens, and the error sits beside the field with the typed value escaped. The security floor's same-origin check covers the post.
  • Where the new address shows: the clock, timeline, .ics and drafts not yet sent all read the stored address, and a test confirms the clock, timeline and .ics. I did not test the drafts, and I did not touch the code that keeps sent reminders as approved.
  • Samples: src/sample.ts finds a sample deal by its address, so an edited sample deal counts as changed. The boot-time date shift skips it, and Restore treats it as a deal you opened. I did not add a test for this.
  • Tests (src/server.test.ts): one route test covers the following.

- The edit shows up on /, in the timeline and in the .ics. - A too-short address is refused with the deal unchanged and the typed value escaped. - A signed-out viewer gets no form and their post changes nothing. - A cross-site post gets 403.

  • README: "Try it on the sample deals" gains a new step 14, "Fix an address". I renumbered Put the samples back to 15.

I did not touch contract.json or loosen any permission cell. The README sentence says unsent drafts carry the new address and sent reminders keep their words; only the first half is exercised by a test.

To try it, sign in, open any deal, tap Edit address, and save a new address.

🤖 Generated with Claude Code

Changes requested — before the latest push

Address edit works on the page, but it misses the second door and a sample-deal regression. Fix in one round:

  1. Both doors: no way to edit an address in src/tty.ts or over MCP (only create_deal exists). Add an update-address action in the terminal and an MCP tool that call updateDeal, with README lines for each, and tests. A write there must reach web viewers live (updateDeal already emits deal.changed).
  2. Samples: src/sample.ts matches a sample deal by address (line 136), so editing a sample's address makes it look like a deal the agent opened: the boot date shift skips it and Restore leaves it and adds a duplicate. Handle it (e.g. key samples by a stored id/marker, not address) and test it.
  3. Tests: the README promises unsent drafts carry the new address and sent reminders keep their words, but neither is tested. Add tests that fail without it. Also add a contract.test.ts row if you add a door; the cell for update is unchanged, good.
  4. The anon assertion anon.status === 303 || >= 400 is too loose; assert the exact status, and test that a user who does not own the deal gets no change.
commented

I've addressed three of the four review points and disagree with part of the fourth; the full bun test run passes. The design lint passes, and there is no scripts/gate.ts or tsconfig.json, so no type check ran. The full suite is flaky on the base branch as well: audit tests that share the per-address rate limit for signed-out callers sometimes get 429. I kept my added tests from adding to that pressure by dropping a signed-out MCP call.

1. Both doors

  • Terminal: pressing A on an open deal asks for the new address and calls updateDeal. The footer hint and the header comment list the key. A signed-out terminal is refused like any other write. updateDeal already emits deal.changed, so web viewers see the change live.
  • MCP: the new update_address tool takes deal_id and address and calls updateDeal.
  • Docs: the README step 14 now names the A key and the tool, and docs/TECHNICAL.md lists update_address among the MCP tools.
  • Tests: a terminal test covers a refused short address and a successful one. An MCP test covers the tool-list entry, a short address changing nothing and a good address saving.
  • contract.test.ts: it already drives updateDeal for every identity, and this adds no new action, cell or door, so I added no row.

2. Samples

  • Fix: a sample deal is now identified by a stored marker instead of its address. A new sample_deal table (migration appended) holds the address each sample was written with, and the migration backfills existing sample deals. isUntouched and refresh read the marker, and writeSamples stores it.
  • Tests: a sample whose address was corrected still shifts with the others at boot and still counts as untouched, and Restore leaves exactly four samples with the original address back. I changed db.test.ts so the "late moment" migration test finds its migration by content, not by being last.
  • Disagreement: Restore did not add a duplicate. It deletes every deal authored by the sample identity before rewriting, so the edited sample was removed and replaced. The date-shift skip was real, and that is what the marker fixes.

3. Drafts and sent reminders: a new test in deals.test.ts opens a deal and sends one reminder. It then edits the address as a different user. Unsent drafts and their subjects carry the new address, while the sent reminder keeps its original words, both in the drafts view and in the stored record.

4. Status codes

  • Signed-out post: now asserted exactly: 303 with the "Sign in…" notice cookie.
  • Non-owner: I did not add a test that a non-owner gets no change. The contract says update is open to any user, and a non-owner already edits a deal in that test, so refusing them would loosen nothing but tighten the table, which this issue doesn't ask for. If you want editing limited to the deal's author, that changes contract.json, which a person has to approve.
Approved — before the latest push

Earlier asks, all met. (1) Both doors: the terminal has A on an open deal, the MCP has update_address, and both call updateDeal, so permit gates them. The README and TECHNICAL.md name them, and tests cover each. (2) Samples: the sample_deal marker table, its backfill migration and the restore/shift test mean a corrected sample stays a sample. (3) Drafts versus sent reminders: the new deals.test.ts case proves unsent drafts take the new address and sent words stay. (4) The signed-out post is asserted exactly, with a 303 and the sign-in notice. I read only the lines changed since fec253ae3086 and found no new problems: input is validated by updateDeal, the typed value is escaped when the form is re-rendered, the same-origin floor covers the post, and contract.json is untouched, so no cell is loosened. Non-blocking: the migration test now finds its migration by content, which is fine, but a short comment on why would help.

commented

I merged main into the branch and pushed it; it merges cleanly again. bun test passes (151 tests) and bun scripts/lint-design.ts is clean. I didn't run a type check, since the repo has no tsconfig.json.

Only src/server.test.ts conflicted. Both sides had added new tests at the end of the file. I kept both: my MCP update_address test and main's find-by-name test. I also restored the closing }); of my test, which I had removed by mistake while clearing the conflict markers. Nothing else in the merge needed a change.

Approved

Earlier asks are met. The terminal A key and the update_address MCP tool both go through updateDeal, which asks permit, validates 3 to 200 characters and is audited. The sample_deal marker keeps a corrected sample shifting and restorable, and has a test. Drafts versus sent reminders now has a test. The signed-out status is asserted exactly. No contract cell is loosened. The route is same-origin guarded and escapes the typed value. I could not diff against 69dfda44bdf0 because it is not in the clone, so I read the full change. Non-blocking: the terminal anon test only checks that nothing changed.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs