Skip to content

[Website] Reveal ZIP imports while their browser autosave finishes - #4132

Merged
adamziel merged 8 commits into
trunkfrom
adamziel/zip-import-progress
Jul 24, 2026
Merged

[Website] Reveal ZIP imports while their browser autosave finishes#4132
adamziel merged 8 commits into
trunkfrom
adamziel/zip-import-progress

Conversation

@adamziel

@adamziel adamziel commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

ZIP imports now leave the New Playground pane as soon as a file is selected.

The full-page Preparing WordPress screen stays up until the imported page is ready. The site then opens while its first OPFS autosave finishes in the Dock. The success notice appears only after that autosave completes.

Imported sites are autosaves, not permanent saves. They follow the normal autosave pruning rules.

Before After
Desktop — importing Before: ZIP import blocks the New Playground pane After: ZIP import uses the full-page Preparing WordPress screen
Mobile — complete Before: imported site completes without an in-page notice and is marked Saved After: imported site is marked Autosaved and shows a completion notice

Testing

Import a Playground ZIP at desktop and mobile sizes. Check that the New Playground pane closes, the full-page loader stays until the site is ready, and the success notice appears only after the Dock autosave finishes.

Import a malformed ZIP and check that the ZIP tab reopens with an inline error.

@adamziel
adamziel force-pushed the adamziel/import-zip-before-persistence branch from 300234e to 672b083 Compare July 21, 2026 10:33
@adamziel
adamziel force-pushed the adamziel/zip-import-progress branch from 859e84c to 4df3e25 Compare July 21, 2026 10:33
@adamziel
adamziel force-pushed the adamziel/import-zip-before-persistence branch from 672b083 to d614ca4 Compare July 21, 2026 10:51
@adamziel
adamziel force-pushed the adamziel/zip-import-progress branch from 4df3e25 to a27aaa9 Compare July 21, 2026 10:51
adamziel added a commit that referenced this pull request Jul 21, 2026
Playground ZIP exports now contain every file under `wp-content`, plus
`wp-config.php`. The manifest records `formatVersion: 2` so the importer
work in #4130 can distinguish these archives from pre-versioned partial
exports.

This removes the `selfContained` option from the public `zipWpContent()`
API. Every caller now receives a complete archive.

## Testing

Export a Playground with a custom file inside a default theme. Inspect
the ZIP and confirm it contains that file, `wp-config.php`, and a
`playground-export.json` manifest with `formatVersion: 2`.


## Stack

