Skip to content

feat(metrics): add metric evidence drilldowns - #226

Merged
aleksdotbar merged 11 commits into
mainfrom
feat/metric-drilldown
Aug 3, 2026
Merged

feat(metrics): add metric evidence drilldowns#226
aleksdotbar merged 11 commits into
mainfrom
feat/metric-drilldown

Conversation

@aleksdotbar

@aleksdotbar aleksdotbar commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add capability-driven supporting-data actions to unified metric charts, tables, and metric views
  • add a stable, virtualized evidence dialog with pagination, multi-metric selection, and human-facing columns
  • add CSV/XLSX export, request cancellation, session-scoped caching, and copyable references
  • preserve existing dashboard details navigation and missing-data semantics

Stack

UI layer of the metric evidence drilldown. Backend stack, merging bottom-up:
constructorfabric/insight#2071 → #2072 → #2073 → #2074. Requires #2072 for
capability advertisement and #2073 for the drilldown endpoint.

Closes constructorfabric/insight#2054

Validation

  • pnpm exec tsc --noEmit
  • pnpm test (695 tests)

Summary by CodeRabbit

  • New Features
    • View supporting data directly from metric cards, charts, tables, breakdowns, peer stories, and dashboard grids.
    • Browse detailed evidence in a paginated table, copy reference values, and export results as CSV or Excel.
    • Click chart points and table values to open evidence for the selected period and dimensions.
  • Bug Fixes
    • Missing metric values now display as em dashes instead of zeroes, with clearer chart gaps and “No data” labels.
    • Dashboard drilldown panels now open and close more reliably.

Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>

# Conflicts:
#	src/components/widgets/metric-views/metric-timeseries-chart.tsx
#	src/components/widgets/metric-views/metric-timeseries-table.tsx
Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
@aleksdotbar
aleksdotbar requested a review from a team as a code owner July 28, 2026 20:43
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 26aa5a11-bf67-4196-8924-897f4ba22497

📥 Commits

Reviewing files that changed from the base of the PR and between 1de440c and 183f2cc.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (16)
  • package.json
  • src/api/metric-definitions-client.ts
  • src/api/metric-results-client.ts
  • src/components/widgets/dashboard/group-drilldown-sheet.tsx
  • src/components/widgets/dashboard/ic-needs-attention.tsx
  • src/components/widgets/dashboard/kpi-tile.tsx
  • src/components/widgets/dashboard/members-grid.tsx
  • src/components/widgets/metric-views/metric-summary-card.tsx
  • src/components/widgets/metric-views/metric-timeseries-chart-model.ts
  • src/components/widgets/metric-views/metric-timeseries-model.ts
  • src/components/widgets/metric-views/metric-timeseries-view.tsx
  • src/lib/insight/kpi-row.ts
  • src/lib/metrics/collection.ts
  • src/routes/__root.tsx
  • src/screens/dashboard.tsx
  • src/screens/team-view.tsx

📝 Walkthrough

Walkthrough

Changes

Metric evidence and drilldown

Layer / File(s) Summary
Drilldown contracts and API
src/api/*, src/auth/session-scope.ts, src/lib/metrics/*
Adds typed drilldown metadata, selection normalization, session authorization scope, query handling, exports, and filename parsing.
Evidence dialog and virtualized results
src/components/metric-evidence-*, src/components/ui/table.tsx, src/lib/download.ts, package.json
Adds session-scoped dialog state, paginated evidence queries, CSV/XLSX export, virtualized rows, copyable references, and related tests.
Metric view entry points
src/components/widgets/metric-views/*, src/components/widgets/dashboard/members-grid.tsx, src/routes/__root.tsx
Adds supporting-data actions to metric cards, peer stories, member cells, and timeseries views.
Timeseries gaps and interactions
src/components/widgets/metric-views/metric-timeseries-*, src/components/ui/chart.tsx
Adds chart and table evidence callbacks, preserves null values, renders gap regions, and hides empty grand totals.
Group drilldown state
src/components/widgets/dashboard/group-drilldown-sheet.tsx, src/screens/dashboard.tsx, src/screens/team-view.tsx
Separates drilldown sheet visibility from selected group state and clears selection after close completion.

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

Possibly related issues

Possibly related PRs

Suggested reviewers: ktursunov, cyberantonz, mitasovr

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.33% 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 clearly and concisely summarizes the main change: adding metric evidence drilldowns.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/metric-drilldown

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.

Actionable comments posted: 5

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

Inline comments:
In `@src/api/metric-drilldown-client.ts`:
- Around line 42-45: Update queryMetricDrilldown’s success-response JSON parsing
to catch malformed bodies and throw AnalyticsApiError with the response status
and the established invalid_json payload, preserving the existing error
classification contract. Reuse or extract the shared response-parsing helper
used by request() and errorFor() rather than duplicating res.json().catch(() =>
null) logic.

In `@src/components/metric-evidence-table.tsx`:
- Around line 129-212: Restore explicit table semantics in the virtualized table
by adding role="table" to Table, role="rowgroup" to TableHeader and TableBody,
role="row" to each TableRow, and role="columnheader"/role="cell" to the
corresponding TableHead/TableCell elements. Ensure aria-rowcount and
aria-rowindex remain attached to their meaningful table and row hosts, and
remove any reliance on aria-hidden for the empty virtual fill row if present.

In `@src/components/widgets/metric-views/metric-breakdown.tsx`:
- Around line 58-60: Update the empty-state card’s early-return branch in the
metric breakdown component to render MetricCardActions alongside CardTitle,
using the already computed evidence value so drilldown-capable metrics retain
“View supporting data” when no rows exist.

In `@src/components/widgets/metric-views/peer-story.tsx`:
- Around line 72-73: Update the FlatGrid rendering path in PeerStory so each
FlatGridCard also renders MetricCardActions with the entry’s evidence and label,
matching HeroCard and SideCard behavior. Ensure neutral mode and
all-mode-without-a-hero expose supporting-data actions without changing the
existing card layout.

In `@src/components/widgets/v2/members-grid.tsx`:
- Around line 546-548: Update the evidence selection call in the members-grid
metric flow to pass the metric’s breakdown dimensions as display_dimensions,
matching the breakdown and summary-card callers. Preserve the null behavior for
metrics without drilldown and keep the existing entityId selection context.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 95cea46e-6d37-4ab8-8fcd-d713a18ce664

📥 Commits

Reviewing files that changed from the base of the PR and between f6bd345 and aa59a04.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (37)
  • eslint.config.js
  • package.json
  • src/api/metric-definitions-client.ts
  • src/api/metric-drilldown-client.ts
  • src/api/metric-results-client.ts
  • src/auth/session-scope.ts
  • src/components/metric-evidence-context.ts
  • src/components/metric-evidence-dialog-provider.tsx
  • src/components/metric-evidence-dialog.tsx
  • src/components/metric-evidence-table.tsx
  • src/components/ui/chart.tsx
  • src/components/ui/table.tsx
  • src/components/widgets/metric-views/metric-breakdown.tsx
  • src/components/widgets/metric-views/metric-card-actions.tsx
  • src/components/widgets/metric-views/metric-summary-card.tsx
  • src/components/widgets/metric-views/metric-timeseries-chart-model.ts
  • src/components/widgets/metric-views/metric-timeseries-chart.tsx
  • src/components/widgets/metric-views/metric-timeseries-chrome.tsx
  • src/components/widgets/metric-views/metric-timeseries-export-browser.test.ts
  • src/components/widgets/metric-views/metric-timeseries-export.ts
  • src/components/widgets/metric-views/metric-timeseries-model.ts
  • src/components/widgets/metric-views/metric-timeseries-presentations.test.tsx
  • src/components/widgets/metric-views/metric-timeseries-table.tsx
  • src/components/widgets/metric-views/metric-timeseries-view.tsx
  • src/components/widgets/metric-views/peer-story.tsx
  • src/components/widgets/v2/group-details-sheet.tsx
  • src/components/widgets/v2/group-drilldown-sheet.tsx
  • src/components/widgets/v2/ic-needs-attention.tsx
  • src/components/widgets/v2/kpi-tile.tsx
  • src/components/widgets/v2/members-grid.tsx
  • src/lib/download.ts
  • src/lib/insight/kpi-row.ts
  • src/lib/metrics/collection.ts
  • src/lib/metrics/peer-story.ts
  • src/routes/__root.tsx
  • src/screens/ic-dashboard/engineering-dashboard-v2.tsx
  • src/screens/team-view-v2.tsx

Comment thread src/api/metric-drilldown-client.ts
Comment thread src/components/metric-evidence-table.tsx
Comment thread src/components/widgets/metric-views/metric-breakdown.tsx
Comment thread src/components/widgets/metric-views/peer-story.tsx
Comment thread src/components/widgets/dashboard/members-grid.tsx
Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
@aleksdotbar
aleksdotbar merged commit c9851d3 into main Aug 3, 2026
9 of 10 checks passed
@aleksdotbar
aleksdotbar deleted the feat/metric-drilldown branch August 3, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stack:metric-drilldown Stacked PR series for metric evidence drilldown (constructorfabric/insight#1603)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Metric drilldown UI

1 participant