Skip to content

Conversation

@aaronfc
Copy link
Contributor

@aaronfc aaronfc commented Dec 19, 2025

Fixes #46237 (comment)

Proposed changes:

  • Add transient caching (1 minute TTL) for the unified experience preference check to avoid remote API calls on every page load
  • Add proxy detection to limit the feature to proxied requests during internal testing phase
  • Support both Simple sites (via wpcom_is_proxied_request()) and WoA/Garden sites (via A8C_PROXIED_REQUEST constant/server variable)
  • Add connection state check before making API call to avoid unnecessary requests
  • Rename method from get_unified_experience_from_wpcom() to fetch_unified_experience_preference() for clarity

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)?

Jetpack product discussion

N/A - Internal tooling improvement

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

No changes to tracking.

Testing instructions:

  1. On a WoA or Garden site, access the site without the A8C proxy
  2. Verify that should_use_unified_experience() returns false (the unified experience is disabled)
  3. Access the site with the A8C proxy enabled
  4. Verify that the unified experience check now proceeds (will still return false if the user hasn't opted in, but the proxy check passes)
  5. Enable the unified experience preference for a user and verify it's cached:
    • First page load should make the API call
    • Subsequent page loads within 1 minute should use the cached value (no additional API calls)
  6. Run the unit tests: cd projects/packages/jetpack-mu-wpcom && composer test-php -- --filter=Agents_Manager_Test

My testing

I have made the following manual tests:

  • Simple site:
    • Disabled when non-proxied.
    • Enabled when opt-in enabled + proxied.
  • Atomic site:
    • Disabled when non-proxied (no requests).
    • Enabled when opt-in enabled + proxied.
    • Refresh did not make a new request until cache expired.

…ce check

- Add transient caching (1 minute) to avoid remote API calls on every page load
- Add proxy detection to limit feature to proxied requests during internal testing
- Support both Simple sites (wpcom_is_proxied_request) and WoA/Garden sites (A8C_PROXIED_REQUEST constant/server var)
- Add connection state check before making API call
- Rename method to fetch_unified_experience_preference() for clarity
- Add tests for proxy detection scenarios

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

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@aaronfc aaronfc marked this pull request as draft December 19, 2025 08:05
@aaronfc aaronfc self-assigned this Dec 19, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 19, 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 fix/unified-experience-uncached-request branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack-mu-wpcom-plugin fix/unified-experience-uncached-request

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 19, 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 the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Dec 19, 2025
@jp-launch-control
Copy link

jp-launch-control bot commented Dec 19, 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 87/96 (90.62%) 0.15% 3 ❤️‍🩹

Full summary · PHP report

@aaronfc aaronfc added the [Type] Bug When a feature is broken and / or not performing as intended label Dec 19, 2025
aaronfc and others added 2 commits December 19, 2025 09:26
…ference

- Add tests using pre_http_request filter to mock API responses
- Test successful API response returning enabled preference
- Test successful API response returning disabled preference
- Test transient caching prevents repeated API calls
- Test API failures are cached to avoid hammering the API
- Mock Jetpack connection by setting user_tokens option

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

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@aaronfc aaronfc marked this pull request as ready for review December 19, 2025 08:54
@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 Dec 19, 2025
@aaronfc aaronfc requested review from WPprodigy and jom December 19, 2025 08:54
Copy link
Member

@jom jom left a comment

Choose a reason for hiding this comment

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

Looks good and works well.

@aaronfc aaronfc added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Dec 19, 2025
@aaronfc aaronfc merged commit 2aa721d into trunk Dec 19, 2025
73 checks passed
@aaronfc aaronfc deleted the fix/unified-experience-uncached-request branch December 19, 2025 11:06
@github-actions github-actions bot removed [Status] In Progress [Status] Ready to Merge Go ahead, you can push that green button! labels Dec 19, 2025
@WPprodigy
Copy link
Contributor

WPprodigy commented Dec 19, 2025

Is refreshing every minute necessary? Could it be cached for longer, and/or can you think of any other ways to invalidate on the rare occasions where it needs to be?

@jom
Copy link
Member

jom commented Dec 19, 2025

@WPprodigy This will just be used to opt-in to internal testing. I think with the proxy check now we should be okay?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[mu wpcom Feature] Agents Manager [Package] Jetpack mu wpcom WordPress.com Features [Tests] Includes Tests [Type] Bug When a feature is broken and / or not performing as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants