Skip to content

Conversation

@aaronfc
Copy link
Contributor

@aaronfc aaronfc commented Dec 9, 2025

Related to DOTCOM-15279

Proposed changes:

  • Hooking into new filter to centralize the logic for Unified AI Experience behind Agents_Manager feature (in jetpack-mu-wpcom).
  • The corresponding user attribute is being introduced in 197669-ghe-Automattic/wpcom
  • This is safe to be released as it is

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

No

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?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Testing instructions:

This is a small (but independent) part in a bigger set of changes. To test the full feature see Automattic/wp-calypso#107601.

Release

This can be independently released. Since nothing is yet consuming the agents_manager_use_unified_experience hook until Automattic/wp-calypso#107601 and https://github.com/Automattic/big-sky-plugin/pull/5210 are deployed.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 9, 2025

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-unified-experience-toggle-logic branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/agents-manager-unified-experience-toggle-logic

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 Dec 9, 2025

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 a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ 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 [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Dec 9, 2025
@jp-launch-control
Copy link

jp-launch-control bot commented Dec 9, 2025

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/jetpack-mu-wpcom/src/features/agents-manager/class-agents-manager.php 57/63 (90.48%) -0.63% 2 ❤️‍🩹

Full summary · PHP report

@aaronfc aaronfc self-assigned this Dec 9, 2025
@aaronfc aaronfc added Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR and removed Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR labels Dec 9, 2025
@aaronfc aaronfc force-pushed the add/agents-manager-unified-experience-toggle-logic branch from 879e976 to 73fc957 Compare December 9, 2025 15:48
We are moving the enable/disable logic into the agent-manager backend
here in jetpack-mu-wpcom.
We are using user attribute `a11n_unified_chat` that will be handled on
wpcom's via wp-admin.
@aaronfc aaronfc force-pushed the add/agents-manager-unified-experience-toggle-logic branch from 73fc957 to 9dd7771 Compare December 10, 2025 08:33
Exposes the `agents_manager_use_unified_experience` filter value
via the `agentsManagerData` global, allowing Help Center to check
the unified experience flag on wp-admin environments (Atomic, Garden,
Simple sites) where the `/me` API is not accessible.
@aaronfc aaronfc requested a review from jom December 10, 2025 11:34
@aaronfc aaronfc marked this pull request as ready for review December 10, 2025 11:34
On Atomic sites, the `get_user_attribute` function is not available.
This adds a fallback that fetches user attributes via the Jetpack
Connection API (`/jetpack-user-attributes` endpoint).

Changes:
- Add `get_user_attribute()` method that handles both Simple and Atomic
- Add `get_user_attribute_via_api()` for Atomic sites (pattern from launchpad)
- Update `has_unified_chat_opt_in_enabled()` to use the new method
- Add test for Atomic site scenario
On Atomic sites, delegate the unified experience decision to wpcom
via /me?fields=unified_ai_chat endpoint instead of trying to fetch
raw user attributes via /jetpack-user-attributes (which was failing).

This approach:
- Uses the same data source as Calypso
- Avoids duplicating rollout logic
- Follows pattern from help-center persisted-open-state
@aaronfc
Copy link
Contributor Author

aaronfc commented Dec 10, 2025

Moving to draft again. This doesn't seem to be enough for Atomic.

We can't access get_user_attributes from Atomic, and using /me (like calypso) doesn't seem supported either with the Jetpack token via \Automattic\Jetpack\Connection\Client::wpcom_json_api_request_as_user.

Alternatives crossing my mind at the moment:

  • Not using /me and use some other (or a new endpoint). We might want to change calypso then to consume this new endpoint (if possible).
  • Review if, somehow, we can get a valid token to use via Jetpack Connection.
  • Research if there is any other alternative to retrieve user attributes from Atomic.

  - Read unified_ai_chat from calypso_preferences instead of a11n_unified_chat
  - On Atomic sites, call /me/preferences via wpcom/v2 (works with Jetpack tokens)
@aaronfc
Copy link
Contributor Author

aaronfc commented Dec 10, 2025

Final approach: Using /me/preferences (which means using a calypso_preferences attribute instead of a new one).

Changes in wpcom have already been applied in 197669-ghe-Automattic/wpcom

Simple sites use local check, anything else uses jetpack connection to
query wpcom.
Clean up error_log statements that were added for debugging the unified
experience toggle issue.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
jom
jom previously approved these changes Dec 12, 2025
- Add Constants import and clear constants in tearDown
- Set IS_WPCOM constant in tests that need Simple site context
- Fix get_user_attribute stub to return proper calypso_preferences array
- Add test for useUnifiedExperience in inline script output

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
The get_unified_experience_from_wpcom() method makes HTTP calls via
Jetpack Connection Client which cannot be easily mocked in unit tests.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@aaronfc aaronfc added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Status] In Progress labels Dec 12, 2025
@aaronfc aaronfc merged commit 0198b5b into trunk Dec 12, 2025
74 of 76 checks passed
@aaronfc aaronfc deleted the add/agents-manager-unified-experience-toggle-logic branch December 12, 2025 13:29
@github-actions github-actions bot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Dec 12, 2025
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