[Blueprints] Report ZIP extraction progress during WordPress imports - #4168
Merged
Conversation
Contributor
There was a problem hiding this comment.
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), usingrunStream()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.
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 |  |  | | Mobile |  |  | ## 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.
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.
importWordPressFiles()now advances its existingUnpacking archivephase while the ZIP is extracted, instead of jumping from zero to 30% after extraction.unzipFile()accepts an optional progress callback: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
ZipArchivewith 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. ConfirmUnpacking archivereports intermediate values before reaching its existing 30% boundary.