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

Merged opened this

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

Merged

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).

Notes

shipped production is serving it deploy aba151a

opened this

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) in src/leads.ts reuses the desk's "Needs you" definition (inView) rather than a second copy of it. It takes no now, unlike the nextNeeding(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: nextLead in src/actions.ts asks permit for list lead and returns null for anyone who may not. contract.json is 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/reply now returns next as {id, name} or null. contract/openapi.json is regenerated.
  • MCP: the send_reply tool returns next, and its description says so.
  • Terminal:
    • ] opens the next lead that needs you.
    • The help line lists ] next that needs you only 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 ] and next in the JSON.

Not done:

  • The link never skips ahead on its own; you tap it.
  • There is no docs/design/areas file for the .next style, since docs/ 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

commented

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) in src/leads.ts reuses the desk's "Needs you" definition (inView) rather than a second copy of it. It takes no now, unlike the nextNeeding(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: nextLead in src/actions.ts asks permit for list lead and returns null for anyone who may not. contract.json is 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/reply now returns next as {id, name} or null. contract/openapi.json is regenerated.
  • MCP: the send_reply tool returns next, and its description says so.
  • Terminal:
    • ] opens the next lead that needs you.
    • The help line lists ] next that needs you only 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 ] and next in the JSON.

Not done:

  • The link never skips ahead on its own; you tap it.
  • There is no docs/design/areas file for the .next style, since docs/ 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

commented

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.

Changes requested

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:

  1. The MCP test asserts next.id toBeLessThanOrEqual(b), which would pass for a wrong answer. Assert toBe(b) (Hal is the only lead left needing the agent) so it fails without the feature.
  2. Remove the filler assertions expect(first).toBeGreaterThan(0) (terminal test) and expect(c).toBeGreaterThan(b) (closed-lead test). They test nothing, and the unused first/c bindings should go with them.
  3. 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

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: nextLead asks permit(list lead) and gives null to anyone who may not list. No cell in contract.json changes, and no role is compared by hand.
  • Both doors: the page, the JSON, the MCP send_reply tool 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.ts covers 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.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs