From 6dc2bf3631ed6eb32d8e3b6c503d624a9685f0db Mon Sep 17 00:00:00 2001
From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Date: Fri, 23 Oct 2026 21:39:43 +0800
Subject: [PATCH] fix(codex-accounts): prefer subscriptions with more allowance
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
---
.../codex-account-settings.css | 2 +
.../codex-account-settings.tsx | 12 +++--
.../loopx-codex-provider-routing/NATIVE.md | 26 ++++++++++-
.../assets/native-accounts-quota-before.png | Bin 0 -> 115115 bytes
.../assets/native-accounts-quota-desktop.png | Bin 0 -> 115755 bytes
.../assets/native-accounts-quota-help.png | Bin 0 -> 67305 bytes
.../assets/native-accounts-quota-narrow.png | Bin 0 -> 58245 bytes
.../extension.toml | 2 +-
.../pyproject.toml | 2 +-
.../smoke/native-policy.test.mjs | 44 ++++++++++++++++++
.../loopx_codex_provider_routing/__init__.py | 2 +-
.../native_policy.ts | 14 ++++--
tests/presentation/test_codex_accounts.py | 32 +++++++++++++
13 files changed, 125 insertions(+), 11 deletions(-)
create mode 100644 packages/loopx-codex-provider-routing/docs/assets/native-accounts-quota-before.png
create mode 100644 packages/loopx-codex-provider-routing/docs/assets/native-accounts-quota-desktop.png
create mode 100644 packages/loopx-codex-provider-routing/docs/assets/native-accounts-quota-help.png
create mode 100644 packages/loopx-codex-provider-routing/docs/assets/native-accounts-quota-narrow.png
diff --git a/apps/presentation/dashboard/src/features/personal-workspace/codex-account-settings.css b/apps/presentation/dashboard/src/features/personal-workspace/codex-account-settings.css
index 1550f76734..4022c0a61c 100644
--- a/apps/presentation/dashboard/src/features/personal-workspace/codex-account-settings.css
+++ b/apps/presentation/dashboard/src/features/personal-workspace/codex-account-settings.css
@@ -5,6 +5,8 @@
.personal-codex-accounts header > span, .codex-account-effect, .personal-codex-accounts details, .codex-account-actions > span { color: var(--pw-muted); font-size: var(--text-caption); line-height: var(--leading-caption); }
.codex-account-enable { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 12px 0; border-top: 1px solid var(--pw-line); border-bottom: 1px solid var(--pw-line); }
.codex-account-enable input { accent-color: var(--pw-text); width: 18px; height: 18px; }
+.codex-account-enable > label { display: flex; align-items: center; gap: 12px; flex: 1; }
+.codex-account-enable .context-help-trigger { border: 0; background: transparent; padding: 0; width: 44px; }
.codex-account-state { display: flex; gap: 8px; align-items: center; font-size: var(--text-body); }
.codex-account-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.codex-account-list article { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; padding-top: 16px; border-top: 2px solid var(--pw-line); min-width: 0; }
diff --git a/apps/presentation/dashboard/src/features/personal-workspace/codex-account-settings.tsx b/apps/presentation/dashboard/src/features/personal-workspace/codex-account-settings.tsx
index a78b5a3e1d..ba2c23ac97 100644
--- a/apps/presentation/dashboard/src/features/personal-workspace/codex-account-settings.tsx
+++ b/apps/presentation/dashboard/src/features/personal-workspace/codex-account-settings.tsx
@@ -2,6 +2,7 @@ import { useCallback, useEffect, useState } from "react";
import { RefreshCw, CheckCircle2, Circle, AlertCircle } from "lucide-react";
import { requestJson } from "../../data/chat";
import { useWorkspaceI18n } from "./i18n";
+import { ContextHelp } from "./context-help";
import "./codex-account-settings.css";
type AccountStatus = {
@@ -20,6 +21,7 @@ const copy = {
"zh-CN": {
title: "Codex 原生账号", enabled: "自动接续已启用", disabled: "自动接续已关闭",
enable: "额度耗尽后自动切换", refresh: "检查额度", retry: "重新连接",
+ selectionHelp: "自动选择顺序", selectionDetail: "优先选择剩余额度比例最多的可用账号;短、长周期取剩余较少的一项。平手从当前账号之后按已登记顺序选择。这里比较的是额度百分比,无法获知绝对剩余 token。当前账号可用时不会主动切换。",
effect: "仅使用下方已登记账号。额度耗尽后正常退出 GPT 专用客户端,保存登录态并切换,再重新打开原来的界面。",
effectWait: "仅使用下方已登记账号。额度耗尽后等待客户端关闭,再保存登录态、切换账号并重新打开。",
restart: "允许自动退出并重开 GPT 客户端", restarting: "正在退出 GPT、切换账号并重新打开",
@@ -47,6 +49,7 @@ const copy = {
en: {
title: "Native Codex accounts", enabled: "Automatic handoff enabled", disabled: "Automatic handoff off",
enable: "Switch automatically when quota runs out", refresh: "Check quota", retry: "Reconnect",
+ selectionHelp: "Automatic selection order", selectionDetail: "Prefer the available account with the most remaining allowance, using the lower remaining percentage across its reported windows. Ties follow the registered order after the current account. These percentages do not establish absolute tokens left. An available current account is not preempted.",
effect: "Use only the registered accounts below. After exhaustion, quit the dedicated GPT client normally, save the login, switch accounts, then reopen the same interface.",
effectWait: "Use only the registered accounts below. After exhaustion, wait for clients to close, save the login, switch accounts, then reopen the same interface.",
restart: "Allow automatic GPT client quit and restart", restarting: "Quitting GPT, switching accounts and reopening",
@@ -114,9 +117,11 @@ export function CodexAccountSettings() {
{(problem && problem !== status?.action) || status?.available === false ?
{label(problem)}
: null}
{status?.available && status.slots?.length ? <>
{restartClients ? forceQuitClients ? c.effectForce : c.effect : c.effectWait}
-