Skip to content

fix(richtext): render nested shortcodes in preview - #7899

Merged
martinjagodic merged 3 commits into
decaporg:mainfrom
marthesselink:7895-fix-nested-shortcode-preview
Sep 2, 2026
Merged

martinjagodic merged 3 commits into
decaporg:mainfrom
marthesselink:7895-fix-nested-shortcode-preview

Conversation

@marthesselink

Copy link
Copy Markdown
Contributor

Summary

  • recursively transform editor-component shortcodes before remark-rehype renders the preview
  • preserve existing root-level shortcode behavior
  • add a regression test for a block image nested under an ordered-list item

Problem

Decap CMS 3.15.0 correctly preserves nested block images in the rich text editor after #7896, but the preview pane still omits them. Image editor components are parsed as shortcodes, and the preview transformer only processed root children. Nested shortcodes therefore reached remark-rehype untransformed and were dropped.

Test plan

  • npm run test:ci
  • npm run build
  • npm run build:demo
  • npm run test:e2e:run-ci (48 specs, all passed)
  • npm run test:package-integrity

Fixes #7898

@yanthomasdev yanthomasdev 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.

Thanks!

@martinjagodic
martinjagodic enabled auto-merge (squash) July 24, 2026 07:26
@netlify

netlify Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for decap-cms ready!

Name Link
🔨 Latest commit b97bfaf
🔍 Latest deploy log https://app.netlify.com/projects/decap-cms/deploys/6a9815063f5ef3000885acde
😎 Deploy Preview https://deploy-preview-7899--decap-cms.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@martinjagodic
martinjagodic merged commit 4d3d3ba into decaporg:main Sep 2, 2026
13 checks passed
sempostma added a commit to laikacms/decap-cms that referenced this pull request Nov 12, 2026
)

* fix(gitlab): refresh expired tokens for GraphQL and REST 401s (#7932)

* fix(gitlab): refresh expired tokens in GraphQL requests

* fix(gitlab): refresh on standard REST 401 response

GitLab REST APIs return { message: '401 Unauthorized' } for invalid or expired credentials.

Recognize that documented response alongside existing OAuth and GraphQL error shapes.

PKCE authentication can then refresh and retry, including the initial user request.

---------

Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com>
Co-authored-by: Martin Jagodic <jagodicmartin1@gmail.com>

* feat(turbo-github): poll site_deployments for deploy status (A3)

The read side of the deploy-status feature: a DeployWatcher that turns
`site_deployments` rows for one commit into a sequence of updates. Nothing
renders yet — the toast is A4.

v1 polls every 5s, behind a DeployTransport so Realtime later replaces one
object rather than the lifecycle rules, which are the shared and easily
mistaken part. Four of those rules are worth naming:

- Core awaits persistEntry and discards its return value, so the commit sha
  had nowhere to live. The backend remembers it as `lastSavedCommit`, and
  clears it on any save that produced none (the REST fallback path) — keeping
  the last one would have that save watch the previous commit's deploy.
- Giving up is the ordinary path, not the edge case: per A0 most sites never
  produce a deploy row at all, so `absent` after 20s and `timeout` at 15min
  are first-class outcomes rather than a UX afterthought.
- Between concurrent deploys, success > running > failed > canceled. A
  success outranks a sibling's failure because the change IS live, and a
  running deploy outranks a failed one because "failed" is not recoverable
  from once shown.
- Stop handles are generation-scoped: A4 mounts this in the app shell, which
  will hold the handle across saves, and save #1's handle must not tear down
  save #2's watch.

Three consecutive poll failures degrade to `absent`, not `failed` — a poll
crossing a token refresh must not end the watch, and inventing a failure
would send the editor after a build log that does not exist. The fetcher
refuses to read without a session: the anon key cannot satisfy the select
policy, so that read would be a guaranteed empty result that looks like "no
deploy".

Not mirrored into turbo-gitlab, unlike supabase.ts and saveMetrics.ts: a
GitLab site cannot produce a row until the generic deploy hook lands, so the
mirror would poll four times per save and always report absent.

See decap-turbo/docs/deploy-status-plan.md §A3.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(core): follow a save's deploy in one updating toast (A4)

"Entry saved" tells an editor their entry was committed, not that the site
they publish has rebuilt. This turns that one-shot toast into a single toast
that follows the deploy: Saved · Publishing… → Building your site… → Your
change is live, with a View link, or a held-open error carrying the build
log.

The core half is generic and upstreamable: notifications gain
updateNotification(id, payload), a NOTIFICATION_UPDATE case, an optional
caller-supplied id, an optional action link, a spinner flag, and a
toast.update path in the component. Nothing about deploys is in any of it.

The wiring stays generic by duck-typing: deployStatus.ts asks the backend
implementation for `watchDeploy` and does nothing if it is absent, so every
backend other than Turbo keeps exactly today's behaviour — as does editorial
workflow, by construction rather than by a check, since the one-call commit
is refused under useWorkflow and so produces no sha to watch.

Four decisions worth naming:

- `dismissAfter: false` had to become expressible. Omitting it does not mean
  "stay up" — react-toastify then applies its own 5s default, which would
  close the Publishing toast before any deploy could report. `undefined`
  still means what it meant, so no existing notification changes.
- The watcher is a thunk-held subscription rather than an app-shell
  component. It survives navigation either way, and a component would need
  new store state to know which commit to watch.
- A canceled deploy collapses to plain "Entry saved" alongside absent and
  timeout: nobody's change broke, someone stopped a build. Only `failed` is
  held open, because it is the one outcome with an action attached.
- A second save replaces the first's toast, so a stale "Publishing…" cannot
  sit next to a fresh one, both claiming to be the save just made.

Not yet seen in a browser: decap-turbo-develop is not an allowed branch on
the decap-cms Netlify project, so it builds no bundle to test with.

See decap-turbo/docs/deploy-status-plan.md §A4.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(core): let a new save clear the previous deploy toast in every state

Found in the browser on the deployed develop bundle: save, let the build
fail, then save again — and the held-open red "Your site failed to build"
sits next to a fresh "Publishing…". Two toasts, one of them red, about two
different commits, at the moment the editor is least able to tell them
apart. It reads as though the new save had failed too.

The cause was finish() clearing activeDeployNotificationId on the watch's
last update, so the next save had nothing to dismiss. That was deliberate
and wrong: the failed toast is the ONE outcome deliberately held open, which
makes it exactly the toast still on screen when the editor saves again —
usually because it failed. Keep the id past the end of the watch instead;
dismissing an id whose toast is already gone is a no-op, so a stale one
costs nothing.

The test that asserted the old behaviour now asserts the new one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(core,turbo-github): async, entry-scoped deploy notifications (A4b)

Replaces A4's single updating toast. A4 held one toast open from save until
the deploy finished; on a site that builds for minutes that is a spinner
pinned to the corner for minutes, and it reported only the most recent save,
and it treated a build cancelled in favour of a newer commit as nothing
happening. Editors should be informed, not blocked.

All three fall out of one reframing: the question is not "did MY commit's
deploy succeed" but "has a deploy that CONTAINS my commit succeeded".
Ancestry, not identity. GitHub's compare answers it exactly in one call
(ahead/identical = contained), asked only when a successful deploy names a
commit that is not ours — which is exactly the cancelled-in-favour-of-newer
case.

So the watcher becomes one per site holding a ledger of this editor's
unpublished saves, keyed by entry path with the newest commit winning (a
stale version must never be announced as live). It polls on a backoff — 5s
for the first minute, 15s to three, then 30s: ~54 requests across a
twenty-minute build where flat 5s polling was 240 — and survives a reload
through localStorage, because a build easily outlives one.

Outcomes: a success carrying the change announces it, naming the entry when
there is one and counting them when a deploy carries several. A failure is
reported but the save STAYS in the ledger, so a fixed build still closes the
loop with "your change is live". A cancelled deploy resolves nothing at all
and the ledger keeps waiting for the newer deploy that carries the change.
An unanswerable ancestry question resolves nothing either — "your change is
live" is the one claim this feature exists to make trustworthy, and two
clocks are not evidence for it.

The subscription moves to App mount, so a resolution reaches the editor
wherever they have navigated to, and so a reload resumes the ledger.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(turbo-github): three defects in the ledger watcher

Found reviewing A4b before verifying it.

A save made just before the silent-watch window closed was thrown away one
second later, together with the whole ledger — the window was measured from
when the watch started and never restarted. Worse, a ledger restored after a
page reload was already older than the window, so resume discarded it before
its first poll: exactly the case the persistence exists for. The window now
restarts with each save, while the 20-minute per-save expiry still bounds it.

Resolution rejecting became an unhandled rejection; it is caught and logged.

And a watcher whose last listener went away kept polling forever. It now
stops and leaves the ledger in storage, so a later subscribe resumes it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(core): let an update cancel a queued dismissal

A notification created with a dismissAfter arms a timer at that moment.
Updating it to be held open changed react-toastify's autoClose but left the
original timer armed, so the toast still vanished on the first message's
schedule — and the case that hits is precisely the one that must not: a
"Saved · Publishing…" toast (4s) updated into a held-open failed build.

The queued dismissal is now held rather than merely flagged, so a changed
dismissAfter clears it and re-arms only if the new one is truthy. Also
cleared when the notification goes away, so a dismissed toast leaves no
timer behind.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(deploy-status): a Deploys page and a header state indicator (A8)

Toasts announce events and then leave. Between "Saved · Publishing…"
dismissing and "your change is live" arriving, nothing on screen said
what was happening — and a build can run for many minutes. A4b removed
the dwelling and removed every trace of state with it. State needs a
place that is not an interruption.

- The nav item IS the indicator. Two doors to the same page is clutter,
  and folding the state into the door means the one always-visible
  element carries the live answer: "Deploys" at rest, "Publishing…" with
  a save outstanding, "Build failed" when the last build failed.
- A /deploys page, routed like /workflow. Editor language on top — one
  sentence and a View site link — with the deploy table below it, so the
  page is readable by the person who needs it most often. Its empty state
  names the likely cause (a Netlify site with no deploy webhook) rather
  than shrugging.
- Auto-hide is the default (A7): no nav item, no route, until this site
  has actually produced deploy information. A CMS whose host says nothing
  should look like a CMS without the feature.
- `backend.deploy_status` turns it off entirely or one surface at a time,
  and names a primary_target for a site published to several hosts.
- One read on mount, then reads only from the watcher's existing poll or
  an explicit Refresh. An indicator that polled to keep itself current
  would undo A4b's whole cost argument, so the status channel is
  deliberately incapable of starting a poll — asserted in a test.

The Refresh affordance follows the precedent Decap already set with
"Check for Preview" on deploy preview links.

38 new tests; 1615 passing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(deploy-status): subscribe once the user exists, not only at mount

The Deploys nav item never appeared on the real tester. Cause: both
deploy thunks resolve the backend through currentBackend(config), and at
App mount the config is still loading, so both throw, get swallowed, and
never retry. The one read that establishes the site's state had never run.

The same gap was in A4b: a ledger left over from before a page reload
only resumed if the editor happened to save again, because that path
re-dispatches the subscription itself. A reload followed by no further
save would have silently dropped the pending change.

Retry when `user` transitions to present. Both thunks are idempotent, so
the repeat costs nothing, and componentDidUpdate is gated on the
transition rather than firing on every render.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* refactor(deploy-status): address review of the Deploys page and indicator

- Deploys moves to the end of the nav — it is the only item that is not
  somewhere an editor goes to work.
- The indicator is the `circle` icon rather than a styled span, so it
  occupies the same box as the other nav icons and lines up with them.
- Commit ids link to the commit on GitHub, via a duck-typed commitUrl on
  the backend, or render as plain text. A commit that linked to the
  deployed site looked like it would show you the change and showed you
  the home page. The deploy's own link moves onto the state cell, where
  it means the site on success and the build log on failure.
- "Reported by" says GitHub or GitLab instead of "Git provider". The
  source encodes the forge, so there was never a reason to be vague.
- Only the newest success is "Live"; earlier ones are "Deployed". Every
  past success was live once and no longer is. A failed newer deploy does
  not move it: the last success is still what the site serves.
- The page refreshes itself every 10s while open, silently so the Refresh
  button does not flicker, pausing on a hidden tab and stopping on
  unmount. This is the only repeating read, and it is scoped to a page
  the editor deliberately opened — an idle CMS still polls zero times.
- The "live" toast links to the entry itself when one entry is named,
  using the collection's preview_path through the same formatter deploy
  preview links use. Grouped notifications keep the plain site link,
  having no single page to point at.

Non-Turbo backends are unaffected, now asserted rather than assumed: no
subscription, no read, no nav item, no route, and exactly the "Entry
saved" toast they have always shown.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(deploy-status): saved entry and published-to columns, stateful nav

Three from review.

**Saved entry.** The entry↔commit map lived only in the saving browser's
ledger and only until the save resolved, so a colleague's save read as a
bare sha and so did your own after a reload. The commit endpoint now
records the entry's title — the same value the notification shows, not
the commit message, which carries the slug and is template-configurable
— and the page joins it by sha. Core passes the label on every save;
backends that do not record deploys ignore it.

The lookup is guarded: it walks entry data that a preSave handler may
have replaced with a shape it does not expect, and the repo's own test
suite caught exactly that. A missing label costs a column; a throw would
have cost the save.

**Published to.** Every transport already carried where a deploy went and
we discarded it — Netlify's `context`, GitHub's `deployment.environment`.
Branch and environment answer different halves, so they show together
only when they differ. Both recorders now accept `cms/`-prefixed
branches, so an editorial-workflow entry's own deploy is recorded and
the column has something to say; the notification poll stays scoped to
the site branch, so a preview deploy can never resolve a published save.

**The nav item names the state.** A green dot beside the word "Deploys"
leaves the reader to work out what green means. It now reads Deployed,
Publishing…, Building or Build failed, falling back to "Deploys" only
when nothing is known. A superseded deploy counts as deployed: the site
is still serving the last success and the change ships inside the newer
build.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(deploy-status): only the site's own branch can be Live

Measured on the tester: unpublishing an entry under editorial workflow
made Netlify branch-deploy `cms/posts/…`, and that success was the newest
row of all. The Deploys page crowned it "Live", the summary band said
"Your latest change is live", and "View site" pointed at a preview of an
entry that had just been UNPUBLISHED.

The history read is deliberately unscoped so the page can show which
branch each deploy went to — that stays. What was wrong is that three
surfaces derived "the state of the site" from it without ever asking
which branch a row belonged to:

- the watcher's `latest` (the header pill), via `observe`, whose rows
  come from that unscoped read rather than from the branch-scoped poll;
- the reducer's `latest` (the page's summary sentence and View site
  link), taken as `deployments[0]`;
- `liveDeployId` (the "Live" label in the table).

All three now ignore a row that names a different branch. A row naming no
branch is kept: some hosts report none, and refusing those would leave
such a site unable to say anything about itself at all.

The branch reaches core the same duck-typed way as the rest of this
feature — `deployStatusConfig()` carries it alongside the parsed options,
and a backend that names none means "do not scope", not "scope to
nothing". `selectDeployStatusVisible` gains a `deployments.length` clause
so a site whose host only reports branch deploys still gets the page:
that site has real deploy information and nothing live, which is exactly
what the page is for.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(richtext): render nested shortcodes in preview (#7899)

Co-authored-by: Martin Jagodic <jagodicmartin1@gmail.com>

* fix(core): stop Editor crashing when its route names a collection missing from state

RouteInCollection's own guard (App.js) and Editor's/withWorkflow's independent
mapStateToProps both read state.collections separately, so a store update
between their renders can let the latter run first with a stale route param —
reproduced live for both a permission-filtered collection and, transiently,
one the member does have access to. withWorkflow now redirects instead of
ever mounting Editor in that case, and both mapStateToProps functions bail
out safely rather than chaining `.get()` on undefined.

* feat(turbo-github,turbo-gitlab): show signed-in user identity and clear session on logout

* refactor: migrate from npm to pnpm (#7645)

* refactor: migrate from npm to pnpm

* feat: migrate project setup from npm to pnpm

* fix: pnpm version in CI

* fix: fixed ci lint errors

* refactor: remove unnecessary React imports across components and tests

* refactor: refactor components to extend from React.Component

* feat: add common-tags to external package exports

* refactor: removed copy-text-to-clipboard

* refactor: push pnpm-lock.yaml

* fix: fixed remaining test:ci errors

* fix: fixed test:unit warning with new jsx transform

* fix: update babel config to include @emotion/babel-plugin and remove deprecated preset

* fix: jest updateSnapshot for svg

* fix: fixed jest and cypress errors

* fix: remove React imports

* fix(lint): handle PlateJS import resolution

* fix(ci): make pnpm release path publishable

* fix: tests

* chore: format

* fix: tests

* chore: update pnpm to v11

* fix: add missing dependency

* fix: update snapshots

* fix: jest resolver config

* fix: cypress proxy

---------

Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com>
Co-authored-by: Martin Jagodic <jagodicmartin1@gmail.com>

* perf(turbo-github,turbo-gitlab,backend-github): cut redundant and duplicate reads

Measured on the turbo tester (3 locales, editorial workflow, 205 entries),
every call through the `gh` proxy costs ~1.3s, roughly half of it the
proxy's own auth/scope/quota preamble. A collection load took 7.5s across
12 requests, of which the one that actually produces the list — a
PostgREST read of the content cache — took 326ms. So the cost is request
count, and four of those requests were avoidable.

Drop `hasWriteAccess()` from turbo-github's `authenticate` (-1.84s). It
reads `permissions.push` for the signed-in GitHub user; Turbo has no
signed-in GitHub user, it commits as the organization's App installation,
which is why `bypassWriteAccessCheckForAppTokens` is set and the answer
was already being discarded. Its other upstream side effect — normalising
`repoOwner` to GitHub's casing — is moot here because `preloadConfig`
takes the repo from the authoritative `sites` row.

Fetch the open pull request list once in `listUnpublishedBranches`
(-1.75s). Both `getPullRequests` calls passed the same `head` and
`state`, differing only in a client-side predicate, so they issued a
byte-identical request on every collection load. The list is now re-read
only when a label migration actually ran, since migrating is what changes
the answer. This fixes the plain GitHub backend too.

Add a request coalescer to both turbo backends (-2.67s on entry open).
With `i18n.structure: multiple_files`, opening one entry calls `getEntry`
once per locale concurrently, and each locale that misses the content
cache resolved its blob sha from the same parent-folder tree — two
identical tree requests in the same tick. It is in-flight only: an entry
is dropped the moment its request settles, so it can never serve a body
the network has moved past.

Overlap `fetchTurboPermissions` with user resolution (-0.59s). Nothing
before it reads its result, and `currentUser` is local, so pairing them
costs nothing. GitLab keeps its write-access check: there the group
token's write access is a real question with a real answer.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* perf(core,turbo-github): answer "is this entry in the workflow" from state

Opening a published entry began with a full round trip whose answer the CMS
already had. `loadUnpublishedEntry` calls `backend.unpublishedEntry`, which
re-derives — for that one slug — the same set of open, CMS-labelled pull
requests the unpublished-entries list was built from moments earlier on the
collection page. When the list is loaded and the slug is not in it, the
entry is by definition not under editorial workflow, and the request only
delays the published entry's own load. Measured through Turbo's proxy at
2.4s, paid on every open of every published entry.

The list is kept current locally as a session works: persisting adds the
entity, publishing and deleting remove it. What it cannot see is a draft
another editor created since the list loaded — but neither can the
collection list or the Workflow tab, which render from this same state, so
the staleness is not new here, and navigating to either reloads it. A list
that never loaded, or whose load failed, leaves `pages.ids` absent, so the
guard stays off and the backend is still asked.

The existing loadUnpublishedEntry test was loading an entry that was absent
from its own fixture's list; its fixture now contains the entry it claims
to load, and two tests cover the new path and the never-loaded case.

Separately, allEntriesByFolder now starts the cache read alongside the
collection sync instead of after it. The sync costs 1.4s even when it has
nothing to do, because it revalidates the branch head through a proxy that
charges a fixed preamble per request, while the read is ~300ms — so
serialising them spent the read's whole duration for nothing on every warm
load. The speculative read is only used when the sync reports `fresh`,
meaning the head already matched the ingested sha and nothing was written;
any other answer discards it and reads again, and a speculative read that
fails is swallowed rather than allowed to fail a load the authoritative
read would have served.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: make pnpm run build and lint work under corepack-managed pnpm

npm-run-all resolves the package manager from npm_execpath and decides
whether to run it via node by testing /\.m?js/ against the extension.
pnpm's entry point is pnpm.cjs, so that test fails and npm-run-all
spawns the .cjs file directly. Corepack's cached wrapper is mode 644,
so the spawn fails with EACCES.

  run-s (build)  -> exits 1, "spawn .../pnpm.cjs EACCES"
  run-p (lint)   -> -c --aggregate-output swallows it and exits 0,
                    so lint silently checked nothing, and test:ci's
                    lint-quiet step passed without running a linter

Both reproduce on a pristine main checkout, so this is not specific to
this branch.

- decap-cms{,-core,-app}: collapse `build` into a single webpack call
  and drop the now-unused `webpack` script. This also removes a second
  fragility: `node ../../node_modules/webpack/bin/webpack.js` only
  resolves because a pnpm .bin shim happens to have set NODE_PATH, so
  it fails standalone. The webpack bin shim plus NODE_OPTIONS is what
  the other 42 packages already do.
- root: pass --npm-path pnpm to run-p, which takes precedence over
  npm_execpath, so lint works however pnpm was installed.

Worth upstreaming to main.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(turbo-github,turbo-gitlab): refresh the token before fetching permissions

Caught on the tester: `GET /functions/v1/permissions` came back 401 on load.
Running `fetchTurboPermissions` concurrently with `api.user()` — the previous
commit's change — meant it read `supabaseAccessToken` before the refresh
that `currentUser` performs had landed, so it sent an expiring token. While
the two were sequential it inherited that refresh by accident of ordering.

A 401 here does not fail loudly. `fetchTurboPermissions` catches it and
returns undefined, and core then loads the config with no `permissions`
object at all — so a member with collection restrictions silently gets the
unrestricted UI. Server-side enforcement still holds, so this was never an
access hole, but it is the wrong thing on screen.

Fixed by making the method self-sufficient rather than re-serialising it: it
now awaits `refreshSessionIfNeeded` itself, like every other call site that
sends this token. Refreshes are memoised on `refreshedTokenPromise`, so
sharing one with `currentUser` costs nothing and the concurrency stands.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* perf(turbo-github): route a first editorial-workflow save through _content/commit

Putting an entry into review cost seven sequential round trips through the
proxy — a blob per file, a branch read, a tree, a commit, a ref, a pull
request and a label — which measured as roughly 15s of a ~23s save. The
endpoint now understands the whole intent, so it is one.

Scoped to the FIRST workflow save. Saving an entry that is already
unpublished rebases its own branch and works out which media to drop from a
diff the client reads; that is a different operation, not a commit with
extra steps, so it stays on the REST path along with open authoring (which
creates a branch with no pull request, from a fork) and renames.

If the commit lands but the pull request or the label does not, the server
says so and only those steps are redone over REST. Re-running
`super.persistFiles` there would upload every blob again and add a second,
identical commit, so the fallback is deliberately narrower than the one used
when nothing was committed at all.

400 joins 404 and 413 as a fallback status. All three are refusals that
happen before any GitHub call, so retrying on REST cannot double-commit —
and it is what makes the CMS bundle and the edge function safe to deploy in
either order: a bundle that sends a request shape the deployed function does
not understand yet saves over REST instead of failing in front of an editor.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(turbo-github): do not watch a deploy for an editorial-workflow save

Routing workflow saves through `_content/commit` made `persistEntry` start
returning a sha where the REST path returned none, which silently enrolled
those saves in deploy watching. The commit lands on the entry's own
`cms/...` branch and never appears in a deploy of the site's branch, so the
editor would have been left waiting on a deploy that was never coming.

An unpublished entry is not going live, and the plain "Entry saved" is the
honest thing to say about it — so the sha is only remembered when the commit
actually targeted the site's branch. Checked against the branch the server
reports committing to, rather than against `options.useWorkflow`, so it
reflects what happened rather than what was asked for.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(core): give the unpublished-entry shortcut a freshness window

`loadUnpublishedEntry` answers "is this entry under editorial workflow" from
`pages.ids` and skips `backend.unpublishedEntry` when the slug is absent. The
justification was that navigating to a collection or the Workflow tab reloads
the list — it does not: `loadUnpublishedEntries` early-returns while
`pages.ids` is set, and nothing clears it after CONFIG_SUCCESS. The list is
therefore fetched once per page load, so "absent from the list" was answered
from a snapshot that could be an entire session old.

The consequence is a broken multi-editor flow on EVERY backend, not just Turbo:
a colleague creates a draft, you open that entry, and you get the published
version with no workflow bar. Saving it then passes
`existingUnpublishedEntry: false`, takes the `!unpublished` path, calls
createBranch on the `cms/...` branch that already exists, and 422s as an opaque
"Failed to persist". Editorial workflow exists for multi-editor use, so this is
the ordinary case rather than an edge.

Stamp `pages.loadedAt` and refresh the LIST when it is older than 30s. That
keeps the optimisation the shortcut was added for — one request covers every
entry opened in the next window, where the old code paid a round trip per
published entry opened — while bounding how stale the proof can be.

Also fixes the existing shortcut test, which had no `loadedAt` and so was
passing only because the refresh threw into a swallowing catch.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(core,turbo-github): three defects in deploy watching

`resolve` awaits one ancestry compare per pending save, and `record` replaces
`this.pending` wholesale — so a re-save landing inside that window was invisible
to the running iterator. Removal then filtered by entryPath, which deleted the
newer, still-building save along with the older one it replaced: the editor was
told the entry was live while their actual change was still building, and the
sha was dropped from the ledger entirely. `record`'s own comment ("announcing an
older version as live when a newer one is still building would be worse than
saying nothing") is the invariant this broke. The failed loop had the mirror
bug, stamping `failureReported` on a save no failure was reported for and
swallowing its own later. Match on save identity (path + sha) in both.

`prune` bounded `savedAt` on one side only. A save stamped while the clock was
fast and then corrected backward — the ledger is in localStorage and survives
reloads — yields a negative age, so it never expires, `pending` never empties,
nothing calls stop(), and `waited()` stays negative, pinning the poll at its
first 5s step for the rest of the session. This was the only path where the poll
could genuinely run forever.

`stopDeployNotifications` was exported and never called from production code.
The subscriptions are module-level singletons, so after a CMS logout —
signing straight back in is the ordinary flow, since Turbo's dashboard session
outlives it — `startDeployNotifications` early-returns while the surviving
closures point at the discarded watcher. The next save then builds a fresh
watcher with no listeners and polls site_deployments for up to the ledger's 20
minutes with nobody to tell, leaving a "Publishing…" toast that can never
resolve. Tear down on logout.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* chore(turbo-github,turbo-gitlab): unbreak type-check and lint

`tsc --noEmit` has been failing on both branches: the config endpoint's
response is cast to `Record<string, unknown>`, so the destructured `repo` and
`branch` spread into the backend config as `{}` where a `string` is required.
Type them on the cast.

Also the one eslint error and two prettier failures this branch introduced
(`func-style` on a recursive helper, formatting in the new API files). The
remaining prettier debt predates the branch and is left alone rather than
mixed into this diff.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(turbo-github,turbo-gitlab): treat a dead refresh token as terminal

A stored session whose refresh token has been rotated away or has expired put
the CMS into an unrecoverable loop: opening a collection produced a flood of
"Failed to load entry: Unauthorized" toasts and 87 POSTs to
/auth/v1/token?grant_type=refresh_token in 41 seconds, ending in 429s from
GoTrue's own rate limiter.

GoTrue answers such a refresh with
`400 {"error_code":"refresh_token_not_found"}`, but
isTerminalRefreshFailure only accepted `invalid_grant` and
`invalid_refresh_token` as terminal at that status. So a permanently dead token
was classified transient: retried three times, then swallowed by
refreshSessionIfNeeded, which let the caller go on to use the EXPIRED access
token. Every request 401'd, and every entry load started the cycle again — the
429s were a symptom, not the cause, and because the failure was never terminal
the session was never cleared, so it could not self-heal.

Any 400 from the refresh grant is now terminal; every code GoTrue uses there
(refresh_token_not_found, refresh_token_already_used, invalid_grant,
invalid_refresh_token, session_not_found, session_expired) means the token will
never work again, so nothing a retry can achieve. The known codes are also
matched independently of status, in case one arrives under another. The result
is one honest "Session expired. Please log in again." instead of a storm.

Also caps the genuinely transient case: refreshedTokenPromise only dedupes
refreshes that overlap in flight, and a collection load fires its entries
sequentially, so a rate limit or 5xx still got one three-attempt cycle per
request. A failed non-terminal refresh now holds off for 30s, cleared on the
next success and on logout.

Pre-existing on decap-turbo, not introduced by decap-turbo-develop; both
backends carried the identical bug.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(deploys): live per branch, a stalled state, and table controls

Three things, from a look at the tester's Deploys page.

**Live is now per branch.** Scoping it to the site's own branch was right
for the summary band and too narrow for the table: with editorial
workflow on, every `cms/…` branch has its own URL that its own newest
success is genuinely serving, and marking only the site's left every
other branch's current deploy sitting in a column of "Deployed" with
nothing saying which one that URL will show you. A Live row on a branch
that is not the site's carries a title saying so. The summary band and
the header pill stay exactly as narrow as they were — that separation is
the point, and it has its own test.

**A build that stopped being reported is no longer "Building".** Some
never resolve: publishing an editorial-workflow entry deletes the `cms/…`
branch, orphaning the Deploy Preview still building for it, and Netlify
leaves that deploy in `uploaded` rather than `ready` — so no notification
fires and no success status reaches GitHub. Two rows on the tester sat at
"Building" for seventeen hours. After thirty minutes without a word, the
table and the pill both say "Unknown", with a title explaining why.
Presentation only: we did not learn it failed, we learnt we stopped
hearing about it, and those are different claims.

**Filtering, sorting and paging.** Reported by / state / branch filters,
sortable Saved entry / Published to / When with `aria-sort`, 20/50/100 per
page with a range readout. HISTORY_LIMIT 25 -> 200, because editorial
workflow produces three rows per commit and a branch filter over 25 rows
would routinely find nothing.

Several existing assertions moved to `within(getByRole('table'))`: the
filter selects list every value present, so they legitimately repeat the
cell text. Deploys tests 30 -> 50.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(deploys): name the success state in the filter

The state filter offers the host's raw states, and `success` had no label
of its own — in the table a success is shown as Live or Deployed, and the
filter cannot make that distinction because both are the same state. So
the option rendered as the bare key `ui.deploys.state.success`. Caught on
the tester, not by a test, which is why there is now a test that every
option the filter offers has a label.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(deploys): filter by the state shown, and sort every column

**The State filter offered no way to ask for Live.** It keyed on the
host's raw state, where Live and Deployed are both `success` — so the
column showed two words that the filter beside it could not name, and
offered a third ("Succeeded") that appears nowhere in the table. It now
keys on the displayed state, so the options are exactly the words in the
column. `ui.deploys.state.success` is gone with it: nothing could reach
it, because a success is always rendered as one or the other.

**Every column sorts.** State, Reported by and Commit were fixed headers;
which column is worth sorting by depends on why you opened the page, and
a header that does nothing when clicked is worse than no header.

State sorts by meaning rather than by first letter — live, deployed,
building, queued, failed, superseded, unknown. Alphabetical would put
what is live in the middle and what is broken above it; reading down from
what is serving now is what someone scanning that column wants. The same
order drives the filter's option list.

Deploys tests 51 -> 57.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* perf(core,turbo-github,turbo-gitlab): stop hydrating every draft, cache i18n siblings

Three fixes to the two paths a live re-measurement found had regressed, all in
the same place: work done per open draft, or per locale, for an answer that
needed neither.

`loadUnpublishedEntry` refreshes a stale snapshot by calling
`backend.unpublishedEntries`, which lists the open workflow branches and then
hydrates every draft it found — a pull request lookup, a diff and a blob read
each. It does that to decide one thing: whether THIS slug is in the workflow.
Measured through Turbo's proxy that was 20 requests and 3.1s, in front of an
entry load that had not started yet, so an entry opened more than 30s after the
last refresh took 4.9s against 1.7s for one opened inside the window — and 8.2s
when the entry's own reads queued behind it. Add
`backend.unpublishedContentKeys`, the same single call without the hydration,
and track the identities as `pages.keys` (collection-qualified, so two
collections may hold the same slug). The freshness guarantee is unchanged; only
the cost of maintaining it is.

The same refresh fired after every save, because UNPUBLISHED_ENTRY_PERSIST_SUCCESS
updates `pages.ids` but not `loadedAt`: the set was accurate and read as stale.
That was 36 requests and 7.7s of a 12.8s save, 97% of its requests, four of them
duplicates from hydrating twice. The key is now added on persist, so the entry
this session put into review needs no round trip to confirm. `loadedAt` is
deliberately NOT refreshed there — a save proves one key, not the whole set, and
resetting the staleness clock without asking the backend would let a colleague's
draft go unnoticed for another full window, which is the multi-editor failure the
window exists to bound. Publishing and deleting drop the key, or the entry would
keep resolving to a branch that no longer exists.

`collectionRegex` narrows a listing to the default locale, which is right — one
card per entry — but it is also the key Turbo's cache is built on, so with
`structure: multiple_files` only `slug.en.md` was ever ingested. The editor reads
each locale as its own file, so `slug.de.md` and `slug.si.md` missed the cache on
every open and fell through to GitHub: a tree read plus a blob read per locale,
~800ms of a ~1s entry open. Core now also derives `localeSiblingRegex` — the same
`i18nRulestring` with the locale substituted, so the two selectors cannot drift
into disagreeing about the repository layout — and the Turbo backends sync those
paths under their own collection key. Their own key because `fetchEntries` must
still return one row per entry, while `fetchEntryByPath` matches on path alone and
does not care which collection tagged the row. Not awaited: nothing on the
listing needs it, and the entry it serves is a human click away.

No server change: the sibling collection runs through the existing sync pipeline,
and at 100 paths per history batch and 5 batches per sync its metadata converges
in one pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(widget-list): route list item changes by item id, not position (#7972)

Changes to a list item are recorded against the item's position. If an item is
removed or moved before the change is applied, it lands on the wrong item, or
past the end of the list — where getObjectValue returns an empty Map and the
change becomes a new item holding only the changed field. With `types`
configured that item has no type key.

Resolve the position from the item's id in state.keys when the change fires,
as SortableList already does. Changes belonging to a removed item are dropped.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>

* Fix: improve relation widget (#7968)

* fix(widget-relation): fix initial load of selected options

* fix(widget-relation): fix handling of too long texts with ellipsis

* fix(widget-relation): show clearer loading message while fetching options

Options can take a moment to load from the backend on the initial
click, and the default react-select loading text was easy to miss,
making the widget look unresponsive.

* fix: put search results first in relation widget

---------

Co-authored-by: Roman Gorisek <rg@rg-mbp.local>

* fix(turbo-github,turbo-gitlab): let config.yml's branch beat the sites row

affc35848 made both repo and branch from the control-plane `config` endpoint
override config.yml, to fix checkRepoScope's "requested repo does not match"
403s. But that check only looks at the repo — dragging branch along with it
broke every deploy that edits a branch other than the sites row's.

One sites row serves every deploy of a repo, so its single branch cannot
describe them all: a production deploy on `main` and a staging deploy on
`develop` share a row, and each names its own branch in its own config.yml.
Since affc35848 the staging deploy silently read production's branch instead,
so entries that exist only on the staging branch rendered as missing.

repo stays authoritative from the sites row; branch now comes from config.yml
whenever it names one, with the sites row as the fallback for a config.yml
that leaves it out. Nothing server-side objects: `_content/sync` already
takes the branch per request and the content cache is keyed by
(site, repo, branch), while permissions still resolve from sites.branch — so
pointing a config.yml at another branch still cannot widen an editor's access.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(core,media-library-s3): stop handing media libraries the refresh token

`getMediaLibraryContext()` passed the whole `state.auth.user` to every
library registered via `registerMediaLibrary`, a public extension point
loaded from arbitrary script tags. For the Turbo backends that object
carries `access_token`, `refresh_token` and `expires_at`; no library has
any use for the refresh token, and the first-party S3 library never read
it.

Replace `authUser` with a `user` shape built by picking named fields, so
a backend that starts returning a new credential does not leak it here by
default. `token` (the short-lived access token) stays — it is what the
contract exists to pass. `backendConfig` stays whole, with a comment: it
is the site's own `config.yml` backend block, already served publicly
from `/admin/config.yml`.

This narrows what core affirmatively hands over. It does not make the
refresh token unreachable — Decap still persists the whole auth user in
`localStorage['decap-cms-user']`, which any script can read. That is
pre-existing behaviour and out of scope here.

`MediaLibraryContext` stays hand-duplicated in the S3 package, which
cannot import types from core; both copies now point at each other.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(media-library-s3): stop logging response headers on API errors

`handleErrorResponse` dumped every response header from the
`integrations/s3` edge function into the browser console, plus the full
error body. Any browser extension can read that. Log only `status` and
`statusText`, and truncate the body to 300 characters — the thrown Error
still carries it in full, so callers lose nothing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(turbo-github,turbo-gitlab): stop sending an email, and log the branch actually committed to

`cms_entry_saved` carried `authorEmail` alongside the content path and
slug, in a table retained 180 days — a second copy of an email the row
already identifies through the server-derived user_id, as its own comment
admitted (decap-turbo H12). The activity feed's fallback to it never
fired, so nothing reads it. The server drops the key regardless now, so
this is the client half of a fix that already holds for bundles we cannot
redeploy.

`branch` was always the site's branch, so an editorial-workflow save to
`cms/posts/x` was logged and displayed as a publish on `turbo` (L8). It
now reports the branch the commit actually went to — `result.branch` when
the one-call endpoint answered, otherwise derived the way each backend's
own persistFiles derives it — plus a `workflow` flag, since a branch
name alone cannot say so: a site is free to publish from a `cms/...`
branch.

`commitAuthorEmail` was write-only once the prop went, so it goes too.
The GitHub side reaches `generateContentKey` through `this.api` to keep
open authoring's repo prefix, with a fallback for a null `api` — that is
unreachable from a real save, but this value only feeds telemetry and
telemetry must never be the thing that breaks one.

* chore(deps): bump immutable from 3.8.2 to 4.3.9 (#7974)

* chore(deps): bump immutable from 3.8.2 to 4.3.9

Bumps [immutable](https://github.com/immutable-js/immutable-js) from 3.8.2 to 4.3.9.
- [Release notes](https://github.com/immutable-js/immutable-js/releases)
- [Changelog](https://github.com/immutable-js/immutable-js/blob/main/CHANGELOG.md)
- [Commits](https://github.com/immutable-js/immutable-js/compare/v3.8.2...v4.3.9)

---
updated-dependencies:
- dependency-name: immutable
  dependency-version: 4.3.9
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix: adapt to immutable 4 breaking changes

Bumping immutable to 4.3.9 broke the build and silently corrupted entry
data. This adapts the codebase to the new behaviour and type definitions.

Runtime fixes:

- immutable 4's `mergeDeep` concatenates Lists instead of merging them by
  index, even when both sides are the same List instance. Because
  `serializeEntryValues` merged the serialized data back over the original
  values with `mergeDeep`, every save of an entry with a list field
  duplicated its items, growing on each save. A shallow `merge` is correct
  here: `serializedData` already holds the fully recursed value for each
  known field, so only unknown fields need preserving.
- The same hazard applied to `fieldsMetaData` in the entry draft reducer,
  which relation widgets populate with entry data that can contain lists.
  Replaced `mergeDeepIn` with a merge that recurses Maps but replaces any
  other value, matching immutable 3's observable behaviour.

Type fixes for the stricter definitions (`getIn` returning `unknown`,
`get`/`find` returning `V | undefined`, `fromJS`/`toJS` no longer
resolving through the `StaticallyTypedRecord` shim, and precise literal
key inference from `Map(obj)`).

Also fixes two latent bugs the stricter types exposed:

- `hasIntegration` wrapped its argument in `fromJS`, but `getIntegrations`
  has taken a plain `CmsConfig` since #4960, so it always returned false
  and disabled the `list-entries` integration check added in #4849.
- `MediaLibraryInstance.show` declared `config` as an immutable record,
  but the caller passes `config.toJS()` and every implementation spreads
  it as a plain object.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(bitbucket): keep non-plain request bodies intact under immutable 4

immutable 4's `fromJS` recurses into any iterable, where immutable 3 only
descended into plain objects and arrays. `unsentRequest` ran the whole
request object through `fromJS`, so a `FormData` body - which is iterable
- was converted into a Map, and the `toJS()` in `toFetchArguments` then
handed `fetch` a plain object instead of the original body.

Bitbucket is the only backend that sends a `FormData` body, which is why
every Bitbucket write failed: media upload, entry persist and delete. The
other backends send JSON strings and were unaffected.

Convert only `params` and `headers`, the two keys the request helpers
actually traverse, and pass every other value through by reference.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: bump immutable versions across packages

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Martin Jagodic <jagodicmartin1@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com>

* fix: applying collection filter on i18n: single file (#7612)

* fix: applying collection filter on i18n: single file

* fix(core): group i18n entries before applying the collection filter

Entries of an i18n collection were filtered before their locales were
grouped into a single entry. With `structure: single_file` the data of
every locale sits under a locale key until grouping, so the filter field
was never found at the root of the entry data and every entry was
filtered out.

Group first, then filter, so the filter is always matched against the
default locale data of a merged entry. This also stops translations from
being dropped in the `multiple_files`/`multiple_folders` structures when
the filter field is not translated.

Add unit tests for the three cases and an `i18n_posts` collection to the
dev-test config to reproduce the bug manually.

* fix(preview): preserve blob: image URLs when sanitizing preview HTML (#7970)

* fix(preview): preserve blob: image URLs when sanitizing preview HTML

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HG5wiw3Z8QdjNWb5bFDLiA

* Scope the blob: exception to <img src> with a same-origin check

The previous fix widened DOMPurify's global ALLOWED_URI_REGEXP to allow
blob:, which also let it through on <a href> and <form action>. Replace
it with a uponSanitizeAttribute hook scoped to exactly IMG+src, and add
a same-origin check on the value itself: a blob: URL embeds the origin
that created it and a browser already refuses to dereference one from a
different origin, so this can't relax anything a browser wouldn't
already block on its own.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* chore: format

---------

Co-authored-by: lilichen-F <147837261+lilichen-F@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com>
Co-authored-by: Martin Jagodic <jagodicmartin1@gmail.com>

* chore: update update-browserslist-db

* chore: update nx.json

* chore(release): publish

 - decap-cms@3.16.1
 - decap-cms-app@3.16.1
 - decap-cms-backend-aws-cognito-github-proxy@3.7.1
 - decap-cms-backend-azure@3.5.1
 - decap-cms-backend-bitbucket@3.5.1
 - decap-cms-backend-forgejo@3.4.1
 - decap-cms-backend-git-gateway@3.7.1
 - decap-cms-backend-gitea@3.5.1
 - decap-cms-backend-github@3.8.1
 - decap-cms-backend-gitlab@3.6.2
 - decap-cms-backend-proxy@3.5.1
 - decap-cms-backend-test@3.5.1
 - decap-cms-core@3.18.1
 - decap-cms-default-exports@3.3.1
 - decap-cms-editor-component-image@3.4.1
 - decap-cms-lib-auth@3.3.1
 - decap-cms-lib-util@3.8.1
 - decap-cms-lib-widgets@3.4.1
 - decap-cms-locales@3.8.1
 - decap-cms-media-library-cloudinary@3.1.1
 - decap-cms-media-library-uploadcare@3.1.1
 - decap-cms-ui-auth@3.3.1
 - decap-cms-ui-default@3.9.1
 - decap-cms-widget-boolean@3.2.1
 - decap-cms-widget-code@3.7.1
 - decap-cms-widget-colorstring@3.3.1
 - decap-cms-widget-datetime@3.6.1
 - decap-cms-widget-file@3.5.1
 - decap-cms-widget-image@3.4.1
 - decap-cms-widget-list@3.6.1
 - decap-cms-widget-map@3.3.1
 - decap-cms-widget-markdown@3.12.1
 - decap-cms-widget-number@3.4.1
 - decap-cms-widget-object@3.7.1
 - decap-cms-widget-relation@3.7.1
 - decap-cms-widget-richtext@3.6.1
 - decap-cms-widget-select@3.4.1
 - decap-cms-widget-string@3.3.1
 - decap-cms-widget-text@3.3.1
 - decap-cms-widget-uuid@3.1.1
 - decap-server@3.11.1

* fix: support Forgejo editorial workflow PR heads (#7976)

Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com>

* chore(core,turbo-github,turbo-gitlab,media-library-s3): clear the lint drift

`test:ci` starts with `lint-quiet`, and the turbo lineage had never been
through it: nodejs.yml runs only on main/master pushes and pull requests,
and these branches are pushed straight up. Fifteen files had drifted from
prettier and two eslint errors had accumulated, all of it invisible until
something ran the gate. main itself is clean.

The formatting is `prettier --write` and changes nothing semantic — long
throws, a five-argument call and one signature wrap; the rest is object
literals broken at printWidth.

The two errors needed real edits. The turbo-gitlab spec built its
ApiRequest from a lazy `require('decap-cms-lib-util')`, which
no-var-requires rejects in a .tsx; nothing mocks that module in this file,
and `../implementation` has already loaded it by line one, so a top-level
import is equivalent. core's backend.spec.js assigned `notFound` as an
arrow, and func-style is configured `declaration`.

This unblocks publish.yml, which runs the same gate before it publishes.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(core): match the preview-path sentinel by origin, not by prefix

entryPreviewPath checked `url.startsWith(SENTINEL)` and sliced the sentinel
back off. That is safe today only because previewUrlFormatter joins base and
path with an unconditional `/`, so a `preview_path` template cannot reach the
host position. Nothing in entryPreviewPath says so, and the guarantee lives in
another function a caller is free to change; CodeQL flags the prefix form for
exactly that reason (js/incomplete-url-substring-sanitization, alert 45).

Parse instead, compare origins, and take pathname + search + hash from the
parsed URL. Behaviour is unchanged for every reachable input — the added test
pins the case the alert was pointing at, `.example.com/evil`, which stays the
path `/.example.com/evil` rather than becoming a host.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(core): stop a persisted slug passing for a loaded workflow list

`pages.ids` carried two meanings: the slugs under editorial workflow, and
"the full list has been fetched". Three places read it as the second —
loadUnpublishedEntries' early return, persistUnpublishedEntry's pre-load,
and EntriesCollection's readiness gate — while two things write it that
prove nothing of the sort. UNPUBLISHED_ENTRY_PERSIST_SUCCESS pushes the one
slug just saved, and an empty list load leaves an empty List, which is
truthy. Either makes every consumer believe a list it never fetched was
complete, so the fetch that would bring in everyone else's drafts never
runs and the Workflow board renders columns that are missing entries.

Both meanings were load-bearing before this branch only because
loadUnpublishedEntry hydrated the whole list as a side effect of opening a
single entry, which kept `ids` honest by accident. Replacing that with the
keys-only fetch (§B1, 20 requests and 3.1s through the proxy) removed the
accident and left the overload exposed.

So separate them: UNPUBLISHED_ENTRIES_SUCCESS — the one call that hydrates
every draft — now also sets `pages.listLoaded`, and the three consumers read
that instead. `ids` goes back to meaning only what it says. The keys-only
refresh still deliberately claims neither.

Also fixes a neighbouring test that passed for the wrong reason: it built
`config` with fromJS, so `state.config.publish_mode` was undefined and the
guard returned early regardless of what it meant to exercise.

This is aimed at the e2e editorial-workflow failures on this branch, which
cannot be reproduced locally — Cypress 12's Electron 21 will not start on
macOS 26 — so CI is the check.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Revert "fix(core): stop a persisted slug passing for a loaded workflow list"

This reverts 5deeb6e68, keeping only its test correction.

The change was aimed at the e2e editorial-workflow failures and did nothing
for them: CI came back with the same failures on the same four shards. It
also turns out to carry real risk in this suite. The e2e fixtures are
recordings replayed by cy.stubFetch, which CONSUMES each matched route and
falls back to replaying an earlier GET, so the request pattern is coupled to
call counts. Git Gateway (GitLab) "can create an entry" records the
unpublished-entries listing exactly once, with an empty body — and this
change made loadUnpublishedEntries fire in places it previously skipped,
which in that harness means replaying that empty response. Not worth
carrying an unverifiable behaviour change for no measured benefit.

`pages.ids` really is overloaded — it means both the workflow slugs and "the
list has been fetched", and persisting one slug makes it claim the latter —
so this is worth revisiting once the actual e2e cause is known. It is not
the cause.

Kept: the `loadUnpublishedEntries` test built `config` with fromJS, so
`state.config.publish_mode` was undefined and the publish-mode check returned
early — the test passed without ever reaching the isFetching guard it is
named for. Config left Immutable a while ago; the plain object is the shape
the real reducer sees.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* test(e2e): report unmatched routes and DOM state when a spec fails

TEMPORARY, for triaging the editorial-workflow e2e failures on this branch.
Revert before merge.

`cypress run` stdout carries the assertion message and nothing else — no
browser console — so two CI rounds produced no information beyond "expected
to find content X but never did". Meanwhile cy.stubFetch already knows the
interesting fact and writes it somewhere nobody reads: it replays recorded
fixtures, and an API request with no recorded route gets a synthetic 404 plus
a console warning. Those recordings encode main's request pattern, and this
branch changed it, so an unmatched route is the leading suspect.

A `log` task is the one channel that reaches the log. On a failed test this
reports the unmatched routes plus enough DOM state to separate the two
failure shapes seen so far: an editor that never rendered its toolbar (the
'Writing in' back link, which is what exitEditor clicks) from a Workflow
board that rendered empty columns. Nothing runs on a passing test.

Not gated by CI either way — lint:js globs {packages,scripts}, not cypress.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(core): do not let a stale listing certify a draft as published

Diagnosed from CI, not guessed. The failing specs were showing "Failed to
load entry: 404 File Not Found" on the entry route, and editors displaying
"Published" and "Delete published entry" for an entry still in review — the
app was loading a live draft from the site branch, where it does not exist.
Unmatched fixture routes were zero, so this was never the recordings.

UNPUBLISHED_ENTRIES_SUCCESS replaced `pages` wholesale: `keys` became exactly
the fetched entries' keys and `loadedAt` was stamped fresh. So a listing that
does not mention an entry this session had just persisted — requested before
that commit landed, or served stale — dropped the key the persist added AND
certified the shorter set as backend-confirmed. loadUnpublishedEntry's
shortcut reads exactly that pair, treats the absence as proof the entry is
not under editorial workflow, and dispatches loadEntry against the site
branch. Main never hit this: it had no shortcut and always asked the backend
per slug.

Union the fetched keys with what is already there instead. A listing cannot
contradict a key added locally, only fail to mention it. Publishing and
deleting still prune keys explicitly, so a key that really is gone still
goes; one that lingers costs a single per-slug lookup, which is the direction
that fails safely.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* test(e2e): probe the workflow absence shortcut

TEMPORARY, paired with the afterEach hook in cypress/support/e2e.js. Revert
with it.

Two fixes aimed at this shortcut changed nothing measurable — the symptom
tallies across a failing run were identical to the digit: 42 "404 File Not
Found", 24 "Delete published entry", 3 "Failed to persist". The DOM says the
shortcut is firing (a deleted entity is what leaves the toolbar showing
"Published"), but not why, and reasoning about it has now been wrong twice.

So record its actual inputs on every call: the key it looked for, the key set
it looked in, `loadedAt`, and whether it took the shortcut. That distinguishes
the remaining candidates — a key set that never received the persist's key, a
key format that disagrees between writer and reader (open authoring prefixes
content keys with `${repo}/`), or a slug that differs from the one in the
route.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(core): key a new workflow entry on the slug the backend committed

Root cause of the e2e editorial-workflow failures, measured rather than
reasoned about. The probe reported, on every affected backend:

  lookedFor : posts/1970-01-01-first-title
  keys      : ["posts/"]
  SHORTCUT  : true

A new entry's draft has no slug — persistEntry computes it and returns it as
`newSlug`. persistUnpublishedEntry dispatched its success action with the
serialized draft, so the reducer built the content key from an empty slug and
recorded `posts/`. The very next line calls loadUnpublishedEntry with the real
slug, which does not find it among the keys, and with `loadedAt` already set
by an earlier listing the absence counts as confirmed: the entry is treated as
published, the entity is deleted, and loadEntry fetches from the site branch
where a draft does not exist. Hence "404 File Not Found" on the entry route
and toolbars reading "Published" / "Delete published entry" for entries still
in review, and hence empty Workflow board columns.

Main was untouched by this: the empty slug went only into `pages.ids`, which
main used as a boolean, and the follow-up fetch stored the entry properly.
This branch made the same value load-bearing as an identity, and the shortcut
removed the fetch that used to heal it.

So carry `newSlug` on the action and key on that. The entity and id keep using
the draft's own slug, because the editor looks the just-saved entry up by the
slug still in its route; only the content key needs the authoritative one. A
persist with neither slug known now records no key rather than a broken one.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Revert the e2e triage probes

Reverts a9d5c942b and 743a18e37. They found what they were for: the workflow
key set held `posts/` for an entry whose real key was
`posts/1970-01-01-first-title`, fixed in efbd05279, and e2e is green on all
four shards.

Worth recording why they were needed, since the next person to debug this
suite will hit the same wall. `cypress run` stdout carries the assertion
message and nothing else — no browser console — so two rounds of reading CI
logs yielded nothing beyond "expected to find content X but never did", and
two fixes reasoned from the source were both wrong. Cypress cannot be run on
macOS 26 to check locally either: every version from 12.17.4 to 16.0.0 fails
the same way on binary startup, so it is not an Electron version to chase.
A `log` task plus a probe on the suspect code path answered it in one round.

Co-authored-by…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rich text preview omits block images nested in list items

3 participants