Public: anyone can read this; the crew can change it.
Keep a private note on a lead (budget, timing, what they want) that shows at the top of their page and never goes to the lead #49
Check · Review · Land · Live done — Landed and live in production.
A lead now has a private "Your note" card at the top of its page. The full bun test run passes (232 tests, including the new src/notes.test.ts) and bun scripts/lint-design.ts is clean.
shipped production is serving it deploy aba151a
3 earlier comments · 1 event
A lead now has a private "Your note" card at the top of its page. The full bun test run passes (232 tests, including the new src/notes.test.ts) and bun scripts/lint-design.ts is clean. bun x tsc --noEmit could not run: the repo has no tsconfig or typescript dependency, so it printed tsc's help instead of checking types. I did not start the app and try it by hand.
What changed
- Storage:
noteandnote_updated_atare two appended migrations insrc/db.ts, so existing leads keep their data. The lead's JSON returns them asnoteandnoteUpdatedAt. - Action:
setNoteinsrc/actions.tstrims the note and refuses text over 2,000 characters, control characters and non-text with a 422, changing nothing. An empty note clears it. It askspermitfor lead update, works in any state, and writes one audit row with the old and new note only when the note actually changed. Anonymous callers get the usual 401. - Page: the "Your note" card shows the note, escaped, with its last-edited time. The edit form appears only when
permitallows it. With no note and no permission the card is omitted. - Desk:
- Row: the note's first line, cut to 80 characters and escaped, shows under the lead's name.
- Search:
qalso matches note text. I changed the search placeholder, aria-label and terminal hint to say so. - Style: a small
.note-linerule instatic/app.css.
- Other doors:
PATCH /leads/:idwith{"note": …}andPOST /leads/:id/note(form or JSON).- A
set_noteMCP tool. non the terminal's lead screen, with ctrl-d to save.- The same-origin door refuses cross-origin POSTs, and
contract/openapi.jsonis re-emitted.
- Activity: the Activity page reads "changed the private note on …", with the old and new text.
- Sample data: Aisha Bello and Marcus Lee each get a realistic note.
- README: "How it works" gains a paragraph on notes, saying they are private to the agent.
Not sent to the lead: nothing in the draft code reads the note. A test shows a lead with a note gets drafts identical to one without, and that the note's text does not appear in any message after a details edit and a send.
Choices and caveats
- No contract change: no cell in
contract.jsonchanged; lead update is alreadyuser. - 403 case:
anonis the only identity belowuser, so "no update permission" gets 401 (sign-in required) rather than 403. I tested the no-form page by rendering it withmayUpdatefalse. - PATCH: it now takes one change at a time (state, details or note) and returns 422 if you send more than one.
- Desk file: in
src/pages/desk.tsI touched only the lead row and the search form's text, so it should not collide with #36's CSV link. - Migration test: I extended the existing migration-twice test in
src/db.test.ts, because the two newADD COLUMNmigrations cannot be run twice. - Left out: the note is not in the CSV export, since the issue did not ask for it and the export may be forwarded.
To try it, open any lead's page, save a note, then check the desk row, search for a word from the note, and read the Activity page as an admin.
🤖 Generated with Claude Code
Mostly good, but two things need fixing in one round.
- (fix first) The new door has no row in src/contract.test.ts. Notes are a new write, through setNote, POST /leads/:id/note, PATCH {note} and MCP set_note. The table test checks every lead-update door per role (it does so for editLead), and this one is missing. Add a setNote check beside editLead, for each identity and each lead state, expecting the same outcome as the table's lead update cell.
- src/pages/desk.ts imports ResponseRecord and View as values. Make them
typeimports, as they were.
Smaller points: the note renders in a <p class="body">, so line breaks collapse on the page (add white-space: pre-wrap to the class). Also, tsc could not run, so types are unchecked.
No contract.json cell is loosened. Not verified: I did not exercise the preview.
I pushed all three fixes to the same branch. The full bun test passes (232 tests) and bun scripts/lint-design.ts is clean. I did not exercise the preview.
- Contract door:
src/contract.test.tsnow checks the note door besideeditLead, for every identity. It callssetNoteand the MCPset_notetool on an open lead, then forces the lead tolostand callssetNoteagain. Each outcome must equal the table's lead-update result. The HTTP routes (POST /leads/:id/note,PATCH {note}) are not in the table test; they call the same action. - Imports: in
src/pages/desk.ts,ResponseRecordandViewaretypeimports again. - Line breaks: I disagree that they collapse.
.bodyis alreadywhite-space: pre-line, which keeps newlines, so<p class="body">shows them as written. I added.note .body { white-space: pre-wrap; }anyway so the note also keeps indentation and repeated spaces. It is scoped to the note card, so other uses of.bodyare unchanged. - Types:
tscstill cannot run because the repo has no tsconfig or typescript dependency. Types are unchecked beyond whatbun testloads.
No contract.json cell changed.
🤖 Generated with Claude Code
I merged main into the branch, resolved the six conflicts and pushed. The full bun test run passes (262 tests) and bun scripts/lint-design.ts is clean. bun x tsc --noEmit still can't run because the repo has no tsconfig.
All six conflicts kept both sides:
src/audit.ts: the act list now holdsopenersfrommainand mynoted, each in the act list and in the doc comment.src/db.tsandsrc/db.test.ts: both migrations are kept,main'sprofile.openersfirst and my twoleadnote columns after it. The run-twice test drops both sets of columns.src/pages/desk.tsandsrc/routes.ts: I combined the imports.main'sintakeimport andNewLeadtype stay alongside mynoteLine,MAX_LEAD_NOTEandtypeimports.src/terminal.ts:main'sv(paste a lead email) key andpasteview stay. The desk hint now reads "find by name, email, phone or note". Mynnote key is on the lead screen, so it doesn't clash withn(log a lead) on the desk.
🤖 Generated with Claude Code
The preview failed because merging main changed the order of the migrations after the preview's database had already run mine. I've fixed it and pushed. Full bun test passes (263 tests). I haven't seen the preview redeploy yet.
- Cause: the preview database had run my two note-column migrations at positions where
main'sprofile.openersmigration now sits. After the merge, its recorded version made the app re-runADD COLUMN note_updated_atand crash with "duplicate column name". The same shift meantopenerswould have been skipped on that database. - Fix in
src/db.ts:migratenow skips anALTER TABLE … ADD COLUMNwhen the table already has that column. I also appended a finalADD COLUMN openersmigration, which does nothing whereveropenersexists and adds it to the preview's database. - Production: it is unaffected. It has only run
main's migrations, so it picks up the note columns normally and skips the extraopenersstep. - Test:
src/db.test.tscovers both cases — a database missingopenerswith its version past the notes, and a column that is already there.
🤖 Generated with Claude Code
Approved. Since my last review the only new work is the migration fix: migrate skips an ADD COLUMN whose column already exists, a trailing openers migration repairs the preview database, and src/db.test.ts covers both cases. The regex reads only static migration SQL, so no user text reaches it. The earlier asks (contract-door row for the note, type imports, line breaks) are met. The preview answers 200 for /. I could not diff against 7a8e5e04e887 because the clone lacks that commit, so I read the change as given.
Non-blocking: bun x tsc --noEmit cannot run because the repo has no tsconfig.
A lead now has a private "Your note" card at the top of its page. The full
bun testrun passes (232 tests, including the newsrc/notes.test.ts) andbun scripts/lint-design.tsis clean.bun x tsc --noEmitcould not run: the repo has no tsconfig or typescript dependency, so it printed tsc's help instead of checking types. I did not start the app and try it by hand.What changed
noteandnote_updated_atare two appended migrations insrc/db.ts, so existing leads keep their data. The lead's JSON returns them asnoteandnoteUpdatedAt.setNoteinsrc/actions.tstrims the note and refuses text over 2,000 characters, control characters and non-text with a 422, changing nothing. An empty note clears it. It askspermitfor lead update, works in any state, and writes one audit row with the old and new note only when the note actually changed. Anonymous callers get the usual 401.permitallows it. With no note and no permission the card is omitted.qalso matches note text. I changed the search placeholder, aria-label and terminal hint to say so..note-linerule instatic/app.css.PATCH /leads/:idwith{"note": …}andPOST /leads/:id/note(form or JSON).set_noteMCP tool.non the terminal's lead screen, with ctrl-d to save.contract/openapi.jsonis re-emitted.Not sent to the lead: nothing in the draft code reads the note. A test shows a lead with a note gets drafts identical to one without, and that the note's text does not appear in any message after a details edit and a send.
Choices and caveats
contract.jsonchanged; lead update is alreadyuser.anonis the only identity belowuser, so "no update permission" gets 401 (sign-in required) rather than 403. I tested the no-form page by rendering it withmayUpdatefalse.src/pages/desk.tsI touched only the lead row and the search form's text, so it should not collide with #36's CSV link.src/db.test.ts, because the two newADD COLUMNmigrations cannot be run twice.To try it, open any lead's page, save a note, then check the desk row, search for a word from the note, and read the Activity page as an admin.
🤖 Generated with Claude Code
Closes #39