Skip to content

fix: add target_console to render_live_sessions and render_summary (#160)#188

Merged
microsasa merged 1 commit intomainfrom
fix/160-add-target-console-parameter-70e63679814ceb82
Mar 21, 2026
Merged

fix: add target_console to render_live_sessions and render_summary (#160)#188
microsasa merged 1 commit intomainfrom
fix/160-add-target-console-parameter-70e63679814ceb82

Conversation

@microsasa
Copy link
Owner

Closes #160

Changes

Adds a keyword-only target_console: Console | None = None parameter to both render_live_sessions() and render_summary(), matching the pattern already used by render_full_summary, render_cost_view, and render_session_detail.

report.py

  • render_live_sessions — added *, target_console: Console | None = None; replaced console = Console() with console = target_console or Console()
  • render_summary — same change

test_report.py

  • _capture_output — removed patch("copilot_usage.report.Console", ...) workaround; now passes target_console=console directly
  • _capture_summary — removed module-level monkeypatching of _mod.Console; now passes target_console=console directly

Testing

All 420 existing tests pass. Coverage remains at 98%.

Generated by Issue Implementer ·

Warning

⚠️ Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • astral.sh

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

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

See Network Configuration for more information.

…summary (#160)

Add keyword-only target_console parameter to render_live_sessions() and
render_summary() for API consistency with the other render functions.

Update test helpers _capture_output and _capture_summary to use
target_console= directly instead of monkeypatching Console.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@microsasa microsasa added the aw Created by agentic workflow label Mar 21, 2026
Copilot AI review requested due to automatic review settings March 21, 2026 02:04
@microsasa microsasa added the aw Created by agentic workflow label Mar 21, 2026
@microsasa microsasa enabled auto-merge March 21, 2026 02:04
Copy link

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 aligns the public rendering API in copilot_usage.report by adding an optional, keyword-only target_console parameter to the remaining render helpers that previously instantiated their own Console(). This removes the need for test-time monkeypatching and enables callers to share a single configured Rich console across render functions.

Changes:

  • Add *, target_console: Console | None = None to render_live_sessions() and render_summary(), using target_console or Console() internally.
  • Update test helpers to pass a real Console(file=StringIO()) via target_console= instead of patching/monkeypatching Console.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/copilot_usage/report.py Adds target_console to render_live_sessions and render_summary and routes output through the provided console when present.
tests/copilot_usage/test_report.py Simplifies output-capture helpers by passing target_console directly, removing prior Console patching/monkeypatching workarounds.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@microsasa microsasa added the aw-quality-gate-approved Quality gate approved the PR label Mar 21, 2026
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Quality Gate: APPROVED

Low-impact API consistency refactoring. Adds target_console keyword-only parameter to render_live_sessions() and render_summary(), matching the pattern used by 15+ other render functions in the same file. Backward compatible (optional param with None default). Test helpers simplified by replacing fragile monkeypatching with direct injection. Net -15 lines.

Auto-approving for merge.

@microsasa microsasa merged commit c9d8ec8 into main Mar 21, 2026
8 checks passed
@microsasa microsasa deleted the fix/160-add-target-console-parameter-70e63679814ceb82 branch March 21, 2026 02:08
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-quality-gate-approved Quality gate approved the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[aw][code health] render_live_sessions and render_summary inconsistently omit target_console parameter

2 participants