fix: suppress active period panel for pure-active sessions (#1190)#1194
Open
fix: suppress active period panel for pure-active sessions (#1190)#1194
Conversation
Guard _render_active_period with has_shutdown_metrics so the misleading 'since last shutdown' panel is not shown for sessions that never had a shutdown. This eliminates both the factually wrong title and the duplicate stats already shown in Aggregate Stats. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adjusts the session detail renderer to avoid showing the “🟢 Active Period (since last shutdown)” panel for sessions that have no meaningful shutdown baseline, addressing issue #1190 where pure-active sessions were shown a misleading/duplicative panel in render_detail.py.
Changes:
- Add a guard to
_render_active_periodso the panel is only rendered when the session is active andhas_shutdown_metricsis true. - Update
_render_active_perioddocstring to explain why the panel is suppressed for pure-active sessions. - Add/adjust unit + integration tests to cover pure-active suppression and explicitly set
has_shutdown_metrics=Truein resumed-session scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/copilot_usage/render_detail.py |
Suppresses the Active Period panel based on has_shutdown_metrics to avoid misleading output for pure-active sessions. |
tests/copilot_usage/test_render_detail.py |
Adds regression tests ensuring pure-active sessions do not render the Active Period panel and updates existing tests for the new guard. |
Comment on lines
+264
to
272
| """Show model calls / messages / tokens since last shutdown (if active). | ||
|
|
||
| Suppressed for pure-active sessions (no shutdown ever occurred) to avoid | ||
| a misleading title and duplicate stats already shown in Aggregate Stats. | ||
| """ | ||
| out = target_console or Console() | ||
|
|
||
| if not summary.is_active: | ||
| if not summary.is_active or not summary.has_shutdown_metrics: | ||
| return |
Comment on lines
+871
to
+894
| def test_pure_active_session_omits_active_period_panel(self) -> None: | ||
| """render_session_detail on a pure-active session must NOT include | ||
| 'since last shutdown' in its output (issue #1190).""" | ||
| summary = SessionSummary( | ||
| session_id="pure-active-e2e", | ||
| start_time=datetime(2026, 4, 1, 10, 0, 0, tzinfo=UTC), | ||
| is_active=True, | ||
| has_shutdown_metrics=False, | ||
| model_calls=5, | ||
| user_messages=3, | ||
| active_model_calls=5, | ||
| active_user_messages=3, | ||
| active_output_tokens=2000, | ||
| ) | ||
| ev = SessionEvent( | ||
| type=EventType.USER_MESSAGE, | ||
| timestamp=datetime(2026, 4, 1, 10, 5, 0, tzinfo=UTC), | ||
| data={"content": "hello"}, | ||
| ) | ||
| buf, console = _buf_console() | ||
| render_session_detail([ev], summary, target_console=console) | ||
| output = _strip_ansi(buf.getvalue()) | ||
| assert "since last shutdown" not in output | ||
|
|
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 #1190
Problem
_render_active_periodinrender_detail.pyunconditionally shows the "🟢 Active Period (since last shutdown)" panel for any active session. For pure-active sessions (no shutdown ever occurred,has_shutdown_metrics=False), this causes:Fix
Added a
has_shutdown_metricsguard so the panel is only rendered for resumed sessions (where shutdown data exists and the delta is meaningful):Tests
test_pure_active_session_suppressed): Verifies_render_active_periodproduces no output for a pure-activeSessionSummary.test_pure_active_session_omits_active_period_panel): Verifiesrender_session_detaildoes not include "since last shutdown" for a pure-active session.has_shutdown_metrics=Truefor resumed-session scenarios.Warning
The following domains were blocked by the firewall during workflow execution:
astral.shpypi.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.