fix: use format_tokens() in render_live_sessions (#133)#167
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes an inconsistency in the copilot-usage live report by ensuring output-token counts are formatted with the shared format_tokens() helper, matching the formatting used elsewhere in the reporting module.
Changes:
- Updated
render_live_sessions()to useformat_tokens(_estimated_output_tokens(...))instead of comma-separated integer formatting. - Adjusted the existing live-session test assertion to expect
K-suffix formatting. - Added a new test to verify
M-suffix formatting for values ≥ 1,000,000 in the live view.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/copilot_usage/report.py |
Aligns live-session output token formatting with the module-wide format_tokens() convention. |
tests/copilot_usage/test_report.py |
Updates/extends tests to assert the new K/M suffix formatting in live-session output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9135aec to
9e826a7
Compare
9e826a7 to
f590d10
Compare
There was a problem hiding this comment.
Pull request overview
Updates the live sessions rendering to use the shared format_tokens() helper so output token counts are displayed consistently across report views (fixes #133).
Changes:
- Switch
render_live_sessionsoutput-token formatting from comma-separated integers toformat_tokens()K/M suffix formatting. - Update the existing live-view test assertion for 15,000 tokens (
15.0K). - Add a new test to verify
Msuffix formatting for ≥ 1,000,000 tokens in the live view.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/copilot_usage/report.py | Uses format_tokens(_estimated_output_tokens(s)) for the “Output Tokens” column in live sessions. |
| tests/copilot_usage/test_report.py | Adjusts the token formatting assertion and adds coverage for M suffix formatting in the live view. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replace raw :, formatting with format_tokens() helper for consistent K/M suffix display across all views. Update test assertion and add M-suffix test for values >= 1,000,000. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
f590d10 to
043195f
Compare
There was a problem hiding this comment.
Low-impact consistency fix — switches render_live_sessions from raw :, formatting to the existing format_tokens() helper, matching all other token-display call sites. Tests updated and meaningful (K/M suffix assertions). All CI green. Auto-approving for merge.
Fixes #133
Changes
src/copilot_usage/report.py—render_live_sessionsnow callsformat_tokens()instead of raw:,f-string formatting for output tokens, matching every other token-displaying call site.tests/copilot_usage/test_report.py:test_active_session_shows_output_tokensassertion from"15,000"→"15.0K"test_active_session_shows_output_tokens_m_suffixverifying values ≥1,000,000 render withMsuffix (e.g.1.5M)Verification
All 405 tests pass. Coverage at 97.97% (≥80% required). Ruff, pyright, and bandit all clean.