Skip to content

Commit 9fef284

Browse files
committed
fix: CodeRabbit follow-ups for pause activeId and docs
Only update activeId when the pause response includes activeCodexAccountId, honor paused in pool reauth callback, and align Pause exhausted docs with credential-scoped refresh behavior.
1 parent 81af52f commit 9fef284

8 files changed

Lines changed: 25 additions & 17 deletions

File tree

‎README.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,9 @@ next Codex session. opencodex keeps these behaviors:
246246
quota window across 5h, weekly, and 30d usage, then picks a lower-usage eligible account for new
247247
sessions once the active account crosses the threshold.
248248
- **Quota lookup is built in.** The dashboard can refresh all account quotas in one click, and the
249-
request log labels pool traffic with non-PII account ordinals. **Pause exhausted** refreshes the
250-
pool and pauses only accounts whose relevant quota window is freshly confirmed at 100%.
249+
request log labels pool traffic with non-PII account ordinals. **Pause exhausted** refreshes
250+
eligible accounts that have credentials and pauses only those whose relevant quota window is
251+
freshly confirmed at 100%; accounts without credentials and unknown or failed refreshes stay unchanged.
251252
- **Failures fail closed.** Token failures mark reauthentication instead of falling back to another
252253
credential silently; 429 quota responses put the account in cooldown and can fail over future work
253254
to another eligible pool account.

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

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

9494
**rotation 戦略**(新しいセッションのみ;bound thread は不変):`quota`(既定)— `autoSwitchThreshold` 超過時に最小 usage を選択;`round-robin` — 均等分散、`accountPoolStickyLimit`(既定 `1`、1–100)で 1 選択あたりの成功 bind 数;`fill-first` — アクティブアカウントを cooldown、再認証、または threshold まで使い切り(未知 usage は強制切替しない)後、安定ソート順で次へ。rotation は provider enforcement を回避しません — 複数アカウント利用は ToS 違反の可能性があります。
9595
:::

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ cooldown, health에 따라 자동 라우팅됩니다.
9191
일시 중지된 계정과 quota metadata는 계속 표시되지만 자동 전환, 재시도/failover 선택, cooldown 복구 probe, 수동 활성화에서는 제외됩니다.
9292
일시 중지는 해당 계정의 thread affinity map도 지웁니다. 진행 중인 요청은 이미 확보한 credential을 유지하지만, 이후 턴은 다시 라우팅되며 일시 중지된 계정은 재사용할 수 없습니다.
9393
상태는 재시작 후에도 유지되며, 모든 계정이 일시 중지되면 Pool 라우팅은 계정을 몰래 선택하지 않고 실패합니다.
94-
**한도 도달 계정 일시 중지**는 먼저 모든 계정을 새로고친 뒤 관련 quota window가 이번 응답에서 100%로 확인된 계정만 일시 중지합니다. quota가 없거나 새로고침에 실패한 계정은 변경하지 않습니다.
94+
**한도 도달 계정 일시 중지**는 credential이 있는 적격 계정만 먼저 새로고친 뒤 관련 quota window가 이번 응답에서 100%로 확인된 계정만 일시 중지합니다. credential이 없는 계정과 quota가 없거나 새로고침에 실패한 계정은 변경하지 않습니다.
9595

9696
**rotation 전략**(새 세션만; bound thread는 변경 없음): `quota`(기본) — `autoSwitchThreshold` 초과 시
9797
최저 usage 선택; `round-robin` — 균등 분배, `accountPoolStickyLimit`(기본 `1`, 1–100)로 한 선택당

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ retry/failover selection, cooldown recovery probes, and manual activation. Pausi
121121
account's thread-affinity map: in-flight requests keep their captured credentials, but subsequent
122122
turns are re-routed and cannot reuse the paused account. The exclusion survives
123123
restarts; if every account is paused, Pool routing fails instead of silently selecting one.
124-
**Pause exhausted** first refreshes every account and pauses only those whose relevant quota window
125-
is freshly confirmed at 100%; unknown quota and failed refreshes are left unchanged.
124+
**Pause exhausted** first refreshes eligible accounts that have credentials available and pauses
125+
only those whose relevant quota window is freshly confirmed at 100%; accounts without credentials
126+
and unknown or failed quota refreshes are left unchanged.
126127
:::
127128

128129
**Rotation strategies** (new sessions only; bound threads are unchanged):

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ raw id аккаунтов и email приватными, а селектор и
100100
этого аккаунта: выполняющиеся запросы сохраняют захваченные учётные данные, но последующие ходы
101101
перемаршрутизируются и не могут повторно использовать приостановленный аккаунт. Состояние сохраняется после перезапуска;
102102
если приостановлены все аккаунты, маршрутизация Pool завершается ошибкой, а не выбирает аккаунт скрытно.
103-
**Приостановить исчерпанные** сначала обновляет все аккаунты и приостанавливает только те, для которых актуальное окно квоты в этом ответе подтверждено на уровне 100%. Аккаунты с неизвестной квотой или неудачным обновлением не меняются.
103+
**Приостановить исчерпанные** сначала обновляет только подходящие аккаунты с доступными учётными данными и приостанавливает только те, для которых актуальное окно квоты в этом ответе подтверждено на уровне 100%. Аккаунты без учётных данных, с неизвестной квотой или неудачным обновлением не меняются.
104104

105105
**Стратегии ротации** (только новые сессии; привязанные потоки не меняются): `quota` (по умолчанию)
106106
— выбор наименьшего usage при превышении `autoSwitchThreshold`; `round-robin` — равномерное

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ metadata;access/refresh token 存放在加固的 Codex account credential stor
8686
暂停后仍会显示账号及其 quota metadata,但不会参与自动切换、重试/failover 选择、cooldown 恢复探测或手动激活。
8787
暂停还会清除该账号的 thread affinity map:进行中的请求保留已捕获的 credential,但后续 turn 会重新路由,无法再使用已暂停账号。
8888
暂停状态会跨重启保留;如果所有账号均已暂停,Pool 路由会明确失败,而不会暗中选择某个账号。
89-
**暂停已达上限账号** 会先刷新全部账号,只暂停相关 quota window 本次明确返回 100% 的账号;未知额度或刷新失败的账号保持不变。
89+
**暂停已达上限账号** 会先刷新有 credential 的合格账号,只暂停相关 quota window 本次明确返回 100% 的账号;无 credential、未知额度或刷新失败的账号保持不变。
9090

9191
**轮换策略**(仅新 session;已绑定 thread 不变):`quota`(默认)— 活跃账号 usage 超过
9292
`autoSwitchThreshold` 时选最低者;`round-robin` — 均分,`accountPoolStickyLimit`(默认 `1`,

‎gui/src/components/CodexAccountPool.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default function CodexAccountPool({ apiBase, accountModeState = null, ban
103103
const activePoolAccount = activeId && activeId !== "__main__"
104104
? accounts.find(a => a.id === activeId)
105105
: null;
106-
const activePoolNeedsReauth = accountNeedsReauth(activePoolAccount);
106+
const activePoolNeedsReauth = !activePoolAccount?.paused && accountNeedsReauth(activePoolAccount);
107107

108108
useEffect(() => {
109109
onActiveNeedsReauthChange?.(activePoolNeedsReauth);

‎gui/src/hooks/useCodexAccountPool.ts‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -250,15 +250,18 @@ 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().catch(() => ({})) as { activeCodexAccountId?: string | null };
253+
const raw = await response.json().catch(() => ({}));
254+
const result = (raw && typeof raw === "object" ? raw : {}) as { activeCodexAccountId?: string | null };
254255
setAccounts(current => current.map(account => (
255256
account.id === id || (id === "__main__" && account.isMain)
256257
? { ...account, paused }
257258
: account
258259
)));
259-
const nextActiveId = result.activeCodexAccountId ?? null;
260-
pendingActiveIdRef.current = { id: nextActiveId };
261-
setActiveId(nextActiveId);
260+
if (Object.prototype.hasOwnProperty.call(result, "activeCodexAccountId")) {
261+
const nextActiveId = result.activeCodexAccountId ?? null;
262+
pendingActiveIdRef.current = { id: nextActiveId };
263+
setActiveId(nextActiveId);
264+
}
262265
void load();
263266
return { ok: true } as const;
264267
} catch {
@@ -276,7 +279,8 @@ export function useCodexAccountPool(apiBase: string, enabled = true): CodexAccou
276279
try {
277280
const response = await fetch(`${apiBase}/api/codex-auth/accounts/pause-exhausted`, { method: "PUT" });
278281
if (!response.ok) return { ok: false, reason: "request" } as const;
279-
const result = await response.json().catch(() => ({})) as {
282+
const raw = await response.json().catch(() => ({}));
283+
const result = (raw && typeof raw === "object" ? raw : {}) as {
280284
pausedAccountIds?: string[];
281285
pausedCount?: number;
282286
activeCodexAccountId?: string | null;
@@ -287,9 +291,11 @@ export function useCodexAccountPool(apiBase: string, enabled = true): CodexAccou
287291
? { ...account, paused: true }
288292
: account
289293
)));
290-
const nextActiveId = result.activeCodexAccountId ?? null;
291-
pendingActiveIdRef.current = { id: nextActiveId };
292-
setActiveId(nextActiveId);
294+
if (Object.prototype.hasOwnProperty.call(result, "activeCodexAccountId")) {
295+
const nextActiveId = result.activeCodexAccountId ?? null;
296+
pendingActiveIdRef.current = { id: nextActiveId };
297+
setActiveId(nextActiveId);
298+
}
293299
void load();
294300
return { ok: true, pausedCount: result.pausedCount ?? pausedIds.size } as const;
295301
} catch {

0 commit comments

Comments
 (0)