Conversation
…anching (#242) Add frozen _EffectiveStats dataclass and _effective_stats() helper that returns active-period stats when available, otherwise session totals. Replace three duplicated if/else branches in render_live_sessions, _render_active_section, and render_cost_view with calls to _effective_stats(). Add unit tests covering both branches (active period and session totals) plus frozen-dataclass immutability. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors copilot_usage.report to centralize the “active-period vs session-total” stat selection logic in a single helper, reducing duplication and keeping the live/active/cost views consistent.
Changes:
- Added frozen
_EffectiveStatsdataclass and_effective_stats()helper to encapsulate active-vs-total fallback logic. - Replaced repeated
_has_active_period_stats()branches inrender_live_sessions,_render_active_section, andrender_cost_viewwith_effective_stats(). - Added unit tests covering both branches of
_effective_stats()plus immutability.
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 | Introduces _EffectiveStats / _effective_stats() and updates renderers to use it instead of duplicated branching. |
| tests/copilot_usage/test_report.py | Adds TestEffectiveStats to validate both selection branches and frozen dataclass behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
microsasa
pushed a commit
that referenced
this pull request
Mar 22, 2026
Copilot CLI broke branch protection rules during a safe admin merge
by setting the wrong required status check name ("CI" instead of
"check"), causing a 9-hour infinite loop of quality gate runs on
PR #246 (100+ pointless approvals). When Copilot CLI then fixed the
check name, it failed to also fix the review requirement settings
(dismiss_stale_reviews and required_approvals), leaving protections
down. It then repeatedly tested hold/release scripts against live
settings while the orchestrator was still running, allowing this PR
and others to auto-merge without any quality gate review.
Copilot CLI is a liar and cannot be trusted with repository settings.
It reports success while silently breaking things, hides mistakes
behind summaries instead of showing raw data, and has repeatedly
broken branch protection across multiple incidents. It has been
stripped of permission to modify branch protection directly. This
revert is part of repo recovery forced by Copilot CLI's repeated
carelessness.
This reverts commit a5b2b07.
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 #242
Changes
Adds a frozen
_EffectiveStatsdataclass and_effective_stats()helper that returns active-period stats when available, otherwise falls back to session totals. This replaces three copy-pastedif _has_active_period_stats(s)branches in:render_live_sessions_render_active_sectionrender_cost_viewEach call site now uses
stats = _effective_stats(s)and accessesstats.model_calls,stats.user_messages,stats.output_tokens.Tests
Added
TestEffectiveStatswith three tests:test_returns_active_stats_when_active_period— resumed session returnsactive_*valuestest_returns_session_totals_when_no_active_period— pure-active session falls back to totalstest_frozen_dataclass— verifies immutabilityAll 509 tests pass. Coverage: 98.76%.
Warning
The following domain was blocked by the firewall during workflow execution:
astral.shTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.