From f77c912fa68df51e741aef182115af767a456662 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Fri, 29 May 2026 20:14:50 -0700 Subject: [PATCH] Fetch Codex account usage on expand --- .../src/components/status-bar/StatusBar.tsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) 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() }} >