Fetch inactive account usage on expand (#3340)

* Fetch inactive account usage on expand

* Keep Claude usage fetch outside state updater

Co-authored-by: Orca <help@stably.ai>

---------

Co-authored-by: Jinwoo-H <jinwoo0825@gmail.com>
Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Neil
2026-05-30 17:56:57 -07:00
committed by GitHub
co-authored by Orca Jinwoo-H
parent 32d7110e0c
commit cca9ea9f29
@@ -643,8 +643,12 @@ function ClaudeSwitcherMenu({
}
}, [])
useEffect(() => {
if (accountsExpanded) {
// Why: inactive-account usage is needed only for the explicit switcher
// expansion, so fetch it on that event instead of one render later.
const handleAccountsExpandedToggle = useCallback((): void => {
const nextExpanded = !accountsExpanded
setAccountsExpanded(nextExpanded)
if (nextExpanded) {
void fetchInactiveClaudeAccountUsage()
}
}, [accountsExpanded, fetchInactiveClaudeAccountUsage])
@@ -735,7 +739,7 @@ function ClaudeSwitcherMenu({
<DropdownMenuItem
onSelect={(event) => {
event.preventDefault()
setAccountsExpanded((prev) => !prev)
handleAccountsExpandedToggle()
}}
>
<span className="max-w-[180px] truncate text-[12px] text-foreground">