diff --git a/backend/internal/handler/dto/mappers.go b/backend/internal/handler/dto/mappers.go index 816550ab04..068771ac8c 100644 --- a/backend/internal/handler/dto/mappers.go +++ b/backend/internal/handler/dto/mappers.go @@ -250,7 +250,7 @@ func AccountFromServiceShallow(a *service.Account) *Account { } } - // 客户端亲和调度(适用于 Anthropic/Antigravity 平台) + // 客户端亲和调度(仅 Anthropic OAuth/SetupToken 账号) if a.IsClientAffinityEnabled() { enabled := true out.ClientAffinityEnabled = &enabled diff --git a/backend/internal/handler/dto/types.go b/backend/internal/handler/dto/types.go index e5310a21f5..a7e04cd2ea 100644 --- a/backend/internal/handler/dto/types.go +++ b/backend/internal/handler/dto/types.go @@ -188,7 +188,7 @@ type Account struct { CacheTTLOverrideEnabled *bool `json:"cache_ttl_override_enabled,omitempty"` CacheTTLOverrideTarget *string `json:"cache_ttl_override_target,omitempty"` - // 客户端亲和调度(仅 Anthropic/Antigravity 平台有效) + // 客户端亲和调度(仅 Anthropic OAuth/SetupToken 账号有效) // 启用后新会话会优先调度到客户端之前使用过的账号 ClientAffinityEnabled *bool `json:"client_affinity_enabled,omitempty"` diff --git a/backend/internal/service/account.go b/backend/internal/service/account.go index 390790a325..d36f55978c 100644 --- a/backend/internal/service/account.go +++ b/backend/internal/service/account.go @@ -1100,10 +1100,10 @@ func (a *Account) IsSessionIDMaskingEnabled() bool { } // IsClientAffinityEnabled 检查是否启用客户端亲和调度 -// 仅适用于 Anthropic 平台账号(包括 anthropic 和 antigravity 平台) +// 仅适用于 Anthropic OAuth/SetupToken 账号(Claude Code) // 启用后,新会话会优先调度到之前使用过的账号 func (a *Account) IsClientAffinityEnabled() bool { - if a.Platform != PlatformAnthropic && a.Platform != PlatformAntigravity { + if !a.IsAnthropicOAuthOrSetupToken() { return false } if a.Extra == nil { diff --git a/frontend/src/components/account/EditAccountModal.vue b/frontend/src/components/account/EditAccountModal.vue index 6026eb9570..0bc5f479cb 100644 --- a/frontend/src/components/account/EditAccountModal.vue +++ b/frontend/src/components/account/EditAccountModal.vue @@ -645,6 +645,36 @@ + +
+
+
+ +

+ {{ t('admin.accounts.quotaControl.clientAffinity.hint') }} +

+
+ +
+
+
@@ -1165,38 +1195,6 @@
- -
-
-
-
- -

- {{ t('admin.accounts.quotaControl.clientAffinity.hint') }} -

-
- -
-
-
-
@@ -1907,16 +1905,16 @@ function loadQuotaControlSettings(account: Account) { cacheTTLOverrideTarget.value = '5m' clientAffinityEnabled.value = false - // Client affinity applies to both Anthropic and Antigravity platforms - if (account.client_affinity_enabled === true) { - clientAffinityEnabled.value = true - } - // Only applies to Anthropic OAuth/SetupToken accounts if (account.platform !== 'anthropic' || (account.type !== 'oauth' && account.type !== 'setup-token')) { return } + // Client affinity (Anthropic OAuth/SetupToken only) + if (account.client_affinity_enabled === true) { + clientAffinityEnabled.value = true + } + // Load from extra field (via backend DTO fields) if (account.window_cost_limit != null && account.window_cost_limit > 0) { windowCostEnabled.value = true @@ -2235,12 +2233,6 @@ const handleSubmit = async () => { } else { delete newExtra.mixed_scheduling } - // Client affinity setting - if (clientAffinityEnabled.value) { - newExtra.client_affinity_enabled = true - } else { - delete newExtra.client_affinity_enabled - } updatePayload.extra = newExtra }