Save Playgrounds by default#3655
Draft
adamziel wants to merge 17 commits into
Draft
Conversation
bb825ab to
1861daa
Compare
…playgrounds # Conflicts: # packages/playground/website/src/lib/state/redux/boot-site-client.ts
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.
What it does
explicitand kept by Playground unless the user deletes them or browser/platform storage is cleared.Saved Playgroundlabel for default-created sites withAutosaved Playground,Autosaving..., orFinalizing autosave...as appropriate.Saveeven while an autosaved Playground is still syncing, so users can preserve the recovery copy immediately.Your Playgroundstoolbar label on desktop so stored sites are easier to find.Saving n/n...state by adding OPFS sync phases: copy progress remains counted, while final journal flush reports as finalizing.?storage=temp,?can-save=no, browser/storage fallbacks, and the Your Playgrounds overlayUnsaved Playgroundopt-out.Finalizing autosave...cannot block forever while WordPress keeps a request or filesystem write active.plan.mdwith the UX/research plan for autosaved default Playgrounds.UX model
The PR now separates recovery from intent:
Autosaved Playground: created automatically in browser storage to avoid data loss. It is removed after 5 newer autosaves unless the user saves it.Saved Playground: explicitly saved by the user viaSave,Save Playground, rename/save APIs, or local filesystem save. It is kept by Playground unless the user deletes it or browser/platform storage is cleared.Unsaved Playground: explicit temporary storage. It keeps the existing warning/save affordance.This follows patterns from other products that separate automatic recovery from intentional preservation:
Implementation
persistence?: 'autosave' | 'explicit'andwhenLastUsedmetadata. Missingpersistenceis treated as explicit for backwards compatibility with existing saved Playgrounds.site-lifecycle.tsand focused tests for legacy handling, retention,whenLastUsed, and pruning exclusions.preserveSite()andplaygroundSites.keep()to promote autosaves to explicit saved sites.createNewSavedSite()now creates autosaves and prunes old autosaves after the new site is selected.persistTemporarySite()and rename/save APIs promote sites to explicit persistence.bootSiteClient()updateswhenLastUsedfor non-temporary sites so autosave retention is based on recency, not only creation time.phase: 'copying' | 'flushing', sends a final copy progress event before the flush phase, and lets the mount resolve while the final journal flush continues in the background.Saveas the autosave promotion action, and avoids leaving users stuck onFinalizing autosave...when the final OPFS journal flush is waiting on ongoing WordPress activity.Autosaving...means recovery is still in progress.Testing
Local passing:
npx nx test playground-website --testFile=packages/playground/website/src/lib/state/redux/slice-sites.spec.tsnpx nx test php-wasm-web --testFile=packages/php-wasm/web/src/lib/directory-handle-mount.spec.tsnpx nx run playground-website:typechecknpx nx run php-wasm-web:typecheckgit diff --checkLatest local passing after merge conflict resolution and finalizing-fix:
npx nx test php-wasm-web --testFile=packages/php-wasm/web/src/lib/directory-handle-mount.spec.tsnpx nx run playground-website:typechecknpx nx run php-wasm-web:typecheckgit diff --checkLocal blocked:
npx playwright test --config=packages/playground/website/playwright/playwright.config.ts --project=chromium -g "Default Playground storage"libglib-2.0,libnss3,libX11,libgbm,libasound, and related dependencies). CI provides browser coverage.CI:
02d94ade6exposed a race intest-e2e-playwright (chromium, 3/3, 3-of-3): the persistence smoke reloaded while the UI still showedAutosaving..., before the initial OPFS mount was ready.e0a7517c545afc2de0355f1b0146072f3366eac5passed GitHub Actions run26066078037: 51 passed, 2 intentionally skipped.ed331afc4f4fac0c3864f852119c56e91de4de74merges currentorigin/trunk, resolves theboot-site-client.tsconflict by combiningwordpressInstallModewith the saved-by-default background OPFS mount behavior, and fixes the stuckFinalizing autosave...state. GitHub Actions run26087850389is in progress.