Conversation
…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>
There was a problem hiding this comment.
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 = Nonetorender_live_sessions()andrender_summary(), usingtarget_console or Console()internally. - Update test helpers to pass a real
Console(file=StringIO())viatarget_console=instead of patching/monkeypatchingConsole.
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.
There was a problem hiding this comment.
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.
Closes #160
Changes
Adds a keyword-only
target_console: Console | None = Noneparameter to bothrender_live_sessions()andrender_summary(), matching the pattern already used byrender_full_summary,render_cost_view, andrender_session_detail.report.pyrender_live_sessions— added*, target_console: Console | None = None; replacedconsole = Console()withconsole = target_console or Console()render_summary— same changetest_report.py_capture_output— removedpatch("copilot_usage.report.Console", ...)workaround; now passestarget_console=consoledirectly_capture_summary— removed module-level monkeypatching of_mod.Console; now passestarget_console=consoledirectlyTesting
All 420 existing tests pass. Coverage remains at 98%.
Warning
The following domain was blocked by the firewall during workflow execution:
astral.shTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.