Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/copilot_usage/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,7 @@ def _render_active_section_from(
)
return

table = Table(
title="🟒 Active Sessions (Since Last Shutdown)", border_style="green"
)
table = Table(title="🟒 Active Sessions", border_style="green")
table.add_column("Name", style="bold", max_width=40)
table.add_column("Model")
table.add_column("Model Calls", justify="right")
Comment on lines +557 to 560
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The render_full_summary docstring still says β€œSection 2: Active sessions since last shutdown.” (see report.py around lines 593–596), but the section title is now unqualified and the active stats can represent full-lifetime data for pure-active sessions. Please update the docstring to match the new behavior to avoid misleading future maintainers.

Copilot uses AI. Check for mistakes.
Expand Down Expand Up @@ -594,7 +592,7 @@ def render_full_summary(
"""Render the two-section summary for interactive mode.

Section 1: Historical shutdown data (totals, per-model, per-session).
Section 2: Active sessions since last shutdown.
Section 2: Currently active sessions.

*sessions* must be in descending ``start_time`` order β€” the contract
guaranteed by :func:`~copilot_usage.parser.get_all_sessions`. No
Expand Down
27 changes: 24 additions & 3 deletions tests/copilot_usage/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -3656,9 +3656,9 @@ def test_resumed_free_session_appears_in_active_section(self) -> None:
},
)
output = _capture_full_summary([session])
# Active section table title should indicate it is scoped to the period
# since the last shutdown, which distinguishes it from the historical table.
assert "Since Last Shutdown" in output
# Active section table title should NOT contain the misleading
# "Since Last Shutdown" qualifier (issue #1072).
assert "Since Last Shutdown" not in output
# The same resumed session should appear in both the historical and active sections.
assert output.count("ResumedFreeSession") == 2
# And the generic empty-active message should not be shown.
Expand All @@ -3683,6 +3683,27 @@ def test_pure_active_session_not_in_historical(self) -> None:
output = _capture_full_summary([session])
assert "No historical shutdown data" in output

def test_pure_active_section_title_no_since_last_shutdown(self) -> None:
"""Issue #1072 β€” pure-active session (has_shutdown_metrics=False)
must NOT show 'Since Last Shutdown' in the active-section title."""
session = SessionSummary(
session_id="pure-active-title-1234",
name="PureActiveTitle",
model="gpt-5-mini",
start_time=datetime(2025, 1, 15, 10, 0, tzinfo=UTC),
is_active=True,
has_shutdown_metrics=False,
total_premium_requests=0,
user_messages=2,
model_calls=1,
active_model_calls=1,
active_output_tokens=100,
)
output = _capture_full_summary([session])
assert "Since Last Shutdown" not in output
# The generic title should still be present.
assert "Active Sessions" in output


class TestBuildEventDetailsCatchAll:
"""Issue #230 β€” _build_event_details catch-all branch for event types without explicit details."""
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ def test_not_found_shows_available_list(self) -> None:
# ---------------------------------------------------------------------------

# Marker that separates the historical section from the active section
_ACTIVE_MARKER = "Active Sessions (Since Last Shutdown)"
_ACTIVE_MARKER = "Active Sessions"

# Minimal completed session with zero premium requests (free-tier model only).
# Used to verify that the historical filter's ``not s.is_active`` branch
Expand Down
Loading