Skip to content

fix(checks): rank successful checks above skipped and neutral - #11337

Merged
Jinwoo-H merged 11 commits into
stablyai:mainfrom
hanqyu:fix/checks-sort-successful-above-skipped
Jul 30, 2026
Merged

Jinwoo-H merged 11 commits into
stablyai:mainfrom
hanqyu:fix/checks-sort-successful-above-skipped

Conversation

@hanqyu

@hanqyu hanqyu commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The PR checks list sorted skipped and neutral above success, so on a repo where most workflow jobs are conditional, the checks panel opens on a wall of Skipped rows 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 with neutral: 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:

before after
failure / timed_out / action_required 0 0
cancelled 1 1
pending 2 2
success 5 3
neutral 3 4
skipped 4 5
unrecognized conclusion 3 (silently neutral) 6 (last)

Relative order inside the failure tier and the ties between failure/timed_out/action_required are 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:

before                          after
─ daily-cleanup     Skipped     ✓ Smoke: Lab API     Successful
─ build-admin       Skipped     ✓ Validate Configs   Successful
─ build-monitor     Skipped     ✓ Validate Kustomize Successful
─ cleanup-preview   Skipped     …
… (scroll) …                    ─ daily-cleanup      Skipped
✓ Smoke: Lab API    Successful  ─ build-admin        Skipped

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 chained pnpm lint invocation OOM-killed the linter process on my machine before finishing; each step is green on its own.
  • pnpm typecheck
  • pnpm test — targeted plus a broad sweep of src/renderer/src/components and src/shared: 1697 files / 14339 tests passing
  • pnpm build (build:desktop and build:native, both exit 0)
  • Added 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/undefined treated as pending, and that the input array is not mutated.

AI Review Report

Reviewed the diff with Claude, focused on:

  • Behavior scope — verified the only ordering change is success moving above neutral/skipped plus 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.
  • Row identity — getCheckDetailsKey(contextKey, check, index) uses the sorted index as a fallback when checkRunId is absent, so expanded-details state is keyed off list position. Rechecked that keys are recomputed from the same sorted array they index into, and that the existing prune-invalid-keys effect covers the reordering.
  • Cross-platform — pure comparator logic, no metaKey, no shortcut labels, no paths, no shell, no Electron API. Identical on macOS, Linux, and Windows.
  • SSH/remote and folder workspaces — the module is a pure function over already-fetched PRCheckDetail[]; it does not touch a process, file, credential, or network path. FolderWorkspacePrChecksPanel renders through the same ChecksList, so folder workspaces get the fix too.
  • Git providers — naming is provider-neutral and the ranks are keyed on the generic PRCheckDetail['conclusion'] union, so GitLab pipeline checks (which map into the same conclusions via src/shared/gitlab-pipeline-checks.ts) sort by the same rule.
  • Performance — one 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.
  • Naming — pr-check-severity-order.ts per AGENTS.md (no helpers/utils/common).

Flagged and addressed: the old ?? 3 fallback quietly ranked unrecognized conclusions as neutral, 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 off Object.prototype, skipped the ?? UNKNOWN_CHECK_RANK fallback, and made the comparator return NaN — scrambling the whole list rather than misplacing one row. conclusion arrives as string from provider payloads, so the union type does not actually constrain it. Fixed in 9c068e2: the table is now a Map, 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): getCheckConclusion and getCheckStatusLabel are still duplicated verbatim between PullRequestPage.tsx and GitHubItemDialog.tsx and could join the same module.

@greptile-apps

greptile-apps Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Greptile Summary

Fixes the checks panel ordering so success ranks above neutral and skipped, and extracts the previously triplicated rank map into a single shared module (src/shared/pr-check-severity-order.ts). A secondary extraction moves derivePRCheckStatus into src/shared/pr-check-status.ts, and several mobile/task-page utilities are split into dedicated files to reduce line-count violations.

  • Rank reorder: success moves from rank 5 → 3 (above neutral=4, skipped=5); unrecognized conclusions now sink to rank 6 instead of silently masquerading as neutral=3. A Map replaces the previous object literal to prevent prototype property names (constructor, toString, etc.) from resolving to non-number ranks and scrambling the comparator.
  • Shared extraction: Three duplicated rank tables in checks-panel-content.tsx, PullRequestPage.tsx, and GitHubItemDialog.tsx are replaced by a single sortChecksBySeverity import; derivePRCheckStatus similarly consolidated.
  • Test coverage: New pr-check-severity-order.test.ts pins the regression, tier ordering, prototype-key safety, null/undefined handling, stable ties, and input immutability.

Confidence Score: 5/5

Safe 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.

Important Files Changed

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
Loading

Reviews (4): Last reviewed commit: "fix: type mobile GitLab review hydration" | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Added 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 PullRequestPage separates conclusion categorization and summary calculations into helpers. Added neutral check-summary handling, GitLab pipeline conversion, hosted review/check/merge helpers, GitLab task hydration, and provider mapping updates.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.73% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: reprioritizing check sorting.
Description check ✅ Passed The description follows the required template and includes the requested summary, screenshots, testing, review, security, and notes sections.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.tsx
  • src/renderer/src/components/PullRequestPage.tsx
  • src/renderer/src/components/right-sidebar/checks-panel-content.tsx
  • src/shared/pr-check-severity-order.test.ts
  • src/shared/pr-check-severity-order.ts

Comment thread src/shared/pr-check-severity-order.ts Resolved
@hanqyu
hanqyu force-pushed the fix/checks-sort-successful-above-skipped branch from 9c068e2 to c895a77 Compare July 29, 2026 12:24
hanqyu and others added 11 commits July 30, 2026 00:53
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.
@Jinwoo-H
Jinwoo-H force-pushed the fix/checks-sort-successful-above-skipped branch from c895a77 to ec793a4 Compare July 30, 2026 07:55

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 lift

Treat GitHub skipped conclusions as passing in buildGitHubCheckSummary.

conclusion: 'skipped' is non-blocking for mergeable checks, matching the existing server-side rollup (['SUCCESS', 'SKIPPED']), but this path drops into neutral after a manual refresh. Also align the failure bucket with the same server mapping by including ERROR and STARTUP_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

manual jobs are always mapped to action_required → failed, even when they're non-blocking by default.

GitLab's own docs note that for when: manual jobs defined outside rules, "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." Since GitLabPipelineJobLike only carries status (no allow_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_failure through pipelineJobs so 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.txt
  • mobile/app/h/[hostId]/tasks.tsx
  • mobile/src/session/github-pr-value-readers.ts
  • mobile/src/tasks/github-check-summary.test.ts
  • mobile/src/tasks/github-check-summary.ts
  • mobile/src/tasks/gitlab-check-summary.ts
  • mobile/src/tasks/mobile-hosted-check-status.test.ts
  • mobile/src/tasks/mobile-hosted-check-status.ts
  • src/main/github/client.ts
  • src/main/github/mappers.ts
  • src/main/gitlab/mappers-workitem.test.ts
  • src/main/gitlab/mappers.test.ts
  • src/main/gitlab/mappers.ts
💤 Files with no reviewable changes (1)
  • config/max-lines-baseline.txt

Comment on lines +32 to +34
if (item.mergeStateStatus === 'BEHIND' || item.checksSummary?.state === 'pending') {
return 'Behind'
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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

Comment on lines +74 to +81
if (
item.reviewDecision === 'review_required' ||
item.reviewDecision === 'REVIEW_REQUIRED' ||
item.reviewerCount !== undefined ||
item.reviewRequests?.length
) {
return 'warning'
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

Suggested change
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'
}

@Jinwoo-H
Jinwoo-H merged commit 6f3845b into stablyai:main Jul 30, 2026
1 check passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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]>
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.

4 participants