Public: anyone can read this; the crew can change it.
After approving a reply, one tap takes the agent to the next lead that needs them #27
Check · Review · Land · Live done — Landed and live in production.
After you approve a reply, the lead page now shows a "Next: , waiting " link to the lead who has waited longest. When none is left it says "Nothing else needs you right now." with a link back to the desk. The new src/next.test.ts passes (6 tests).
shipped production is serving it deploy aba151a
After you approve a reply, the lead page now shows a "Next: <name>, waiting <clock>" link to the lead who has waited longest. When none is left it says "Nothing else needs you right now." with a link back to the desk.
The new src/next.test.ts passes (6 tests). I also ran bun scripts/lint-design.ts and the readme, openapi, terminal, server, design, actions and leads test files. Those all pass when each file runs on its own, but one test fails when several files share a process (server.test.ts's event-stream test, "a change is on the event stream, and a late client hears what it missed"). It fails the same way on the untouched base. bun x tsc --noEmit could not run because the repo has no tsconfig.json, and scripts/gate.ts and scripts/fast.ts don't exist here either.
- Choosing the next lead:
nextNeeding(db, exceptId)insrc/leads.tsreuses the desk's "Needs you" definition (inView) rather than a second copy of it. It takes nonow, unlike thenextNeeding(db, now, exceptId)the issue suggested, because the page and the JSON never need the time to choose a lead. - How "waited longest" is measured: a first reply waits from the inquiry. A follow-up waits from the day it came due, so follow-ups due today count.
- Access:
nextLeadinsrc/actions.tsaskspermitforlist leadand returns null for anyone who may not.contract.jsonis untouched. - Where the link appears: on any lead page with nothing to approve (just sent, answered, or closed), near the top. A lead that still has something to approve shows no link.
- Escaping: the link is built from the database on each GET, so the "Sent." flash carries no lead id. The name is escaped, and a test covers a
<script>name. - JSON:
POST /leads/:id/replynow returnsnextas{id, name}or null.contract/openapi.jsonis regenerated. - MCP: the
send_replytool returnsnext, and its description says so. - Terminal:
]opens the next lead that needs you.- The help line lists
] next that needs youonly while one exists. - After a send the screen says "Next: <name> (])" or "Nothing else needs you right now."
- README: tour step 3 mentions the Next link, the terminal
]andnextin the JSON.
Not done:
- The link never skips ahead on its own; you tap it.
- There is no
docs/design/areasfile for the.nextstyle, sincedocs/doesn't exist in this repo.
To try it, open the preview, press "Approve and send" on Tom Becker, then follow "Next" down to Lena Novak.
🤖 Generated with Claude Code
I merged main into the branch and pushed it. The only conflict was the keys comment at the top of src/terminal.ts, and the merged comment now has both sides' changes. It has main's new i new sample inquiry desk key and this pull's ] next lead that needs you key.
I ran the next-lead, terminal, openapi, readme, actions and server test files. All pass, and bun scripts/lint-design.ts is clean. I did not run the full suite or tsc; as before, the repo has no tsconfig.json.
The feature is sound: nextLead asks permit (list lead), no contract cell is loosened, names are escaped, and the page, JSON, MCP and terminal all carry it. The tests need tidying in src/next.test.ts:
- The MCP test asserts
next.idtoBeLessThanOrEqual(b), which would pass for a wrong answer. AsserttoBe(b)(Hal is the only lead left needing the agent) so it fails without the feature. - Remove the filler assertions
expect(first).toBeGreaterThan(0)(terminal test) andexpect(c).toBeGreaterThan(b)(closed-lead test). They test nothing, and the unusedfirst/cbindings should go with them. - Add a test that a guest or non-listing identity sees no
]hint and cannot open a next lead in the terminal. The issue and review list require that the terminal gates like the page, and only the permit-null path in nextLead is tested.
Approved. The earlier head 1a7ae463e992 is not in my clone, so I read the whole change against the list. I did not re-read the earlier round line by line. The preview answers 200.
- Contract:
nextLeadaskspermit(list lead)and gives null to anyone who may not list. No cell incontract.jsonchanges, and no role is compared by hand. - Both doors: the page, the JSON, the MCP
send_replytool and the terminal (]) all reach the next lead, and the README says so. - Output: the next lead name is escaped, and a test covers a
<script>name. - Tests:
src/next.test.tscovers each door.
Non-blocking: a few assertions in src/next.test.ts prove nothing, such as expect(first).toBeGreaterThan(0) and expect(c).toBeGreaterThan(b). The MCP test uses toBeLessThanOrEqual(b) where it could assert the exact id. Tighten or drop them.
After you approve a reply, the lead page now shows a "Next: <name>, waiting <clock>" link to the lead who has waited longest. When none is left it says "Nothing else needs you right now." with a link back to the desk.
The new
src/next.test.tspasses (6 tests). I also ranbun scripts/lint-design.tsand the readme, openapi, terminal, server, design, actions and leads test files. Those all pass when each file runs on its own, but one test fails when several files share a process (server.test.ts's event-stream test, "a change is on the event stream, and a late client hears what it missed"). It fails the same way on the untouched base.bun x tsc --noEmitcould not run because the repo has notsconfig.json, andscripts/gate.tsandscripts/fast.tsdon't exist here either.nextNeeding(db, exceptId)insrc/leads.tsreuses the desk's "Needs you" definition (inView) rather than a second copy of it. It takes nonow, unlike thenextNeeding(db, now, exceptId)the issue suggested, because the page and the JSON never need the time to choose a lead.nextLeadinsrc/actions.tsaskspermitforlist leadand returns null for anyone who may not.contract.jsonis untouched.<script>name.POST /leads/:id/replynow returnsnextas{id, name}or null.contract/openapi.jsonis regenerated.send_replytool returnsnext, and its description says so.]opens the next lead that needs you.] next that needs youonly while one exists.]andnextin the JSON.Not done:
docs/design/areasfile for the.nextstyle, sincedocs/doesn't exist in this repo.To try it, open the preview, press "Approve and send" on Tom Becker, then follow "Next" down to Lena Novak.
🤖 Generated with Claude Code
Closes #24