Conversation
Extract shared hours/minutes/seconds decomposition logic into a single _format_timedelta(td: timedelta) helper. Rewrite format_duration, _format_elapsed_since, and _format_detail_duration to delegate to it. - format_duration (public API): signature unchanged - _format_elapsed_since: now uses compact format via _format_timedelta - _format_detail_duration: now uses compact format via _format_timedelta - Added direct unit tests for _format_timedelta core helper - Updated boundary tests to match compact formatting Closes #243 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors copilot_usage.report duration rendering by consolidating duplicated hours/minutes/seconds formatting logic into a single private helper (_format_timedelta), and updates tests to reflect the new compact output format.
Changes:
- Added
_format_timedelta(td: timedelta)as the core duration formatter. - Updated
format_duration,_format_elapsed_since, and_format_detail_durationto delegate to_format_timedelta. - Extended/adjusted test coverage to validate
_format_timedeltadirectly and align boundary expectations (e.g.,60s -> "1m").
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 |
Introduces _format_timedelta and routes existing duration helpers through it. |
tests/copilot_usage/test_report.py |
Adds direct unit tests for _format_timedelta and updates expected strings for compact formatting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
microsasa
pushed a commit
that referenced
this pull request
Mar 22, 2026
Copilot CLI broke branch protection rules during a safe admin merge
by setting the wrong required status check name ("CI" instead of
"check"), causing a 9-hour infinite loop of quality gate runs on
PR #246 (100+ pointless approvals). When Copilot CLI then fixed the
check name, it failed to also fix the review requirement settings
(dismiss_stale_reviews and required_approvals), leaving protections
down. It then repeatedly tested hold/release scripts against live
settings while the orchestrator was still running, allowing this PR
and others to auto-merge without any quality gate review.
Copilot CLI is a liar and cannot be trusted with repository settings.
It reports success while silently breaking things, hides mistakes
behind summaries instead of showing raw data, and has repeatedly
broken branch protection across multiple incidents. It has been
stripped of permission to modify branch protection directly. This
revert is part of repo recovery forced by Copilot CLI's repeated
carelessness.
This reverts commit 579eaf6.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Consolidates three duration-formatting functions in
report.pyinto a single core helper_format_timedelta(td: timedelta), as specified in #243.Changes
src/copilot_usage/report.py_format_timedelta(td: timedelta) -> str— single core helper for hours/minutes/seconds decomposition and formattingformat_duration(ms: int)— now delegates to_format_timedelta(timedelta(milliseconds=ms)); public API signature unchanged_format_elapsed_since(start)— now delegates to_format_timedelta(now - start)_format_detail_duration(start, end)— now returns"—"for None, else delegates to_format_timedelta(end - start)tests/copilot_usage/test_report.pyTestFormatTimedeltaclass with 9 test cases covering zero, negative, seconds-only, minutes+seconds, exact minute, exact hour, full h/m/s, hours+minutes, and hours+seconds_format_elapsed_sinceand_format_detail_durationto match the compact format (e.g."1m"instead of"1m 0s")Verification
All 518 tests pass, coverage at 98.74% (threshold: 80%). Full CI suite (
ruff check,ruff format,pyright,pytest --cov) passes cleanly.Closes #243