Skip to content

Jetpack AI: load the Scheduled tasks tab only when it is opened - #51969

Draft
t-wright wants to merge 3 commits into
trunkfrom
update/jetpack-ai-lazy-scheduled-tasks
Draft

Jetpack AI: load the Scheduled tasks tab only when it is opened#51969
t-wright wants to merge 3 commits into
trunkfrom
update/jetpack-ai-lazy-scheduled-tasks

Conversation

@t-wright

@t-wright t-wright commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Fixes FORNO-512

Proposed changes

  • Lazy-load the Scheduled tasks tab into its own chunk. It's behind a flag that defaults to off, but its dependencies shipped with every AI page load.
  • Import requestJwt through a new @automattic/jetpack-ai-client/jwt subpath, which keeps the block editor script handles off the page.
  • Print the chunk base URL from PHP, since publicPath: 'auto' breaks under Simple's script concatenation.
  • Add an error boundary so a failed chunk load shows a notice instead of a blank page.

jetpack-ai-admin.js: 1,482 KB → 488 KB. Script handles: 30 → 25.

Related product discussion/links

  • FORNO-512

Does this pull request change what data or activity we track or use?

No.

Testing instructions

  1. Build: jp build plugins/jetpack --production.
  2. Open Jetpack → Jetpack AI with the network tab open. jetpack-ai-scheduled-tasks.js isn't requested.
  3. Enable the flag: add_filter( 'jetpack_feature_flag_enabled_ai-hub-scheduled-tasks', '__return_true' );
  4. Open the Scheduled tasks tab. The chunk loads with a 200 and the tab works as before.
  5. Optional: block the chunk URL in dev tools. The tab shows a reload notice and the page stays up.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the update/jetpack-ai-lazy-scheduled-tasks branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/jetpack-ai-lazy-scheduled-tasks

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions Bot added [JS Package] AI Client [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests Admin Page React-powered dashboard under the Jetpack menu RNA labels Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: October 6, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@jp-launch-control

jp-launch-control Bot commented Sep 4, 2026

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 3 files.

File Coverage Δ% Δ Uncovered
projects/packages/my-jetpack/src/class-wpcom-products.php 138/161 (85.71%) -1.24% 2 ❤️‍🩹
projects/plugins/jetpack/_inc/client/ai/main.jsx 81/87 (93.10%) 0.16% 0 💚
projects/plugins/jetpack/_inc/lib/admin-pages/class-jetpack-ai-page.php 201/214 (93.93%) 0.15% 0 💚

2 files are newly checked for coverage.

File Coverage
projects/plugins/jetpack/_inc/client/ai/components/chunk-error-boundary/index.jsx 5/5 (100.00%) 💚
projects/plugins/jetpack/_inc/client/ai/public-path.js 2/2 (100.00%) 💚

Full summary · PHP report · JS report

@t-wright
t-wright force-pushed the update/jetpack-ai-lazy-scheduled-tasks branch from 446044a to 033380f Compare September 4, 2026 06:49
The tab sits behind a flag that defaults to off, yet its DataViews and AI client dependencies shipped in every load of the AI page. Lazy-load the tab into its own chunk, with the plugin printing the chunk base URL because auto publicPath breaks under Simple's script concatenation. Import requestJwt through a new ai-client jwt subpath so the block editor script handles it dragged in stay off the page. Cuts jetpack-ai-admin.js from 1,482 KB to 487 KB and drops six script handles.
A failed chunk load used to throw through Suspense and unmount the whole AI page. A small error boundary now keeps the rest of the page up and asks the user to reload. The lazy-load test moves to its own file so it cannot depend on test order, and the public path module gets the same test its siblings have. Also drops 4 block editor script handles, not 6 as the previous commit said.
On CI the lazy import compiled DataViews during the flag test, and the 1s findBy wait ran out on the Suspense spinner. A static import in the test file moves that transform ahead of the tests.
@t-wright
t-wright force-pushed the update/jetpack-ai-lazy-scheduled-tasks branch from 033380f to 1c08f16 Compare September 9, 2026 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Admin Page React-powered dashboard under the Jetpack menu [JS Package] AI Client [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ RNA [Status] In Progress [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant