Skip to content

Agents Manager: Add dedicated CIAB variant support#47314

Open
aaronfc wants to merge 5 commits intotrunkfrom
add/agents-manager-ciab-variant-support
Open

Agents Manager: Add dedicated CIAB variant support#47314
aaronfc wants to merge 5 commits intotrunkfrom
add/agents-manager-ciab-variant-support

Conversation

@aaronfc
Copy link
Contributor

@aaronfc aaronfc commented Feb 25, 2026

Proposed changes

Add a dedicated ciab variant for Agents Manager in CIAB (Commerce in a Box / Next Admin) environments. This replaces the previous approach of falling back to the wp-admin variant.

This is part of a 3-PR change set for WOOAI-253:

PR Repository Purpose
This PR Automattic/jetpack Add dedicated ciab variant to Agents Manager PHP
wp-calypso #108896 Automattic/wp-calypso Add agents-manager-ciab.js webpack entry point
ciab-admin #3299 Automattic/ciab-admin Disable Big Sky dock when AM is active

Key changes:

  • CIAB variant: get_variant() returns 'ciab' for connected CIAB sites and 'ciab-disconnected' for disconnected sites. CIAB manages its own AI experience.
  • Enabled by default with escape hatch: CIAB goes through is_enabled() like every other context, but with a dedicated agents_manager_enabled_in_ciab filter that defaults to true. This provides a clean way to disable AM in CIAB for debugging or gradual rollout.
  • Skip admin bar for CIAB: CIAB hides the classic WordPress admin bar and uses its own Site Hub. Admin bar manipulation (node removal, menu panel) is skipped for CIAB — the JS variant handles UI independently.
  • Help Center coexists: AM does not dequeue Help Center scripts in CIAB (dequeue only happens in Gutenberg). Help Center continues to manage its own Site Hub button.

Other information

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?

Testing instructions

CIAB connected

  1. Set up a CIAB environment with Jetpack connected
  2. Verify agentsManagerData.sectionName is "ciab" in the inline script
  3. Verify Agents Manager chat UI loads
  4. Verify Help Center button still appears in the Site Hub

CIAB disconnected

  1. Simulate Jetpack disconnected in CIAB (edit is_jetpack_disconnected to return true)
  2. Verify sectionName is "ciab-disconnected"

Non-CIAB wp-admin

  1. Verify behavior is unchanged — AM only loads when useUnifiedExperience is true

Disabling via filter

  1. Add add_filter( 'agents_manager_enabled_in_ciab', '__return_false' ) in a plugin
  2. Verify AM does not load in CIAB

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

No.

aaronfc and others added 2 commits February 24, 2026 22:23
Previously, get_variant() returned null for CIAB environments when the
site was connected (not disconnected), meaning no scripts were loaded.
Since there is no dedicated ciab variant, return 'wp-admin' instead so
the Agents Manager loads in connected CIAB environments.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- CIAB environments now always load Agents Manager, regardless of the
  useUnifiedExperience flag. This replaces the previous behavior where
  connected CIAB sites either didn't load AM or fell back to wp-admin variant.

- New 'ciab' variant for connected CIAB sites (uses dedicated JS entry point
  that mounts the chat UI without touching the classic admin bar or Site Hub).

- Move agents_manager_enqueue_in_block_editor filter to top of get_variant()
  so it applies universally (including CIAB) rather than being inside is_enabled().

- Skip admin bar manipulation for CIAB — the SPA hides the classic admin bar
  and uses its own Site Hub, so admin bar nodes are invisible.

- Help Center continues to work independently in CIAB — AM does not dequeue
  Help Center scripts outside of Gutenberg contexts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Feb 25, 2026

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 (WordPress.com Site Helper), and enable the add/agents-manager-ciab-variant-support branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/agents-manager-ciab-variant-support

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
Contributor

github-actions bot commented Feb 25, 2026

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!

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Feb 25, 2026
@jp-launch-control
Copy link

jp-launch-control bot commented Feb 25, 2026

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/jetpack-mu-wpcom/src/features/agents-manager/class-agents-manager.php 232/346 (67.05%) 0.10% 0 💚

Full summary · PHP report

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a dedicated Agents Manager (AM) script variant for CIAB / Next Admin environments so CIAB no longer falls back to the wp-admin build and can manage its own AI experience/UI.

Changes:

  • Introduces CIAB-specific variant selection: get_variant() returns ciab / ciab-disconnected for CIAB environments without is_enabled() gating.
  • Moves the block editor enqueue filter to the top of get_variant() so it applies consistently (including CIAB).
  • Skips classic WP admin bar manipulation in CIAB; updates/extends PHPUnit coverage for the new behavior.

Reviewed changes

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

File Description
projects/packages/jetpack-mu-wpcom/src/features/agents-manager/class-agents-manager.php Adds CIAB variant routing in get_variant() and avoids admin-bar mutations in CIAB.
projects/packages/jetpack-mu-wpcom/tests/php/features/agents-manager/Agents_Manager_Test.php Updates CIAB test expectations and adds coverage for the new connected CIAB variant.
projects/packages/jetpack-mu-wpcom/changelog/agents-manager-ciab-variant-support Documents the new CIAB variant support and behavior change.

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

@aaronfc aaronfc requested review from a team, peterfabian and timur987 February 25, 2026 10:36
@aaronfc aaronfc self-assigned this Feb 25, 2026
@aaronfc aaronfc marked this pull request as ready for review February 25, 2026 10:36
@aaronfc aaronfc added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Feb 25, 2026
aaronfc and others added 2 commits February 25, 2026 12:54
Instead of bypassing is_enabled() entirely for CIAB environments,
add a dedicated `agents_manager_enabled_in_ciab` filter that defaults
to true. This keeps CIAB loading by default while providing an escape
hatch for debugging or gradual rollout.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The `agents_manager_enqueue_in_block_editor` filter belongs to a
separate PR (#47248) and should not be mixed into the CIAB variant
changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 25, 2026 12:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

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

Comments suppressed due to low confidence (1)

projects/packages/jetpack-mu-wpcom/src/features/agents-manager/class-agents-manager.php:331

  • PR description mentions moving an agents_manager_enqueue_in_block_editor filter, but that filter name doesn’t appear in this repo (the code uses agents_manager_enabled_in_block_editor). Please align the PR description with the actual filter names/behavior, or add the intended filter if it’s missing.
		// Full unified experience: Agents Manager with support guides, Help Center takeover, etc.
		if ( apply_filters( 'agents_manager_use_unified_experience', false ) ) {
			return true;
		}

		// Block editor only: Agents Manager replaces Big Sky's native UI. Hooked by Big Sky.
		if ( $this->is_block_editor() && apply_filters( 'agents_manager_enabled_in_block_editor', false ) ) {
			return true;

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

- Use $wp_actions counter instead of do_action('next_admin_init') to
  avoid triggering enqueue_scripts() as a side effect in tests
- Fix docblocks: "when Jetpack is connected" → "when
  is_jetpack_disconnected() returns false" for accuracy
- Remove stale "bypasses is_enabled()" comments
- Add test for agents_manager_enabled_in_ciab filter escape hatch

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants