Skip to content

feat: stage static publishes for review, then go live; version history and rollback - #19

Open
mvanhorn wants to merge 1 commit into
spacefast:mainfrom
mvanhorn:fix/wordpress-stage-approve-rollback
Open

mvanhorn wants to merge 1 commit into
spacefast:mainfrom
mvanhorn:fix/wordpress-stage-approve-rollback

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Nov 16, 2026 •

Copy link
Copy Markdown

Summary

Static publishes went straight to the public site with no way to review them first or undo them from WordPress. Now a site owner can turn on "Review before going live" (off by default) and stage each publish. A Staged version card offers Open preview, Copy preview link, Go live and Discard, and a Versions panel lists the last 20 versions with Make live to roll back.

Why this matters

Every static publish is created with finalize: { channel: 'live' }, so a theme change, a bad crawl or a half-finished page is public the moment the export finishes, and the admin only shows the last version ID. Spacefast's API already supports each step: a nullable finalize channel, preview sessions, promote and the version list. This puts them in wp-admin, where the person editing the site already is.

Demo

Simulated demo (HyperFrames), built from a real run: Docker WordPress connected to a Spacefast Space, driven through the actual admin forms:

demo

Changes

Spacefast_Client gets a channel argument on create_static_version (null stages), plus list_versions, preview_session, promote_version and delete_version. With the toggle off, the publish request is byte-for-byte what it is today. Sync state records the staged version and whether each version came from a manual or automatic publish. Partial exports stay additive while staged.

Editors (edit_others_posts) can stage and preview when review is on. Administrators promote, roll back and discard, and the spacefast_wordpress_can_promote filter can narrow or delegate that. spaces:publish doesn't cover promote or preview sessions, so static connections now request publish:write. Existing installs see a Reconnect notice and keep publishing until they reconnect.

Spacefast can answer a promote with confirmation_required, asking a person to approve it. The plugin then shows a Waiting for approval card that links to the approval, instead of the API's raw text. Finish resends the same request with the continuation token and the original Idempotency-Key. The token stays in a non-autoloaded option, is never rendered, and is cleared on finish, cancel, expiry, disconnect and uninstall.

This also fixes an upgrade problem. Sync state saved by 0.5.x lacks the new keys, so the compare-and-swap in Spacefast_Sync_State::mutate never matched, and every post save hit a fatal error. It now compares against the stored row.

Testing

bin/test.sh behavior tests pass. New cases cover the staged and toggle-off payloads, go live, rollback and discard (including stale forms, capability limits and failed promotions), the approval card, early Finish, token and key reuse, expiry, an already-open approval, and state written by an earlier release. bin/test-wordpress.sh container acceptance passes.

Live, through wp-admin: with review on, I edited a page and clicked Publish now. The export staged in about 20 seconds while the public page kept the old text. Open preview served the new text and returned 403 without the preview session, and Go live made it public. Make live on an older version showed the approval card with a working Approve in Spacefast link. Finish before approval kept the card open and left the live site alone. I didn't approve it myself, since that gate is meant for a person. The upgrade fatal reproduced live before the fix and is gone after it.

This overlaps files that open #13, #15 and #16 change, and #18 also bumps to 0.6.0, so I'll rebase after whichever lands first. If you'd rather review it in two parts, Versions plus rollback could go first, then staging. One thing for the API side: the version endpoint reported 0 added/changed/removed for a staged version whose page did change, so the card's counts may need a look.


Proof this PR
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…rollback

Add a Review before going live setting (off by default). With it on, static
exports finalize without going live and a Staged version card offers a
private preview, a copyable preview link, Go live and Discard. A Versions
panel lists the last 20 versions with Make live for rollback. Editors can
stage; administrators promote, with a spacefast_wordpress_can_promote filter.

Static connections now request publish:write, which covers promotion and
preview sessions; existing installs see a reconnect notice.

When Spacefast requires a person to approve a promotion, keep the
continuation token server-side, link to the approval, and resend the same
request on Finish. Sync state saved by earlier releases keeps working:
compare-and-swap now compares against the stored row.
@coderabbitai

coderabbitai Bot commented Nov 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

This review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a5028625-aaad-4a13-b4a0-553aee8f34d6
Commits

Reviewing files that changed from the base of the PR and between 04f0854 and 1805e95.

Files selected for processing: 13

  • README.md
  • includes/class-spacefast-client.php
  • includes/class-spacefast-oauth.php
  • includes/class-spacefast-plugin.php
  • includes/class-spacefast-settings.php
  • includes/class-spacefast-simply-static-task.php
  • includes/class-spacefast-static-publisher.php
  • includes/class-spacefast-sync-state.php
  • readme.txt
  • spacefast-wordpress.php
  • tests/acceptance/wordpress.php
  • tests/behavior.php
  • uninstall.php
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

1 participant