fix(antigravity): fetch default mapping from API and sync Redis on rate limit

1. Frontend: replace hardcoded antigravityDefaultMappings with async
   fetch from GET /admin/accounts/antigravity/default-model-mapping,
   eliminating the duplicate data source that caused frontend/backend
   mapping inconsistency.

2. Backend: convert handleSmartRetry and antigravityRetryLoop from
   standalone functions to AntigravityGatewayService methods, enabling
   Redis cache sync (updateAccountModelRateLimitInCache) after both
   rate-limit write paths — long-delay branch and retry-exhausted branch.
This commit is contained in:
erio
2026-02-07 15:59:27 +08:00
parent b4f6c4f9d5
commit 2656320d04
4 changed files with 51 additions and 44 deletions

View File

@@ -387,6 +387,17 @@ export async function importData(payload: {
return data
}
/**
* Get Antigravity default model mapping from backend
* @returns Default model mapping (from -> to)
*/
export async function getAntigravityDefaultModelMapping(): Promise<Record<string, string>> {
const { data } = await apiClient.get<Record<string, string>>(
'/admin/accounts/antigravity/default-model-mapping'
)
return data
}
export const accountsAPI = {
list,
getById,
@@ -412,7 +423,8 @@ export const accountsAPI = {
bulkUpdate,
syncFromCrs,
exportData,
importData
importData,
getAntigravityDefaultModelMapping
}
export default accountsAPI