Skip to content

Commit f2b839f

Browse files
committed
Align report range defaults with project selection
1 parent 3c31a56 commit f2b839f

6 files changed

Lines changed: 19 additions & 16 deletions

File tree

README.en.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
🌐 **Landing page**: [ericweichun.github.io/usage](https://ericweichun.github.io/usage/)
1212

13-
`usage` is a macOS menu bar tool that pins your **Codex** usage to the top-right of your screen, while keeping **Claude Code** as an optional integration. Click the icon for a popover showing Session, Weekly, per-project usage (today / 7-day / monthly / all-time), and today's token usage and cost estimate; click Report to generate an all-time HTML report.
13+
`usage` is a macOS menu bar tool that pins your **Codex** usage to the top-right of your screen, while keeping **Claude Code** as an optional integration. Click the icon for a popover showing Session, Weekly, per-project usage (today / 7-day / monthly / all-time), and today's token usage and cost estimate; click Report for a last-30-days HTML report, or switch Project Usage to All Time before reporting to generate an all-time report.
1414

1515
It **never calls the Anthropic / OpenAI API** and **never reads the Keychain**, so it avoids the observer effect of "pinging once a minute counts as usage."
1616

@@ -229,7 +229,7 @@ Press `Ctrl+C` to exit.
229229
230230
## Reports and deep analytics
231231
232-
Beyond the menu bar and TUI, the popover's **Report** button generates an **all-time HTML report**. If you want a specific range, the `usage_cli.py` analytics entrypoint can export HTML reports or run an interactive terminal dashboard:
232+
Beyond the menu bar and TUI, the popover's **Report** button generates an HTML report: All Time project range generates an all-time report, while the other project ranges keep the report on the last 30 days. The `usage_cli.py` analytics entrypoint can also export HTML reports for explicit ranges or run an interactive terminal dashboard:
233233
234234
<p align="center">
235235
<img src="docs/report.en.png" alt="HTML report screen: Your AI Usage Recap" width="520">
@@ -245,7 +245,7 @@ python3 usage_cli.py
245245
python3 usage_cli.py claude
246246
python3 usage_cli.py codex
247247
248-
# Generate an HTML report and open it in your default browser (default range: all data)
248+
# Generate an HTML report and open it in your default browser (default range: last 30 days)
249249
python3 usage_cli.py report
250250
python3 usage_cli.py report --last30 # last 30 days
251251
python3 usage_cli.py report --today # today

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
🌐 **介紹頁**[ericweichun.github.io/usage](https://ericweichun.github.io/usage/)
1212

13-
`usage` 是一個 macOS menu bar(螢幕右上角的選單列)小工具,把 **Codex** 的用量釘在你的螢幕右上角,並保留 **Claude Code** 作為可選整合。點開可以看到 Session、Weekly、各專案用量(今日 / 7 日 / 月 / 全部),以及今日 token 用量與成本估算;按「報告」會產生 all-time HTML report。
13+
`usage` 是一個 macOS menu bar(螢幕右上角的選單列)小工具,把 **Codex** 的用量釘在你的螢幕右上角,並保留 **Claude Code** 作為可選整合。點開可以看到 Session、Weekly、各專案用量(今日 / 7 日 / 月 / 全部),以及今日 token 用量與成本估算;按「報告」預設會產生近 30 天 HTML report,只有專案用量切到「全部」時才產生 all-time report。
1414

1515
不呼叫 Anthropic / OpenAI 的 API(接口)、也不讀 Keychain(macOS 內建的密碼保險箱),所以不會發生「自己每分鐘 ping 一次也算用量」這種事。
1616

@@ -231,7 +231,7 @@ python3 main.py --tui
231231

232232
## 報告與深度分析
233233

234-
除了選單列跟 TUI,popover 裡的「報告」按鈕會直接產生 **all-time HTML report**。如果你想指定時間範圍,也可以用 CLI 進入點 `usage_cli.py` 匯出 HTML 報告、或在終端機開互動式 dashboard(儀表板,互動式統計面板):
234+
除了選單列跟 TUI,popover 裡的「報告」按鈕會產生 HTML report:專案用量切到「全部」時產生 **all-time HTML report**,其他範圍維持近 30 天 report。你也可以用 CLI 進入點 `usage_cli.py` 指定時間範圍、或在終端機開互動式 dashboard(儀表板,互動式統計面板):
235235

236236
<p align="center">
237237
<img src="docs/report.png" alt="HTML 報告畫面:你的 AI 用量回顧" width="520">
@@ -247,7 +247,7 @@ python3 usage_cli.py
247247
python3 usage_cli.py claude
248248
python3 usage_cli.py codex
249249

250-
# 產生 HTML 報告並用預設瀏覽器打開(預設範圍:全部資料
250+
# 產生 HTML 報告並用預設瀏覽器打開(預設範圍:近 30 天
251251
python3 usage_cli.py report
252252
python3 usage_cli.py report --last30 # 近 30 天
253253
python3 usage_cli.py report --today # 今日

menubar.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@ def uninstallStatusline_(self, sender: Any) -> None:
427427
def analyzeUsage_(self, sender: Any) -> None:
428428
thread = threading.Thread(
429429
target=self._analyze_usage_in_background,
430-
args=("all",),
431430
daemon=True,
432431
)
433432
thread.start()

tests/test_analyzer_pipeline.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ def fake_save_and_open(received_data: dict[str, object]) -> str:
7777
assert calls == {"agents": agents, "period": "last30", "data": report_data}
7878

7979

80-
def test_app_analyze_uses_all_time_report(monkeypatch: Any) -> None:
80+
def test_app_analyze_uses_last30_by_default_and_all_time_when_requested(
81+
monkeypatch: Any,
82+
) -> None:
8183
calls: list[str] = []
8284

8385
class InlineThread:
@@ -102,7 +104,7 @@ def fake_generate_analysis_report(
102104
language: str | None = None,
103105
) -> str:
104106
calls.append(period)
105-
return "~/.usage-reports/all.html"
107+
return "~/.usage-reports/report.html"
106108

107109
monkeypatch.setattr(
108110
menubar,
@@ -116,8 +118,9 @@ def fake_generate_analysis_report(
116118
)
117119

118120
delegate.analyzeUsage_(None)
121+
delegate.analyzeAllUsage_(None)
119122

120-
assert calls == ["all"]
123+
assert calls == ["last30", "all"]
121124

122125

123126
def test_last30_report_uses_rolling_720_hours(monkeypatch: Any) -> None:

tests/test_usage_cli.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,12 @@ def test_main_daily_sort_flag_controls_render_order(monkeypatch: pytest.MonkeyPa
9191
@pytest.mark.parametrize(
9292
("argv", "expected_period"),
9393
[
94-
(["usage", "report"], "all"),
94+
(["usage", "report"], "last30"),
9595
(["usage", "report", "--last30"], "last30"),
96+
(["usage", "report", "--all"], "all"),
9697
],
9798
)
98-
def test_main_report_defaults_to_all_time(
99+
def test_main_report_parses_period(
99100
monkeypatch: pytest.MonkeyPatch,
100101
argv: list[str],
101102
expected_period: str,

usage_cli.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
"output": ("output_tokens", True),
2727
}
2828

29-
REPORT_HELP = """Usage: usage report [--all|--last30|--today|--week|--month] [--out PATH]
29+
REPORT_HELP = """Usage: usage report [--last30|--all|--today|--week|--month] [--out PATH]
3030
3131
Generate an HTML usage report.
3232
3333
Options:
34-
--all Include all usage data (default)
35-
--last30 Include the last 30 days
34+
--last30 Include the last 30 days (default)
35+
--all Include all usage data
3636
--today Include today only
3737
--week Include this week
3838
--month Include this month
@@ -64,7 +64,7 @@ def _parse_sort_args(args: list[str]) -> tuple[list[str], str | None, bool]:
6464

6565

6666
def _parse_report_args(args: list[str]) -> tuple[str, str | None, bool]:
67-
period = "all"
67+
period = "last30"
6868
out_path = None
6969
show_help = False
7070
i = 0

0 commit comments

Comments
 (0)