Skip to content

Commit 76e4938

Browse files
committed
fix: apply Codex quota refresh before history scan
1 parent 5c6b439 commit 76e4938

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

menubar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ def _refresh_in_background(self) -> None:
893893
self.performSelectorOnMainThread_withObject_waitUntilDone_(
894894
"_applyCodexRefreshResult:",
895895
codex_result,
896-
False,
896+
True,
897897
)
898898
fallback_state = getattr(self, "latest_state", _empty_state(self.language))
899899
project_rows = list(fallback_state.projects)

tests/test_menubar.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,7 @@ def button(self) -> FakeButton:
13421342

13431343
def test_refresh_error_preserves_codex_quota() -> None:
13441344
captured: dict[str, object] = {}
1345+
calls: list[tuple[str, bool]] = []
13451346
session = menubar_state.QuotaRowState(
13461347
title="Session",
13471348
percent=1.0,
@@ -1372,6 +1373,7 @@ def _load_codex_refresh_result(self) -> dict[str, object]:
13721373
def performSelectorOnMainThread_withObject_waitUntilDone_(
13731374
self, selector: str, result: dict[str, object], wait: bool
13741375
) -> None:
1376+
calls.append((selector, wait))
13751377
captured["selector"] = selector
13761378
captured["result"] = result
13771379
captured["wait"] = wait
@@ -1389,6 +1391,10 @@ async def _fetch(self) -> PollOutcome:
13891391
assert state.codex_weekly == weekly
13901392
assert result["codex_5h_pct"] == 1.0
13911393
assert result["codex_model"] == "gpt-test"
1394+
assert calls == [
1395+
("_applyCodexRefreshResult:", True),
1396+
("_applyRefreshResult:", False),
1397+
]
13921398

13931399

13941400
def test_refresh_error_preserves_project_usage() -> None:

0 commit comments

Comments
 (0)