Agents Manager: Add dedicated CIAB variant support#47314
Agents Manager: Add dedicated CIAB variant support#47314
Conversation
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>
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCoverage changed in 1 file.
|
There was a problem hiding this comment.
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()returnsciab/ciab-disconnectedfor CIAB environments withoutis_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.
projects/packages/jetpack-mu-wpcom/tests/php/features/agents-manager/Agents_Manager_Test.php
Outdated
Show resolved
Hide resolved
projects/packages/jetpack-mu-wpcom/tests/php/features/agents-manager/Agents_Manager_Test.php
Outdated
Show resolved
Hide resolved
projects/packages/jetpack-mu-wpcom/tests/php/features/agents-manager/Agents_Manager_Test.php
Outdated
Show resolved
Hide resolved
projects/packages/jetpack-mu-wpcom/src/features/agents-manager/class-agents-manager.php
Outdated
Show resolved
Hide resolved
projects/packages/jetpack-mu-wpcom/tests/php/features/agents-manager/Agents_Manager_Test.php
Show resolved
Hide resolved
projects/packages/jetpack-mu-wpcom/tests/php/features/agents-manager/Agents_Manager_Test.php
Outdated
Show resolved
Hide resolved
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>
There was a problem hiding this comment.
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_editorfilter, but that filter name doesn’t appear in this repo (the code usesagents_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.
projects/packages/jetpack-mu-wpcom/tests/php/features/agents-manager/Agents_Manager_Test.php
Outdated
Show resolved
Hide resolved
projects/packages/jetpack-mu-wpcom/src/features/agents-manager/class-agents-manager.php
Show resolved
Hide resolved
- 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>
Proposed changes
Add a dedicated
ciabvariant for Agents Manager in CIAB (Commerce in a Box / Next Admin) environments. This replaces the previous approach of falling back to thewp-adminvariant.This is part of a 3-PR change set for WOOAI-253:
Automattic/jetpackciabvariant to Agents Manager PHPAutomattic/wp-calypsoagents-manager-ciab.jswebpack entry pointAutomattic/ciab-adminKey changes:
get_variant()returns'ciab'for connected CIAB sites and'ciab-disconnected'for disconnected sites. CIAB manages its own AI experience.is_enabled()like every other context, but with a dedicatedagents_manager_enabled_in_ciabfilter that defaults totrue. This provides a clean way to disable AM in CIAB for debugging or gradual rollout.Other information
Testing instructions
CIAB connected
agentsManagerData.sectionNameis"ciab"in the inline scriptCIAB disconnected
is_jetpack_disconnectedto return true)sectionNameis"ciab-disconnected"Non-CIAB wp-admin
useUnifiedExperienceis trueDisabling via filter
add_filter( 'agents_manager_enabled_in_ciab', '__return_false' )in a pluginDoes this pull request change what data or activity we track or use?
No.