Skip to content

fix: use format_tokens() in render_live_sessions (#133)#167

Merged
microsasa merged 1 commit intomainfrom
fix/133-format-tokens-live-sessions-603a16e397909b50
Mar 20, 2026
Merged

fix: use format_tokens() in render_live_sessions (#133)#167
microsasa merged 1 commit intomainfrom
fix/133-format-tokens-live-sessions-603a16e397909b50

Conversation

@microsasa
Copy link
Owner

Fixes #133

Changes

src/copilot_usage/report.pyrender_live_sessions now calls format_tokens() instead of raw :, f-string formatting for output tokens, matching every other token-displaying call site.

tests/copilot_usage/test_report.py:

  • Updated test_active_session_shows_output_tokens assertion from "15,000""15.0K"
  • Added test_active_session_shows_output_tokens_m_suffix verifying values ≥1,000,000 render with M suffix (e.g. 1.5M)

Verification

All 405 tests pass. Coverage at 97.97% (≥80% required). Ruff, pyright, and bandit all clean.

Generated by Issue Implementer ·

Copilot AI review requested due to automatic review settings March 19, 2026 16:51
@microsasa microsasa added the aw Created by agentic workflow label Mar 19, 2026
@microsasa microsasa enabled auto-merge March 19, 2026 16:51
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 use format_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.

@microsasa microsasa force-pushed the fix/133-format-tokens-live-sessions-603a16e397909b50 branch from 9135aec to 9e826a7 Compare March 19, 2026 17:00
@microsasa microsasa disabled auto-merge March 19, 2026 17:34
@microsasa microsasa enabled auto-merge March 19, 2026 17:35
@microsasa microsasa disabled auto-merge March 19, 2026 17:35
@microsasa microsasa enabled auto-merge March 19, 2026 17:35
Copilot AI review requested due to automatic review settings March 19, 2026 17:35
@microsasa microsasa force-pushed the fix/133-format-tokens-live-sessions-603a16e397909b50 branch from 9e826a7 to f590d10 Compare March 19, 2026 17:35
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_sessions output-token formatting from comma-separated integers to format_tokens() K/M suffix formatting.
  • Update the existing live-view test assertion for 15,000 tokens (15.0K).
  • Add a new test to verify M suffix 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.

@microsasa microsasa disabled auto-merge March 19, 2026 17:41
@microsasa microsasa enabled auto-merge March 19, 2026 17:41
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>
@microsasa microsasa force-pushed the fix/133-format-tokens-live-sessions-603a16e397909b50 branch from f590d10 to 043195f Compare March 19, 2026 17:42
@microsasa microsasa added aw-quality-gate-approved Quality gate approved the PR and removed aw-quality-gate-approved Quality gate approved the PR labels Mar 19, 2026
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@microsasa microsasa merged commit 98df723 into main Mar 20, 2026
4 checks passed
@microsasa microsasa deleted the fix/133-format-tokens-live-sessions-603a16e397909b50 branch March 20, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aw Created by agentic workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[aw][code health] render_live_sessions formats output tokens with :, instead of format_tokens()

2 participants