Show time spent in draft on PR dashboard - #272
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: da8d0334-64a0-4ae5-a6b4-1540971e8450
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Updates the pull request dashboard to show how long PRs have been in draft (based on the latest “convert to draft” event, with a creation-time fallback) instead of GitHub’s general updated timestamp.
Changes:
- Render draft PRs with a new “Draft age” column sorted by
draftSince(orcreatedAtfallback). - Add GitHub GraphQL support to fetch latest “convert to draft” transitions in batches.
- Extend unit tests to cover rendering/sorting of draft age and
draftSinceenrichment behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| .github/scripts/pull-request-dashboard/render.py | Renders “Draft age” using draftSince / createdAt and sorts drafts accordingly. |
| .github/scripts/pull-request-dashboard/publish_dashboard.py | Enriches draft PRs with draftSince using a GraphQL lookup (conditionally). |
| .github/scripts/pull-request-dashboard/github_cli.py | Adds fetch_latest_draft_transitions() and switches list_open_prs to return createdAt. |
| .github/scripts/pull-request-dashboard/test_render.py | Adds a test validating draft age rendering and sorting. |
| .github/scripts/pull-request-dashboard/test_publish_dashboard.py | Adds a test for draftSince enrichment with fallback to creation time. |
| .github/scripts/pull-request-dashboard/test_github_cli.py | Adds a test for consolidated GraphQL querying of draft transitions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Copilot comment: The GraphQL query is built with large triple-quoted blocks per PR, which adds substantial whitespace and can significantly bloat query size for larger batches. To reduce the likelihood of hitting GitHub's GraphQL query size/complexity limits (and to speed up requests), consider generating a more compact query string (e.g., stripping/dedenting the per-PR block, or using a single-line template) and/or lowering `_DRAFT_TRANSITION_BATCH_SIZE` if needed. Analysis: The previous implementation built each per-PR selection using a triple-quoted f-string with four levels of indentation plus leading/trailing blank lines, contributing roughly 200 bytes of whitespace per PR. For a batch of 50 PRs that is about 10 KB of pure whitespace in a single query string. The fix replaces the multi-line template with a single-line format that preserves the same GraphQL structure and spacing conventions that the existing tests assert (e.g. `pr_7: pullRequest`), joining selections with a single space rather than newlines and indentation. Upsides: Reduces query payload size proportionally to batch size, lowering the chance of hitting GitHub GraphQL complexity or size limits. No semantic change to the query itself. Downsides: The query is now a single long line, which is less readable in isolation, but the logic stays in one place and the tests still assert the exact alias and field structure. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Pull request dashboard statusWaiting on reviewers · refreshed 2026-08-20 17:29 UTC Review the latest changes. Status above doesn't look right?
|
The draft PR table now shows how long each pull request has been in draft instead of GitHub's general updated timestamp, which dashboard status-comment edits can reset.
For PRs returned to draft, the clock starts at the latest conversion. For PRs opened as drafts, it starts at PR creation.