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

Realtor.com is its own lead source: its leads get their own opener, their own row in the response record, and a sample lead #57

Merged opened this

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

Merged

Realtor.com is now its own lead source. The full test suite passes (267 tests), but I couldn't type-check and didn't run scripts/gate.ts. The repo has no tsconfig.json, so bun x tsc --noEmit only printed its help.

Notes

shipped production is serving it deploy aba151a

opened this

Realtor.com is now its own lead source. The full test suite passes (267 tests), but I couldn't type-check and didn't run scripts/gate.ts. The repo has no tsconfig.json, so bun x tsc --noEmit only printed its help. scripts/gate.ts doesn't exist in this clone. I also didn't run scripts/design-lint.ts or start the app.

What changed

  • Source and opener: realtor_com is a Source in src/drafts.ts with the label "Realtor.com" and a built-in opener, "Thanks for reaching out on Realtor.com". The agent can edit it like the others. The profile page, JSON API, MCP and terminal all take their lists from SOURCES, so each shows and validates it, and an unknown source is still refused.
  • Migration: a new last migration in src/db.ts rebuilds the lead table with realtor_com in the source CHECK. It keeps every row and id, the messages and other tables that point at leads, and the index. The migration is safe to run twice. A new test builds the old schema, adds a lead with a message, migrates, and checks the lead, its id and its message survived and that realtor_com is now accepted.
  • Intake: readLeadEmail returns realtor_com for a Realtor.com notification, and the fixture test now expects that. A source named in the email is also read when it says "Realtor.com" or "realtor_com". The same applies to sourceOf in src/actions.ts, which the web form and API use.
  • Log-a-lead form: it offers Realtor.com.
  • Response record and CSV: both are built from SOURCES, so Realtor.com gets its own row and its own name in the export. I only checked this through the tests that exercise them.
  • Sample leads: Ethan Brooks changed from website to realtor_com, so the sample desk still has 12 leads and now covers 5 sources. I also added a Realtor.com inquiry, Hugo Lindqvist, to the inbound sample list.
  • Docs and contract: README.md lists Realtor.com for both the openers and the API source values. contract/openapi.json is regenerated for the new enum.
  • Tests adjusted:
    • The terminal source picker is numbered, so Realtor.com is now 2. The test that chose "3" for Open house now chooses "4".
    • The profile-editing tests press Enter once more per extra opener field.
    • The sample-desk test now expects 5 sources.
    • The migration-rerun test now finds the openers migration by name, because the rebuild is the last migration, not the openers column.

Not done

  • Existing leads that came in as Realtor.com but were logged as website stay as they are. Nothing in the data says which ones they were.

Try it Run bun test. Then open the desk, choose "Realtor.com" in the add form, and check the response record.

🤖 Generated with Claude Code

Closes #55

2 earlier comments · 1 event
commented

Realtor.com is now its own lead source. The full test suite passes (267 tests), but I couldn't type-check and didn't run scripts/gate.ts. The repo has no tsconfig.json, so bun x tsc --noEmit only printed its help. scripts/gate.ts doesn't exist in this clone. I also didn't run scripts/design-lint.ts or start the app.

What changed

  • Source and opener: realtor_com is a Source in src/drafts.ts with the label "Realtor.com" and a built-in opener, "Thanks for reaching out on Realtor.com". The agent can edit it like the others. The profile page, JSON API, MCP and terminal all take their lists from SOURCES, so each shows and validates it, and an unknown source is still refused.
  • Migration: a new last migration in src/db.ts rebuilds the lead table with realtor_com in the source CHECK. It keeps every row and id, the messages and other tables that point at leads, and the index. The migration is safe to run twice. A new test builds the old schema, adds a lead with a message, migrates, and checks the lead, its id and its message survived and that realtor_com is now accepted.
  • Intake: readLeadEmail returns realtor_com for a Realtor.com notification, and the fixture test now expects that. A source named in the email is also read when it says "Realtor.com" or "realtor_com". The same applies to sourceOf in src/actions.ts, which the web form and API use.
  • Log-a-lead form: it offers Realtor.com.
  • Response record and CSV: both are built from SOURCES, so Realtor.com gets its own row and its own name in the export. I only checked this through the tests that exercise them.
  • Sample leads: Ethan Brooks changed from website to realtor_com, so the sample desk still has 12 leads and now covers 5 sources. I also added a Realtor.com inquiry, Hugo Lindqvist, to the inbound sample list.
  • Docs and contract: README.md lists Realtor.com for both the openers and the API source values. contract/openapi.json is regenerated for the new enum.
  • Tests adjusted:
    • The terminal source picker is numbered, so Realtor.com is now 2. The test that chose "3" for Open house now chooses "4".
    • The profile-editing tests press Enter once more per extra opener field.
    • The sample-desk test now expects 5 sources.
    • The migration-rerun test now finds the openers migration by name, because the rebuild is the last migration, not the openers column.

Not done

  • Existing leads that came in as Realtor.com but were logged as website stay as they are. Nothing in the data says which ones they were.

Try it Run bun test. Then open the desk, choose "Realtor.com" in the add form, and check the response record.

🤖 Generated with Claude Code

Changes requested — before the latest push

The change itself is sound: no cell in contract.json is loosened, input is validated through SOURCES, and the migration rebuilds lead and keeps rows and ids. The missing piece is tests. Several behaviours the issue lists have none that would fail without them.

Fix first: add the tests below.

  1. Box 5: add a test that a Realtor.com lead gets its own row in responseRecord(...).by_source and its own realtor_com value in the CSV export. Nothing asserts either today.
  2. Box 1: add a test that draft() for a realtor_com lead opens with "Thanks for reaching out on Realtor.com". Add another test that an agent-saved realtor_com opener overrides it. The SOURCES loop in openers.test.ts only checks that the form field exists.
  3. Box 4: add a test that sourceOf/readNewLead accepts "realtor_com", "Realtor.com" and "realtor.com", that "trulia" is still refused, and that the refusal message names the new source. The [\s.-] regex change in actions.ts has no test. Add one that the log-a-lead form offers a value="realtor_com" option.
  4. Box 6: add a test that INQUIRIES includes a realtor_com entry. The sample-desk test only counts distinct sources. Ethan Brooks being flipped to realtor_com is not the new inquiry.
  5. Box 3: a source named in the email as "Realtor.com" or "realtor_com" (the said branch in intake.ts) is not tested either. Add one.

Please also run bun x tsc --noEmit, scripts/design-lint.ts (src/pages/desk.ts is touched) and start the app. The pull says none of these were run.

Boxes met on this head: 1 (code only), 2, 3 (fixture test), 7. Boxes 4, 5 and 6 are implemented but untested, so I am leaving them open until the tests exist.

commented

I added the missing tests for Realtor.com as its own lead source in a new file, src/realtor.test.ts (6 tests). The full suite passes (273 tests), the app boots and / answers 200, and bun scripts/lint-design.ts printed nothing. I did not check that the new tests fail without the change.

The new tests cover the five points in the review:

  • Response record and CSV:
    • A Realtor.com lead gets its own row in responseRecord(...).by_source.
    • The CSV export carries realtor_com.
    • The desk shows the line "Realtor.com · 1 lead".
  • Opener: draft() for a realtor_com lead opens with "Thanks for reaching out on Realtor.com". An opener the agent saved overrides it, both in draft() and in a lead added after the profile save.
  • Boundary:
    • sourceOf and readNewLead accept realtor_com, Realtor.com, realtor.com and Realtor-com.
    • trulia is still refused, and the refusal message names realtor_com.
    • The log-a-lead form offers a value="realtor_com" option.
  • Sample inquiries: INQUIRIES includes a realtor_com entry.
  • Source named in the email: Source: Realtor.com and Source: realtor_com both read as realtor_com.

The scripts you named don't match this clone:

  • scripts/design-lint.ts: it doesn't exist. The script here is scripts/lint-design.ts, and that is the one I ran.
  • bun x tsc --noEmit: the repo has no tsconfig.json, so the command only prints tsc's help. I reran with -p . and it printed nothing useful. The type check therefore still hasn't run, and TypeScript errors are only caught if the test run would hit them.
commented

I merged main into the branch and pushed it. All 295 tests pass.

Only src/db.ts and src/db.test.ts conflicted.

  • src/db.ts: main added a migration for message.skipped_by_hand, and my branch added the lead rebuild that accepts realtor_com. I kept both and put the main migration first, so its version number is unchanged for databases that already ran it. The lead rebuild comes after it and doesn't touch message.
  • src/db.test.ts: I kept my version of the openers-migration test. It finds the openers migration by name instead of by its position from the end, so it still works when the list grows.

I didn't re-run bun x tsc --noEmit, which still can't type-check here because the repo has no tsconfig.json.

One run of the suite logged a form-parse error ("incorrect MIME type/boundary") from src/routes.ts. The test that triggers it still passes, and I didn't look into it.

Approved

Approved. The migration rebuilds lead with every row and id kept and recreates its index. A test opens an old-schema database and checks the lead and its message survive. Realtor.com is validated at every door from SOURCES, and an unknown source is still refused. realtor.test.ts covers the new behaviour. I could not diff against my last reviewed head (not in the clone), so I read the full change. The contract is untouched.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs