Skip to content

Commit ca4d2c5

Browse files
agentHitsclaude
andcommitted
fix(gui): show a saved-but-not-live pool strategy as such, and review findings
The accounts toolbar offered a live-looking strategy selector for a generic pool while `pool.kernel` was off, when the runtime does not consume the stored strategy. The dashboard read `inert` from /api/pool/settings, but the unified DTO never served it, so the flag was always false. - The unified DTO reports `inert` for the generic kind. The field is already optional in the CLI's pool schema and in the documented `account pool` shape; codex and anthropic keep their key set. The contract test pins both. - The toolbar disables the selector and labels it "Saved, not live" while inert. - A stored strategy this dashboard does not model (Kiro's CLI-only `least-loaded`) is shown as stored instead of as the default, and the pool switch writes only `enabled`, so toggling can no longer overwrite it. Smaller review findings: - AccountAuthChoiceModal restores focus after the frame that removes the dialog, so the trigger is focusable again when focus returns. - The reset-first description names the 5-hour fallback in every locale. - A card cannot start a quota read while another read is running in the same roster. - Full-width card rows span `1 / -1` instead of two columns, so they no longer force a second column in the single-column mobile grid. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent c82dded commit ca4d2c5

17 files changed

Lines changed: 182 additions & 41 deletions

‎gui/src/components/AccountAuthChoiceModal.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ export default function AccountAuthChoiceModal({
3232
if (!isOpen) return;
3333
const previous = document.activeElement as HTMLElement | null;
3434
primary.current?.focus();
35-
return () => { if (previous?.isConnected && typeof previous.focus === "function") previous.focus(); };
35+
// Deferred: React is still removing the dialog during cleanup and resets focus to the
36+
// body afterwards, which would discard a synchronous restoration.
37+
return () => { requestAnimationFrame(() => { if (previous?.isConnected && typeof previous.focus === "function") previous.focus(); }); };
3638
}, [isOpen]);
3739
useEffect(() => {
3840
if (!isOpen) return;

‎gui/src/components/provider-workspace/ProviderAccountCard.tsx‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export interface ProviderAccountCardProps {
2929
switching: boolean;
3030
disabled: boolean;
3131
refreshing: boolean;
32+
/** A quota read is running somewhere in this roster, so no card may start another. */
33+
refreshBusy?: boolean;
3234
onSwitch: (account: OAuthAccountRow) => void;
3335
onRefreshSingle?: (account: OAuthAccountRow) => void;
3436
onEditAlias: (account: OAuthAccountRow) => void;
@@ -55,6 +57,7 @@ export default function ProviderAccountCard({
5557
switching,
5658
disabled,
5759
refreshing,
60+
refreshBusy = false,
5861
onSwitch,
5962
onRefreshSingle,
6063
onEditAlias,
@@ -273,7 +276,7 @@ export default function ProviderAccountCard({
273276
type="button"
274277
className="btn btn-ghost btn-xs pwi-icon-btn"
275278
title={t("pws.refreshAccountQuota")}
276-
disabled={refreshing || disabled}
279+
disabled={refreshing || refreshBusy || disabled}
277280
onClick={() => onRefreshSingle(account)}
278281
>
279282
<IconRefresh width={12} height={12} className={refreshing ? "pwi-spin-inline" : ""} aria-hidden="true" />
@@ -303,7 +306,7 @@ export default function ProviderAccountCard({
303306
{/* Compact Bar Columns: Clean Gemini/Claude headers & round % */}
304307
<div className="pwi-dense-bars-grid">
305308
{showReauth && (
306-
<div style={{ gridColumn: "span 2", display: "flex", justifyContent: "space-between", alignItems: "center", padding: "4px 8px", background: "color-mix(in srgb, var(--amber) 10%, var(--surface))", borderRadius: "4px" }}>
309+
<div style={{ gridColumn: "1 / -1", display: "flex", justifyContent: "space-between", alignItems: "center", padding: "4px 8px", background: "color-mix(in srgb, var(--amber) 10%, var(--surface))", borderRadius: "4px" }}>
307310
<span style={{ fontSize: "11px", color: "var(--amber)", fontWeight: 600 }}>⚠️ {t("pws.healthLabel.reauthRequired")}</span>
308311
{onReauth && <button type="button" className="btn btn-primary btn-sm" style={{ height: "22px", padding: "0 8px", fontSize: "11px" }} onClick={() => onReauth(account)}>{t("pws.reauthenticate")}</button>}
309312
</div>
@@ -377,7 +380,7 @@ export default function ProviderAccountCard({
377380

378381
{/* Generic fallback */}
379382
{!analyzed.gemini5h && !analyzed.geminiWeekly && !analyzed.claude5h && !analyzed.claudeWeekly && (
380-
<div className="pwi-dense-col" style={{ gridColumn: "span 2" }}>
383+
<div className="pwi-dense-col" style={{ gridColumn: "1 / -1" }}>
381384
{(analyzed.generic5h || analyzed.genericWeekly) ? (
382385
<>
383386
{renderSingleQuotaBar(t("pws.window5hLabel"), analyzed.generic5h?.percent, analyzed.generic5h?.resetAt)}
@@ -448,7 +451,7 @@ export default function ProviderAccountCard({
448451
type="button"
449452
className="btn btn-ghost btn-sm pwi-icon-btn"
450453
title={t("pws.refreshAccountQuota")}
451-
disabled={refreshing || disabled || switching}
454+
disabled={refreshing || refreshBusy || disabled || switching}
452455
onClick={() => onRefreshSingle(account)}
453456
>
454457
<IconRefresh width={13} height={13} className={refreshing ? "pwi-spin-inline" : ""} aria-hidden="true" />
@@ -513,14 +516,14 @@ export default function ProviderAccountCard({
513516
)}
514517

515518
{showReauth && (
516-
<div style={{ gridColumn: "span 2", padding: "12px 14px", background: "color-mix(in srgb, var(--amber) 10%, var(--surface))", border: "1px solid color-mix(in srgb, var(--amber) 30%, transparent)", borderRadius: "6px", display: "flex", alignItems: "center", justifyContent: "space-between", gap: "10px" }}>
519+
<div style={{ gridColumn: "1 / -1", padding: "12px 14px", background: "color-mix(in srgb, var(--amber) 10%, var(--surface))", border: "1px solid color-mix(in srgb, var(--amber) 30%, transparent)", borderRadius: "6px", display: "flex", alignItems: "center", justifyContent: "space-between", gap: "10px" }}>
517520
<span style={{ fontSize: "12px", color: "var(--amber)", fontWeight: 600 }}>⚠️ {t("pws.healthLabel.reauthRequired")}</span>
518521
{onReauth && <button type="button" className="btn btn-primary btn-sm" onClick={() => onReauth(account)}>{t("pws.reauthenticate")}</button>}
519522
</div>
520523
)}
521524

522525
{!isAntigravity && !showReauth && (
523-
<div className="pwi-quota-col" style={{ gridColumn: "span 2" }}>
526+
<div className="pwi-quota-col" style={{ gridColumn: "1 / -1" }}>
524527
{(analyzed.generic5h || analyzed.genericWeekly) ? (
525528
<>
526529
{renderSingleQuotaBar(t("pws.window5hLabel"), analyzed.generic5h?.percent, analyzed.generic5h?.resetAt)}

‎gui/src/components/provider-workspace/ProviderAccountsToolbar.tsx‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ export interface ProviderAccountsToolbarProps {
4040
poolEnabled?: boolean;
4141
onTogglePoolEnabled?: () => void;
4242
poolStrategy?: AccountPoolStrategy;
43+
/** The saved strategy is persisted but not consumed (shared pool kernel off). */
44+
poolInert?: boolean;
45+
/** A stored strategy outside this selector's options, shown as-is rather than as the default. */
46+
poolUnmodeledStrategy?: string | null;
4347
onSelectPoolStrategy?: (strategy: AccountPoolStrategy) => void;
4448
}
4549

@@ -66,6 +70,8 @@ export default function ProviderAccountsToolbar({
6670
poolEnabled = false,
6771
onTogglePoolEnabled,
6872
poolStrategy = DEFAULT_ACCOUNT_POOL_STRATEGY,
73+
poolInert = false,
74+
poolUnmodeledStrategy = null,
6975
onSelectPoolStrategy,
7076
}: ProviderAccountsToolbarProps) {
7177
const t = useT();
@@ -859,16 +865,20 @@ export default function ProviderAccountsToolbar({
859865
{poolEnabled && onSelectPoolStrategy && (
860866
<select
861867
className="pwi-pool-select"
862-
value={poolStrategy}
868+
value={poolUnmodeledStrategy ?? poolStrategy}
863869
onChange={e => onSelectPoolStrategy(e.target.value as AccountPoolStrategy)}
864870
aria-label={t("accountPool.strategy")}
871+
disabled={poolInert}
872+
title={poolInert ? t("genericPool.visualKernelGap") : undefined}
865873
>
874+
{poolUnmodeledStrategy && <option value={poolUnmodeledStrategy}>{poolUnmodeledStrategy}</option>}
866875
<option value="reset-first">📅 {t("accountPool.strategyResetFirst")}</option>
867876
<option value="quota">⚡ {t("accountPool.strategyQuota")}</option>
868877
<option value="round-robin">🔄 {t("accountPool.strategyRoundRobin")}</option>
869878
<option value="fill-first">🎯 {t("accountPool.strategyFillFirst")}</option>
870879
</select>
871880
)}
881+
{poolEnabled && poolInert && <span className="badge badge-muted">{t("genericPool.visualStored")}</span>}
872882
<div className={`pwi-pool-tooltip-wrap${tooltipOpen ? " is-open" : ""}`}>
873883
<button
874884
type="button"

‎gui/src/components/provider-workspace/ProviderAuthPanel.tsx‎

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import CodexAccountPool from "../CodexAccountPool";
1717
import AnthropicAccountPoolSettings from "./AnthropicAccountPoolSettings";
1818
import { LoginHint as LoginHintView } from "../login-url-block";
1919
import { OpenBrowserPrefToggle } from "../open-browser-pref-toggle";
20-
import { getPoolSettings, putPoolSettings } from "../../pool-settings";
21-
import { normalizeAccountPoolStrategy, type AccountPoolStrategy } from "../../account-pool-strategy";
20+
import { getPoolSettings, putPoolSettings, type PoolSettings } from "../../pool-settings";
21+
import type { AccountPoolStrategy } from "../../account-pool-strategy";
2222
import { DEFAULT_ACCOUNT_POOL_STRATEGY } from "../../account-pool-strategy";
2323
import ProviderAccountQuota from "./ProviderAccountQuota";
2424
import { GrokResetCouponModal } from "./GrokResetCoupons";
@@ -273,7 +273,18 @@ export default function ProviderAuthPanel({
273273
// Pool settings belong to the provider and server they were read for. The panel is not
274274
// remounted per provider, so a value from another scope is hidden during render: it is
275275
// never shown, and the toggle can never persist it, under the provider now on screen.
276-
const [genericPoolState, setGenericPool] = useState<{ scope: string; enabled: boolean; strategy: AccountPoolStrategy } | null>(null);
276+
const [genericPoolState, setGenericPool] = useState<{
277+
scope: string; enabled: boolean; strategy: AccountPoolStrategy; inert: boolean;
278+
/** A stored strategy this dashboard does not model (Kiro's CLI-only least-loaded). */
279+
unmodeledStrategy: string | null;
280+
} | null>(null);
281+
const poolStateFrom = (scope: string, res: PoolSettings) => ({
282+
scope,
283+
enabled: res.enabled === true || res.enabledEffective === true,
284+
strategy: res.strategy,
285+
inert: res.inert,
286+
unmodeledStrategy: res.storedStrategy !== null && res.storedStrategy !== res.strategy ? res.storedStrategy : null,
287+
});
277288
const genericPool = genericPoolState?.scope === grantScope ? genericPoolState : null;
278289

279290
const [poolSaveError, setPoolSaveError] = useState<string | null>(null);
@@ -289,11 +300,7 @@ export default function ProviderAuthPanel({
289300
let cancelled = false;
290301
void getPoolSettings(apiBase, item.name).then(res => {
291302
if (cancelled || !res) return;
292-
setGenericPool({
293-
scope: grantScope,
294-
enabled: res.enabled === true || res.enabledEffective === true,
295-
strategy: normalizeAccountPoolStrategy(res.strategy),
296-
});
303+
setGenericPool(poolStateFrom(grantScope, res));
297304
});
298305
return () => { cancelled = true; };
299306
}, [apiBase, grantScope, isOauth, item.name]);
@@ -305,29 +312,24 @@ export default function ProviderAuthPanel({
305312
const generation = ++poolSaveGeneration.current;
306313
setGenericPool({ ...prev, enabled: nextEnabled });
307314
setPoolSaveError(null);
308-
void putPoolSettings(apiBase, item.name, {
309-
enabled: nextEnabled,
310-
strategy: prev.strategy,
311-
}).then(saved => {
315+
// Only the switch is written. Sending the strategy along would overwrite a stored name
316+
// this dashboard does not model with the default it was normalized to.
317+
void putPoolSettings(apiBase, item.name, { enabled: nextEnabled }).then(saved => {
312318
if (generation !== poolSaveGeneration.current) return;
313319
if (!saved) {
314320
setGenericPool(prev);
315321
setPoolSaveError(t("prov.updateFail"));
316322
return;
317323
}
318-
setGenericPool({
319-
scope: prev.scope,
320-
enabled: saved.enabled === true || saved.enabledEffective === true,
321-
strategy: normalizeAccountPoolStrategy(saved.strategy),
322-
});
324+
setGenericPool(poolStateFrom(prev.scope, saved));
323325
});
324326
}, [apiBase, genericPool, item.name, t]);
325327

326328
const handleSelectPoolStrategy = useCallback((nextStrategy: AccountPoolStrategy) => {
327329
if (!genericPool) return;
328330
const prev = genericPool;
329331
const generation = ++poolSaveGeneration.current;
330-
setGenericPool({ ...prev, strategy: nextStrategy });
332+
setGenericPool({ ...prev, strategy: nextStrategy, unmodeledStrategy: null });
331333
setPoolSaveError(null);
332334
void putPoolSettings(apiBase, item.name, {
333335
enabled: prev.enabled,
@@ -339,11 +341,7 @@ export default function ProviderAuthPanel({
339341
setPoolSaveError(t("prov.updateFail"));
340342
return;
341343
}
342-
setGenericPool({
343-
scope: prev.scope,
344-
enabled: saved.enabled === true || saved.enabledEffective === true,
345-
strategy: normalizeAccountPoolStrategy(saved.strategy),
346-
});
344+
setGenericPool(poolStateFrom(prev.scope, saved));
347345
});
348346
}, [apiBase, genericPool, item.name, t]);
349347

@@ -614,6 +612,8 @@ export default function ProviderAuthPanel({
614612
poolEnabled={genericPool?.enabled ?? false}
615613
onTogglePoolEnabled={handleTogglePoolEnabled}
616614
poolStrategy={genericPool?.strategy ?? DEFAULT_ACCOUNT_POOL_STRATEGY}
615+
poolInert={genericPool?.inert ?? false}
616+
poolUnmodeledStrategy={genericPool?.unmodeledStrategy ?? null}
617617
onSelectPoolStrategy={handleSelectPoolStrategy}
618618
/>
619619
{poolSaveError && (
@@ -646,6 +646,7 @@ export default function ProviderAuthPanel({
646646
/>
647647
) : undefined}
648648
refreshing={refreshingQuota && (refreshingAccountId === analyzed.account.id || !refreshingAccountId)}
649+
refreshBusy={refreshingQuota}
649650
onSwitch={acc => void authHandlers.onSwitchAccount(item.name, acc)}
650651
onRefreshSingle={canRefreshQuota ? acc => {
651652
setRefreshingAccountId(acc.id);

‎gui/src/i18n/de.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4031,7 +4031,7 @@ export const de: Record<TKey, string> = {
40314031
"genericPool.visualUsageAria": "Beispielnutzung des aktiven Kontos, Prozent",
40324032
"genericPool.visualStay": "Die nächste Anfrage bleibt auf dem aktiven Konto.",
40334033
"genericPool.visualSwitch": "Die nächste Anfrage wechselt zum nächsten angemeldeten Konto.",
4034-
"genericPool.visualResetFirst": "Verbraucht zuerst das Konto, dessen 7-Tage-Wochenkontingent am frühesten zurückgesetzt wird. Anfragen bleiben auf dem aktiven Konto bis zur Erschöpfung (100% oder 429), danach wird auf den nächsten frühesten Reset gewechselt.",
4034+
"genericPool.visualResetFirst": "Verbraucht zuerst das Konto, dessen 7-Tage-Wochenkontingent am frühesten zurückgesetzt wird (das 5-Stunden-Fenster, wenn kein Wochen-Reset bekannt ist). Anfragen bleiben auf dem aktiven Konto bis zur Erschöpfung (100% oder 429), danach wird auf den nächsten frühesten Reset gewechselt.",
40354035
"genericPool.visualQuota": "Quota behält das aktive Konto, bis ein 5-Stunden- oder Wochenfenster 100% erreicht oder ein 429 kommt. Die Schwelle wechselt nicht früher.",
40364036
"genericPool.visualFillFirst": "Fill-first würde das aktive Konto bis {threshold}% behalten und dann das nächste öffnen.",
40374037
"genericPool.visualRoundRobin": "Round-robin würde neue ungebundene Anfragen über bereite Konten verteilen.",

‎gui/src/i18n/en.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2642,7 +2642,7 @@ export const en = {
26422642
"genericPool.visualUsageAria": "Example usage on the active account, percent",
26432643
"genericPool.visualStay": "The next request stays on the active account.",
26442644
"genericPool.visualSwitch": "The next request moves to the next logged-in account.",
2645-
"genericPool.visualResetFirst": "Consumes the account whose 7-day weekly allowance resets earliest. Requests stay on the active account until exhausted (100% or 429), then switch to the next soonest reset.",
2645+
"genericPool.visualResetFirst": "Consumes the account whose 7-day weekly allowance resets earliest (the 5-hour window when no weekly reset is known). Requests stay on the active account until exhausted (100% or 429), then switch to the next soonest reset.",
26462646
"genericPool.visualQuota": "Quota keeps the active account until a 5-hour or weekly window hits 100%, or until a 429. The threshold does not switch earlier.",
26472647
"genericPool.visualFillFirst": "Fill-first would stay on the active account until usage reaches {threshold}%, then open the next one.",
26482648
"genericPool.visualRoundRobin": "Round-robin would spread new unbound requests across ready accounts.",

‎gui/src/i18n/fr.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4020,7 +4020,7 @@ export const fr: Record<TKey, string> = {
40204020
"genericPool.visualUsageAria": "Exemple d’utilisation du compte actif, en pourcentage",
40214021
"genericPool.visualStay": "La prochaine requête reste sur le compte actif.",
40224022
"genericPool.visualSwitch": "La prochaine requête passe au prochain compte connecté.",
4023-
"genericPool.visualResetFirst": "Consomme en priorité le compte dont le quota hebdomadaire de 7 jours expire le plus tôt. Les requêtes restent sur le compte actif jusqu'à épuisement (100% ou 429), puis basculent sur le prochain compte.",
4023+
"genericPool.visualResetFirst": "Consomme en priorité le compte dont le quota hebdomadaire de 7 jours expire le plus tôt (la fenêtre de 5 heures si aucune réinitialisation hebdomadaire n’est connue). Les requêtes restent sur le compte actif jusqu'à épuisement (100% ou 429), puis basculent sur le prochain compte.",
40244024
"genericPool.visualQuota": "Quota garde le compte actif jusqu’à 100% sur une fenêtre 5 h ou hebdomadaire, ou jusqu’à un 429. Le seuil ne bascule pas plus tôt.",
40254025
"genericPool.visualFillFirst": "Fill-first garderait le compte actif jusqu’à {threshold}%, puis ouvrirait le suivant.",
40264026
"genericPool.visualRoundRobin": "Round-robin répartirait les nouvelles requêtes non liées entre les comptes prêts.",

‎gui/src/i18n/ja.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4053,7 +4053,7 @@ export const ja: Record<TKey, string> = {
40534053
"genericPool.visualUsageAria": "アクティブアカウントの使用量の例(パーセント)",
40544054
"genericPool.visualStay": "次のリクエストはアクティブなアカウントに留まります。",
40554055
"genericPool.visualSwitch": "次のリクエストはログイン済みの次のアカウントへ移ります。",
4056-
"genericPool.visualResetFirst": "7日間の週間クォータが最も早くリセットされるアカウントを優先して消費します。リクエストは枯渇(100%または429)するまでアクティブなアカウントに留まり、次にリセットが近いアカウントへ切り替わります。",
4056+
"genericPool.visualResetFirst": "7日間の週間クォータが最も早くリセットされるアカウントを優先して消費します(週間リセットが不明な場合は5時間ウィンドウ)。リクエストは枯渇(100%または429)するまでアクティブなアカウントに留まり、次にリセットが近いアカウントへ切り替わります。",
40574057
"genericPool.visualQuota": "クォータは 5 時間または週次ウィンドウが 100% になるか 429 が来るまでアクティブアカウントを維持します。しきい値ではそれより早く切り替わりません。",
40584058
"genericPool.visualFillFirst": "フィルファーストなら使用量が {threshold}% に達するまでアクティブアカウントを維持し、その後次を開きます。",
40594059
"genericPool.visualRoundRobin": "ラウンドロビンなら新しい未紐付けリクエストを準備できたアカウントへ分散します。",

‎gui/src/i18n/ko.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4053,7 +4053,7 @@ export const ko: Record<TKey, string> = {
40534053
"genericPool.visualUsageAria": "활성 계정 사용량 예시, 퍼센트",
40544054
"genericPool.visualStay": "다음 요청은 활성 계정에 남습니다.",
40554055
"genericPool.visualSwitch": "다음 요청은 로그인한 다음 계정으로 넘어갑니다.",
4056-
"genericPool.visualResetFirst": "7일 주간 할당량이 가장 빨리 재설정되는 계정을 먼저 사용합니다. 요청은 소진(100% 또는 429)될 때까지 활성 계정에 유지된 후 다음으로 재설정이 빠른 계정으로 전환됩니다.",
4056+
"genericPool.visualResetFirst": "7일 주간 할당량이 가장 빨리 재설정되는 계정을 먼저 사용합니다(주간 재설정을 알 수 없으면 5시간 창). 요청은 소진(100% 또는 429)될 때까지 활성 계정에 유지된 후 다음으로 재설정이 빠른 계정으로 전환됩니다.",
40574057
"genericPool.visualQuota": "할당량은 5시간 또는 주간 창이 100%가 되거나 429가 올 때까지 활성 계정을 유지합니다. 임계값은 더 일찍 바꾸지 않습니다.",
40584058
"genericPool.visualFillFirst": "필 퍼스트는 사용량이 {threshold}%에 이를 때까지 활성 계정을 유지한 뒤 다음 계정을 엽니다.",
40594059
"genericPool.visualRoundRobin": "라운드로빈은 새 미바인딩 요청을 준비된 계정에 나눕니다.",

0 commit comments

Comments
 (0)