refactor: share check status mapping between host-service and desktop

Merged
KI
1mo ago
+129-144

Summary

Host-service and the desktop pull request view each had a copy of two functions:

  • GitHub check run status and conclusion → success / failure / pending / skipped / cancelled
  • a list of checks → one overall status

The copies drifted. The desktop mapped STARTUP_FAILURE to failure, host-service did not, so a check that never started kept a PR pending (#8962, fixed in #8963).

This moves both functions to a new @superset/shared/pull-request-checks module and uses it from:

  • packages/host-service/.../pull-request-mappers.ts (parseCheckContexts), pull-requests.ts, and trpc/router/pull-requests/pull-request-checks.ts
  • apps/desktop/.../pull-requests/utils/toPullRequestDetail.ts

Host-service's local ChecksStatus and PullRequestCheck types now come from @superset/shared/pull-request. They have the same values, so the tRPC output does not change.

Not changed on purpose

  • v2 workspace computeChecksRollup: it also counts checks, rolls up all-skipped to none, and maps unknown conclusions to failure. Sharing it would change what the UI shows.
  • Mobile effectiveCheckStatus: a different vocabulary (needs-action, ignored, neutral counts as passed).
  • v1 pr-resolution.ts: v1 is being sunset.

Tests

  • The aggregate tests moved from host-service into pull-request-checks.test.ts, plus one table test over every conclusion. Removing the STARTUP_FAILURE case makes it fail (7 pass, 1 fail).
  • packages/shared pull-request-checks: 8 pass. packages/host-service pull-requests: 187 pass. apps/desktop pull-requests: 66 pass.
  • tsc passes in packages/shared and packages/host-service. Desktop tsc locally reports only TS1149 path-casing errors in packages/chat-runtime caused by my worktree path, none in changed files; CI will confirm.
  • biome check clean on the changed files.

Summary by cubic

Consolidates the GitHub check status and aggregate rollup logic that was duplicated between host-service and the desktop pull request view into a new @superset/shared/pull-request-checks module.

The copies had drifted: the desktop mapped STARTUP_FAILURE to failure, host-service did not, so a check that never started kept a PR pending indefinitely. Both packages now import checkRunStatus and computeChecksStatus from the shared module, and host-service's ChecksStatus and PullRequestCheck types come from @superset/shared/pull-request with identical values, so the tRPC output is unchanged.

Not shared on purpose

  • The v2 workspace computeChecksRollup and mobile effectiveCheckStatus stay local because they count checks differently (skipped/neutral handling, additional statuses like needs-action).
  • Test coverage for both functions moved into pull-request-checks.test.ts, including a table test over every GitHub conclusion.

Summary by CodeRabbit

  • Bug Fixes
    • Pull request check summaries now consistently reflect failed, cancelled, pending, and successful checks.
    • Skipped checks are treated as successful when determining the overall status; an empty check list is shown as having no status.