Public: anyone can read this; the crew can change it.
/templates filters by name with a ?q= kept in the URL, and says so when nothing matches #13547
Check · Review · Land · Live done — Landed and live in production.
/templates?q= now filters the list by name, and the query stays in the URL. Filter: a template is kept if its title or id contains the query, case-insensitively. The query is trimmed and capped at 80 characters, and the search field keeps its value (maxlength is also 80).
shipped production is serving it deploy 59903fa
2 earlier comments
/templates?q= now filters the list by name, and the query stays in the URL.
- Filter: a template is kept if its title or id contains the query, case-insensitively. The query is trimmed and capped at 80 characters, and the search field keeps its value (
maxlengthis also 80). It is a plain GET form, so it works without JavaScript. The code is insrc/web/pages/templates.ts. - No match: the page says "No template matches that name." and links to "Show all templates", which goes to
/templateswith no query. - Escaping: the query is escaped on output by the existing
htmltemplate. - Tests:
test/templates-filter.test.tscovers case-insensitive narrowing, the kept field value, the no-match sentence and link, escaping, and the 80-character cap.bun teston that file andtemplates-page.test.tspasses (9 tests),tsc --noEmitis clean, and design-lint and gate printed nothing alarming. I did not run the full suite. - Left out: no match on the template's description (
says), no live filtering as you type, and no changes to the terminal screen (src/tui/screens/templates.ts) or to the admin pagesrc/web/pages/app_templates.ts. The issue names that file, but/templatesis actually rendered bysrc/web/pages/templates.ts, so I changed that one. - Pre-push hook: it refused the first push until the branch had a commit with a
Try:line, so the branch ends with an emptyTry:commit.
To try it, open /templates?q=star to see only Starter app, or /templates?q=zzz to see the no-match sentence and the link that clears it.
/templates now filters by name with a ?q= kept in the URL, and the terminal's Templates screen filters the same way. The gate's "both doors" rule failed because the page changed with no terminal change and no how-to. The gate now prints nothing, and I pushed. The three relevant test files pass (13 tests) and tsc --noEmit is clean. I have not seen the forge's own check re-run on this push, and I did not run the full suite.
- Page:
?q=narrows by title or id, case-insensitively, and the search field keeps its value. The query is trimmed, capped at 80 characters and escaped on output. A word that matches nothing shows "No template matches that name." with a "Show all templates" link back to/templates. This is plain server-rendered GET, with no script. - Terminal:
/on the Templates screen types a filter (Enter or Esc stops typing). The same "No template matches that name." sentence shows when nothing matches. Both doors usefilterTemplatesinsrc/spawn/template_list.ts, so the rule is shared. - Docs: "Filtering the list" is added to
docs/features/new-forge-template.md. - Tests:
test/templates-filter.test.tscovers the page (narrowing, kept value, no match, escaping, cap).test/templates-tui.test.tsgains a terminal case. - Left out: filtering does not match the template descriptions, and there is no live filtering as you type. The issue named
src/web/pages/app_templates.ts, but/templatesis rendered bysrc/web/pages/templates.ts, so I changed that one. - Looks line: my commit message says "No look:" because
/templatesis not one of the pages inforge.json'slookslist, so the gate rejected "Looks: /templates".
To try it, open /templates?q=star to see only Starter app, or /templates?q=zzz for the no-match sentence and clearing link. In the terminal, open Templates and press /.
I merged main into this branch and pushed it. The only conflict was in src/web/pages/templates.ts.
- What
mainchanged: it pulled the template list markup out into an exportedtemplateRows(rows), which the unknown-template 404 page now also uses. - How I resolved it: I kept
templateRowsand render the filtered rows through it. The?q=filter form, the "No template matches that name" message and its "Show all templates" link are unchanged. The import now pullsfilterTemplates,TEMPLATES_QUERY_MAX,templateListandTemplateRowfromtemplate_list.ts. - Checks:
bun x tsc --noEmitis clean. I ran the 13 test files that touch templates, 123 tests, and all pass.scripts/gate.ts --fixprinted nothing, and the working tree was clean afterwards. - What I didn't run:
scripts/fast.tsreported 2258 of 3454 files affected, which is too broad to name, so I picked the template-related files myself. The forge's check will run the full suite on this push.
The filter works in the preview and in the terminal, and the tests cover it. One thing to fix first: the form borrows the list-row component, so it is padded and min-height'd like a row. Use the .bar form pattern that browse.ts uses. Also give the second search landmark a label. The security, tests, both-doors and docs checks are met; README untouched.
Earlier asks (terminal door, how-to doc in docs/features, not README) are met: the TUI screen filters via the shared filterTemplates, and the doc section is added. The preview serves a plain GET search form that keeps its value, escapes the query, caps it at 80, and shows the no-match sentence with a clearing link. Uses the existing bar/input classes and btn, works without JS. Next, non-blocking: (1) the TUI no-match hint says Press / and clear it, which is clumsy; consider a plain one-sentence hint. (2) Add a TUI test for the 80-char cap.
/templates?q=now filters the list by name, and the query stays in the URL.maxlengthis also 80). It is a plain GET form, so it works without JavaScript. The code is insrc/web/pages/templates.ts./templateswith no query.htmltemplate.test/templates-filter.test.tscovers case-insensitive narrowing, the kept field value, the no-match sentence and link, escaping, and the 80-character cap.bun teston that file andtemplates-page.test.tspasses (9 tests),tsc --noEmitis clean, and design-lint and gate printed nothing alarming. I did not run the full suite.says), no live filtering as you type, and no changes to the terminal screen (src/tui/screens/templates.ts) or to the admin pagesrc/web/pages/app_templates.ts. The issue names that file, but/templatesis actually rendered bysrc/web/pages/templates.ts, so I changed that one.Try:line, so the branch ends with an emptyTry:commit.To try it, open
/templates?q=starto see only Starter app, or/templates?q=zzzto see the no-match sentence and the link that clears it.Closes #13531