fix: guard active-period panel for pure-active sessions (#1070)#1071
Open
fix: guard active-period panel for pure-active sessions (#1070)#1071
Conversation
- render_detail: skip _render_active_period when has_shutdown_metrics is False, preventing duplicate/misleading 'since last shutdown' panel for sessions that have never been shut down. - report: make _render_active_section_from table title dynamic — only include 'Since Last Shutdown' when at least one active session has prior shutdown data. - Add tests for both pure-active and resumed paths in test_render_detail.py and test_report.py. - Update existing tests to set has_shutdown_metrics=True where the Active Period panel is expected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes misleading “since last shutdown” labeling in the interactive summary and session-detail views by only rendering shutdown-relative UI when the session actually has shutdown history (has_shutdown_metrics=True).
Changes:
- Guarded
render_detail._render_active_periodso the “🟢 Active Period (since last shutdown)” panel is not shown for pure-active sessions. - Made
report._render_active_section_fromchoose its table title dynamically based on whether any active session has shutdown history. - Added/updated unit tests covering pure-active vs resumed-session behavior in both renderers.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/copilot_usage/render_detail.py |
Suppresses “Active Period (since last shutdown)” panel unless shutdown history exists. |
src/copilot_usage/report.py |
Adjusts active-sessions table title to avoid “Since Last Shutdown” when inappropriate. |
tests/copilot_usage/test_render_detail.py |
Adds coverage for pure-active sessions and updates existing tests to reflect new guard. |
tests/copilot_usage/test_report.py |
Adds coverage ensuring the active-section title matches shutdown-history presence. |
Owner
Author
|
❌ Pipeline orchestrator: CI still failing after ci-fixer attempt. Marking as stuck for human review. |
Owner
Author
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 #1070
Problem
_render_active_periodinrender_detail.pyrendered a panel titled "🟢 Active Period (since last shutdown)" for all active sessions, including pure-active sessions that have never been shut down (has_shutdown_metrics=False). This produced confusing duplicate output — the "Active Period" and "Aggregate Stats" panels showed identical numbers with a factually wrong label.Similarly,
_render_active_section_frominreport.pyused a static title "🟢 Active Sessions (Since Last Shutdown)" even for pure-active sessions.Fix
render_detail.pyAdded a
has_shutdown_metricsguard to_render_active_periodso the panel only renders when there is a prior shutdown cycle to compare against:report.pyMade the
_render_active_section_fromtable title dynamic — it only includes "Since Last Shutdown" when at least one active session hashas_shutdown_metrics=True:Tests
test_render_detail.pytest_pure_active_session_no_active_period_panel: pure-active session → no outputtest_resumed_session_shows_active_period_panel: resumed session → panel rendered with correct statstest_active_session_renders_panelto sethas_shutdown_metrics=Truetest_active_session_shows_active_period_panelto sethas_shutdown_metrics=Truetest_report.pytest_pure_active_session_active_section_title: pure-active session → title does NOT contain "Since Last Shutdown"test_resumed_session_active_section_title: resumed session → title contains "Since Last Shutdown"Warning
The following domains were blocked by the firewall during workflow execution:
astral.shindex.crates.iopypi.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.