DashboardDS: Fix Mixed panels not updating on time-range change with stale upstreams
Tier 2 easy typescript · local · real merged PR from grafana/grafana #124665
Ground-truth defects
This PR adds a filter on the Mixed-DS path that completes the time-range-change stream on the first terminal emission whose range matches, but it compares the upstream terminal emission's range against `options.range` (the chain request range) via `isSameRange(upstreamRange, options.range)`. When a source panel carries a PanelTimeRange override, the upstream legitimately runs for the source panel's own range, which differs from the chain range, so the matching terminal Done is dropped and the Mixed panel is stuck in permanent loading. The comparison should use the source panel's effective range (read via sceneGraph.getTimeRange), not the chain range.
The change under review
diff
@@ -1,11 +1,13 @@ -import { first } from 'rxjs'; +import { first, ReplaySubject } from 'rxjs'; import { arrayToDataFrame, + dateTime, type DataQueryResponse, type DataSourceInstanceSettings, getDefaultTimeRange, LoadingState, + type PanelData, standardTransformersRegistry, FieldType, type DataFrame, @@ -16,6 +18,7 @@ import { getPanelPlugin } from '@grafana/data/test'; import { setPluginImportUtils } from '@grafana/runtime'; import { SafeSerializableSceneObject, + type SceneDataProviderResult, SceneDataNode, SceneDataTransformer, SceneFlexItem, @@ -110,6 +113,88 @@ describe('DashboardDatasource', () => { expect(first).not.toHaveBeenCalled(); }); + it('Should skip the stale Done replayed by the upstream ReplaySubject on time-range change in MixedDS', async () => { + // The upstream SceneQueryRunner exposes its results via a ReplaySubject(1) + // that synchronously replays the previous range's Done state on subscribe. + // The Mixed-DS operator's `first(Done || Error)` used to match that stale + // Done and complete the substream before the upstream re-ran for the new + // range, so the chain panel rendered with stale data and never re-rendered + // when the real Done arrived seconds later. + const oldRange = makeRange('2026-05-01T00:00:00Z', '2026-05-08T00:00:00Z'); + const newRange = makeRange('2026-05-04T00:00:00Z', '2026-05-08T00:00:00Z'); + + const { observable, upstreamStream } = setupWithControllableUpstream( + { refId: 'A', panelId: 1 }, + `${MIXED_REQUEST_PREFIX}1`, + newRange + ); + + // Prime the ReplaySubject with the stale Done BEFORE subscribing, so it gets + // replayed synchronously on subscribe — exactly the production scenario. + upstreamStream.next(makeResult(LoadingState.Done, arrayToDataFrame([1]), oldRange)); + + const emissions: DataQueryResponse[] = []; + observable.subscribe({ next: (data) => emissions.push(data) }); + + await waitForDebounce(); + expect(emissions).toEqual([]); + + // Upstream now re-runs for the new range: Loading then Done. + upstreamStream.next(makeResult(LoadingState.Loading, arrayToDataFrame([1]), newRange)); + upstreamStream.next(makeResult(LoadingState.Done, arrayToDataFrame([2, 3]), newRange)); + + await waitForDebounce(); + expect(emissions).toHaveLength(1); + expect(emissions[0].state).toBe(LoadingState.Done); + expect(emissions[0].data[0].fields[0].values).toEqual([2, 3]); + }); + + it('Should still emit the only Done when ranges match (Mixed editor-add path)', async () => { + // The filter must not skip the editor-add case: same range, single Done emission. + const range = makeRange('2026-05-04T00:00:00Z', '2026-05-08T00:00:00Z'); + + const { observable, upstreamStream } = setupWithControllableUpstream( + { refId: 'A', panelId: 1 }, + `${MIXED_REQUEST_PREFIX}1`, + range + ); + + upstreamStream.next(makeResult(LoadingState.Done, arrayToDataFrame([7, 8, 9]), range)); + + const emissions: DataQueryResponse[] = []; + observable.subscribe({ next: (data) => emissions.push(data) }); + + await waitForDebounce(); + expect(emissions).toHaveLength(1); + expect(emissions[0].state).toBe(LoadingState.Done); + expect(emissions[0].data[0].fields[0].values).toEqual([7, 8, 9]); + }); + + it('Should not drop Done when the chain panel has a different range than the upstream (non-Mixed PanelTimeRange override)', async () => { + // Regression guard: a chain panel with a PanelTimeRange override (timeFrom, + // timeShift, ...) legitimately observes ranges that differ from the upstream. + // The range-mismatch filter only runs on the Mixed-DS path; the non-Mixed + // path must keep forwarding terminal emissions regardless of range. + const chainRange = makeRange('2026-05-04T00:00:00Z', '2026-05-08T00:00:00Z'); + const upstreamRange = makeRange('2026-04-27T00:00:00Z', '2026-05-04T00:00:00Z'); + + const { observable, upstreamStream } = setupWithControllableUpstream( + { refId: 'A', panelId: 1 }, + /* non-Mixed requestId */ 'panel-1', + chainRange + ); + + upstreamStream.next(makeResult(LoadingState.Done, arrayToDataFrame([42]), upstreamRange)); + + const emissions: DataQueryResponse[] = []; + observable.subscribe({ next: (data) => emissions.push(data) }); + + await waitForDebounce(); + expect(emissions).toHaveLength(1); + expect(emissions[0].state).toBe(LoadingState.Done); + expect(emissions[0].data[0].fields[0].values).toEqual([42]); + }); + it('Should not mutate field state in dataframe', async () => { const { observable } = setup({ refId: 'A', panelId: 1, withTransforms: true }); @@ -889,6 +974,87 @@ function setupWithAnnotations(query: DashboardQuery, requestId?: string) { return { observable, sourceData }; } +function makeRange(fromIso: string, toIso: string) { + const from = dateTime(fromIso); + const to = dateTime(toIso); + return { from, to, raw: { from, to } }; +} + +function makeResult( + state: LoadingState, + frame: DataFrame, + range: ReturnType<typeof makeRange> +): SceneDataProviderResult { + const data: PanelData = { + series: [frame], + state, + timeRange: range, + request: { + requestId: 'upstream-req', + interval: '', + intervalMs: 0, + range, + scopedVars: {}, + targets: [], + timezone: 'utc', + app: '', + startTime: 0, + }, + }; + return { origin: undefined as unknown as SceneDataProviderResult['origin'], data }; +} + +function waitForDebounce() { + // datasource.ts uses debounceTime(50) followed by the Mixed-DS operator which adds + // an internal 400ms debounce on the first Done. Wait long enough for both to drain. + return new Promise((r) => setTimeout(r, 600)); +} + +function setupWithControllableUpstream(query: DashboardQuery, requestId: string, range: ReturnType<typeof makeRange>) { + // Match production: upstream SceneQueryRunner exposes a ReplaySubject(1) so + // subscribers attaching after the upstream has already emitted Done get the + // stale Done replayed synchronously on subscribe. + const upstreamStream = new ReplaySubject<SceneDataProviderResult>(1); + + const sourceData = new SceneDataNode({ + data: { + series: [arrayToDataFrame([0])], + state: LoadingState.Done, + timeRange: getDefaultTimeRange(), + }, + }); + jest.spyOn(sourceData, 'getResultsStream').mockReturnValue(upstreamStream); + + const scene = new SceneFlexLayout({ + children: [ + new SceneFlexItem({ + body: new VizPanel({ + key: getVizPanelKeyForPanelId(1), + $data: sourceData, + }), + }), + ], + }); + + const ds = new DashboardDatasource({} as DataSourceInstanceSettings); + + const observable = ds.query({ + timezone: 'utc', + targets: [query], + requestId, + interval: '', + intervalMs: 0, + range, + scopedVars: { + __sceneObject: new SafeSerializableSceneObject(scene), + }, + app: '', + startTime: 0, + }); + + return { observable, upstreamStream, sourceData }; +} + function setup(query: DashboardQuery, requestId?: string) { const sourceData = new SceneDataTransformer({ $data: new SceneDataNode({ @@ -1,4 +1,4 @@ -import { type Observable, debounce, debounceTime, defer, finalize, first, interval, map, of } from 'rxjs'; +import { type Observable, debounce, debounceTime, defer, filter, finalize, first, interval, map, of } from 'rxjs'; import { DataSourceApi, @@ -16,6 +16,7 @@ import { type AdHocVariableFilter, type MetricFindValue, getValueMatcher, + type TimeRange, ValueMatcherID, type DataSourceGetDrilldownsApplicabilityOptions, type DrilldownsApplicability, @@ -31,6 +32,13 @@ import { MIXED_REQUEST_PREFIX } from '../mixed/MixedDataSource'; import { type DashboardQuery } from './types'; +function isSameRange(a: TimeRange | undefined, b: TimeRange | undefined): boolean { + if (!a?.from || !a?.to || !b?.from || !b?.to) { + return false; + } + return a.from.valueOf() === b.from.valueOf() && a.to.valueOf() === b.to.valueOf(); +} + /** * This should not really be called */ @@ -96,8 +104,32 @@ export class DashboardDatasource extends DataSourceApi<DashboardQuery> { const activateCleanUp = activateSceneObjectAndParentTree(sourceDataProvider!); + // Only the Mixed-DS path uses `first(Done || Error)` to complete the + // substream, so only that path needs to defend against a stale Done + // replayed from the upstream SceneQueryRunner's ReplaySubject after a + // time-range change. The non-Mixed path stays open and naturally + // re-emits when the fresh Done arrives, so adding the filter there + // could only hurt: a chain panel with a `PanelTimeRange` override + // legitimately observes ranges that differ from the upstream and we + // would block its terminal emission indefinitely. + const isMixedDs = options.requestId.includes(MIXED_REQUEST_PREFIX); + return sourceDataProvider!.getResultsStream!().pipe( debounceTime(50), + filter((result) => { + if (!isMixedDs) { + return true; + } + const state = result.data.state; + if (state !== LoadingState.Done && state !== LoadingState.Error) { + return true; + } + const upstreamRange = result.data.request?.range; + if (!upstreamRange?.from || !upstreamRange?.to) { + return true; + } + return isSameRange(upstreamRange, options.range); + }), map((result) => { return { data: this.getDataFramesForQueryTopic(result.data, query, adHocFilters),
Leaderboard for this case
easy · 9 of 9 bots fully caught it (100% solve rate) · 100% avg coverage.
| # | Bot | Result | Caught | Coverage | Findings | False alarms |
|---|---|---|---|---|---|---|
| 1 | Claude Code (Opus 5.5) | solved | 1/1 | 100.0% | 2 | 0 |
| 2 | Cubic | solved | 1/1 | 100.0% | 2 | 0 |
| 3 | cursor | solved | 1/1 | 100.0% | 1 | 0 |
| 4 | Drape (Deep Review) | solved | 1/1 | 100.0% | 1 | 0 |
| 5 | Drape (Review) | solved | 1/1 | 100.0% | 1 | 0 |
| 6 | greptile | solved | 1/1 | 100.0% | 1 | 0 |
| 7 | Mjolnir (Opus 5.5) | solved | 1/1 | 100.0% | 2 | 0 |
| 8 | Mjolnir (Sonnet 5.5) | solved | 1/1 | 100.0% | 2 | 0 |
| 9 | qodo | solved | 1/1 | 100.0% | 1 | 0 |
Bot results
Claude Code (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
On the Mixed-DS path the new filter drops every Done/Error whose upstream request range differs from options.range, but lets Loading through. A ranged mismatch that persists makes `first(Done||Error)` never match, so the substream never completes. That happens when a Mixed chain panel has a PanelTimeRange override, or the source panel has its own time override. Before this change the Done would have been emitted. The change's own comment admits this risk for the non-Mixed path but leaves the Mixed path exposed to it. [grounded: diff] [consensus 3/3: valid=3]
raw comments (2)
On the Mixed-DS path, a Done or Error emission now passes only if the upstream `request.range` exactly equals the chain panel's `options.range`. That only holds when both panels resolve the same time range. If the chain panel or the source panel has a panel-level time override (`timeFrom` / `timeShift`, i.e. `PanelTimeRange`), the two ranges never match. Every Done and Error is then filtered out, so `emitFirstLoadedDataIfMixedDS`'s `first(Done || Error)` never fires. The Mixed panel's Dashboard-DS subquery stays stuck in Loading forever, and errors are swallowed. The code comment names this exact hazard for the non-Mixed path, but Mixed panels can have time overrides too. Before this change these setups worked. A safer approach is to skip only the stale value replayed synchronously on subscribe, or to compare against the upstream provider's own expected range rather than the chain panel's range.
When ranges differ, the filter drops terminal states but still lets Loading and Streaming through. The Mixed operator then forwards non-terminal emissions while it waits for a Done that, in the mismatch cases above, never arrives. The panel shows a perpetual loading state with no timeout and no error surfaced to the user.
Cubic · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
The new tests do wait on real 600ms timers to out-wait about 450ms of real debounce time. That makes the suite slower and could flake if the event loop stalls. Still, this is about test style and robustness, not wrong production behaviour, and under normal conditions Node fires timers in expiry order, so the tests pass. [grounded: diff] [consensus 5/5: minor=5]
raw comments (3)
<!-- cubic:v=8cb29ed3-d097-499e-bdd2-5d4895e88e58 -->
<!-- cubic:review-run=bf90a78e-28c3-5837-80fe-ff0de173d764 -->
<!-- metadata:{"confidence":8} -->
P1: When a Mixed dashboard query references a source panel with a `PanelTimeRange` override, `result.data.request.range` differs legitimately from the consuming request's `options.range`. This filter drops the source panel's only terminal result, leaving the Mixed query without data; preserve terminal results for source-panel overrides or compare against the source panel's expected range.
<details>
<summary>Prompt for AI agents</summary>
```text
Check if this issue is valid — if so, understand the root cause and fix it. At public/app/plugins/datasource/dashboard/datasource.ts, line 131:
<comment>When a Mixed dashboard query references a source panel with a `PanelTimeRange` override, `result.data.request.range` differs legitimately from the consuming request's `options.range`. This filter drops the source panel's only terminal result, leaving the Mixed query without data; preserve terminal results for source-panel overrides or compare against the source panel's expected range.</comment>
<file context>
@@ -96,8 +104,32 @@ export class DashboardDatasource extends DataSourceApi<DashboardQuery> {
+ if (!upstreamRange?.from || !upstreamRange?.to) {
+ return true;
+ }
+ return isSameRange(upstreamRange, options.range);
+ }),
map((result) => {
</file context>
```
</details>
<!-- cubic:v=29e9e652-7a7c-45cf-a8db-eb8d70ff9712 -->
<!-- cubic:review-run=bf90a78e-28c3-5837-80fe-ff0de173d764 -->
<!-- metadata:{"confidence":6} -->
P3: The three new tests rely on fixed 600ms wall-clock sleeps (waitForDebounce) instead of jest fake timers, adding ~3.6s to the suite and leaving only a ~150ms margin over the ~450ms of real debounce timers (debounceTime(50) + debounce(interval(400))) they must out-wait. datasource.ts itself notes the 400ms debounce was tuned for heavily throttled CPUs, so under throttled CI the fixed sleep can elapse before the pipeline drains and the test flakes intermittently. Use jest fake timers (or advance timers) around these tests to make them deterministic and fast.
<details>
<summary>Prompt for AI agents</summary>
```text
Check if this issue is valid — if so, understand the root cause and fix it. At public/app/plugins/datasource/dashboard/datasource.test.ts, line 1010:
<comment>The three new tests rely on fixed 600ms wall-clock sleeps (waitForDebounce) instead of jest fake timers, adding ~3.6s to the suite and leaving only a ~150ms margin over the ~450ms of real debounce timers (debounceTime(50) + debounce(interval(400))) they must out-wait. datasource.ts itself notes the 400ms debounce was tuned for heavily throttled CPUs, so under throttled CI the fixed sleep can elapse before the pipeline drains and the test flakes intermittently. Use jest fake timers (or advance timers) around these tests to make them deterministic and fast.</comment>
<file context>
@@ -889,6 +974,87 @@ function setupWithAnnotations(query: DashboardQuery, requestId?: string) {
+function waitForDebounce() {
+ // datasource.ts uses debounceTime(50) followed by the Mixed-DS operator which adds
+ // an internal 400ms debounce on the first Done. Wait long enough for both to drain.
+ return new Promise((r) => setTimeout(r, 600));
+}
+
</file context>
```
</details>
<!-- cubic:review-summary:start -->
**2 issues found** across 2 files
<!-- cubic:review-summary:end -->
<details>
<summary>Prompt for AI agents (unresolved issues)</summary>
```text
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="public/app/plugins/datasource/dashboard/datasource.ts">
<violation number="1" location="public/app/plugins/datasource/dashboard/datasource.ts:131">
P1: When a Mixed dashboard query references a source panel with a `PanelTimeRange` override, `result.data.request.range` differs legitimately from the consuming request's `options.range`. This filter drops the source panel's only terminal result, leaving the Mixed query without data; preserve terminal results for source-panel overrides or compare against the source panel's expected range.</violation>
</file>
<file name="public/app/plugins/datasource/dashboard/datasource.test.ts">
<violation number="1" location="public/app/plugins/datasource/dashboard/datasource.test.ts:1010">
P3: The three new tests rely on fixed 600ms wall-clock sleeps (waitForDebounce) instead of jest fake timers, adding ~3.6s to the suite and leaving only a ~150ms margin over the ~450ms of real debounce timers (debounceTime(50) + debounce(interval(400))) they must out-wait. datasource.ts itself notes the 400ms debounce was tuned for heavily throttled CPUs, so under throttled CI the fixed sleep can elapse before the pipeline drains and the test flakes intermittently. Use jest fake timers (or advance timers) around these tests to make them deterministic and fast.</violation>
</file>
```
</details>
<sub>Reply with feedback, questions, or to request a fix.<br /><br />[Re-trigger cubic](https://www.cubic.dev/action/re-review/pr/drape-io/crbench-cubic-2026-09/41/ai_pr_review_github_delivery_e763174bbbf0c65f3bb65105747182280ec16b65c65539cd17a332e6c352db87?returnTo=https%3A%2F%2Fgithub.com%2Fdrape-io%2Fcrbench-cubic-2026-09%2Fpull%2F41)</sub>
<!-- cubic:review-post:ai_pr_review_github_delivery_e763174bbbf0c65f3bb65105747182280ec16b65c65539cd17a332e6c352db87:da037b9e07bfd4d161c3d4d7b69303470f3fcbcf:bf90a78e-28c3-5837-80fe-ff0de173d764 -->
cursor · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
raw comments (2)
### Mixed DS hangs on range mismatch
**High Severity**
<!-- DESCRIPTION START -->
The Mixed-DS filter drops `Done` and `Error` when upstream `request.range` differs from `options.range`. Dashboard DS data comes from a source panel that can legitimately use a different range via `PanelTimeRange` (`timeFrom`/`timeShift`) on either panel. `first(Done || Error)` then never matches, Mixed `forkJoin` never completes, and the panel stays loading.
<!-- DESCRIPTION END -->
<!-- BUGBOT_BUG_ID: 2984df8c-c172-42c0-8e34-6d64e02db452 -->
<!-- LOCATIONS START
public/app/plugins/datasource/dashboard/datasource.ts#L118-L132
LOCATIONS END -->
<div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmRlMjMyNjBjLTE0ODUtNGJlNS1hYmZmLTYwYmE1YTY3MjlmNSIsImVuY3J5cHRpb25LZXkiOiJuOTR0R2YzTnRwaFVYM05aVHdyeEpRSVQ1aFBXY3gwbUp0MExxeXViamNnIiwiYnJhbmNoIjoidDItZ3JhZmFuYS0xMjQ2NjUiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmRlMjMyNjBjLTE0ODUtNGJlNS1hYmZmLTYwYmE1YTY3MjlmNSIsImVuY3J5cHRpb25LZXkiOiJuOTR0R2YzTnRwaFVYM05aVHdyeEpRSVQ1aFBXY3gwbUp0MExxeXViamNnIiwiYnJhbmNoIjoidDItZ3JhZmFuYS0xMjQ2NjUiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByTnVtYmVyIjo0MSwiY29tbWl0U2hhIjoiYmU5ZmQyMDQ5N2E4MjcwNTk4NWNlY2JkMjE3YzkxMzBiMWQzNWFkYSIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div>
<sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit be9fd20497a82705985cecbd217c9130b1d35ada. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- BUGBOT_REVIEW -->
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
<!-- BUGBOT_FIX_ALL -->
<a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTowODFjN2QxMi1lNDJjLTQ1YzgtODAyYy02YmRkZmE1ODUwOTciLCJlbmNyeXB0aW9uS2V5IjoiZ21yYVF6cm1MbkFmR2FEci14QmdJb3hrb01kSlV1a05mYmJLLThDWWR4QSIsImJyYW5jaCI6InQyLWdyYWZhbmEtMTI0NjY1IiwicmVwb093bmVyIjoiZHJhcGUtaW8iLCJyZXBvTmFtZSI6ImNyYmVuY2gtY3Vyc29yLTIwMjYtMDkiLCJwcm92aWRlciI6ImdpdGh1YiJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix All in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>
<!-- /BUGBOT_FIX_ALL -->
<!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN -->
<sup>❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END -->
<sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit be9fd20497a82705985cecbd217c9130b1d35ada. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
Drape (Deep Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
raw comments (1)
**Mixed panel stuck loading when time ranges differ**
If the chain or source panel has a relative-time or time-shift override, the source's Done range never equals `options.range`, so every Done is filtered and `first(Done||Error)` never fires. Skip a mismatching Done only when it is the replayed value present at subscribe time, not every mismatching Done.
```
public/app/plugins/datasource/dashboard/datasource.ts:115 const isMixedDs = options.requestId.includes(MIXED_REQUEST_PREFIX);
public/app/plugins/datasource/dashboard/datasource.ts:117 return sourceDataProvider!.getResultsStream!().pipe(
public/app/plugins/datasource/dashboard/datasource.ts:118 debounceTime(50),
public/app/plugins/datasource/dashboard/datasource.ts:119 filter((result) => {
public/app/plugins/datasource/dashboard/datasource.ts:127 const upstreamRange = result.data.request?.range;
public/app/plugins/datasource/dashboard/datasource.ts:128 if (!upstreamRange?.from || !upstreamRange?.to) {
public/app/plugins/datasource/dashboard/datasource.ts:129 return true;
public/app/plugins/datasource/dashboard/datasource.ts:130 }
public/app/plugins/datasource/dashboard/datasource.ts:131 return isSameRange(upstreamRange, options.range);
public/app/plugins/datasource/dashboard/datasource.ts:371 first((val) => val.state === LoadingState.Done || val.state === LoadingState.Error)
```
Drape (Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
raw comments (1)
**Mixed-DS panels with time override never get Done**
On the Mixed path, the filter drops any Done/Error whose upstream range differs from `options.range`. If the source panel has its own time override, the ranges never match, so the terminal state is never forwarded. Detect stale replays another way than comparing against options.range.
```
public/app/plugins/datasource/dashboard/datasource.ts:115 const isMixedDs = options.requestId.includes(MIXED_REQUEST_PREFIX);
public/app/plugins/datasource/dashboard/datasource.ts:117 return sourceDataProvider!.getResultsStream!().pipe(
public/app/plugins/datasource/dashboard/datasource.ts:118 debounceTime(50),
public/app/plugins/datasource/dashboard/datasource.ts:119 filter((result) => {
```
greptile · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
raw comments (2)
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Valid Mixed Results Dropped**
A Mixed panel can contain a Dashboard datasource target while the consuming and source panels use independent `timeFrom` or `timeShift` overrides. Here, `options.range` belongs to the consuming panel, but `upstreamRange` belongs to the source panel. This equality check therefore drops the source panel's legitimate terminal result when those ranges differ. Because the Mixed path waits for a terminal result before completing, the query can remain pending indefinitely. The new differing-range test covers only the non-Mixed path.
<h3>Greptile Summary</h3>
This PR attempts to prevent Mixed dashboard queries from completing on a stale terminal result replayed for an earlier time range.
- Adds a Mixed-only range filter before terminal-result handling.
- Adds regression tests for stale Done replay, matching ranges, and non-Mixed panel range overrides.
- The range filter does not account for valid Mixed Dashboard chains whose source and consuming panels have different effective ranges.
<h3>Confidence Score: 4/5</h3>
The PR is not safe to merge until legitimate differing-range Mixed Dashboard chains can still deliver their terminal result.
The new equality gate compares the consuming Mixed panel's range with the independently executed source panel's range, so supported time overrides can cause every terminal result to be discarded and leave the Mixed request unresolved.
**Files Needing Attention:** public/app/plugins/datasource/dashboard/datasource.ts, public/app/plugins/datasource/dashboard/datasource.test.ts
<details><summary><h3>Important Files Changed</h3></summary>
| Filename | Overview |
|----------|----------|
| public/app/plugins/datasource/dashboard/datasource.ts | Adds terminal-result range filtering that fixes stale replay but also rejects supported Mixed chains with independent panel ranges. |
| public/app/plugins/datasource/dashboard/datasource.test.ts | Adds focused replay regression coverage, but the differing-range case is exercised only through the non-Mixed path. |
</details>
<details open><summary><h3>Sequence Diagram</h3></summary>
```mermaid
sequenceDiagram
participant Mixed as Mixed consuming panel
participant DashboardDS as DashboardDatasource
participant Source as Source panel provider
Mixed->>DashboardDS: "query(options.range = consumer range)"
DashboardDS->>Source: subscribe to existing results stream
Source-->>DashboardDS: "Done(request.range = source range)"
DashboardDS->>DashboardDS: compare source range to consumer range
DashboardDS--xMixed: legitimate terminal result filtered
Note over Mixed,DashboardDS: Mixed request remains pending
```
</details>
<!-- greptile_other_comments_section -->
<sub>Reviews (1): Last reviewed commit: ["Update public/app/plugins/datasource/das..."](https://github.com/drape-io/crbench-greptile-2026-09/commit/eb1c0a15e40f180060eef12e8688c240f7d1bd0f) | [Re-trigger Greptile](https://app.greptile.com/api/retrigger?id=64284467)</sub>
Mjolnir (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
On the Mixed-DS path, the filter drops every Done/Error whose upstream request.range differs from options.range. If the chain panel or the source panel has a PanelTimeRange override, the two ranges never match. In that case `first(Done||Error)` never fires and the panel stays stuck in Loading. Before this change those Done emissions were forwarded, and the new tests only cover the matching-range Mixed case and the mismatched non-Mixed case. [grounded: diff] [consensus 3/3: valid=3]
raw comments (2)
[P1] Mixed-DS filter blocks the terminal emission forever when the time ranges legitimately differ
public/app/plugins/datasource/dashboard/datasource.ts:119-131 The new comment says the filter is kept off the non-Mixed path because a panel with a `PanelTimeRange` override legitimately sees a range that differs from the upstream, which would block its terminal emission. The same thing happens on the Mixed path. Take a Mixed panel that has a relative-time or time-shift override and includes a `-- Dashboard --` query, or one whose source panel has its own time override. Its `options.range` will never match the upstream's `result.data.request.range`. Every Done/Error result gets dropped, so `emitFirstLoadedDataIfMixedDS`'s `first(Done || Error)` never fires, and the panel stays in Loading with no data. Before this change, those panels worked. The filter needs to cover only the stale-replay case, for example by dropping just the first replayed result or by comparing against the upstream's own current time range. Comparing the upstream request range with the consumer's requested range does not do that.
[P1] Mixed-DS chain panels with a different time range never get Done
public/app/plugins/datasource/dashboard/datasource.ts:118-132 The new filter assumes that on the Mixed-DS path the upstream's `request.range` will eventually equal `options.range`. That only holds when both panels use the same dashboard time range. If the consuming panel has a PanelTimeRange override (relative time or time shift) and uses Mixed with a `-- Dashboard --` query, its `options.range` never matches the upstream range. The same happens when the source panel has its own override. In both cases every Done/Error from the upstream is dropped, so `emitFirstLoadedDataIfMixedDS`'s `first(Done || Error)` never fires and the panel stays in Loading. The in-code comment names this override scenario as the reason to skip the filter on the non-Mixed path, but Mixed panels can have the same overrides. The new tests only check the matching-range Mixed case and the non-Mixed mismatch case, so this regression isn't covered.
Mjolnir (Sonnet 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | off by one |
In the Mixed path, the new filter drops every Done/Error whose upstream request.range differs from options.range. If the source panel has a PanelTimeRange override (timeFrom/timeShift) or the consumer has one, the two ranges legitimately differ, so every terminal emission is dropped. `first(Done||Error)` then never fires and the panel stays in Loading. Before this change those emissions passed through. The PR's own comment admits this failure mode for the non-Mixed path but leaves the Mixed path unprotected. [grounded: diff] [consensus 3/3: valid=3]
raw comments (2)
[P2] Mixed-DS query can hang when source and consumer ranges differ
For Mixed-DS requests, the new filter drops every `Done` or `Error` result whose `request.range` differs from `options.range`. `first(Done || Error)` in `emitFirstLoadedDataIfMixedDS` is then never satisfied, so the Mixed query never completes and the panel stays in Loading. This happens whenever the source panel's range legitimately differs from the consuming panel's range. Examples are a source panel with a `PanelTimeRange` override (relative time or time shift) feeding a Mixed panel on the dashboard range, or the reverse. The code comment says this scenario would block terminal emission for the non-Mixed path, but the same reasoning applies to the Mixed path, where the block is permanent. The filter should not require strict equality with `options.range` when the ranges differ by design. A stale-replay guard that compares against the upstream's own current range would avoid this.
[P2] Mixed-DS stream never completes when source and consumer time ranges differ
For the Mixed path, the new filter drops every Done/Error result whose `request.range` isn't identical to `options.range`. That also drops legitimate terminal emissions when the source panel's range legitimately differs from the consuming panel's range. Examples are a source panel with a relative-time or time-shift override (`PanelTimeRange`) used by a Dashboard-DS query that sits in a Mixed panel, or the consumer having its own override. In that case the Done is never let through. `emitFirstLoadedDataIfMixedDS`'s `first(Done || Error)` never fires, so the Mixed panel stays in Loading until timeout or cancel, and it never gets the source data. The code comment acknowledges this exact failure mode for the non-Mixed path but doesn't guard against it in the Mixed path. The filter treats "range differs" as "stale", but it can also mean "intentionally different range". A stale-vs-fresh check that doesn't depend on the consumer's range being equal to the source's (for example, comparing against the previous range seen from the upstream) would avoid this.
qodo · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
raw comments (3)
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required">
1\. Mixed-source panels stay loading forever <code>🐞 Bug</code> <code>≡ Correctness</code>
<pre>
<b><i>query</i></b> rejects every terminal source result on Mixed requests when <b><i>result.data.request.range</i></b>
differs from the chain panel's <b><i>options.range</i></b>. Mixed explicitly supports Dashboard targets, and
when the referenced source panel has its own time override its query runner uses that different
range, so the dashboard substream never satisfies <b><i>first</i></b> and <b><i>MixedDatasource</i></b>'s <b><i>toArray</i></b> and
<b><i>forkJoin</i></b> leave the whole panel loading.
</pre>
<details>
<summary><strong>Agent Prompt</strong></summary>
```
## Issue description
The Mixed-only stale-result filter compares the referenced source panel's result range with the chain panel's request range. Those ranges legitimately differ when the source panel has a panel-level time override, causing all terminal results to be discarded and the mixed query never to complete.
## Fix Focus Areas
- public/app/plugins/datasource/dashboard/datasource.ts[107-142]
- public/app/plugins/datasource/dashboard/datasource.test.ts[116-196]
## Recommended Fix
Validate replayed results against the source data provider's effective current range rather than the outer chain panel's `options.range`, or otherwise track whether a terminal value was replayed before the source began its new execution. Add a Mixed-request regression test where the referenced source panel's effective range intentionally differs from the chain panel's range and verify its terminal result is emitted.
```
<code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code>
</details>
<h3>PR Summary by Qodo</h3>
Prevent stale Mixed dashboard results after time-range changes
<code>🐞 Bug fix</code> <code>🧪 Tests</code> <code>🕐 20-40 Minutes</code>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<details>
<summary>AI Description</summary>
<dl>
<dd>
<br/>
><pre>
>• Ignore stale terminal replays for Mixed dashboard queries after time-range changes.
>• Preserve matching Mixed results and non-Mixed panel time-range overrides.
>• Add ReplaySubject regression coverage for stale, matching, and overridden ranges.
></pre>
</dd>
</dl>
</details>
<details>
<summary>Diagram</summary>
<dl>
<dd>
<br/>
```mermaid
sequenceDiagram
participant M as Mixed DS
participant D as Dashboard DS
participant U as Upstream stream
participant F as Range filter
participant C as Chain panel
M->>D: Query new range
D->>U: Subscribe
U-->>F: Replay stale Done
F--xC: Drop mismatched range
U-->>F: Emit fresh Done
F-->>D: Accept matching range
D-->>M: Complete substream
M-->>C: Render fresh data
```
</dd>
</dl>
</details>
<details>
<summary>High-Level Assessment</summary>
<dl>
<dd>
<br/>
>The following are alternative approaches to this PR:
<details>
<summary><b>1. Version upstream emissions by request</b></summary>
<dl>
<dd>
- ➕ Correlates results directly with the originating query instead of inferring freshness from time ranges.
- ➕ Could prevent stale replays for future request dimensions beyond time range.
- ➖ Requires broader changes to scene-provider result contracts and producers.
- ➖ Introduces substantially more cross-cutting risk for a focused regression.
</dd>
</dl>
</details>
<details>
<summary><b>2. Wait for a Loading emission</b></summary>
<dl>
<dd>
- ➕ Avoids accepting a terminal replay before a new execution visibly starts.
- ➕ Does not require comparing time ranges.
- ➖ Drops valid single-Done responses, including the Mixed editor-add path.
- ➖ Assumes every provider emits Loading before completion.
</dd>
</dl>
</details>
>**Recommendation:** Keep the PR's targeted range filter. It fixes the Mixed-only early-completion failure while preserving single-Done matching responses and non-Mixed PanelTimeRange overrides; broader request versioning is more robust conceptually but disproportionate for this regression.
</dd>
</dl>
</details>
<details>
<summary> Files changed (2) <code> +200 / -2 </code> </summary>
<dl>
<dd>
<br/>
<details>
<summary>Bug fix (1) <code> +33 / -1 </code></summary>
<dl>
<dd>
<details>
<summary>datasource.ts<code>Filter stale Mixed terminal results by requested time range</code> <code>+33/-1</code></summary>
<br/>
>Filter stale Mixed terminal results by requested time range
>
><pre>
>• Detects Mixed datasource requests and filters Done or Error results whose upstream request range differs from the active query range. Non-terminal results, results without range metadata, and all non-Mixed requests continue unchanged.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/40/files#diff-5530f1d5f78fd48f9c593e2bdfa60b884597b554a05d66ed6b8143517056f60b'>public/app/plugins/datasource/dashboard/datasource.ts</a>
</details>
</dd>
</dl>
</details>
<details>
<summary>Tests (1) <code> +167 / -1 </code></summary>
<dl>
<dd>
<details>
<summary>datasource.test.ts<code>Cover stale Mixed datasource replay and range exceptions</code> <code>+167/-1</code></summary>
<br/>
>Cover stale Mixed datasource replay and range exceptions
>
><pre>
>• Adds a controllable ReplaySubject-based upstream fixture that reproduces synchronous replay behavior. Tests verify stale Mixed terminal results are skipped, matching results are emitted, and non-Mixed range overrides remain unaffected.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/40/files#diff-f9175357c0f0deed6b9960b72f110aacdd34727618acefa69d726a8285cdd5e2'>public/app/plugins/datasource/dashboard/datasource.test.ts</a>
</details>
</dd>
</dl>
</details>
</dd>
</dl>
</details>
<h3>Code Review by Qodo</h3>
<code>🐞 Bugs (1)</code> <code>📘 Rule violations (0)</code> <code>📜 Skill insights (0)</code>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<br/>
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required">
<details>
<summary> 1. Mixed-source panels stay loading forever <code>🐞 Bug</code> <code>≡ Correctness</code></summary>
<br/>
> <details open>
><summary>Description</summary>
><br/>
>
><pre>
><b><i>query</i></b> rejects every terminal source result on Mixed requests when <b><i>result.data.request.range</i></b>
>differs from the chain panel's <b><i>options.range</i></b>. Mixed explicitly supports Dashboard targets, and
>when the referenced source panel has its own time override its query runner uses that different
>range, so the dashboard substream never satisfies <b><i>first</i></b> and <b><i>MixedDatasource</i></b>'s <b><i>toArray</i></b> and
><b><i>forkJoin</i></b> leave the whole panel loading.
></pre>
></details>
> <details>
><summary>Code</summary>
><br/>
>
><code>[public/app/plugins/datasource/dashboard/datasource.ts[131]](https://github.com/drape-io/crbench-qodo-2026-09/pull/40/files#diff-5530f1d5f78fd48f9c593e2bdfa60b884597b554a05d66ed6b8143517056f60bR131-R131)</code>
>
>```diff
>+ return isSameRange(upstreamRange, options.range);
>```
></details>
> <details>
><summary>Evidence</summary>
><br/>
>
><pre>
>MixedDataSource explicitly handles Dashboard targets as supported individual batches, clones the
>outer chain-panel request into each datasource request, and waits for each child observable to
>complete through <b><i>toArray()</i></b> and <b><i>forkJoin()</i></b>. Referenced panels own independent query runners,
>while PanelTimeRange computes a panel-specific overridden range; <b><i>runRequest</i></b> stores that source
>request and range in the resulting PanelData. The added filter compares this source range with the
>cloned outer range, and the downstream <b><i>first(Done || Error)</i></b> cannot complete after the legitimate
>terminal value is rejected.
></pre>
>
> <code>[public/app/plugins/datasource/mixed/MixedDataSource.ts[51-68]](https://github.com/drape-io/crbench-qodo-2026-09/blob/e43302efe63e27b06b30d778e193dad48b8d285f/public/app/plugins/datasource/mixed/MixedDataSource.ts/#L51-L68)</code>
> <code>[public/app/plugins/datasource/mixed/MixedDataSource.ts[124-161]](https://github.com/drape-io/crbench-qodo-2026-09/blob/e43302efe63e27b06b30d778e193dad48b8d285f/public/app/plugins/datasource/mixed/MixedDataSource.ts/#L124-L161)</code>
> <code>[public/app/features/dashboard-scene/utils/createPanelDataProvider.ts[24-42]](https://github.com/drape-io/crbench-qodo-2026-09/blob/e43302efe63e27b06b30d778e193dad48b8d285f/public/app/features/dashboard-scene/utils/createPanelDataProvider.ts/#L24-L42)</code>
> <code>[public/app/features/dashboard-scene/scene/panel-timerange/PanelTimeRange.tsx[61-82]](https://github.com/drape-io/crbench-qodo-2026-09/blob/e43302efe63e27b06b30d778e193dad48b8d285f/public/app/features/dashboard-scene/scene/panel-timerange/PanelTimeRange.tsx/#L61-L82)</code>
> <code>[public/app/features/query/state/runRequest.ts[121-143]](https://github.com/drape-io/crbench-qodo-2026-09/blob/e43302efe63e27b06b30d778e193dad48b8d285f/public/app/features/query/state/runRequest.ts/#L121-L143)</code>
> <code>[public/app/plugins/datasource/dashboard/datasource.ts[117-142]](https://github.com/drape-io/crbench-qodo-2026-09/blob/e43302efe63e27b06b30d778e193dad48b8d285f/public/app/plugins/datasource/dashboard/datasource.ts/#L117-L142)</code>
></details>
> <details>
><summary>Agent prompt</summary>
><br/>
>
>```
>The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
>
>## Issue description
>The Mixed-only stale-result filter compares the referenced source panel's result range with the chain panel's request range. Those ranges legitimately differ when the source panel has a panel-level time override, causing all terminal results to be discarded and the mixed query never to complete.
>
>## Fix Focus Areas
>- public/app/plugins/datasource/dashboard/datasource.ts[107-142]
>- public/app/plugins/datasource/dashboard/datasource.test.ts[116-196]
>
>## Recommended Fix
>Validate replayed results against the source data provider's effective current range rather than the outer chain panel's `options.range`, or otherwise track whether a terminal value was replayed before the source began its new execution. Add a Mixed-request regression test where the referenced source panel's effective range intentionally differs from the chain panel's range and verify its terminal result is emitted.
>```
> <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code>
></details>
<hr/>
</details>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<!-- qodo-context:start -->
<details><summary><strong>Context sources</strong></summary>
<div>Review mode: <code>⚖️ Balanced</code>: This changes runtime datasource filtering in a Mixed-DS query path and adds substantial regression-test scaffolding, creating meaningful behavioral risk, but the logic remains localized enough for one careful review pass.</div>
<!-- qodo-context:end -->
</details>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<!-- qodo-daily-tip:start -->
<details>
<summary><strong>Tip of the day</strong></summary>
<br/>
<pre>💡 Did you know, you can reply 'qodo' on any finding to push back, ask questions, or dig deeper</pre>
<a href="https://docs.qodo.ai/tips-and-tricks">More tips ↗</a> | <a href="https://app.qodo.ai/configurations?tab=display-preferences">Customize Qodo ↗</a> | <a href="https://docs.qodo.ai">Qodo docs ↗</a>
</details>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<!-- qodo-daily-tip:end -->
<!-- https://github.com/drape-io/crbench-qodo-2026-09/commit/e43302efe63e27b06b30d778e193dad48b8d285f -->
<a href="https://www.qodo.ai"><img src="https://www.qodo.ai/wp-content/uploads/2025/03/qodo-logo.svg" width="80" alt="Qodo Logo"></a>