Skip to content

[Blueprints] Report ZIP extraction progress during WordPress imports - #4168

Merged
adamziel merged 10 commits into
trunkfrom
adamziel/granular-zip-import-progress
Jul 25, 2026
Merged

[Blueprints] Report ZIP extraction progress during WordPress imports#4168
adamziel merged 10 commits into
trunkfrom
adamziel/granular-zip-import-progress

Conversation

@adamziel

@adamziel adamziel commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

importWordPressFiles() now advances its existing Unpacking archive phase while the ZIP is extracted, instead of jumping from zero to 30% after extraction.

unzipFile() accepts an optional progress callback:

await unzipFile(php, zip, target, true, (progress) => {
	renderProgress(progress);
});

ZipArchive::extractTo() has no extraction-progress callback in any supported PHP version, so this PR calls it in batches. Each batch ends after either 100 files or 400 KiB of uncompressed data, whichever comes first. For example, 250 one-byte files are extracted as three batches of 100, 100, and 50 files, with an update after each batch.

Each update includes cumulative file and byte counts plus their totals. Calls without a callback use the same extraction loop but skip the totals scan and progress output.

The run inputs are passed through the PHP request environment rather than interpolated into PHP source.

Browser clients receive the updates through runStream(). The worker keeps the PHP instance checked out until that stream finishes.

Updates happen between ZIP entries. A single entry larger than 400 KiB reports after that entry finishes; this does not replace ZipArchive with a custom ZIP reader.

This PR supplies real import progress. It does not replace the website's indeterminate full-page loader yet.

Testing

Run importWordPressFiles() with a progress tracker against a multi-megabyte export. Confirm Unpacking archive reports intermediate values before reaching its existing 30% boundary.

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.

This PR adds ZIP extraction progress reporting to WordPress imports by streaming incremental unzip progress updates from PHP to JS, and wiring those updates into the existing progress tracker/worker lifecycle.

Changes:

  • Extend unzipFile() to optionally report progress during extraction (files + uncompressed bytes), using runStream() when enabled.
  • Update importWordPressFiles() to advance the existing “Unpacking archive” phase based on unzip progress instead of jumping after extraction.
  • Add/extend tests to validate unzip progress reporting and ensure pooled PHP instances remain checked out until streaming completes.

Reviewed changes

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

Show a summary per file
File Description
packages/playground/common/src/index.ts Adds UnzipProgress, batch-based ZIP extraction progress reporting, and runStream() parsing of progress lines.
packages/playground/blueprints/src/lib/steps/import-wordpress-files.ts Hooks unzip progress into the import progress tracker (0–30% “Unpacking archive”).
packages/playground/blueprints/src/tests/steps/import-wordpress-files.spec.ts Adds a regression test verifying intermediate progress during archive unpacking.
packages/php-wasm/universal/src/lib/php-worker.ts Adds runStream() to the worker API and keeps pooled PHP checked out until response.finished.
packages/php-wasm/universal/src/test/php-worker.spec.ts Tests that pooled PHP isn’t reaped until the streaming response finishes.
packages/php-wasm/node/src/test/unzip-file.spec.ts Adds tests for unzip progress batching and compatibility (including PHP 5.2).

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

Comment thread packages/playground/common/src/index.ts Outdated
Comment thread packages/playground/common/src/index.ts
Comment thread packages/playground/common/src/index.ts Outdated
Comment thread packages/playground/common/src/index.ts Outdated
Comment thread packages/playground/common/src/index.ts Outdated
Comment thread packages/php-wasm/universal/src/lib/php-worker.ts
@adamziel
adamziel merged commit 030d919 into trunk Jul 25, 2026
53 checks passed
@adamziel
adamziel deleted the adamziel/granular-zip-import-progress branch July 25, 2026 16:58
adamziel added a commit that referenced this pull request Jul 27, 2026
#4168 reports progress between `ZipArchive` extraction batches. The
website
still discarded those details and showed the same indeterminate viewport
for
the entire import.

This PR keeps that progress in Redux and renders it in the site
viewport. The
bar remains animated until the first non-zero update, then becomes
determinate
and shows `Extracting {processed}/{total}` as its only status line.
Ordinary
boot and import progress use the same `LoadingViewport` rendering path.

PHP executes synchronously inside its worker, so `flush()` alone cannot
deliver
a progress line until execution returns. On PHP 7+, `unzipFile()` yields
after
the first and final updates and no more than once every 50 ms between
them.
Extraction still uses only `ZipArchive`; this PR adds no file-transfer,
metadata-scanning, or alternate ZIP-extraction path.

| | Before | After |
| --- | --- | --- |
| Desktop | ![Indeterminate ZIP import loader on
desktop](https://raw.githubusercontent.com/articles-adamziel-com/wordpress-playground/dd264da9c33266c59731047a8513654470a2028d/before-desktop.png)
| ![ZIP extraction file count and determinate progress bar on
desktop](https://raw.githubusercontent.com/articles-adamziel-com/wordpress-playground/d98da202ce8b6e8100614f7c5929d462d8fdce9e/pr4176-after-reduced-desktop.png)
|
| Mobile | ![Indeterminate ZIP import loader on
mobile](https://raw.githubusercontent.com/articles-adamziel-com/wordpress-playground/dd264da9c33266c59731047a8513654470a2028d/before-mobile.png)
| ![ZIP extraction file count and determinate progress bar on
mobile](https://raw.githubusercontent.com/articles-adamziel-com/wordpress-playground/d98da202ce8b6e8100614f7c5929d462d8fdce9e/pr4176-after-reduced-mobile.png)
|

## Testing

Open the website without `storage=temp` and import a ZIP containing
thousands
of entries. Confirm the viewport changes from an animated bar to
`Extracting {processed}/{total}` with a determinate bar, then opens the
imported
site. Reload and confirm the saved site remains available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment