Skip to content

[Website] Replace failed Blueprint runs before pruning autosaves - #4134

Merged
adamziel merged 1 commit into
trunkfrom
replace-failed-blueprint-runs-safely
Jul 21, 2026
Merged

[Website] Replace failed Blueprint runs before pruning autosaves#4134
adamziel merged 1 commit into
trunkfrom
replace-failed-blueprint-runs-safely

Conversation

@adamziel

@adamziel adamziel commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Part of #4099.

Builds on #4129.

Retrying an unfinished Blueprint run now replaces the failed Playground before autosave pruning begins.

The retry keeps the original Playground as its return target, creates and activates the replacement, and then removes the failed run. Only after that succeeds does it prune old autosaves. If the failed run cannot be removed, pruning stops instead of deleting an unrelated Playground to make room.

Autosave pruning already handles its own deletion failures, so the Blueprint editor no longer wraps it in a second try/catch. The editor also stops claiming that the failed run will remain in Recent after retry.

Testing

From a stored Playground, run a Blueprint with preferredVersions.wp set to 999.9. Open the failed run in the Blueprint editor, change the version to latest, and run it again. Confirm the replacement opens, the original Playground remains, and the failed run is absent from Recent.

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.

Adjusts Blueprint retry behavior so failed/unfinished runs are replaced (and the failed run discarded) before autosave pruning, preventing unrelated Playgrounds from being deleted and updating UI messaging accordingly.

Changes:

  • On retry, activates the replacement site and attempts to remove the failed run before pruning autosaves (and aborts pruning if removal fails).
  • Updates the Blueprint editor hint text logic to avoid implying failed runs will remain in Recent after retry.
  • Extends unit tests to cover removal-before-prune ordering and the “do not prune if removal fails” case.

Reviewed changes

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

File Description
packages/playground/website/src/components/blueprint-editor/BlueprintBundleEditor.tsx Reorders retry flow to remove failed runs before pruning; adjusts run-hint rendering for unfinished runs.
packages/playground/website/src/components/blueprint-editor/BlueprintBundleEditor.spec.tsx Adds tests ensuring removal happens before pruning and pruning is skipped if removal fails.
Comments suppressed due to low confidence (1)

packages/playground/website/src/components/blueprint-editor/BlueprintBundleEditor.tsx:1

  • If removeSite / pruneAutosavedSites are async thunks (e.g., created with RTK createAsyncThunk), dispatch(thunk) typically resolves to an action and does not throw on rejection unless unwrapped. In that case, the catch block won’t run and pruning may still proceed even when removal failed—contradicting the intended safety behavior. Consider unwrapping the dispatched promise (or explicitly checking for a rejected action) so failures reliably abort pruning.
import { autocompletion } from '@codemirror/autocomplete';

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

Retrying an unfinished Blueprint run creates a replacement but used to leave the failed candidate behind. Activate the replacement, discard the failed run, and only then enforce autosave retention. If that discard fails, skip pruning rather than deleting an unrelated Playground to compensate. Keep the original return target and hide the stale hint that said the failed run would remain in Recent. Autosave pruning already handles its own deletion failures, so remove the editor-level catch and the test that modeled a rejected prune.
@adamziel
adamziel force-pushed the replace-failed-blueprint-runs-safely branch from 924cd81 to b484990 Compare July 21, 2026 01:20
@adamziel
adamziel merged commit d4c5531 into trunk Jul 21, 2026
53 checks passed
@adamziel
adamziel deleted the replace-failed-blueprint-runs-safely branch July 21, 2026 01:38
adamziel added a commit that referenced this pull request Jul 21, 2026
Builds on #4134.

A stored Blueprint can fail before its first WordPress file copy
completes. The old error dialog could be dismissed, leaving a loading
screen that could never finish.

This PR makes the error dialog the recovery screen. It keeps the
specific failure reason and offers two explicit actions:

- **Edit Blueprint** opens the Blueprint editor so the input can be
corrected.
- **Return to your last Playground** discards the failed run and
restores the Playground that launched it.

If that Playground no longer exists, the second action starts a new one
instead. Seamless mode omits the editor and makes the return action
primary.

The dialog cannot be closed with an X, Escape, or an outside click.
Close does not secretly navigate. Private repository authentication may
cover it temporarily; the recovery dialog returns when authentication
closes.

Reloading an interrupted run also stops before booting WordPress again.
It keeps the return target and does not delete the partial files behind
the user's back.

| Desktop before | Desktop after |
| --- | --- |
| <img width="720" alt="Before: an unavailable release dialog with no
route back to the Blueprint"
src="https://raw.githubusercontent.com/WordPress/wordpress-playground/39e991af1c1df706f2008630cfa69032a33aefd6/after-desktop.png">
| <img width="720" alt="After: an unavailable release dialog with AI
troubleshooting and explicit Blueprint recovery actions"
src="https://raw.githubusercontent.com/WordPress/wordpress-playground/8964cf1261bd2761eb0ff7318b04ad35c1789487/after-desktop.png">
|

| Mobile before | Mobile after |
| --- | --- |
| <img width="390" alt="Before on mobile: an unavailable release dialog
with no route back to the Blueprint"
src="https://raw.githubusercontent.com/WordPress/wordpress-playground/39e991af1c1df706f2008630cfa69032a33aefd6/after-mobile.png">
| <img width="390" alt="After on mobile: an unavailable release dialog
with AI troubleshooting and explicit recovery actions"
src="https://raw.githubusercontent.com/WordPress/wordpress-playground/8964cf1261bd2761eb0ff7318b04ad35c1789487/after-mobile.png">
|

## Testing

1. From a stored Playground, run a Blueprint with `preferredVersions.wp`
set to `999.9`.
2. Confirm the failure dialog shows the unavailable version, keeps
**Troubleshoot with AI**, and cannot be dismissed.
3. Open **Edit Blueprint**, close the editor, and confirm the failure
dialog returns.
4. Choose **Return to your last Playground** and confirm the original
Playground opens and the failed run is absent from Recent.
5. Repeat at a mobile viewport.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment