Repository navigation
Closes #1315: Keep next-gen progress visible until done - #1348
faisalahammad wants to merge 5 commits into
Conversation
The "Generating missing next-gen" bar was hidden as soon as the remaining count hit 0, so users never saw n/n and got no message. The first count also took 15 seconds, so small runs ended unseen. Now the bar shows n/n, stays full and a done message is shown. The first progress request is sent right away, and ticks that come before the run starts are ignored. Fixes wp-media#1315
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 12 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
Note Generated by the AI delivery pipeline (lead-reviewer · standalone). Review: CHANGES REQUESTED (one MEDIUM convention finding; logic is sound) Blockers:
Inline findings (rendered, dry run):
Verified OK:
Tests:
Nice-to-haves:
|
- Create the next-gen done message with native DOM, after the single missing-message paragraph, instead of jQuery. - Fill the role="status" live region after insertion so screen readers announce it. - After the launch request answers, ignore ticks until a new Imagifybeat request was sent, so a tick from before the launch can not finish the new run. Addresses PR feedback. Refs wp-media#1348
|
@remyperona Thanks for the review. I pushed 1fda655 and merged the latest
Checks: ESLint clean, Jest 44/44 pass. The E2E and Code Coverage failures come from the missing Could you take another look? |
remyperona
left a comment
There was a problem hiding this comment.
Note
Generated by the AI delivery pipeline (lead-reviewer · standalone).
Review: CHANGES REQUESTED
One blocker: reloading the settings page after a completed run brings the "done" state back, with the button hidden, for up to an hour. Details are in the inline comment on options.js:582.
What holds up
launching,waitingFreshTickand theconnectNow()calls stop an old count from finishing or resetting a new run. This relies on jQuery's callback order inbeat.js(.always()before.done()) and a 0 ms timer, so it is fragile, but it is correct today.- The new DOM code uses native APIs and
textContent, with noinnerHTML. The jQuery calls added (.css,.hide,.slideDown) match the rest of this legacy file. options.min.jswas rebuilt from the new source.- The new string uses
__()with theimagifytext domain and is passed throughwp_localize_script.
Tests
- No automated test covers the
launching/waitingFreshTicklogic. The Jest suite inTests/jsonly covers helpers andgetProgress. - This JS admin UI is a frontend change, so it needs a Playwright spec, or at least a "reload after done" step in the manual test plan.
- Resume the next-gen run in init() only when remaining > 0, so the cached total no longer replays the done state after a reload. - Change the done message to "Next-gen generation is complete." - Shorten the addQueueImagifybeat() comment to two lines. Addresses PR feedback. Refs wp-media#1348
faisalahammad
left a comment
There was a problem hiding this comment.
@remyperona Thanks for the review. I pushed a54f1f8 and merged the latest develop.
- [MEDIUM] Reload after a done run (options.js:582): Fixed.
init()resumes a run only whenremaining > 0, so the cached total no longer brings back the done state or hides the button. - Nit, comment length: Fixed, now 2 lines.
- Nit, done message: Changed to "Next-gen generation is complete."
- Tests: I added "reload after done" and "reload during a run" steps to the How to test section. I did not add a Playwright spec in this PR. I can add one if you want it here.
Local checks: npm run build, npm run test:unit, composer test-unit, composer run-stan, PHPCS. All pass.
Can you take another look?
|
@remyperona Two CI checks fail on this PR, but not because of the code change.
All other checks pass: PHPUnit on all PHP and WP versions, Jest, PHPCS, PHPStan and Codacy. Can you run CI with secrets for this branch? For example, push it to a branch in |
Description
Closes #1315
When next-gen generation runs on the settings page (after saving AVIF/WebP, or with the "Generate missing next-gen versions" button), the progress bar was hidden as soon as the remaining count reached 0. Users never saw
n/nand got no message, so it looked like the process stopped. The first progress check also waited 15 seconds, so small runs finished before anything moved.Now the bar shows
n/n, stays full, the button is hidden and a "Next-gen generation is complete." message is shown. The first progress check is sent right away.Type of change
Detailed scenario
What was tested
Manual:
n/nwith the done message.Automated:
npm run build(ESLint),npm run test:unit(Jest),composer test-unit,composer run-stan, PHPCS on the changed PHP file. All pass.How to test
n/n(full), the button is hidden and the text says "Next-gen generation is complete."n/n). Expected: the bar comes back with the current count and finishes.Affected Features & Quality Assurance Scope
Settings page next-gen generation progress (Imagifybeat polling in
assets/js/options.js). No PHP logic change, only a new translatable string.Technical description
Documentation
processQueueImagifybeat()paints the bar first, then callsprocessFinished( true )whenremaining === 0. Before, it finished before painting.processFinished( completed ): whencompletedis true, the bar is kept, the button and the "missing" text are hidden, and a<p role="status">is added with native DOM right after the single "missing" paragraph. Its text is set 100 ms after insertion so screen readers announce it.init()andlaunchProcess()callimagify.beat.connectNow()so the first count comes right away.init()resumes a run only whenremaining > 0. Theimagify_missing_next_gen_totaltransient stays up to an hour after a run, so a reload after a finished run must not show the run UI again.launchingflag), and after the launch answers until a new Imagifybeat request was sent (waitingFreshTickflag). Imagifybeat can send the next request from the previous request's.always()callback, before that previous tick fires, so the flag is cleared on the next task. This way an old count can not finish or reset the new run.nextGenDoneTextininc/functions/i18n.php.New dependencies
None.
Risks
Low, JS only. Known limits not changed by this PR: a media counts as done once any one of its sizes has a next-gen version, so
n/ncan show while the last full sizes are still converting. A media that keeps failing with a temporary error keeps the bar atx/n.Mandatory Checklist
Code validation
Code style
Unticked items justification
No JS test covers
options.jstoday (it is a jQuery file bound to the settings page markup). The change was tested by hand on the settings page.Additional Checks