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
Check · Review · Land · Live done — Landed and live in production.
/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.
shipped production is serving it deploy d2eada7
2 earlier comments · 1 event
/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 isplan()followed by a newplannedDates()insrc/deals.ts, which reads from the same scheduleinsertDealuses. Nothing is written or audited, and it goes through the same rationing insrc/security.tsas other posts. - Refused forms:
POST /dealsused 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()insrc/result.tstakes an optionalfield, andplan()sets it. API and MCP callers see no change, since they only readerrorandmessage. - 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,
.actionsand.field-error, named indocs/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
/dealsand/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.
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.
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:
- Both doors: the terminal has no way to see the dates before opening (the
nflow 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. - 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); assertname="business_days" checked. - 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.
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
casks the same five questions asnand lists every datenwould create. The list comes fromplan()andplannedDates(), with the owner's name, and nothing is written or audited. It is gated bymayOpen, so a guest is told to sign in and sees no prompt. The key hint,docs/TECHNICAL.mdand README step 10 now mentionc. - Guest test: an anonymous
POST /deals/checkgets a 303 back to/deals/newwith 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
ctest 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 everyinvalidrefusal, 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 renderingnewDealPagewith 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.
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.
/deals/newnow 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 notsconfig.json, sobun x tsc --noEmitonly prints help. There is also noscripts/gate.tsorscripts/fast.ts, so I ransrc/server.test.ts,deals.test.ts,design.test.tsandsecurity.test.tsdirectly. I didn't try the running app or the preview.What changed
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 isplan()followed by a newplannedDates()insrc/deals.ts, which reads from the same scheduleinsertDealuses. Nothing is written or audited, and it goes through the same rationing insrc/security.tsas other posts.POST /dealsused 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.fail()insrc/result.tstakes an optionalfield, andplan()sets it. API and MCP callers see no change, since they only readerrorandmessage..actionsand.field-error, named indocs/design/areas/new-deal.md.Tests
/dealsand/deals/check. The typed address is shown again, escaped, and the reason is next to the closing date field.dana,erin) because the per-identity rationing returned 429 on a shared one.Not done
Closes #12