v1.1.0: rename provider id to ultimate-ai-connector-anthropic-max + fix render clobber#6
Conversation
WP core's routes/connectors-home/content.js runs registerDefaultConnectors() from inside an async dynamic import, and the connectors store reducer spreads new config over existing entries — so the default's `args.render = ApiKeyConnector` can overwrite a plugin's custom render. This plugin currently dodges the bug because its JS slug (ai-provider-for-anthropic-max/connector) doesn't collide with the PHP-side provider id (anthropic-max). That's fragile — a future upstream change to slug normalization or sanitization could break it without warning. Re-assert the registration on five ticks (sync + microtask + setTimeout 0/50/250/1000ms) so we always end up last regardless of dynamic-import resolution order. Idempotent and cheap. The proper upstream fix is WordPress/gutenberg#77116. Once that ships in a Gutenberg release, this defense can be removed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ix render clobber
This commit makes two coordinated changes that have to ship together:
1. RENAME the AI Client provider id from 'anthropic-max' to
'ultimate-ai-connector-anthropic-max', and the JS registerConnector()
slug from 'ai-provider-for-anthropic-max/connector' to the same
'ultimate-ai-connector-anthropic-max'. This:
- Matches the naming convention used by the sister plugins
(ultimate-ai-connector-webllm, ultimate-ai-connector-compatible-endpoints).
- Claims the 'ultimate-ai-connector-' namespace properly so a future
third-party 'anthropic-max' plugin can't collide with this one.
- Causes the WP Connectors page to render ONE card instead of two —
previously a hidden duplicate auto-registered ApiKeyConnector card
existed alongside the custom-rendered card because the slugs differed.
This is a BREAKING change for any caller that hardcoded the old
provider id (e.g. AiClient::defaultRegistry()->getProvider('anthropic-max')).
Stored OAuth tokens, REST endpoint URLs, option keys, transient prefixes,
plugin folder name, text domain, and css class are unchanged.
2. WORKAROUND for WP core's registerDefaultConnectors() clobbering custom
renders. The rename in (1) makes the slugs match, which exposes this
plugin to the same race the other Ultimate-Multisite connector plugins
hit: WP core's routes/connectors-home/content module runs
registerDefaultConnectors() inside an async dynamic import, after our
top-level registerConnector() has already populated the store, and the
reducer's spread overwrites our custom render with the generic
ApiKeyConnector. Re-assert the registration on five ticks (sync +
microtask + setTimeout 0/50/250/1000ms) so we always end up last.
The proper upstream fix is in WordPress/gutenberg#77116. Once that ships
in a Gutenberg release, the 5-tick workaround can be removed; the rename
is permanent.
CSS class on the rendered card also updated from
`connector-item--anthropic-max` to `connector-item--ultimate-ai-connector-anthropic-max`
to match the new slug and the convention used by the sister plugins.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis release renames the Anthropic Max provider identifier from 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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
readme.txt (2)
39-39:⚠️ Potential issue | 🟡 MinorDocumentation references outdated provider id.
Line 39 still states the plugin registers as
anthropic-max, but the changelog at line 70 documents the rename toultimate-ai-connector-anthropic-max. This inconsistency will confuse users.📝 Proposed fix
-The plugin registers as a separate provider (`anthropic-max`) and coexists with the standard API-key-based Anthropic provider. +The plugin registers as a separate provider (`ultimate-ai-connector-anthropic-max`) and coexists with the standard API-key-based Anthropic provider.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@readme.txt` at line 39, The README still references the old provider id 'anthropic-max' while the changelog and code use 'ultimate-ai-connector-anthropic-max'; update the README text on line mentioning the provider id to use 'ultimate-ai-connector-anthropic-max' so the documentation matches the renamed provider, and search for any other occurrences of 'anthropic-max' in this file (or nearby docs) to replace them with 'ultimate-ai-connector-anthropic-max' to keep IDs consistent with the changelog and code.
56-56:⚠️ Potential issue | 🟡 MinorFAQ section also references the old provider id.
Same inconsistency here - should be updated to reflect the new
ultimate-ai-connector-anthropic-maxid.📝 Proposed fix
-Yes. This plugin registers as "Anthropic Max" (`anthropic-max`), separate from the standard "Anthropic" (`anthropic`) provider. Both can be active simultaneously. +Yes. This plugin registers as "Anthropic Max" (`ultimate-ai-connector-anthropic-max`), separate from the standard "Anthropic" (`anthropic`) provider. Both can be active simultaneously.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@readme.txt` at line 56, Update the FAQ entry that references the old provider id to use the new provider id string: replace any occurrences of "anthropic-max" or the standard "anthropic" where the FAQ is meant to refer to the new connector with "ultimate-ai-connector-anthropic-max" and ensure the display name "Anthropic Max" remains consistent; look for the FAQ text that mentions the provider id and change the identifier to ultimate-ai-connector-anthropic-max so the README matches the registered provider name.
🧹 Nitpick comments (1)
js/connector.jsx (1)
528-535: Consider freezing the CONFIG object to prevent accidental mutation.Since
CONFIGis shared across multiple deferred calls, freezing it ensures the same reference is always passed.🔧 Optional: freeze the config object
const CONFIG = { label: __( 'Anthropic Max' ), description: __( 'Use Claude with your Max subscription via OAuth. Supports account pool rotation for reliability.' ), render: AnthropicMaxConnectorCard, -}; +}; +Object.freeze( CONFIG );🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@js/connector.jsx` around lines 528 - 535, CONFIG is mutated-prone as a shared object; make it immutable by freezing it so deferred callers always receive the same unmodifiable reference. Replace the current CONFIG declaration with a frozen object (e.g., use Object.freeze on the CONFIG object or assign CONFIG = Object.freeze({...})) while keeping SLUG and render reference to AnthropicMaxConnectorCard unchanged; a shallow freeze is sufficient for label/description/render but if nested mutability is possible, apply a deep freeze utility before exporting/using CONFIG.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@readme.txt`:
- Line 39: The README still references the old provider id 'anthropic-max' while
the changelog and code use 'ultimate-ai-connector-anthropic-max'; update the
README text on line mentioning the provider id to use
'ultimate-ai-connector-anthropic-max' so the documentation matches the renamed
provider, and search for any other occurrences of 'anthropic-max' in this file
(or nearby docs) to replace them with 'ultimate-ai-connector-anthropic-max' to
keep IDs consistent with the changelog and code.
- Line 56: Update the FAQ entry that references the old provider id to use the
new provider id string: replace any occurrences of "anthropic-max" or the
standard "anthropic" where the FAQ is meant to refer to the new connector with
"ultimate-ai-connector-anthropic-max" and ensure the display name "Anthropic
Max" remains consistent; look for the FAQ text that mentions the provider id and
change the identifier to ultimate-ai-connector-anthropic-max so the README
matches the registered provider name.
---
Nitpick comments:
In `@js/connector.jsx`:
- Around line 528-535: CONFIG is mutated-prone as a shared object; make it
immutable by freezing it so deferred callers always receive the same
unmodifiable reference. Replace the current CONFIG declaration with a frozen
object (e.g., use Object.freeze on the CONFIG object or assign CONFIG =
Object.freeze({...})) while keeping SLUG and render reference to
AnthropicMaxConnectorCard unchanged; a shallow freeze is sufficient for
label/description/render but if nested mutability is possible, apply a deep
freeze utility before exporting/using CONFIG.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d0c1132b-6692-461c-9ca4-dd4c97b41cff
📒 Files selected for processing (5)
js/connector.jsxpackage.jsonplugin.phpreadme.txtsrc/Provider/AnthropicMaxProvider.php
SummaryTwo coordinated changes that have to ship together to fix the Connectors page properly. 1. Rename the provider id (BREAKING)
2. 5-tick
|
Summary
Two coordinated changes that have to ship together to fix the Connectors page properly.
1. Rename the provider id (BREAKING)
createProviderMetadata()first arg'anthropic-max''ultimate-ai-connector-anthropic-max'registerConnector()slug'ai-provider-for-anthropic-max/connector''ultimate-ai-connector-anthropic-max'ConnectorItemclassNameconnector-item--anthropic-maxconnector-item--ultimate-ai-connector-anthropic-maxWhy:
ultimate-ai-connector-webllmandultimate-ai-connector-compatible-endpointsthat both follow theultimate-ai-connector-{name}naming.anthropic-maxis generic enough that another plugin author could easily collide with it.ultimate-ai-connector-anthropic-maxreserves the name properly.registerDefaultConnectors()was creating a separate auto-registered entry with the generic API-key form alongside our custom card. The duplicate was just visually hidden in most layouts. Matching the slugs collapses them into a single store entry.This is a breaking change for any caller that hardcoded the old id, e.g.
AiClient::defaultRegistry()->getProvider('anthropic-max'). Things that are deliberately not changed to keep upgrades safe:anthropic_max_oauth_pooloption)anthropic_max_pkce_)anthropic-max-pool/v1)2. 5-tick
registerConnector()re-assertion (workaround)Once the slugs match, this plugin is exposed to the same race the other Ultimate-Multisite connector plugins hit:
routes/connectors-home/contentmodule runsregisterDefaultConnectors()from inside an async dynamic import.registerConnector()has already populated the store.@wordpress/connectorsspreads new config over existing entries, so the default'sargs.render = ApiKeyConnectoroverwrites our custom render and the user sees the generic API-key form.Re-assert the registration on five ticks (sync + microtask + setTimeout at 0/50/250/1000 ms) so we always end up last regardless of dynamic-import resolution order. Idempotent so the redundant calls cost essentially nothing.
The proper upstream fix is WordPress/gutenberg#77116 (already opened, makes
registerDefaultConnectors()skip slugs that already have a custom render). Once that ships in a Gutenberg release, the workaround can be removed; the rename in (1) is permanent.Test plan
Release
Bumps version 1.0.0 → 1.1.0 in:
plugin.phpheader +ANTHROPIC_MAX_AI_PROVIDER_VERSIONconstantpackage.jsonreadme.txtStable tag + new changelog entry (marked with BREAKING)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Chores