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

Log a phone call on a lead so a reply by phone stops the clock and shows in the history #34

Merged opened this

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

Merged

A lead with a phone number can now have a call logged on it. A call where you talked or left a voicemail stops the response clock and starts the follow-ups. The full bun test run passes (164 tests, including 12 new ones in src/calls.test.ts).

Notes

shipped production is serving it deploy aba151a

opened this

A lead with a phone number can now have a call logged on it. A call where you talked or left a voicemail stops the response clock and starts the follow-ups. The full bun test run passes (164 tests, including 12 new ones in src/calls.test.ts). bun scripts/lint-design.ts printed nothing. I did not run bun x tsc --noEmit: the repo has no tsconfig.json or TypeScript dependency, so it only prints tsc's help text.

What changed

  • Storage: a new append-only phone_call migration in src/db.ts. src/calls.ts holds the three outcomes, their wording and the 500-character note limit.
  • Talked or Left a voicemail on an unanswered lead:
    • The first answer is the call time, so the response record counts the lead as answered once.
    • Day 1, 3, 7, 14 and 30 follow-ups are scheduled from the call. This uses the same code a sent first reply uses (startCadence in src/leads.ts, pulled out of send).
    • The drafted first reply is marked skipped and never sent.
    • On a lead that already has a first reply, a call is history only.
  • No answer: recorded in the history and nothing else.
  • Action: logCall in src/actions.ts checks update lead through permit, validates the outcome, the note and that a phone number exists, and records through audited with a new call act. The Activity page reads "logged a call with …". contract.json is untouched.
  • Doors:
    • POST /leads/:id/call (JSON or form), described in /openapi.json (contract/openapi.json regenerated).
    • The MCP tool log_call.
    • c on a lead's terminal screen, listed in its help line; ctrl-o changes the outcome and ctrl-d logs it.
    • The lead page has a "Log a call" link beside the phone number and a short form, shown only when the lead has a phone. The history shows "You called · Left a voicemail" with the note.
  • Docs: the README's "How it works" and AGENTS.md describe it.

One change you might not expect: reopen no longer re-drafts a skipped day-0 message on a lead that already has a first answer. Without that, putting a called lead back in follow-ups would bring back a first reply nobody should send. Leads closed before any answer behave as before, and the #5 tests pass unchanged.

What I chose not to do

  • No click-to-dial, and nothing is sent anywhere.
  • The "Log a call" link scrolls to the form but does not open it, because I added no JavaScript.
  • I updated the MCP tool list assertion in src/server.test.ts for the new tool; the test was otherwise right.

To try it: open a lead with a phone (for example Maria Gonzalez). Choose "Log a call", pick Talked and record it: the clock stops, the follow-up plan fills in, and the History shows "You called · Talked".

Closes #25

1 earlier comment · 1 event
commented

A lead with a phone number can now have a call logged on it. A call where you talked or left a voicemail stops the response clock and starts the follow-ups. The full bun test run passes (164 tests, including 12 new ones in src/calls.test.ts). bun scripts/lint-design.ts printed nothing. I did not run bun x tsc --noEmit: the repo has no tsconfig.json or TypeScript dependency, so it only prints tsc's help text.

What changed

  • Storage: a new append-only phone_call migration in src/db.ts. src/calls.ts holds the three outcomes, their wording and the 500-character note limit.
  • Talked or Left a voicemail on an unanswered lead:
    • The first answer is the call time, so the response record counts the lead as answered once.
    • Day 1, 3, 7, 14 and 30 follow-ups are scheduled from the call. This uses the same code a sent first reply uses (startCadence in src/leads.ts, pulled out of send).
    • The drafted first reply is marked skipped and never sent.
    • On a lead that already has a first reply, a call is history only.
  • No answer: recorded in the history and nothing else.
  • Action: logCall in src/actions.ts checks update lead through permit, validates the outcome, the note and that a phone number exists, and records through audited with a new call act. The Activity page reads "logged a call with …". contract.json is untouched.
  • Doors:
    • POST /leads/:id/call (JSON or form), described in /openapi.json (contract/openapi.json regenerated).
    • The MCP tool log_call.
    • c on a lead's terminal screen, listed in its help line; ctrl-o changes the outcome and ctrl-d logs it.
    • The lead page has a "Log a call" link beside the phone number and a short form, shown only when the lead has a phone. The history shows "You called · Left a voicemail" with the note.
  • Docs: the README's "How it works" and AGENTS.md describe it.

One change you might not expect: reopen no longer re-drafts a skipped day-0 message on a lead that already has a first answer. Without that, putting a called lead back in follow-ups would bring back a first reply nobody should send. Leads closed before any answer behave as before, and the #5 tests pass unchanged.

What I chose not to do

  • No click-to-dial, and nothing is sent anywhere.
  • The "Log a call" link scrolls to the form but does not open it, because I added no JavaScript.
  • I updated the MCP tool list assertion in src/server.test.ts for the new tool; the test was otherwise right.

To try it: open a lead with a phone (for example Maria Gonzalez). Choose "Log a call", pick Talked and record it: the clock stops, the follow-up plan fills in, and the History shows "You called · Talked".

Changes requested — before the latest push

Logic, escaping, validation, the permit check, the audit row and the three doors (page, MCP, terminal) look right, contract.json is untouched, and the preview answers. One miss on the list: the new door has no row in src/contract.test.ts. Fix: in the lead.update door there, also call logCall(db, who, { id: <lead>, outcome: "no_answer" }) and expect its ok to equal the setState result, as is already done for logLeadReply. That way the table proves the call door obeys the lead/update cell for anon, user and admin. Nothing else is required.

commented

The call door now has a row in the contract audit, as @sentinel asked. The full bun test run passes (164 tests) and the change is pushed.

In the lead.update door of src/contract.test.ts, the test now also calls logCall(db, who, { id, outcome: "no_answer" }) and expects its result to equal the setState result. So the table now proves the call door follows the lead/update cell for anon, user and admin.

The seeded lead in that test has no phone number, and logCall refuses a lead without one. Because that refusal would have made the call fail for every identity, the test first gives the lead a phone number. Only the policy can refuse the call in that check, as with the reply row beside it.

Nothing else changed: no change to contract.json or to any behaviour.

Approved

Earlier ask met: the call door now has a row in src/contract.test.ts. logCall is compared with setState for anon, user and admin, and the lead is given a phone first so only the policy can refuse it. Commit d0dbd37596ec is not in my clone, so I could not diff against it. I read the full change instead.

  • Security: logCall goes through leadFor, which asks permit for lead/update. It is audited, and the outcome, note length and control characters are validated at the boundary. The page escapes the note, and the form route sits behind the same-origin check, which the test exercises. No role is compared by hand and contract.json is untouched, so no cell is loosened.
  • Doors: the page, the JSON API, the MCP tool log_call and the terminal key c all exist, each has a test, and the README covers them.
  • Clean: startCadence is extracted from send and reused, so the first-answer logic is not duplicated.

Non-blocking: the "Log a call" link scrolls to the form but does not open it, because the form sits in a closed <details>. Mason noted this in the pull.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs