v1.1.1: defeat WP default-connector clobbering on Connectors page#24
v1.1.1: defeat WP default-connector clobbering on Connectors page#24superdav42 merged 1 commit intomainfrom
Conversation
WP core's routes/connectors-home/content.js runs registerDefaultConnectors() from inside an async dynamic import. By the time it executes, our top-level registerConnector() has already run, and the connectors store reducer spreads new config over the existing entry — so the default's `args.render = ApiKeyConnector` overwrites our custom card. The user sees the generic API-key UI instead of the endpoint URL / model picker form. The proper upstream fix is WordPress/gutenberg#77116. Until that lands and ships in a Gutenberg release, work around it by re-asserting our registration on five ticks (sync + microtask + setTimeout 0/50/250/1000ms) so we always end up last regardless of dynamic-import resolution order. Re-registration with the same render is idempotent so the redundant calls cost almost nothing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis patch release (1.1.0 → 1.1.1) fixes connector registration persistence by re-asserting Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/index.jsx (1)
425-430: Consider centralizing the retry delays.A small delay list keeps the workaround easier to tune now and easier to remove once the upstream Gutenberg fix ships.
Small cleanup
registerOurs(); Promise.resolve().then( registerOurs ); -setTimeout( registerOurs, 0 ); -setTimeout( registerOurs, 50 ); -setTimeout( registerOurs, 250 ); -setTimeout( registerOurs, 1000 ); +[ 0, 50, 250, 1000 ].forEach( ( delay ) => { + setTimeout( registerOurs, delay ); +} );🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/index.jsx` around lines 425 - 430, Centralize the retry delays used to call registerOurs by replacing the multiple repeated calls with a single delays array (e.g., const RETRY_DELAYS = [0, 50, 250, 1000]) plus the immediate Promise.resolve().then(registerOurs) call; iterate over RETRY_DELAYS and call setTimeout(registerOurs, delay) for each entry so future tuning or removal is done in one place and the retry behavior is clearer; ensure you still call registerOurs() once immediately and keep the Promise.resolve().then(registerOurs) scheduling intact if needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ultimate-ai-connector-compatible-endpoints.php`:
- Line 24: Update the script registration to use the version constant instead of
the hard-coded '1.0.0': replace the literal version passed to
wp_register_script_module for the build/connector.js registration in
inc/admin.php with ULTIMATE_AI_CONNECTOR_COMPATIBLE_ENDPOINTS_VERSION so caches
are invalidated when the constant changes; ensure the call that registers the
connector script (wp_register_script_module for 'build/connector.js' or the
corresponding handle name) uses that constant for its $ver argument.
---
Nitpick comments:
In `@src/index.jsx`:
- Around line 425-430: Centralize the retry delays used to call registerOurs by
replacing the multiple repeated calls with a single delays array (e.g., const
RETRY_DELAYS = [0, 50, 250, 1000]) plus the immediate
Promise.resolve().then(registerOurs) call; iterate over RETRY_DELAYS and call
setTimeout(registerOurs, delay) for each entry so future tuning or removal is
done in one place and the retry behavior is clearer; ensure you still call
registerOurs() once immediately and keep the
Promise.resolve().then(registerOurs) scheduling intact if needed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4457d9cb-ffa8-4496-9ba9-08f253abd13a
📒 Files selected for processing (4)
package.jsonreadme.txtsrc/index.jsxultimate-ai-connector-compatible-endpoints.php
| } | ||
|
|
||
| define( 'ULTIMATE_AI_CONNECTOR_COMPATIBLE_ENDPOINTS_VERSION', '1.1.0' ); | ||
| define( 'ULTIMATE_AI_CONNECTOR_COMPATIBLE_ENDPOINTS_VERSION', '1.1.1' ); |
There was a problem hiding this comment.
Use this version constant to invalidate the connector bundle.
inc/admin.php:14-32 still passes '1.0.0' to wp_register_script_module() for build/connector.js. That lets upgraded sites keep a cached pre-1.1.1 bundle, so the new re-registration logic may never run and the generic API-key card can still appear until caches expire.
Suggested change in inc/admin.php
- '1.0.0'
+ ULTIMATE_AI_CONNECTOR_COMPATIBLE_ENDPOINTS_VERSION🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@ultimate-ai-connector-compatible-endpoints.php` at line 24, Update the script
registration to use the version constant instead of the hard-coded '1.0.0':
replace the literal version passed to wp_register_script_module for the
build/connector.js registration in inc/admin.php with
ULTIMATE_AI_CONNECTOR_COMPATIBLE_ENDPOINTS_VERSION so caches are invalidated
when the constant changes; ensure the call that registers the connector script
(wp_register_script_module for 'build/connector.js' or the corresponding handle
name) uses that constant for its $ver argument.
What
WhyWP core's [ action.slug ]: {
...state.connectors[ action.slug ], // existing
slug: action.slug,
...action.config, // new (wins per key)
}So the default's FixRe-assert our registration on five ticks: sync, microtask, and Test plan
ReleaseBumps version to 1.1.1 in:
Merged via PR #24 to main.
|
What
registerConnector()is now re-asserted on multiple ticks so the WP coreregisterDefaultConnectors()auto-register can't clobber our custom card with the generic API-key form.Why
WP core's
routes/connectors-home/contentmodule runsregisterDefaultConnectors()from inside an async dynamic import. By the time it executes, our top-levelregisterConnector()has already populated the connectors store. The store reducer in@wordpress/connectorsspreads new config over the existing entry:So the default's
args.render = ApiKeyConnectoroverwrites our custom render. The user sees the generic API key form instead of the endpoint URL / model picker we built.This is a real, observed regression — see the screenshot in #(linked issue) on the sister WebLLM connector plugin where exactly the same thing was happening.
Fix
Re-assert our registration on five ticks: sync, microtask, and
setTimeoutat 0/50/250/1000 ms. Whichever order the browser settles dynamic-import resolution in, we always end up last. Re-registering with the same render reference is idempotent so the redundant calls cost essentially nothing.The proper upstream fix is WordPress/gutenberg#77116 (just opened, makes
registerDefaultConnectors()skip slugs that already have a custom render). Once that ships in a Gutenberg release, this workaround can be removed.Test plan
@wordpress/aiplugin loaded.Release
Bumps version to 1.1.1 in:
ultimate-ai-connector-compatible-endpoints.phpplugin header +ULTIMATE_AI_CONNECTOR_COMPATIBLE_ENDPOINTS_VERSIONconstantpackage.jsonreadme.txtStable tag+ new changelog entry🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes