Skip to content

Keeping drafts current

A hosted draft holds only the blocks an editor changed. The editor's forms show your production branch with the draft on top, saves never touch GitHub, and Publish keeps each whole draft block.

An editor changes a homepage title while a developer pushes a new footer. The draft should keep the title and show the new footer, without asking anyone to create a branch, merge or rebase.

There's nothing to synchronize. The hosted site editor keeps a draft as only the blocks the editor changed, and lays them over your content: in the editor, over your production branch; on your site, over the latest release. Every block the draft didn't change follows your developers' changes; the draft itself never has to move.

What a draft is

  • Only the changes. A draft is one object in Deco's storage, beside the releases: the whole blocks the editor saved, and the names they deleted. It isn't in your repository, and it isn't a branch.
  • No base of its own. A draft records no production commit and keeps no private copy of content: what it's laid over is always what's current.
  • Versions are content hashes. Each block's version is a hash of its content. Equal content has an equal version, wherever it's stored.

Drafts saved before this design keep working as they are.

What the editor shows

The forms show your production branch with the draft on top. The site editor reads the production branch through the GitHub API when it opens and in its background check, about every 30 seconds and when you return to the tab, and lays the draft's blocks over it. A block the draft holds shows the draft's version; every other block shows the production branch's.

The preview on your site renders the same draft over the latest release, the one latest.json in Deco's storage names (see Previewing drafts). A developer's change that's on the production branch but not released yet shows in the forms first, and in the preview once it's released.

A save

A save is one blocks.apply to the draft. For each block it changed, the site editor sends the whole block, and the save writes it into the draft, replacing whatever the draft had for that block. Nothing else is involved: a save never reads your repository or calls GitHub, and it doesn't read the schema. Content is checked against the schema by deco check in your CI, not by the site editor.

Each saved block carries the version the form loaded, so two people never overwrite each other without knowing (see Overlays):

  • A block that isn't in the draft yet is saved only if it still isn't.
  • A block that's already in the draft is saved only if the draft still has the version the form loaded.
  • A block the draft deletes is in the draft too: the deletion has a version of its own, so bringing the block back is saved only if the draft still deletes it. A form that loaded the block before someone deleted it gets the side-by-side view, not a silent overwrite.

The check runs against the draft alone. If someone else saved that block in between, nothing is written, and the site editor opens the side-by-side view: their version and yours, field by field, and you pick what to keep (for an A/B test or a campaign, you pick one whole version). An editor never meets this for their own saves: after each save, the site editor uses the version that save answered with.

Two saves of different blocks that land at the same moment are both kept: the draft is written only if nobody wrote it in between, and otherwise read again and the save applied on top. "Saved" shows as soon as the write is confirmed; the list of changes and the preview refresh right after, without holding up the next save.

The list of changes

The list of changes is the draft's own blocks. Each one's "before" is the block on your production branch, as the form loaded it, so the list needs no GitHub call after a save. A block stays in the list until it's published or you discard it, even if you set it back to exactly what's on the production branch. Discarding a block takes it out of the draft, so the production branch's version shows again.

A developer's push

A developer's push to your production branch shows up in the forms on the site editor's next background check, and in the preview once it's released (see How a commit becomes a release). From then on, every block the draft didn't change shows the developer's version. A block the draft changed keeps the draft's version.

Publish: the whole draft block wins

Publish is where the draft meets GitHub. It reads your production branch's latest commit and commits the draft's blocks on top of it, content files only. Every other file on the branch, code and schema included, stays as it is. If the branch moves while Publish runs, it reads the new latest commit and commits on top of that instead, a few times over; a conflicting block never stops it.

When a developer changed the same block on the production branch, the whole draft block wins. There's no merge of fields inside a block:

The blockResult
Changed only in the draftThe draft's block
Changed only on the production branchThe production branch's block (the draft doesn't touch it)
Changed in both, even in different fieldsThe whole draft block
Deleted in the draft, edited on the production branchDeleted
Edited in the draft, deleted on the production branchThe draft's block

For example, if the draft changes the hero's title and a developer changed the hero's image, the published hero has the draft's title and its previous image. If the developer changed the footer, which the draft didn't touch, the footer keeps their change.

The review before Publish says so, and never blocks: "Your developer also changed Footer. Publishing keeps your version." It names each draft block that differs between the latest release and the production branch's latest commit. To keep the developer's version instead, discard your change to that block first.

The commit then becomes a release like any other, and the draft empties, so the same preview link keeps working and shows the new release.

Preview transport

The preview gets the draft as an overlay: only the changed blocks and the deletions, applied over the latest release, which the rendering server checks for before it renders a draft. The overlay names no base revision.

Studio implementation

The Studio implementation handoff maps this design to Studio's modules.