Skip to content

fix: guard active-period panel for pure-active sessions (#1070)#1071

Open
microsasa wants to merge 1 commit intomainfrom
fix/1070-active-period-pure-active-guard-3b45d548753105e2
Open

fix: guard active-period panel for pure-active sessions (#1070)#1071
microsasa wants to merge 1 commit intomainfrom
fix/1070-active-period-pure-active-guard-3b45d548753105e2

Conversation

@microsasa
Copy link
Copy Markdown
Owner

Closes #1070

Problem

_render_active_period in render_detail.py rendered 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_from in report.py used a static title "🟢 Active Sessions (Since Last Shutdown)" even for pure-active sessions.

Fix

render_detail.py

Added a has_shutdown_metrics guard to _render_active_period so the panel only renders when there is a prior shutdown cycle to compare against:

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

report.py

Made the _render_active_section_from table title dynamic — it only includes "Since Last Shutdown" when at least one active session has has_shutdown_metrics=True:

has_resumed = any(s.has_shutdown_metrics for s in active)
title = (
    "🟢 Active Sessions (Since Last Shutdown)" if has_resumed
    else "🟢 Active Sessions"
)

Tests

test_render_detail.py

  • test_pure_active_session_no_active_period_panel: pure-active session → no output
  • test_resumed_session_shows_active_period_panel: resumed session → panel rendered with correct stats
  • Updated test_active_session_renders_panel to set has_shutdown_metrics=True
  • Updated test_active_session_shows_active_period_panel to set has_shutdown_metrics=True

test_report.py

  • test_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

⚠️ Firewall blocked 3 domains

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

  • astral.sh
  • index.crates.io
  • pypi.org

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

network:
  allowed:
    - defaults
    - "astral.sh"
    - "index.crates.io"
    - "pypi.org"

See Network Configuration for more information.

Generated by Issue Implementer · ● 17.7M ·

- 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>
Copilot AI review requested due to automatic review settings April 24, 2026 09:26
@microsasa microsasa added the aw Created by agentic workflow label Apr 24, 2026
@microsasa microsasa enabled auto-merge April 24, 2026 09:26
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

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_period so the “🟢 Active Period (since last shutdown)” panel is not shown for pure-active sessions.
  • Made report._render_active_section_from choose 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.

@microsasa microsasa added aw-ci-fix-attempted CI fixer has attempted to fix CI aw-pr-stuck:ci labels Apr 24, 2026
@microsasa
Copy link
Copy Markdown
Owner Author

❌ Pipeline orchestrator: CI still failing after ci-fixer attempt. Marking as stuck for human review.

@microsasa
Copy link
Copy Markdown
Owner Author

CI fix already attempted once — stopping to prevent loops. Manual intervention needed.

Generated by CI Fixer · ● 488.3K ·

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

Labels

aw Created by agentic workflow aw-ci-fix-attempted CI fixer has attempted to fix CI aw-pr-stuck:ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[aw][code health] _render_active_period shows misleading "since last shutdown" panel for pure-active sessions

2 participants