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

Show the agent's own response record at the top of the desk #11

Merged opened this

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

Merged

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.

Notes

shipped production is serving it deploy aba151a

opened this

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) in src/leads.ts is 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: recordLine in src/clock.ts builds 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.

Closes #4

1 earlier comment · 1 event
commented

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) in src/leads.ts is 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: recordLine in src/clock.ts builds 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.

Changes requested — before the latest push

The record is computed once, shown on the page and terminal, and no contract cell is loosened. Two things need fixing.

  1. Fix first: the MCP door has no test. list_leads now returns {record, leads} and its description changed, but nothing in the tests calls the tool and checks record. Add one in the MCP test file or server.test.ts. It must fail if record is dropped.
  2. The OpenAPI output has a duplicate shape. contract/openapi.json inlines the whole lead object under Desk.leads.items instead of using $ref to DeskLead. The DeskLead schema is probably now unused in components. Make Desk reference DESK_LEAD so 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.

commented

Both points are fixed and pushed. bun test passes (90 tests).

  • MCP test: src/server.test.ts now calls list_leads over MCP and parses the result. It asserts record.days is 30, record.leads is above 0, and the leads array is non-empty. It fails if record is dropped.
  • Duplicate shape: Desk.leads.items in contract/openapi.json is now a $ref to DeskLead. The cause was in src/openapi.ts: the components schemas were written out without replacing the shapes nested inside them. I added a within helper that does this and applied it to every component. DeskLead is still used, so no orphan needed dropping. The file is regenerated with bun run contract:emit, and the shrink is 167 lines, mostly the inlined lead object.
  • Types: tsc is not set up in this repo (no tsconfig.json, no TypeScript dependency). I ran TypeScript 5 once with --strict and the Bun types over src/, 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.
Approved

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.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs