Skip to content

Use dedicated endpoint for Agents Manager state#108636

Open
jom wants to merge 2 commits intotrunkfrom
update/use-dedicated-state-endpoint
Open

Use dedicated endpoint for Agents Manager state#108636
jom wants to merge 2 commits intotrunkfrom
update/use-dedicated-state-endpoint

Conversation

@jom
Copy link
Member

@jom jom commented Feb 10, 2026

Partially fixes AI-850

Paired with Automattic/jetpack#46937

Proposed Changes

  • Switches all Agents Manager API calls from the general /me/preferences endpoint to the new dedicated /wpcom/v2/agents-manager/state endpoint.
  • Removes the calypso_preferences wrapper from all request and response handling — the new endpoint uses a flat key/value format.
  • Updates four files:
    • resolvers.ts: GET now hits /agents-manager/state and reads flat keys directly instead of unwrapping calypso_preferences.
    • actions.ts: POST now hits /agents-manager/state with { state: { ... } } body instead of { calypso_preferences: { ... } }.
    • use-persisted-history.ts: Same POST pattern for persisting router history on navigation.
    • use-unified-ai-chat.ts: Now fetches from /agents-manager/state?key=unified_ai_chat (v2) instead of /me/preferences (v1.1).
  • The Jetpack apiFetch path (/agents-manager/open-state) is unchanged — the Jetpack proxy handles the translation.

Why are these changes being made?

  • The general /me/preferences endpoint exposes all calypso preferences, which is unnecessarily broad for Agents Manager.
  • A dedicated scoped endpoint follows the principle of least privilege — the Agents Manager only reads/writes the keys it needs.

Testing Instructions

  1. Test alongside Use Agents Manager state endpoint jetpack#46937
  2. Calypso (wordpress.com):
    • Open WordPress.com, open Agents Manager, verify it loads correctly (state persisted).
    • Open DevTools Network tab, confirm requests go to /agents-manager/state (not /me/preferences).
    • Close and reopen Agents Manager — state should persist (open/docked/position). Note: There is a preexisting issue where the request happens multiple times because the router and open/closed state changes happen seperately.
    • Navigate within Agents Manager, refresh — router history should restore.
  3. wp-admin (Atomic site):
    • In sandbox, run:
      • install-plugin.sh agents-manager update/use-dedicated-state-endpoint
      • install-plugin.sh help-center update/use-dedicated-state-endpoint
    • Sandbox widgets.wp.com
    • On dev WoA site, using Jetpack Beta plugin, switch to change/use-wpcom-agents-manager-endpoint.
    • Open wp-admin on an Atomic site with Agents Manager enabled.
    • Verify the panel opens/closes and state persists across page loads.
    • Confirm frontend requests still go to /agents-manager/open-state (the Jetpack proxy).
  4. wp-admin (WPCOM site):
    • In sandbox, run:
      • install-plugin.sh agents-manager update/use-dedicated-state-endpoint (if not already)
      • install-plugin.sh help-center update/use-dedicated-state-endpoint (if not already)
      • bin/jetpack-downloader test jetpack-mu-wpcom-plugin change/use-wpcom-agents-manager-endpoint (Use Agents Manager state endpoint jetpack#46937)
    • Sandbox widgets.wp.com
    • Open wp-admin on an WPCOM site with Agents Manager enabled.
    • Verify the panel opens/closes and state persists across page loads.
    • Confirm frontend requests still go to new WPCOM public-api /agents-manager/state endpoint.
  5. Unified AI chat flag:
    • For a user with unified_ai_chat enabled, verify the flag is correctly read on Calypso. Unified sidebar should load when the setting is enabled.

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you tested accessibility for your changes? Ensure the feature remains usable with various user agents (e.g., browsers), interfaces (e.g., keyboard navigation), and assistive technologies (e.g., screen readers) (PCYsg-S3g-p2).
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
    • For UI changes, have we tested the change in various languages (for example, ES, PT, FR, or DE)? The length of text and words vary significantly between languages.
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

@jom jom self-assigned this Feb 10, 2026
@jom jom marked this pull request as draft February 10, 2026 23:17
@matticbot
Copy link
Contributor

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • agents-manager
  • help-center
  • notifications
  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug update/use-dedicated-state-endpoint on your sandbox.

@jom jom requested a review from a team February 18, 2026 00:27
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Feb 18, 2026
@jom jom marked this pull request as ready for review February 18, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants