Add site checkpoints: whole-site (files + database) save points with rollback#4098
Draft
shaunandrews wants to merge 5 commits into
Draft
Add site checkpoints: whole-site (files + database) save points with rollback#4098shaunandrews wants to merge 5 commits into
shaunandrews wants to merge 5 commits into
Conversation
…+ database Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Related issues
How AI was used in this PR
Built end-to-end with Claude Code from a reviewed plan: research passes over the codebase and prior art (Cline, Replit, DDEV, Jetpack Backup), an adversarial design review, four validation spikes run against real sites before any implementation, then implementation with unit tests and a scripted Playwright pass over the packaged app for light/dark visual verification. All code was verified by running it: full create → mutate → diff → restore round trips on live sites of both runtimes.
Proposed Changes
When the agent (or you) makes big changes to a site, there's currently no way back. This adds checkpoints: capture the entire state of a site — every file and the SQLite database — at "known good" moments, and roll back to any of them later. This closes the gap that desktop AI coding tools document as a limitation: Cursor/Claude Code/Cline checkpoint only the files their own edit tools touch; Studio owns the whole site directory and its database, so it can checkpoint everything, including wp-cli side effects and uploads.
How it behaves:
checkpoint_create/list/restore/difftools, and destructive tools (wp_cli, imports, pulls, scaffolding, data liberation) automatically capture a checkpoint before running (debounced to one per 2 minutes). Checkpoint chips render in the chat transcript with a restore affordance.studio checkpoint create|list|restore|delete|diff. The diff answers "what changed since things last worked": files added/modified/deleted plus per-table row-count deltas and changedwp_optionsnames.Storage is a content-addressed store per site under
~/.studio/checkpoints/— git-like dedupe without a git dependency (Studio ships to machines without git). Unchanged files cost nothing after the first checkpoint: measured on a ~96 MB site, the first checkpoint stored 30 MB compressed in 3.5 s, the next one 58 KB in 0.8 s. Restores are transactional about the database: while a site runs, capture executesVACUUM INTOinside the site's own PHP runtime, and every artifact is integrity-verified host-side with retries (the validation spike reproduced a torn read on the Playground runtime under concurrent writes — the daemon runs wp-cli in parallel WASM instances whose SQLite locks don't coordinate — so verification is load-bearing, not paranoia).Trade-offs and deliberate v1 boundaries, so reviewers know what they're evaluating: restore is always files+database together (files-only invites plugin/DB mismatches); reprint-pulled sites are refused with a clear message; retention is fixed policy (manual/agent kept forever, last 10 auto, last 5 safety) with no settings UI yet; create/restore progress in the desktop UI is pending/complete rather than granular; a crash-interrupted restore is recoverable via the journal from the CLI but has no desktop dialog yet.
This spans a new architectural boundary (CLI engine + agent tool decorator + local-server routes + desktop IPC + UI), which is why it's a draft PoC rather than a merge-ready change.
Testing Instructions
npm install && npm run cli:buildnode apps/cli/dist/cli/main.mjs checkpoint create --path ~/Studio/<site> --label "known good", change something (studio wp option update blogname broken, add/delete a plugin file), thencheckpoint diff <id>andcheckpoint restore <id>— the site should come back exactly, running or stopped, with an undo hint pointing at the safety checkpoint.npm start, open a site → Settings → Checkpoints. Create, restore (note the confirm dialog copy), delete.wp_clicommand and watch the auto-checkpoint chip appear in the transcript; trycheckpoint_diff("what changed since the last checkpoint?").npm test -- apps/cli/lib/checkpoints apps/cli/ai/tools/auto-checkpoint.UI was visually verified in light and dark via a scripted run of the packaged app; a second pair of human eyes on the timeline, dialogs, and chips is still welcome.
Pre-merge Checklist
npm run typecheck,npx eslint,npm test)🤖 Generated with Claude Code