Repository navigation
fix(cms): Fast Preview never edits the production branch - #8389
Merged
Merged
Conversation
A Blocks v7 Fast Preview draft is a git branch, so a session on the
repository's default branch saved every autosave straight to production.
Deleting the last draft moved the session there ("read-only production" was
only a label), and opening a page there persisted missing defaults, so just
browsing committed to the live site.
- api: PATCH /decofile refuses the default branch (409
`default_branch_read_only`) before anything is queued; cms /git/rebase and
/git/discard refuse it too (a rebase onto another base could rewrite it).
Reads, rpc and v8's CDN draft are unchanged.
- web: on production a v7 Fast Preview session shows only a notice with
"New draft" instead of Preview/Content; the header keeps the draft
switcher and drops Publish. The default branch comes from the server
(`/git/status` base), not the "main" fallback. Local mode stays open.
- web: the switcher's "New draft" is shared with the notice (useStartDraft).
- e2e: specs that moved `main` through PATCH now commit through the GitHub
stub; v7 sessions open on a draft; new spec for the guard and the notice.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
3 of 4 tasks
Simpler than gating the site editor: the only way a Fast Preview session reached production from the UI was deleting the last draft, which fell back to the base branch. Now the version switcher keeps the last draft (Delete is disabled, saying why) and deleting the active draft never falls back to production. The API still refuses writes to the default branch. Drops the production gate, the notice, useStartDraft and the header change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
They never write, so the API guard doesn't touch them; the move to a draft was only needed by the dropped production notice. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…raft Both guards: the version switcher keeps the last draft (deleting it can't move a session to production), and a v7 Fast Preview session that is on production anyway (an older chat, one opened there by hand) shows only a notice with "New draft" instead of the editor; Publish hides there. The gate, from review: - a failed /git/status refetch keeps the known default branch (it used to open the editor on production); - a listed draft opens without waiting for /git/status; - a CMS session waits for its branch instead of mounting the editor first; - once decided for a branch, a later "pending" keeps the decision rather than unmounting the editor; - the status placeholder only comes from the same project; - "New draft" creates one draft per click. Also: confirmDelete re-checks the last-draft rule; stale docs fixed; the stale-form spec drops its unused branch parameter; the e2e spec covers the notice and deleting the active draft. Co-Authored-By: Claude Opus 5.5 <[email protected]>
aka-sacci-ccr
enabled auto-merge (squash)
November 6, 2026 17:34
decocms Bot
pushed a commit
that referenced
this pull request
Nov 6, 2026
PR: #8389 fix(cms): Fast Preview never edits the production branch Bump type: patch - decocms (apps/api/package.json): 4.556.3 -> 4.556.4 - @decocms/e2e (packages/e2e/package.json): 1.131.3 -> 1.131.4 Deploy-Scope: both
tlgimenes
added a commit
that referenced
this pull request
Nov 6, 2026
Main's production gate (#8389) asked useMainSchemaV8 whether a session is a v7 site and waited on an undecided Local tunnel. This branch replaced that hook with the project's "Blocks v8 site" switch (useBlocksV8Project) and removed the undecided tunnel state, so the rebase left the gate importing a module that no longer exists (tsc and knip failed). The gate now takes blocksV8 (synchronous, so no "loading" or "error" waits) and no tunnelUndecided; its tests drop the removed states. Co-Authored-By: Claude Opus 5.5 <[email protected]>
tlgimenes
added a commit
that referenced
this pull request
Nov 6, 2026
Main's #8389 made a v7 site's default branch read-only: the editor shows the production notice there and PATCH /decofile on it answers 409. The spec, added on this branch, opened its session on main and asserted the save landed on main, so after the rebase every case waited on a blocks panel the production notice replaced. It now seeds a `draft` branch at main's head (as main's own specs do), opens the session there and checks the save on that branch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
tlgimenes
added a commit
that referenced
this pull request
Nov 6, 2026
Port the three default-branch tests main added to v8-gates.test.ts (#8389) onto this branch's decofile route harness: a PATCH on the default branch answers 409 default_branch_read_only and commits nothing, the same PATCH on a draft branch answers 200 and commits, and reads of the default branch (GET, and status in place of main's rpc, which this branch does not have) are still served. Co-Authored-By: Claude Opus 5.5 <[email protected]>
tlgimenes
added a commit
that referenced
this pull request
Nov 9, 2026
Main's production gate (#8389) asked useMainSchemaV8 whether a session is a v7 site and waited on an undecided Local tunnel. This branch replaced that hook with the project's "Blocks v8 site" switch (useBlocksV8Project) and removed the undecided tunnel state, so the rebase left the gate importing a module that no longer exists (tsc and knip failed). The gate now takes blocksV8 (synchronous, so no "loading" or "error" waits) and no tunnelUndecided; its tests drop the removed states. Co-Authored-By: Claude Opus 5.5 <[email protected]>
tlgimenes
added a commit
that referenced
this pull request
Nov 9, 2026
Main's #8389 made a v7 site's default branch read-only: the editor shows the production notice there and PATCH /decofile on it answers 409. The spec, added on this branch, opened its session on main and asserted the save landed on main, so after the rebase every case waited on a blocks panel the production notice replaced. It now seeds a `draft` branch at main's head (as main's own specs do), opens the session there and checks the save on that branch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
tlgimenes
added a commit
that referenced
this pull request
Nov 9, 2026
Port the three default-branch tests main added to v8-gates.test.ts (#8389) onto this branch's decofile route harness: a PATCH on the default branch answers 409 default_branch_read_only and commits nothing, the same PATCH on a draft branch answers 200 and commits, and reads of the default branch (GET, and status in place of main's rpc, which this branch does not have) are still served. Co-Authored-By: Claude Opus 5.5 <[email protected]>
tlgimenes
added a commit
that referenced
this pull request
Nov 9, 2026
Main's production gate (#8389) asked useMainSchemaV8 whether a session is a v7 site and waited on an undecided Local tunnel. This branch replaced that hook with the project's "Blocks v8 site" switch (useBlocksV8Project) and removed the undecided tunnel state, so the rebase left the gate importing a module that no longer exists (tsc and knip failed). The gate now takes blocksV8 (synchronous, so no "loading" or "error" waits) and no tunnelUndecided; its tests drop the removed states. Co-Authored-By: Claude Opus 5.5 <[email protected]>
tlgimenes
added a commit
that referenced
this pull request
Nov 9, 2026
Main's #8389 made a v7 site's default branch read-only: the editor shows the production notice there and PATCH /decofile on it answers 409. The spec, added on this branch, opened its session on main and asserted the save landed on main, so after the rebase every case waited on a blocks panel the production notice replaced. It now seeds a `draft` branch at main's head (as main's own specs do), opens the session there and checks the save on that branch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
tlgimenes
added a commit
that referenced
this pull request
Nov 9, 2026
Port the three default-branch tests main added to v8-gates.test.ts (#8389) onto this branch's decofile route harness: a PATCH on the default branch answers 409 default_branch_read_only and commits nothing, the same PATCH on a draft branch answers 200 and commits, and reads of the default branch (GET, and status in place of main's rpc, which this branch does not have) are still served. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this contribution about?
In a Blocks v7 project with Fast Preview on, a draft is a git branch: every autosave is a commit on the session's branch. Nothing stopped that branch from being the repository's default branch, so a session on production saved straight to the live site.
The way in from the UI: deleting the active draft when it is the last one made the version switcher fall back to production (
branch-picker.tsx,confirmDelete→pick(baseBranch)). Once there, just opening a page writes the missing schema@defaults, so browsing alone committed to the default branch.This closes it at three levels:
1. The last draft stays (version switcher)
useStartDraft, so the notice below can reuse it.2. Production is blocked in the site editor
main). There, a v7 Fast Preview session shows only a notice, "Production can't be edited here", with New draft, instead of Preview, Content and Blocks, so nothing that reads or saves the decofile mounts.resolveProductionGate(pure, unit-tested) decides this, throughuseProductionGate.deco serveand coding sessions./git/status→base, the same cache entry as the Fast Preview header). It does not come fromuseBaseBranch, which says"main"whenever the branch has no PR.3. The API fails closed
PATCH /api/:org/decofile/:vmcp/:branchrefuses the default branch with409 { code: "default_branch_read_only" }, before anything is queued. Body validation runs first, so invalid bodies still answer 400./git/rebaseand/git/discardrefuse it too. A rebase with abaseother than the default branch could rewrite production onto it.GET,rpc(the editor reads main's schema through/decofile/:vmcp/main/rpc), publish (it already refused the default branch), and Blocks v8, which never sendsPATCH.e2e
mainthroughPATCHnow commit through the GitHub stub (commitStubFiles), the way another draft's publish or a push lands.mainnow open on a seeded draft.fast-preview-production.spec.tscovers:Companion change: #8390 adds a project switch to stop forms from persisting missing defaults when they open.
How did you verify your code works?
bun run verify: exit 0, 13218 pass, 0 fail.tsc --noEmitpasses forapps/api,apps/webandpackages/e2e.v8-gates.test.ts› "v7 writes to the default branch": PATCH on the default branch → 409 with nocommitFilescall; the same PATCH on a draft commits; GET andrpcon main still answer 200.git-compat.test.ts:repoGitRebase/repoGitDiscardthrowDefaultBranchWriteErroron the default branch.production-gate.test.ts(21 cases) and theonProductioncase insite-draft-bar-parts.test.ts.fast-preview-production: 9/9 (--repeat-each=3).compact-page-layout,content-loader-editor,content-protocol-github,site-editor-stale-form,site-editor-breadcrumbs,fast-preview-git-syncanddecofile-api: 67/67.Screenshots/Demonstration
How to Test
COLLECTION_THREADS_CREATEwithbranch: "main"). The canvas shows "Production can't be edited here" with New draft, and the header has no Publish. New draft opens the editor on a fresh draft.PATCH /api/<org>/decofile/<vmcp>/mainwith any valid block returns409 default_branch_read_only, and no commit lands on the default branch.Review Checklist
Out of scope:
useBaseBranchstill falls back to"main", so on repos whose default branch has another name the switcher's "Production" label doesn't show. The gate and the API don't rely on it.🤖 Generated with Claude Code