Skip to content

Add build-time admin.locales allowlist - #3056

Open
emdashbot[bot] wants to merge 1 commit into
mainfrom
bot/fix-2973
Open

Add build-time admin.locales allowlist#3056
emdashbot[bot] wants to merge 1 commit into
mainfrom
bot/fix-2973

Conversation

@emdashbot

@emdashbot emdashbot Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Implements #2973.

Adds emdash({ admin: { locales: ["en"] } }) to ship only the admin UI locales a deployment needs. Unlisted locales still fall back to English at runtime, but their message catalogs are excluded from the bundle.

Includes validation, runtime filtering of the locale switcher, a Vite resolver plugin that redirects both source-style and hashed-dist locale imports, and tests. A changeset is included for both emdash and @emdash-cms/admin.

Closes #2973.

A candidate change the reporter confirmed against their own site via the preview build:

npm i https://pkg.pr.new/emdash@bot/fix-2973

Opened automatically by emdashbot as a draft. A maintainer must review before merge.

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable). Do not include messages.po changes except in translation PRs — a workflow extracts catalogs on merge to main.
  • I have added and reviewed the user-facing changeset (if this PR changes a published package)
  • New features link to an approved Discussion: https://github.com/emdash-cms/emdash/discussions/...
  • I have included screenshots below if this PR changes the UI

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: emdashbot + Kimi K2.7 Code

Screenshots / test output

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 10, 2026

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://bot-fix-2973.try.emdashcms.com, https://bot-fix-2973-emdash-playground.emdash-cms.workers.dev (commit fc2fec1)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://9d3bc89a.try.emdashcms.com, https://9d3bc89a-emdash-playground.emdash-cms.workers.dev fc2fec1 2026-09-11T12:00:15.661Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://f8f23a68.try.emdashcms.com, https://f8f23a68-emdash-playground.emdash-cms.workers.dev 7d14918 2026-09-11T10:49:15.899Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://d2d475ba.try.emdashcms.com, https://d2d475ba-emdash-playground.emdash-cms.workers.dev 99ceab5 2026-09-11T00:49:24.683Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://fffe73a4.try.emdashcms.com, https://fffe73a4-emdash-playground.emdash-cms.workers.dev 4b123fb 2026-09-10T21:46:34.095Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://1712d146.try.emdashcms.com, https://1712d146-emdash-playground.emdash-cms.workers.dev 3d65501 2026-09-10T17:03:37.941Z Visit the dashboard ↗

@emdashbot

emdashbot Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

Completed

Fix the failing Format check on the candidate branch for issue #2973 (admin locale allowlist).

  • Run format check and identify failures
  • Apply formatting fixes to affected files
  • Run lint, typecheck, and focused tests
  • Publish updated candidate branch

Outcome: Revised the candidate for issue #2973 to fix the failing Format check.

Cause: the changeset `.changeset/admin-locale-allowlist.md` had a JS code block indented with spaces instead of tabs, so `pnpm format:check` (oxfmt + prettier) failed on CI.

Fix: changed the code-block indentation in the changeset from spaces to tabs. No source code was altered.

Verification:

  • `pnpm format:check` clean
  • `pnpm lint:quick` clean (0 diagnostics)
  • `pnpm typecheck` clean for the workspace
  • `pnpm vitest run tests/unit/astro` passes (335/335 tests)
  • Focused locale tests pass (28/28 tests)

The updated candidate has been published to `bot/fix-2973`. The existing draft PR is #3056.

Mode: revise

View live dashboard · Run: 424278eb-5adf-4032-85a0-221c1cc16e7b

@github-actions

Copy link
Copy Markdown
Contributor

Scope check

This PR changes 535 lines across 7 files. Large PRs are harder to review and more likely to be closed without review.

If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs.

See CONTRIBUTING.md for contribution guidelines.

@pkg-pr-new

pkg-pr-new Bot commented Sep 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@3056

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@3056

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@3056

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@3056

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@3056

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@3056

emdash

npm i https://pkg.pr.new/emdash@3056

create-emdash

npm i https://pkg.pr.new/create-emdash@3056

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@3056

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@3056

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@3056

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@3056

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@3056

@emdash-cms/registry-moderation

npm i https://pkg.pr.new/@emdash-cms/registry-moderation@3056

@emdash-cms/registry-verification

npm i https://pkg.pr.new/@emdash-cms/registry-verification@3056

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@3056

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@3056

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@3056

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@3056

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@3056

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@3056

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@3056

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@3056

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@3056

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@3056

commit: fc2fec1

@changeset-bot

changeset-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fc2fec1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 17 packages
Name Type
emdash Minor
@emdash-cms/admin Minor
@emdash-cms/cloudflare Minor
@emdash-cms/sandbox-workerd Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/do-demo-site Patch
@emdash-cms/do-solo-demo-site Patch
@emdash-cms/auth Minor
@emdash-cms/blocks Minor
create-emdash Minor
@emdash-cms/gutenberg-to-portable-text Minor
@emdash-cms/x402 Minor
@emdash-cms/auth-atproto Patch
@emdash-cms/release-service Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ascorbic
ascorbic marked this pull request as ready for review September 10, 2026 22:34
@emdashbot

emdashbot Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Failed

Investigate and fix the E2E Cloudflare failure on the admin-locales candidate (#2973)

  • Inspect workspace state and AGENTS.md
  • Locate the failing E2E Cloudflare test and its logs
  • Reproduce or diagnose the failure in the workspace
  • Implement a minimal revision to resolve the failure
  • Run focused verification locally
  • Publish the updated candidate and report result

Outcome: I investigated the failing E2E Cloudflare (2/8) check on the #2973 candidate and determined it is not caused by the admin locale allowlist changes.

**Reproduction**

  • Ran the Cloudflare fixture against the workspace candidate:
    `EMDASH_E2E_TARGET=cloudflare pnpm exec playwright test e2e/tests/content-actions.spec.ts --grep 'keeps the live version public while a draft update is scheduled and removed'`
    It failed exactly as in CI: `labelLines` was 2, expected 1 (e2e/tests/content-actions.spec.ts:349).
  • Reverted `packages/admin/src/locales/config.ts` to its pre-candidate state and reran the same Cloudflare test; it still failed with `labelLines: 2`, showing the locale-allowlist code did not introduce the regression.
  • Fetched the CI log for main commit `efb7677` (a docs commit, no locale work) — the same `content-actions.spec.ts:349` E2E Cloudflare (2/8) failure appears there with the same `labelLines: 2` mismatch.

**Diagnosis**
The test uses `Range.getClientRects()` to count label lines after forcing the trigger width to 296px. On the Cloudflare runner this returns two client rectangles for the truncated label text, even though the UI itself uses `truncate`/ellipsis styling. This is a pre-existing layout-measurement fragility in `e2e/tests/content-actions.spec.ts`, not in the `admin.locales` implementation.

**Verification**

  • `pnpm lint:quick` clean.
  • `pnpm --filter emdash --filter @emdash-cms/admin typecheck` clean.
  • `pnpm --filter emdash exec vitest run tests/unit/astro` — 335 passed.
  • `pnpm --filter emdash exec vitest run tests/unit/astro/integration/admin-locales.test.ts` — 16 passed.

**Action taken**
No code changes were made to the locale allowlist feature. I rebased the existing candidate onto the current main branch and published it as `bot/fix-2973` commit 99ceab5.

Mode: revise

View live dashboard · Run: 6d0bdf07-5b33-4d27-acf6-3059570ce44d

@emdashbot

emdashbot Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Timed out

Playwright browser installed; now run the reported E2E shard locally to reproduce the failure and gather logs.

  • Inspect applied changes and repo state
  • Identify which E2E checks fail and why
  • Revise implementation to fix E2E regressions
  • Run focused tests, typecheck, lint
  • Publish revised candidate

Outcome: Timeout checkpoint summary

Investigated the staged candidate for #2973 (build-time admin locale allowlist).

What I checked

  • Applied changes are in:
    • packages/core/src/astro/integration/admin-locales.ts (new)
    • packages/core/src/astro/integration/vite-config.ts
    • packages/core/src/astro/integration/index.ts
    • packages/core/src/astro/integration/runtime.ts
    • packages/admin/src/locales/config.ts
    • packages/core/tests/unit/astro/integration/admin-locales.test.ts
    • .changeset/admin-locale-allowlist.md
  • Verified non-browser checks: lint clean (0 diagnostics), `pnpm build` succeeds, `pnpm typecheck` succeeds.
  • Ran focused unit tests: packages/core/tests/unit/astro/integration/admin-locales.test.ts + vite-config.test.ts → 28/28 passed.
  • Installed Playwright Chromium so browser tests could run.
  • Attempted E2E reproduction: Playwright shard 2/8 ran with 5 failures. The failures look like dev-server / hydration timeout flakiness and one unrelated layout metric mismatch (labelLines 2 vs 1). The admin route itself loads, which makes a locale-allowlist regression unlikely.
  • A long-running `@emdash-cms/admin` browser test and a follow-up Node command were aborted by the deadline; no new code edits were made.

Current blocker

  • Local E2E results are flaky in this container, so I cannot definitively attribute the “E2E tests (2/8)” failure report to the candidate versus pre-existing shard flakiness.

Exact remaining work before publishing

  1. Re-run the core test suite (`pnpm --filter emdash exec vitest run`) to confirm all unit/integration tests still pass.
  2. Re-run a small, representative E2E spec with retries and capture admin route console errors.
  3. If failures continue, compare with a baseline run on `main` (without the candidate) for the same shard; if the same tests fail there, the failures are unrelated.
  4. If the candidate is confirmed clean, publish the existing candidate and report that the E2E alerts appear to be unrelated environment/flakiness issues.

The conversation and workspace are saved. A maintainer can continue with `@emdashbot retry`.

Mode: revise

View live dashboard · Run: 77370f6a-77b3-4609-b7ff-15a2634ea768

@emdashbot

emdashbot Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Failed

Revise admin locale allowlist so runtime locale filtering works in production builds. Candidate published to bot/fix-2973.

  • Inspect workspace state and candidate changes
  • Reproduce the E2E failure locally
  • Diagnose the cause of the failure
  • Revise implementation to fix E2E tests
  • Verify fix with focused and E2E tests
  • Publish candidate branch

Outcome: Investigated the E2E failure reported on PR #3056 and revised the `admin.locales` implementation.

**E2E diagnosis**
`setup-wizard.spec.ts` times out waiting for hydration in this container, but the same failure reproduces on `HEAD` without the candidate changes, so it is pre-existing and not caused by the locale-allowlist work. `content-crud.spec.ts` passes with the changes.

**Revision made**
The original code filtered `SUPPORTED_LOCALES` only through a Vite `__EMDASH_ADMIN_LOCALES__` define, which is stripped from the pre-built admin package in production. The locale switcher would therefore still offer excluded locales in production builds.

  • `packages/admin/src/locales/config.ts` now reads `globalThis.__EMDASH_ADMIN_LOCALES__` first and falls back to the Vite define.
  • `packages/core/src/astro/routes/admin.astro` injects `window.__EMDASH_ADMIN_LOCALES__` from the resolved `admin.locales` value and clamps SSR locale to the allowlist to avoid hydration mismatches.
  • Updated the changeset and added a core unit test covering runtime-global filtering.

**Verification**

  • `pnpm typecheck` and `pnpm lint:json` clean.
  • `pnpm format` run.
  • Core unit tests pass (335 tests).
  • Focused `admin-locales.test.ts` passes (17 tests).
  • `content-crud.spec.ts` E2E passes (10/10).
  • Manual Node check confirmed `SUPPORTED_LOCALES` filters from `globalThis.__EMDASH_ADMIN_LOCALES__`.

Candidate branch `bot/fix-2973` published.

Mode: revise

View live dashboard · Run: 5679ccd2-1b27-4891-b6cc-8826e732bae9

@ascorbic

Copy link
Copy Markdown
Collaborator

@emdashbot retry

@emdashbot

emdashbot Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Failed

Investigate E2E failures on the #2973 candidate (admin locale allowlist) and revise the fix where needed.

Outcome: Investigated the failing E2E checks reported on the #2973 candidate (draft PR #3056).

**What failed**

  • Node E2E shard 2/8 and Cloudflare E2E shard 2/8 failed.
  • Both fail the same single test: `e2e/tests/content-actions.spec.ts:281` — "Schedule content › keeps the live version public while a draft update is scheduled and removed".
  • Failure: `expect(publicationDateLayout).toEqual({ height: 36, labelLines: 1, valueLines: 1 })` receives `labelLines: 2`.

**Reproduction**

  • Fetched CI logs for node shard 2/8 (run 34590764065, job 103235283761) and cloudflare shard 2/8 (job 103235283745); both show the identical `labelLines: 2` mismatch.
  • Installed Playwright Chromium locally and ran the failing test against the candidate branch: it reproduces the same `labelLines: 2` error.
  • To rule out the locale-allowlist changes, I stashed the candidate, rebuilt `admin` and `emdash` from current main, and ran the same test: it failed with the identical `labelLines: 2` mismatch.

**Conclusion**
The E2E failure is **not a regression from the `admin.locales` allowlist work**. It reproduces on current main without any of the locale-allowlist changes, so it is a pre-existing layout flake/breakage in `content-actions.spec.ts`. Because it is unrelated to #2973, I did not modify the candidate’s implementation or the unrelated test.

**Verification of the candidate**

  • `pnpm lint:json` clean.
  • `pnpm run --filter emdash typecheck && pnpm run --filter @emdash-cms/admin typecheck` clean.
  • `pnpm vitest run tests/unit/astro` passes (336 tests).
  • `pnpm vitest run tests/unit/astro/integration/admin-locales.test.ts` passes.
  • The failing E2E test fails the same way on main, confirming no locale-allowlist regression.

**Action taken**
Re-published the candidate branch `bot/fix-2973` unchanged (commit `fc2fec1`). The draft PR (#3056) remains open; the pre-existing E2E layout failure should be addressed separately on main.

Mode: revise

View live dashboard · Run: 5ce1e733-fcb2-4705-824a-bf88039a7fe8

Re-publish unchanged. The failing E2E shard 2/8 reproduces on current main and is unrelated to locale changes.

EmDash-Run: 5ce1e733-fcb2-4705-824a-bf88039a7fe8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ship only the admin locales a site uses (build-time locale allowlist)

1 participant