From da8a1be9c284fc7f8765e2919b6721f8f6274f41 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sat, 30 May 2026 11:42:40 -0700 Subject: [PATCH] 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 --------- Co-authored-by: Jinwoo-H Co-authored-by: Orca --- src/renderer/src/components/status-bar/StatusBar.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/renderer/src/components/status-bar/StatusBar.tsx b/src/renderer/src/components/status-bar/StatusBar.tsx index 96bcb24da..6de4255c0 100644 --- a/src/renderer/src/components/status-bar/StatusBar.tsx +++ b/src/renderer/src/components/status-bar/StatusBar.tsx @@ -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({ { event.preventDefault() - setAccountsExpanded((prev) => !prev) + handleAccountsExpandedToggle() }} >