[Storage] Add embedded site OPFS locator - #4184
Closed
ashfame wants to merge 6 commits into
Closed
Conversation
ashfame
force-pushed
the
agent/add-embedded-site-opfs-path
branch
from
July 28, 2026 23:53
2da7fdc to
326ab85
Compare
adamziel
pushed a commit
that referenced
this pull request
Jul 29, 2026
## What Updates the concurrent SQLite publish regression fixture so its `varchar` columns accept the 500-character values the test intentionally inserts. ## Root cause The test created every stress column as `varchar(191)` and then inserted a 500-character value into each column. Current WordPress field validation rejects those values before the test reaches the SQLite concurrency behavior it is meant to exercise, returning HTTP 500 with an error that the supplied values may be too long or invalid. The mismatch has existed since the test was introduced in #3920. It was exposed while working on #4184 because changes to `@wp-playground/storage` mark Playground CLI as affected and therefore execute the entire CLI suite. Running the focused test directly on the current `trunk` commit reproduces the same failure, so this is independent of the OPFS work. Changing the schema to `varchar(500)` preserves the intended payload and concurrency pressure while making the fixture internally valid. ## Impact This changes test setup only. Production CLI and SQLite behavior are unchanged. This is the first of two stacked PRs. #4190 is stacked on this branch and corrects the CI base/head calculation used by `nx affected`, which currently compares `trunk` to itself on post-merge push runs and skips affected Nx tasks. ## Testing - `npm exec nx run playground-cli:test-playground-cli -- --testFile=sqlite-concurrent-publish.spec.ts` - `npm exec nx run playground-cli:typecheck` - `npm exec nx lint playground-cli` - `npx nx format:check --base=origin/trunk --head=HEAD`
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
Adds a constrained OPFS locator for sites managed by embedding applications:
getExistingEmbeddedSiteOpfsDirectoryHandle(storageKey)is public and only opens an existing directory.getOrCreateEmbeddedSiteOpfsDirectoryHandle(storageKey)is private tobrowser-fs.tsand is used by mount handling.opfs-paths.tsowns both the website-managed/sitesroot and embedded-site/embedded-sitesroot, plus the internal embedded-site path derivation.Adds an
opfs-embedded-sitemount device that accepts the same opaque storage key.remote.htmlalready resolves mounts throughdirectoryHandleFromMountDevice(), which now uses the private get-or-create operation.Why
An embedding that persists a Playground through
remote.htmland later reads it through a lightweightapi.htmlneeds both endpoints to locate the same directory by storage key. Creation policy should not be a caller-controlled boolean: mount handling must create the directory, while a consumer must never turn an unknown key into an empty site.This is intentionally a small precursor to #4095. That PR can call
getExistingEmbeddedSiteOpfsDirectoryHandle(storageKey)and pass the returned handle to its ZIP implementation.The website-specific
opfsSiteStorage.exportSavedSiteAsZip(slug)remains unchanged. It is coupled to the website's/sitesnamespace, slug lookup, andwp-runtime.jsoncompleteness metadata, so it is not the exporter for embedded sites.Impact
Embedders can persist a site through
startPlaygroundWeb()with:Before removing the Playground iframe, callers should use
await playground.flushOpfs('/wordpress')orawait playground.unmountOpfs('/wordpress')to ensure pending changes have reached OPFS.The later lightweight API can locate the persisted directory with:
Existing raw
opfspath mounts are unchanged. Website and Personal WP site storage now share the canonical/sitesroot exported by the storage package.Testing
npm exec nx test playground-storagenpm exec nx lint playground-storagenpm exec nx build playground-storagenpm exec nx build playground-clientnpm exec nx typecheck playground-personal-wpnpm exec nx lint playground-personal-wpnpm exec nx typecheck playground-websitenpm exec nx lint playground-websitenpm exec nx test playground-website