usage-cli 0.32.2__py3-none-any.whl → 0.32.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
menubar/agy.py CHANGED
@@ -213,20 +213,20 @@ def _remaining_percent(window: AgyQuotaWindow) -> float:
213
213
  return max(0.0, min(100.0, float(window.remaining_percent)))
214
214
 
215
215
 
216
- def _cache_age_minutes(fetched_at: str, now: float) -> int:
217
- """Whole minutes since the cached snapshot was taken (never negative)."""
216
+ def _cache_age_minutes(fetched_at: str, now: float) -> float:
217
+ """Minutes since the cached snapshot was taken (never negative)."""
218
218
  try:
219
219
  age_seconds = now - parse_iso8601_utc_or_raise(fetched_at).timestamp()
220
220
  except (TypeError, ValueError):
221
221
  return 0
222
- return max(0, int(age_seconds // 60))
222
+ return max(0.0, age_seconds / 60)
223
223
 
224
224
 
225
225
  def _window_row(
226
226
  title: str,
227
227
  window: AgyQuotaWindow,
228
228
  language: str,
229
- age_minutes: int = 0,
229
+ age_minutes: float = 0,
230
230
  forecast_seconds: float | None = None,
231
231
  warning_max_seconds: float | None = None,
232
232
  *,
@@ -236,12 +236,20 @@ def _window_row(
236
236
  used = 100.0 - remaining
237
237
  warning = False
238
238
  warning_seconds: float | None = None
239
- if remaining == 100.0:
239
+ reset_done = window.resets_in_minutes is not None and window.resets_in_minutes <= max(
240
+ 0, age_minutes
241
+ )
242
+ if reset_done:
243
+ used = 0.0
244
+ reset_text = _t(language, "reset_done")
245
+ elif remaining == 100.0:
240
246
  reset_text = _t(language, "agy_quota_full")
241
247
  elif window.resets_in_minutes is None:
242
248
  reset_text = _t(language, "reset_placeholder")
249
+ elif window.resets_in_minutes - max(0, age_minutes) < 1:
250
+ reset_text = _t(language, "reset_imminent")
243
251
  else:
244
- minutes_left = max(1, window.resets_in_minutes - max(0, age_minutes))
252
+ minutes_left = window.resets_in_minutes - int(max(0, age_minutes))
245
253
  time_to_reset = minutes_left * 60
246
254
  if window_seconds is None:
247
255
  if (
@@ -275,12 +283,13 @@ def _window_row(
275
283
  )
276
284
  return QuotaRowState(
277
285
  title=title,
278
- percent=used,
286
+ percent=100.0 - remaining,
279
287
  percent_text=_t(language, "percent_used", value=_format_percent(used)),
280
288
  reset_text=reset_text,
281
289
  color=_bar_color(used, AGY_COLOR),
282
290
  warning=warning,
283
291
  available=True,
292
+ reset_done=reset_done,
284
293
  )
285
294
 
286
295
 
menubar/app.py CHANGED
@@ -70,6 +70,7 @@ from loaders.history_loader import (
70
70
  flush_caches_on_terminate as flush_history_cache,
71
71
  )
72
72
  from menubar import actions as menubar_actions
73
+ from menubar import manual_refresh
73
74
  from menubar import menu as menubar_menu
74
75
  from menubar import notify as menubar_notify
75
76
  from menubar import refresh as menubar_refresh
@@ -419,7 +420,7 @@ class AppDelegate(NSObject):
419
420
  self._panel_window_did_hide()
420
421
 
421
422
  def refreshNow_(self, sender: Any) -> None:
422
- self._refresh(queue_if_busy=True)
423
+ manual_refresh.start_mac(self)
423
424
 
424
425
  def installHook_(self, sender: Any) -> None:
425
426
  thread = threading.Thread(target=self._install_hook_in_background, daemon=True)
@@ -822,7 +823,7 @@ class AppDelegate(NSObject):
822
823
  codex_model = result.get("codex_model", "unknown")
823
824
  self.codex_5h_pct = codex_5h_pct
824
825
  self.codex_model = codex_model
825
- self.latest_state = state
826
+ self.latest_state = manual_refresh.finish_mac(self, state)
826
827
  self._process_quota_notifications(state)
827
828
  if self._panel_window_is_visible():
828
829
  self.popover_controller.setState_(self.latest_state)
@@ -831,8 +832,7 @@ class AppDelegate(NSObject):
831
832
  menubar_title._set_button_title(self, state)
832
833
  finally:
833
834
  should_refresh_again = bool(self._refresh_queued)
834
- self._refresh_queued = False
835
- self._refresh_in_flight = False
835
+ self._refresh_queued = self._refresh_in_flight = False
836
836
  if should_refresh_again:
837
837
  self._refresh()
838
838
  if started_at:
@@ -842,7 +842,7 @@ class AppDelegate(NSObject):
842
842
  )
843
843
 
844
844
  def _clearRefreshInFlight_(self, _sender: Any) -> None:
845
- self._refresh_in_flight = False
845
+ manual_refresh.fail_mac(self)
846
846
 
847
847
  def _load_codex_refresh_result(self) -> dict[str, Any]:
848
848
  history_scan = None if self.mock else self._history_source_scan()
menubar/grok.py CHANGED
@@ -18,9 +18,7 @@ from menubar.state import (
18
18
  GROK_COLOR,
19
19
  GrokStaleState,
20
20
  QuotaRowState,
21
- _bar_color,
22
- _format_percent,
23
- format_human_time,
21
+ _quota_row,
24
22
  )
25
23
  from usage_common.time_utils import parse_iso8601_utc_or_raise
26
24
 
@@ -56,22 +54,15 @@ def project_quota(
56
54
  period_end = parse_iso8601_utc_or_raise(quota.period_end).timestamp()
57
55
  except (TypeError, ValueError):
58
56
  return None
59
- if period_end < current_time:
60
- return None
61
57
  stale = _stale_state(quota.fetched_at, current_time, language)
62
- used = max(0.0, min(100.0, quota.used_percent))
63
58
  return GrokQuotaProjection(
64
- weekly=QuotaRowState(
65
- title=_t(language, "weekly_label"),
66
- percent=used,
67
- percent_text=_t(language, "percent_used", value=_format_percent(used)),
68
- reset_text=_t(
69
- language,
70
- "reset_in",
71
- time=format_human_time(max(0.0, period_end - current_time), language),
72
- ),
73
- color=_bar_color(used, GROK_COLOR),
74
- available=True,
59
+ weekly=_quota_row(
60
+ _t(language, "weekly_label"),
61
+ quota.used_percent,
62
+ period_end,
63
+ current_time,
64
+ GROK_COLOR,
65
+ language,
75
66
  ),
76
67
  stale=stale,
77
68
  )
@@ -0,0 +1,51 @@
1
+ """Status-chip feedback for user-requested refreshes."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ from i18n import _t
8
+ from menubar.state import PopoverState
9
+
10
+
11
+ def begin(state: PopoverState, *, queued: bool = False) -> None:
12
+ if state.refresh_status is None:
13
+ state.refresh_status = (state.status_text, state.status_long)
14
+ state.refresh_queued = state.refresh_queued or queued
15
+ state.status_text = _t(
16
+ state.language, "status_text", value=_t(state.language, "status_refreshing")
17
+ )
18
+ state.status_long = False
19
+
20
+
21
+ def finish(
22
+ previous: PopoverState | None, state: PopoverState, *, queued: bool = False
23
+ ) -> PopoverState:
24
+ if previous is not None and previous.refresh_status is not None:
25
+ keep = previous.refresh_queued and queued
26
+ previous.status_text, previous.status_long = previous.refresh_status
27
+ previous.refresh_status = None
28
+ previous.refresh_queued = False
29
+ if keep:
30
+ begin(state)
31
+ return state
32
+
33
+
34
+ def finish_mac(app: Any, state: PopoverState) -> PopoverState:
35
+ return finish(app.latest_state, state, queued=bool(app._refresh_queued))
36
+
37
+
38
+ def start_mac(app: Any) -> None:
39
+ begin(app.latest_state, queued=bool(app._refresh_in_flight))
40
+ app._refresh(queue_if_busy=True)
41
+ if app._panel_window_is_visible():
42
+ app.popover_controller.setState_(app.latest_state)
43
+
44
+
45
+ def fail_mac(app: Any) -> None:
46
+ state = getattr(app, "latest_state", None)
47
+ if state is not None:
48
+ finish(state, state)
49
+ app._refresh_in_flight = False
50
+ if state is not None and app._panel_window_is_visible():
51
+ app.popover_controller.setState_(state)
menubar/state.py CHANGED
@@ -99,6 +99,13 @@ class QuotaRowState:
99
99
  warning: bool = False
100
100
  available: bool = True
101
101
  reset_text_compact: str = ""
102
+ reset_done: bool = False
103
+
104
+ # Keep percent unchanged for quota notifications; renderers use display_percent.
105
+
106
+ @property
107
+ def display_percent(self) -> float | None:
108
+ return 0.0 if self.reset_done else self.percent
102
109
 
103
110
 
104
111
  class CodexStaleState(TypedDict):
@@ -156,6 +163,8 @@ class PopoverState:
156
163
  grok_stale: GrokStaleState | None = None
157
164
  card_order: tuple[str, ...] = ("claude", "codex", "agy", "grok")
158
165
  history_error: HistoryLoadErrorState | None = None
166
+ refresh_status: tuple[str, bool] | None = None
167
+ refresh_queued: bool = False
159
168
 
160
169
 
161
170
  @dataclass(frozen=True, slots=True)
@@ -970,7 +979,10 @@ def _quota_row(
970
979
  pct = max(0.0, min(100.0, float(pct)))
971
980
  time_to_reset = resets_at - now
972
981
  warning_seconds: float | None = None
973
- if time_to_reset < 60:
982
+ if time_to_reset <= 0:
983
+ reset_text = _t(language, "reset_done")
984
+ warning = False
985
+ elif time_to_reset < 60:
974
986
  reset_text = _t(language, "reset_imminent")
975
987
  warning = False
976
988
  else:
@@ -1007,11 +1019,14 @@ def _quota_row(
1007
1019
  row = QuotaRowState(
1008
1020
  title=title,
1009
1021
  percent=pct,
1010
- percent_text=_t(language, "percent_used", value=_format_percent(pct)),
1022
+ percent_text=_t(
1023
+ language, "percent_used", value=_format_percent(0.0 if time_to_reset <= 0 else pct)
1024
+ ),
1011
1025
  reset_text=reset_text,
1012
- color=_bar_color(pct, color),
1026
+ color=_bar_color(0.0 if time_to_reset <= 0 else pct, color),
1013
1027
  warning=warning,
1014
1028
  available=True,
1029
+ reset_done=time_to_reset <= 0,
1015
1030
  )
1016
1031
  if warning_seconds is not None:
1017
1032
  row.reset_text_compact = _t(
menubar/title.py CHANGED
@@ -66,20 +66,22 @@ def _menubar_attributed_title(app: _TitleApp, state: PopoverState) -> Any:
66
66
  if not state.hide_claude:
67
67
  claude_percent = (
68
68
  "--"
69
- if state.claude_session.percent is None
70
- else f"{_format_percent(state.claude_session.percent)}%"
69
+ if state.claude_session.display_percent is None
70
+ else f"{_format_percent(state.claude_session.display_percent)}%"
71
71
  )
72
72
  title.appendAttributedString_(_menubar_icon_attachment_string(_claude_menubar_icon()))
73
73
  title.appendAttributedString_(_menubar_text_string(app, f" {claude_percent}"))
74
74
  if not state.hide_codex and (app.codex_5h_pct is not None or state.hide_claude):
75
- codex_percent = (
76
- "--" if app.codex_5h_pct is None else f"{_format_percent(float(app.codex_5h_pct))}%"
75
+ codex_row = (
76
+ state.codex_session if state.codex_session.percent is not None else state.codex_weekly
77
77
  )
78
+ codex_used = 0.0 if codex_row.reset_done else app.codex_5h_pct
79
+ codex_percent = "--" if codex_used is None else f"{_format_percent(float(codex_used))}%"
78
80
  if not state.hide_claude:
79
81
  title.appendAttributedString_(_menubar_text_string(app, " "))
80
82
  title.appendAttributedString_(_menubar_icon_attachment_string(_codex_menubar_icon()))
81
83
  title.appendAttributedString_(_menubar_text_string(app, f" {codex_percent}"))
82
- agy_session_percent = state.agy_session.percent
84
+ agy_session_percent = state.agy_session.display_percent
83
85
  agy_visible = not state.hide_agy and agy_session_percent is not None
84
86
  if agy_visible:
85
87
  assert agy_session_percent is not None
@@ -88,7 +90,7 @@ def _menubar_attributed_title(app: _TitleApp, state: PopoverState) -> Any:
88
90
  title.appendAttributedString_(_menubar_text_string(app, " "))
89
91
  title.appendAttributedString_(_menubar_icon_attachment_string(_agy_menubar_icon()))
90
92
  title.appendAttributedString_(_menubar_text_string(app, f" {agy_percent}"))
91
- grok_weekly_percent = state.grok_weekly.percent
93
+ grok_weekly_percent = state.grok_weekly.display_percent
92
94
  grok_visible = not state.hide_grok and grok_weekly_percent is not None
93
95
  if grok_visible:
94
96
  assert grok_weekly_percent is not None
@@ -123,18 +125,22 @@ def _compose_title(app: _TitleApp, state: PopoverState) -> str:
123
125
  if not state.hide_claude:
124
126
  claude = (
125
127
  "--"
126
- if state.claude_session.percent is None
127
- else f"{_format_percent(state.claude_session.percent)}%"
128
+ if state.claude_session.display_percent is None
129
+ else f"{_format_percent(state.claude_session.display_percent)}%"
128
130
  )
129
131
  parts.append(claude)
130
132
  if not state.hide_codex and (app.codex_5h_pct is not None or state.hide_claude):
131
- codex = "--" if app.codex_5h_pct is None else f"{_format_percent(float(app.codex_5h_pct))}%"
133
+ codex_row = (
134
+ state.codex_session if state.codex_session.percent is not None else state.codex_weekly
135
+ )
136
+ codex_used = 0.0 if codex_row.reset_done else app.codex_5h_pct
137
+ codex = "--" if codex_used is None else f"{_format_percent(float(codex_used))}%"
132
138
  parts.append(codex)
133
- if not state.hide_agy and state.agy_session.percent is not None:
134
- agy = f"{_format_percent(state.agy_session.percent)}%"
139
+ if not state.hide_agy and state.agy_session.display_percent is not None:
140
+ agy = f"{_format_percent(state.agy_session.display_percent)}%"
135
141
  parts.append(agy)
136
- if not state.hide_grok and state.grok_weekly.percent is not None:
137
- grok = f"{_format_percent(state.grok_weekly.percent)}%"
142
+ if not state.hide_grok and state.grok_weekly.display_percent is not None:
143
+ grok = f"{_format_percent(state.grok_weekly.display_percent)}%"
138
144
  parts.append(grok)
139
145
  # Both providers hidden: keep a recognizable, clickable status item.
140
146
  return " · ".join(parts) if parts else "usage"
panels/payload.py CHANGED
@@ -91,7 +91,7 @@ def _data_uri(asset_name: str) -> str:
91
91
 
92
92
  def _row_payload(row: QuotaRowState) -> dict[str, object]:
93
93
  return {
94
- "percent": row.percent,
94
+ "percent": row.display_percent,
95
95
  "percentText": row.percent_text,
96
96
  "resetText": row.reset_text,
97
97
  "resetTextCompact": row.reset_text_compact or row.reset_text,
@@ -56,6 +56,7 @@
56
56
  "data_stale_hint": "資料來自備援來源,建議檢查設定",
57
57
  "status_loading": "載入中",
58
58
  "status_synced": "✓ 已同步",
59
+ "status_refreshing": "↻ 更新中…",
59
60
  "status_no_data": "無資料",
60
61
  "awaiting_rate_limits": "請對 Claude Code 發送一句訊息以同步配額",
61
62
  "hook_broken_not_installed": "⚠ 狀態列沒在更新,請按「設定狀態列」重新安裝",
@@ -75,6 +76,7 @@
75
76
  "percent_used": "{value}% 已用",
76
77
  "reset_in": "重置 {time}",
77
78
  "reset_imminent": "即將重置",
79
+ "reset_done": "已重置",
78
80
  "burn_warning": "⚠ 照目前速度 {empty}後用完 · 重置 {reset}",
79
81
  "burn_warning_compact": "⚠ {empty}後用完",
80
82
  "reset_placeholder": "重置 --",
@@ -490,6 +492,7 @@
490
492
  "claude_pane_invalid_sidecar": "usage-pane.json 格式錯誤",
491
493
  "claude_pane_elapsed": "{minutes}分{seconds}秒",
492
494
  "claude_pane_remaining": "剩",
495
+ "claude_pane_reset_done": "已重置",
493
496
  "claude_pane_hours_ago": "{count}時前"
494
497
  },
495
498
  "en": {
@@ -549,6 +552,7 @@
549
552
  "data_stale_hint": "Data is from a fallback source. Check settings.",
550
553
  "status_loading": "Loading",
551
554
  "status_synced": "✓ Synced",
555
+ "status_refreshing": "↻ Refreshing…",
552
556
  "status_no_data": "No data",
553
557
  "awaiting_rate_limits": "Send a message in Claude Code to sync your quota",
554
558
  "hook_broken_not_installed": "⚠ Status line is not updating. Click \"Set Up Status Line\" to reinstall it.",
@@ -568,6 +572,7 @@
568
572
  "percent_used": "{value}% used",
569
573
  "reset_in": "Resets in {time}",
570
574
  "reset_imminent": "Reset imminent",
575
+ "reset_done": "Reset",
571
576
  "burn_warning": "⚠ At this pace, empty in {empty} · resets in {reset}",
572
577
  "burn_warning_compact": "⚠ Empty in {empty}",
573
578
  "reset_placeholder": "Resets in --",
@@ -983,6 +988,7 @@
983
988
  "claude_pane_invalid_sidecar": "Invalid usage-pane.json",
984
989
  "claude_pane_elapsed": "{minutes}m{seconds}s",
985
990
  "claude_pane_remaining": "left",
991
+ "claude_pane_reset_done": "Reset",
986
992
  "claude_pane_hours_ago": "{count}h ago"
987
993
  },
988
994
  "zh-CN": {
@@ -1042,6 +1048,7 @@
1042
1048
  "data_stale_hint": "数据来自备用来源,建议检查设置",
1043
1049
  "status_loading": "加载中",
1044
1050
  "status_synced": "✓ 已同步",
1051
+ "status_refreshing": "↻ 更新中…",
1045
1052
  "status_no_data": "无数据",
1046
1053
  "awaiting_rate_limits": "请对 Claude Code 发送一句消息以同步配额",
1047
1054
  "hook_broken_not_installed": "⚠ 状态栏没有更新,请点「设置状态栏」重新安装",
@@ -1061,6 +1068,7 @@
1061
1068
  "percent_used": "{value}% 已用",
1062
1069
  "reset_in": "重置 {time}",
1063
1070
  "reset_imminent": "即将重置",
1071
+ "reset_done": "已重置",
1064
1072
  "burn_warning": "⚠ 按当前速度 {empty}后用完 · 重置 {reset}",
1065
1073
  "burn_warning_compact": "⚠ {empty}后用完",
1066
1074
  "reset_placeholder": "重置 --",
@@ -1476,6 +1484,7 @@
1476
1484
  "claude_pane_invalid_sidecar": "usage-pane.json 格式错误",
1477
1485
  "claude_pane_elapsed": "{minutes}分{seconds}秒",
1478
1486
  "claude_pane_remaining": "剩",
1487
+ "claude_pane_reset_done": "已重置",
1479
1488
  "claude_pane_hours_ago": "{count}时前"
1480
1489
  },
1481
1490
  "ja": {
@@ -1535,6 +1544,7 @@
1535
1544
  "data_stale_hint": "データはフォールバック元から取得しています。設定を確認してください。",
1536
1545
  "status_loading": "読み込み中",
1537
1546
  "status_synced": "✓ 同期済み",
1547
+ "status_refreshing": "↻ 更新中…",
1538
1548
  "status_no_data": "データなし",
1539
1549
  "awaiting_rate_limits": "Claude Code にメッセージを送信してクォータを同期してください",
1540
1550
  "hook_broken_not_installed": "⚠ ステータスラインが更新されていません。「ステータスラインを設定」を押して再インストールしてください。",
@@ -1554,6 +1564,7 @@
1554
1564
  "percent_used": "{value}% 使用済み",
1555
1565
  "reset_in": "{time}後にリセット",
1556
1566
  "reset_imminent": "まもなくリセット",
1567
+ "reset_done": "リセット済み",
1557
1568
  "burn_warning": "⚠ このペースで{empty}で使い切り·リセット{reset}",
1558
1569
  "burn_warning_compact": "⚠ {empty}で使い切り",
1559
1570
  "reset_placeholder": "リセット --",
@@ -1969,6 +1980,7 @@
1969
1980
  "claude_pane_invalid_sidecar": "usage-pane.json の形式が不正です",
1970
1981
  "claude_pane_elapsed": "{minutes}分{seconds}秒",
1971
1982
  "claude_pane_remaining": "残り",
1983
+ "claude_pane_reset_done": "リセット済み",
1972
1984
  "claude_pane_hours_ago": "{count}時間前"
1973
1985
  },
1974
1986
  "ko": {
@@ -2028,6 +2040,7 @@
2028
2040
  "data_stale_hint": "데이터가 대체 소스에서 왔습니다. 설정을 확인하세요.",
2029
2041
  "status_loading": "불러오는 중",
2030
2042
  "status_synced": "✓ 동기화됨",
2043
+ "status_refreshing": "↻ 새로 고치는 중…",
2031
2044
  "status_no_data": "데이터 없음",
2032
2045
  "awaiting_rate_limits": "Claude Code에 메시지를 보내 할당량을 동기화하세요",
2033
2046
  "hook_broken_not_installed": "⚠ 상태 표시줄이 업데이트되지 않습니다. \"상태 표시줄 설정\"을 눌러 다시 설치하세요.",
@@ -2047,6 +2060,7 @@
2047
2060
  "percent_used": "{value}% 사용됨",
2048
2061
  "reset_in": "{time} 후 초기화",
2049
2062
  "reset_imminent": "곧 초기화",
2063
+ "reset_done": "리셋됨",
2050
2064
  "burn_warning": "⚠ 현재 속도면 {empty} 후 소진 · 초기화까지 {reset}",
2051
2065
  "burn_warning_compact": "⚠ {empty} 후 소진",
2052
2066
  "reset_placeholder": "초기화까지 --",
@@ -2462,6 +2476,7 @@
2462
2476
  "claude_pane_invalid_sidecar": "usage-pane.json 형식이 잘못되었습니다",
2463
2477
  "claude_pane_elapsed": "{minutes}분{seconds}초",
2464
2478
  "claude_pane_remaining": "남음",
2479
+ "claude_pane_reset_done": "리셋됨",
2465
2480
  "claude_pane_hours_ago": "{count}시간 전"
2466
2481
  }
2467
2482
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: usage-cli
3
- Version: 0.32.2
3
+ Version: 0.32.3
4
4
  Summary: usage — 在 macOS menu bar 與 Windows 系統匣顯示 Claude Code、Codex、Antigravity 用量的小工具(也提供終端機 TUI)
5
5
  License-Expression: AGPL-3.0-only
6
6
  Requires-Python: >=3.13
@@ -65,18 +65,19 @@ loaders/jsonl_utils.py,sha256=fWMDCP2skgNvdERLevxaQtcEB7nFzgSG_vxjPJpB0ug,1118
65
65
  loaders/muse_loader.py,sha256=906pUoUVH7tNdddRpfZYzHOhCsxXmiPMU1HRMLFD4Z8,6438
66
66
  menubar/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
67
67
  menubar/actions.py,sha256=EZIgfpQiphJ5Zy5LzkZ9d1ngT9pb_uWrxz7BWdg7RZw,8408
68
- menubar/agy.py,sha256=LEbdRn_wBYkASZ8vlMSOI5l7RRMWnw8_YO1PaQAo4a4,10355
69
- menubar/app.py,sha256=tPVEwlIgKkcQ9RAg3NSDAXQcNi0CYGqFkO0uSY_DLEg,41964
68
+ menubar/agy.py,sha256=AV_Dn7GctMrnyrMTbA2RuWXlLEK7jBv7qsX1TJKsJts,10711
69
+ menubar/app.py,sha256=0imKzQ3VSQi4eQlFjKpoGJE2ANFsRz6sYeJWUnncNIk,42009
70
70
  menubar/chrome.py,sha256=So9CEw7cGKpVtaY3lEQR3xLJvotdipZcs7e3r1bRq3w,5119
71
- menubar/grok.py,sha256=c7pzFtAJ-Cs3JUQqxFd0KmGePw29YakNbmGUGczjw08,3945
71
+ menubar/grok.py,sha256=9-ElLqhsLgnvgE3t7zK6KXUSu3uQYQOaLj0aVAgl82c,3545
72
+ menubar/manual_refresh.py,sha256=gWh03HAfj1gxEZkl8_YmFKDLQlT8nl-VySBVAgSFTOw,1662
72
73
  menubar/menu.py,sha256=ezuqbNTzaE-Bau5DCgtBgCY1297LQt46DKhypWyUzPk,6424
73
74
  menubar/new_badge.py,sha256=I7A4AAoDO4hMWGSLXfNxVFC6zLTZYrLJckF0ZEFbH3k,3277
74
75
  menubar/notify.py,sha256=ozWCNtSye_kZZILHnejgpFMjcArU8yGOfbX8N1r4dVY,3476
75
76
  menubar/popover.py,sha256=qYU02aQ359nq6g13BjqK4W0izI2fGgQXAG6U_UIcIdQ,11594
76
77
  menubar/prefs.py,sha256=uk5F_B7Ul7i0h6NQDt7oj89cL1RaW2qsFss6lCVkMEQ,5166
77
78
  menubar/refresh.py,sha256=R8aYRa-1PBU5nQ9i5Bgr4VQK5GEqnCdmWI-LmbnYU9w,11217
78
- menubar/state.py,sha256=p1MacjdQO7melcSyh3KSXnuXmAju2x3hZLvTtVQ7Y78,43200
79
- menubar/title.py,sha256=2_7AMHNkfeVDMG5_dPc1GzWyItIwe5dWmpgym2SxmwA,5516
79
+ menubar/state.py,sha256=XZb8kDJaxaYTpek3MFDuajpHKDjQOgiiatJmaCDKuUk,43741
80
+ menubar/title.py,sha256=nt5aGzKjfk3UtpDZj5TYyNk7T9SEFubMWJgxjuVeh2o,5952
80
81
  menubar/update.py,sha256=U1F9HiLy4qLYKKs_jvIbdPOdH2FQPHmlGgM1ec6wMlg,3826
81
82
  panels/__init__.py,sha256=ryL7R_PT9ureS00w4Wr_fl2vMHoRvsLJ5MyrES5_B_Y,7649
82
83
  panels/base.py,sha256=XJUZLN0wP_kXzUaaeReCxu6bS0QGbhh3xP55K0yRxr8,2777
@@ -84,7 +85,7 @@ panels/dynamic_height.py,sha256=Qio6Thnqih7QOriI79ta94PIK6Wozp7fjLy9cyFeE7M,9716
84
85
  panels/panel_scale.py,sha256=z-8THYvI4usWDVWPz-k2LGuDz6jjDEViFl91-vikpEM,1779
85
86
  panels/panel_window.py,sha256=cHitXmmBd-P1XjG_lyGJJTtqARM7aAAQV7BxB84ccNQ,2507
86
87
  panels/panel_window_state.py,sha256=E83mqXRPoWSUk4qT3uMlSXARuobmdArD1UrsfHRwB8o,5059
87
- panels/payload.py,sha256=njpu7t_TFvgmmmQK5nFq3eNvEHp36f32CnBztoM45gY,5838
88
+ panels/payload.py,sha256=JUB-H5wM2NDA5n2qOhBprUR5oOPg01qjIYPVDWmVaUc,5846
88
89
  panels/web_panel.py,sha256=kOhgSBkWLfGC_-bO9SauPRlo0aaXVkH1w4Ya0-5x8pY,18250
89
90
  panels/window_drag.py,sha256=a86iAOMEDK6AIuJr1TeGQDjP7MsN3Y0Qd5A6RKI6I5A,1776
90
91
  quota/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -109,8 +110,8 @@ updates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
109
110
  updates/checker.py,sha256=tgAwczfX9gj2kaI7OgCKDutsa3AFGxS7b-On64Aerz4,4972
110
111
  updates/gate.py,sha256=1Tgnw8WOpUAYXboYscNGEZLhg1qJR336mg9VILw2Q6s,2229
111
112
  updates/release_notes.py,sha256=3M03Zxn4ZQvrpIpz2fbCoavcmuxiYu96epCGwwdbqHI,1734
112
- usage_cli-0.32.2.data/data/share/usage/i18n.json,sha256=a7BqOe0dd5vvtmhb-JEwpnzORBZf_7YYUBTfKo6Js1c,186185
113
- usage_cli-0.32.2.dist-info/licenses/LICENSE,sha256=GbPiL4Am4oP7rnqY-G84xpiYOGUGqVZiqnKFBDDWRFo,34586
113
+ usage_cli-0.32.3.data/data/share/usage/i18n.json,sha256=EOsEqbfYZJ6nGAWtbgLV2lLW9p1mwTlI5fozDTRN2FY,186802
114
+ usage_cli-0.32.3.dist-info/licenses/LICENSE,sha256=GbPiL4Am4oP7rnqY-G84xpiYOGUGqVZiqnKFBDDWRFo,34586
114
115
  usage_common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
115
116
  usage_common/subprocess_utils.py,sha256=LczNW2o-n70BH_-ZVzpW5TfZphK5RvjZLZj47qqb59I,621
116
117
  usage_common/time_utils.py,sha256=aGRJioBHdThvvuFn1f21DuVtKR9KBTi3DYAL7JT1W8M,666
@@ -118,12 +119,12 @@ usage_common/usage_dir_sweeper.py,sha256=5TjfFH-1MNb5GKCGjjtslsaXCG-2UbdHTmGXz4E
118
119
  usage_common/usage_lang.py,sha256=EDV_dYxeqdUL_HQfOSf8lZqyX5xb8yPQIEN6ZuTgAJ4,2602
119
120
  usage_common/usage_logging.py,sha256=uHIf5aJsRrKZUPCxKI45i3ju0v7_mwstqabVqzOZYN8,2636
120
121
  wintray/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
121
- wintray/app.py,sha256=Ictp5O93cukG7hM-VLEL_uxt7abQmBKbtbBM03wWMug,95341
122
+ wintray/app.py,sha256=HG2xRlDL9PshIbgNIfKddJZkH30MOGnCYn6ZdLYxGYg,96442
122
123
  wintray/login_item.py,sha256=550-crK2F27RuLetGbGDOcRY_Bo_Hz1W8PKjyVDM-Bk,1474
123
124
  wintray/menu.py,sha256=Xovi2MIOLsmf3baeom0X8D1PlLfOHDngSwk_0vSQy9I,4725
124
125
  wintray/watch.py,sha256=u-V4hQwBpXSVi4zbcS50pgweGJ1C7bINq9M73AM8MWc,15881
125
- usage_cli-0.32.2.dist-info/METADATA,sha256=zplgF-URxLW69FZbiwNbQd-lwi9CuxpWffFcHBgYyok,21284
126
- usage_cli-0.32.2.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
127
- usage_cli-0.32.2.dist-info/entry_points.txt,sha256=9lSkmKBSXLL30xY7A393j4oqspnoTUNTSHpakty9uDE,68
128
- usage_cli-0.32.2.dist-info/top_level.txt,sha256=AOBfBDtNFuvQ1PZm6x84KNlyXIpI2SQ6pKMXJuBsTUI,395
129
- usage_cli-0.32.2.dist-info/RECORD,,
126
+ usage_cli-0.32.3.dist-info/METADATA,sha256=NTEhMio4mlLbJi4adxtAoZNuPepWSjh205h1lK-wyr0,21284
127
+ usage_cli-0.32.3.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
128
+ usage_cli-0.32.3.dist-info/entry_points.txt,sha256=9lSkmKBSXLL30xY7A393j4oqspnoTUNTSHpakty9uDE,68
129
+ usage_cli-0.32.3.dist-info/top_level.txt,sha256=AOBfBDtNFuvQ1PZm6x84KNlyXIpI2SQ6pKMXJuBsTUI,395
130
+ usage_cli-0.32.3.dist-info/RECORD,,
wintray/app.py CHANGED
@@ -35,6 +35,7 @@ from loaders import codex_loader, grok_loader
35
35
  from loaders.history_loader import UsageEntry, load_entries
36
36
  from menubar import agy as menubar_agy
37
37
  from menubar import grok as menubar_grok
38
+ from menubar import manual_refresh
38
39
  from menubar import state as menubar_state
39
40
  from menubar.prefs import (
40
41
  _auto_update_check_enabled,
@@ -566,7 +567,11 @@ def _set_taskbar_progress(
566
567
 
567
568
  def build_tooltip(state: menubar_state.PopoverState) -> str:
568
569
  def line(name: str, row: menubar_state.QuotaRowState) -> str:
569
- used = "--" if row.percent is None else str(min(100, max(0, round(row.percent))))
570
+ used = (
571
+ "--"
572
+ if row.display_percent is None
573
+ else str(min(100, max(0, round(row.display_percent))))
574
+ )
570
575
  return f"{name} {row.title}: {used}%"
571
576
 
572
577
  lines = [
@@ -888,7 +893,7 @@ class _WindowsTrayController:
888
893
  self.inject_state(force=True)
889
894
  # A panel reload can recreate its taskbar button. Reapply the
890
895
  # latest value once the visible native window has loaded.
891
- self._update_taskbar_progress(self.latest_state.claude_session.percent)
896
+ self._update_taskbar_progress(self.latest_state.claude_session.display_percent)
892
897
 
893
898
  @staticmethod
894
899
  def _screen_rectangle(value: object) -> tuple[int, int, int, int] | None:
@@ -1458,6 +1463,17 @@ class _WindowsTrayController:
1458
1463
  self._last_file_event_refresh_started_at = time.monotonic()
1459
1464
  self.refresh()
1460
1465
 
1466
+ def refresh_manual(self) -> None:
1467
+ with self.refresh_lock:
1468
+ if self.stopping.is_set():
1469
+ return
1470
+ manual_refresh.begin(self.latest_state, queued=self._refresh_in_flight)
1471
+ try:
1472
+ if self.visible:
1473
+ self.inject_state()
1474
+ finally:
1475
+ self.refresh()
1476
+
1461
1477
  def refresh(self) -> None:
1462
1478
  with self.refresh_lock:
1463
1479
  if self.stopping.is_set():
@@ -1484,10 +1500,14 @@ class _WindowsTrayController:
1484
1500
 
1485
1501
  while True:
1486
1502
  try:
1487
- self.latest_state = self._build_state(
1503
+ state = self._build_state(
1488
1504
  measure=measure,
1489
1505
  debug_timing=debug_timing,
1490
1506
  )
1507
+ with self.refresh_lock:
1508
+ self.latest_state = manual_refresh.finish(
1509
+ self.latest_state, state, queued=self._refresh_queued
1510
+ )
1491
1511
  self._process_quota_notifications(self.latest_state)
1492
1512
  started_at = time.monotonic() if debug_timing else 0.0
1493
1513
  self._update_tray()
@@ -1497,6 +1517,15 @@ class _WindowsTrayController:
1497
1517
  self.inject_state()
1498
1518
  measure("inject_state", started_at)
1499
1519
  except Exception:
1520
+ with self.refresh_lock:
1521
+ manual_refresh.finish(
1522
+ self.latest_state, self.latest_state, queued=self._refresh_queued
1523
+ )
1524
+ if self.visible:
1525
+ try:
1526
+ self.inject_state()
1527
+ except Exception:
1528
+ logger.warning("Windows tray refresh status update failed", exc_info=True)
1500
1529
  if os.environ.get("USAGE_DEBUG") == "1":
1501
1530
  logger.warning("Windows tray refresh failed", exc_info=True)
1502
1531
 
@@ -1669,7 +1698,7 @@ class _WindowsTrayController:
1669
1698
  return await self.usage_client.fetch_once()
1670
1699
 
1671
1700
  def _update_tray(self) -> None:
1672
- percent = self.latest_state.claude_session.percent
1701
+ percent = self.latest_state.claude_session.display_percent
1673
1702
  self._update_taskbar_progress(percent)
1674
1703
  if self.icon is None:
1675
1704
  return
@@ -1729,7 +1758,7 @@ class _WindowsTrayController:
1729
1758
  self.visible = True
1730
1759
  self._place_window()
1731
1760
  self._dispatch_window_mutation(self._show_panel_on_ui_thread)
1732
- self._update_taskbar_progress(self.latest_state.claude_session.percent)
1761
+ self._update_taskbar_progress(self.latest_state.claude_session.display_percent)
1733
1762
  self.inject_state(force=True)
1734
1763
  self.refresh()
1735
1764
 
@@ -2158,7 +2187,7 @@ class _WindowsTrayController:
2158
2187
  elif action == "reset_panel_position":
2159
2188
  self.reset_panel_position()
2160
2189
  elif action == "refresh":
2161
- self.refresh()
2190
+ self.refresh_manual()
2162
2191
  elif action == "toggle_login":
2163
2192
  self.toggle_login()
2164
2193
  elif action == "toggle_quota_notifications":
@@ -2178,7 +2207,7 @@ class _WindowsTrayController:
2178
2207
  return None
2179
2208
  action = str(payload)
2180
2209
  if action == "refresh":
2181
- self.refresh()
2210
+ self.refresh_manual()
2182
2211
  elif action == "quit":
2183
2212
  self.quit()
2184
2213
  elif action == "switch":