Skip to content

Save Playgrounds by default#3655

Draft
adamziel wants to merge 47 commits into
trunkfrom
codex/default-saved-playgrounds
Draft

Save Playgrounds by default#3655
adamziel wants to merge 47 commits into
trunkfrom
codex/default-saved-playgrounds

Conversation

@adamziel
Copy link
Copy Markdown
Collaborator

@adamziel adamziel commented May 17, 2026

What it does

Makes browser Playgrounds save by default without changing reusable setup URLs.

A fresh visit to playground.wordpress.net/?php=8.3&plugin=... now creates an autosaved OPFS Playground, keeps the original setup URL in the address bar, and shows an Autosaved status menu. storage=temp and can-save=no still opt out.

If a matching recent autosave exists, Playground starts a new site immediately and shows a non-blocking restore nudge. Choosing Restore opens the previous autosave. Choosing Keep new starts autosaving the new site.

Rationale

Autosave prevents accidental data loss, but replacing setup URLs with site-slug broke a core Playground workflow: refreshing the same URL to start again with the same parameters.

This keeps both properties:

  • user changes are protected by default
  • setup URLs remain stable, shareable, and refreshable

The restore nudge avoids blocking WordPress startup. New Playgrounds also stay temporary until the user chooses whether to restore or keep them, so a discarded fresh site does not consume one of the last 5 autosave slots.

Implementation

Adds autosave metadata for persistence state, last-used time, and setup URL fingerprinting. The fingerprint ignores transient parameters such as site-slug, modal state, and cache busters.

The site selection flow now:

  1. loads an explicit site-slug when present
  2. otherwise creates a fresh temporary site from the setup URL
  3. looks for a recent matching autosave
  4. shows the restore nudge while WordPress continues loading
  5. autosaves the fresh site only after Keep new

Autosaves are kept as the last 5 recent autosaves unless the user chooses Store permanently.

The saved Playgrounds UI was adjusted around that model: autosaves appear first, the status indicator owns Unsaved / Autosaved actions, creation buttons are intent-driven, and GitHub import opens its modal before creating a site.

Supporting storage changes let new OPFS Playgrounds become usable before the full initial file copy finishes while still flushing queued writes in the background.

Testing instructions

Automated coverage:

npm exec nx test playground-website --testFile=setup-url.spec.ts
npm exec nx test php-wasm-web --testFile=directory-handle-mount.spec.ts
npm exec nx typecheck playground-website
npm exec nx typecheck php-wasm-web
npm exec nx lint playground-website
npx playwright test --config=packages/playground/website/playwright/playwright.config.ts website-ui.spec.ts --project=chromium --workers=1 --grep "Default Playground storage"
npx playwright test --config=packages/playground/website/playwright/playwright.config.ts sites-api.spec.ts opfs.spec.ts --project=chromium --workers=1 --grep "playgroundSites.list\\(\\) returns the active site|should switch between sites"

GitHub CI passed on edcc8ed93 with 48 jobs.

@adamziel adamziel force-pushed the codex/default-saved-playgrounds branch from bb825ab to 1861daa Compare May 19, 2026 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant