Skip to content

feat(web): 基于 /backend-api/subscriptions 的轻量 Codex Subscription - #745

Open
HuiCheng wants to merge 10 commits into
seakee:devfrom
HuiCheng:cursor/feat-codex-subscription-6719
Open

HuiCheng wants to merge 10 commits into
seakee:devfrom
HuiCheng:cursor/feat-codex-subscription-6719

Conversation

@HuiCheng

@HuiCheng HuiCheng commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Screenshots (Subscription UI polish)

Before After
before after

Quota unchanged: quota


Summary

#743 维护者方向,增加轻量 Codex Subscription:慢刷新、按 chatgpt_account_id 共享、非 Free 详情 Tab;套餐到期时间优先级为 subscriptions > wham > JWT。配额(wham/usage)刷新链路不变。

Community and maintenance PRs must target dev. Repository automation
retargets other pull requests to dev; this can change the diff and make
existing review comments outdated. main accepts only a promotion PR whose
source is this repository's dev branch.

Scope

  • Frontend panel
  • Manager Server
  • CPA panel mode
  • Full Docker mode
  • Native packages / release
  • Docs / Wiki
  • CI / build / tooling

Changes

  • 新增 codexSubscription 模块:解析 /backend-api/subscriptions、30 分钟 TTL store、同账号去重、soft-fail。
  • resolveCodexSubscriptionUntilMs / 列表「剩余天数」统一走 subscriptions > wham > JWT 的同一 subscriptionUntilMs(与 fix(accounts): sort Codex rows by plan remaining time #742 sort=remaining 兼容)。
  • 非 Free Codex 详情增加 Subscription Tab(plan_type / active_start / active_until / billing_period / will_renew)。
  • 列表套餐 / 剩余天数点击可打开该 Tab。
  • 不改 utils/quota/*AccountQuotaTab 的配额刷新语义。

User Impact

付费 Codex 账号可在详情看到订阅元数据;列表剩余天数在 subscriptions 可用时更贴近真实 active_until。Free / 其他 Provider 无此 Tab。依赖 CPA management api-call 能对 ChatGPT 返回 JSON(Chrome TLS,见 CLIProxyAPI 相关修复)。

Compatibility / Runtime Notes

  • CPA panel mode: 前端能力;经现有 management api-call 拉 subscriptions。
  • Manager Server mode: 同上,无 Manager Server schema 变更。
  • Full Docker / native packages: 面板重建 / 镜像更新后生效。

Data / Security Notes

经已有 management api-call 使用账号 token 请求 ChatGPT;不新增密钥存储。soft-fail 不清理配额状态。

Risk / Rollback

Risk level: Medium

Rollback notes: 回退本 PR 提交即可;配额链路未改。若 CPA 侧 TLS 未就绪,subscriptions 会 soft-fail 并回落 wham/JWT。

Verification

  • Type check
  • Lint
  • Tests
  • Build
  • Manual UI check
  • Docs/link check
  • Not applicable, docs-only

Commands / evidence:

npm run type-check
npm run test
# web 相关用例通过(agent 工作区);Changed-file ESLint clean
# 现网 CPA 热更 Chrome TLS 后 api-call → subscriptions:5/5 账号 HTTP 200 JSON(另案验证)

Screenshots / Recordings

待合入前补录:付费 Codex 详情 Subscription Tab;列表剩余天数在 subscriptions 成功时的展示。可先看 fork 工作 PR:HuiCheng#4

Docs

  • README / README_CN updated for user-visible capabilities
  • Matching docs manual and navigation updated
  • Demo fixtures, screenshots, and deep links reviewed
  • Release notes needed
  • Not needed — explanation included below

Docs decision: 沿用现有账号详情 Tab / 列表控件;新增能力以 Issue #743 与本 PR 说明为准,暂不扩 README(若维护者要求再补)。

Related

Refs #743
Fork working PR: HuiCheng#4
CPA TLS 依赖: router-for-me/CLIProxyAPI#5769

HuiCheng and others added 2 commits September 12, 2026 16:25
Fetch /backend-api/subscriptions independently of quota refresh, share
records by chatgpt_account_id, and prefer subscriptions.activeUntilMs
for list remaining days. Paid Codex gets a gated Subscription tab.

Co-authored-by: 程辉 <HuiCheng@users.noreply.github.com>
Replace the brittle renderer tab test with field-builder coverage and
assert the demo api-call subscriptions payload.

Co-authored-by: 程辉 <HuiCheng@users.noreply.github.com>
@HuiCheng HuiCheng changed the title feat(web): lightweight Codex Subscription from /backend-api/subscriptions feat(web): 基于 /backend-api/subscriptions 的轻量 Codex Subscription Sep 12, 2026
HuiCheng and others added 3 commits September 12, 2026 17:35
Replace the unstyled field dump with Quota-style summary metric cards
and an Overview field grid for secondary billing details.

Co-authored-by: 程辉 <HuiCheng@users.noreply.github.com>
Keep the new tab tests stable under react-test-renderer and match Prettier.

Co-authored-by: 程辉 <HuiCheng@users.noreply.github.com>
Show the formatted until time as the metric value and remaining days as
a second line so the 4-card row no longer ellipsizes "2 days".

Co-authored-by: 程辉 <HuiCheng@users.noreply.github.com>
HuiCheng added a commit to HuiCheng/CPA-Manager-Plus that referenced this pull request Sep 12, 2026
HuiCheng added a commit to HuiCheng/CPA-Manager-Plus that referenced this pull request Sep 12, 2026
HuiCheng added a commit to HuiCheng/CPA-Manager-Plus that referenced this pull request Sep 12, 2026
@HuiCheng

HuiCheng commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author

Subscription tab UI (visual check)

Local dev:demo after polish commits 6c0c77b / 3be5656 (Quota-style summary cards + until two-line).

Before

before Subscription Pro 20x

After — Subscription (Pro 20x)

after Subscription Pro 20x

  • Four summary cards: Plan Pro 20x · Until 09/14 10:55 + 2 days · Monthly · Yes
  • Secondary grid: Active start / Fetched at
  • Reuses Quota quotaSummaryPanel + Overview overviewFieldGrid

After — Quota still OK (no regression)

after Quota still OK

Keep the absolute until timestamp as the overview card hero and leave
remaining days only in the value tooltip.

Co-authored-by: 程辉 <HuiCheng@users.noreply.github.com>
cursor Bot pushed a commit to HuiCheng/CPA-Manager-Plus that referenced this pull request Sep 13, 2026
Replace the seakee#745 After shot so 有效期至 / Active until shows the
absolute timestamp only, with no remaining-days line on the card face.

Co-authored-by: 程辉 <HuiCheng@users.noreply.github.com>
@seakee

seakee commented Sep 13, 2026

Copy link
Copy Markdown
Owner

感谢实现。方向本身和 #743 一致,但这里有一个更前置的问题需要先确认。

当前核心链路是:

CPAMP -> CPA /v0/management/api-call -> /backend-api/subscriptions

我检查了 CPA 当前正式 release / main,现有 management/api-call 仍使用标准 Go HTTP transport,并没有 #5769 / #5774 中增加的 ChatGPT Web TLS fingerprint 能力。#5774 目前也未合并,因此 CPAMP 不能把这类未进入正式 CPA 的能力作为功能成立前提。

请先使用未经修改的当前正式 CPA验证 /backend-api/subscriptions?account_id=... 是否能通过现有 management/api-call 稳定返回 JSON。

如果只有应用 #5774 这类修改后才能正常工作,那么当前方案缺少 CPAMP 可依赖的正式上游能力。仅靠 subscriptions -> wham -> JWT fallback 只能保证不回归,并不能真正解决 #743 中 wham 不可用、JWT 可能陈旧的问题。

CPAMP 侧也不适合自行实现 ChatGPT Web TLS / fingerprint transport,这部分应继续属于 CPA。

所以先确认这个前置条件:

#5769 / #5774 可以作为技术验证参考,但目前不能作为 CPAMP 的正式依赖。

@HuiCheng

Copy link
Copy Markdown
Contributor Author

感谢确认前置条件。我按你的要求做了对照:

环境:官方镜像 eceasy/cli-proxy-api:v7.2.159,同一台机器、同一批 Codex auth。

  1. 未修改二进制 CLIProxyAPI.v7.2.159.orig
    POST /v0/management/api-callGET /backend-api/subscriptions?account_id=…
    结果:8/8 upstream 403,拿不到可用 JSON / active_until

  2. 仅热更进 #5774 一类 Chrome TLS 的二进制
    同样 8 个账号:8/8 upstream 200 JSON,均有 active_until

结论:当前正式 CPA 的 management/api-call 无法稳定拿到 subscriptions;只有上游 TLS 修复后这条链路才成立。#745 暂不适合合并;#743 继续保留,等正式 CPA 带上该能力后再收口。

同意:CPAMP 不应自行实现 ChatGPT Web TLS / fingerprint,这部分继续属于 CPA。#5774 仅作技术验证参考,不作为 CPAMP 正式依赖。

HuiCheng and others added 4 commits September 13, 2026 14:18
Reject unmatched array payloads, mark post-ready fetch failures as
soft_failed with retry cooldown, resolve ready store records when
callers omit subscriptionsRecord, and rotate a sibling authIndex after
http/network soft-fail.

Co-authored-by: 程辉 <HuiCheng@users.noreply.github.com>
…builds

Keep token-scoped objects without account-id, but return null for mismatched
object/nested payloads. Preserve a fresh ready record when a chained force
soft-fails. Re-run target ensure when subscriptionEntries change so sibling
authIndex rotate actually schedules, and include subscriptionEntries in the
rows useMemo deps for seakee#742 sort bake timing.

Co-authored-by: 程辉 <HuiCheng@users.noreply.github.com>
…n objects

A parent account-id that is not the requested account must not adopt a
nested token-scoped object. Nested arrays under an envelope id can still
select a matching per-account element.

Co-authored-by: 程辉 <HuiCheng@users.noreply.github.com>
Honor triedAuthIndexes for 3+ siblings, keep ready only for chained force
after a just-ready inflight, default demo subscriptions to free when plan
is missing, hide the tab when the API plan is free, and search dual-key
subscriptions arrays before token-scoped sibling objects.

Co-authored-by: 程辉 <HuiCheng@users.noreply.github.com>
cursor Bot pushed a commit to HuiCheng/CPA-Manager-Plus that referenced this pull request Sep 13, 2026
Replace the seakee#745 After shot so 有效期至 / Active until is date-only,
with remaining days only in the tooltip. Refresh quota tab shot too.

Co-authored-by: 程辉 <HuiCheng@users.noreply.github.com>
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