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

A deal's closing carries a time and a place, like "2:00 pm at Lakeside Title, 400 Main St", on its page, the client timeline, the closing reminders and the calendar file #126

Merged opened this

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

Merged

A deal's closing now carries an optional time and place. They show on the deal's page and the client timeline, in the closing and walk-through reminders, and in the calendar file. src/closing.test.ts and the neighbouring suites pass.

Notes

shipped production is serving it deploy d2eada7

opened this

A deal's closing now carries an optional time and place. They show on the deal's page and the client timeline, in the closing and walk-through reminders, and in the calendar file.

src/closing.test.ts and the neighbouring suites pass. Two things did not run clean:

  • Speed tests: the "first time after a deal changes" cases land at 50–57 ms here, and 2–3 of them also fail on untouched main in this sandbox (the failing ones vary run to run). I read that as machine noise and did not chase it.
  • Type check: bun x tsc --noEmit can't run because the repo has no tsconfig. scripts/gate.ts and scripts/fast.ts aren't in this clone, so I ran no gate and named the test files by hand.

What changed

  • Storage: two nullable columns on deal, closing_time and closing_place, added as a migration at the end of the list. A new module, src/closing.ts, validates them and words them in one place.
  • Validation: the time is HH:MM on a quarter hour from 07:00 to 20:00, so 25:00 and 2pm give a 422. The place is 1 to 200 characters. Blank or null clears either one.
  • Editing: updateDeal takes both fields and is audited. The new form POST /deals/:id/closing ("Edit closing time and place" on the deal page) is same-origin only and keeps what was typed when it refuses. Changes appear on the Activity page as "changed a deal".
  • API and MCP: both fields are read and written by /api/deals, which gains them on PATCH, and by src/openapi.ts. A new update_closing MCP tool writes them, and get_deal and client_timeline return them. contract/openapi.json is regenerated.
  • Display: the deal page and the client timeline (screen and print) show "Closing Nov 21 · 2:00 pm · Lakeside Title, 400 Main St". A deal with neither reads as before.
  • Reminders:

- The closing reminders (before and day of) say "…on Sat, Nov 21, 2:00 pm at Lakeside Title, 400 Main St". - The walk-through reminders add "Closing follows on …". - The date-changed notice and the status update name them too.

  • Calendar: with a time set, closing is a one-hour event in floating local time (DTSTART:20261121T140000). The place goes in LOCATION, escaped per RFC 5545. This holds in both the deal's file and Add all to calendar. With no time it stays VALUE=DATE. The "closing today" alarm is recomputed so it still fires at 9 am.
  • Moves: moving the closing date leaves the time and place alone.
  • Samples: Alder Lane (closing this week) gets 2:00 pm at Bayside Title, 400 Main St, and Restore the sample deals brings it back.
  • Docs: README and docs/TECHNICAL.md describe the feature.

What I chose not to do

  • The new-deal form and POST /api/deals don't take a time or place; the issue asked for the deal's page. They can be set right after opening, or via PATCH.
  • The terminal doesn't edit them.
  • contract.json is untouched, so no permission cell was loosened.

To try it Open a deal, tap Edit closing time and place, save "14:00" and a place, then check the deal page, "Client timeline", "Add to calendar", and the closing and walk-through drafts under Messages.

🤖 Generated with Claude Code

Closes #122

5 earlier comments · 1 event
commented

A deal's closing now carries an optional time and place. They show on the deal's page and the client timeline, in the closing and walk-through reminders, and in the calendar file.

src/closing.test.ts and the neighbouring suites pass. Two things did not run clean:

  • Speed tests: the "first time after a deal changes" cases land at 50–57 ms here, and 2–3 of them also fail on untouched main in this sandbox (the failing ones vary run to run). I read that as machine noise and did not chase it.
  • Type check: bun x tsc --noEmit can't run because the repo has no tsconfig. scripts/gate.ts and scripts/fast.ts aren't in this clone, so I ran no gate and named the test files by hand.

What changed

  • Storage: two nullable columns on deal, closing_time and closing_place, added as a migration at the end of the list. A new module, src/closing.ts, validates them and words them in one place.
  • Validation: the time is HH:MM on a quarter hour from 07:00 to 20:00, so 25:00 and 2pm give a 422. The place is 1 to 200 characters. Blank or null clears either one.
  • Editing: updateDeal takes both fields and is audited. The new form POST /deals/:id/closing ("Edit closing time and place" on the deal page) is same-origin only and keeps what was typed when it refuses. Changes appear on the Activity page as "changed a deal".
  • API and MCP: both fields are read and written by /api/deals, which gains them on PATCH, and by src/openapi.ts. A new update_closing MCP tool writes them, and get_deal and client_timeline return them. contract/openapi.json is regenerated.
  • Display: the deal page and the client timeline (screen and print) show "Closing Nov 21 · 2:00 pm · Lakeside Title, 400 Main St". A deal with neither reads as before.
  • Reminders:

- The closing reminders (before and day of) say "…on Sat, Nov 21, 2:00 pm at Lakeside Title, 400 Main St". - The walk-through reminders add "Closing follows on …". - The date-changed notice and the status update name them too.

  • Calendar: with a time set, closing is a one-hour event in floating local time (DTSTART:20261121T140000). The place goes in LOCATION, escaped per RFC 5545. This holds in both the deal's file and Add all to calendar. With no time it stays VALUE=DATE. The "closing today" alarm is recomputed so it still fires at 9 am.
  • Moves: moving the closing date leaves the time and place alone.
  • Samples: Alder Lane (closing this week) gets 2:00 pm at Bayside Title, 400 Main St, and Restore the sample deals brings it back.
  • Docs: README and docs/TECHNICAL.md describe the feature.

What I chose not to do

  • The new-deal form and POST /api/deals don't take a time or place; the issue asked for the deal's page. They can be set right after opening, or via PATCH.
  • The terminal doesn't edit them.
  • contract.json is untouched, so no permission cell was loosened.

To try it Open a deal, tap Edit closing time and place, save "14:00" and a place, then check the deal page, "Client timeline", "Add to calendar", and the closing and walk-through drafts under Messages.

🤖 Generated with Claude Code

commented

Four of the five failures are fixed; the fifth, a speed-budget test, looks like a timing flake. I haven't confirmed a clean run on the forge.

  • Four partycontact tests: the deal fixture in src/partycontact.test.ts predated the new closing_time and closing_place fields. They came through as undefined instead of null, so clock12 crashed on undefined.slice. I gave the fixture both fields as null. The code was right and only the test was stale.
  • "The clock answers within budget the first time after a deal changes":

- It is a 50 ms budget, and the clock took 52.8 ms in the first run and 50.7 ms in one of three reruns. - The other two reruns passed, along with the contact tests. - Nothing in this pull touches that path. It only adds two columns and the edit fields, so I left the budget and the code alone. If it fails again on the forge, that needs a real look.

I didn't run bun scripts/gate.ts. bun x tsc --noEmit printed its usage help instead of a type check, so the types are unchecked. The fix is pushed.

🤖 Generated with Claude Code

Changes requested — before the latest push

The page, API, MCP, calendar, reminders and samples look right, and I found no security problem. The closing time and place are validated at every door, the place is escaped in the .ics, the new form is same-origin, and no contract cell was loosened. One thing is missing.

Fix first: src/tty.ts. The list requires that what a person can do on the page they can also do in the terminal, and the README must say how. The pull sets closing time and place on the page, over the API and over MCP, but not in the terminal. It also leaves the terminal deal view without the closing line ("Closing Nov 21 · 2:00 pm · Lakeside Title, 400 Main St"). The issue did not exempt the terminal, so this is not optional.

What to add:

  • An edit action in tty.ts that calls updateDeal with closingTime and closingPlace. updateDeal already checks permit and audits the change. A change made there must reach web viewers live; updateDeal already emits deal.changed.
  • The closing line in the terminal deal view, using closingLine.
  • A tty test for the edit, a refused bad time and the closing line in the view.
  • A README line saying how to do it in the terminal. The README currently says the terminal does not edit them, so change that.

Smaller: tsc was not run and neither was gate.ts. Run what the clone allows before pushing.

commented

The terminal can now set a deal's closing time and place, and its deal view shows the closing line. Only bun test src/terminal.test.ts passed. Neither bun scripts/gate.ts nor bun x tsc --noEmit ran, because the clone has no scripts/gate.ts and no tsconfig.json.

  • Edit in the terminal: pressing C on a deal asks for the time (HH:MM) and then the place; a blank answer clears either. It calls updateDeal with closingTime and closingPlace, so the permission check, the audit row and the live deal.changed event are the same as on the page. A signed-out terminal is not prompted. The code is in src/terminal.ts, since src/tty.ts only wires that module to the pty.
  • Closing line in the deal view: the terminal deal view now shows closingLine, e.g. "Closing Nov 21 · 2:00 pm · Lakeside Title, 400 Main St". It appears only when a time or place is set. The key is also listed in the help line and the header comment.
  • Tests: two new tests in src/terminal.test.ts cover the edit, a refused bad time (2pm), the closing line in the view, clearing both values, and the signed-out case.
  • README: it now says to press C on a deal in the terminal, instead of saying the terminal does not edit these fields.

🤖 Generated with Claude Code

commented

I have no fix to push: the failing speed test also fails on the commit before this pull, so I don't think this pull causes it.

The test is "the clock answers within budget the first time after a deal changes", which has a 50 ms limit. On this branch it failed three times in a row, at 50.8, 55.9 and 59.0 ms.

I then ran the same file on f920885, the commit before this pull. It also failed, three times out of three, at 72, 62 and 55 ms. Different routes failed on different runs there, including the reminder review in the plain 50 ms test. This machine is loaded, so every route sits near the limit.

The diff on this branch adds two columns and a few string operations on the closing line. None of that can account for a 5–20 ms change on the clock. The 407 other tests pass, including the new terminal tests.

I did not raise BUDGET_MS or change the test to get a green run, because the 50 ms budget is the repository's own requirement. If this keeps failing on the forge's check, someone needs to profile the clock's rebuild after an edit, on a machine that isn't loaded. That would be a separate change from this one.

🤖 Generated with Claude Code

commented

I merged main into this branch, resolved the conflicts, and pushed. bun test passes (429 tests, 0 failures). tsc could not check the merge, because the repository has no tsconfig.json. I did not run scripts/design-lint.ts, so the page changes in src/pages/deal.ts are not lint-checked.

Both sides' intent is kept, and the conflicts were mostly additive:

  • Closing time and place: the closing_time and closing_place columns, the update_closing tool, the C key in the terminal and the closing line on the deal page and timeline all stay.
  • Side: the new side column, the set_side tool, the Y key in the terminal, the side label and the Save side form from main also stay.
  • Shared code: updateDeal and PATCH /api/deals/:id now take the closing time, place and side together and write them in one UPDATE. The deal view in the terminal shows both the side label and the closing line.
  • Docs and tests: the README and TECHNICAL.md carry both sections, and the terminal tests for C and for the side both stay.
  • OpenAPI file: I regenerated contract/openapi.json with scripts/contract-emit.ts from the merged routes instead of merging the JSON by hand.

No contract cell is loosened.

commented

The failing test was the clock answers within budget the first time after a deal changes. The clock was slow on a cold request because it read the whole book of deals twice. The full suite now passes here (429 tests, 0 failures), and the speed test passed on three runs in a row. I haven't seen the deploy re-run.

The 50 ms budget was only barely met, so the test was close to failing before this pull. Merged main ran the cold clock in about 43–51 ms against the 50 ms budget, and the same budget check failed on different routes in different runs, including the reminder review. After the fix the cold clock's own work is about 16 ms.

  • Cause: the GET / handler read all the deals once for the page, then waitingFor(c) read them again just to count the drafts waiting for approval. The second read cost about 10 ms.
  • Fix: src/routes.ts now counts the waiting drafts from the deals the handler already has, with the same waitingCount(deals, today(), agent) call as before. The Review link shows the same number.
  • Not changed: the other pages still use waitingFor. The cold reminder review took about 28–32 ms, within the budget, so I left it alone.
Approved

The earlier commit is not in my clone, so I judged the head as a whole. The terminal door now has C for time and place, with tests, and the README says so. The bad-time cases are 422 at the API, MCP, form and terminal. The place is control-character stripped and escaped in the .ics. The write goes through updateDeal, which asks permit, so no contract cell changes. The form is same-origin and keeps what was typed when refused. Output is escaped on the page and the timeline. The routes.ts change to GET / (counting waiting drafts from the deals already read) keeps the same count.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs