fix: model_calls double-counting and table rendering duplication#41
Merged
fix: model_calls double-counting and table rendering duplication#41
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes incorrect aggregation in the interactive cost report and reduces duplicated Rich table rendering logic in the reporting module, aligning behavior with the session summary semantics (total vs post-shutdown counts).
Changes:
- Fix
render_cost_viewgrand total Model Calls to avoid double-countingactive_model_callsfor resumed/active sessions. - Refactor
_render_historical_sectionto reuse_render_model_table/_render_session_table(adding optionaltitleparameters) instead of duplicating table-building code. - Add regression tests for the double-counting bug and helper reuse expectations; update README example grand total.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/copilot_usage/report.py |
Removes the duplicate active_model_calls increment and refactors historical section to call shared table helpers with configurable titles. |
tests/copilot_usage/test_report.py |
Adds regression coverage for resumed sessions and assertions that historical output includes the expected table title and model breakdown. |
README.md |
Updates the copilot-usage cost example “Grand Total” model calls to the corrected value. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Remove duplicate addition of active_model_calls to grand_model_calls in render_cost_view (fixes #20) - Add title parameter to _render_model_table and _render_session_table - Refactor _render_historical_section to call shared helpers instead of duplicating table-build logic (fixes #22) - Update README cost example Grand Total from 9 to 8 - Add regression tests for both issues Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
6f6cf7c to
886a5d3
Compare
Copilot review: literal ESC byte in regex is invisible in diffs. Column-index split is fragile. Use regex to match Model Calls column. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 #20
Closes #22