Public: anyone can read this; the crew can change it.
The response record says how fast each lead source was answered #52
Check · Review · Land · Live done — Landed and live in production.
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.
shipped production is serving it deploy aba151a
2 earlier comments · 1 event
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):responseRecordstill 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 isrecord.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 newsourceLinebuilds 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 /leadscarriesrecord.by_source. The OpenAPI schema describes it and lists it as required. The MCPlist_leadstool 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.
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.
The feature works as the issue asks and no contract cell is loosened. Two changes are needed before it lands:
- 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.mapline insrc/terminal.tsis removed. The pull description says this was skipped on purpose, but box 4 and "every behaviour has a test" both require it. responseRecordgroups withgroups.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. Useget, create the array if missing, andpush.
Minor: the test uses as never for the hostile source. Prefer a typed cast that keeps the intent visible.
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.tsrenders the terminal desk. It expects everysourceLineof the record'sby_sourcerows on screen. I commented out the...by_source.mapline insrc/terminal.tsand the test failed. I restored the line afterwards. - Grouping:
responseRecordinsrc/leads.tsnow 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.tsnow usesas unknown as Sourceinstead ofas never.
No behaviour, contract cell or dependency changed.
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.
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 --noEmitbecause the repo has no tsconfig, so there was nothing to check. The repo has noscripts/gate.ts, and I didn't runscripts/design-lint.ts, so I can't say whether that lint would flag the new class.src/leads.ts):responseRecordstill 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 isrecord.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.src/clock.ts): the newsourceLinebuilds the line and is used by both the page and the terminal. The median reads as m:ss, and "1 lead" is singular.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.src/routes.ts,src/mcp.ts):GET /leadscarriesrecord.by_source. The OpenAPI schema describes it and lists it as required. The MCPlist_leadstool returns it too, and its description now mentions it.GET /leads.I changed no contract cells and added no dependencies. I didn't add a terminal-specific test; the terminal uses the same
sourceLineas the page.To try it, open the desk and read the lines under "Median first reply…". The same data is in
GET /leadsunderrecord.by_source.Closes #32