Skip to content

Admin shell: Open Blaze Ads without a page load - #54905

Closed
enejb wants to merge 5 commits into
trunkfrom
try/blaze-admin-shell
Closed

enejb wants to merge 5 commits into
trunkfrom
try/blaze-admin-shell

Conversation

@enejb

@enejb enejb commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Fixes JETPACK-3745

Proposed changes

Exploratory. With the jetpack-admin-shell flag on, Jetpack → Blaze Ads opens inside the admin shell, without a page load, like the other Jetpack dashboards. Blaze itself is not rewritten: it's still the Calypso bundle loaded from widgets.wp.com.

Admin shell (packages/admin-ui)

  • New script member kind for pages that aren't built with wp-build. A script member declares the element its scripts mount into (container: id and optional class) instead of the wp-build keys. The shell creates that element, then runs the page's own scripts through the guest endpoint, and the scripts boot the page. Hovering its menu link starts the download early.
  • Script members join only as guests. Loading one directly is still a normal page load.
  • The container goes inside empty copies of the host page's boot-layout wrappers, so the page gets the same frame, rounded stage and loading state as the wp-build dashboards. The copied stage gets a stable jetpack-admin-shell__stage class for the page's own CSS, since boot's class names are hashed.
  • A script page counts as rendered once its container has content (it may show its own loader before any heading). If its boot fails, its styles are removed and later visits load the page normally.
  • A script member's stylesheets are switched off while it is hidden. Calypso's CSS includes an unlayered global reset (div, span, a, li, ul, h1, button { margin: 0; padding: 0; … }), and @wordpress/ui styles live in @layer wp-ui.components, so the reset restyled tabs, toggles and buttons on every other dashboard once Blaze had loaded.
  • The synthetic popstate the shell sends after a switch now carries no state. TanStack reads history itself, and calypso-router throws on another router's state but re-reads the URL on a null one.

Blaze (packages/blaze)

  • Registers the dashboard as a script member when it sits in the Jetpack menu. Not on Simple sites, when the dashboard is disabled, when Blaze can't initialize, or when the standalone Blaze Ads plugin owns the menu. Only when the installed admin-ui knows the script kind.
  • When Blaze is one of the shell's pages, loading it directly also draws it in the Jetpack dashboards' frame: the menu-coloured surround and a white stage with 12px corners that scrolls inside, from 782px up. The empty stage replaces the GIF spinner while it loads. With the shell off, the page looks as it does on trunk.
  • Inside .jetpack-admin-shell__stage, Calypso's .promote-post-i2__page gets min-height: calc(100vh - admin bar - 8px) instead of 100vh - admin bar, so it no longer overflows the stage by the 8px gap below it. The rule sits on the dashboard's stylesheet, so it also loads (and switches off) with Blaze in the shell.
  • The inline jQuery that render() printed (icon sprite + hashbang links) is now plain JS attached to the dashboard script with wp_add_inline_script(), so it also runs inside the shell. Behavior on a normal page load is unchanged.

Known gaps (exploratory):

  • Calypso's is-section-promote-post-i2 body class and --color-* variables on <html> stay after Blaze has loaded; nothing visible depends on them with its stylesheet off.
  • Blaze now scrolls inside the stage, like the wp-build dashboards. Calypso's infinite-scroll lists haven't been tried with a long list yet.

Test coverage: the PHP member validation has unit tests, and the client has a test for switching a hidden page's stylesheets off. The rest is the page boot, the router hand-off and the direct-load frame, which only show up in a real browser with the Calypso bundle, so the rehearsals below cover them instead (hence Covered by non-unit tests).

Related product discussion/links

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

No.

Testing instructions

Rehearsals

Run the rehearsals below from Tools → Rehearsal on any Jurassic Ninja site with the shell flag on. They work in both setups below (with Jetpack, or VideoPress + Blaze Ads) and cover: opening Blaze from another dashboard without a page load, Blaze's styles staying off the other dashboards (and the second visit having no console errors), and the direct load drawing the rounded frame. The prose steps cover what they can't: looks, the flag-off path and links inside Blaze.

Rehearsal: Blaze Ads: Opens from another Jetpack dashboard without a page load

Rehearsal f357d90 · 6 steps · covers packages/admin-ui, packages/blaze, packages/my-jetpack
Last run: Passed on WordPress 7.1.4 · Theme: Twenty Twenty-Four 1.6 · Akismet Anti-spam: Spam Protection 5.7.2 · Blaze Ads 0.9.0 · Jetpack VideoPress 3.8, run #18, 2026-11-12.
View or install this rehearsal · JSON · Playwright test (links work while wildly-residential.jurassic.ninja exists)

Rehearsal JSON
{
    "format": 2,
    "requires": [
        "jetpack or jetpack-videopress",
        "jetpack or blaze-ads"
    ],
    "covers": [
        "packages/admin-ui",
        "packages/blaze",
        "packages/my-jetpack"
    ],
    "viewport": "desktop",
    "timeout": 30000,
    "steps": [
        {
            "goto": "/wp-admin/admin.php?page=my-jetpack"
        },
        {
            "expect": "[data-shell-page=\"my-jetpack\"][data-shell-state=\"visible\"]",
            "toHaveCount": 1
        },
        {
            "click": "#adminmenu a:has-text(\"Blaze Ads\")"
        },
        {
            "expect": "[data-shell-state=\"visible\"] h1:has-text(\"Blaze Ads\")",
            "toBeVisible": true
        },
        {
            "expect": "[data-shell-page=\"my-jetpack\"][data-shell-state=\"hidden\"]",
            "toHaveCount": 1
        },
        {
            "expectNoConsoleErrors": true
        }
    ]
}

Rehearsal: Blaze Ads: Its styles stay off the other Jetpack dashboards

Rehearsal e1db83c · 12 steps · covers packages/admin-ui, packages/blaze, packages/my-jetpack
Last run: Passed on WordPress 7.1.4 · Theme: Twenty Twenty-Four 1.6 · Akismet Anti-spam: Spam Protection 5.7.2 · Blaze Ads 0.9.0 · Jetpack VideoPress 3.8, run #19, 2026-11-12.
View or install this rehearsal · JSON · Playwright test (links work while wildly-residential.jurassic.ninja exists)

Rehearsal JSON
{
    "format": 2,
    "requires": [
        "jetpack or jetpack-videopress",
        "jetpack or blaze-ads"
    ],
    "covers": [
        "packages/admin-ui",
        "packages/blaze",
        "packages/my-jetpack"
    ],
    "viewport": "desktop",
    "timeout": 30000,
    "steps": [
        {
            "goto": "/wp-admin/admin.php?page=my-jetpack"
        },
        {
            "expect": "[data-shell-page=\"my-jetpack\"][data-shell-state=\"visible\"]",
            "toHaveCount": 1
        },
        {
            "click": "#adminmenu a:has-text(\"Blaze Ads\")"
        },
        {
            "expect": "[data-shell-state=\"visible\"] h1:has-text(\"Blaze Ads\")",
            "toBeVisible": true
        },
        {
            "click": "#adminmenu a:has-text(\"My Jetpack\")"
        },
        {
            "expect": "[data-shell-page=\"my-jetpack\"][data-shell-state=\"visible\"]",
            "toHaveCount": 1
        },
        {
            "expect": "link[href*=\"blaze-dashboard\"][disabled]",
            "toHaveCount": 1
        },
        {
            "expect": "[data-shell-page=\"my-jetpack\"] [role=tab]:has-text(\"Overview\")",
            "toBeVisible": true
        },
        {
            "click": "#adminmenu a:has-text(\"Blaze Ads\")"
        },
        {
            "expect": "[data-shell-state=\"visible\"] h1:has-text(\"Blaze Ads\")",
            "toBeVisible": true
        },
        {
            "expect": "link[href*=\"blaze-dashboard\"]:not([disabled])",
            "toHaveCount": 1
        },
        {
            "expectNoConsoleErrors": true
        }
    ]
}

Rehearsal: Blaze Ads: Loads in the rounded Jetpack frame

Rehearsal 0893b2e · 4 steps · covers packages/admin-ui, packages/blaze
Last run: Passed on WordPress 7.1.4 · Theme: Twenty Twenty-Four 1.6 · Akismet Anti-spam: Spam Protection 5.7.2 · Blaze Ads 0.9.0 · Jetpack VideoPress 3.8, run #20, 2026-11-12.
View or install this rehearsal · JSON · Playwright test (links work while wildly-residential.jurassic.ninja exists)

Rehearsal JSON
{
    "format": 2,
    "requires": [
        "jetpack or jetpack-videopress",
        "jetpack or blaze-ads"
    ],
    "covers": [
        "packages/admin-ui",
        "packages/blaze"
    ],
    "viewport": "desktop",
    "timeout": 30000,
    "steps": [
        {
            "goto": "/wp-admin/admin.php?page=advertising"
        },
        {
            "expect": "#wpcom h1:has-text(\"Blaze Ads\")",
            "toBeVisible": true
        },
        {
            "expect": "[class*=\"-frame__stage\"] #wpcom h1:has-text(\"Blaze Ads\")",
            "toBeVisible": true
        },
        {
            "expectNoConsoleErrors": true
        }
    ]
}

With the Jetpack plugin

  • On a connected site with this branch, turn the shell on: wp companion feature-flag enable jetpack-admin-shell on Jurassic Ninja, or add_filter( 'jetpack_admin_shell_enabled', '__return_true' );.
  • Go to Jetpack → My Jetpack (or any other shell dashboard) and wait for it to load.
  • Click Jetpack → Blaze Ads. The address changes to page=advertising without a page load. The empty white rounded stage shows, then the Blaze dashboard renders in it (no grey GIF spinner, no square corners).
  • Click Jetpack → My Jetpack. The Overview / Features / Help tabs keep their spacing and the toggles and buttons look as before visiting Blaze.
  • Click Jetpack → Blaze Ads again. It shows at once, still styled, with no reading 'replace' error in the console.
  • Open wp-admin/admin.php?page=advertising directly. Blaze loads in the same rounded frame as Jetpack → Protect: its stage starts at the same spot, is the same size, and shows all four corners. Links inside it (Campaigns, Payments, Promote) still work.
  • Turn the flag off and repeat: Blaze Ads is a normal page load with no frame, as on trunk.
  • Optional: add &jetpack_admin_shell_debug=1 to log each switch in the console.

Without the Jetpack plugin (VideoPress + Blaze Ads)

This checks that Blaze joins the shell through another plugin's copy of the packages. Blaze Ads 0.9.0 bundles jetpack-blaze 0.27.0 and puts Blaze under Tools, so this setup swaps in this branch's package and moves Blaze under the Jetpack menu with a test-only mu-plugin. Shipping that for real needs a change in Automattic/blaze-ads after a jetpack-blaze release.

  • On the same connected site, build the VideoPress plugin from this branch (jetpack build --deps plugins/videopress), install and activate it, then deactivate Jetpack.

  • Install and activate Blaze Ads from WordPress.org. Replace wp-content/plugins/blaze-ads/vendor/automattic/jetpack-blaze/src and build with this branch's projects/packages/blaze/src and build.

  • Keep the shell flag on and JETPACK_AUTOLOAD_DEV defined, so this branch's admin-ui from VideoPress is the copy that loads.

  • Add this test-only mu-plugin:

    wp-content/mu-plugins/1-blaze-ads-under-jetpack-menu.php
    <?php
    // Test only: let Blaze Ads' bundled jetpack-blaze put Blaze under the Jetpack menu, so it can join the admin shell.
    add_filter( 'jetpack_blaze_enabled', '__return_true', 20 );
    add_filter(
    	'jetpack_blaze_menu_slug',
    	static function () {
    		return 'wp-blaze';
    	}
    );
    add_action(
    	'admin_menu',
    	static function () {
    		global $wp_filter;
    		foreach ( $wp_filter['admin_menu']->callbacks[999] ?? array() as $callback ) {
    			$function = $callback['function'];
    			if ( is_array( $function ) && is_object( $function[0] ) && 'BlazeAds\Blaze_Dashboard' === get_class( $function[0] ) && 'add_admin_menu' === $function[1] ) {
    				remove_action( 'admin_menu', $function, 999 );
    			}
    		}
    	},
    	998
    );
  • Go to Jetpack → My Jetpack. The Jetpack menu lists My Jetpack, Activity Log, Blaze Ads and VideoPress.

  • Click Jetpack → Blaze Ads. The address changes to page=wp-blaze without a page load, and Blaze renders in the rounded stage. It's in Blaze Ads mode: blue theme, no Jetpack logo, "Blaze Ads" in the footer.

  • Click Jetpack → VideoPress. It looks as it does without visiting Blaze: no Calypso fonts or reset on its tabs and buttons.

  • Open wp-admin/admin.php?page=wp-blaze directly. Blaze loads in the rounded frame.

  • To restore: activate Jetpack and delete the mu-plugin; reinstalling Blaze Ads brings back its own jetpack-blaze.

@enejb enejb self-assigned this Nov 12, 2026
@github-actions

github-actions Bot commented Nov 12, 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 or WordPress.com Site Helper), and enable the try/blaze-admin-shell branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack try/blaze-admin-shell
bin/jetpack-downloader test jetpack-mu-wpcom-plugin try/blaze-admin-shell

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

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!

@jp-launch-control

jp-launch-control Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 7 files. Only the first 5 are listed here.

File Coverage Δ% Δ Uncovered
projects/packages/admin-ui/src/admin-shell/index.js 214/297 (72.05%) -13.24% 48 💔
projects/packages/blaze/src/class-dashboard.php 65/103 (63.11%) -20.45% 26 💔
projects/packages/blaze/src/class-blaze.php 203/289 (70.24%) -3.54% 16 💔
projects/packages/admin-ui/src/admin-shell/header.js 172/184 (93.48%) -0.48% 1 ❤️‍🩹
projects/packages/admin-ui/src/admin-shell/app.js 53/55 (96.36%) 0.14% 0 💚

Full summary · PHP report · JS report

Coverage check overridden by Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code .

@enejb
enejb marked this pull request as ready for review November 13, 2026 00:30
@kraftbj

kraftbj commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

@enejb - I updated the description to link this to the linear issue

@enejb
enejb force-pushed the try/blaze-admin-shell branch from 8b42fe7 to 4b2cc76 Compare November 13, 2026 22:34
@enejb
enejb force-pushed the try/blaze-admin-shell branch from 4b2cc76 to eee81d3 Compare November 17, 2026 16:00
@enejb enejb added Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Nov 17, 2026
… drop a non-text kind, and let the Blaze icon fetch fail quietly
@enejb

enejb commented Nov 27, 2026

Copy link
Copy Markdown
Member Author

The issue with this approach is that the CSS is coming from calypso and we could end up in the state where the CSS pollutes the global scope.
and once the users visits blaze then other Jetpack admin pages are impacted.

We explored another PR #55113 which uses an iframe to contain the css just to the scope of this PR but then you end up changing the feature, since the UI shows the sidebar.

I am closing this approach for now.

@enejb enejb closed this Nov 27, 2026
@github-actions github-actions Bot removed the [Status] Needs Review This PR is ready for review. label Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code [Package] Admin Ui [Package] Blaze [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants