Skip to content

fix: suppress active period panel for pure-active sessions (#1190)#1194

Open
microsasa wants to merge 1 commit intomainfrom
fix/1190-render-active-period-pure-active-1cfd3a0a0bfd402d
Open

fix: suppress active period panel for pure-active sessions (#1190)#1194
microsasa wants to merge 1 commit intomainfrom
fix/1190-render-active-period-pure-active-1cfd3a0a0bfd402d

Conversation

@microsasa
Copy link
Copy Markdown
Owner

Closes #1190

Problem

_render_active_period in render_detail.py unconditionally 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:

  1. Misleading title — "since last shutdown" implies a prior shutdown that never happened.
  2. Duplicate data — the panel repeats the same stats already shown in the Aggregate Stats panel above.

Fix

Added a has_shutdown_metrics guard so the panel is only rendered for resumed sessions (where shutdown data exists and the delta is meaningful):

if not summary.is_active or not summary.has_shutdown_metrics:
    return

Tests

  • Unit test (test_pure_active_session_suppressed): Verifies _render_active_period produces no output for a pure-active SessionSummary.
  • Integration test (test_pure_active_session_omits_active_period_panel): Verifies render_session_detail does not include "since last shutdown" for a pure-active session.
  • Updated existing tests to explicitly set has_shutdown_metrics=True for resumed-session scenarios.

Warning

⚠️ Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • astral.sh
  • pypi.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "astral.sh"
    - "pypi.org"

See Network Configuration for more information.

Generated by Issue Implementer · ● 6.5M ·

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>
Copilot AI review requested due to automatic review settings May 5, 2026 11:10
@microsasa microsasa added the aw Created by agentic workflow label May 5, 2026
@microsasa microsasa enabled auto-merge May 5, 2026 11:10
Copy link
Copy Markdown

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

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_period so the panel is only rendered when the session is active and has_shutdown_metrics is true.
  • Update _render_active_period docstring 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=True in 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aw Created by agentic workflow

Projects

None yet

2 participants