diff --git a/js/connector.jsx b/js/connector.jsx index 5f09b75..dfc81f1 100644 --- a/js/connector.jsx +++ b/js/connector.jsx @@ -509,7 +509,7 @@ function AnthropicMaxConnectorCard( { slug, label, description } ) { return ( } name={ label } description={ description } @@ -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 ); diff --git a/package.json b/package.json index 07a6892..6144884 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/plugin.php b/plugin.php index 26018d0..d7a0363 100644 --- a/plugin.php +++ b/plugin.php @@ -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 @@ -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. diff --git a/readme.txt b/readme.txt index d39336b..3cc8524 100644 --- a/readme.txt +++ b/readme.txt @@ -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 @@ -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. diff --git a/src/Provider/AnthropicMaxProvider.php b/src/Provider/AnthropicMaxProvider.php index 9541d5b..c550d41 100644 --- a/src/Provider/AnthropicMaxProvider.php +++ b/src/Provider/AnthropicMaxProvider.php @@ -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 * @@ -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,