Fetch Codex account usage on expand

This commit is contained in:
Neil
2026-05-29 20:14:50 -07:00
parent c0580bf12b
commit f77c912fa6
@@ -1090,11 +1090,17 @@ function CodexSwitcherMenu({
}
}, [])
useEffect(() => {
if (accountsExpanded) {
void fetchInactiveCodexAccountUsage()
}
}, [accountsExpanded, fetchInactiveCodexAccountUsage])
const handleAccountsExpandedToggle = useCallback((): void => {
setAccountsExpanded((current) => {
const nextExpanded = !current
if (nextExpanded) {
// Why: inactive-account usage is needed only for the explicit switcher
// expansion, so fetch it on that event instead of one render later.
void fetchInactiveCodexAccountUsage()
}
return nextExpanded
})
}, [fetchInactiveCodexAccountUsage])
const selectedRuntimeKey = getCodexStatusRuntimeKey(
normalizeCodexStatusRuntimeTarget(accountState, toCodexStatusRuntimeTarget(codexTarget))
@@ -1136,7 +1142,7 @@ function CodexSwitcherMenu({
<DropdownMenuItem
onSelect={(event) => {
event.preventDefault()
setAccountsExpanded((prev) => !prev)
handleAccountsExpandedToggle()
}}
>
<div className="flex min-w-0 flex-1 flex-col gap-0.5 py-0.5 text-[12px]">