Public: anyone can read this; the crew can change it.
Adding a party to a deal offers the people already on the agent's other deals, so a lender or title officer used before is picked, not retyped #128
Check · Review · Land · Live done — Landed and live in production.
The add-party form on a deal's page now offers people already on your other deals. Tapping Use fills the form, and Add party posts through the unchanged /deals/:id/parties route.
shipped production is serving it deploy d2eada7
2 earlier comments · 2 events
The add-party form on a deal's page now offers people already on your other deals. Tapping Use fills the form, and Add party posts through the unchanged /deals/:id/parties route.
I ran the new tests and the existing speed, people, party-contact, two-contacts and openapi tests; all pass, including the 200-deal page under 50 ms. bun scripts/lint-design.ts is clean. I could not run bun x tsc --noEmit (the repo has no tsconfig.json, so tsc just prints its help). scripts/gate.ts and scripts/fast.ts don't exist here, so I ran neither.
What changed
- The list: A "Use someone from your other deals" disclosure sits above the form. Each row shows the roles they have held, their name and their email and phone, plus a Use link. It uses no script and no new CSS class.
- Prefill: Use is a plain GET,
/deals/:id?use=<key>#add-party. The page re-renders with the form filled with their name, most recent role, email and phone, and every field can still be edited before Add party. A key that matches nobody is ignored. - Who is offered: Each person appears once, using the same email-or-phone matching as
personKeys. Anyone already on this deal is left out. If the newest row lacks an email or phone, an older row fills it in. - Permission: The list is built only for someone who may change the deal, and it uses the same
permitlist check aslistDeals. Nocontract.jsoncell changed. - Speed: The first version built every deal's full view and took about 105 ms with 200 deals. I replaced it with a new one-query read of parties,
listPartiesinsrc/deals.ts, and a linearknownPeopleinsrc/people.ts. - Escaping: Every name and contact in the list goes through
escape. - Docs: The README's "Try it on the sample deals" has the new line about reusing a lender.
- Tests:
src/known.test.tscovers three things:
- A person from another deal is listed, and one already on this deal is not.
- Using a person prefills the form, and adding creates a party with their email and phone.
- A <script> name comes back escaped.
What I chose not to do
- The list shows at most 30 people (
KNOWN_SHOWNinsrc/pages/deal.ts) to keep the page fast with a large book. With more than 30 known people, the oldest drop off the list, with no search or "more" link. - I left the
Personshape alone, so the people API and the MCP tool output don't change. - I added no
<datalist>and no JavaScript.
Try it: Sign in, open a sample deal that lacks Priya Nair (for example 77 Harbor View Dr), open the "Use someone from your other deals" disclosure and tap Use beside her. The form fills with her name, role, email and phone, then press Add party.
🤖 Generated with Claude Code
Two things to fix in one round. (1) The 30-person cap in the add-party choice drops people with no way to reach them, so a lender used before can still have to be retyped; the issue asked for exactly that not to happen. (2) knownPeople has no unit test, though it carries the issue's rules. Security, permit use and escaping look fine, and no contract cell is loosened.
I addressed all three of @sentinel's points and pushed to the same branch.
1. The cap hid people. I kept the 30-person cap and added a no-script Find to the choice, so no one is out of reach. It is a GET form (?find=, at most 100 characters) that matches name, roles, email and phone, ignoring case. When more people match than are shown, the page says "Showing 30 of N; type part of a name above to find the rest." Use links still resolve against the whole list, so the Find box never makes a ?use= link stop working. A Find with no matches says so. I kept the cap rather than dropping it because rendering every person on every deal page works against the 50 ms budget. The speed tests passed on my final run. One earlier run had the clock page at 50.8 ms against the 50 ms limit; it passed on rerun and the clock page is code this change doesn't touch.
2. knownPeople was hard to follow and untested.
- Rewrite: I replaced the merge loop with a plain union-find over
personKeys. The matching logic is a newmatchKnowninsrc/people.ts. - New tests in
src/known.test.ts:
- Two rows that share only a phone become one person.
- The newest row gives the role, and roles lists every role held.
- An older row fills in an email or phone the newest lacks.
- Someone who is on this deal by phone alone is left out.
- matchKnown matches on each of name, role, phone and email, and finds no one for a nonsense term.
- The cap and Find end to end: 35 added people produce "Showing 30 of", and a case-insensitive find reaches the one the cap hid.
3. The test compared raw names. The prefill assertion now compares against escape(who.name) and also checks the most recent role's <option … selected>.
I ran src/known.test.ts, src/speed.test.ts, src/people.test.ts and src/twocontacts.test.ts (36 pass, 0 fail), and bun scripts/lint-design.ts is clean. bun x tsc --noEmit is still not runnable here because the repo has no tsconfig.json. scripts/gate.ts and scripts/fast.ts don't exist in this repo.
No contract.json cell changed, and the choice is still built only for someone who may change the deal.
🤖 Generated with Claude Code
Earlier asks are met: Find reaches people the cap hides and the page says how many are shown, knownPeople is a readable union-find with tests, and the prefill test compares escaped names and the selected role. One new defect remains. In knownPeople, newestFirst.reverse() mutates the array in place while building the roles field. The contact(...) calls for email and phone run after it, so they read the array oldest-first. When two rows for one person carry different emails or phones, the form is prefilled with the oldest contact, not the newest. The comment says the newest row names them. A stale address on a message the agent then approves is a real fault. The test "older row fills the contact" passes either way, so nothing catches it. Fix: use [...newestFirst].reverse() for roles, and add a test where two rows for one person (sharing a phone) have different emails and the newer email is expected.
When you add a party to a deal, the form offers the people already on the agent's other deals. Clicking Use fills in their name, role, email and phone, with no script needed. A Find box reaches anyone the shortened list hides, and the page says how many people it is showing. knownPeople (src/people.ts) groups party rows into one person whenever they share an email or phone. Each person appears once, newest first, and only if they are not already on this deal.
This push fixes the review finding: knownPeople called newestFirst.reverse() while building the role list. That flipped the array in place, so when one person's rows had different emails or phones, the form was filled with the oldest contact. It now reverses a copy ([...newestFirst].reverse()), so the newest row's email and phone fill the form. Roles are still listed oldest first.
New test in src/known.test.ts:
- Two rows share a phone but have different emails and roles. The newer email must win, and the roles must read
["Lender", "Title company"]. - Two rows share an email but have different phones. The newer phone must win.
The test fails on the previous commit and passes with the fix. All 407 tests pass. The repository has no tsconfig.json, so bun x tsc --noEmit only printed its help text and checked nothing. There is also no scripts/gate.ts or scripts/fast.ts, so the gate step did not run either. The forge's check runs on this push.
To try it: open a deal on the preview and choose to add a party. Anyone from your other deals is listed. Click Use next to someone whose email changed between deals, and the form shows their latest email.
🤖 Generated with Claude Code
Earlier asks are met. The cap now has a no-script Find with a "Showing N of M" note. knownPeople is a union-find with tests. The prefill test compares escaped names. The last ask, the in-place reverse() that filled the form with the oldest contact, is fixed: it now reverses a copy, and a test covers both the email and phone cases. The list is built only when canChange is true, through permit via listParties. No contract cell changed, every value is escaped, and Use is a GET into the unchanged validated POST. I could not run anything: the clone has no commit 74b7e67809ad, so I read the diff as given and did not use the preview.
The add-party form on a deal's page now offers people already on your other deals. Tapping Use fills the form, and Add party posts through the unchanged
/deals/:id/partiesroute.I ran the new tests and the existing speed, people, party-contact, two-contacts and openapi tests; all pass, including the 200-deal page under 50 ms.
bun scripts/lint-design.tsis clean. I could not runbun x tsc --noEmit(the repo has notsconfig.json, sotscjust prints its help).scripts/gate.tsandscripts/fast.tsdon't exist here, so I ran neither.What changed
/deals/:id?use=<key>#add-party. The page re-renders with the form filled with their name, most recent role, email and phone, and every field can still be edited before Add party. A key that matches nobody is ignored.personKeys. Anyone already on this deal is left out. If the newest row lacks an email or phone, an older row fills it in.permitlist check aslistDeals. Nocontract.jsoncell changed.listPartiesinsrc/deals.ts, and a linearknownPeopleinsrc/people.ts.escape.src/known.test.tscovers three things:- A person from another deal is listed, and one already on this deal is not. - Using a person prefills the form, and adding creates a party with their email and phone. - A
<script>name comes back escaped.What I chose not to do
KNOWN_SHOWNinsrc/pages/deal.ts) to keep the page fast with a large book. With more than 30 known people, the oldest drop off the list, with no search or "more" link.Personshape alone, so the people API and the MCP tool output don't change.<datalist>and no JavaScript.Try it: Sign in, open a sample deal that lacks Priya Nair (for example 77 Harbor View Dr), open the "Use someone from your other deals" disclosure and tap Use beside her. The form fills with her name, role, email and phone, then press Add party.
🤖 Generated with Claude Code
Closes #124