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

New deal shows every computed date before it is opened, and a refused form keeps what was typed #22

Merged opened this

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

Merged

/deals/new now has a Check the dates button next to Open deal, and a refused form keeps what was typed. The server tests and the design lint pass. I couldn't run the type check because the repo has no tsconfig.json, so bun x tsc --noEmit only prints help.

Notes

shipped production is serving it deploy d2eada7

opened this

/deals/new now has a Check the dates button next to Open deal, and a refused form keeps what was typed. The server tests and the design lint pass. I couldn't run the type check because the repo has no tsconfig.json, so bun x tsc --noEmit only prints help. There is also no scripts/gate.ts or scripts/fast.ts, so I ran src/server.test.ts, deals.test.ts, design.test.ts and security.test.ts directly. I didn't try the running app or the preview.

What changed

  • Check the dates: the button posts the same fields to a new POST /deals/check. The page comes back with the fields filled in and a list of every date the deal would get (label, weekday and date, who owes it). The list is plan() followed by a new plannedDates() in src/deals.ts, which reads from the same schedule insertDeal uses. Nothing is written or audited, and it goes through the same rationing in src/security.ts as other posts.
  • Refused forms: POST /deals used to redirect to an empty form on a refusal. For an invalid form it now returns 422 with the typed values and the reason beside the field. Sign-in and permission refusals still redirect as before.
  • Which field: fail() in src/result.ts takes an optional field, and plan() sets it. API and MCP callers see no change, since they only read error and message.
  • Form and CSS: the first-paint form is unchanged apart from the extra button. There is no script, and the inputs are the same 16px and 44px controls. I added two classes, .actions and .field-error, named in docs/design/areas/new-deal.md.
  • Docs: the README's New deal paragraph mentions Check the dates.

Tests

  • Check the dates: with a Friday contract date, the inspection date is 10 calendar days later (Mon, Oct 12). With business days on and a 3-day inspection it lands on Wed, Oct 7. The deal count is the same afterwards and the echoed address is escaped.
  • Refused form: a closing date before the contract date returns 422 from both /deals and /deals/check. The typed address is shown again, escaped, and the reason is next to the closing date field.
  • Test identities: the tests use fresh identities (dana, erin) because the per-identity rationing returned 429 on a shared one.

Not done

  • The preview shows the buyer and seller names for their dates and the role label for any other party.
  • No contract cell changed.
  • I didn't touch the deal page, so rebasing over #9 should be clean.

Closes #12

2 earlier comments · 1 event
commented

/deals/new now has a Check the dates button next to Open deal, and a refused form keeps what was typed. The server tests and the design lint pass. I couldn't run the type check because the repo has no tsconfig.json, so bun x tsc --noEmit only prints help. There is also no scripts/gate.ts or scripts/fast.ts, so I ran src/server.test.ts, deals.test.ts, design.test.ts and security.test.ts directly. I didn't try the running app or the preview.

What changed

  • Check the dates: the button posts the same fields to a new POST /deals/check. The page comes back with the fields filled in and a list of every date the deal would get (label, weekday and date, who owes it). The list is plan() followed by a new plannedDates() in src/deals.ts, which reads from the same schedule insertDeal uses. Nothing is written or audited, and it goes through the same rationing in src/security.ts as other posts.
  • Refused forms: POST /deals used to redirect to an empty form on a refusal. For an invalid form it now returns 422 with the typed values and the reason beside the field. Sign-in and permission refusals still redirect as before.
  • Which field: fail() in src/result.ts takes an optional field, and plan() sets it. API and MCP callers see no change, since they only read error and message.
  • Form and CSS: the first-paint form is unchanged apart from the extra button. There is no script, and the inputs are the same 16px and 44px controls. I added two classes, .actions and .field-error, named in docs/design/areas/new-deal.md.
  • Docs: the README's New deal paragraph mentions Check the dates.

Tests

  • Check the dates: with a Friday contract date, the inspection date is 10 calendar days later (Mon, Oct 12). With business days on and a 3-day inspection it lands on Wed, Oct 7. The deal count is the same afterwards and the echoed address is escaped.
  • Refused form: a closing date before the contract date returns 422 from both /deals and /deals/check. The typed address is shown again, escaped, and the reason is next to the closing date field.
  • Test identities: the tests use fresh identities (dana, erin) because the per-identity rationing returned 429 on a shared one.

Not done

  • The preview shows the buyer and seller names for their dates and the role label for any other party.
  • No contract cell changed.
  • I didn't touch the deal page, so rebasing over #9 should be clean.
commented

I merged main into the branch and pushed it; the only conflict was README.md.

main had rewritten the README as a numbered walkthrough and dropped the long prose paragraphs, including the New deal one I had edited. I kept main's version and added my Check the dates description to step 10 of the walkthrough, where "Open a new deal" now lives.

After the merge, src/server.test.ts, src/deals.test.ts, src/design.test.ts and src/security.test.ts pass. I did not run the full suite, and the type check still can't run because the repo has no tsconfig.json.

Changes requested — before the latest push

Page door is sound: same-origin and body cap come from the shared form()/security floor, output is escaped, mayOpen is asked (no hand-compared roles), no contract cell is touched. Changes needed, all in one round:

  1. Both doors: the terminal has no way to see the dates before opening (the n flow in src/terminal.ts goes straight to createDeal). Add the same preview there, built from plan() + plannedDates(), gated by mayOpen like the page (a guest sees nothing), and say how in the README.
  2. Tests: nothing proves /deals/check refuses a guest (anon) and writes nothing; add it. The toContain("checked") assertion is weak (the word appears elsewhere on the page); assert name="business_days" checked.
  3. The refusal path of POST /deals for a signed-in non-field failure is untested; add one case for the general (no field) message rendering.
commented

I've addressed all three review points and pushed. The server, terminal, deals, design and security test files pass. I did not run the full suite, and the type check still can't run because the repo has no tsconfig.json.

  • Terminal preview: pressing c asks the same five questions as n and lists every date n would create. The list comes from plan() and plannedDates(), with the owner's name, and nothing is written or audited. It is gated by mayOpen, so a guest is told to sign in and sees no prompt. The key hint, docs/TECHNICAL.md and README step 10 now mention c.
  • Guest test: an anonymous POST /deals/check gets a 303 back to /deals/new with a notice. The test checks that nothing is rendered and no deal is written.
  • Business-days assertion: the test now asserts name="business_days" checked. It also asserts the plain calendar-day preview does not have it.
  • Terminal tests: a new c test covers the preview, the unchanged deal count, an invalid answer and a guest.
  • General refusal: I could not test this through POST /deals. plan() names a field for every invalid refusal, and every other refusal redirects, so a signed-in refusal with no field can't happen there today. I tested the page's no-field path directly instead, by rendering newDealPage with a problem that has no field. It shows the message escaped above the form and keeps the typed values. I kept that branch rather than deleting it as unreachable, so a future rule that names no field still shows its message.
Approved

All earlier asks are met: the terminal has c (gated by mayOpen, so a guest is asked to sign in), with a test; a guest POST to /deals/check is tested; the business-days assertion checks checked; the no-field refusal path is tested by rendering the page directly. /deals/check asks mayOpen (permit) and writes nothing; echoed values are escaped; no contract cell is loosened; no new dependency. I could not diff against 54a6fd5 (the commit is not in the clone), so I judged the full change. Non-blocking: the docs/TECHNICAL.md line for c runs long.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs