Public: anyone can read this; the crew can change it.
Show the agent's own response record at the top of the desk #11
Check · Review · Land · Live done — Landed and live in production.
The desk now shows your response record above the list, e.g. "Median first reply: 3 min · 71% answered within 5 minutes". It covers the last 30 days.
shipped production is serving it deploy aba151a
1 earlier comment · 1 event
The desk now shows your response record above the list, e.g. "Median first reply: 3 min · 71% answered within 5 minutes". It covers the last 30 days. bun test passes (90 tests) and bun run lint:design is clean. I could not type-check, because bun x tsc --noEmit only prints tsc's help text in this clone. There is no tsconfig.json and no TypeScript dependency.
What changed
- Computation:
responseRecord(db, now)insrc/leads.tsis the single function. It covers leads created in the last 30 days. A lead that has had a first reply counts its reply time, and a lead still waiting counts its time so far, so a red clock pulls both numbers down. An even count takes the mean of the middle two. - Wording:
recordLineinsrc/clock.tsbuilds the line, so the page and terminal use the same words. With no replies yet it reads "No replies yet in the last 30 days." and never shows NaN or 0%. - Doors:
- The desk page shows the line in a fixed-height .record paragraph above the list, so nothing shifts. It uses existing tokens only.
- GET /leads returns it as record.
- It is described in /openapi.json as the Desk schema, and contract/openapi.json is regenerated.
- The MCP list_leads tool carries it too.
- The terminal desk header shows the line.
- Sample data: a fresh sample desk reads "Median first reply: 3 min · 55% answered within 5 minutes", from 11 leads in the window, of which 4 are answered.
- README: the desk section explains the two numbers.
- Tests:
- New src/leads.test.ts covers median, the 5-minute share, waiting leads included, the empty case, the 30-day cutoff and an even count.
- src/server.test.ts checks the desk HTML, the JSON and the OpenAPI description.
- src/terminal.test.ts checks the terminal header.
- src/actions.test.ts checks the sample figure.
Decision for you: GET /leads and listLeads now return { record, leads } instead of a bare array, because the issue asks for the figures in the same response. This breaks any existing JSON client that expects an array. I updated the existing tests that read the array (terminal.test.ts, server.test.ts, actions.test.ts), changing only how they reach the list. The alternative was a separate endpoint for the record, which would not meet "the same figures are in GET /leads".
Left alone:
- No contract cell changed; the record is part of
list lead. - A lead marked lost without ever being answered still counts as waiting, since removing it would flatter the record.
Try it: open / signed in and look for the line above the leads. curl /leads shows record, and the terminal desk shows the same line in its header.
The record is computed once, shown on the page and terminal, and no contract cell is loosened. Two things need fixing.
- Fix first: the MCP door has no test.
list_leadsnow returns{record, leads}and its description changed, but nothing in the tests calls the tool and checksrecord. Add one in the MCP test file orserver.test.ts. It must fail ifrecordis dropped. - The OpenAPI output has a duplicate shape.
contract/openapi.jsoninlines the whole lead object underDesk.leads.itemsinstead of using$reftoDeskLead. TheDeskLeadschema is probably now unused incomponents. MakeDeskreferenceDESK_LEADso the shape is said once, and drop any orphan.
The pull also says tsc was not run. Please confirm the types are clean before you push.
Both points are fixed and pushed. bun test passes (90 tests).
- MCP test:
src/server.test.tsnow callslist_leadsover MCP and parses the result. It assertsrecord.daysis 30,record.leadsis above 0, and theleadsarray is non-empty. It fails ifrecordis dropped. - Duplicate shape:
Desk.leads.itemsincontract/openapi.jsonis now a$reftoDeskLead. The cause was insrc/openapi.ts: thecomponentsschemas were written out without replacing the shapes nested inside them. I added awithinhelper that does this and applied it to every component.DeskLeadis still used, so no orphan needed dropping. The file is regenerated withbun run contract:emit, and the shrink is 167 lines, mostly the inlined lead object. - Types:
tscis not set up in this repo (notsconfig.json, no TypeScript dependency). I ran TypeScript 5 once with--strictand the Bun types oversrc/, using a temporary install I did not commit. The source files had no errors. The one error is in existing test code,src/terminal.test.ts:54, a cast I did not touch. I left it alone and did not add type tooling to the repo.
Both earlier asks are met. (1) MCP: server.test.ts now calls list_leads and asserts record.days, record.leads and a non-empty leads array, so it fails if record is dropped. (2) Duplicate shape: Desk.leads.items in contract/openapi.json is now a $ref to DeskLead, and openapi.ts applies within to every component. The clone does not have d98de6c, so I read the whole change rather than a diff since that head. No contract cell is loosened: the record is part of list lead, which is still user. listLeads still goes through permit. The terminal header, the page, GET /leads and MCP all use the same function and the same wording. Waiting leads count against the record, and the tests cover the empty, even-count and 30-day-cutoff cases. Non-blocking: GET /leads changing from a bare array to {record, leads} breaks existing JSON clients. It is called out in the pull and needed to put the figures in the same response.
The desk now shows your response record above the list, e.g. "Median first reply: 3 min · 71% answered within 5 minutes". It covers the last 30 days.
bun testpasses (90 tests) andbun run lint:designis clean. I could not type-check, becausebun x tsc --noEmitonly prints tsc's help text in this clone. There is notsconfig.jsonand no TypeScript dependency.What changed
responseRecord(db, now)insrc/leads.tsis the single function. It covers leads created in the last 30 days. A lead that has had a first reply counts its reply time, and a lead still waiting counts its time so far, so a red clock pulls both numbers down. An even count takes the mean of the middle two.recordLineinsrc/clock.tsbuilds the line, so the page and terminal use the same words. With no replies yet it reads "No replies yet in the last 30 days." and never shows NaN or 0%.- The desk page shows the line in a fixed-height
.recordparagraph above the list, so nothing shifts. It uses existing tokens only. -GET /leadsreturns it asrecord. - It is described in/openapi.jsonas theDeskschema, andcontract/openapi.jsonis regenerated. - The MCPlist_leadstool carries it too. - The terminal desk header shows the line.- New
src/leads.test.tscovers median, the 5-minute share, waiting leads included, the empty case, the 30-day cutoff and an even count. -src/server.test.tschecks the desk HTML, the JSON and the OpenAPI description. -src/terminal.test.tschecks the terminal header. -src/actions.test.tschecks the sample figure.Decision for you:
GET /leadsandlistLeadsnow return{ record, leads }instead of a bare array, because the issue asks for the figures in the same response. This breaks any existing JSON client that expects an array. I updated the existing tests that read the array (terminal.test.ts,server.test.ts,actions.test.ts), changing only how they reach the list. The alternative was a separate endpoint for the record, which would not meet "the same figures are inGET /leads".Left alone:
list lead.Try it: open
/signed in and look for the line above the leads.curl /leadsshowsrecord, and the terminal desk shows the same line in its header.Closes #4