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

Find a lead on the desk by name, email or phone #21

Merged opened this

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

Merged

The signed-in desk now has a search box that finds a lead by name, email or phone, and the pull is pushed. The search tests, the server tests and the other touched suites pass, as does the design lint. I didn't run bun test over the whole suite, since the forge runs that on push.

Notes

shipped production is serving it deploy aba151a

opened this

The signed-in desk now has a search box that finds a lead by name, email or phone, and the pull is pushed. The search tests, the server tests and the other touched suites pass, as does the design lint. I didn't run bun test over the whole suite, since the forge runs that on push. Three checks didn't run:

  • bun x tsc --noEmit: it printed only its help text and checked nothing, because the clone has no tsconfig.json.
  • scripts/gate.ts and scripts/fast.ts: these don't exist in this clone.
  • Live refresh: I read the code but didn't run it. static/live.js refetches location.href, so it should keep q and show.

What changed

  • Search: src/leads.ts has queryOf, which trims the text, caps it at 80 characters and refuses control characters. desk() matches name or email case-insensitively. It matches phone by digits only, so "555 0101" finds "(206) 555-0101".
  • Safety: the query is parameterised and %, _ and \ are escaped, so a % matches literally.
  • Desk page: a plain GET form at the top, with show carried in a hidden field. The view links keep q. Below the form it says "N leads match 'x'" with a Clear link, or "No lead matches 'maria'." when nothing does.
  • Bad search on the page: a too-long or control-character query still shows the desk with the refusal above it, instead of the signed-out page.
  • JSON and MCP: GET /leads?q=… returns the same list, and a refused query gets a 422. /openapi.json and contract/openapi.json describe q. The MCP list_leads tool takes q.
  • Terminal: / opens a search prompt. Enter applies it, an empty search clears it, esc cancels.
  • Counts: the view counts show how many of the matches fall in each view, not the whole desk.
  • Access and docs: access is list lead through permit, and no contract cell changed. The README desk section mentions it, and static/app.css adds a one-row .search form.
  • Tests: src/search.test.ts covers name, email and phone matches, a view combined with a search, a literal %, a refused over-long query, the page wording and escaping, and the terminal. src/server.test.ts checks that the JSON matches the HTML and that MCP q works.

Not done

  • No search-as-you-type JavaScript.
  • No fuzzy matching: it is substring only.

Try it: open /?q=maria, /?show=open&q=555+0102, or /leads?q=555%200101. In the terminal, press / and type.

🤖 Generated with Claude Code

Closes #19

commented

The signed-in desk now has a search box that finds a lead by name, email or phone, and the pull is pushed. The search tests, the server tests and the other touched suites pass, as does the design lint. I didn't run bun test over the whole suite, since the forge runs that on push. Three checks didn't run:

  • bun x tsc --noEmit: it printed only its help text and checked nothing, because the clone has no tsconfig.json.
  • scripts/gate.ts and scripts/fast.ts: these don't exist in this clone.
  • Live refresh: I read the code but didn't run it. static/live.js refetches location.href, so it should keep q and show.

What changed

  • Search: src/leads.ts has queryOf, which trims the text, caps it at 80 characters and refuses control characters. desk() matches name or email case-insensitively. It matches phone by digits only, so "555 0101" finds "(206) 555-0101".
  • Safety: the query is parameterised and %, _ and \ are escaped, so a % matches literally.
  • Desk page: a plain GET form at the top, with show carried in a hidden field. The view links keep q. Below the form it says "N leads match 'x'" with a Clear link, or "No lead matches 'maria'." when nothing does.
  • Bad search on the page: a too-long or control-character query still shows the desk with the refusal above it, instead of the signed-out page.
  • JSON and MCP: GET /leads?q=… returns the same list, and a refused query gets a 422. /openapi.json and contract/openapi.json describe q. The MCP list_leads tool takes q.
  • Terminal: / opens a search prompt. Enter applies it, an empty search clears it, esc cancels.
  • Counts: the view counts show how many of the matches fall in each view, not the whole desk.
  • Access and docs: access is list lead through permit, and no contract cell changed. The README desk section mentions it, and static/app.css adds a one-row .search form.
  • Tests: src/search.test.ts covers name, email and phone matches, a view combined with a search, a literal %, a refused over-long query, the page wording and escaping, and the terminal. src/server.test.ts checks that the JSON matches the HTML and that MCP q works.

Not done

  • No search-as-you-type JavaScript.
  • No fuzzy matching: it is substring only.

Try it: open /?q=maria, /?show=open&q=555+0102, or /leads?q=555%200101. In the terminal, press / and type.

🤖 Generated with Claude Code

commented

I merged main into the branch, resolved the two conflicts, and pushed. The full bun test run passes (114 tests, 0 failures) and the design lint is clean. I didn't run a type check or scripts/gate.ts, because the clone has neither a tsconfig.json nor that script.

  • src/terminal.ts: the three conflicts were the key-help lines and the View type. I kept both sides, so the terminal desk has / to find a lead and a for activity, and its View type has both search and activity.
  • static/app.css: I kept the .search and .found rules and the .activity rule.
  • contract/openapi.json: I re-emitted it after the merge so it matches the routes from both sides.
Approved

Clean. Search goes through listLeads and permit (list lead), so every door is gated the same way. The query is parameterised with %, _ and \ escaped, and queryOf caps it at 80 characters and refuses control characters. Output is escaped. No contract cell changes and there are no new dependencies. Tests cover name, email and phone matches, the view combined with a search, literal %, the refusal, the page wording, the terminal, the JSON route and MCP. The README is updated. I could only fetch the signed-out preview, so I did not see the signed-in search in use. Nits only: src/mcp.ts and Q_HELP hardcode 80 instead of using MAX_QUERY, and the signed-out test only asserts ok is false.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs