Skip to content

feat(studio): MetricTrendPanel - #1269

Open
steramae-nvidia wants to merge 1 commit into
mainfrom
steramae/metric-trend-panel
Open

feat(studio): MetricTrendPanel#1269
steramae-nvidia wants to merge 1 commit into
mainfrom
steramae/metric-trend-panel

Conversation

@steramae-nvidia

@steramae-nvidia steramae-nvidia commented Aug 12, 2026

Copy link
Copy Markdown
Contributor
Screenshot 2026-08-12 at 4 04 17 PM Screenshot 2026-08-12 at 4 04 11 PM Screenshot 2026-08-12 at 4 00 18 PM Screenshot 2026-08-12 at 4 00 14 PM

Signed-off-by: Sean Teramae steramae@nvidia.com

Summary

Related Issue

Changes

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with documentation updates
  • Documentation only
  • Contributor tooling or automation
  • CI, build, or test infrastructure

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Documentation updated for user-visible behavior
  • Documentation not applicable — justification:

Verification

  • Pull request title follows the repository's Conventional Commit format
  • Every commit includes an appropriate Signed-off-by: trailer
  • uv run pre-commit run -a passes, or any blocked checks are identified below
  • Targeted tests pass, or tests are marked not applicable above
  • No secrets, API keys, or credentials are included

Targeted validation:

Summary by CodeRabbit

  • New Features
    • Added a metric trend panel for visualizing time-based data with responsive area charts and tooltips.
    • Supports multiple metric series, series switching, comparison values, delta indicators, and customizable formatting.
    • Added loading-state placeholders and an optional header action for viewing more details.
    • Includes light and dark theme styling for a consistent appearance across the application.

Signed-off-by: Sean Teramae <steramae@nvidia.com>
@steramae-nvidia

Copy link
Copy Markdown
Contributor Author

This change is part of the following stack:

Change managed by git-spice.

@steramae-nvidia
steramae-nvidia requested review from a team as code owners August 12, 2026 23:05
@github-actions github-actions Bot added the feat label Aug 12, 2026
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds MetricTrendPanel with typed metric series, selectable trends, formatted values, deltas, loading states, themed charts, optional view actions, Storybook scenarios, and interaction tests.

Changes

Metric Trend Panel

Layer / File(s) Summary
Panel contracts and rendering
web/packages/studio/src/components/charts/MetricTrendPanel/index.tsx
Defines metric data and panel props. Renders selectable series, formatted metrics, deltas, loading states, callbacks, and a responsive themed area chart.
Storybook scenarios
web/packages/studio/src/components/charts/MetricTrendPanel/MetricTrendPanel.stories.tsx
Adds deterministic chart data and stories for default, single-series, negative-delta, and loading states.
Interaction validation
web/packages/studio/src/components/charts/MetricTrendPanel/MetricTrendPanel.test.tsx
Tests default display, uncontrolled and controlled series selection, series change callbacks, and the view action callback.

Sequence Diagram(s)

sequenceDiagram
  participant Consumer
  participant MetricTrendPanel
  participant Recharts
  Consumer->>MetricTrendPanel: Provide metric series and panel props
  MetricTrendPanel->>Recharts: Render active-series trend data
  Recharts-->>MetricTrendPanel: Render responsive area chart
  MetricTrendPanel-->>Consumer: Render values, delta, series controls, and view action
Loading

Suggested reviewers: marcusds

Mergeability Score: 🔵 Low · up to 6bca0

The panel can mislabel an unchanged metric as increasing and can show loading indefinitely when no data is available. These are bounded presentation issues, so the PR is mergeable with explicit owner awareness or follow-up.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the new MetricTrendPanel feature added to Studio.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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 steramae/metric-trend-panel

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: 2

🧹 Nitpick comments (1)
web/packages/studio/src/components/charts/MetricTrendPanel/index.tsx (1)

17-17: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Import FC as a type.

FC is used only as a type.

-import { FC, useId, useMemo, useState } from 'react';
+import { useId, useMemo, useState } from 'react';
+import type { FC } from 'react';

As per coding guidelines, “Use import type for type-only imports.”

🤖 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 `@web/packages/studio/src/components/charts/MetricTrendPanel/index.tsx` at line
17, Update the React import in MetricTrendPanel to import FC using a type-only
import while keeping useId, useMemo, and useState as runtime imports.

Source: Coding guidelines

🤖 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 `@web/packages/studio/src/components/charts/MetricTrendPanel/index.tsx`:
- Around line 101-140: Update the delta styling and rendering in
MetricTrendPanel so delta === 0 uses the neutral tag color and omits the
Triangle, while preserving the existing red/downward behavior for negative
values and green/upward behavior for positive values. Add a test covering zero
delta and asserting the neutral presentation without a directional icon.
- Around line 172-175: Update the loading condition in MetricTrendPanel so an
empty series with isPending=false does not render StackedSkeleton indefinitely;
render the established empty state instead, or enforce a non-empty series
contract. Add a test covering series={[]} with isPending={false} and verify the
loading skeleton is not shown.

---

Nitpick comments:
In `@web/packages/studio/src/components/charts/MetricTrendPanel/index.tsx`:
- Line 17: Update the React import in MetricTrendPanel to import FC using a
type-only import while keeping useId, useMemo, and useState as runtime imports.
🪄 Autofix

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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: abb58632-2b8c-4b9b-ad33-3b77fb751498

📥 Commits

Reviewing files that changed from the base of the PR and between 5f6569d and 6bca085.

📒 Files selected for processing (3)
  • web/packages/studio/src/components/charts/MetricTrendPanel/MetricTrendPanel.stories.tsx
  • web/packages/studio/src/components/charts/MetricTrendPanel/MetricTrendPanel.test.tsx
  • web/packages/studio/src/components/charts/MetricTrendPanel/index.tsx

Comment on lines +101 to +140
const delta = active?.delta;
const isNegative = delta !== undefined && delta < 0;
const deltaColor = isNegative ? 'red' : 'green';
const lineColor = isNegative ? 'var(--text-color-accent-red)' : 'var(--text-color-brand)';
const colorMode = useNvColorMode();
const gradient = colorMode === 'dark' ? AREA_GRADIENT.dark : AREA_GRADIENT.light;

return (
<PanelRoot elevation="mid">
<PanelHeader className="items-start">
<Stack gap="density-xs" className="min-w-0 flex-1">
<Text kind="label/bold/xl">{title}</Text>
{description && (
<Text kind="body/regular/md" className="text-secondary">
{description}
</Text>
)}
</Stack>
{onViewClick && (
<Button kind="tertiary" size="small" className="shrink-0" onClick={onViewClick}>
{viewLabel}
</Button>
)}
</PanelHeader>

<PanelContent>
<Stack gap="density-lg">
<Text kind="display/lg">{active ? formatValue(active.value) : '—'}</Text>

<Flex align="center" gap="density-lg" wrap="wrap">
{delta !== undefined && (
<Flex align="center" gap="density-sm">
<Tag readOnly color={deltaColor} density="compact">
<Triangle
size={12}
className={`fill-current ${isNegative ? 'rotate-180' : ''}`}
aria-hidden
/>
{formatDelta(delta)}
</Tag>

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 | 🟡 Minor | ⚡ Quick win

Render zero delta as neutral.

When delta === 0, the panel shows a green upward triangle. This reports no change as an increase. Use a neutral tag and omit the directional icon for zero.

Add a zero-delta test.

🤖 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 `@web/packages/studio/src/components/charts/MetricTrendPanel/index.tsx` around
lines 101 - 140, Update the delta styling and rendering in MetricTrendPanel so
delta === 0 uses the neutral tag color and omits the Triangle, while preserving
the existing red/downward behavior for negative values and green/upward behavior
for positive values. Add a test covering zero delta and asserting the neutral
presentation without a directional icon.

Comment on lines +172 to +175
<div className="-mx-density-2xl -mb-density-2xl overflow-hidden rounded-b-density-xl">
{isPending || !active ? (
<StackedSkeleton count={1} height={chartHeight} className="w-full" />
) : (

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 | 🟡 Minor | ⚡ Quick win

Do not show loading for empty data.

When series is empty and isPending is false, !active renders StackedSkeleton indefinitely. Render an empty state, or require a non-empty series contract.

Add a test for series={[]} with isPending={false}.

🤖 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 `@web/packages/studio/src/components/charts/MetricTrendPanel/index.tsx` around
lines 172 - 175, Update the loading condition in MetricTrendPanel so an empty
series with isPending=false does not render StackedSkeleton indefinitely; render
the established empty state instead, or enforce a non-empty series contract. Add
a test covering series={[]} with isPending={false} and verify the loading
skeleton is not shown.

@github-actions

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 32239/40906 78.8% 63.7%
Integration Tests 18640/38832 48.0% 20.7%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant