Skip to content

Comments

feat: 反重力(Antigravity)增强、Failover 重构及新模型支持#627

Merged
Wei-Shaw merged 25 commits intoWei-Shaw:mainfrom
touwaeriol:pr/bugfixes-and-enhancements
Feb 25, 2026
Merged

feat: 反重力(Antigravity)增强、Failover 重构及新模型支持#627
Wei-Shaw merged 25 commits intoWei-Shaw:mainfrom
touwaeriol:pr/bugfixes-and-enhancements

Conversation

@touwaeriol
Copy link
Contributor

@touwaeriol touwaeriol commented Feb 24, 2026

概要

反重力(Antigravity)新模型支持

  • 新增 claude-sonnet-4-6 模型映射、定价、请求转换器支持
  • 新增 gemini-3.1-pro-high/low/preview 模型映射
  • 修正 Gemini 3 默认映射为非强制 3.1(gemini-3-pro-high/low 不再默认映射到 3.1)
  • 数据库迁移:为所有反重力账号自动添加新模型映射(058、059)

反重力 Failover 重构

  • 将网关处理器中的 failover 循环逻辑抽取为独立的 FailoverState(failover_loop.go)
  • 包含反重力专属的线性递增延时策略和单账号 503 退避重试
  • 补充 732 行 failover 单元测试

反重力计费与限流修正

  • Forward/ForwardGemini 改为使用映射后的模型名计费(而非原始请求模型)
  • 429 限流写入最终反重力模型 key(如 claude-opus-4-6claude-opus-4-6-thinking

反重力 OAuth 与配置改进

  • OAuth client_secret 改为硬编码默认值(不再强制环境变量配置)
  • UserAgent 默认版本更新为 1.18.4
  • 新增 gateway.antigravity_extra_retries 配置项

反重力混合通道预检查

  • 新增 POST /accounts/check-mixed-channel 独立预检查接口
  • 前端创建/编辑账号改为先预检查再提交,优化用户体验

反重力 Warmup 拦截修复与扩展

  • 修复反重力账号 intercept_warmup_requests 配置无法保存的 bug(创建时漏写、编辑时缺少清除分支)
  • 将 Anthropic 独有的 warmup 请求拦截功能扩展到反重力平台
  • 新增 warmup 拦截单元测试

前端 UI 优化

  • 反重力模型限流指示器使用短缩写(如 COpus46CSon46)和倒计时显示
  • Gemini 平台启用 model_mapping UI
  • Gemini 3→3.1 映射快捷按钮
  • 批量编辑改进

其他

  • Gemini API Key 模型映射过滤统一走 IsModelSupported 检查
  • 新增 opus-4.6gemini-3.1-pro 回退定价

测试计划

  • golangci-lint run 通过(v2.7,0 issues)
  • govulncheck ./... 通过(无漏洞)
  • gosec 通过
  • pnpm audit 通过(例外项已验证)
  • go build ./... 通过
  • go vet ./... 通过

The usage progress bar only matched claude-sonnet-4-5 and
claude-opus-4-5-thinking. After upgrading to 4.6, the backend returns
claude-sonnet-4-6/claude-opus-4-6-thinking which didn't match,
causing the Claude usage bar to not display.

- Add claude-sonnet-4-6 and claude-opus-4-6-thinking to the match list
- Rename label from "C4.5" to "Claude" for future-proofing
Before this change, when a client disconnected mid-request, the error
message was "Upstream request failed after retries", which is misleading
and pollutes error logs. Now we check context.Err() to return a more
accurate "Client disconnected" message for both Claude and Gemini
forward paths.
Extract applyInterceptWarmup utility to unify all credential building
call sites:
- Fix upstream account creation missing intercept_warmup_requests write
- Fix apikey edit mode missing else-branch to clear the setting
- Add backend unit test for IsInterceptWarmupEnabled
- Add frontend unit test for credentialsBuilder
Add a dedicated CheckMixedChannel endpoint that allows the frontend
to pre-validate mixed channel risk before submitting create/update
requests. This improves UX by showing warnings earlier in the flow
instead of only after form submission.

Backend changes:
- Add CheckMixedChannelRequest struct and CheckMixedChannel handler
- Register POST /check-mixed-channel route
- Expose CheckMixedChannelRisk as public method on AdminService
- Simplify Create/Update 409 responses (remove details/require_confirmation)
- Add comprehensive handler tests and stub methods

Frontend changes:
- Add checkMixedChannelRisk API function and TypeScript types
- Refactor CreateAccountModal to precheck before step transition and submission
- Refactor EditAccountModal to precheck before update submission
- Replace pendingPayload pattern with action-based dialog flow
- Extract duplicated failover logic from gateway_handler.go (3 places)
  and gemini_v1beta_handler.go into shared failover_loop.go
- Introduce FailoverState with HandleFailoverError and HandleSelectionExhausted
- Move helper functions (needForceCacheBilling, sleepWithContext) into failover_loop.go
- Add comprehensive unit tests (32+ test cases)
- Delete redundant gateway_handler_single_account_retry_test.go
…rate limiting

- Use mapped model (billingModel) instead of original request model for billing
- Use resolveFinalAntigravityModelKey for 429 rate limit model key,
  ensuring rate limit records match the actual upstream model
- Add regression tests for both fixes
Remove the special case that bypassed model-supported checks for Gemini
API Key accounts, allowing model_mapping to filter requests properly.
Add tests for multiplatform model filtering behavior.
Add comprehensive tests for warmup request interception behavior
covering Antigravity accounts with various credential configurations.
Add Gemini model presets to BulkEditAccountModal for bulk model mapping.
Fix AccountStatusIndicator model rate limit grid layout using proper
grid container.
- Add claude-sonnet-4-6 to default Antigravity model mapping
- Add antigravity_extra_retries default value in config
- Add cache-dependency-path to CI setup-go for faster builds
- Simplify vitest config to avoid vite plugin compatibility issues
Add claude-sonnet-4-6 to identity injection modelInfoMap and
Antigravity model selector. Add gemini-3.1-pro-high/low to
Antigravity model list and Sonnet 4.6 preset mapping.
Update the default ANTIGRAVITY_USER_AGENT_VERSION from 1.84.2 to
1.18.4 to match the current Antigravity-Manager desktop client.
Add migration 058 to update existing Antigravity accounts with
claude-sonnet-4-6 in model_mapping. Add migration 059 to add
gemini-3.1-pro-high/low/preview mappings.
Add missing gemini-3.1-pro-preview -> gemini-3.1-pro-high mapping to
DefaultAntigravityModelMapping for consistency with migration 059.
Add a built-in default for ANTIGRAVITY_OAUTH_CLIENT_SECRET so the
service works out of the box without requiring environment variable
configuration. The env var can still override the default.
- Fix oauth_test.go and client_test.go to use defaultClientSecret
  variable instead of env var (init() already sets the default)
- Align migration 058 gemini-3-pro-high/low/preview mappings with
  constants.go (map to 3.1 versions)
The ClientSecret constant was left as an empty string after
getClientSecret() was refactored to use defaultClientSecret.
Remove the dead constant and update the test accordingly.
- Remove Gemini platform exclusion from model restriction UI in
  Create/Edit account modals (Gemini now supports model_mapping)
- Remove outdated Gemini model passthrough info cards
- Add model_mapping field to GeminiCredentials type
- Extend warmup request interception toggle to Antigravity platform
- Remove redundant try/catch in API key account creation
- Remove noisy gateway.request_completed debug log
- Reorganize Gemini model mapping sections in constants.go
- Change layout from fixed 3-column grid to vertical-first responsive
  columns (1 col for ≤4 items, 2 cols for ≤8, 3 cols for 9+)
- Add short aliases for all known model scope keys (e.g. COpus46, CSon46,
  G3PH, G3F) to reduce badge width
- Display countdown timer directly on each badge (supports h/m/s)
- Retain legacy scope aliases for backward compatibility
@touwaeriol touwaeriol changed the title feat: bugfixes, performance optimizations, and new features feat: 反重力(Antigravity)增强、Failover 重构及新模型支持 Feb 24, 2026
@Wei-Shaw Wei-Shaw merged commit c7e18bd into Wei-Shaw:main Feb 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants