Skip to content

fix: GitHub PRs never showed review glyphs, and CI dots misreported multi-workflow pushes - #7

Open
ubuntudroid wants to merge 3 commits into
krystof018:mainfrom
ubuntudroid:fix/github-review-glyph-isdraft
Open

fix: GitHub PRs never showed review glyphs, and CI dots misreported multi-workflow pushes#7
ubuntudroid wants to merge 3 commits into
krystof018:mainfrom
ubuntudroid:fix/github-review-glyph-isdraft

Conversation

@ubuntudroid

Copy link
Copy Markdown

Two independent bugs made the plugin's GitHub support look broken on real-world repos. Both are root-caused, regression-tested, and verified live against PRs on a repo with many workflows per push.

1. Review glyphs never appeared on GitHub PRs

In gci_review_for_mr(), the draft flag was extracted with

jq -r '.data.repository.pullRequest.isDraft // empty'

jq's // operator treats false as falsy — not just null — so every non-draft PR (isDraft: false) collapsed to empty, tripped the [ -n "$draft" ] guard, and returned with GCI_REVIEW="". Draft PRs passed the guard but render no badge by policy anyway: no GitHub PR could ever show a review glyph. GitLab was unaffected (detailed_merge_status is a string).

Fixed by bailing only on a genuinely missing PR:

jq -r 'if .data.repository.pullRequest == null then empty else (.data.repository.pullRequest.isDraft|tostring) end'

2. CI dot misreported repos with several workflows per push

gci_latest_ci() sampled a single workflow run (actions/runs?branch=X&per_page=1) — whichever was created last. On repos where a push triggers several workflows, that is often a skip-conditioned one, so a green or running push rendered as the ⚪ "other" state (observed live: a skipped "Claude Code" run masking 17 green + 1 running checks).

Fixed by aggregating all check runs on the branch head — the same signal the PR page shows — with the most severe canonical status winning (failed > running > pending > manual > canceled > success > unknown > skipped). The decisive run supplies id/url/updated for the CI pane. A 404 (branch not on the remote yet/anymore) now counts as "no CI" instead of a transient error, so labels don't freeze.

Tests

  • gci_review_for_mr github path covered by stubbing gh with a shell function: non-draft (the regression), draft, and missing-PR responses.
  • gci_github_checks_status covered for severity ordering, queued→pending, skipped-only, and empty input — including the tab-IFS field-collapse edge case for runs without a conclusion.

bash test.sh: 113 checks green.

🤖 Generated with Claude Code

ubuntudroid and others added 3 commits July 17, 2026 18:55
jq's // operator treats false as falsy, so `.isDraft // empty` erased
isDraft:false and the guard bailed with GCI_REVIEW="" — no GitHub PR
could ever show a review glyph. Extract via an explicit null check on
.pullRequest instead, so only a missing PR bails.

Regression-tested by stubbing gh with a shell function in test.sh:
non-draft, draft, and missing-PR responses.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
actions/runs?branch=X&per_page=1 returns whichever workflow run was
created last — on repos with several workflows per push that is often a
skip-conditioned one (e.g. "Claude Code"), so a green or running push
rendered as the ⚪ 'other' state. Fetch the branch head's check runs
(what the PR page aggregates) and let the most severe canonical status
win: failed > running > pending > manual > canceled > success >
unknown > skipped. The winning run supplies id/url/updated for the CI
pane; a 404 (branch not on the remote) counts as no CI rather than a
transient error, so labels don't freeze.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
commits/<ref>/check-runs answers 422 "No commit found for SHA" when the
ref doesn't resolve — 404 only covers a missing repo. Merged branches
are typically auto-deleted, so the previous 404-only guard returned
rc 5 (api-error), making the poller SKIP the workspace every cycle:
the stale pre-merge label froze and gci_merged_pr never ran.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant