Skip to content

fix(stories): load the country flags in Ladle - #480

Merged
Ardnived merged 1 commit into
mainfrom
claude/fix-ladle-flags
Nov 25, 2026
Merged

Ardnived merged 1 commit into
mainfrom
claude/fix-ladle-flags

Conversation

@Ardnived

Copy link
Copy Markdown
Contributor

Summary

Country flags did not load in the Ladle design playground. Two faults stacked:

  1. src/lib/flag-cdn.ts: Vite's dev server treated new URL('/flags/', import.meta.url) as an asset reference and rewrote it to /@fs/flags (slash dropped), so every flag src was /@fs/flagsin.svg.
  2. scripts/circle-flags.mjs: Ladle's server is Koa, which presets the status to 404 before middleware runs, so even a correct /flags/in.svg answer arrived as a 404 and the browser drew nothing.

Change outline

 scripts/circle-flags.mjs
+        res.statusCode = 200
 src/lib/flag-cdn.ts
-export const FLAG_CDN_URL = new URL('/flags/', import.meta.url).href
+export const FLAG_CDN_URL = new URL(/* @vite-ignore */ '/flags/', import.meta.url).href

Preview

Design playground story views--countries (Views > Countries): the country list shows its flags again. Preview pending for the deployed playground.

Test results

  • Ladle, views--countries, counting img[data-testid=circle-country-flag] with naturalWidth > 0:
    • on main (fix reverted): 12 flag imgs, 0 loaded (src = /@fs/flagsin.svg)
    • with the fix: 12 flag imgs, 12 loaded (src = /flags/in.svg)
  • .claude/skills/pr-prep/check.sh: lint and typecheck pass. Unit tests: 2390 passed, 1 failed (Modal.focus-opener.test.tsx, which also fails alone and touches neither changed file).
  • pnpm build passes. The bundle emits new URL("/flags/", import.meta.url).href unchanged, so there is no host-observable change and CHANGELOG.md is untouched. pnpm size ran.

Notes for reviewer

Split out of #466 so it can merge first. #466 drops the commit when it rebases.

🤖 Generated with Claude Code

Two faults, both Ladle's dev server alone:

- Vite resolved `new URL('/flags/', import.meta.url)` as an asset under
  Ladle's root and rewrote it to `/@fs/flags`, dropping the slash. The
  build already left it to runtime; `@vite-ignore` makes every server do so.
- Ladle's server is Koa, which presets 404, so the flag middleware's
  answers arrived as 404s. It now sets 200.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 8ed1fd9)
@sydevs-dispatcher

sydevs-dispatcher Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

🤖 no session running

Written by the sydevs dispatcher. Sessions never edit this comment.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
sahajatlas-design 8c72a02 Nov 25 2026, 03:26 PM

@sydevs-dispatcher sydevs-dispatcher Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved for Ardnived, who wrote it: GitHub refuses an author's own approval. CI is green and the automated review has run. Enable auto-merge when you want it merged: the queue tests it against its base. 🤖 Written by the sydevs autonomous loop — see what this is

@sydevs-dispatcher

Copy link
Copy Markdown
Contributor

Adversarial review skipped: 2 file(s), 9 changed line(s), under review.skipWhen. Say @sydevs-bot review to force one.

🤖 sydevs dispatcher

@Ardnived
Ardnived added this pull request to the merge queue Nov 25, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Pending to Awaiting in SYDevelopers Technical Roadmap Nov 25, 2026
Merged via the queue into main with commit 40b7e27 Nov 25, 2026
21 checks passed
@Ardnived
Ardnived deleted the claude/fix-ladle-flags branch November 25, 2026 15:34
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Awaiting to Done in SYDevelopers Technical Roadmap Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant