Skip to content

feat: Support stacked line charts - #3290

Merged
kodiakhq[bot] merged 2 commits into
mainfrom
cursor/support-stacked-line-charts-5224
Oct 7, 2026
Merged

kodiakhq[bot] merged 2 commits into
mainfrom
cursor/support-stacked-line-charts-5224

Conversation

@pulpdrew

@pulpdrew pulpdrew commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR introduces a stacked_line display type, which (like stacked_bar) is a sub-type of time series display type.

In the CLI, these are rendered as stacked bar charts, because the stacking/fill doesn't look clear in the CLI, and stacked_bar is nearly the same display anyway.

Screenshots

Screenshot 2026-10-05 at 2 08 12 PM

Testing

  • Create a line chart on the chart explorer or dashboard.
  • Set the type switcher to stacked line chart

References

Closes HDX-5376

@changeset-bot

changeset-bot Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ad4a345

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@hyperdx/common-utils Minor
@hyperdx/app Minor
@hyperdx/api Minor
@hyperdx/cli Minor
@hyperdx/otel-collector Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hyperdx-oss Ready Ready Preview Oct 7, 2026 2:17pm UTC
hyperdx-storybook Ready Ready Preview Oct 7, 2026 2:17pm UTC

Request Review

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Duplicate code analysis

No new duplicate code introduced by this PR.


jscpd compared this branch against origin/main
across app, api and common-utils. Only new clones are listed; the codebase
currently holds 127 in total (1.78%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@greptile-apps

greptile-apps Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Adds stacked line chart display type across dashboards and alerts.

The PR appears safe to merge; no new actionable issue was established.

Summary

The PR adds stacked-line charts across the editor, dashboards, API, alerts, and CLI; the CLI renders them as stacked bars. It also adds PromQL query attribution, an optional instance label, and persistent dismissal of a metric drill-down warning.

Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Editor[Chart editor or API] --> Config[Stacked-line config]
  Config --> Query[Time-series query]
  Query --> Web[Stacked-area chart]
  Query --> CLI[Stacked-bar terminal chart]
Loading

Reviews (6) · Last reviewed commit: "Merge branch 'main' into cursor/support-..." · Reviewed by Greptile

Comment thread packages/cli/src/shared/tileRender.ts Resolved
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 399 passed • 1 skipped • 1535s

Status Count
✅ Passed 399
❌ Failed 0
⚠️ Flaky 1
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

@pulpdrew
pulpdrew force-pushed the cursor/support-stacked-line-charts-5224 branch 2 times, most recently from c0ab6cb to d648f13 Compare October 5, 2026 18:18
@pulpdrew
pulpdrew marked this pull request as ready for review October 5, 2026 18:19
@pulpdrew pulpdrew changed the title feat: support stacked line charts feat: Support stacked line charts Oct 5, 2026
@github-actions github-actions Bot added the review/tier-4 Critical — deep review + domain expert sign-off label Oct 5, 2026
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

🔴 Tier 4 — Critical

Touches authentication, tenancy data models, the public API or shipped database config — or substantially changes the query rendering engine, background tasks, the OTel pipeline, image build, or release CI.

Why this tier:

  • Critical-path files (4) — tenancy, public API, or shipped database config:
    • packages/api/src/routers/external-api/v2/alerts.ts
    • packages/api/src/routers/external-api/v2/dashboards.ts
    • packages/api/src/routers/external-api/v2/utils/alertChartConfig.ts
    • packages/api/src/routers/external-api/v2/utils/dashboards.ts
  • Cross-layer change: touches frontend (packages/app) + backend (packages/api) + shared utils (packages/common-utils)

Additional context: touches background tasks or the delivery pipeline lightly (7 lines, under the 30-line bar for Tier 4), touches the query rendering engine lightly (5 lines, under the 150-line bar for Tier 4)

Review process: Deep review from a domain expert. Synchronous walkthrough may be required.
SLA: Schedule synchronous review within 2 business days.

Stats
  • Production files changed: 33
  • Production lines changed: 670 (+ 405 in test files, excluded from tier calculation)
  • Critical-path lines changed: 164
  • Branch: cursor/support-stacked-line-charts-5224
  • Author: pulpdrew

To override this classification, remove the review/tier-4 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

Comment thread packages/app/src/DBDashboardPage.tsx Resolved
Comment thread packages/api/src/utils/externalApi.ts Resolved
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 critical or 🟠 major in code this PR adds or changes: fix before asking for review.
  • 🔵 minor in code this PR changes: your call. Fix if small, otherwise reply.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    severity. Reply with one sentence; if it is critical, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

2 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 2 minor

1 posted as inline comment(s) on the changed lines. 1 listed below.

Findings outside the changed lines

1 minor
  • 🔵 packages/cli/src/shared/adhocChart.ts:34 — hdx chart --display stacked_line is rejected even though the CLI now renders stacked_line tiles → Add stacked_line: DisplayType.StackedLine to ADHOC_DISPLAY_TYPES, or spread TIME_SERIES_DISPLAY_TYPE_BY_NAME from @hyperdx/common-utils/dist/core/utils into it. Then update the --display help text in packages/cli/src/cli.tsx:1106,1183 and packages/cli/README.md:143. As it stands, parseDisplayType('stacked_line') throws Invalid --display, while dashboard tiles of that type render fine through CLI_SUPPORTED_DISPLAY_TYPES/tileRender.

Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides.

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

This is a clean, additive feature. The new stacked_line DisplayType is threaded consistently through the shared enum and helper predicates (isTimeSeriesDisplayType, TIME_SERIES_DISPLAY_TYPE_BY_NAME, displayTypeSupports*Alerts), the web renderer, the Zod/OpenAPI/MCP contracts, alert evaluation, and the CLI. The API contract is total and non-breaking (all $refs resolve, round-trips are exhaustive), agent/MCP parity holds across every surface, and the background alert path handles the new type without a silent no-alert or throw. The findings below are edge-case polish; most mirror behavior that already exists for stacked_bar.

🟡 P2 -- recommended

  • packages/app/src/components/ChartDisplaySettingsDrawer.tsx:204 -- isTimeChart now includes stacked_line, so the drawer's "Compare to Previous Period" checkbox is shown for stacked tiles; on a dashboard (controlled mode) the setDisplayTypeLocal guard in DBTimeChart.tsx:667 is bypassed, so the dashed previous-period series get stackId="1" and stack into the current band, producing a doubled/misleading total — contradicting the stated intent that compare is disallowed for stacked line.
    • Fix: gate the compare (and fitYAxisToData) checkbox to DisplayType.Line rather than all time charts, and/or strip compareToPreviousPeriod on save when the display type is stacked.
    • adversarial, correctness, previous-comments
🔵 P3 nitpicks (5)
  • packages/cli/src/termchart/timeseries.ts:181 -- stacked_line is routed to renderStackedBarChart, which returns "No data" when every bucket total is <= 0 (and mis-assigns cell colors/heights for mixed-sign series), so an all-negative metric vanishes in the CLI; the web also pins the stacked y-axis to [0, auto], so negative stacks are not meaningfully representable anywhere (inherent to stacking, same as stacked_bar).
    • Fix: fall back to renderLineChart for stacked_line when totals are non-positive, or surface a diagnostic instead of "No data".
    • adversarial, previous-comments
  • packages/cli/src/shared/adhocChart.ts:32 -- ADHOC_DISPLAY_TYPES omits stacked_line even though CLI_SUPPORTED_DISPLAY_TYPES and renderTileContent now support it, so chart --display stacked_line errors as invalid while dashboard tiles render fine.
    • Fix: add stacked_line: DisplayType.StackedLine, or add a comment documenting the deliberate omission so the two allowlists do not silently diverge.
    • maintainability, kieran-typescript
  • packages/app/src/components/ChartDisplaySettingsDrawer.tsx:302 -- the "Fit Y-Axis to Data" control renders and is enabled for stacked_line via isTimeChart, but computeYAxisBounds returns the zero-pinned DEFAULT_Y_AXIS_BOUNDS for stacked types, so toggling it has no effect (a clarifying description was added but the control still shows).
    • Fix: hide or disable the toggle for stacked display types.
    • previous-comments, adversarial
  • packages/cli/src/termchart/timeseries.ts:219 -- the stacked-bar downsampler collapses each column to the single max-total bucket, so a series whose peak lands in a non-winning bucket is dropped; stacked_line is conceptually a line chart whose own renderer preserves per-series peaks, so routing it through the bar renderer regresses that guarantee.
    • Fix: preserve per-series peaks for the stacked_line path, or document the sampling loss.
  • packages/app/src/components/ChartEditor/utils.ts:190 -- isPromqlDisplayType is aliased to isRawSqlDisplayType; the two predicates are identical today but assert independent concerns, so a future raw-SQL-only display type would silently leak into the PromQL guard.
    • Fix: derive both from a shared constant, or add a comment that the two sets are intentionally kept identical.
    • maintainability, kieran-typescript

Reviewers (11): correctness, adversarial, testing, maintainability, project-standards, api-contract, reliability, kieran-typescript, previous-comments, agent-native, learnings-researcher.

Testing gaps:

  • No component/render test asserts the stacked_line <Area> props (stackId, type="linear", fillOpacity 0.35, flat-color fill, data-stacked-fill hover opt-out); only computeYAxisBounds and an e2e persistence test cover the feature.
  • No checkAlerts integration test exercises a saved stacked_line (or stacked_bar) inline alert end-to-end.
  • translateExternalChartToTileConfig and convertV1ChartConfigToV2 stacked_line mapping paths are covered only indirectly via round-trip/e2e tests.
  • No test covers stacked_line + compareToPreviousPeriod=true (save normalization and render behavior), nor a CLI test for stacked_line with negative/mixed-sign totals.
  • Nothing guards openapi.json against drift from the hand-maintained JSDoc @openapi blocks and Zod schemas for the new stacked-line shapes.

No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond

Comment thread packages/cli/src/shared/tileRender.ts Resolved
@greptile-apps

This comment has been minimized.

@pulpdrew
pulpdrew force-pushed the cursor/support-stacked-line-charts-5224 branch from 7b2aace to 0927f7a Compare October 6, 2026 18:35
Comment thread packages/common-utils/src/core/utils.ts Resolved

@knudtty knudtty 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.

Approving with question:
In order for IaC to use this, do we need to update the terraform provider?

return { errors, warnings };
}

/** Maps the time-series display type names used by the external API and v1 chart configs. */

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.

🔵 minor — TIME_SERIES_DISPLAY_TYPE_BY_NAME and isTimeSeriesDisplayType list the same set separately and must be kept in sync by hand

Derive the predicate from the map, e.g. Object.values(TIME_SERIES_DISPLAY_TYPE_BY_NAME).includes(displayType), so the set has one source of truth. Callers such as packages/api/src/mcp/tools/dashboards/validation.ts:122 (displayType in TIME_SERIES_DISPLAY_TYPE_BY_NAME) and ChartUtils.convertV1ChartConfigToV2 check membership through the map, while every other caller goes through isTimeSeriesDisplayType. A future time-series type added to only one of the two will make those code paths disagree.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

@pulpdrew

pulpdrew commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Approving with question: In order for IaC to use this, do we need to update the terraform provider?

Good question - no we should not need to

@kodiakhq
kodiakhq Bot merged commit 68082b6 into main Oct 7, 2026
29 checks passed
@kodiakhq
kodiakhq Bot deleted the cursor/support-stacked-line-charts-5224 branch October 7, 2026 14:23

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — ad4a3453 Deployed Oct 7, 2026 by vercel[bot]
Preview – hyperdx-storybook — ad4a3453 Deployed Oct 7, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge review/tier-4 Critical — deep review + domain expert sign-off

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants