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

A template on /templates links to a read-only live preview of what a new forge from it looks like #14698

Merged opened this

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

Merged

Each template row on /templates now carries one link, Preview, to that template's read-only page, or says "no preview yet" when there is nothing to show. tsc, bun scripts/gate.ts, design-lint and the three template test files I ran all pass. I did not run the full suite; the forge's check does that on push.

Notes

shipped production is serving it deploy 4ec2c16

opened this

Each template row on /templates now carries one link, Preview, to that template's read-only page, or says "no preview yet" when there is nothing to show. tsc, bun scripts/gate.ts, design-lint and the three template test files I ran all pass. I did not run the full suite; the forge's check does that on push.

  • What the link points to: the existing /templates/<id> page, which already lists the template's files and is a plain GET page. It carries the same security headers as every other page. I did not build a separate sample view.
  • What counts as a preview: Starter app and any template repository with readable files get the link. Blank, and a repository with no commits or that can't be read, get "no preview yet".
  • Where the code is: previewLink in src/web/template_card.ts, called from src/web/pages/templates.ts.
  • Terminal screen: the selected template on the terminal templates screen gains a Preview: line, and docs/features/template-holds.md says so. These two changes weren't in the issue's file list; the repo's "both doors" rule asks for them.
  • Tests: test/template-preview.test.ts checks Starter has the link and Blank says "no preview yet". It checks the preview page returns the security headers and rejects POST. It also checks the repository case with and without files, as a unit test on previewLink; it doesn't create a real template repository.

Left out: pictures and screenshots of a template, as the issue's risks note says, and a bespoke "what a new forge looks like" rendering.

Try it: open /templates, click Preview on Starter app, and see "no preview yet" under Blank.

[
  {"go": "/templates", "look": "the Starter app row", "expect": "a small Preview link under the row that opens /templates/starter"},
  {"go": "/templates", "look": "the Blank row", "expect": "the muted words 'no preview yet' and no link"},
  {"go": "/templates/starter", "look": "the page", "expect": "read-only: no form besides the Start a forge button"}
]

🤖 Generated with Claude Code

Closes #14675

1 earlier comment · 1 event
commented

Each template row on /templates now carries one link, Preview, to that template's read-only page, or says "no preview yet" when there is nothing to show. tsc, bun scripts/gate.ts, design-lint and the three template test files I ran all pass. I did not run the full suite; the forge's check does that on push.

  • What the link points to: the existing /templates/<id> page, which already lists the template's files and is a plain GET page. It carries the same security headers as every other page. I did not build a separate sample view.
  • What counts as a preview: Starter app and any template repository with readable files get the link. Blank, and a repository with no commits or that can't be read, get "no preview yet".
  • Where the code is: previewLink in src/web/template_card.ts, called from src/web/pages/templates.ts.
  • Terminal screen: the selected template on the terminal templates screen gains a Preview: line, and docs/features/template-holds.md says so. These two changes weren't in the issue's file list; the repo's "both doors" rule asks for them.
  • Tests: test/template-preview.test.ts checks Starter has the link and Blank says "no preview yet". It checks the preview page returns the security headers and rejects POST. It also checks the repository case with and without files, as a unit test on previewLink; it doesn't create a real template repository.

Left out: pictures and screenshots of a template, as the issue's risks note says, and a bespoke "what a new forge looks like" rendering.

Try it: open /templates, click Preview on Starter app, and see "no preview yet" under Blank.

[
  {"go": "/templates", "look": "the Starter app row", "expect": "a small Preview link under the row that opens /templates/starter"},
  {"go": "/templates", "look": "the Blank row", "expect": "the muted words 'no preview yet' and no link"},
  {"go": "/templates/starter", "look": "the page", "expect": "read-only: no form besides the Start a forge button"}
]

🤖 Generated with Claude Code

Changes requested — before the latest push

Works in the preview: Starter has a Preview link to /templates/starter (200), Blank says 'no preview yet'. Fix first: the link's accessible name. Every row will read just 'Preview', so a screen-reader link list is N identical links. Changes needed: (1) name the link per template (aria-label 'Preview Starter app', or visible text 'Preview <title>'); previewLink needs the title. (2) The terminal 'Preview:' line prints the same path as 'Share:' on the line above (principle 1: nothing says itself twice); merge them or make Preview a real distinct thing. (3) The test for the POST only asserts 'not 200', which passes on a 500 or a redirect; assert the exact refusal status (404/405). Also add a test that the page has no mutating form besides the GET start form, since 'read-only' is box 2. (4) The no-link case for a repository template with no commits is only a unit test on previewLink; add a page-level case if the test harness can make an empty template repo, otherwise say so in the pull. (5) The link sits in its own <p> between the row and the use line, adding a fourth stacked line per row (principle 3/7: rows, not stacks); put it inside the row's sentence line or the holds dl as a row. Box 1 is met only in part until (1) lands.

commented

Each template row on /templates now links to that template's read-only preview, or says "no preview yet". The review changes are in and pushed.

I ran bun x tsc --noEmit, scripts/gate.ts --fix and scripts/design-lint.ts, and they reported nothing to fix. I also ran seven template test files, 35 tests, and all pass. scripts/fast.ts said the diff was too broad to name tests, so I picked those files myself and did not run the full suite.

  • Link name: the link carries aria-label="Preview <title>", for example "Preview Starter app". previewLink now takes the title.
  • Row shape: the link sits inside the row's own sentence span, so the separate <p> is gone and rows have one fewer stacked line.
  • Terminal: I dropped the Preview: line. Share: already prints the same path.
  • POST test: POST /templates/starter must now return 404 or 405. A second check asserts there is no POST form on the page. It excludes the theme switcher's form (/theme), which is part of the shared page chrome.
  • Aria-label tests: a page-level check covers the Starter row, and a unit check covers a repository template.
  • Empty repository template (not done): the no-link case for a repository template with no commits is still only a unit test on previewLink. The test harness does not set up a template repository, and building one only for this case seemed too much.
Approved

Earlier asks are met: the link has an aria-label, it sits inside the row sentence, and POST to the preview is tested. In the preview, Starter and preview-admin/kit link to /templates/<id>, which returns 200. Blank says "no preview yet". Two things to do next. (1) Non-blocking: docs/features/template-holds.md says the terminal lines read Share: and Preview:, but the Preview: line was dropped, so fix that sentence. (2) Non-blocking: add a page-level test for an empty template repository.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs