Repository navigation
fix(core): refresh cached pages after taxonomy edits - #3338
Conversation
🦋 Changeset detectedLatest commit: 17c9d9a The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 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 |
There was a problem hiding this comment.
This PR fixes the taxonomy-only publishing gap by storing staged tag/category assignments inside the draft revision (_taxonomyDrafts) and promoting them together with the next content publish. The approach fits EmDash's revision model, keeps direct API clients backward-compatible (they simply omit stage), handles translation groups correctly, and updates the admin's invalidation paths so tag-only edits now surface Publish changes.
I read the diff, the changed admin/backend files, and the relevant AGENTS.md conventions. The implementation is solid for the happy path and the regression tests cover staging, publishing, discarding, and D1 rollback. The docs and REST API reference are accurate, and the new UI strings are Lingui-wrapped.
One real issue remains: ContentRepository.publish introduces a multi-statement write (promote the content row, then DELETE/INSERT tag assignments). The D1 path uses executeAtomicBatchIfSupported, but the SQLite/Postgres fallback executes those statements sequentially without a transaction. If a tag assignment statement fails after the promote has succeeded, the content row ends up published while the taxonomy changes are only partially applied. The reconciliation logic only checks the content row, so it can even report success. The fix is to wrap the fallback in withTransaction(this.db, ...), matching the pattern already used by restoreDraftRevision. A representative failure test on the fallback adapter should also be added.
| } else { | ||
| const result = await promote.execute(this.db); | ||
| promoted = result.rows.length === 1; | ||
| if (promoted) { | ||
| for (const write of taxonomyWrites) await write.execute(this.db); | ||
| } |
There was a problem hiding this comment.
[needs fixing] The taxonomy-promotion fallback runs the content promote UPDATE and the taxonomy DELETE/INSERT statements without a transaction. On adapters that don't support atomic batches (SQLite/Postgres) a failure after promote succeeds leaves the entry published with only some of its tag/category changes applied. The reconciliation code then only inspects the content row, so it can treat the operation as successful.
Wrap the fallback in a transaction, using the same withTransaction pattern already used by restoreDraftRevision in this file and adding a failure test for the non-atomic adapter path.
| } else { | |
| const result = await promote.execute(this.db); | |
| promoted = result.rows.length === 1; | |
| if (promoted) { | |
| for (const write of taxonomyWrites) await write.execute(this.db); | |
| } | |
| } else { | |
| await withTransaction(this.db, async (trx) => { | |
| const result = await promote.execute(trx); | |
| promoted = result.rows.length === 1; | |
| if (promoted) { | |
| for (const write of taxonomyWrites) await write.execute(trx); | |
| } | |
| }); | |
| } |
Scope checkThis PR changes 750 lines across 16 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. |
@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-test
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/registry-loader
@emdash-cms/registry-moderation
@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: |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
docs | 29eb39f | Sep 23 2026, 05:05 PM |
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://fix-tag-only-publish-changes.try.emdashcms.com, https://fix-tag-only-publish-changes-emdash-playground.emdash-cms.workers.dev (commit 17c9d9a)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
This reverts commit 29eb39f.
Overlapping PRsThis PR modifies files that are also changed by other open PRs:
This may cause merge conflicts or duplicated work. A maintainer will coordinate. |
There was a problem hiding this comment.
This re-review confirms the previous draft-taxonomy concern is gone. The PR now takes the narrower, architecture-consistent fix: term assignments still save immediately, the term-assignment route purges the public edge-cache tags that published pages use, and the admin toast explains that term changes do not wait for Publish changes.
I re-read the diff, the changed route/handler/component files, the new ContentRepository.findTranslationIds, and the added tests against the AGENTS.md conventions. The approach looks right: the reverted staging draft avoided conflating content and term lifecycles, and the cache invalidation stays symmetrical with the existing publish / content-update routes.
What I checked:
- Cache tags: The invalidated tags (
collection, canonical + sibling entry IDs,taxonomyTag(...)) match thecacheHinttags emitted byloader.tsfor collection lists, entries, and taxonomy facets. - Batching: Large translation groups are chunked at
MAX_CACHE_PURGE_TAGS = 100, mirrored by an integration test that asserts no batch exceeds 100 tags. - SQL safety:
findTranslationIdsuses${sql.ref(tableName)}and a parameterizedtranslationGroupvalue, with the existingdeleted_at IS NULLfilter. - Localization: The new admin description is wrapped in Lingui
t; nomessages.pochanges are included. - Authorization: The POST route still checks
content:edit_ownplus ownership, andcache.invalidateis gated oncache?.enabledlike the existing publish route. - Changeset: The
.changeset/lively-tags-cache.mdentry is user-facing, names the observable behavior and the editor clarification, and skips implementation mechanics. - Logged-out query counts: No new queries are added to any logged-out route.
- Prior finding:
ContentRepository.publishis no longer touched by this PR, so the non-atomic taxonomy-promotion fallback from the previous review has been removed along with the staging implementation.
No new blocking issues or regressions remain. The added tests cover the actual behavior (cache invalidation with translation siblings, batch sizing, and the toast copy) rather than asserting the implementation back at itself. LGTM.
What does this PR do?
Fixes tag and category edits leaving cached public pages stale. Term assignments already save immediately; the content publish route purged the public cache, but the term-assignment route did not. It now invalidates collection, translation-entry, and taxonomy-facet cache tags after a successful assignment, batching large purges. The admin explains that term changes do not wait for Publish changes, without promising that a term lacking a locale translation appears on every published page.
The previous draft-taxonomy implementation has been reverted. Publish changes still applies to content drafts, not immediate tag edits. This is the narrow bug fix from the team chat; bulk tagging remains a separate request. There is no GitHub issue to close.
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change) — 35 targeted core and 81 admin browser tests passpnpm formathas been runmessages.pochanges are included.AI-generated code disclosure
Screenshots / test output
Published A Weekend with a Side Project post in
demos/simple, 1440 × 900, English, light theme. The content field is unchanged in both screenshots.Before: Creativity is assigned; the post is published.
After: Tools is assigned immediately, while the post remains published with no pending content draft. The success toast explains that term changes do not wait for Publish changes.
pnpm build,pnpm typecheck,pnpm lint,pnpm lint:quick, andpnpm --silent lint:json(zero diagnostics) pass. Focused route tests cover affected translations, taxonomy facets, and the 100-tag purge limit. Manually checked immediate updates and Arabic RTL layout in the running demo. A persistent second-opinion adversarial review converged with no findings.