diff --git a/src/renderer/src/components/status-bar/StatusBar.tsx b/src/renderer/src/components/status-bar/StatusBar.tsx index feda8c73787..0b743442da4 100644 --- a/src/renderer/src/components/status-bar/StatusBar.tsx +++ b/src/renderer/src/components/status-bar/StatusBar.tsx @@ -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({ { event.preventDefault() - setAccountsExpanded((prev) => !prev) + handleAccountsExpandedToggle() }} >