Conversation
Explain charts omit time_zone and were binned in UTC. Resolve the same explore default as dashboards, keeping an explicit spec zone authoritative and falling back to UTC when no explore is available.
|
1. The On this branch, These pass on The layering here is deliberate: export function resolveChartTimeZone(explicitTimeZone, explore) {
if (explicitTimeZone) return explicitTimeZone;
if (!explore) return getUTCIANA();
return getDefaultTimeZone({
...explore,
timeZones: explore.defaultPreset?.timezone
? [explore.defaultPreset.timezone, ...(explore.timeZones ?? [])]
: explore.timeZones,
});
}(or simply read 2. The explore that supplies the timezone is chosen arbitrarily, and the selection is duplicated.
3. The chart is blank while the explores query is in flight.
4. Minor: the UTC branch in
|
nishantmonu51
left a comment
There was a problem hiding this comment.
The create_chart tool prompt is not in this diff but now contradicts the renderer: runtime/ai/create_chart.go:431 documents time_zone as "Optional time zone (defaults to "UTC")" and every example uses Z timestamps, so the model plans UTC-midnight start/end bounds and narrates in UTC while the chart bins in the explore's zone (data-provider.ts:119 passes timeRange.timeZone to the query). For an explore defaulting to Asia/Shanghai, start: 2024-01-01T00:00:00Z is 08:00 on 2024-01-01 local, so the first and last day buckets are partial and the day labels no longer line up with the model's text. Either state the inheritance rule in the prompt or instruct the model to always pass an explicit time_zone.
The branch is 56 commits behind main (merge-base a21215b6), but none of the touched files changed there, so there is no conflict.
| export function getDefaultTimeZone(explore: V1ExploreSpec) { | ||
| const preference = explore.timeZones?.[0] ?? DEFAULT_TIMEZONES[0]; | ||
| const preference = | ||
| explore.defaultPreset?.timezone || |
There was a problem hiding this comment.
getDefaultTimeZone is the pre-YAML baseline that getRillDefaultExploreState feeds into getRillDefaultExploreUrlParams, and cleanUrlParams/cleanUrlParamsForGoto subtract that baseline from every generated explore URL. Folding defaultPreset.timezone in here means an explore whose YAML sets defaults: timezone: Asia/Kathmandu has tz stripped from its URLs: running the suites against this head gives 44 failures across url-state-variations.spec.ts (10), convertURLSearchParamsToExploreState.spec.ts (10), DashboardStateManager.spec.ts (14) and explore-web-view-store.spec.ts (10), all of the shape Expected: "tr=P7D&tz=Asia%2FKathmandu&..." Received: "tr=P7D&...", and the same suites pass on main. The preset timezone is deliberately applied one layer up, in get-explore-state-from-yaml-config.ts:126 and in getDefaultExplorePreset.ts:70, where ...explore.defaultPreset is spread after timezone: getDefaultTimeZone(explore) so the preset already wins. The chat chart only needs the preset-first rule inside resolveChartTimeZone (read explore.defaultPreset?.timezone first and put it through the same Local/IANA normalization), which lets this hunk and the first case of its new spec be dropped.
| $: exploresQuery = useGetExploresForMetricsView( | ||
| runtimeClient, | ||
| chartSpec.metrics_view ?? "", | ||
| ); | ||
| $: exploreSpec = selectBestDashboard($exploresQuery.data ?? [])?.explore |
There was a problem hiding this comment.
ChartContainer.svelte:117 already runs this same explores query and selectBestDashboard through useExploreAvailability for the "open in explore" link, so this duplicates it, and the inherited zone agrees with the link target only because both inputs happen to be identical. Exposing the selected validSpec from useExploreAvailability, or a shared selector, would make that coupling explicit.
| {organization} | ||
| themeMode="light" | ||
| /> | ||
| {#if timezoneReady} |
There was a problem hiding this comment.
While the explores query is loading for a spec without time_zone, this gate renders an empty 400px .chart-container instead of ChartContainer's own loading state, so the chart pops in only once ListResources resolves. Gating the query rather than the component would keep the skeleton.
time_zonewere always binned in UTC, so day grains did not match the explore default timezone.ChartBlocknow resolves timezone the same way dashboards do: explicit spectime_zone, else the exploredefaultPreset.timezone/ firsttimeZonesentry, else UTC.getDefaultTimeZonehonorsdefaultPreset.timezonefirst. An explicit spec zone stays authoritative.Checklist:
Developed in collaboration with Claude Code