apache / apache/rocketmq-dashboard
[Studio][Bug] Metrics Explorer silently reverts to the 1h window when the dashboard switches instances
- Dominant language
- Java
- Stars
- 1.4k
- Forks
- 683
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 58
Description
**Problem**
On the home dashboard (`/`, `web/src/pages/home/dashboard.tsx`), the Metrics Explorer below the cluster cards keeps its component instance mounted while the 实例 selector changes (`` with no `key`). When the instance prop changes, the profile-loading effect re-runs and reloads every panel — but it hardcodes `RANGE_OPTIONS[0]` (the 1h window, `web/src/components/MetricsExplorer.tsx:539` before the fix) instead of the currently selected range.
**Evidence**
Reproduction (component test, mocked API):
1. Select a non-default range (e.g. 6h) — the panel issues a query with `start = end - 6h`, `step = '2m'`, and the Segmented control shows 6h.
2. Change the dashboard instance selector (instance-1 → instance-2). The profiles effect re-runs (`loadAll` is in its dependency chain through `runQuery`, which depends on `instanceId`) and reloads the panels.
3. Observed with the unfixed code: the reload query uses the default 1h window (`start = end - 1h`, `step = '30s'`) while the Segmented control still displays **6h**. The charts now show one hour of data for a control that says six hours, and the user is not told anything changed.
The same effect runs once on mount, where `RANGE_OPTIONS[0]` is correct; the defect is that the value is also used on the *reload* path where a user selection already exists.
**Impact**
Every instance switch on the home dashboard silently narrows the explored window to 1h for users working with the 6h/24h ranges — the displayed range label and the actual data window disagree, so trend readings taken right after a switch are quietly wrong.
**Expected behavior**
A reload triggered by an instance change reuses the range the user selected; the 1h default applies only before the first selection (initial mount).
**Related work**
- #3304 / PR #3299 fixed the sibling request-guard issue in the same effect (shared requestId double-bump); the range-reuse gap remained.
- #1603 (closed) addressed stale data-source refs on instance switch in the same component — the selected time range reverting on the same trigger is a distinct gap.
- No existing issue/PR covers the range reverting on instance switch (searched: metrics range, range reset, instance switch, rangeId).
**PR**
Fix: #4189
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in web/src/pages/home/dashboard.tsx to trace the MetricsExplorer instance change, then inspect the profile-loading effect around web/src/components/MetricsExplorer.tsx:539. Run the component test reproduction with a non-default range and an instance switch; done means the reload query and displayed control retain the selected range instead of reverting to 1h.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend, observability
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100