Skip to content

fix: model_calls double-counting and table rendering duplication#41

Merged
microsasa merged 2 commits intomainfrom
fix/report-cleanup
Mar 14, 2026
Merged

fix: model_calls double-counting and table rendering duplication#41
microsasa merged 2 commits intomainfrom
fix/report-cleanup

Conversation

@microsasa
Copy link
Owner

Closes #20
Closes #22

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

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_view grand total Model Calls to avoid double-counting active_model_calls for resumed/active sessions.
  • Refactor _render_historical_section to reuse _render_model_table / _render_session_table (adding optional title parameters) 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>
@microsasa microsasa force-pushed the fix/report-cleanup branch from 6f6cf7c to 886a5d3 Compare March 14, 2026 18:29
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>
@microsasa microsasa merged commit d283729 into main Mar 14, 2026
4 checks passed
@microsasa microsasa deleted the fix/report-cleanup branch March 16, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants