Fetch Codex account usage on expand (#3435)

* Fetch Codex account usage on expand

* Avoid side effects in Codex account toggle updater

Co-authored-by: Orca <help@stably.ai>

---------

Co-authored-by: Jinwoo-H <jinwoo0825@gmail.com>
Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Neil
2026-05-30 14:42:40 -04:00
committed by GitHub
co-authored by Orca Jinwoo-H
parent 502f37b01e
commit da8a1be9c2
@@ -1211,8 +1211,12 @@ function CodexSwitcherMenu({
}
}, [])
useEffect(() => {
if (accountsExpanded) {
const handleAccountsExpandedToggle = useCallback((): void => {
const nextExpanded = !accountsExpanded
setAccountsExpanded(nextExpanded)
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()
}
}, [accountsExpanded, fetchInactiveCodexAccountUsage])
@@ -1257,7 +1261,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]">