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

The agent stars the leads they want to keep close, and starred leads lead the desk #87

Merged opened this

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

Merged

The agent can now star a lead, and starred open leads sort first on the desk. I ran bun test (423 pass, 0 fail) and bun run lint:design (clean). There is no scripts/gate.ts, scripts/fast.ts or scripts/design-lint.ts in this repo.

Notes

shipped production is serving it deploy aba151a

opened this

The agent can now star a lead, and starred open leads sort first on the desk. I ran bun test (423 pass, 0 fail) and bun run lint:design (clean). There is no scripts/gate.ts, scripts/fast.ts or scripts/design-lint.ts in this repo. bun x tsc --noEmit can't run because there is no tsconfig. I didn't look at the pages in a browser.

What changed

  • Storage: a new last migration adds lead.starred INTEGER NOT NULL DEFAULT 0 CHECK (0,1). Existing leads stay as they were, unstarred. A test builds a database at the previous version with a lead in it, migrates it, and checks the lead is intact.
  • Action: setStarred in src/actions.ts goes through permit(lead, update) and audited. A bad value gets a 422. Starring an already-starred lead succeeds and changes nothing. contract.json is not touched.
  • Desk: show=starred is a new filter, which holds open starred leads only. starredFirst lifts starred open leads to the top of every view and keeps recency order inside each group.
  • Overdue first replies: a first reply that has waited past the green clock (5 minutes) stays ahead of the stars, so a star never hides a lead who is owed an answer. When nobody is starred, the order is unchanged.
  • Page:

- The star is a form with a button, so it works without JavaScript and goes through the existing same-origin check. - It sits beside each desk row and under the name on a lead's page. A button can't live inside a link, so the row <li class="lead-item"> is now a two-column grid. - The button is 44px square on every screen. - The form's back field is checked against a strict pattern, so it only returns to the desk (with its filter) or the lead's page. - The new classes are documented in docs/design/areas/desk.md.

  • API and CSV:

- starred appears in a lead's JSON. - PATCH /leads/:id accepts {starred: true|false}, and /openapi.json is regenerated. - The CSV gets a starred column, yes or no.

  • MCP and terminal: MCP has a star_lead tool, and list_leads takes show=starred. In the terminal, * stars from the desk and from a lead's screen, f cycles through the Starred view, and starred leads show ★.
  • Activity: it reads "starred …" and "took the star off …", and refused attempts are audited too.
  • Docs: README and AGENTS.md describe the star.
  • Tests: src/star.test.ts covers star/unstar, ordering, the overdue case, anon refused, the CSV column, the migration, and the page, API, MCP and terminal.

Existing tests I changed

  • Tests pinned to the old shape:

- The view counts, the view cycle, the CSV row, and the MCP tool list in server.test.ts needed the new starred view, column and tool. - lost.test.ts read lost_reason as the last CSV column. It now finds it by header name, because starred is the new last column.

  • Appended CSV column: I put starred at the end rather than before lost_reason, so existing consumers keep their column positions.

What I chose not to do

  • Closed leads: they can be starred, but they never lead the desk and are not in Starred.
  • Reordering by hand: a star is a flag, not a ranking.
  • Cadence: the star doesn't touch it, and it doesn't bump updated_at, so lost-lead reporting is unaffected.

To try it: open / and tap ☆ on a row, then try /?show=starred, /leads.csv, and * in the terminal.

🤖 Generated with Claude Code

Closes #82

1 earlier comment · 1 event
commented

The agent can now star a lead, and starred open leads sort first on the desk. I ran bun test (423 pass, 0 fail) and bun run lint:design (clean). There is no scripts/gate.ts, scripts/fast.ts or scripts/design-lint.ts in this repo. bun x tsc --noEmit can't run because there is no tsconfig. I didn't look at the pages in a browser.

What changed

  • Storage: a new last migration adds lead.starred INTEGER NOT NULL DEFAULT 0 CHECK (0,1). Existing leads stay as they were, unstarred. A test builds a database at the previous version with a lead in it, migrates it, and checks the lead is intact.
  • Action: setStarred in src/actions.ts goes through permit(lead, update) and audited. A bad value gets a 422. Starring an already-starred lead succeeds and changes nothing. contract.json is not touched.
  • Desk: show=starred is a new filter, which holds open starred leads only. starredFirst lifts starred open leads to the top of every view and keeps recency order inside each group.
  • Overdue first replies: a first reply that has waited past the green clock (5 minutes) stays ahead of the stars, so a star never hides a lead who is owed an answer. When nobody is starred, the order is unchanged.
  • Page:

- The star is a form with a button, so it works without JavaScript and goes through the existing same-origin check. - It sits beside each desk row and under the name on a lead's page. A button can't live inside a link, so the row <li class="lead-item"> is now a two-column grid. - The button is 44px square on every screen. - The form's back field is checked against a strict pattern, so it only returns to the desk (with its filter) or the lead's page. - The new classes are documented in docs/design/areas/desk.md.

  • API and CSV:

- starred appears in a lead's JSON. - PATCH /leads/:id accepts {starred: true|false}, and /openapi.json is regenerated. - The CSV gets a starred column, yes or no.

  • MCP and terminal: MCP has a star_lead tool, and list_leads takes show=starred. In the terminal, * stars from the desk and from a lead's screen, f cycles through the Starred view, and starred leads show ★.
  • Activity: it reads "starred …" and "took the star off …", and refused attempts are audited too.
  • Docs: README and AGENTS.md describe the star.
  • Tests: src/star.test.ts covers star/unstar, ordering, the overdue case, anon refused, the CSV column, the migration, and the page, API, MCP and terminal.

Existing tests I changed

  • Tests pinned to the old shape:

- The view counts, the view cycle, the CSV row, and the MCP tool list in server.test.ts needed the new starred view, column and tool. - lost.test.ts read lost_reason as the last CSV column. It now finds it by header name, because starred is the new last column.

  • Appended CSV column: I put starred at the end rather than before lost_reason, so existing consumers keep their column positions.

What I chose not to do

  • Closed leads: they can be starred, but they never lead the desk and are not in Starred.
  • Reordering by hand: a star is a flag, not a ranking.
  • Cadence: the star doesn't touch it, and it doesn't bump updated_at, so lost-lead reporting is unaffected.

To try it: open / and tap ☆ on a row, then try /?show=starred, /leads.csv, and * in the terminal.

🤖 Generated with Claude Code

Changes requested — before the latest push

Solid change overall: the star goes through permit and audited, back is validated against a strict pattern, the POST is same-origin checked, contract.json is untouched, and the tests are thorough. Two things to fix before this lands.

  1. (fix first) The new door has no row in src/contract.test.ts. That test walks every door against the policy table (see the put-away, note and skip rows). Add one that calls setStarred, the star_lead tool and the page route as anon, user and admin, and expects the result to match lead update.
  2. Misplaced doc comment in src/terminal.ts. mayStar was inserted between the /** Whether the private note ... */ comment and mayNote, so the note comment now sits on mayStar. Move mayStar above that comment and give it its own one-line comment. mayStar and mayNote are now identical, so consider having one use the other.

Preview: the desk answers 200 with the bearer token alone, but it shows no star buttons, because that request carries no signed identity and the desk hides the star from anon. I could not see the star working in the preview as a signed-in person; I checked it in the tests instead.

Box 6: I could not confirm design-lint here. The builder says the script is absent (they ran bun run lint:design). The CSS uses --size-tap (44px) on the button.

commented

I've fixed both review points and pushed them to the same branch. bun test on contract.test.ts, star.test.ts and terminal.test.ts passes (41 tests, 0 failures). I didn't re-run the full suite after this change.

  • Contract test: src/contract.test.ts now has a row in the lead update door. It calls setStarred and the star_lead tool as anon, user and admin, and checks each result matches what the policy table allows for lead update.
  • Page route: I didn't add a separate POST /leads/:id/star check to the contract test. That route is a thin wrapper over setStarred, so the contract row covers its permission, and the guest and cross-origin cases for the route are already in src/star.test.ts. If you want the route walked in contract.test.ts as well, say so.
  • Comment: in src/terminal.ts, mayNote is back under its own comment. mayStar now follows it with its own one-line comment and is defined as mayNote, since both ask the same lead update cell.
  • Design lint: the script is bun run lint:design (scripts/lint-design.ts). It passed and printed nothing. The task text calls it scripts/design-lint.ts, which doesn't exist in this repo.
Approved

Both earlier asks are met: the lead update door in contract.test.ts now walks setStarred and the star_lead tool across anon, user and admin, and mayStar has its own comment. No cell in contract.json is loosened. The preview serves the Starred view. Non-blocking: the POST /leads/:id/star route is not walked in contract.test.ts itself, though it wraps setStarred and star.test.ts covers its guest and cross-origin cases.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs