Skip to content

feat(accounts): show proxy binding as a list badge with a quick editor - #606

Merged
james-6-23 merged 1 commit into
mainfrom
james-6-23/feature-account-proxy-badge
Sep 1, 2026
Merged

feat(accounts): show proxy binding as a list badge with a quick editor#606
james-6-23 merged 1 commit into
mainfrom
james-6-23/feature-account-proxy-badge

Conversation

@james-6-23

@james-6-23 james-6-23 commented Sep 1, 2026

Copy link
Copy Markdown
Owner

做了什么

账号列表新增「代理」列徽章,点击直达只改 proxy_url 一个字段的快速设置弹窗。Codex / Grok / Antigravity 三个视图全覆盖,表格与卡片两种布局都有。

后端零改动——PATCH /accounts/:id/scheduler {proxy_url} 本来就落库并热更新运行时,分页列表投影里也一直带着 proxy_url

为什么

真正的动机不是"看得见代理",而是有个致命状态此前在 UI 上完全不可见:

  • 账号钉死在一条已禁用 / 测试失败 / 已删除的托管代理上,代理池开启时 AccountHasUsableEgress 会直接把它排除出调度——页面上却只显示一个状态正常的号。
  • 同理,代理池开着但没有任何可用条目、又没配全局代理时,所有未自绑账号一起失去出口。

这两种情况现在都是红色徽章。

徽章状态

徽章 判定
🔵 HK-01 · 82ms 自绑,命中池内健康条目
🔴 代理不可用 自绑托管代理但已不在启用池中(池开启时无出口,不会被调度)
🟡 host:port 自绑,未纳入代理池(不受池启停影响)
🟣 组:主力 未自绑,继承分组代理
⚪️ 代理池 / 全局 / 直连 逐级回落
🔴 无可用出口 池开启但无可用条目,且无全局代理

几个刻意的取舍

  • 继承态只报来源、不报具体 URL。 组内/池内选路是 stickyProxyIndex(accountID, len) 粘性散列,前端复刻必然与调度器漂移;要精确到生效 URL 只能由后端在列表投影下发。
  • URL 只 trim、不做规范化,与 buildProxyPoolSet 恒等——末尾多个斜杠就是另一条代理,UI 不"帮忙修好"。
  • 分组查全量而非按渠道过滤:后端解析组代理不看渠道,过滤会把迁移前的跨渠道成员误报成"无组代理"。
  • 行组件收到的是一个 memo 出来的稳定上下文对象,不是散装数组,避免打掉表格行的 memo。
  • 悬浮提示里的代理 URL 打掉账密,与代理页"URL 默认打码 + 显隐开关"的口径一致——列表 hover 不是"我要看凭据"的动作。

验证

  • npm test — 181 passed(新增 16 条单测,覆盖全部 8 种状态,含 fail-closed、代理池关闭时不误报、trim-only 匹配、凭据打码)
  • npm run typecheck — 无错误
  • npm run build — 通过
  • 真接口打通:绑定 → 列表回显 → 清空解绑 → 回落直连,走的就是弹窗调的那个 endpoint
  • 本地 pg+redis 栈重建自查通过

本次不含

批量给选中账号设代理、保存自定义 URL 时「同时加入代理池」、后端下发精确 effective_proxy_url

Summary by CodeRabbit

  • New Features

    • Added proxy status badges to account lists and cards, showing each account’s effective connection and availability.
    • Added a quick editor to assign, test, update, or remove an account proxy directly from the account list.
    • Applied proxy visibility and quick editing across standard, Antigravity, and Grok account pages.
    • Added localized English and Chinese text, including status explanations and validation messages.
  • Tests

    • Added coverage for proxy resolution, fallback behavior, availability checks, formatting, and credential redaction.

The account lists never showed where an account's egress actually comes
from, which hid a state that silently drops accounts out of scheduling:
an account pinned to a managed proxy that is disabled, test-failed or
deleted has no usable egress while the proxy pool is on, and
AccountHasUsableEgress filters it away. The same holds when the pool is
on with no usable entry and no global proxy configured. Both now render
as a red badge instead of looking like a perfectly healthy account.

A new "proxy" column on the Codex, Grok and Antigravity lists resolves
the same priority as auth/store.go — account > group > pool > global >
direct — and clicking the badge opens a small editor that changes only
proxy_url, reusing the pool picker and the proxy test endpoint. Saving
an empty value unbinds and falls back to the inherited source. No
backend change is needed: PATCH /accounts/:id/scheduler already accepts
proxy_url and the list projection already carries it.

Inherited states name the source but never a concrete URL. Selection
within a group or the pool is a sticky hash over the account ID, so
reproducing it in the frontend would drift from the scheduler as soon as
either side changes; an exact effective URL has to come from the backend
projection instead. URLs are compared with trim only, matching
buildProxyPoolSet, so a trailing slash is a different proxy rather than
something the UI quietly repairs. Group lookup deliberately uses the
full group list rather than the channel-filtered one, because the
backend ignores channel when resolving group proxies and filtering would
misreport pre-migration cross-channel members as unbound.

Rows receive one memoized context object rather than loose arrays, so
the memoized table rows are not defeated. Tooltips mask proxy
credentials, in line with the proxy page keeping URLs behind an explicit
reveal toggle — hovering a list row is not a request to see secrets.
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 02b28af4-dc14-4a51-942d-9833d250c498

📥 Commits

Reviewing files that changed from the base of the PR and between 0c5efea and 397973c.

📒 Files selected for processing (9)
  • frontend/src/components/AccountProxyBadge.tsx
  • frontend/src/components/AccountProxyQuickEditor.tsx
  • frontend/src/lib/accountProxyBinding.test.mjs
  • frontend/src/lib/accountProxyBinding.ts
  • frontend/src/locales/en.json
  • frontend/src/locales/zh.json
  • frontend/src/pages/Accounts.tsx
  • frontend/src/pages/AntigravityAccounts.tsx
  • frontend/src/pages/GrokAccounts.tsx

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Adds effective proxy binding resolution, localized account proxy badges, quick proxy editing, and proxy columns to the Accounts, Antigravity, and Grok account views.

Changes

Account proxy management

Layer / File(s) Summary
Binding resolution and formatting
frontend/src/lib/accountProxyBinding.ts, frontend/src/lib/accountProxyBinding.test.mjs
Adds binding types, context construction, resolution precedence, availability checks, URL redaction, egress formatting, and comprehensive tests.
Shared proxy badge and quick editor
frontend/src/components/AccountProxyBadge.tsx, frontend/src/components/AccountProxyQuickEditor.tsx, frontend/src/locales/*.json
Adds localized binding badges and a modal for proxy testing, validation, saving, and unbinding.
Accounts page integration
frontend/src/pages/Accounts.tsx
Adds proxy settings state, binding context propagation, proxy columns, badge actions, and quick-editor wiring for table and card views.
Antigravity and Grok integration
frontend/src/pages/AntigravityAccounts.tsx, frontend/src/pages/GrokAccounts.tsx
Adds proxy settings loading, binding contexts, proxy columns, badge actions, and shared quick editors to both account pages.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to 39797

This PR adds proxy-status visibility and a quick editor through existing administrative APIs, with credential redaction and no backend contract changes. No actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: ifthink404

Sequence Diagram(s)

sequenceDiagram
  participant AccountPage
  participant AccountProxyBadge
  participant resolveAccountProxyBinding
  participant AccountProxyQuickEditor
  participant API
  AccountPage->>resolveAccountProxyBinding: Resolve effective proxy binding
  resolveAccountProxyBinding-->>AccountProxyBadge: Return binding state
  AccountProxyBadge-->>AccountPage: Open editor on click
  AccountPage->>AccountProxyQuickEditor: Provide account and proxy context
  AccountProxyQuickEditor->>API: Test or update proxy URL
  API-->>AccountPage: Return result and refresh accounts
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 6 files. (3 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary changes: displaying account proxy bindings as list badges and adding a quick editor.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 6 files. (3 skipped: 2 unsupported, 1 too large.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch james-6-23/feature-account-proxy-badge

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@james-6-23
james-6-23 merged commit 3053705 into main Sep 1, 2026
16 checks passed
@james-6-23
james-6-23 deleted the james-6-23/feature-account-proxy-badge branch September 1, 2026 07:50
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.

1 participant