Skip to content

[Website] Run edited Blueprints in fresh Playgrounds - #4067

Merged
adamziel merged 4 commits into
trunkfrom
adamziel/dock-ui-substitution
Jul 15, 2026
Merged

[Website] Run edited Blueprints in fresh Playgrounds#4067
adamziel merged 4 commits into
trunkfrom
adamziel/dock-ui-substitution

Conversation

@adamziel

@adamziel adamziel commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Running an edited Blueprint now creates a new autosaved Playground instead of deleting the source site's WordPress files.

Background

Before this PR, running a Blueprint from an autosaved Playground did three things:

  1. Stored the edited Blueprint under the existing site slug.
  2. Deleted that site's WordPress files.
  3. Booted the edited Blueprint under the same site identity.

That destroyed the site used to author the Blueprint. Explicitly saved Playgrounds already ran edited Blueprints in a new Playground, so the same button had different consequences depending on how the source was stored.

This change

All stored Playgrounds now copy the edited Blueprint bundle into a fresh autosave and activate it. The source Playground, its WordPress files, and its identity remain available. Autosaved Blueprint drafts also remain attached to their source. Temporary Playgrounds still reuse the current site because there is no stored source to preserve. Their action says Discard current Playground & run Blueprint.

Screenshots

Before

An autosaved Playground was reset in place

Before: the Blueprint Dock warned that running the Blueprint would reset the autosaved Playground and replace its files

After

When editing a stored Playground's Blueprint, offer to run the updated Blueprint in a dedicated new Playground

After: a stored Playground shows Run in a new Playground and says where the source remains available

When editing an unsaved Playground's Blueprint – explicitly explain the unsaved Playground will be discarded

After: a temporary Playground shows the red Discard current Playground and run Blueprint action

The Run action waits for the pending editor write before copying the bundle. A synchronous guard ignores repeated clicks while creation is in progress. Autosave pruning excludes both the source and destination. A pruning failure is logged after the new Playground is committed; reporting the run as failed would invite a retry and create a duplicate. If copying the bundle or writing site metadata fails, createStoredSite() removes the partial bundle.

Testing

The unit tests cover temporary and stored runs, the save barrier, repeated clicks, retry after creation failure, pruning failure, the text shown for preserved sources, and partial-bundle cleanup. The browser tests verify that autosaved and explicitly saved sources survive while the edited Blueprint boots in a new autosave.

Test with:

npm exec nx -- test playground-website --runInBand
npm exec nx -- run playground-website:lint
npm exec nx -- run playground-website:typecheck
npm exec nx -- run playground-website:build:standalone
npm exec nx -- run playground-website:e2e:playwright -- website-ui.spec.ts --project=chromium --grep="should edit a Blueprint for an autosaved Playground"
npm exec nx -- run playground-website:e2e:playwright -- website-ui.spec.ts --project=chromium --grep="should edit a Blueprint for a saved Playground"

Copilot AI 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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates Blueprint “Run” behavior so edited Blueprints for stored Playgrounds (autosaved + explicitly saved) execute in a newly created autosaved Playground instead of mutating the existing one, preserving the source for comparison.

Changes:

  • Adjust stored site creation to persist Blueprint bundles within the same failure-handling scope as site creation, cleaning up partial bundle copies on error.
  • Update Blueprint editor run flow to create/activate a fresh autosaved Playground for stored sites, with a run guard to prevent duplicate creation and a UI hint reflecting the new behavior.
  • Expand unit + e2e coverage to validate bundle-copy cleanup, duplicate-run guarding, and preserved source Playground behavior.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/playground/website/src/lib/state/redux/slice-sites.ts Moves bundle persistence into try/catch with site creation to ensure partial bundle cleanup on failure.
packages/playground/website/src/lib/state/redux/slice-sites.spec.ts Adds a regression test ensuring failed bundle copy triggers bundle deletion and blocks site creation.
packages/playground/website/src/lib/state/opfs/opfs-site-storage.ts Clarifies documentation for WordPress-files cleanup behavior used by autosave recreation APIs.
packages/playground/website/src/lib/state/opfs/opfs-autosave-reset.ts Updates/clarifies docs around the autosave reset helper and when it should be used.
packages/playground/website/src/components/blueprint-editor/blueprint-bundle-editor.module.css Adds styling for a new “run hint” message in the Blueprint editor UI.
packages/playground/website/src/components/blueprint-editor/BlueprintBundleEditor.tsx Changes run behavior: stored sites run into a new autosaved Playground; adds run guard + updates UI text and dispatch flow.
packages/playground/website/src/components/blueprint-editor/BlueprintBundleEditor.spec.tsx Adds/updates unit tests for the new run behavior, guarding, and messaging.
packages/playground/website/playwright/e2e/website-ui.spec.ts Updates e2e expectations and asserts source autosave remains intact after running the edited Blueprint into a new Playground.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/playground/website/playwright/e2e/website-ui.spec.ts Outdated
@adamziel
adamziel merged commit 7ce8cff into trunk Jul 15, 2026
53 checks passed
@adamziel
adamziel deleted the adamziel/dock-ui-substitution branch July 15, 2026 22:15
adamziel added a commit that referenced this pull request Jul 15, 2026
Removes `window.playgroundSites.recreateAutosavedSite()` and the
same-slug autosave reset path.

Stacked on #4067, which makes edited Blueprints open in a fresh
Playground.

## Background

`recreateAutosavedSite()` replaced an autosave in place: it wrote new
setup metadata under the existing slug, deleted that site's WordPress
files, and booted the replacement under the same identity.

The Dock no longer does that. It creates a fresh Playground and leaves
the current site intact. No repository caller still needs the
destructive compatibility path.

## This change

The public method, `resetAutosavedSiteSpec()`, and
`resetAutosavedSiteFilesWithPendingMarker()` are removed together with
their dedicated tests.

This is a breaking change for external callers of
`window.playgroundSites.recreateAutosavedSite()`. FWIW, I didn't find
any via a SourceGraph lookup.

Boot still recognizes `opfsSiteRemovalPending`. Older builds may have
persisted that marker before an interrupted reset. Removing the reader
would let those sites mount WordPress files that do not match their
metadata.

## Testing

Test with:

```
npm exec nx -- test playground-website --runInBand
npm exec nx -- run playground-website:lint
npm exec nx -- run playground-website:typecheck
npm exec nx -- run playground-website:build:standalone
npm exec nx -- run playground-website:e2e:playwright -- sites-api.spec.ts --project=chromium
git diff --check
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment