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

/templates filters by a ?q= word with a plain GET form #13989

Merged opened this

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

Merged

/templates?q= now matches a template's description as well as its name and id. The pushed branch carries one code change plus a new test file. bun x tsc --noEmit is clean, and gate.ts --fix and design-lint ran.

Notes

shipped production is serving it deploy 4adf612

opened this

/templates?q= now matches a template's description as well as its name and id. The pushed branch carries one code change plus a new test file. bun x tsc --noEmit is clean, and gate.ts --fix and design-lint ran. The four templates test files (18 tests) pass.

Most of this was already on main: the GET form, case-insensitive name filtering, the escaped echo, the 80-character cap, and a "no match" line with a "Show all templates" link. The only gap was description matching, so that is all I changed:

  • filterTemplates in src/spawn/template_list.ts also searches each template's description. The terminal templates screen uses the same function, so it matches descriptions too.
  • Filter box in src/web/pages/templates.ts: the placeholder and aria-label now say "name or description".
  • test/templates-search.test.ts is new and covers three cases: a match by description word in any case plus a match by name, no match with the link to the full list, and a hostile q that comes back escaped.

I left the existing test/templates-filter.test.ts as it was, so the two files overlap a little.

To try it, open /templates?q=server (matches by description), /templates?q=zzzz (no match), and /templates?q="><script> (escaped in the box). The page stays server-rendered with no script.

I did not run the full suite, since the forge runs it on push.

Closes #13973

5 earlier comments
commented

<!-- look-pages 10a72604e280 --> Look pages for 10a7260, from the gate:

  • look pages (none): this pull changes src/web/pages/templates.ts but the forge could not trace the route of /settings/security/controls (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
commented

The "both doors" check failed because I changed src/web/pages/templates.ts without a matching change under src/tui/. I've now updated the terminal's /templates screen to say the same thing. I haven't re-run the forge's check on the new push, so whether it now passes is not confirmed.

  • Terminal change: the filter key hint in src/tui/screens/templates.ts now reads "filter by name or description". The terminal already used the same filterTemplates function, so it was matching descriptions after my first push, but its hint didn't say so.
  • Look line: the second gate message said it couldn't trace the page for the look. I put Looks: /templates in the commit message to name it.

tsc is clean and the two templates test files (9 tests) pass. gate.ts --fix ran before I committed, so it saw the old diff and printed both messages again. Whether the pushed commit now satisfies the gate is what the forge's check will show.

The branch is pushed at 3ba5cc142.

commented

<!-- look-pages 3ba5cc142d0f --> Look pages for 3ba5cc1, from the gate:

  • look pages (none): "Looks: /templates" is not a page of app.looks in forge.json; this pull changes src/web/pages/templates.ts but the forge could not trace the route of /settings/security/controls (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
commented

I added docs/features/templates-search.md and pushed it as 8bf10b175. That file was the missing piece for the "both doors" rule. I haven't confirmed the check now passes. The local gate still printed both messages, but it reads committed history and I ran it before committing, so I don't trust that output.

  • How-to: the new page covers /templates?q= and the terminal filter, and lists the code and the tests.
  • Look line: /templates isn't one of the pages in forge.json's looks, so my earlier "Looks: /templates" line was rejected. This commit says "No look:" and gives the reason instead. I left forge.json alone.

The change has no code edits this round. I didn't re-run the tests, since nothing but docs changed since the last passing run.

commented

I added the "pipeline first" Direction: line the gate asked for in an empty commit, ed4962d4f, and pushed it. I haven't run the forge's check on this push, so whether it now passes is still open.

The line says issue #13973 asks for template search directly and the change touches no pipeline code. No code, docs or tests changed this round, and I didn't re-run the tests.

commented

/templates?q=word now narrows the list to templates whose name, id or description contains the word, case-insensitively. The terminal /templates screen filters with / through the same function, filterTemplates in src/spawn/template_list.ts. A miss shows "No template matches that name." with a link back to the full list.

This push fixes the two feature-orphan failures. My docs/features/templates-search.md had no row in docs/features/README.md, and I added one under "Your apps". The index test and orphan test now pass.

I did not change anything for the two ETag failures, "a signed-out page showing a flash carries no ETag and is never a 304" and "a signed-out 404 carries no ETag". Both ran in shard 47 and my change doesn't touch ETag code. test/etag.test.ts passes on its own and alongside the three templates test files. The check's log doesn't show why they failed, so I haven't found the cause. The forge's re-run of the check on this push will show whether they still fail.

Run here: test/feature-orphans.test.ts, test/etag.test.ts, test/templates-search.test.ts, test/templates-filter.test.ts, test/templates-tui.test.ts, and bun x tsc --noEmit, all green. I did not run the full suite; the forge does that.

To try it, open /templates?q=server, then /templates?q=zzzz.

🤖 Generated with Claude Code

Approved

Small, clean, escaped (the echoed value goes through html``), capped at 80 chars, GET-only, works without JS. Description matching works on the preview (?q=server finds starter; ?q=zzzz shows the none sentence and the full-list link). Terminal reads the same filterTemplates and its hint is updated; how-to is in docs/features, README untouched. Touches no pipeline code; single-purpose. Minor, not blocking: the no-match sentence says "name" though it now also matches descriptions.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs