Skip to content

feat(code-review): Team tab with a per-person scorecard for reviews and CI - #2018

Merged
Makisuo merged 3 commits into
mainfrom
feat/code-review-team
Oct 31, 2026
Merged

Makisuo merged 3 commits into
mainfrom
feat/code-review-team

Conversation

@Makisuo

@Makisuo Makisuo commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Adds a Team tab to Code Review (/code-review/team): one row per person, built from the PR reviews and CI runs Maple already stores, with the team's health numbers above it.

Scorecard Ranked
Team tab, light Ranked view, light
Team tab, dark Ranked view, dark
Mobile Mobile, scorecard

New page, so there is no before: the tab strip had Analytics, Pull requests, CI, Issues and Settings. The screenshots are /lab/code-review-team, the real page inside the real shell over a seven-person fixture team (made-up logins, so the avatars are generated tiles).

What it shows

  • Team KPIs: pull requests merged, median review to merge, median time to first review, default-branch failure rate, CI time per merged PR, p95 runner wait.
  • Highlights: most findings fixed, steadiest CI, quickest to merge. Each one needs enough data to mean something; a team of one gets none.
  • Scorecard: per person, shown next to a Team median row. Columns: merged, time to merge, fix rate (findings fixed, over fixed plus still open when the PR merged), critical findings per PR, first-try green CI, rerun rate, shipped clean (post-merge verdict), runner time. Every column sorts. Hovering a cell shows the counts behind it.
  • Ranked (opt-in, ?ranked=true): numbers people by one rate or median, only for people with at least 5 reviewed PRs. Count columns (merged, CI time) can't be ranked, so ranking never rewards volume.

Making the CI data fair

Checked on our own org first. Two things would have made a naive leaderboard lie:

  • Fork PR runs waiting for maintainer approval were stored as one long failed run. One outside contributor showed 381 CI hours from 11 runs. The new ciActorStatsQuery only counts runs with a job that actually ran, and measures runner time from jobs minus queue: that contributor drops to 0.14h.
  • Bots ([bot] logins) are left out of the people rows. They still count in team runner time and the default-branch rate, since they share the runners.

How it works

  • GET /internal/code-review/team → CodeReviewTeamService. It reads per-PR folds of pr_reviews (a PR counts when its first review is in the window), per-PR finding counts, the CI per-actor query and runner queue totals, all at once, then merges them by GitHub login.
  • The contract returns counts, not rates. The page computes rates, medians, sorting, ranking and highlights in team/derive.ts.
  • The default branch is matched per repository (owner, name, branch), from each repo's own setting.

Verification

  • CodeReviewTeamService.test.ts (PGlite and a stubbed warehouse): the fold across a PR's reviews, a re-reviewed older PR not counting, fix rate judged at merge, bots dropped, CI-only people, per-repo default branch in the SQL, and another org's repo id reading nothing. Writing it caught a real bug: having min(created_at) loses the timestamp codec.
  • derive.test.ts covers rates, medians, ordering with nulls last, ranking eligibility, shared ranks and highlights. team.scene.test.ts covers fetch on entry, sort and ranked URLs, the median row, ranked filtering, inert count headers and the empty on-ramp.
  • Ran the CI query against our org over 30 days.
  • Typecheck passes for web, api, backend and query-engine. Code Review web tests: 61 passed. query-engine src/ch + src/benchmark: 843 passed. Lint: no errors.
  • An independent review pass found six issues: fix-rate numerator, first-review window, findings scope, the actor-row cap feeding totals, default branch per repo, and ranked headers. All are fixed in this PR.

Not covered here: human reviewers. The webhook doesn't ingest pull_request_review events yet, so approvals and time to first human review are a follow-up.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

…nd CI

One row per GitHub login from PR reviews and CI runs: merged, time to merge,
fix rate at merge, critical findings per PR, first-try green, reruns, shipped
clean and runner time, shown next to the team median. Ranked is opt-in and
ranks rates only, for people with at least five reviewed pull requests.

Bots are left out, and CI runs with no job that ran (fork runs waiting for
approval) are dropped, so they no longer read as hours of failed CI.
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f1e7eb91-bc10-4ed3-a93c-17934209019e
Commits

Reviewing files that changed from the base of the PR and between 33def5a and 359f925.

Files ignored due to path filters: 1
  • apps/web/src/ui/icons.generated.ts is excluded by !**/*.generated.*
Files selected for processing: 26
  • apps/api/src/routes/internal/code-review.http.ts
  • apps/api/src/runtime/service-graph.ts
  • apps/web/src/lab/entries/code-review-team.ts
  • apps/web/src/lab/registry.ts
  • apps/web/src/page/code-review/index.ts
  • apps/web/src/page/code-review/kit/api.ts
  • apps/web/src/page/code-review/kit/layout.ts
  • apps/web/src/page/code-review/kit/retained.ts
  • apps/web/src/page/code-review/tabs-update.ts
  • apps/web/src/page/code-review/tabs.ts
  • apps/web/src/page/code-review/team/derive.test.ts
  • apps/web/src/page/code-review/team/derive.ts
  • apps/web/src/page/code-review/team/model.ts
  • apps/web/src/page/code-review/team/team.scene.test.ts
  • apps/web/src/page/code-review/team/update.ts
  • apps/web/src/page/code-review/team/view.ts
  • apps/web/src/route/app-route.ts
  • apps/web/src/route/routers.ts
  • apps/web/src/route/search.ts
  • packages/backend/src/services/pr-review/CodeReviewTeamService.test.ts
  • packages/backend/src/services/pr-review/CodeReviewTeamService.ts
  • packages/domain/src/http/code-review.ts
  • packages/query-engine/src/__sql_baseline__/catalog.sql
  • packages/query-engine/src/benchmark/builders.ts
  • packages/query-engine/src/ch/index.ts
  • packages/query-engine/src/ch/queries/ci-runs.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@maple-review-bot

This comment has been minimized.

@Makisuo Makisuo added the preview:web Deploy a Workers-only PR preview (no ingest/Electric); see docs/pr-previews.md label Oct 31, 2026
@Makisuo
Makisuo deployed to pr-preview October 31, 2026 14:39 — with GitHub Actions Active

@maple-review-bot maple-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 inline note from Maple's review. The score and summary are in the review comment above.

@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

🍁 Maple PR preview

Note

Preview resources were removed when this pull request closed.

Final commit 359f925 · View workflow run

@Makisuo
Makisuo deployed to pr-preview October 31, 2026 14:45 — with GitHub Actions Active
@maple-review-bot

maple-review-bot Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Maple review

🟢 Confidence 8/10 · likely safe to merge. Held at 8 because earlier reviews of this pull request found 1 defect.
no findings · tests covered · risk medium · 3/3 new units observable · 1 defect fixed in earlier rounds

Adds the Code Review Team tab: a tenant-scoped /internal/code-review/team endpoint, the ciActorStatsQuery per-actor CI fold, and the scorecard page over it. Since the last review only a satisfies clause and one comment changed; safe to merge.

  • ciActorStatsQuery folds runs and ran jobs per GitHub actor
  • CodeReviewTeamService merges review and CI counts per login
  • Team tab derives rates, medians, sorting and ranking

Fixed since the last review

  • ✅ F1 · ciActorStatsQuery emits Branch IN () when the org has no repository

359f925 · What was checked, coverage and telemetry details are on the Maple / review check. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.

@Makisuo
Makisuo deployed to pr-preview October 31, 2026 14:47 — with GitHub Actions Active
@Makisuo

Makisuo commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator Author

Preview test (app-pr-2018.maple.dev, 359f925)

A separate agent tested the preview with only the PR context. It found no bugs.

The preview org has no PR reviews or CI runs, so every view shows the empty states. The scorecard with data is covered by the lab screenshots in the description.

Check Result
/code-review/team inside the shell, Team tab current ✅ "No team activity yet" on-ramp
GET /_api/internal/code-review/team ✅ 200, ~340ms round trip, expected shape
Analytics → CI → Team ✅ Team re-renders from the retained answer, no second request
Time range change (?timePreset=1w) ✅ new request, 200
Unknown ?repo= ✅ "Nobody in this window" + Clear filters, which returns to the default
?ranked=true, ?sort=fixRate deep links ✅ load cleanly
390px mobile ✅ no horizontal overflow (scrollWidth 390 = clientWidth)
Console / page errors from this page ✅ none. The only errors were 503s from the live-sync shape stream, which preview:web doesn't deploy

An invalid ?sort=bogus shows "Page not found". That is how the app treats bad search params on the other Code Review tabs too (CI with ?repo=not-a-uuid), so I left it.

Traces (deployment.environment = pr-2018)

11 CodeReviewTeamService.team spans, all Ok:

  • 10–12ms when an unknown repository id short-circuits;
  • 62–156ms for full reads, median about 90ms.

The slowest trace, 15bed8fb759281667deb6c3a2b774bff (156ms):

CodeReviewTeamService.team                156ms
├─ SELECT vcs_repositories                 34ms   (serial: scope + default branches)
├─ SELECT pr_reviews (per-PR fold)          ~0ms  ┐
├─ SELECT pr_review_findings               18ms   │ in parallel
├─ executeSql ciActorStats                122ms   │   68ms of it: warehouse settings lookup
└─ executeSql ciQueueTotals               107ms   ┘   (same lookup, run twice in parallel)
  • No N+1. Two warehouse queries and three Postgres reads per request.
  • The time goes to the warehouse settings lookup (68ms), which runs once per warehouse read. Two parallel reads both miss and hit Postgres. That duplicate already exists in WarehouseQueryService and also shows on the CI tab, so I'm not fixing it here.
  • The 34ms repository read could overlap with the Postgres reads (only the warehouse queries need it). That would save about 30ms; not worth the extra plumbing for now.
  • In the browser, the first FetchCodeReviewTeam took 1.38s on a cold page load. Every other startup request in parallel took about 1.3s too (customer, infra presence, integration statuses), so that is page-load contention, not this endpoint.

Ready to merge from my side once CI is green.

@Makisuo
Makisuo merged commit bde890f into main Oct 31, 2026
38 checks passed
@Makisuo
Makisuo deleted the feat/code-review-team branch October 31, 2026 15:09
@Makisuo
Makisuo deployed to pr-preview October 31, 2026 15:09 — with GitHub Actions Active

This branch was successfully deployed

1 active deployment
pr-preview — 359f925c Deployed Oct 31, 2026 by Makisuo via deploy-pr-preview #8142
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview:web Deploy a Workers-only PR preview (no ingest/Electric); see docs/pr-previews.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant