close
Skip to content

Fix: Redundant API requests for providers on settings page when multiple features share the same capability#542

Merged
dkotter merged 1 commit into
WordPress:developfrom
hbhalodia:fix/issue-541
May 13, 2026
Merged

Fix: Redundant API requests for providers on settings page when multiple features share the same capability#542
dkotter merged 1 commit into
WordPress:developfrom
hbhalodia:fix/issue-541

Conversation

@hbhalodia
Copy link
Copy Markdown
Contributor

@hbhalodia hbhalodia commented May 13, 2026

What?

Closes #541

Why?

How?

  • Use the approach to remove providers fetch logic to a custom hook and implement a module level cache for requests results based on capability.

Use of AI Tools

AI assistance: Yes
Tool(s): GitHub Copilot, Claude
Model(s): Opus 4.6
Used for: Providing suggestion on improvement based on issue. Reviwed the code generated manually and then raised the PR.

Testing Instructions

  1. Open Page - options-general.php?page=ai-wp-admin, Enable model selection.
  2. Enable all features.
  3. Check the network request, it should only be 3 for now, text_generation, vision, image_generation, instead of individual request for each features.

Screenshots or screencast

Screen.Recording.2026-05-13.at.3.57.15.PM.mov

Changelog Entry

Changed - Deduplicate provider API requests on the settings page by caching fetches per capability, reducing redundant network calls.

Open WordPress Playground Preview

@github-actions
Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.72%. Comparing base (27ac41f) to head (b7972a2).

Additional details and impacted files
@@            Coverage Diff             @@
##             develop     #542   +/-   ##
==========================================
  Coverage      70.72%   70.72%           
  Complexity      1144     1144           
==========================================
  Files             67       67           
  Lines           5510     5510           
==========================================
  Hits            3897     3897           
  Misses          1613     1613           
Flag Coverage Δ
unit 70.72% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dkotter dkotter added this to the 1.0.0 milestone May 13, 2026
@dkotter dkotter merged commit ab1eb6c into WordPress:develop May 13, 2026
18 checks passed
simison pushed a commit to simison/ai that referenced this pull request May 25, 2026
…ultiple requests (WordPress#542)

Fixed - Deduplicate provider API requests on the settings page when developer mode is toggled on.

Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redundant API requests for providers on settings page when multiple features share the same capability

2 participants