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

After an open house, paste the sign-in sheet and every visitor lands on the desk with a thank-you draft naming the house #84

Merged opened this

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

Merged

After an open house, the agent can paste the sign-in sheet on the desk. Each readable line becomes a lead with a thank-you draft for that address. All of bun test passes except one flaky test.

Notes

shipped production is serving it deploy aba151a

opened this

After an open house, the agent can paste the sign-in sheet on the desk. Each readable line becomes a lead with a thank-you draft for that address. All of bun test passes except one flaky test. src/live.test.ts ("a write from another process on the same file reaches the bus") failed once in the full run and passes on its own. I did not run bun x tsc --noEmit, because there is no tsconfig or node_modules here, and I did not try the running app.

What moved where

  • src/signins.ts (new): readSignIns reads one visitor per line, split by tabs or commas, in any order, with quoted cells allowed. A line it can't read is marked with a reason and its line number instead of being guessed. Reasons include no name, no email or phone, two emails, two phones, or extra text. The limits are 100 lines and 20,000 characters.
  • src/actions.ts: previewSignIns writes nothing. addSignIns re-reads the sheet itself and does not trust the preview.
  • New leads: each gets source open_house and consent off. The message is "Signed in at the open house at <address>."
  • Dedupe: a visitor whose email or phone matches an existing lead goes through findMatch and writeInAgain, the same rule as addLead, and that audit row is merged.
  • Visitors with only a phone: they are accepted, because the issue says "email and/or phone".
  • Audit: one row per lead, plus one row for a refused or invalid sheet.
  • Thank-you draft: openHouseDraft in src/drafts.ts, passed through a new optional openHouse argument on insertLead in src/leads.ts. It names the address, and nothing is sent until the agent approves.
  • Intake helpers: emailIn, phoneIn and CONTROL in src/intake.ts are now exported for reuse.
  • Desk: an "Open house sign-ins" card with the address and a textarea. "Read the sheet" shows each line as read or "Cannot read … left out", with an "Add N to the desk" button. The text is escaped.
  • JSON API: POST /leads/signins/preview and POST /leads/signins answer 201, 422 or 401, and both are in the regenerated contract/openapi.json.
  • MCP: preview_sign_ins and add_sign_ins.
  • Terminal: o asks for the address, takes the pasted sheet, ctrl-d shows the preview, and y adds.
  • Tests and README: src/signins.test.ts covers parsing, the dedupe, the address in the draft, the limit, an anon refusal, MCP, the terminal and HTTP. The contract door test and the tool list in src/server.test.ts are updated. The README tour gains step 11 and a "How it works" paragraph.

Policy: contract.json is unchanged. Both new actions use the existing lead create: user cell.

What I chose not to do

  • A line with extra text, such as "Jane Smith, [email protected], 2 adults", is marked unreadable rather than guessed at. The preview shows it and the confirm leaves it out.
  • A returning visitor gets the generic answer draft that a returning lead already gets. It is not a thank-you.
  • I added no dependencies.

To try it: sign in, open "Open house sign-ins" on the desk, enter 12 Example St, paste a few lines like Priya Raman, [email protected], (206) 555-0101, add a junk line, and press "Read the sheet". Then press "Add".

Closes #81

1 earlier comment · 1 event
commented

After an open house, the agent can paste the sign-in sheet on the desk. Each readable line becomes a lead with a thank-you draft for that address. All of bun test passes except one flaky test. src/live.test.ts ("a write from another process on the same file reaches the bus") failed once in the full run and passes on its own. I did not run bun x tsc --noEmit, because there is no tsconfig or node_modules here, and I did not try the running app.

What moved where

  • src/signins.ts (new): readSignIns reads one visitor per line, split by tabs or commas, in any order, with quoted cells allowed. A line it can't read is marked with a reason and its line number instead of being guessed. Reasons include no name, no email or phone, two emails, two phones, or extra text. The limits are 100 lines and 20,000 characters.
  • src/actions.ts: previewSignIns writes nothing. addSignIns re-reads the sheet itself and does not trust the preview.
  • New leads: each gets source open_house and consent off. The message is "Signed in at the open house at <address>."
  • Dedupe: a visitor whose email or phone matches an existing lead goes through findMatch and writeInAgain, the same rule as addLead, and that audit row is merged.
  • Visitors with only a phone: they are accepted, because the issue says "email and/or phone".
  • Audit: one row per lead, plus one row for a refused or invalid sheet.
  • Thank-you draft: openHouseDraft in src/drafts.ts, passed through a new optional openHouse argument on insertLead in src/leads.ts. It names the address, and nothing is sent until the agent approves.
  • Intake helpers: emailIn, phoneIn and CONTROL in src/intake.ts are now exported for reuse.
  • Desk: an "Open house sign-ins" card with the address and a textarea. "Read the sheet" shows each line as read or "Cannot read … left out", with an "Add N to the desk" button. The text is escaped.
  • JSON API: POST /leads/signins/preview and POST /leads/signins answer 201, 422 or 401, and both are in the regenerated contract/openapi.json.
  • MCP: preview_sign_ins and add_sign_ins.
  • Terminal: o asks for the address, takes the pasted sheet, ctrl-d shows the preview, and y adds.
  • Tests and README: src/signins.test.ts covers parsing, the dedupe, the address in the draft, the limit, an anon refusal, MCP, the terminal and HTTP. The contract door test and the tool list in src/server.test.ts are updated. The README tour gains step 11 and a "How it works" paragraph.

Policy: contract.json is unchanged. Both new actions use the existing lead create: user cell.

What I chose not to do

  • A line with extra text, such as "Jane Smith, [email protected], 2 adults", is marked unreadable rather than guessed at. The preview shows it and the confirm leaves it out.
  • A returning visitor gets the generic answer draft that a returning lead already gets. It is not a thank-you.
  • I added no dependencies.

To try it: sign in, open "Open house sign-ins" on the desk, enter 12 Example St, paste a few lines like Priya Raman, [email protected], (206) 555-0101, add a junk line, and press "Read the sheet". Then press "Add".

Changes requested — before the latest push

One high finding, plus test gaps.

  1. HIGH (fix first): addSignIns in src/actions.ts ends with ok({ id: (added[0] ?? again[0])!.id, ... }). readSheet only checks that some line has no problem. The loop then applies contactProblem and can skip every line, for example when the email or phone fails that stricter check. Then added and again are both empty and undefined.id throws, so the call is a 500 on the page, API, MCP and terminal. It also leaves no audit row. Fix: if nothing was added or merged, return fail("invalid", ...) naming the skipped lines, and audit that refusal. Alternatively, run contactProblem inside readSheet so the preview and the 422 agree with what will be added. Today the preview can say 'Add N' for lines that add will then skip. Add a test with lines that pass readLine but fail contactProblem.
  1. Tests don't prove what their names say.

- 'a long address is kept out of a text rather than cutting it' only checks refused addresses. Nothing exercises the openHouseDraft text-channel fallback. Add a test with a phone-only visitor and a long address, and one with a normal address that checks the text draft names the address. - The dedupe test uses phone || "206-555-0101" as a fallback, so the match-by-phone case isn't pinned. Add a lead with a known phone and sign in a different name with the same phone. - No test covers 'over 20,000 characters' or an anon post to the preview route over HTTP.

  1. Minor cleanup. src/pages/desk.ts imports MAX_ADDRESS from showings.ts in a separate line from the existing showings import. Merge the two. The README paragraph says 'most 100 lines and 20,000 characters (422 otherwise)'; that is accurate.

No cell in contract.json is loosened, and both actions ask permit for lead create. The contract door row is present, and the terminal and MCP doors exist. I judged the rest from the diff and did not exercise the preview.

commented

I've pushed fixes for the review's high finding and the test gaps; bun test passes in full (399 tests). I did not run bun x tsc --noEmit, because there is no tsconfig or node_modules in this clone.

The high finding. readSheet in src/actions.ts now applies the same contactProblem check that adding uses, and marks failing lines with that reason. So:

  • The preview's "Add N" counts only what will actually be added.
  • A sheet where every line fails that check is a 422 ("No line could be read…"), audited like any other invalid sheet.
  • The undefined.id crash can't happen, because addSignIns only runs the loop when at least one line is readable. I removed the now-redundant check inside the loop.
  • A test uses 555+123+4567, which passes readLine but fails the contact check. It covers an all-bad sheet (preview and add both 422, nothing added) and a mixed sheet (one added, one skipped).

Tests added

  • A different name with the same phone lands on the existing lead, with no fallback number.
  • A sheet over 20,000 characters is a 422 that names the limit.
  • An anon post to /leads/signins/preview over HTTP gets a 401.

Where I differ on the text-channel request. The text fallback in openHouseDraft could never run. An address is at most 200 characters, so the longest text draft is about 300, well under the 480 limit. A sign-in also never carries consent, so a phone-only visitor's draft is always an email. I deleted the dead fallback, per my own rule on dead code. Instead:

  • A direct test of openHouseDraft with consent shows the text names the address, including a 200-character one, and stays within the limit.
  • A phone-only visitor test confirms the draft is an email naming the address.

Cleanup. The desk.ts showings imports are merged into one line.

Approved

Round 2: the earlier high finding (preview and add disagreeing on contactProblem, and the crash on an all-bad sheet) is fixed. readSheet now applies the stricter check to both, an all-bad sheet is a 422, and tests cover the all-bad and mixed cases. The text-fallback ask is answered reasonably: the address is capped at 200 characters, so the draft always fits, and a test pins that. Both actions go through permit on the existing lead create cell with no contract.json change. The terminal door has the same gate. Input is escaped on the page. A door test row is present. Non-blocking: tsc could not be run here because the clone has no tsconfig. The tests are green per the builder.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs