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

The agent chooses the days their follow-ups go out (default 1, 3, 7, 14, 30) from their profile, and new leads follow it #75

Merged opened this

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

Merged

An admin can now set the follow-up days on the profile page, and leads answered after the change get their touches on those days. The full bun test run passes (346 tests) and design-lint is clean. I could not run bun x tsc --noEmit: the repo has no tsconfig.json, so tsc only prints its help.

Notes

shipped production is serving it deploy aba151a

opened this

An admin can now set the follow-up days on the profile page, and leads answered after the change get their touches on those days. The full bun test run passes (346 tests) and design-lint is clean. I could not run bun x tsc --noEmit: the repo has no tsconfig.json, so tsc only prints its help. There is no scripts/gate.ts or scripts/fast.ts here.

  • Profile page: a "Follow-up days" field shows 1, 3, 7, 14, 30 until changed. Everyone signed in can read it; saving it goes through the existing permit(profile, update), so only an admin can. No cell of contract.json changed.
  • Validation: readCadence in src/actions.ts accepts 1 to 8 whole days, each 1–90, strictly increasing. It takes text from the form (1, 3, 7) or a list from the API.

- Anything else is refused with a plain-English message and nothing changes. The JSON API returns 422. - The form's refusal is a redirect back to /profile with the message shown, the same way the profile form already reports errors. The typed value is not kept.

  • Storage: a new nullable cadence column on profile (JSON, migration appended) holds the days. Null means the default. They survive a restart.
  • Scheduling: startCadence in src/leads.ts uses the saved days. Leads already in their follow-ups keep their scheduled rows and sent history, because those rows carry their own day numbers. CADENCE stays in src/drafts.ts as the default.
  • Day collisions: the 90-day cap keeps every day clear of the after-showing (500+) and answer (1000+) offsets.
  • Wording for new days: draft() only had text for days 1, 3, 7, 14 and 30, and anything else fell back to the "about a month" wording. A day-2 touch would have said "yesterday" and a day-60 one "about a month". The new wordingDay in src/drafts.ts maps each day to the nearest fitting wording: "yesterday" only for day 1, "about a month" only for 28–45, and the open-ended "still here" wording for later days.
  • Activity: a new audit act cadence reads "changed the follow-up days: follow-up days “1, 3, 7, 14, 30” → “2, 5”". If one save changes both days and openers, it is logged under openers, and the detail still lists both changes.
  • Docs and other doors: README.md "Your profile" explains the field. The OpenAPI schema and the regenerated contract/openapi.json describe it, and MCP set_profile accepts cadence.
  • Tests: src/cadence.test.ts covers the new days, existing leads untouched, a restart, each invalid input, non-admins, Activity wording, wordingDay and MCP. src/server.test.ts covers the form, the 422 and the unchanged state after a refusal.

Not done: the terminal's profile editor does not edit the days. Saving from the terminal leaves them as they are, and the terminal's profile screen doesn't list them.

To try it: sign in as admin, open /profile, set the field to 2, 5, 10 and save. Answer a new lead, and its plan shows days 2, 5 and 10. Leads already in follow-ups are unchanged. Try 3, 3 and the form shows the error.

🤖 Generated with Claude Code

Closes #58

1 earlier comment · 1 event
commented

An admin can now set the follow-up days on the profile page, and leads answered after the change get their touches on those days. The full bun test run passes (346 tests) and design-lint is clean. I could not run bun x tsc --noEmit: the repo has no tsconfig.json, so tsc only prints its help. There is no scripts/gate.ts or scripts/fast.ts here.

  • Profile page: a "Follow-up days" field shows 1, 3, 7, 14, 30 until changed. Everyone signed in can read it; saving it goes through the existing permit(profile, update), so only an admin can. No cell of contract.json changed.
  • Validation: readCadence in src/actions.ts accepts 1 to 8 whole days, each 1–90, strictly increasing. It takes text from the form (1, 3, 7) or a list from the API.

- Anything else is refused with a plain-English message and nothing changes. The JSON API returns 422. - The form's refusal is a redirect back to /profile with the message shown, the same way the profile form already reports errors. The typed value is not kept.

  • Storage: a new nullable cadence column on profile (JSON, migration appended) holds the days. Null means the default. They survive a restart.
  • Scheduling: startCadence in src/leads.ts uses the saved days. Leads already in their follow-ups keep their scheduled rows and sent history, because those rows carry their own day numbers. CADENCE stays in src/drafts.ts as the default.
  • Day collisions: the 90-day cap keeps every day clear of the after-showing (500+) and answer (1000+) offsets.
  • Wording for new days: draft() only had text for days 1, 3, 7, 14 and 30, and anything else fell back to the "about a month" wording. A day-2 touch would have said "yesterday" and a day-60 one "about a month". The new wordingDay in src/drafts.ts maps each day to the nearest fitting wording: "yesterday" only for day 1, "about a month" only for 28–45, and the open-ended "still here" wording for later days.
  • Activity: a new audit act cadence reads "changed the follow-up days: follow-up days “1, 3, 7, 14, 30” → “2, 5”". If one save changes both days and openers, it is logged under openers, and the detail still lists both changes.
  • Docs and other doors: README.md "Your profile" explains the field. The OpenAPI schema and the regenerated contract/openapi.json describe it, and MCP set_profile accepts cadence.
  • Tests: src/cadence.test.ts covers the new days, existing leads untouched, a restart, each invalid input, non-admins, Activity wording, wordingDay and MCP. src/server.test.ts covers the form, the 422 and the unchanged state after a refusal.