1. [#4139 — Export complete versioned Playground ZIP
snapshots](#4139)
2. [#4141 — Separate runtime-managed paths from legacy ZIP
omissions](#4141)
3. [#4130 — Import versioned ZIP content while retaining legacy
defaults](#4130)
4. [#4131 — Import ZIP contents before initial browser
persistence](#4131)
5. [#4132 — Keep ZIP preparation visible until the imported site is
ready](#4132)
6. [#4121 — Accept ZIP drops across the
page](#4121)
@adamziel
adamziel force-pushed the adamziel/import-zip-before-persistence branch from d614ca4 to 7d01d5a Compare July 21, 2026 11:13
@adamziel
adamziel force-pushed the adamziel/zip-import-progress branch from a27aaa9 to 32ef0d7 Compare July 21, 2026 11:13
@adamziel
adamziel force-pushed the adamziel/import-zip-before-persistence branch from 7d01d5a to 0a834bb Compare July 21, 2026 11:16
@adamziel
adamziel force-pushed the adamziel/zip-import-progress branch from 32ef0d7 to ab958d7 Compare July 21, 2026 11:16
@adamziel
adamziel force-pushed the adamziel/import-zip-before-persistence branch from 0a834bb to 77ac877 Compare July 21, 2026 12:20
@adamziel
adamziel force-pushed the adamziel/zip-import-progress branch from ab958d7 to 9d68a74 Compare July 21, 2026 12:20
@adamziel
adamziel force-pushed the adamziel/import-zip-before-persistence branch from 77ac877 to ab848b1 Compare July 21, 2026 12:28
@adamziel
adamziel force-pushed the adamziel/zip-import-progress branch from 9d68a74 to c864646 Compare July 21, 2026 12:28
@adamziel
adamziel force-pushed the adamziel/import-zip-before-persistence branch from ab848b1 to 2858fe5 Compare July 21, 2026 12:40
@adamziel
adamziel force-pushed the adamziel/zip-import-progress branch 2 times, most recently from 63a41a9 to 2b0a33c Compare July 21, 2026 12:50
@adamziel
adamziel force-pushed the adamziel/import-zip-before-persistence branch from 2858fe5 to 08a63a6 Compare July 21, 2026 12:50
adamziel added a commit that referenced this pull request Jul 21, 2026
… defaults (#4130)

A version-2 Playground ZIP now defines user-owned `wp-content`: archived
files replace the boot defaults, and a missing user file means it was
deleted. Legacy runtime artifacts remain owned by the importing
Playground through #4141.

Pre-versioned exports remain partial. When one omits a stock plugin,
theme, or database directory, import retains the fresh installation's
copy. An archived copy still wins when present.

This preserves customized default themes such as BrewCommerce's purple
Twenty Twenty-Five background through export, import, and reload without
treating stock themes as runtime files.

## Testing

Browser coverage imports a pre-versioned partial export, then separately
customizes Twenty Twenty-Five, exports it, imports it into a new
Playground, reloads, and checks both the theme file and rendered
background. The full stack passes 488 Blueprint tests, 347 website
tests, both packages' lint and typecheck, and 10 Chromium ZIP-import
scenarios.

## Stack

1. [#4139 — Export complete versioned Playground ZIP
snapshots](#4139)
2. [#4141 — Exclude legacy runtime artifacts from site
snapshots](#4141)
3. [#4130 — Import versioned ZIP user content while retaining legacy
defaults](#4130)
4. [#4131 — Import ZIP contents before initial browser
persistence](#4131)
5. [#4132 — Keep ZIP preparation visible until the imported site is
ready](#4132)
6. [#4121 — Accept ZIP drops across the
page](#4121)
@adamziel
adamziel force-pushed the adamziel/import-zip-before-persistence branch from 08a63a6 to 4623ea7 Compare July 21, 2026 13:45
@adamziel
adamziel force-pushed the adamziel/zip-import-progress branch from 2b0a33c to 2bba7ff Compare July 21, 2026 13:45
adamziel added a commit that referenced this pull request Jul 21, 2026
… defaults (#4130)

A version-2 Playground ZIP now defines user-owned `wp-content`: archived
files replace the boot defaults, and a missing user file means it was
deleted. Legacy runtime artifacts remain owned by the importing
Playground through #4141.

Pre-versioned exports remain partial. When one omits a stock plugin,
theme, or database directory, import retains the fresh installation's
copy. An archived copy still wins when present.

This preserves customized default themes such as BrewCommerce's purple
Twenty Twenty-Five background through export, import, and reload without
treating stock themes as runtime files.

## Testing

Browser coverage imports a pre-versioned partial export, then separately
customizes Twenty Twenty-Five, exports it, imports it into a new
Playground, reloads, and checks both the theme file and rendered
background. The full stack passes 488 Blueprint tests, 347 website
tests, both packages' lint and typecheck, and 10 Chromium ZIP-import
scenarios.

## Stack

1. [#4139 — Export complete versioned Playground ZIP
snapshots](#4139)
2. [#4141 — Exclude legacy runtime artifacts from site
snapshots](#4141)
3. [#4130 — Import versioned ZIP user content while retaining legacy
defaults](#4130)
4. [#4131 — Import ZIP contents before initial browser
persistence](#4131)
5. [#4132 — Keep ZIP preparation visible until the imported site is
ready](#4132)
6. [#4121 — Accept ZIP drops across the
page](#4121)
adamziel added a commit that referenced this pull request Jul 21, 2026
…me files (#4141)

Make new ZIP exports preserve the site’s plugins, themes, uploads, and
database exactly. Make imports remove any pre-bundled Playground's
runtime files (such as `0-playground.php` mu-plugin) and lean on their
latest versions shipped in the `/internal` directory.

## Backwards compatibility

Playground's ZIP export format evolved over time. Here's how each
version is handled after this PR:

| ZIP | Site files in `wp-content` | Playground runtime artifacts | If a
theme or plugin is missing |
| --- | --- | --- | --- |
| Before this PR | Custom plugins, themes, and uploads. Default
`themes/twenty*` directories were included only by the self-contained
export. `database/` may be absent. | Some January–May 2024 ZIPs contain
the old SQLite MU plugin. | Backfill well-known paths from the site
loaded right before the import: Akismet, Hello Dolly, WordPress
Importer, default themes, and `database/`. This is a best-effort
heuristic. We can't distinguish a deleted theme from a missing theme. |
| `formatVersion: 2` after this PR | Every site path then on disk:
plugins, themes, uploads, `database/`, and a custom `db.php` if the user
specifically created one. | None. | Leave it missing. |

On every import, archived Playground files are removed. The new
Playground supplies them.

## Playground runtime files

These four old paths are always treated as Playground-provided runtime
files:

- `mu-plugins/sqlite-database-integration`
- `mu-plugins/playground-includes`
- `mu-plugins/0-playground.php`
- `mu-plugins/0-sqlite.php`

From January 29 through May 8, 2024, the self-contained exporter
included `mu-plugins/sqlite-database-integration`. It also included
`mu-plugins/0-sqlite.php` when present. It already omitted
`mu-plugins/0-playground.php` and `mu-plugins/playground-includes`;
those entries handle stale sites, GitHub trees, and hand-built ZIPs.

`db.php` needs a separate rule because it can be a custom WordPress
drop-in. During legacy WordPress boot, `writeLegacyDbPhp()` creates
Playground's copy through `generateDbPhpContent()`. That function writes
`@playground-managed` into the file header. Only a `db.php` with that
marker is treated as a Playground file. An unmarked `db.php` stays with
the site.

Before January 29, 2024, SQLite used
`plugins/sqlite-database-integration`. This PR leaves that path as site
content because it is also a valid user-installed plugin path.

**Breaking change:** `wpContentFilesExcludedFromExport` is no longer
public. `getLegacyPlaygroundRuntimeWpContentPaths()` exposes the smaller
runtime rule.

## Testing

Tests cover a modified Twenty Twenty-Five theme, a deleted v2 theme, a
theme omitted by a pre-v2 ZIP, archived runtime files, marked and custom
`db.php` files, failed runtime staging, and archives without
`wp-content`. The full stack passes 488 Blueprint tests, 347 website
tests, package lint and typecheck, and 10 Chromium ZIP-import scenarios.

## Stack

1. [#4139 — Export complete versioned Playground ZIP
snapshots](#4139)
— merged
2. [#4141 — Exclude legacy runtime artifacts from site
snapshots](#4141)
— includes #4130
3. [#4131 — Import ZIP contents before initial browser
persistence](#4131)
4. [#4132 — Keep ZIP preparation visible until the imported site is
ready](#4132)
5. [#4121 — Accept ZIP drops across the
page](#4121)
@adamziel
adamziel requested review from a team, Copilot and zaerl July 21, 2026 19:42

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 the ZIP import UX so the full-viewport “Preparing WordPress” loader stays visible until the imported site is ready, while browser persistence can continue in the background with a Dock “Saving” state and a success-styled completion notice.

Changes:

  • Add global UI state to represent “site import running” and use it to control viewport loader + save indicator behavior.
  • Track ZIP import progress (installation + OPFS copy) and refresh the imported site before revealing it.
  • Replace alert() completion/failure UX with Dock operation notices and inline ZIP-tab errors; update Playwright coverage accordingly.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/playground/website/src/lib/state/redux/slice-ui.ts Adds siteImportIsRunning and introduces success/error “kind” for dock operation notices.
packages/playground/website/src/lib/state/redux/site-management-api-middleware.ts Implements ZIP import progress tracking, refresh-on-import, and toggles siteImportIsRunning.
packages/playground/website/src/components/site-manager/index.tsx Removes close-blocking wiring from the pane.
packages/playground/website/src/components/saved-playgrounds-panel/style.module.css Styles inline ZIP import status/error surfaces.
packages/playground/website/src/components/saved-playgrounds-panel/index.tsx Switches ZIP import UX to close pane + show success toast or inline error instead of dialogs.
packages/playground/website/src/components/playground-viewport/index.tsx Keeps loader visible and hides iframes while siteImportIsRunning is true.
packages/playground/website/src/components/dock/style.module.css Adds success styling for operation toast.
packages/playground/website/src/components/dock/dock.tsx Enables dismissing operation notices via Escape and click-outside (across iframes); adds success semantics.
packages/playground/website/src/components/browser-chrome/save-status-indicator.tsx Forces save status to loading during site import.
packages/playground/website/playwright/e2e/website-ui.spec.ts Updates failure-notice behavior expectations and dismissal mechanics.
packages/playground/website/playwright/e2e/opfs.spec.ts Adds/updates e2e coverage for ZIP import across OPFS/no-OPFS and updated success UX.
packages/playground/blueprints/src/lib/steps/import-wordpress-files.ts Reports progress captions/percentages during import step execution.

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

Comment thread packages/playground/website/src/lib/state/redux/site-management-api-middleware.ts Outdated
Comment thread packages/playground/website/src/lib/state/redux/slice-ui.ts
Base automatically changed from adamziel/import-zip-before-persistence to trunk July 21, 2026 20:34
adamziel added a commit that referenced this pull request Jul 21, 2026
ZIP imports used to persist a fresh WordPress installation before
applying the
archive. The archive then rewrote that stored filesystem:

1. Boot fresh WordPress in MEMFS.
2. Copy the fresh site to browser storage.
3. Apply the ZIP to the running site.
4. Flush the rewritten site to browser storage again.

This PR applies the ZIP during the new site's first boot, before its
initial
browser-storage copy:

1. Boot fresh WordPress in MEMFS.
2. Apply the ZIP in MEMFS.
3. Copy the finished filesystem to browser storage once.

`createNewSiteFromZip()` registers the import as first-boot work. The
boot path
runs that work before the initial MEMFS-to-OPFS copy, and the call
reports
success only after that copy finishes.

If ZIP initialization or the first OPFS copy fails, the newly created
stored
site is removed and the previously active Playground is selected again.
When
OPFS is unavailable, the import uses a fresh temporary Playground. Its
new slug
forces React to boot a new iframe instead of reusing the previous
runtime.

The ZIP picker now delegates this lifecycle to `createNewSiteFromZip()`
instead
of coordinating site creation, client boot, import, and persistence
through
component effects.

This PR does not change which files a ZIP contains or how versioned and
legacy
ZIP contents are interpreted. Those rules are handled by #4141 and
#4130. This
PR changes when the imported filesystem is written to browser storage.

## Testing

1. Import a ZIP from both temporary and saved Playgrounds and confirm
the new
   site persists after reload.
2. Import a malformed ZIP and confirm no incomplete stored site remains.
3. Confirm the previously active Playground remains selected after a
failed
   stored-site import.

Unit coverage checks that ZIP initialization runs before the initial
OPFS copy
and that failed-import cleanup selects the requested previous site once.
Browser
coverage checks that a failed import leaves the stored-site list
unchanged,
including after reload.

## Stack

1. [#4139 — Export complete versioned Playground ZIP
snapshots](#4139)
— merged
2. [#4141 — Export and import all site files except Playground runtime
files](#4141) —
merged
3. [#4130 — Import versioned ZIP user content while retaining legacy
defaults](#4130) —
merged
4. [#4131 — Import ZIP contents before initial browser
persistence](#4131)
5. [#4132 — Keep ZIP preparation visible until the imported site is
ready](#4132)
6. [#4121 — Accept ZIP drops across the
page](#4121)
@adamziel
adamziel force-pushed the adamziel/zip-import-progress branch from 9c56cbf to fe7b422 Compare July 21, 2026 20:37
@adamziel adamziel changed the title [Website] Keep ZIP preparation visible until the imported site is ready Jul 21, 2026
@adamziel
adamziel force-pushed the adamziel/zip-import-progress branch from 907eaee to 371553e Compare July 22, 2026 09:20
@adamziel
adamziel force-pushed the adamziel/zip-import-progress branch from 01522ad to 24e6693 Compare July 24, 2026 17:14
@adamziel
adamziel merged commit 2f2e65e into trunk Jul 24, 2026
52 of 53 checks passed
@adamziel
adamziel deleted the adamziel/zip-import-progress branch July 24, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment