From 95aa5008009dba54c98602e4a00a027355806167 Mon Sep 17 00:00:00 2001 From: Jinwoo-H Date: Sat, 30 May 2026 00:51:08 -0700 Subject: [PATCH] Avoid side effects in Codex account toggle updater Co-authored-by: Orca --- .../src/components/status-bar/StatusBar.tsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/renderer/src/components/status-bar/StatusBar.tsx b/src/renderer/src/components/status-bar/StatusBar.tsx index 0b743442da4..6d6032ea136 100644 --- a/src/renderer/src/components/status-bar/StatusBar.tsx +++ b/src/renderer/src/components/status-bar/StatusBar.tsx @@ -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))