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

/templates shows each template's latest picture beside its name, with a plain placeholder when it has none #14584

Merged opened this

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

Merged

Each template on /templates now shows a 64×40 picture before its name, or a same-sized box with its initial when it has none. The new test file and the existing templates, template-use and TUI tests pass (31 tests), and tsc, gate.ts --fix and the design lint are clean.

Notes

shipped production is serving it deploy 6dfa34b

opened this

Each template on /templates now shows a 64×40 picture before its name, or a same-sized box with its initial when it has none. The new test file and the existing templates, template-use and TUI tests pass (31 tests), and tsc, gate.ts --fix and the design lint are clean. The full suite was not run here; the forge runs it on push.

  • With a look: the picture is the repository's newest production thumbnail, the same one the board's "landed" rows use. It is lazy-loaded, with width/height set so there is no layout shift. The alt text is the template's title, for example alice/seen.
  • Without a look: the box shows the first letter of the template's name. This covers the built-in templates, which have no repository, and repositories with no look the viewer may fetch.
  • One read: the new src/web/pages/template_picture.ts reads every look for all the rows at once with looksForApps, then applies the existing thumbLook and mayFetchLook checks. A private app's picture never appears to someone who couldn't fetch it, so there is no broken image.
  • Styling: .template-thumb is added in components.ts and documented in docs/design/areas/templates.md.
  • Tests: test/templates-picture.test.ts covers a template with a look, one without, a built-in, and a hostile title escaped in the alt text. It also checks the page answers quickly; that check is a loose 500 ms bound on a second request, not a tight budget.
  • Not done: I did not add pictures to the single template page (/templates/owner/name) or the TUI, and there are no new dependencies.
  • Push: the pre-push hook wanted a commit carrying a Try: line, so I added an empty commit for it.

To try it, open /templates on the preview. Any template repository that has a production look shows it.

🤖 Generated with Claude Code

Closes #14558

Show 3 earlier items

7 earlier comments · 1 event
commented

/templates now shows each template's newest look beside its name, or a box with its initial when there is none. I fixed the "both doors" failure and pushed. The other failure, apps: a slow test step, I did not look at or run, and it may be flaky.

  • "both doors" failure: the check treats every file in src/web/pages/ as a page that needs a terminal screen. template_picture.ts is a helper for /templates, not a page. I moved it to src/web/template_picture.ts and updated its imports and the one import in templates.ts. /templates keeps its existing terminal door.
  • Verification: tsc --noEmit is clean. test/doorless.test.ts and test/templates-picture.test.ts pass (8 tests), and bun scripts/gate.ts --fix prints nothing.
  • Slow-test-step failure: the check log doesn't tie it to this pull. It sits in an area this change doesn't touch (a deploy whose test step sleeps). Please re-run the check, and if it fails again I'll look at it.
  • To try it: open /templates. Templates with a look show a 64×40 lazy-loaded picture whose alt text is the template's id. Built-ins and templates without a look show the initial in a box.
commented

I merged main into the branch and pushed it. The only conflict was in src/web/pages/templates.ts, in the row markup.

I kept both sides: each row still shows the template's picture or initial box, and it now also shows the preview link that main added after the description. Type-check is clean, and the 201 tests in the template test files pass. I did not run the full suite. The sandbox blocked two outbound connections to localhost:80 during those tests.

bun scripts/gate.ts --fix rewrapped long comments in two files, and I committed those in the same merge commit.

Review block

[{"go":"/templates","look":"each template row","expect":"the picture (or initial box) sits before the name, and the preview link follows the description"}]
commented

The check failed because my earlier gate --fix rewrapped comments in src/git/pace.ts and test/check-times.test.ts, which this pull doesn't touch. I restored both files to main's version and merged the latest main again. bun scripts/gate.ts now passes, tsc is clean, and test/templates-picture.test.ts passes (4 tests). I didn't re-run the other template tests.

The diff against main is now five files:

  • docs/design/areas/templates.md
  • src/web/pages/templates.ts
  • src/web/style/components.ts
  • src/web/template_picture.ts
  • test/templates-picture.test.ts

No other source or test file differs from main. I pushed this as ede74b223.

Review block

[{"go":"/templates","look":"each template row","expect":"the picture (or initial box) sits before the name, and the preview link follows the description"}]
Changes requested — before the latest push

The feature works on the preview (rows carry .template-thumb) and the shape follows the repo. Changes before it lands, all in one round:

  1. Tests are too loose for box 3: the alt-escape test only checks alt= is present, not that the hostile title is escaped inside the attribute; the speed test is a 500 ms bound that would pass for any page, so it does not hold 'under its budget'. There is also no test that a private/unfetchable look yields the placeholder, which is the main reason thumbLook exists here.
  2. Design principle 6: the 1px border around the thumb is a box around a thing. Drop it and let the muted background carry the shape.
  3. Principle 8 / a11y: alt repeats the adjacent bold title, so a screen reader says the name twice. Keep alt naming the template as the issue asks, but make it distinct, e.g. Latest look of ${title}.
  4. Phone at 360px: the 64px thumb sits in a flex .row with the text and the button; confirm the row wraps rather than squeezing the sentence, and add min-width:0 handling if it does not.
  5. The initial is computed with an inline spread expression in the template literal; pull it into a small named helper.

Both-doors: /templates already has its terminal screen and a picture has no terminal form, so no TUI work is asked; no README change, good.

commented

All five review points are addressed in 638f89edf. tsc and gate are clean, and the picture and page-budget tests pass (14 tests). I did not run the rest of the suite or look at the page on a 360px viewport.

  1. Tests:
    • The alt-escape test now asserts the exact escaped attribute, alt="Latest look of &quot;&gt;&lt;script&gt;…", and that no raw <script> appears.
    • A new test seeds a template whose only look is a phone shot (the owner's view). A stranger gets the box with its initial and no <img>.
    • I removed the 500 ms speed test and added /templates to the repo's page budget instead, in src/perf/page_budgets/templates.ts. It is walked signed out, with a 50 ms median and a 12-statement limit; it measured 5 statements and about 3 ms on the seeded forge. The two tests in test/page-budget.test.ts that pin the roster now list it too.
  2. Border: I dropped the 1px border on .template-thumb; the muted fill carries the shape.
  3. Alt text: It now reads Latest look of <title>.
  4. 360px: I did not confirm this by eye. The sentence was a flex item with no min-width: 0, so I made it flex: 1 1 0; min-width: 0; overflow-wrap: anywhere in #templates form.row. The 64px thumb and the button keep their size.
  5. Initial: It is now the exported templateInitial() in src/web/pages/templates.ts, with its own test.

Review block

[{"go":"/templates at 360px width","look":"a row with a long description","expect":"thumb, wrapped sentence and button on one line, nothing squeezed or overflowing"},{"go":"/templates","look":"a template with no picture","expect":"a plain muted box with the template's initial, no border"}]
commented

Pushed. The check should now go green on the failures this pull caused; the rest were already red on main, so this push does not fix them.

Mine, fixed: /templates had no entry in docs/design/size-budget.json. That broke "no first page's client JavaScript or CSS passes its ceiling" and "the ceiling file names exactly the budgeted pages". I regenerated the ceilings with FORGE_SIZE_WRITE=1 bun test test/client-size.test.ts. /templates now has js 21760 and css 47616, and every other page's css ceiling went up by 512 or 1024. The generator rewrote those, and I kept them rather than trimming the diff by hand. client-size, gate-size-ceiling-merged and templates-picture pass locally.

Not mine, left alone: a clean checkout of origin/main fails these on its own:

  • fetch-timeout: src/http/server.ts:3243 and src/kernel/outbound.ts:206 call fetch with no signal.
  • outbound-sweep (#14664): src/maintain/duties/edge_kept.ts names the forge's own host unnamed.
  • docs-link: docs/HOPS.md has no line in DOC_LINES.
  • llms-budget: /llms.txt is over its byte budget.
  • The SQL-statement count on /maintenance (86 against a budget of 83) trips page-budget, and the matching count on /api/v1/maintenance/duties (69 against 66) trips pages-budget. I did not rerun llms-budget on my branch.

Those need fixes on main; this pull touches none of them. I did not run tsc or the gate script this round.

commented

The five remaining failures come from main, not from this pull. I merged the latest main and pushed, but no code of mine changed this round, so the check will most likely still be red on these five.

  • <time test: src/web/pages/passkeys.ts:395 writes a <time> by hand. My diff touches neither that file nor any <time> markup. I reran test/time-element.test.ts locally on the merged tree and it fails on that line alone.
  • The other four: I did not rerun them this round. They were already failing on a clean origin/main in the last round, before the new merge:
    • fetch-timeout: a fetch in src with no signal.
    • llms-budget: /llms.txt over its byte budget.
    • page-budget: /maintenance runs more SQL statements than its budget.
    • pages-budget: the same count on /maintenance and /api/v1/maintenance/duties.

This pull is a change to the Templates page: it shows each template's latest picture, with a size ceiling for /templates and the CSS ceilings regenerated. It does not alter any of those five areas. I did not run tsc or the gate script this round.

To try it, open /templates on the preview.

commented

The check is still going to fail on this push, but nothing it fails on comes from my change. I merged the latest main and reran the failing tests locally. test/client-size.test.ts and test/templates-picture.test.ts pass, and the /templates page (the one this pull changes) is not named in any failure.

What still fails, all in code this pull does not touch:

  • fetch-timeout: src/http/server.ts:3248 and src/kernel/outbound.ts:206 call fetch with no signal.
  • llms-budget: /llms.txt is 80797 bytes against a budget of 80500.
  • page-budget: /changelog runs 22 SQL statements against a budget of 21.
  • pages-budget: /maintenance runs 86 against 83, and /api/v1/maintenance/duties runs 69 against 66.
  • Time and wait tests: the <time> hand-written-markup test and the "wait is one budget under 25 s" test (#13794) were in the failure list but did not show up in my local run. I did not look into them separately.

They fail the same way on a clean origin/main, so I left them alone. They need fixes or raised budgets on main. I did not touch their budget files or tests, since doing that here would hide real regressions that belong to other pulls.

This pull itself is the Templates page showing each template's latest picture, plus the /templates size ceiling. To try it, open /templates on the preview.

commented

I merged main into the branch and pushed. src/web/pages/templates.ts was the only conflict.

The conflict: main added a note under the template list for when no template has a repository (templates-empty, one wording for admins and one for everyone else). This branch changed the same call so each row gets its picture. I kept both, so the list now passes the pictures and the empty-state note still follows it.

Checks:

  • tsc is clean.
  • gate.ts --fix changed nothing.
  • The templates tests, client-size and page-budget pass: 69 tests across 12 files.

I did not run the full suite; the forge's check does that on the push.

To try it, open /templates on the preview. Each template should show its latest picture, and a forge with no repository-backed templates should show the empty-state note.

Approved

All five earlier asks are met: exact escaped alt assertion, private-look placeholder test, page budget replacing the timing test, border dropped, alt text now Latest look of <title>, and templateInitial exported with a test. The preview serves the placeholder box with the initial for built-ins and fixed 64x40 markup, no JS needed. Next, in order: (1) Non-blocking: check the row at 360px by eye, since it was only reasoned about; (2) Non-blocking: the placeholder uses a hard-coded font-weight; use the existing token if one exists. The raised size ceilings across all pages are generator output and acceptable.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs