Skip to content

feat: git metrics on /v1/metric-results + metric-view refinements - #191

Merged
aleksdotbar merged 2 commits into
mainfrom
feat/unified-metrics-git-ui
Jul 10, 2026
Merged

feat: git metrics on /v1/metric-results + metric-view refinements#191
aleksdotbar merged 2 commits into
mainfrom
feat/unified-metrics-git-ui

Conversation

@aleksdotbar

@aleksdotbar aleksdotbar commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Git metrics cut over to /v1/metric-results (mirrors the AI family), plus generic metric-view refinements.

Git family

  • git_output → metrics group; metadata server-owned. prs_merged KPI → git.prs_merged.
  • Median computation + histogram view added to the wire vocabulary.
  • Git-specific legacy rendering removed. The v1 dashboard, team modal, catalog, and mocks keep their git entries.

Metric views (generic — also benefit AI)

  • Distributions: histogram bars shaded vs the peer median (green better / red worse by direction, intensity by distance); entity's own median as the headline, peer median as the pivot line. Grouped in one "Distributions" card.
  • Dimension breakdown folded into the trend legend (per-part total + share, rounded to sum to 100); standalone breakdown block dropped (renderer kept).
  • Commits + PRs merged combined into one trend; lone dimensionless series named by its metric.
  • keepPreviousData dropped → a period change shows a spinner, not dimmed stale data; focus/reconnect refetch disabled.

Checks: tsc + eslint clean; unit 261 + storybook 3 green. Adversarial review (Codex + CodeRabbit) — no critical/high; findings fixed.

Closes constructorfabric/insight#1702

🤖 Generated with Claude Code

Cut the git metrics family over to the unified /v1/metric-results path,
mirroring the AI family: git_output renders from server-owned metadata and
the git-specific legacy rendering is removed.

Git family:
- Add median computation and the histogram view to the wire vocabulary,
  normalization, MSW factory, and fixtures.
- Flip git_output to a MetricGroup (git.* metrics with per-metric views);
  move the prs_merged KPI tile onto git.prs_merged.
- Remove the git-specific legacy rendering: registry ids, member/dept-dist
  queries and their mock handlers, the drilldown-extras branch, the
  order/description/partition entries, and the orphaned v2 LOC chart. The v1
  dashboard, team modal, catalog, and mocks keep their git entries.

Metric views (generic, shared with the AI family):
- Distributions: shade histogram bars by each range's side of the peer median
  (per metric direction), intensity by distance from it; headline is the
  entity's own median, with the peer median as the pivot line. Grouped in one
  "Distributions" card.
- Fold each dimension breakdown into its trend legend (per-part total and
  share) and drop the standalone breakdown block; keep the renderer.
- Combine commits and PRs merged into one trend; label a lone dimensionless
  series by its metric and hide a one-series legend.
- Round composition shares with the largest-remainder method so a legend
  always sums to 100.
- Drop keepPreviousData so a period change shows a spinner instead of dimmed
  stale data; disable focus and reconnect refetches; metric KPI tiles and
  drilldowns render a spinner while loading.
- Let a lone chart span the full width; centralize status fill colors and the
  value-vs-median scoring helper.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
@aleksdotbar
aleksdotbar requested a review from a team as a code owner July 9, 2026 16:18
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@aleksdotbar, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 45 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2ce35f88-d49b-492f-b0e4-30dbf78a7bfe

📥 Commits

Reviewing files that changed from the base of the PR and between 0cd1dda and f4211cf.

📒 Files selected for processing (1)
  • src/components/widgets/metric-views/metric-trend.tsx
📝 Walkthrough

Walkthrough

This PR migrates git-related metrics from legacy batch endpoints to the unified metric system, adding histogram and median result types, a new MetricHistogram widget, and Distributions drilldown rendering. It removes legacy git_output LOC handling, updates legend percentage-share formatting across MetricBreakdown/MetricTrend, adds a PeerStory multiplier gap format, and separately disables query refetch-on-reconnect and placeholder-data caching.

Changes

Git-metrics migration to unified histogram/median metric system

Layer / File(s) Summary
API contract: histogram and median types
src/api/metric-results-client.ts
Adds histogram view, median computation, MedianMetricResult, HistogramBin, and HistogramView types.
Collection normalization and chunking
src/lib/metrics/collection.ts, src/lib/metrics/collection.test.ts
Wires histogram view through request building, normalization, forEntity, and non-chunkable behavior.
Status/median and percentage share helpers
src/lib/status.ts, src/lib/metrics/shares.ts, src/lib/metrics/shares.test.ts, src/lib/insight/kpi-row.ts
Adds statusVsMedian, STATUS_COLOR_VAR, and integerPercentShares; kpi-row.ts now imports statusVsMedian instead of defining it.
MetricHistogram widget
src/components/widgets/metric-views/metric-histogram.tsx, metric-histogram.test.tsx, src/components/ui/chart.tsx
New chart component visualizing entity distribution vs peer median, with Cell exported from chart primitives.
Collection drilldown Distributions section
src/components/widgets/metric-views/collection-drilldown.tsx, collection-drilldown.test.tsx
Splits chart blocks from histogram blocks and renders a "Distributions" card of MetricHistogram items.
Group/drilldown/KPI config wiring
src/lib/insight/groups.ts, groups.test.ts, kpi-row.test.ts, src/lib/insight/v2/bullet-defs.ts, metric-order.ts, partition.ts
Adds GIT_OUTPUT_COLLECTION, rewires git_output group to metrics-based config, updates KPI_ROW, and adjusts related legacy metric mappings.
Mocks for histogram/median and legacy removal
src/api/metric-registry.ts, src/mocks/handlers.ts, metric-results-factory.ts, metric-results-fixtures.ts
Removes V2_MEMBER_VALUES_GIT/V2_DEPT_DIST_GIT registry entries and mock handlers; adds histogram mock case and MEDIAN_METRIC_FIXTURE.
Legacy git_output LOC drilldown removal
src/components/widgets/v2/loc-stacked-bar.tsx, group-drilldown-sheet.tsx, src/queries/v2/ic-extras.ts, team-extras.ts
Deletes LocStackedBar, removes loc data path from drilldown batch queries, and drops git_output from legacy metric mappings.
Dashboard KPI loading state
src/components/widgets/v2/kpi-tile.tsx, kpi-tile.test.tsx, src/screens/ic-dashboard/engineering-dashboard-v2.tsx
Adds KpiTileLoading spinner state and updates dashboard legacy row mapping from git_output to task_delivery.

Legend percentage-share and gap-formatting UI polish

Layer / File(s) Summary
MetricBreakdown legend
src/components/widgets/metric-views/metric-breakdown.tsx, metric-breakdown.test.tsx
Ribbon becomes color-only; a separate legend shows integer percent shares via integerPercentShares.
MetricTrend composition legend
src/components/widgets/metric-views/metric-trend.tsx, metric-trend.test.tsx
Custom legend list shows per-series totals and percent shares for composition cases.
PeerStory multiplier gap
src/components/widgets/metric-views/peer-story.tsx, peer-story.test.tsx
Displays "N×" label when the value deviates from peer median by at least 2x.

Estimated code review effort: 4 (Complex) | ~75 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers: cyberantonz, mitasovr

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% 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
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main changes: moving git metrics to /v1/metric-results and refining metric views.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/unified-metrics-git-ui

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

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/queries/metric-results.ts (1)

116-120: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Trim the keepPreviousData wording in the page-dim comment. Metric queries now go isPending on period changes, so isFetching && !isPending only describes revalidation/background refetches here; the old “show old values while new ones load” phrasing is stale.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/queries/metric-results.ts` around lines 116 - 120, The comment around the
metric delta handling in metric-results.ts still refers to
keepPreviousData-style behavior that no longer applies. Update the explanatory
comment near previousUsable/hasPrevious to remove the stale “show old values
while new ones load” wording and instead describe that metric queries become
isPending on period changes, so isFetching && !isPending only covers
revalidation/background refetches in this path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/queries/metric-results.ts`:
- Around line 116-120: The comment around the metric delta handling in
metric-results.ts still refers to keepPreviousData-style behavior that no longer
applies. Update the explanatory comment near previousUsable/hasPrevious to
remove the stale “show old values while new ones load” wording and instead
describe that metric queries become isPending on period changes, so isFetching
&& !isPending only covers revalidation/background refetches in this path.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6c964a9c-c661-4587-addd-031a3d877c66

📥 Commits

Reviewing files that changed from the base of the PR and between ec714f7 and 0cd1dda.

📒 Files selected for processing (37)
  • src/api/metric-registry.ts
  • src/api/metric-results-client.ts
  • src/components/ui/chart.tsx
  • src/components/widgets/metric-views/collection-drilldown.test.tsx
  • src/components/widgets/metric-views/collection-drilldown.tsx
  • src/components/widgets/metric-views/metric-breakdown.test.tsx
  • src/components/widgets/metric-views/metric-breakdown.tsx
  • src/components/widgets/metric-views/metric-histogram.test.tsx
  • src/components/widgets/metric-views/metric-histogram.tsx
  • src/components/widgets/metric-views/metric-trend.test.tsx
  • src/components/widgets/metric-views/metric-trend.tsx
  • src/components/widgets/metric-views/peer-story.test.tsx
  • src/components/widgets/metric-views/peer-story.tsx
  • src/components/widgets/v2/group-drilldown-sheet.tsx
  • src/components/widgets/v2/kpi-tile.test.tsx
  • src/components/widgets/v2/kpi-tile.tsx
  • src/components/widgets/v2/loc-stacked-bar.tsx
  • src/lib/insight/groups.test.ts
  • src/lib/insight/groups.ts
  • src/lib/insight/kpi-row.test.ts
  • src/lib/insight/kpi-row.ts
  • src/lib/insight/v2/bullet-defs.ts
  • src/lib/insight/v2/metric-order.ts
  • src/lib/insight/v2/partition.ts
  • src/lib/metrics/collection.test.ts
  • src/lib/metrics/collection.ts
  • src/lib/metrics/shares.test.ts
  • src/lib/metrics/shares.ts
  • src/lib/status.ts
  • src/mocks/handlers.ts
  • src/mocks/metric-results-factory.ts
  • src/mocks/metric-results-fixtures.ts
  • src/queries/metric-results.ts
  • src/queries/v2/ic-extras.ts
  • src/queries/v2/team-extras.ts
  • src/query-client.ts
  • src/screens/ic-dashboard/engineering-dashboard-v2.tsx
💤 Files with no reviewable changes (8)
  • src/lib/insight/v2/partition.ts
  • src/queries/v2/team-extras.ts
  • src/components/widgets/v2/group-drilldown-sheet.tsx
  • src/api/metric-registry.ts
  • src/components/widgets/v2/loc-stacked-bar.tsx
  • src/lib/insight/v2/metric-order.ts
  • src/lib/insight/v2/bullet-defs.ts
  • src/mocks/handlers.ts

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
@aleksdotbar
aleksdotbar merged commit 675c401 into main Jul 10, 2026
6 checks passed
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.

feat: migrate git metrics to unified metric system (frontend)

2 participants