From fb5f471fe1306e4b6d7a8b2959a317b9dc117e38 Mon Sep 17 00:00:00 2001 From: erio Date: Fri, 6 Mar 2026 17:44:27 +0800 Subject: [PATCH] feat: extend client affinity to all Anthropic account types - Backend: expand IsClientAffinityEnabled() to support all Anthropic accounts (OAuth/SetupToken/APIKey), not just OAuth/SetupToken - Frontend: show client affinity toggle for all Anthropic accounts - Frontend: fix save logic to properly chain extra field updates - Antigravity accounts explicitly excluded from client affinity Co-Authored-By: Claude Opus 4.6 --- backend/internal/service/account.go | 4 +-- .../components/account/EditAccountModal.vue | 26 ++++++++++++++----- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/backend/internal/service/account.go b/backend/internal/service/account.go index effcfeaa03..07459d8246 100644 --- a/backend/internal/service/account.go +++ b/backend/internal/service/account.go @@ -1100,10 +1100,10 @@ func (a *Account) IsSessionIDMaskingEnabled() bool { } // IsClientAffinityEnabled 检查是否启用客户端亲和调度 -// 适用于 Anthropic 和 Antigravity 账号 +// 仅适用于 Anthropic 账号(OAuth/SetupToken/APIKey) // 启用后,新会话会优先调度到之前使用过的账号 func (a *Account) IsClientAffinityEnabled() bool { - if a.Platform != PlatformAnthropic && a.Platform != PlatformAntigravity { + if a.Platform != PlatformAnthropic { return false } if a.Extra == nil { diff --git a/frontend/src/components/account/EditAccountModal.vue b/frontend/src/components/account/EditAccountModal.vue index 21144f3434..aca86a7790 100644 --- a/frontend/src/components/account/EditAccountModal.vue +++ b/frontend/src/components/account/EditAccountModal.vue @@ -645,9 +645,9 @@ - +
@@ -1905,13 +1905,18 @@ function loadQuotaControlSettings(account: Account) { cacheTTLOverrideTarget.value = '5m' clientAffinityEnabled.value = false - // Client affinity (Anthropic & Antigravity accounts) + // Remaining quota control settings only apply to Anthropic accounts + if (account.platform !== 'anthropic') { + return + } + + // Client affinity (all Anthropic accounts) if (account.client_affinity_enabled === true) { clientAffinityEnabled.value = true } - // Remaining quota control settings only apply to Anthropic OAuth/SetupToken accounts - if (account.platform !== 'anthropic' || (account.type !== 'oauth' && account.type !== 'setup-token')) { + // Window cost / session limit only apply to Anthropic OAuth/SetupToken accounts + if (account.type !== 'oauth' && account.type !== 'setup-token') { return } @@ -2224,7 +2229,7 @@ const handleSubmit = async () => { updatePayload.credentials = newCredentials } - // For antigravity accounts, handle mixed_scheduling and client_affinity in extra + // For antigravity accounts, handle mixed_scheduling in extra if (props.account.platform === 'antigravity') { const currentExtra = (props.account.extra as Record) || {} const newExtra: Record = { ...currentExtra } @@ -2233,6 +2238,13 @@ const handleSubmit = async () => { } else { delete newExtra.mixed_scheduling } + updatePayload.extra = newExtra + } + + // For all Anthropic accounts, handle client_affinity in extra + if (props.account.platform === 'anthropic') { + const currentExtra = (updatePayload.extra as Record) || (props.account.extra as Record) || {} + const newExtra: Record = { ...currentExtra } if (clientAffinityEnabled.value) { newExtra.client_affinity_enabled = true } else { @@ -2243,7 +2255,7 @@ const handleSubmit = async () => { // For Anthropic OAuth/SetupToken accounts, handle quota control settings in extra if (props.account.platform === 'anthropic' && (props.account.type === 'oauth' || props.account.type === 'setup-token')) { - const currentExtra = (props.account.extra as Record) || {} + const currentExtra = (updatePayload.extra as Record) || (props.account.extra as Record) || {} const newExtra: Record = { ...currentExtra } // Window cost limit settings