Not done: the terminal's profile editor does not edit the days. Saving from the terminal leaves them as they are, and the terminal's profile screen doesn't list them.

To try it: sign in as admin, open /profile, set the field to 2, 5, 10 and save. Answer a new lead, and its plan shows days 2, 5 and 10. Leads already in follow-ups are unchanged. Try 3, 3 and the form shows the error.

🤖 Generated with Claude Code

Changes requested — before the latest push

One change needed (high): the terminal is a door like the page, and it cannot set or show the follow-up days. The pull description says so itself: "the terminal's profile editor does not edit the days ... and the terminal's profile screen doesn't list them." What an admin can do on /profile they must be able to do in src/tty.ts, and a non-admin must see the days there too, as on the page.

Fix, in one round:

  1. src/tty.ts: show the follow-up days on the profile screen. Add a field to the profile editor so an admin can edit them. It must go through the same saveProfile/permit path and readCadence validation, and show the plain-English error on refusal. A save from the terminal must not reset the days. Because the write goes through saveProfile, it emits lead.changed, so web viewers see it live.
  2. Add a tty test: the screen lists the days, an admin edit changes them, a bad list is refused and changes nothing, and a non-admin cannot save.
  3. README: add one line to the "Follow-up days" paragraph saying how to do this in the terminal.

Smaller points, to fix in the same round:

  • When one save changes both the days and the openers, the audit act is recorded as openers, so Activity files the change under the wrong act. Record one row per kind of change, or name the act for what changed.
  • The limits 8 and 90 are written as literals in routes.ts (CADENCE_FIELD) and mcp.ts. Import CADENCE_MAX_TOUCHES and CADENCE_MAX_DAY so the schemas cannot drift from the validator.
  • profile.ts and actions.ts each define a function named readCadence with different jobs. Rename one (for example keptCadence).
  • A refused form save drops what the agent typed. Keep the typed value in the re-rendered field if that is cheap.

Checked and fine: no contract.json cell is loosened; saving goes through permit; the input is validated; the output is escaped; the migration is appended; existing leads keep their scheduled rows; the Activity wording, openapi and MCP are all covered.

commented

I've pushed the fixes for all five review points to the same branch. The full bun test run passes (348 tests) and design-lint is clean. tsc still can't run here because the repo has no tsconfig.json.

  • Terminal: the terminal's code is in src/terminal.ts; src/tty.ts only starts it, so the change is there.

- The p screen now lists "Follow-up days" for everyone who can read the profile. - An admin's e editor gets a final "Follow-up days" step, prefilled with the current days. - Saves go through the same saveProfile and permit path with the same validation, so the plain-English refusal shows and nothing changes. Saving other fields keeps the days. - A non-admin gets "Only an admin can change the profile." A save still emits lead.changed.

  • Terminal tests: the new test in src/terminal.test.ts covers all three cases you asked for:

- the screen lists the days; - an admin edit changes them, and a bad list is refused with nothing changed; - a non-admin cannot save.

  • Existing tests changed: because the new step sits last in the editor, I added one Enter to the two existing editor tests and raised the loop count in the blank-license test. They step through the editor by position, and the behaviour they check is unchanged.
  • Audit: a save that changes both the days and an opening now records two rows, one cadence and one openers, each with only its own detail. A test in src/cadence.test.ts covers this.
  • Limits: routes.ts and mcp.ts import CADENCE_MAX_TOUCHES and CADENCE_MAX_DAY, so the schemas and descriptions follow the validator.
  • Rename: the validator in actions.ts is now parseCadence, and the one in profile.ts is keptCadence.
  • Form refusal: a refused browser save now re-renders /profile with status 422, the message, and what was typed. That covers the profile fields, the days and the openers. JSON requests are unchanged. The server test checks the typed value is kept.
  • README: the "Follow-up days" paragraph now says how to use the days in the terminal.
Approved

Earlier asks are met: the terminal shows and edits the follow-up days through saveProfile/permit, with tests; a refused browser save re-renders the form with 422, the message and what was typed (escaped); one save that changes days and openers is audited as two rows; the validator is parseCadence and the limits are shared. No contract.json cell is loosened. I read the diff and the surrounding route helpers; I did not run the tests or the preview. Non-blocking: the repo has no tsconfig, so tsc cannot run.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs