Skip to content

perf(docs): serve every image in the dimensions each place needs, not one size for all #4686

Closed

Description

@yannickmonney

Summary

Most images Tale ships exist in exactly one dimension. The clearest case is the docs screenshots: services/docs/public/images/ holds 82 WebP files (about 6.8 MB), 45 of them 2880×1800 (a DPR 2 capture of a 1440×900 viewport), and every page references that one file with plain markdown, for example ![…](/images/platform/chat-thread-reply.webp). A phone, a laptop and a retina desktop all download the same bitmap, and the browser is never told its size. The marketing site already solved this for its own images; the docs, the design-system docs, the README and the social cards did not take it up.

This issue is to give every place that shows an image the dimension or dimensions it needs, from one shared implementation.

Current behavior

Verified in the repository:

  • One size per docs screenshot. services/docs/public/images/manifest.json has 82 entries: 45 at 2880×1800, three at 4480×2800, three at 2048×1700, and the rest vary by shot. Each shot is one file. The German and French trees (public/images/platform/de, …/fr) hold 8 shots each, again one file apiece.
  • The only contract is a ceiling. services/docs/tests/image-manifest.test.ts requires width ≤ 2880 and even (the DPR 2 contract), that every file is in the manifest, and that every file is referenced. Nothing asks for a smaller variant.
  • Rendered as a bare <img>. The shared markdown renderer's ImageZoom (packages/ui/src/markdown/components/image-zoom.tsx:43-49) emits src, alt, loading="lazy" and decoding="async": no srcset, no sizes, no width/height. The browser cannot pick a smaller file, and the layout shifts as each image arrives. The zoom lightbox loads the same file.
  • Captured at one viewport. services/platform/tests/docs-screenshots/capture.ts:119 takes shot.viewport ?? VIEWPORT, so a shot is one page at one size; there is no notion of the same page captured for phone and desktop.
  • Every other place is its own thing. The README tiles are straight downscales of the docs shots (bun run readme:assets, services/platform/tests/docs-screenshots/readme-assets.ts, output .github/assets/readme-*.webp). The ui-docs site ships a single public/og.png; social-image tags come from packages/ui/src/seo/document-meta.ts. The platform does no server-side image resizing (sharp appears only in capture and test tooling).

The repository already has the pattern, in one place only:

  • services/web/scripts/optimize-images.ts emits AVIF and WebP at 480 / 828 / 1200 / 1600 / 2400 / 2880 px plus a blur preview, within a 200 KiB budget, into app/generated/image-manifest.ts.
  • services/web/app/components/blocks/product-screenshot.tsx:222 renders a <picture> with a separate phone crop (media="(max-width: 639px)"), srcSet, sizes and explicit width/height.
  • The @tale/ui Image primitive (packages/ui/src/components/primitives/image.tsx) already passes srcSet, sizes, dimensions and a blur placeholder through.

Proposed change

Two parts that share one manifest. Part 2 can follow part 1.

  1. Deliver the right size. One width ladder and format policy (AVIF + WebP) for every captured image, generated from the capture, with the existing /images/<section>/<shot>.webp path kept as the full-size file. The shared markdown image component renders srcset, sizes and the intrinsic width/height from the manifest, so a phone fetches a phone-sized file and the layout is reserved before the image loads. The lightbox keeps loading the largest.
  2. Capture the right dimension. Let a shot be captured at more than one viewport (phone, tablet, desktop) where the page differs, recorded as variants of the same shot in the manifest, and let a page pick the matching one (<picture media>, as the marketing site does) instead of one desktop screenshot scaled down. README tiles and social cards (for example 1200×630) come out of the same pipeline, not by hand.

One implementation, not two: the docs and the marketing site should share the encoder, the manifest shape and the image component rather than the docs growing a copy of optimize-images.ts. Decide where the shared piece lives (@tale/ui for the component; the encoder wherever both services can import it).

All places to cover

  • Docs screenshots: EN, DE and FR trees
  • ui-docs: social image and any inline images
  • Marketing site: confirm it meets the same budget and rules; it is the reference
  • README gallery and tour (.github/assets/)
  • Social/OG images for docs, ui-docs and web
  • In-app images (chat attachments, the document preview, branding logos): no thumbnails are generated today, so check what each loads and at what size

Acceptance criteria

  • A written ladder, format policy and per-variant byte budget, enforced by a test (extend image-manifest.test.ts: every variant exists, is referenced, sits on the ladder and matches its file header; no orphans).
  • Every docs image renders with srcset, sizes and width/height; no layout shift as images load.
  • The existing /images/… URLs keep answering as the full-size file (the README and external pages link them).
  • Shots whose layout differs by device have phone and desktop captures; list which ones in the PR.
  • Before/after numbers in the PR: image bytes and CLS/LCP for one representative docs page at a phone width and at desktop width.
  • docs/AGENTS.md, the write-docs skill and the screenshot-capture README describe the new flow; the Turbo input globs and their guards (services/docs/turbo.json, services/web/turbo.json) cover any newly generated files.

Open decisions

  • Scope of "different dimensions": delivered widths (part 1), capture viewports (part 2), or both.
  • Whether generated variants are committed (as the marketing site does: "no build-step dependency") or built.

Activity

  1. added
    perf
    improvement
    on Oct 10, 2026
  2. added
    agent-ready
    on Oct 29, 2026
  3. tale-code-bot commented on Nov 1, 2026

    @tale-code-bot
    Collaborator

    Triage split this issue in three (task TALE-112):

    1. Responsive delivery of the docs images (EN, DE and FR trees). This covers:

      • one width ladder, AVIF + WebP policy and byte budget, shared with the marketing site's encoder;
      • committed variants;
      • srcset, sizes and width/height on every docs image.

      TALE-112 works it, and its commit will close this issue.

    2. Per-viewport capture (phone, tablet, desktop) with <picture media>: feat(docs): capture screenshots per viewport where the layout differs #5250.

    3. README tiles, social cards, video posters and the in-app image audit: perf: right-size README tiles, social cards and in-app images #5251.

  4. added a commit that references this issue on Nov 1, 2026
    1a17c9e
  5. added 2 commits that reference this issue on Nov 1, 2026
    183d184
    b2bd5ce
  6. tale-code-bot commented on Nov 1, 2026

    @tale-code-bot
    Collaborator

    Landed on the feature line release/0.6 with feature train #5265, merged by rebase at 2026-11-01 17:57:59Z, as b2bd5ce perf(docs): serve each docs image in the widths a screen needs (task TALE-112). It ships with Tale 0.6.0.

    GitHub closes an issue from a Closes #4686 line only for a commit on the default branch main, so the feature-train role closes it here.

  7. added 15 commits that reference this issue on Nov 2, 2026
    21c6297
    da3eb15
    65fb9e5
    930dda6
    ceefe59
    909d057
    31dc496
    21a4efb
    2705ce1
    8fd71a7
    0aad774
    91f123e
    03b129f
    2d69210
    614c5d6
  8. added a commit that references this issue on Nov 15, 2026
    1a92b06
  9. added a commit that references this issue on Nov 23, 2026
    9918354
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyimprovementperf

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions