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

opened this

Merged 24d 4h ago, live in production

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

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

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".

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.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs