Repository navigation
fix(checks): rank successful checks above skipped and neutral - #11337
Conversation
Greptile SummaryFixes the checks panel ordering so
Confidence Score: 5/5Safe to merge. The change is a pure comparator swap with no side effects on counters, row identity, or data fetching. The core fix is a three-line rank change inside a new shared module. The comparator is pure, the sort is stable, the input array is not mutated, and null/undefined conclusions are handled. The prototype-pollution fix (Map instead of object literal) was correctly identified and addressed before this PR landed. Three previously duplicated rank tables are now a single source of truth, reducing future drift risk. The test suite pins the regression, the full tier ordering, prototype-key edge cases, and immutability. No auth, IPC, filesystem, or network surface is touched. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/shared/pr-check-severity-order.ts | New module: Map-based rank table with success(3) now above neutral(4)/skipped(5); unknown conclusions sink to rank 6; null/undefined treated as pending. Immutable sort with index-based stable tie-breaking. |
| src/shared/pr-check-severity-order.test.ts | Comprehensive test suite: covers the regression case, full tier ordering, prototype property names as unknown, null/undefined as pending, stable ties, immutability, and GitLab-normalized conclusion interop. |
| src/shared/pr-check-status.ts | New shared module: derivePRCheckStatus extracted from duplicate code; handles both typed PRCheckDetail arrays and raw provider rollups (GitHub commit status + GitLab-style state fields). |
| src/renderer/src/components/right-sidebar/checks-panel-content.tsx | Removes inline rank map, imports sortChecksBySeverity from shared module. passingCount/failingCount/pendingCount counters still operate on the unsorted checks array; keys derived from sorted array as before. |
| src/renderer/src/components/task-page-pr-check-summary.ts | Skipped counts as passed; neutral stays separate; action_required counts as failed; unknown completed conclusions fall to neutral. State derivation logic looks correct. |
| src/renderer/src/store/slices/github-checks.ts | Replaced inline check-status derivation with import from shared pr-check-status module; re-exported as deriveCheckStatusFromChecks for backward compat. |
| mobile/src/tasks/mobile-hosted-check-status.ts | New mobile utility: getHostedReviewLabel, getHostedMergeLabel, getHostedChecksLabel, getHostedReviewSignalTone — pure functions over ProviderCheckSummary and PRMergeableState with no side effects. |
| src/renderer/src/components/task-page-linear-cache-selectors.ts | Linear-specific selectors extracted from task-page-cache-selectors.ts; re-exported through the original module for backward compat. Logic appears correct. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["checks: PRCheckDetail[]<br/>(unsorted — used for counters)"] --> B["sortChecksBySeverity(checks)<br/>src/shared/pr-check-severity-order.ts"]
B --> C["sorted: PRCheckDetail[]<br/>rank: failure/timed_out/action_required=0<br/>cancelled=1 · pending=2<br/>✓ success=3 · neutral=4 · skipped=5<br/>unknown=6"]
C --> D["rows[] = sorted.map(check, index ↦ {check, key})<br/>key = checkRunId | workflowRunId | url | fallback:name:index"]
D --> E["ChecksList renders rows in rank order"]
A --> F["passingCount / failingCount / pendingCount<br/>(from unsorted array — unchanged)"]
F --> E
G["PRCheckDetail.conclusion: string | null"] --> H["CHECK_SEVERITY_RANK: Map<string,number>"]
H -->|"Map.get(key) ?? UNKNOWN_CHECK_RANK"| I["rank: number"]
H -->|"null/undefined → 'pending'"| I
Reviews (4): Last reviewed commit: "fix: type mobile GitLab review hydration" | Re-trigger Greptile
📝 WalkthroughWalkthroughAdded shared utilities for ranking PR check conclusions and sorting checks without mutating input arrays. Updated three checks interfaces to use the shared sorting logic, while 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b351c63a-0313-46d3-8d76-71540f95e53f
📥 Commits
Reviewing files that changed from the base of the PR and between 238d3a1 and e3cfa8b7630c43c2c23eed02b97a9b1ed0c5ab9c.
📒 Files selected for processing (5)
src/renderer/src/components/GitHubItemDialog.tsxsrc/renderer/src/components/PullRequestPage.tsxsrc/renderer/src/components/right-sidebar/checks-panel-content.tsxsrc/shared/pr-check-severity-order.test.tssrc/shared/pr-check-severity-order.ts
9c068e2 to
c895a77
Compare
Checks were ordered with `skipped` (4) and `neutral` (3) ahead of `success` (5), so a PR with a long tail of skipped jobs pushed every passing check below the fold — you scroll past a wall of "Skipped" to find out whether anything actually ran. Rank the no-signal conclusions last (`success` 3, `neutral` 4, `skipped` 5) and pull the order out of its three duplicated copies (checks-panel-content, PullRequestPage, GitHubItemDialog) into `src/shared/pr-check-severity-order.ts`. Unknown conclusions now sink to the bottom instead of silently ranking as `neutral`.
An object-literal rank table resolves `constructor`, `toString`, and `__proto__` off Object.prototype, so those keys returned a function instead of falling through to UNKNOWN_CHECK_RANK — the comparator then subtracted functions, went NaN, and left the list in arbitrary order. Conclusions come from provider payloads, so keep the lookup on a Map and cover prototype property names in the test.
c895a77 to
ec793a4
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
mobile/src/tasks/github-check-summary.ts (1)
15-59: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy liftTreat GitHub
skippedconclusions as passing inbuildGitHubCheckSummary.
conclusion: 'skipped'is non-blocking for mergeable checks, matching the existing server-side rollup (['SUCCESS', 'SKIPPED']), but this path drops intoneutralafter a manual refresh. Also align the failure bucket with the same server mapping by includingERRORandSTARTUP_FAILURE, or share one check-status mapping module.🐛 Possible fix
for (const check of checks) { if (isFailedCheck(check) || check.conclusion === 'action_required') { failed += 1 } else if (isPendingCheck(check)) { pending = 1 - } else if (check.conclusion === 'success') { + } else if (check.conclusion === 'success' || check.
🧹 Nitpick comments (1)
mobile/src/tasks/gitlab-check-summary.ts (1)
18-33: 🎯 Functional Correctness | 🔵 Trivial | ⚖️ Poor tradeoff
manualjobs are always mapped toaction_required→ failed, even when they're non-blocking by default.GitLab's own docs note that for
when: manualjobs defined outsiderules, "allow_failure is true, which is the default setting for jobs that have when: manual defined outside of rules. The status does not contribute to the overall pipeline status. A pipeline can succeed even if all of its manual jobs fail." SinceGitLabPipelineJobLikeonly carriesstatus(noallow_failure), an MR with an untriggered, purely-optional manual deploy job will show its checks as "failing" here even though GitLab itself would report the pipeline as passed.If this is intentional per the "Refine GitLab pipeline mapping" layer, feel free to disregard; otherwise consider threading
allow_failurethroughpipelineJobsso optional manual jobs aren't treated the same as blocking ones.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 16d7eed9-5b86-4090-abac-877c093c006e
📥 Commits
Reviewing files that changed from the base of the PR and between c895a775b6ae67d0be10e54896e572836cfbba3a and ec793a4.
📒 Files selected for processing (13)
config/max-lines-baseline.txtmobile/app/h/[hostId]/tasks.tsxmobile/src/session/github-pr-value-readers.tsmobile/src/tasks/github-check-summary.test.tsmobile/src/tasks/github-check-summary.tsmobile/src/tasks/gitlab-check-summary.tsmobile/src/tasks/mobile-hosted-check-status.test.tsmobile/src/tasks/mobile-hosted-check-status.tssrc/main/github/client.tssrc/main/github/mappers.tssrc/main/gitlab/mappers-workitem.test.tssrc/main/gitlab/mappers.test.tssrc/main/gitlab/mappers.ts
💤 Files with no reviewable changes (1)
- config/max-lines-baseline.txt
| if (item.mergeStateStatus === 'BEHIND' || item.checksSummary?.state === 'pending') { | ||
| return 'Behind' | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Pending checks are mislabeled as "Behind" for merge status.
item.checksSummary?.state === 'pending' is OR'd into the same branch as mergeStateStatus === 'BEHIND', so any item with checks still running gets the "Behind" label/tone regardless of its actual merge/branch state. mergeStateStatus ('BLOCKED'/'BEHIND'/'CLEAN') is a GitHub-only concept — GitLab items hydrated via mobile/app/h/[hostId]/tasks.tsx never set it — so for every GitLab MR with a running pipeline, getHostedMergeLabel/getHostedReviewSignalTone('merge') will always fall into this branch and display "Behind", even though the MR isn't behind its target branch at all. The same issue affects GitHub PRs with mergeStateStatus: 'CLEAN' but pending checks.
As per coding guidelines, **/*.{ts,tsx,js,jsx}: "keep provider-specific behavior behind explicit checks... avoid GitHub-only names for generic review concepts" — this shared condition conflates a GitHub-specific field with an unrelated, provider-agnostic checks state.
🐛 Proposed fix: don't conflate pending checks with "Behind"
export function getHostedMergeLabel(item: MobileHostedReviewStatus): string {
if (item.mergeable === 'CONFLICTING' || item.mergeStateStatus === 'BLOCKED') {
return 'Conflicts'
}
- if (item.mergeStateStatus === 'BEHIND' || item.checksSummary?.state === 'pending') {
+ if (item.mergeStateStatus === 'BEHIND') {
return 'Behind'
}
if (item.mergeable === 'MERGEABLE' || item.mergeStateStatus === 'CLEAN') {
return 'Able to merge'
}
return 'Unknown'
}Apply the equivalent change to the merge branch of getHostedReviewSignalTone (lines 99-101) so the tone stays consistent with the label.
Also applies to: 99-101
Source: Coding guidelines
| if ( | ||
| item.reviewDecision === 'review_required' || | ||
| item.reviewDecision === 'REVIEW_REQUIRED' || | ||
| item.reviewerCount !== undefined || | ||
| item.reviewRequests?.length | ||
| ) { | ||
| return 'warning' | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
reviewerCount: 0 is treated as "has reviewers" for tone, but as "No reviewers" for the label.
item.reviewerCount !== undefined is truthy even when reviewerCount is explicitly 0 (a real value set by the GitLab hydration path when reviewers is an empty array), causing this branch to return 'warning'. Meanwhile getHostedReviewLabel treats reviewerCount as falsy at 0 and returns 'No reviewers' — so the chip can show "No reviewers" text with a "warning" tone.
🐛 Proposed fix
if (
item.reviewDecision === 'review_required' ||
item.reviewDecision === 'REVIEW_REQUIRED' ||
- item.reviewerCount !== undefined ||
+ (item.reviewerCount ?? 0) > 0 ||
item.reviewRequests?.length
) {
return 'warning'
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if ( | |
| item.reviewDecision === 'review_required' || | |
| item.reviewDecision === 'REVIEW_REQUIRED' || | |
| item.reviewerCount !== undefined || | |
| item.reviewRequests?.length | |
| ) { | |
| return 'warning' | |
| } | |
| if ( | |
| item.reviewDecision === 'review_required' || | |
| item.reviewDecision === 'REVIEW_REQUIRED' || | |
| (item.reviewerCount ?? 0) > 0 || | |
| item.reviewRequests?.length | |
| ) { | |
| return 'warning' | |
| } |
…ai#11337) * fix(checks): rank successful checks above skipped and neutral Checks were ordered with `skipped` (4) and `neutral` (3) ahead of `success` (5), so a PR with a long tail of skipped jobs pushed every passing check below the fold — you scroll past a wall of "Skipped" to find out whether anything actually ran. Rank the no-signal conclusions last (`success` 3, `neutral` 4, `skipped` 5) and pull the order out of its three duplicated copies (checks-panel-content, PullRequestPage, GitHubItemDialog) into `src/shared/pr-check-severity-order.ts`. Unknown conclusions now sink to the bottom instead of silently ranking as `neutral`. * fix(checks): look up check ranks through a Map, not an object literal An object-literal rank table resolves `constructor`, `toString`, and `__proto__` off Object.prototype, so those keys returned a function instead of falling through to UNKNOWN_CHECK_RANK — the comparator then subtracted functions, went NaN, and left the list in arbitrary order. Conclusions come from provider payloads, so keep the lookup on a Map and cover prototype property names in the test. * test(checks): cover provider-neutral ordering states * fix(checks): preserve actionable provider states * fix(checks): preserve unresolved provider rollups * fix(checks): keep unknown GitLab rollups neutral * fix: preserve neutral review check summaries * fix: complete provider-neutral check ordering remediation * fix: use provider-neutral mobile review status input * fix: hydrate GitLab mobile review status * fix: type mobile GitLab review hydration --------- Co-authored-by: OrcaWin <[email protected]>
Summary
The PR checks list sorted
skippedandneutralabovesuccess, so on a repo where most workflow jobs are conditional, the checks panel opens on a wall ofSkippedrows and every passing check sits below the fold. You have to scroll past a dozen no-op jobs to learn whether anything actually ran.The rank map lived in three duplicated copies (
checks-panel-content.tsx,PullRequestPage.tsx,GitHubItemDialog.tsx), all withneutral: 3, skipped: 4, success: 5.This PR moves the no-signal conclusions to the bottom and extracts the single ordering into
src/shared/pr-check-severity-order.ts:failure/timed_out/action_requiredcancelledpendingsuccessneutralskippedneutral)Relative order inside the failure tier and the ties between
failure/timed_out/action_requiredare unchanged, so nothing about failure triage moves.Screenshots
Ordering change only — same rows, same styling, no layout or token changes.
On a PR with 19 passing checks and ~7 skipped jobs, the panel now reads:
Testing
pnpm lint— every sub-step run individually and passing (oxlint,audit:code-quality:native,audit:code-quality:type-aware,check:reliability-gates,check:max-lines-ratchet,verify:bundled-skill-guides,verify:skill-bundle-manifest,verify:localization-catalog,verify:localization-coverage). The single chainedpnpm lintinvocation OOM-killed the linter process on my machine before finishing; each step is green on its own.pnpm typecheckpnpm test— targeted plus a broad sweep ofsrc/renderer/src/componentsandsrc/shared: 1697 files / 14339 tests passingpnpm build(build:desktopandbuild:native, both exit 0)src/shared/pr-check-severity-order.test.ts: pins the reported regression (passing checks above skipped/neutral noise), the failure → in-flight → success tiering, unknown conclusions sinking last, prototype property names (constructor,toString,hasOwnProperty,__proto__) ranking as unknown,null/undefinedtreated aspending, and that the input array is not mutated.AI Review Report
Reviewed the diff with Claude, focused on:
successmoving aboveneutral/skippedplus unknown conclusions sinking last. Counters (passingCount,failingCount,pendingCount), the summary label, auto-expand-first-failed, and check-detail keys all derive from the unsorted list or from row identity, so none of them shift.getCheckDetailsKey(contextKey, check, index)uses the sorted index as a fallback whencheckRunIdis absent, so expanded-details state is keyed off list position. Rechecked that keys are recomputed from the samesortedarray they index into, and that the existing prune-invalid-keys effect covers the reordering.metaKey, no shortcut labels, no paths, no shell, no Electron API. Identical on macOS, Linux, and Windows.PRCheckDetail[]; it does not touch a process, file, credential, or network path.FolderWorkspacePrChecksPanelrenders through the sameChecksList, so folder workspaces get the fix too.PRCheckDetail['conclusion']union, so GitLab pipeline checks (which map into the same conclusions viasrc/shared/gitlab-pipeline-checks.ts) sort by the same rule.Object-lookup comparator over an already-materialized array, memoized in the sidebar panel exactly as before. No new allocation in a hot path; three duplicated maps became one.pr-check-severity-order.tsper AGENTS.md (nohelpers/utils/common).Flagged and addressed: the old
?? 3fallback quietly ranked unrecognized conclusions asneutral, meaning a future GitHub conclusion would outrank real successes. Replaced with an explicit last-place rank and covered by a test.Security Audit
No input handling, command execution, path handling, auth, secrets, dependency, or IPC surface is touched. The new module is a pure comparator over data already fetched and rendered; no new dependency, no new IPC channel, no user-controlled string reaching a shell or filesystem call.
Correction to my first pass: this section originally claimed the rank lookup could not reach prototype-inherited properties. That was wrong, and CodeRabbit caught it. The rank table was an object literal, so a conclusion named
constructor/toString/__proto__resolved a function offObject.prototype, skipped the?? UNKNOWN_CHECK_RANKfallback, and made the comparator returnNaN— scrambling the whole list rather than misplacing one row.conclusionarrives asstringfrom provider payloads, so the union type does not actually constrain it. Fixed in 9c068e2: the table is now aMap, with prototype property names covered in the test.Notes
No platform-, remote-, agent-, integration-, or provider-specific behavior. Follow-up worth considering (not in this PR):
getCheckConclusionandgetCheckStatusLabelare still duplicated verbatim betweenPullRequestPage.tsxandGitHubItemDialog.tsxand could join the same module.