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

A template's page carries a share card and a plain link that starts a forge from it #13619

opened this

Merged 20d 1h ago, live in production

/templates/ now serves a template's own page with share meta and a plain link that starts a forge from it. I did not run bun scripts/fast.ts's test list: it named 2,274 test files, so I ran the tests nearest the change instead (95 pass across the OG, route-marks, template-TUI and docs-index suites).

Notes

opened this

/templates/<name> now serves a template's own page with share meta and a plain link that starts a forge from it. I did not run bun scripts/fast.ts's test list: it named 2,274 test files, so I ran the tests nearest the change instead (95 pass across the OG, route-marks, template-TUI and docs-index suites). The forge's check runs the full suite on this push. tsc and design-lint are clean; gate --fix rewrapped comments in 2 files, and those are in the commit.

What changed

  • Page: /templates/starter and /templates/owner/name (templatePage, src/web/pages/templates.ts) serve the title, one-line description, og:image and twitter:image. The page also has a primary button, "Start a forge from <title>", linking to /forges/new?template=<id>.
  • Card: a new template kind on the existing /og/template/<ref>.svg and .png routes. It reuses the cached PNG path and the same renderer, with no new renderer. A repository template's ref is owner~name, like every other card.
  • 404s: an unknown template is 404 on the page and the card. A template the reader cannot see is the same 404, so private templates are not revealed.
  • Public card: the card is drawn only from what a signed-out reader is offered. A private template's page therefore has no custom image and falls back to the site card.
  • Terminal door: the Templates screen prints Share: /templates/<id> under the selected row.
  • Docs and test: docs/features/new-forge-template.md has a new section, and test/template-share.test.ts reads the meta and the link, the card, and the 404s.

Not done

  • A repository template has no card test: the test covers the built-in starter template and unknown names only.
  • No before/after look: the commit says No look: …, since no listed look covers a new page.
  • No new dependency.

Try: open /templates/starter on the preview and view the page source. The og:image points at /og/template/starter.png, and the button opens New forge with Starter app chosen.

🤖 Generated with Claude Code

Closes #13593

Show 3 earlier items

7 earlier comments
commented

I fixed the first failure and pushed the fix. I'm treating the second as a timing flake, but I haven't proved that.

  • "a route the fixture cannot fill is listed, not skipped silently": this pull's two new routes, /templates/:name and /templates/:owner/:name, have no fixture in test/pages-budget.test.ts. That took the unfixtured count to 153 against a cap of 151. I raised MAX_UNFIXTURED to 153 with a comment naming the two routes. This follows the cap's existing pattern of one note per added route, instead of building template fixtures for a share page.
  • "after a write, signed-in home is answered from memory within the budget…": it took 4.4 s in the check run and passed on the two local runs of test/pages-budget.test.ts I did after the change. The check log also shows the same file green on main at a5a2fb6. I changed nothing for it, so if it fails again on this push it needs another look.

bun x tsc --noEmit is clean and bun scripts/gate.ts --fix raised only the "look pages" note.

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

commented

<!-- look-pages a85e1843218b --> Look pages for a85e184, from the gate:

  • look pages (none): this pull changes src/web/pages/og.ts, 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 gate's note asks for a "Looks:" line in the pull description, so I changed no code and there is nothing new to push. The gate couldn't trace a route from the files I changed, so it named an unrelated settings page. I've put the right page in the line below. The forge reads that line from this description.

Looks: /templates/starter

What changed

  • /templates/<id> is a page for one template, such as /templates/starter or /templates/owner/name. It carries Open Graph and Twitter meta (title, one-line sentence, and the card /og/template/<id>.png). It also has one plain link, "Start a forge from <name>", to /forges/new?template=<id>.
  • The card uses the existing renderer and its cached PNG path. It is drawn only from what a signed-out reader is offered.
  • A template that is unknown, or not listed to the reader, answers 404 either way.
  • The terminal's Templates screen prints the same path under each row as "Share:".
  • main's /templates?q= filter is merged in and sits alongside the share page in the docs. The share routes are counted in the MAX_UNFIXTURED cap in test/pages-budget.test.ts, up by 2 to 153.

What I left out

  • A fixture for the two new template routes in the pages-budget walk. I raised the cap instead, as the file's other additions do.
  • Any change to what a private template shows. It is visible only to people who can read its repository.

How to try it

  • Open /templates/starter on the preview, https://lab--13619--forge-trevato-apps.open-platform.sh/templates/starter, and view its source for the meta tags.
  • bun test test/template-share.test.ts test/pages-budget.test.ts.

The earlier check failure on "signed-in home is answered from memory within the budget" looked like a timing flake. It passed on my local runs and on main, but I haven't proved that. If it fails again, it needs another look.

commented

A template's page, /templates/:name or /templates/:owner/:name, now carries a share card and a link that starts a forge from that template.

What changed

  • Duplicate removed: main had added its own templatePage in src/web/pages/template.ts (#13432, #13454). That clashed with the one this pull added to templates.ts, which broke the type check. I removed mine and its duplicate routes, and merged main.
  • Share card on main's page:
    • Title: a built-in template's title is now <Title> template, for example "Starter app template".
    • Description: a built-in template's description is its one-line summary.
    • Image: og:image and twitter:image point at /og/template/<ref>.png, set only when the template is listed to an anonymous reader. A template hidden from them gets no card URL.
    • Start link: the page has one primary button, "Start a forge from X", which opens /forges/new?template=<id>.
  • Kept from before: the /og/template/… card routes, the templateCardRef helper and test/template-share.test.ts. The files list and last-forge timing line on main's page are unchanged.

What I didn't do

  • I didn't change what main's page lists or how it reads the repository.
  • Non-built-in templates (owner/name repositories) get a start button and card only when the template list also knows them.

Checks: tsc --noEmit is clean. The template share, page, list and filter tests pass, along with pages-budget and template-page-gets. gate.ts --fix still prints the "could not trace the route of /settings/security/controls" look line. I added Looks: /templates/starter to the merge commit message to answer it.

To try it: curl -s <preview>/templates/starter | grep og: shows the card meta. The page has the start button.

🤖 Generated with Claude Code

commented

<!-- look-pages abd86cad07cd --> Look pages for abd86ca, from the gate:

  • look pages (none): "Looks: /templates/starter" is not a page of app.looks in forge.json; this pull changes src/web/pages/og.ts, src/web/pages/template.ts, 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 gate rejected Looks: /templates/starter because that path isn't in app.looks in forge.json. I pushed an empty commit with a No look: line instead. It says /templates/:name is not in app.looks, and the change is two meta tags and one button on an existing plain page.

I didn't add a template page to app.looks. That list sets which pages get screenshotted, which seems a reviewer's call. If you want a look for this page, say so and I'll add /templates/starter to forge.json. I haven't re-run the gate or any tests since this commit, and the commit changes no code.

The gate also still can't trace /settings/security/controls. That page is not part of this change.

commented

I've addressed all six points and pushed. tsc is clean, and the template share, TUI, page, list and pages-budget tests pass. I did not run the full suite, so the forge's check on this push is the first full run. The CI-only unix-socket suites didn't run here either.

  1. Tests (test/template-share.test.ts, test/templates-tui.test.ts):
    • TUI Share: line: the selected row prints its path. The blank row prints none.
    • /og/template/<id>.png: a listed template returns a PNG, or 503 when the rasterizer can't load. An unknown id returns 404.
    • owner/name template: a public one gets a page and card using owner~name.
    • Hidden template: a private template gets a 404 on the page and on both the .svg and .png cards for an anonymous reader. That is the behaviour the docs name.
  2. Docs: templatePage is now named in src/web/pages/template.ts, and the docs also point to the id/ref pair in template_list.ts.
  3. MAX_UNFIXTURED: the raise was needed, but not for the template pages, which are already fixtured. The two new /og/template/:ref.svg and .png routes were the unfixtured ones. I reverted the cap to 151 and added fixtures for both routes (alice~forge) instead.
  4. Lookup cost:
    • Built-in templates: templateRow answers a built-in id with no query.
    • Page view: the page reads the anonymous row first and only reads the viewer's own list when the anonymous row is missing. A public template costs at most one list read. A built-in costs none.
  5. Redundancy: the button now says "Start a forge", so the heading carries the template name and the paragraph carries the description. I changed test/templates-page.test.ts nowhere, because its "Start a forge from Starter app" check is for the /templates list buttons, which I didn't touch.
  6. id↔ref pair: templateCardRef and templateIdOfRef now sit beside templatePath in template_list.ts. og.ts and the page both use them, and the hand-rolled replace is gone.

While testing I found that the blank forge's /templates/blank page is a 404, but the TUI printed a share path for it and the card route would have drawn a card. templateRow now returns nothing for the blank forge. The TUI prints no Share: line for it, and its card is a 404.

Rewrap in og.ts: I restored the original header comment, but bun scripts/gate.ts --fix rewraps it again whenever og.ts is touched. That is the gate's rule, so the diff still shows the rewrap.

The gate's /settings/security/controls look message is unrelated to this change. The No look: line is already on the branch.

commented

I merged main into the branch, resolved the one conflict, and pushed. The branch should merge cleanly again.

The conflict was in src/web/pages/template.ts. main had switched the page header to pageHead(...), with the template's description as its subtitle. This branch had added the share card, the "Start a forge" button and the og:image tag. The resolved page uses pageHead and keeps the share-card title, description and og:image. It also keeps the "Start a forge" button, and the "begins with these files" line for templates that aren't built. The separate paragraph that repeated the description is gone, because the subtitle now carries it.

Checks run:

  • bun x tsc --noEmit: no type errors.
  • bun scripts/gate.ts --fix: printed nothing.
  • bun scripts/design-lint.ts: clean.
  • Seven template and page-budget test files (31 tests): all pass.

I didn't run the full bun test suite here. scripts/fast.ts couldn't name a bounded set (the diff touches scripts/design-lint.ts), so I started the full suite. I then stopped it and ran the seven files above instead, so the forge's check does the full run on this push.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs