Avoid side effects in Codex account toggle updater

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Jinwoo-H
2026-05-30 00:51:08 -07:00
co-authored by Orca
parent f77c912fa6
commit 95aa500800
@@ -1091,16 +1091,14 @@ function CodexSwitcherMenu({
}, [])
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 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])
const selectedRuntimeKey = getCodexStatusRuntimeKey(
normalizeCodexStatusRuntimeTarget(accountState, toCodexStatusRuntimeTarget(codexTarget))