Skip to content

feat: more global vars for dashboard links - #3726

Merged
kodiakhq[bot] merged 4 commits into
mainfrom
aaron/dashboard-link-globals
Dec 1, 2026
Merged

kodiakhq[bot] merged 4 commits into
mainfrom
aaron/dashboard-link-globals

Conversation

@knudtty

@knudtty knudtty commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds more dashboard globals such as time ranges and $_all_variables to allow better linking between dashboards.

Screenshots or video

export-1795040481503.mp4

References

  • Linear Issue: Closes HDX-5542

Note

Medium Risk
Changes how navigation URLs and filter query params are built and merged; mistakes could open wrong scopes or drop/duplicate filters, but behavior is limited to dashboard linking and templating.

Overview
Expands table row-click and markdown tile linking so templates can use Grafana-style globals ({{__from}} / {{__to}}, timezone, ready-made __url_time_range and __all_variables fragments) plus a {{date …}} Handlebars helper. External URLs can embed the current time range and dashboard filter state without hand-building query params.

Dashboard drill-down gains includeCurrentFilters to pass the source dashboard’s selections to the destination, with explicit row-driven filters overriding matching keys. Filters can now use kind: "variableTemplate" so static-list destinations are set by variable name, not expression. OpenAPI, MCP schemas, and the onClick editor UI (variable filter rows, carry-over checkbox) follow the new shapes.

Markdown tiles substitute the same globals as $__… macros when a date range is present, and ${var:url} URL-encodes variable values in link destinations.

Reviewed by Cursor Bugbot for commit 3c39f9f. Bugbot is set up for automated code reviews on this repo. Configure here.

@knudtty
knudtty requested a review from a team as a code owner November 18, 2026 22:24
@vercel

vercel Bot commented Nov 18, 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 Dec 1, 2026 1:48pm UTC
hyperdx-storybook Ready Ready Preview Dec 1, 2026 1:48pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3c39f9f

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

This PR includes changesets to release 4 packages
Name Type
@hyperdx/common-utils Patch
@hyperdx/app Patch
@hyperdx/api Patch
@hyperdx/otel-collector Patch

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

@github-actions github-actions Bot added the review/tier-4 Critical — deep review + domain expert sign-off label Nov 18, 2026
@github-actions

github-actions Bot commented Nov 18, 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 (1) — tenancy, public API, or shipped database config:
    • packages/api/src/routers/external-api/v2/dashboards.ts
  • Cross-layer change: touches frontend (packages/app) + backend (packages/api) + shared utils (packages/common-utils)

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: 15
  • Production lines changed: 699 (+ 266 in test files, excluded from tier calculation)
  • Critical-path lines changed: 48
  • Branch: aaron/dashboard-link-globals
  • Author: knudtty

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

@github-actions

github-actions Bot commented Nov 18, 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 109 in total (1.10%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

);
}
if (value == null || value === '') return '';
const ms =

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.

🟡 P2 — date helper gets URL-encoded column values in external URLs, so string timestamps render empty

renderOrError with encodeValues sends row values through renderUrlTemplate/stringifyAndEncode before Handlebars runs. So {{date Timestamp "iso"}} receives e.g. 2026-01-01T00%3A00%3A00Z, Date.parse returns NaN, and the helper silently returns ''. Fix: decode string arguments inside the helper (or only encode the final output, not helper inputs), and add a test with a string timestamp column in an external urlTemplate.

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

@github-actions

github-actions Bot commented Nov 18, 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:

  • 🔴 P0/P1 in code this PR adds or changes: fix before asking for review.
  • 🟡 P2 in code this PR changes: your call. Fix if small, otherwise reply.
  • 🔵 P3 is collapsed at the bottom: nobody needs to act on it before merge.
  • 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
    priority. Reply with one sentence; if it is P0, 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.

5 finding(s): 🔴 1 P0/P1 · 🟡 2 P2 · 🔵 2 P3

1 posted as inline comment(s) on the changed lines. 2 P3 folded at the bottom. 2 unchanged from an earlier push (already inline above).

🔵 2 P3 — no action needed before merge
  • 🔵 P3 packages/common-utils/src/core/linkUrlBuilder.ts:420 — renderOnClickExternal makes dateRange optional, but the only caller always passes it → The only caller, useOnClickLinkBuilder.ts:164, always spreads a full linkContext that includes dateRange. The Partial<LinkContext> type and the conditional globals exist only for old tests. They also mean a template that uses {{__from}} would fail with a missing-variable error if a caller ever left dateRange out. Take & LinkContext like renderOnClickSearch/renderOnClickDashboard do, drop the conditional, and update the tests.
  • 🔵 P3 packages/app/src/hooks/useOnClickLinkBuilder.ts:34 — Duplicates the existing getLocalTimeZone() helper → Intl.DateTimeFormat().resolvedOptions().timeZone is already wrapped as getLocalTimeZone() in packages/app/src/timeZone.ts:52. Use useDisplayTimeZone() ?? getLocalTimeZone() instead of a second copy (REQUIRED DRY rule in the repository conventions).

Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 484 passed • 1 skipped • 1112s

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

Tests ran across 4 shards in parallel.

View full report →

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found. The change is well-structured and carries strong test coverage (new linkUrlBuilder, variables, HDXMarkdownChart, and useOnClickLinkBuilder specs). The URL/filters= encoding is consistent with the pre-existing double-encode-then-URLSearchParams pattern and round-trips correctly through dashboardFilterValuesParser, so no encoding regression was found. The schema widening (OnClickDashboardFilterTemplate union, includeCurrentFilters) is backward compatible — existing expressionTemplate configs still validate. The items below are recommendations, not blockers.

🟡 P2 — recommended

  • packages/common-utils/src/core/handlebarsEnv.ts:41 — The new date helper is resolved by Handlebars ahead of a same-named row column, so a template {{date}} meant to interpolate a column literally named date now invokes the helper with no format and throws, failing both validateTemplate on save and rendering at click time.
    • Fix: Return an empty string (as floor/default do) when the date helper is invoked with a missing format instead of throwing, or reserve/validate column-name collisions so same-named columns stay referenceable.
    • correctness, previous-comments
🔵 P3 nitpicks (1)
  • packages/common-utils/src/core/linkUrlBuilder.ts:378 — With includeCurrentFilters: true, carried-over selections for filters the destination dashboard does not declare are forwarded verbatim, which the inline comment acknowledges can trigger the destination's "ignored filters" banner and surface unexpected filter state.
    • Fix: Intersect carried-over selections against the destination's declared filters (available via dashboardFiltersById) before serializing, or document the banner behavior for users.

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

Testing gaps:

  • No test for the date helper shadowing a row column named date, nor for the ms format or non-numeric/ISO/Infinity inputs to date.
  • No test for a variableTemplate whose destination filter is single-select, nor for includeCurrentFilters interaction with passthrough (lucene) entries.

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

@jordan-simonovski jordan-simonovski 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.

Looks good! Lmk when you're fixed the lint stuff and I can stamp

…e selection

With includeCurrentFilters, a carried-over variable-keyed entry won over
the link's expression template at the destination, which reads variable
entries first. Drop carried-over entries the destination keys by variable
for an expression the link sets.
* Formats a timestamp (epoch ms, or a date string) as `iso`, `seconds` or `ms`.
* Returns an empty string when the input can't be read as a date.
*/
hb.registerHelper('date', (value: unknown, format: unknown): string => {

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.

🔴 P1 — New global date helper takes over every existing {{date}} column reference

For a bare {{date}}, Handlebars looks up helpers before the context. Once date is registered, a link template that points at a row column named date (for example toDate(Timestamp) AS date) calls the helper with only the options object. The helper then throws Unknown date format "". As a result, saved row-click links that worked before now fail at click time, and validateOnClickTemplate rejects them when the tile is saved. The same env backs compileLenient in seriesNameTemplate.ts, so a PromQL legend template {{date}} quietly falls back to the default name. Fix: give the helper a name that can't clash with a column (e.g. formatDate). Or, when it is called with no params, return the context value (options.data.root.date) instead of throwing. Add a regression test for a date column.

Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond

);
}
if (value == null || value === '') return '';
const ms =

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.

🟡 P2 — date helper reads zone-less ClickHouse DateTime strings in the browser's local time

ClickHouse returns DateTime and DateTime64 row values as strings like 2026-01-01 12:00:00, with no zone. Date.parse treats that non-ISO form as local time, so {{date Timestamp "iso"}} and "ms" come out shifted by the viewer's UTC offset, and two users get different links for the same row. Fix: normalise YYYY-MM-DD HH:MM:SS[.fff] to ISO and treat it as UTC, or as the display timezone, before parsing. Add a test with a row timestamp; the current tests only pass the numeric __from/__to.

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

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

Stale Bugbot comment from a previous run.

if (format === 'seconds') return String(Math.floor(ms / 1000));
if (format === 'ms') return String(ms);
return new Date(ms).toISOString();
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Date helper shadows date column

Medium Severity

Registering a Handlebars helper named date steals the identifier from row context, so {{date}} no longer interpolates a column named date. Handlebars prefers helpers over fields, and this helper throws when it does not receive a format argument, so templates that reference that column fail validation on save and fail at click time. There is no supported helper for looking up a field with the same name.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6884724. Configure here.

const value = options?.encodeValues
? renderUrlTemplate(template, rowData)
: renderLinkTemplate(template, rowData);
? renderUrlTemplate(template, values, globals?.fragments)

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.

🟡 P2 — {{date <column> ...}} returns empty for string timestamps in external URLs

For external links, renderUrlTemplate URL-encodes every row value before the helpers run (stringifyAndEncode in core/linkTemplate.ts). A row value like 2026-01-01T00:00:00Z reaches date as 2026-01-01T00%3A00%3A00Z, Date.parse returns NaN, and the helper renders ''. Only the numeric __from/__to globals work, and those are the only inputs the tests cover. Pass raw values to the helpers and encode only the final interpolated output. For example, have the date helper call decodeURIComponent on its input, or encode in a custom escapeExpression. Add a test that renders {{date Timestamp "iso"}} on a row.

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

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3c39f9f. Configure here.

if (format === 'seconds') return String(Math.floor(ms / 1000));
if (format === 'ms') return String(ms);
return new Date(ms).toISOString();
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Date helper fails on encoded timestamps

Medium Severity

The date helper is documented to accept date strings, but external urlTemplate rendering URL-encodes string context values before helpers run. Colons and spaces in ISO or ClickHouse timestamps become %3A / %20, so Date.parse fails and the helper returns an empty string. Epoch-ms globals like __from still work because numbers are not encoded; row timestamp columns typically do not.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3c39f9f. Configure here.

@kodiakhq
kodiakhq Bot merged commit dceb21d into main Dec 1, 2026
31 of 32 checks passed
@kodiakhq
kodiakhq Bot deleted the aaron/dashboard-link-globals branch December 1, 2026 13:54

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — 3c39f9fc Deployed Dec 1, 2026 by vercel[bot]
Preview – hyperdx-storybook — 3c39f9fc Deployed Dec 1, 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.

3 participants