Skip to content

Commit 81af52f

Browse files
committed
fix(gui): address CodeRabbit pause-control follow-ups
Disable Pause exhausted while any pause mutation is in flight, guard pause response JSON parsing, add paused to toast fixtures, and document that pause clears thread affinity for subsequent turns.
1 parent 4101b83 commit 81af52f

10 files changed

Lines changed: 20 additions & 7 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ next Codex session. opencodex keeps these behaviors:
240240

241241
- **Existing sessions keep affinity.** A thread id is bound to the selected account and reused on
242242
later turns, so a long request or a mobile/SSH-attached session keeps using the same account.
243+
Pausing an account clears its affinity map: in-flight requests keep captured credentials, but
244+
subsequent turns are re-routed and cannot reuse the paused account.
243245
- **New sessions can auto-route.** When auto-switch is enabled, opencodex compares the hottest known
244246
quota window across 5h, weekly, and 30d usage, then picks a lower-usage eligible account for new
245247
sessions once the active account crosses the threshold.

‎docs-site/src/content/docs/ja/reference/configuration.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ pool アカウントの追加と quota 更新はダッシュボードの **Codex
8787
保管します。既存 thread id はアカウント affinity を維持し、新しいセッションは `accountPoolStrategy`、quota、cooldown、health に
8888
応じて自動ルーティングされます。
8989
一時停止したアカウントと quota metadata は表示されたままですが、自動切り替え、再試行/failover 選択、cooldown 復旧プローブ、手動有効化の対象外です。
90+
一時停止するとそのアカウントの thread affinity map も消去されます。処理中のリクエストは取得済み credential を維持しますが、以降のターンは再ルーティングされ、一時停止中のアカウントは再利用できません。
9091
状態は再起動後も保持され、すべてのアカウントが一時停止中なら Pool ルーティングは別のアカウントを暗黙に選ばず失敗します。
9192
**上限到達を一括停止** は全アカウントを先に更新し、関連する quota window が今回 100% と確認できたアカウントだけを停止します。quota が不明、または更新に失敗したアカウントは変更しません。
9293

‎docs-site/src/content/docs/ko/reference/configuration.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ pool 계정 추가와 quota 갱신은 대시보드의 **Codex Auth** 페이지
8989
보관합니다. 기존 thread id는 계정 affinity를 유지하며, 새 세션은 `accountPoolStrategy`, quota,
9090
cooldown, health에 따라 자동 라우팅됩니다.
9191
일시 중지된 계정과 quota metadata는 계속 표시되지만 자동 전환, 재시도/failover 선택, cooldown 복구 probe, 수동 활성화에서는 제외됩니다.
92+
일시 중지는 해당 계정의 thread affinity map도 지웁니다. 진행 중인 요청은 이미 확보한 credential을 유지하지만, 이후 턴은 다시 라우팅되며 일시 중지된 계정은 재사용할 수 없습니다.
9293
상태는 재시작 후에도 유지되며, 모든 계정이 일시 중지되면 Pool 라우팅은 계정을 몰래 선택하지 않고 실패합니다.
9394
**한도 도달 계정 일시 중지**는 먼저 모든 계정을 새로고친 뒤 관련 quota window가 이번 응답에서 100%로 확인된 계정만 일시 중지합니다. quota가 없거나 새로고침에 실패한 계정은 변경하지 않습니다.
9495

‎docs-site/src/content/docs/reference/configuration.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ credential store. Existing thread ids keep account affinity, while new sessions
117117
account is retried once on an eligible alternate account in the same request (so Codex CLI does not
118118
stall on a depleted primary while another account still has quota).
119119
Pause keeps an account and its quota metadata visible, but excludes it from automatic switching,
120-
retry/failover selection, cooldown recovery probes, and manual activation. The exclusion survives
120+
retry/failover selection, cooldown recovery probes, and manual activation. Pausing also clears that
121+
account's thread-affinity map: in-flight requests keep their captured credentials, but subsequent
122+
turns are re-routed and cannot reuse the paused account. The exclusion survives
121123
restarts; if every account is paused, Pool routing fails instead of silently selecting one.
122124
**Pause exhausted** first refreshes every account and pauses only those whose relevant quota window
123125
is freshly confirmed at 100%; unknown quota and failed refreshes are left unchanged.

‎docs-site/src/content/docs/ru/reference/configuration.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ raw id аккаунтов и email приватными, а селектор и
9696
аккаунту; новые сессии маршрутизируются по `accountPoolStrategy`, квоте, cooldown и
9797
работоспособности.
9898
Приостановленный аккаунт и его метаданные квоты остаются видимыми, но исключаются из автоматического переключения,
99-
повторов/failover, проб восстановления cooldown и ручной активации. Состояние сохраняется после перезапуска;
99+
повторов/failover, проб восстановления cooldown и ручной активации. Пауза также очищает карту affinity потоков
100+
этого аккаунта: выполняющиеся запросы сохраняют захваченные учётные данные, но последующие ходы
101+
перемаршрутизируются и не могут повторно использовать приостановленный аккаунт. Состояние сохраняется после перезапуска;
100102
если приостановлены все аккаунты, маршрутизация Pool завершается ошибкой, а не выбирает аккаунт скрытно.
101103
**Приостановить исчерпанные** сначала обновляет все аккаунты и приостанавливает только те, для которых актуальное окно квоты в этом ответе подтверждено на уровне 100%. Аккаунты с неизвестной квотой или неудачным обновлением не меняются.
102104

‎docs-site/src/content/docs/zh-cn/reference/configuration.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ pool account id(不能是内部 `__main__`),或用 `"@main"` 表示 Codex
8484
metadata;access/refresh token 存放在加固的 Codex account credential store 中。已有 thread id 会
8585
保留 account affinity;新 session 按 `accountPoolStrategy`、quota、cooldown 和 health 自动路由。
8686
暂停后仍会显示账号及其 quota metadata,但不会参与自动切换、重试/failover 选择、cooldown 恢复探测或手动激活。
87+
暂停还会清除该账号的 thread affinity map:进行中的请求保留已捕获的 credential,但后续 turn 会重新路由,无法再使用已暂停账号。
8788
暂停状态会跨重启保留;如果所有账号均已暂停,Pool 路由会明确失败,而不会暗中选择某个账号。
8889
**暂停已达上限账号** 会先刷新全部账号,只暂停相关 quota window 本次明确返回 100% 的账号;未知额度或刷新失败的账号保持不变。
8990

‎gui/src/components/CodexAccountPool.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ export default function CodexAccountPool({ apiBase, accountModeState = null, ban
252252
embedded={embedded}
253253
refreshingQuota={refreshingQuota}
254254
pausingExhausted={pausingExhausted}
255+
pauseBusy={pauseUpdatingId !== null || pausingExhausted}
255256
onRefresh={() => { void refreshQuotas(); }}
256257
onPauseExhausted={() => { void pauseExhausted(); }}
257258
/>

‎gui/src/components/codex-account-pool-main-card.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,15 @@ export function CodexAccountPoolPageHead({
125125
embedded,
126126
refreshingQuota,
127127
pausingExhausted,
128+
pauseBusy,
128129
onRefresh,
129130
onPauseExhausted,
130131
}: {
131132
t: TFn;
132133
embedded: boolean;
133134
refreshingQuota: boolean;
134135
pausingExhausted: boolean;
136+
pauseBusy?: boolean;
135137
onRefresh: () => void;
136138
onPauseExhausted: () => void;
137139
}) {
@@ -146,15 +148,15 @@ export function CodexAccountPoolPageHead({
146148
type="button"
147149
className="btn btn-sm btn-ghost"
148150
onClick={onPauseExhausted}
149-
disabled={refreshingQuota || pausingExhausted}
151+
disabled={refreshingQuota || pausingExhausted || !!pauseBusy}
150152
>
151153
<IconPause width={14} /> {pausingExhausted ? t("codexAuth.pausingExhausted") : t("codexAuth.pauseExhausted")}
152154
</button>
153155
<button
154156
type="button"
155157
className="btn btn-sm btn-ghost"
156158
onClick={onRefresh}
157-
disabled={refreshingQuota || pausingExhausted}
159+
disabled={refreshingQuota || pausingExhausted || !!pauseBusy}
158160
>
159161
<IconRefresh width={14} /> {refreshingQuota ? t("codexAuth.refreshingQuota") : t("codexAuth.refreshQuota")}
160162
</button>

‎gui/src/hooks/useCodexAccountPool.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ export function useCodexAccountPool(apiBase: string, enabled = true): CodexAccou
250250
body: JSON.stringify({ id, paused }),
251251
});
252252
if (!response.ok) return { ok: false, reason: "request" } as const;
253-
const result = await response.json() as { activeCodexAccountId?: string | null };
253+
const result = await response.json().catch(() => ({})) as { activeCodexAccountId?: string | null };
254254
setAccounts(current => current.map(account => (
255255
account.id === id || (id === "__main__" && account.isMain)
256256
? { ...account, paused }
@@ -276,7 +276,7 @@ export function useCodexAccountPool(apiBase: string, enabled = true): CodexAccou
276276
try {
277277
const response = await fetch(`${apiBase}/api/codex-auth/accounts/pause-exhausted`, { method: "PUT" });
278278
if (!response.ok) return { ok: false, reason: "request" } as const;
279-
const result = await response.json() as {
279+
const result = await response.json().catch(() => ({})) as {
280280
pausedAccountIds?: string[];
281281
pausedCount?: number;
282282
activeCodexAccountId?: string | null;

‎gui/tests/codex-account-pool-toast-tone.test.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ const account: CodexAccountEntry = {
2222
id: "pool-1",
2323
2424
isMain: false,
25+
paused: false,
2526
hasCredential: true,
2627
quota: { resetCredits: 2, updatedAt: 1 },
2728
};
2829

2930
function makeController(overrides: Partial<CodexAccountPoolController> = {}): CodexAccountPoolController {
3031
return {
3132
accounts: [
32-
{ id: "main", email: "[email protected]", isMain: true, hasCredential: true, quota: null },
33+
{ id: "main", email: "[email protected]", isMain: true, paused: false, hasCredential: true, quota: null },
3334
account,
3435
],
3536
activeId: null,

0 commit comments

Comments
 (0)