Root Cause
render_detail._render_active_period is called unconditionally for any session where summary.is_active is True:
def _render_active_period(summary: SessionSummary, ...) -> None:
if not summary.is_active:
return
content = (...)
out.print(Panel(content, title="🟢 Active Period (since last shutdown)", ...))
This includes pure-active sessions (no shutdown ever, has_shutdown_metrics=False). For these sessions, two bugs occur simultaneously.
Bug 1 — Factually wrong panel title
"🟢 Active Period (since last shutdown)" implies a prior shutdown occurred. For pure-active sessions, no shutdown has ever happened. The qualifier "since last shutdown" is incorrect.
This is the render_detail.py analogue of issue #1146 (which covers the same mistake in report.py's _render_active_section_from), but it is a separate function in a separate module and is not addressed by fixing #1146.
Bug 2 — Duplicate data shown to the user
For pure-active sessions, _build_active_summary sets:
active_model_calls = fp.total_turn_starts # equals model_calls
active_user_messages = fp.user_message_count # equals user_messages
active_output_tokens = fp.total_output_tokens # equals session totals
The Aggregate Stats panel (always rendered above) already shows these same numbers via total_output_tokens(summary). For pure-active sessions total_output_tokens returns active_output_tokens exactly, so the user sees identical stats twice:
- Aggregate Stats: "N model calls N user messages N output tokens"
- Active Period (since last shutdown): "N model calls N user messages N output tokens"
For resumed sessions the Active Period panel is genuinely useful (it shows the delta since the last shutdown). For pure-active sessions it is pure duplication.
Context
render_session_detail in render_detail.py calls:
_render_aggregate_stats(summary, ...) # correct for all sessions
_render_shutdown_cycles(summary, ...) # prints "No shutdown cycles recorded." for pure-active
_render_active_period(summary, ...) # BUG: shows wrong panel for pure-active
Fix
Guard _render_active_period with summary.has_shutdown_metrics so it only activates for sessions that have actual shutdown data:
def _render_active_period(summary: SessionSummary, ...) -> None:
if not summary.is_active or not summary.has_shutdown_metrics:
return
...
This suppresses the panel for pure-active sessions (where it duplicates and misleads) while keeping it for resumed sessions (where it provides useful differential data).
Testing Requirement
Add a regression test in tests/copilot_usage/test_render_detail.py that constructs a pure-active SessionSummary (is_active=True, has_shutdown_metrics=False) and verifies that _render_active_period produces no output (i.e., the panel is suppressed). Also add an integration-level assertion to TestRenderSessionDetailActivePeriod verifying that render_session_detail on a pure-active session does not include "since last shutdown" in its output.
Generated by Code Health Analysis · ● 6.9M · ◷
Root Cause
render_detail._render_active_periodis called unconditionally for any session wheresummary.is_active is True:This includes pure-active sessions (no shutdown ever,
has_shutdown_metrics=False). For these sessions, two bugs occur simultaneously.Bug 1 — Factually wrong panel title
"🟢 Active Period (since last shutdown)" implies a prior shutdown occurred. For pure-active sessions, no shutdown has ever happened. The qualifier "since last shutdown" is incorrect.
This is the
render_detail.pyanalogue of issue #1146 (which covers the same mistake inreport.py's_render_active_section_from), but it is a separate function in a separate module and is not addressed by fixing #1146.Bug 2 — Duplicate data shown to the user
For pure-active sessions,
_build_active_summarysets:The Aggregate Stats panel (always rendered above) already shows these same numbers via
total_output_tokens(summary). For pure-active sessionstotal_output_tokensreturnsactive_output_tokensexactly, so the user sees identical stats twice:For resumed sessions the Active Period panel is genuinely useful (it shows the delta since the last shutdown). For pure-active sessions it is pure duplication.
Context
render_session_detailinrender_detail.pycalls:Fix
Guard
_render_active_periodwithsummary.has_shutdown_metricsso it only activates for sessions that have actual shutdown data:This suppresses the panel for pure-active sessions (where it duplicates and misleads) while keeping it for resumed sessions (where it provides useful differential data).
Testing Requirement
Add a regression test in
tests/copilot_usage/test_render_detail.pythat constructs a pure-activeSessionSummary(is_active=True,has_shutdown_metrics=False) and verifies that_render_active_periodproduces no output (i.e., the panel is suppressed). Also add an integration-level assertion toTestRenderSessionDetailActivePeriodverifying thatrender_session_detailon a pure-active session does not include "since last shutdown" in its output.