fix(core): prepare seeded media usage - #2472
Conversation
🦋 Changeset detectedLatest commit: c1b3d8e The changes in this PR will be included in the next version bump. This PR includes changesets to release 17 packages
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 |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-demo-do | c1b3d8e | Aug 15 2026, 11:49 PM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-playground | c1b3d8e | Aug 15 2026, 11:49 PM |
There was a problem hiding this comment.
This is the right change, solving the right problems.
The PR addresses two specific, linked issues in the seeded-media / dev-bypass path: seed $media references were saving the storage-key ULID as the MediaValue id instead of the actual media row id, and the dev-bypass had no step to populate the Media Usage index for freshly seeded sample content, so local demos opened to empty "Used in" data.
I checked:
packages/core/src/seed/apply.ts—resolveMedianow mints a separatestorageIdfor the storage key and usesmedia.idfor the returnedMediaValue.id. This correctly binds seed image/file references to the media-library row.packages/core/src/astro/routes/api/setup/dev-bypass.ts— afterapplySeed, it repairs Media Usage only whenincludeContentis true and at least one content row was created or updated, and only for collections present in the seed. It does not touch incremental capture activation.packages/core/src/media/usage/content-repair.ts— the existing collection repair utility is invoked; it works in non-identity mode while activation state isexpanded(the default), so the post-seed repair matches the "no incremental capture" constraint.- Tests —
seed/media.test.tsnow assertsidequalsmedia.id, directly verifying the storage-vs-row ID fix.setup-dev-bypass.test.tsadds a regression test that the bypass leaves Media Usage ready and activation inexpanded. - AGENTS.md conventions — no new queries are added to any logged-out hot path (this is a dev-only setup route). Kysely usage is safe (
validateIdentifierfor collection slug). The changeset is user-facing and present-tense.
No blocking issues or AGENTS.md violations found. The implementation is minimal, gated correctly, and the tests cover both the ID fix and the bypass readiness fix.
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-demo-cache | c1b3d8e | Aug 15 2026, 11:50 PM |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/registry-verification
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
There was a problem hiding this comment.
Re-review of the rebased branch. The diff matches the previously approved patch: seed $media now stores the actual media row id in MediaValue.id while keeping the storage key under meta.storageKey, and the dev-only setup bypass repairs the Media Usage index for any seeded content collections after applySeed completes.
I re-checked:
packages/core/src/seed/apply.ts—resolveMediamints a separatestorageIdfor the storage key and usesmedia.idfor the returned value. The local provider’sgetEmbedalready prefersmeta.storageKey, so file URLs continue to resolve to the uploaded object whileMediaValue.idcorrectly points at the library row.packages/core/src/astro/routes/api/setup/dev-bypass.ts— the repair loop is gated onincludeContent, seed validation passing, and at least one content row created or updated. It only touches collections present in the seed and throws if repair does not complete, which is appropriate for a dev-only setup route.packages/core/src/media/usage/content-repair.ts— in the defaultexpandedactivation state this runs in non-identity mode, so incremental capture is not activated.- Tests —
seed/media.test.tsassertsMediaValue.idequals the createdmediarow, andsetup-dev-bypass.test.tsverifies the usage index is ready while activation remainsexpanded. - AGENTS.md conventions — no logged-out hot-path changes, no new interpolated SQL (
validateIdentifieris used), changeset is present-tense and user-facing.
No regressions or AGENTS.md violations surfaced on the re-read. The branch is ready to merge.
What does this PR do?
Fixes two problems that made local seeded Media Usage demos misleading:
$mediaseed values now store the ID of the media-library row that was actually created, instead of a separate temporary storage ID;The preparation runs only from the development bypass, only after seeded content changed, and does not activate incremental capture. Schema-only setup with
?content=0remains unchanged. Production activation is still controlled by #2445.This PR is stacked directly on #2470 and should be reviewed relative to
feature/media-usage-used-in-ui.Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runAI-generated code disclosure
Screenshots / test output
No visual changes.
Verified locally after restacking on #2470:
Try this PR
Open a fresh playground →
A full working EmDash site, deployed from this branch. Each visit gets its own session-scoped sandbox: no login needed and no shared state. Try the admin, edit content, hit the public site.
Tracks
chore/media-usage-dev-seed-readiness. Updated automatically when the playground redeploys.