Conversation
…e sessions _render_model_table now checks whether any session has shutdown metrics or is no longer active before displaying request counts and premium cost. When all sessions are pure-active (still running, no shutdown event), these columns show '—' instead of misleading '0' — consistent with the existing behaviour in render_cost_view. Closes #1191 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the summary report in copilot_usage so the per-model table no longer shows misleading zero request/cost values for pure-active sessions, aligning render_summary more closely with the existing cost-view behavior.
Changes:
- Added a
show_requestsguard in_render_model_tableto render"—"instead of0for Requests and Premium Cost when all summarized sessions are pure-active. - Expanded
_render_model_tabledocumentation to describe the pure-active display behavior. - Added a regression test covering a pure-active session in
render_summary.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/copilot_usage/report.py |
Adjusts per-model summary rendering for request/cost columns in pure-active-session scenarios. |
tests/copilot_usage/test_report.py |
Adds a regression test intended to validate the new pure-active summary-table output. |
Comment on lines
+364
to
+366
| # Request/cost data is only meaningful when at least one session has | ||
| # completed shutdown metrics or is no longer active. | ||
| show_requests = any(s.has_shutdown_metrics or not s.is_active for s in sessions) |
Comment on lines
+1266
to
+1275
| # The row must NOT show "0" as the requests count (which would be | ||
| # between the model name and the "—" or the output tokens). | ||
| # Split by the model name and check the numeric columns that follow. | ||
| after_model = model_row.split("claude-sonnet-4", 1)[1] | ||
| # Strip leading/trailing and split by whitespace for column values | ||
| cols = after_model.split() | ||
| # cols should be: [Requests, PremiumCost, InputTokens, OutputTokens, | ||
| # CacheRead, CacheWrite] | ||
| assert cols[0] == "—", f"Requests column should be '—', got '{cols[0]}'" | ||
| assert cols[1] == "—", f"Premium Cost column should be '—', got '{cols[1]}'" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1191
Problem
_render_model_tableinrender_summarydisplayed0for Requests and Premium Cost columns when rendering pure-active sessions (still running, no shutdown event). This is misleading because the data is simply not yet available — not actually zero.Fix
Added a
show_requestsguard (mirroring the existing logic inrender_cost_view) that checks whether any session has shutdown metrics or is no longer active. When all sessions are pure-active, Requests and Premium Cost columns now display"—"instead of"0".The condition used is:
This is consistent with the per-session logic already used in
render_cost_view(line 686).Testing
Added
test_pure_active_session_shows_dash_for_requests_and_costtoTestRenderSummarywhich:is_active=True,has_shutdown_metrics=False, known model, non-zero output tokens)"—"(not"0")Warning
The following domain was blocked by the firewall during workflow execution:
pypi.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.