Repository navigation
feat: more global vars for dashboard links - #3726
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 3c39f9f The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
🔴 Tier 4 — CriticalTouches 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:
Review process: Deep review from a domain expert. Synchronous walkthrough may be required. Stats
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
| ); | ||
| } | ||
| if (value == null || value === '') return ''; | ||
| const ms = |
There was a problem hiding this comment.
🟡 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
PR Review
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
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. |
E2E Test Results✅ All tests passed • 484 passed • 1 skipped • 1112s
Tests ran across 4 shards in parallel. |
Deep Review✅ No critical issues found. The change is well-structured and carries strong test coverage (new 🟡 P2 — recommended
🔵 P3 nitpicks (1)
Reviewers (11): correctness, testing, maintainability, project-standards, security, api-contract, adversarial, kieran-typescript, previous-comments, agent-native, learnings-researcher. Testing gaps:
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
left a comment
There was a problem hiding this comment.
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.
d822782 to
6884724
Compare
| * 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 => { |
There was a problem hiding this comment.
🔴 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 = |
There was a problem hiding this comment.
🟡 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
| if (format === 'seconds') return String(Math.floor(ms / 1000)); | ||
| if (format === 'ms') return String(ms); | ||
| return new Date(ms).toISOString(); | ||
| }); |
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit 6884724. Configure here.
| const value = options?.encodeValues | ||
| ? renderUrlTemplate(template, rowData) | ||
| : renderLinkTemplate(template, rowData); | ||
| ? renderUrlTemplate(template, values, globals?.fragments) |
There was a problem hiding this comment.
🟡 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
There was a problem hiding this comment.
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).
❌ 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(); | ||
| }); |
There was a problem hiding this comment.
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)
Reviewed by Cursor Bugbot for commit 3c39f9f. Configure here.


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
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_rangeand__all_variablesfragments) 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
includeCurrentFiltersto pass the source dashboard’s selections to the destination, with explicit row-drivenfiltersoverriding matching keys. Filters can now usekind: "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.