Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions js/connector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ function AnthropicMaxConnectorCard( { slug, label, description } ) {

return (
<ConnectorItem
className="connector-item--anthropic-max"
className="connector-item--ultimate-ai-connector-anthropic-max"
icon={ <Logo /> }
name={ label }
description={ description }
Expand All @@ -521,10 +521,36 @@ function AnthropicMaxConnectorCard( { slug, label, description } ) {
}

// Register the connector card.
registerConnector( 'ai-provider-for-anthropic-max/connector', {
//
// SLUG matches the PHP provider id from AnthropicMaxProvider::createProviderMetadata()
// so the WP core Connectors page renders ONE card instead of two (the
// auto-discovered server entry + a separately-keyed JS entry).
const SLUG = 'ultimate-ai-connector-anthropic-max';
const CONFIG = {
label: __( 'Anthropic Max' ),
description: __(
'Use Claude with your Max subscription via OAuth. Supports account pool rotation for reliability.'
),
render: AnthropicMaxConnectorCard,
} );
};

// WP core's `routes/connectors-home/content` module runs
// `registerDefaultConnectors()` from inside an async dynamic import. By the
// time it executes, our top-level registerConnector() has already populated
// the store — and the store reducer spreads new config over existing
// entries, so the default's `args.render = ApiKeyConnector` would overwrite
// our custom render. The proper fix is in WordPress/gutenberg#77116; until
// that ships we re-assert our registration on five ticks (sync + microtask
// + setTimeout 0/50/250/1000ms) so our render always ends up last regardless
// of dynamic-import resolution order. Re-registering with the same render
// reference is idempotent so the redundant calls cost essentially nothing.
function registerOurs() {
registerConnector( SLUG, CONFIG );
}

registerOurs();
Promise.resolve().then( registerOurs );
setTimeout( registerOurs, 0 );
setTimeout( registerOurs, 50 );
setTimeout( registerOurs, 250 );
setTimeout( registerOurs, 1000 );
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ai-provider-for-anthropic-max",
"version": "1.0.0",
"version": "1.1.0",
"private": true,
"license": "GPL-2.0-or-later",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: Anthropic provider for the WordPress AI Client using Claude Max OAuth tokens with account pool rotation.
* Requires at least: 6.9
* Requires PHP: 7.4
* Version: 1.0.0
* Version: 1.1.0
* Author: Ultimate Multisite Community
* Author URI: https://ultimatemultisite.com
* License: GPL-2.0-or-later
Expand All @@ -21,7 +21,7 @@
return;
}

define( 'ANTHROPIC_MAX_AI_PROVIDER_VERSION', '1.0.0' );
define( 'ANTHROPIC_MAX_AI_PROVIDER_VERSION', '1.1.0' );

// ---------------------------------------------------------------------------
// PSR-4 autoloader for src/ classes.
Expand Down
8 changes: 7 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: superdav42
Tags: ai, anthropic, claude, oauth, max
Requires at least: 6.9
Tested up to: 7.0
Stable tag: 1.0.0
Stable tag: 1.1.0
Requires PHP: 7.4
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -65,6 +65,12 @@ OAuth tokens are stored in the WordPress options table. Only site administrators

== Changelog ==

= 1.1.0 =

* **BREAKING**: renamed the AI Client provider id from `anthropic-max` to `ultimate-ai-connector-anthropic-max` for consistency with the sister plugins (`ultimate-ai-connector-webllm`, `ultimate-ai-connector-compatible-endpoints`) and to claim the namespace properly. Code that called `AiClient::defaultRegistry()->getProvider('anthropic-max')` must update the id. Stored OAuth tokens, REST endpoints, and option keys are unchanged so existing setups continue to work.
* Improved: the JS-side `registerConnector()` slug now matches the PHP provider id, so the WP core Connectors page renders one card instead of two (a previously-hidden duplicate auto-registered card with the generic API-key form is now suppressed).
* Fix: re-assert our `registerConnector()` call across multiple ticks (microtask + 0/50/250/1000 ms) so the WP core `registerDefaultConnectors()` auto-register can't clobber the custom card with the generic API-key UI. Necessary because matching the slug exposes us to the same race the other Ultimate-Multisite connector plugins hit. The proper upstream fix is in https://github.com/WordPress/gutenberg/pull/77116 — once that ships in a Gutenberg release, this workaround can be removed.

= 1.0.0 =

* Initial release.
Expand Down
20 changes: 14 additions & 6 deletions src/Provider/AnthropicMaxProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/**
* Anthropic Max provider for the WordPress AI Client.
*
* Registers as a separate provider ('anthropic-max') so it can coexist
* with the standard API-key-based Anthropic provider.
* Registers as a separate provider ('ultimate-ai-connector-anthropic-max')
* so it can coexist with the standard API-key-based Anthropic provider.
*
* @since 1.0.0
*
Expand Down Expand Up @@ -77,17 +77,25 @@ protected static function createModel(
/**
* Creates the provider metadata.
*
* Uses 'anthropic-max' as the provider ID to avoid conflicts
* with the standard API-key-based Anthropic provider.
* Uses 'ultimate-ai-connector-anthropic-max' as the provider ID. The
* `ultimate-ai-connector-` namespace matches the sister plugins
* (`ultimate-ai-connector-webllm`, `ultimate-ai-connector-compatible-endpoints`)
* and avoids any future collision with another plugin author who might
* register a generic 'anthropic-max' provider id.
*
* @since 1.0.0
* @since 1.0.0 As 'anthropic-max'.
* @since 1.1.0 Renamed to 'ultimate-ai-connector-anthropic-max' for
* consistency with other Ultimate-Multisite connector plugins
* and to make the JS-side `registerConnector()` slug match
* this id (so the WP core Connectors page renders one card
* instead of two).
*
* @return ProviderMetadata
*/
protected static function createProviderMetadata(): ProviderMetadata
{
$args = [
'anthropic-max',
'ultimate-ai-connector-anthropic-max',
'Anthropic Max',
ProviderTypeEnum::cloud(),
null,
Expand Down