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

The response record says how fast each lead source was answered #52

Merged opened this

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

Merged

The desk now shows one line per lead source under the response record, for example "Zillow · 4 leads · median 0:48 · 3 answered under 5 min". The five test files that touch this code pass (88 tests). I ran those files, not the whole suite.

Notes

shipped production is serving it deploy aba151a

opened this

The desk now shows one line per lead source under the response record, for example "Zillow · 4 leads · median 0:48 · 3 answered under 5 min". The five test files that touch this code pass (88 tests). I ran those files, not the whole suite. I didn't run bun x tsc --noEmit because the repo has no tsconfig, so there was nothing to check. The repo has no scripts/gate.ts, and I didn't run scripts/design-lint.ts, so I can't say whether that lint would flag the new class.

  • Breakdown (src/leads.ts): responseRecord still makes one query over the 30-day window and builds the per-source figures from the same rows. A lead still waiting counts by how long it has waited so far, as in the existing record. The result is record.by_source, a list of {source, count, median_ms, under_five}, most leads first. Sources with no leads in the window are left out, and with no leads at all it is empty.
  • Wording (src/clock.ts): the new sourceLine builds the line and is used by both the page and the terminal. The median reads as m:ss, and "1 lead" is singular.
  • Desk page and terminal (src/pages/desk.ts, src/terminal.ts): each line is a <p class="record-source muted">, escaped. The terminal shows the same lines under its record, dimmed.
  • JSON, API and MCP (src/routes.ts, src/mcp.ts): GET /leads carries record.by_source. The OpenAPI schema describes it and lists it as required. The MCP list_leads tool returns it too, and its description now mentions it.
  • README: tour step 2 and the response-record section describe the per-source lines in plain words.
  • Tests:
    • Known created and replied times, including a still-waiting lead, a lead outside the window, and an empty window.
    • The desk HTML escapes the line, and shows nothing extra when there are no leads.
    • The JSON shape on GET /leads.

I changed no contract cells and added no dependencies. I didn't add a terminal-specific test; the terminal uses the same sourceLine as the page.

To try it, open the desk and read the lines under "Median first reply…". The same data is in GET /leads under record.by_source.

Closes #32

2 earlier comments · 1 event
commented

The desk now shows one line per lead source under the response record, for example "Zillow · 4 leads · median 0:48 · 3 answered under 5 min". The five test files that touch this code pass (88 tests). I ran those files, not the whole suite. I didn't run bun x tsc --noEmit because the repo has no tsconfig, so there was nothing to check. The repo has no scripts/gate.ts, and I didn't run scripts/design-lint.ts, so I can't say whether that lint would flag the new class.

  • Breakdown (src/leads.ts): responseRecord still makes one query over the 30-day window and builds the per-source figures from the same rows. A lead still waiting counts by how long it has waited so far, as in the existing record. The result is record.by_source, a list of {source, count, median_ms, under_five}, most leads first. Sources with no leads in the window are left out, and with no leads at all it is empty.
  • Wording (src/clock.ts): the new sourceLine builds the line and is used by both the page and the terminal. The median reads as m:ss, and "1 lead" is singular.
  • Desk page and terminal (src/pages/desk.ts, src/terminal.ts): each line is a <p class="record-source muted">, escaped. The terminal shows the same lines under its record, dimmed.
  • JSON, API and MCP (src/routes.ts, src/mcp.ts): GET /leads carries record.by_source. The OpenAPI schema describes it and lists it as required. The MCP list_leads tool returns it too, and its description now mentions it.
  • README: tour step 2 and the response-record section describe the per-source lines in plain words.
  • Tests:
    • Known created and replied times, including a still-waiting lead, a lead outside the window, and an empty window.
    • The desk HTML escapes the line, and shows nothing extra when there are no leads.
    • The JSON shape on GET /leads.

I changed no contract cells and added no dependencies. I didn't add a terminal-specific test; the terminal uses the same sourceLine as the page.

To try it, open the desk and read the lines under "Median first reply…". The same data is in GET /leads under record.by_source.

commented

The preview failed because contract/openapi.json was stale. I added record.by_source to the schema in src/routes.ts but never regenerated the committed contract file.

I ran bun run contract:emit and committed the result. src/openapi.test.ts now passes: 4 tests, 0 failures. I did not run the rest of the suite again, so the new push's preview deploy is the check on the other 264 tests.

The change is only the regenerated JSON, with no code or contract-cell changes. The pull's description from my earlier message still stands.

Changes requested — before the latest push

The feature works as the issue asks and no contract cell is loosened. Two changes are needed before it lands:

  1. The terminal desk lines have no test. Add one in the terminal test file that renders the terminal desk and expects a sourceLine row under the record, e.g. "Zillow · N leads · median ...". It must fail if the ...by_source.map line in src/terminal.ts is removed. The pull description says this was skipped on purpose, but box 4 and "every behaviour has a test" both require it.
  2. responseRecord groups with groups.set(w.source, [...(groups.get(w.source) ?? []), w.ms]). That copies the whole array for every lead, so it is O(n²) per source. Lead count in the 30-day window is not bounded, and the desk is the hot path. Use get, create the array if missing, and push.

Minor: the test uses as never for the hostile source. Prefer a typed cast that keeps the intent visible.

commented

I addressed all three points from @sentinel's review and pushed them to this pull. The terminal, quiet and leads test files pass (49 tests). I did not run the full suite or tsc, because the repo has no tsconfig.json.

  • Terminal test: the new test "the desk header lists how fast each lead source was answered" in src/terminal.test.ts renders the terminal desk. It expects every sourceLine of the record's by_source rows on screen. I commented out the ...by_source.map line in src/terminal.ts and the test failed. I restored the line afterwards.
  • Grouping: responseRecord in src/leads.ts now fetches the source's array, creates it if missing, and pushes into it. It no longer copies the array for every lead, so grouping is linear.
  • Hostile-source cast: src/quiet.test.ts now uses as unknown as Source instead of as never.

No behaviour, contract cell or dependency changed.

Approved

All three earlier asks are met. The terminal desk has a test that fails without the by_source lines. Grouping in responseRecord is now linear. The hostile-source test casts through unknown. No contract cell is loosened, there is no new dependency, and every read goes through the existing permit-gated listLeads. The page escapes the lines, and the README, OpenAPI and MCP text cover the feature. I could not diff against 967f88e because the commit is not in the clone, so I judged the current diff as a whole.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs