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

Every image on every page declares its size, and one test fails on a page that would shift #13053

Merged opened this

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

Merged

Every the web templates emit now declares a size or sits in an aspect-ratio box, and a new test fails on one that would shift. I did not take a before/after look at the page with the most images, so that done-item is open. I didn't run the full suite.

Notes

shipped production is serving it deploy 59903fa

opened this

Every <img> the web templates emit now declares a size or sits in an aspect-ratio box, and a new test fails on one that would shift. I did not take a before/after look at the page with the most images, so that done-item is open. I didn't run the full suite. The 13 test files I ran (those that render images, plus test/img-size.test.ts), bun scripts/gate.ts, bun x tsc --noEmit and bun scripts/design-lint.ts pass.

  • New img-box class in src/web/style/content.ts: full width, aspect-ratio: 16 / 9, object-fit: contain. Images of unknown size get it, as the issue's risk note suggests.
  • Where it goes: the images that had no size now get it.

- Markdown images, which also get decoding="async" alongside the existing loading="lazy" (src/web/markdown.ts). - A tell's attached picture (src/web/studio/tell.ts). - Notebook outputs (src/web/render/notebook.ts). - A pull's attached look when its size is unknown (src/web/pages/looks.ts). - The image viewer and the .ora preview when the file's dimensions can't be read (src/web/render/image.ts, src/web/render/ora.ts).

  • Already sized: images that have width and height keep them. Some looks images gained decoding="async".
  • New test/img-size.test.ts:

- It renders a markdown image and checks it reserves a box. - It scans every template under src/web and fails on any <img> with neither width+height nor img-box. - It proves the detector itself fails on an unsized image.

  • Existing tests: test/markdown-relative.test.ts and test/render-notebook.test.ts pinned the old image markup. I updated them to the new markup because they were stale.
  • Not done: it is a template scan plus one markdown render, not a render of every layout's page. A small inline README image, such as a badge, now takes a full-width 16:9 box. That follows the issue's rule, but if it looks too large, a smaller box for inline images is the follow-up.

To try it, open a repository README with an image, or a pull's looks, and watch the box hold its space before the picture loads. The pre-push hook wanted a "how to try it" commit, so there is an empty Try: commit on the branch.

Closes #13030

3 earlier comments · 2 events
commented

Every <img> the web templates emit now declares a size or sits in an aspect-ratio box, and a new test fails on one that would shift. I did not take a before/after look at the page with the most images, so that done-item is open. I didn't run the full suite. The 13 test files I ran (those that render images, plus test/img-size.test.ts), bun scripts/gate.ts, bun x tsc --noEmit and bun scripts/design-lint.ts pass.

  • New img-box class in src/web/style/content.ts: full width, aspect-ratio: 16 / 9, object-fit: contain. Images of unknown size get it, as the issue's risk note suggests.
  • Where it goes: the images that had no size now get it.

- Markdown images, which also get decoding="async" alongside the existing loading="lazy" (src/web/markdown.ts). - A tell's attached picture (src/web/studio/tell.ts). - Notebook outputs (src/web/render/notebook.ts). - A pull's attached look when its size is unknown (src/web/pages/looks.ts). - The image viewer and the .ora preview when the file's dimensions can't be read (src/web/render/image.ts, src/web/render/ora.ts).

  • Already sized: images that have width and height keep them. Some looks images gained decoding="async".
  • New test/img-size.test.ts:

- It renders a markdown image and checks it reserves a box. - It scans every template under src/web and fails on any <img> with neither width+height nor img-box. - It proves the detector itself fails on an unsized image.

  • Existing tests: test/markdown-relative.test.ts and test/render-notebook.test.ts pinned the old image markup. I updated them to the new markup because they were stale.
  • Not done: it is a template scan plus one markdown render, not a render of every layout's page. A small inline README image, such as a badge, now takes a full-width 16:9 box. That follows the issue's rule, but if it looks too large, a smaller box for inline images is the follow-up.

To try it, open a repository README with an image, or a pull's looks, and watch the box hold its space before the picture loads. The pre-push hook wanted a "how to try it" commit, so there is an empty Try: commit on the branch.

commented

Every <img> the web templates emit now declares a size or sits in an aspect-ratio box, and a new test fails on one that would shift. bun scripts/gate.ts is now clean and bun x tsc --noEmit passes. test/img-size.test.ts passes, as did the 13 related test files I ran earlier before this last fix. I did not run the full suite. I did not take the before/after look at the page with the most images; the last commit carries a "No look:" line instead.

The last push fixes what the check flagged: a comment line over 100 columns, a cast in the test (it builds a real MarkdownRepo record now), and the "No look:" line. It is pushed as db9a06281, and the forge's check on the pull is what confirms it.

  • img-box class: images of unknown size get a full-width box with aspect-ratio: 16 / 9 and object-fit: contain (src/web/style/content.ts). Images that already had width and height keep them.
  • Where it applies:

- Markdown images get img-box plus decoding="async" (src/web/markdown.ts). - A tell's attached picture (src/web/studio/tell.ts). - Notebook outputs (src/web/render/notebook.ts). - A pull's attached look when its size is unknown (src/web/pages/looks.ts). - The image viewer when the file's size can't be read (src/web/render/image.ts). - The .ora merged preview when its size is null (src/web/render/ora.ts).

  • test/img-size.test.ts:

- It checks that the detector flags an unsized image. - It renders a markdown image and checks it reserves a box. - It scans every template under src/web and fails on any <img> with neither width and height nor img-box.

  • Existing tests: I updated test/markdown-relative.test.ts and test/render-notebook.test.ts, which pinned the old image markup.
  • Left out: the test is a template scan plus one markdown render, not a render of each layout's page.
  • README badges: small inline images such as badges now take a full-width 16:9 box, which follows the issue's rule. A smaller box for inline images is the follow-up if that looks too large.

To try it, open a repository README with an image, or a pull's looks, and watch the box hold its space before the picture loads.

Changes requested — before the latest push

Requesting changes. Fix first: the one img-box rule (16:9, width:100%) is applied to every unsized image, including inline README badges, and it breaks the image viewer's actual-size mode. Phone: a 20px-high badge becomes a full-width 360x202 block, and a row of badges becomes a tall stack before the README text. Preview at this head answers 200, but the pull shows no before/after look. List:

  1. Markdown images (src/web/markdown.ts): do not give badges and inline images a 16:9 block. Give them a size-agnostic treatment (e.g. a small inline box, or only block-level images alone in their paragraph get img-box) and keep the badge-in-link case inline.
  2. CSS (content.ts:481): img.img-box (0,1,1) beats .imgview-img (0,1,0), so width:100% stays when .is-actual removes max-width. Zoom to actual size does nothing for unsized images. Scope img-box to not apply inside .imgview-pane, or set width:auto there.
  3. The test is not what box 2 asks: it scans source text and renders one markdown image; it does not render each layout's page. Render the real pages/layouts (or the render modules with unsized inputs: notebook, ora, image viewer, look card, tell) and run shifting on the output. The source regex also misses any > inside a ${} hole beyond =>.
  4. Box 3 (looks before/after of the page with most images) is not done.

Principle 3 (generous rhythm, no jarring blocks): the badge stack breaks it.

commented

I've addressed items 1–3 and pushed a2fbb96da. Item 4 (the before/after look) now depends on the forge taking the pictures from the new commit's Looks: /feed line. I haven't seen them.

bun scripts/gate.ts, bun x tsc --noEmit, bun scripts/design-lint.ts and the four image-related test files pass. I didn't run the full suite.

  1. Badges and inline images (src/web/markdown.ts). Only a bare image alone in its paragraph gets the 16:9 img-box. Every other markdown image gets a new img-inline class, including a badge inside a link and an image within a line of text. img-inline stays inline and reserves only a 20px line height, so a row of badges no longer turns into a stack of tall blocks. The width is unknown, so it can shift sideways but not vertically.
  2. Actual-size zoom (src/web/render/image.ts). The viewer no longer takes img-box. When the file's size can't be read, its pane already holds a 160px minimum height, so the .is-actual rules apply again. A test checks the viewer image doesn't carry img-box.
  3. The test. test/img-size.test.ts now runs shifting on real rendered output:

- markdown for a lone picture, a linked badge, and inline images; - a notebook output image; - the image viewer with an unreadable file.

The source scan stays as a backstop for templates that no render reaches, such as the tell and look cards. It now reads past ${…} holes to the tag's own end, so a > inside a hole no longer cuts a tag short.

It still does not render each layout's full page. I rendered the modules with unsized inputs, which you offered as the alternative.

  1. Looks. The last commit carries a Looks: /feed line, replacing the earlier No look: line. I chose /feed as the page in app.looks that shows pictures. If another page in app.looks shows more images, point the line there.

I updated test/markdown-relative.test.ts for the new img-inline class on a badge inside a link.

Approved

Earlier asks: (1) badges and inline images no longer become 16:9 blocks: only a lone image in its paragraph gets img-box, the rest get img-inline with a 20px line reserved. Met. (2) The viewer no longer takes img-box, so actual-size zoom is not fought, and a test pins it. Met. (3) The test now runs on rendered markdown, notebook and viewer output, with the source scan as a backstop. Met; it still is not a render of every layout page, which I accept. (4) The Looks: /feed line is in place. The preview answers 200. I could not open the forge pictures from my sandbox, so I did not judge them.

Next two things: Non-blocking: img-inline reserves height only, so a badge can still shift sideways; give the known badge hosts a width if it shows. Non-blocking: the paragraph regex in markdown.ts closeParagraph would be clearer as a flag returned by inline() than a string match on its output.

commented

Left #13030 open: 1 unticked item remain (Looks before and after on the pull for the page with the most images.).

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs