Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

fix(frontend): keep sparkline cursor on local scrub

rcourtman78a0eac73c08
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 86e035ee55..c53da64bb1 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -228,19 +228,20 @@ connections` visible as the API-backed alternative for Proxmox and
route strings or provider-local link builders inside feature panels.
15. Keep shared summary-card emphasis coherent. When shared summary primitives enter an `inactive` state, `SummaryMetricCard`, `InteractiveSparkline`, and `DensityMap` must all demote background context together so storage, infrastructure, and workloads read as one interaction model instead of mixing page-local opacity, sticky-shell, or highlight rules.
16. Keep density-map summaries overview-first. When a shared summary density map receives row focus or chart-hover emphasis, `frontend-modern/src/components/shared/DensityMap.tsx`, `frontend-modern/src/components/shared/useDensityMapState.ts`, and `frontend-modern/src/components/shared/densityMapModel.ts` must preserve the multi-entity overview rows and layer focused-entity detail into the card chrome instead of swapping the card into a single-series chart, dimming the rest of the map into unusable background noise, duplicating cursor-value tooltip copy, or covering the heatmap body with a floating detail overlay.
-17. Keep shared contextual focus canonical after adoption. Once a summary or table surface enters route-backed contextual focus, future additions must extend `frontend-modern/src/components/shared/contextualFocus.ts` and its guardrail tests rather than forking another helper for workload IDs, resource IDs, or scroll-preserving same-route selection.
-18. Keep shared infrastructure/resource selectors on the canonical agent-facet
+17. Keep sparkline scrubbing source-local and sibling-sync timestamp-based. The chart a user is actively scrubbing in `frontend-modern/src/components/shared/InteractiveSparkline.tsx` and `frontend-modern/src/components/shared/useInteractiveSparklineState.ts` must keep its dashed hover cursor on the real local mouse `x`, while sibling cards may map the shared hover timestamp onto their own timelines. Shared cursor sync must not snap the source chart back onto the nearest sample timestamp.
+18. Keep shared contextual focus canonical after adoption. Once a summary or table surface enters route-backed contextual focus, future additions must extend `frontend-modern/src/components/shared/contextualFocus.ts` and its guardrail tests rather than forking another helper for workload IDs, resource IDs, or scroll-preserving same-route selection.
+19. Keep shared infrastructure/resource selectors on the canonical agent-facet
truth. Shared primitives and settings-facing selector helpers must treat
top-level TrueNAS appliances as agent-facet infrastructure via shared
helper ownership instead of reviving a direct `resource.type === 'truenas'`
branch inside page shells, selectors, or reporting-resource type helpers.
-19. Keep shared feature-shell Patrol run fixtures on the canonical run-record
+20. Keep shared feature-shell Patrol run fixtures on the canonical run-record
contract. When `frontend-modern/src/features/patrol/` consumes Patrol run
history, the shared normalized record must preserve provider-backed counts
such as `truenas_checked` instead of letting feature-local fixtures or
fallback objects collapse API-backed TrueNAS systems back into generic
agent-host presentation.
-20. Keep the authenticated app root aligned with that same first-session path.
+21. Keep the authenticated app root aligned with that same first-session path.
That same shared-primitive ownership now includes contextual row focus.
`frontend-modern/src/components/shared/contextualFocus.ts` is the canonical
owner for interactive-series filtering, focused-label lookup, active-series
@@ -253,34 +254,34 @@ connections` visible as the API-backed alternative for Proxmox and
the governed dashboard empty state route first-time operators into
Infrastructure Install, instead of preserving a separate root-only jump to
`/infrastructure` that drifts from the rest of the onboarding contract.
-21. Keep relay settings shell copy on the shared presentation owner in
+22. Keep relay settings shell copy on the shared presentation owner in
`frontend-modern/src/utils/relayPresentation.ts`. The route metadata in
`settingsHeaderMeta.ts` and the leading `SettingsPanel` in
`RelaySettingsPanel.tsx` must reuse the same description and availability
copy instead of drifting into separate rollout or pairing wording.
-22. Keep shared settings-shell legal and docs referrals on
+23. Keep shared settings-shell legal and docs referrals on
`frontend-modern/src/utils/docsLinks.ts`. Shared settings surfaces such as
`AIRuntimeControlsSection.tsx` must not hardcode GitHub `main` doc URLs for
privacy, security, proxy-auth, scope-reference, or Terms-of-Service links.
-23. Keep shared settings-shell telemetry transparency controls on the governed
+24. Keep shared settings-shell telemetry transparency controls on the governed
general settings panel. Preview/reset affordances for anonymous telemetry
must stay rendered inside
`frontend-modern/src/components/Settings/GeneralSettingsPanel.tsx`
instead of drifting into route-local modals, hidden dev tools, or shell
chrome that operators would not naturally inspect.
-24. Keep the short telemetry/privacy summary copy on that same shared surface
+25. Keep the short telemetry/privacy summary copy on that same shared surface
accurate to the governed privacy doc. If the trust boundary depends on a
specific retention window or on “IP addresses are not stored” rather than
“IPs are never seen,” the summary copy in
`GeneralSettingsPanel.tsx` must state those facts plainly instead of
reverting to a stronger but inaccurate shorthand.
-25. Keep shared storage-route feature presentation on neutral capability truth.
+26. Keep shared storage-route feature presentation on neutral capability truth.
Reusable mappers and presenters in `frontend-modern/src/features/storageBackups/`
must distinguish inventory datastores from backup repositories so VMware
rows on the shared storage route stay canonical to the admitted phase-1 floor instead of
reviving backup-target, protected-target, or recovery-local semantics on a
shared page.
-26. Keep infrastructure settings-shell API alternatives on the shared shell
+27. Keep infrastructure settings-shell API alternatives on the shared shell
contract. `frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx`,
`frontend-modern/src/components/Settings/settingsHeaderMeta.ts`,
`frontend-modern/src/components/Settings/settingsNavigationModel.ts`, and
@@ -288,7 +289,7 @@ connections` visible as the API-backed alternative for Proxmox and
present `Platform connections` as the canonical API-backed alternative for
Proxmox, TrueNAS, and future provider integrations instead of reviving
top-level `Direct Proxmox` wording or shell-local provider routes.
-27. Keep the infrastructure settings platform-connections summary and provider
+28. Keep the infrastructure settings platform-connections summary and provider
workspaces on one shared state source. `frontend-modern/src/components/Settings/useInfrastructureSettingsState.ts`,
`frontend-modern/src/components/Settings/useSettingsInfrastructurePanelProps.ts`,
`frontend-modern/src/components/Settings/InfrastructurePlatformConnectionsSummaryCard.tsx`,
@@ -296,14 +297,14 @@ connections` visible as the API-backed alternative for Proxmox and
derive TrueNAS connection counts and availability from the shared
infrastructure settings state instead of letting the reporting summary and
the provider-specific panel issue separate connection fetches.
-28. Keep alert-history feature composition on the current owned state contract.
+29. Keep alert-history feature composition on the current owned state contract.
`frontend-modern/src/features/alerts/tabs/HistoryTab.tsx` must react to the
shared `alertData()` history state instead of reviving deleted aliases, and
it must pass unified-resource resolution through to
`frontend-modern/src/features/alerts/AlertResourceIncidentsPanel.tsx` so
the panel can render shared route chips without creating another page-local
resource lookup or provider-specific handoff layer.
-29. Keep the alert-thresholds containers surface on the canonical shared owner.
+30. Keep the alert-thresholds containers surface on the canonical shared owner.
`alertOverridesModel.ts`, `useAlertOverridesState.ts`, and
`useAlertsConfigurationState.ts` must surface API-backed `app-container`
parents such as TrueNAS as first-class `Container Runtimes`, while
diff --git a/frontend-modern/src/components/shared/InteractiveSparkline.tsx b/frontend-modern/src/components/shared/InteractiveSparkline.tsx
index cd6cbda253..28859bab24 100644
--- a/frontend-modern/src/components/shared/InteractiveSparkline.tsx
+++ b/frontend-modern/src/components/shared/InteractiveSparkline.tsx
@@ -35,6 +35,7 @@ export const InteractiveSparkline: Component<InteractiveSparklineProps> = (props
data-highlight-series-id={props.highlightSeriesId ?? ''}
data-highlight-series-active={sparkline.externalSeriesIndex() !== null ? 'true' : 'false'}
data-active-hover-timestamp={sparkline.activeHoverTimestamp() ?? ''}
+ data-active-hover-cursor-x={sparkline.activeHoverCursorX() ?? ''}
data-active-series-display={sparkline.activeSeriesDisplay()}
data-rendered-series-count={sparkline.renderedSeriesCount()}
data-summary-chart-state={interactionState()}
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index c853dbca6e..cb10c87a00 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -540,6 +540,7 @@ describe('shared primitive guardrails', () => {
it('keeps interactive sparkline on shell, runtime, and model owners', () => {
expect(interactiveSparklineSource).toContain('useInteractiveSparklineState');
expect(interactiveSparklineSource).toContain('data-active-series-display');
+ expect(interactiveSparklineSource).toContain('data-active-hover-cursor-x');
expect(interactiveSparklineSource).toContain('data-rendered-series-count');
expect(interactiveSparklineSource).not.toContain('createEffect');
expect(interactiveSparklineSource).not.toContain('createSignal');
@@ -555,6 +556,10 @@ describe('shared primitive guardrails', () => {
expect(interactiveSparklineStateSource).toContain('createSignal');
expect(interactiveSparklineStateSource).toContain('scheduleSparkline');
expect(interactiveSparklineStateSource).toContain('computeInteractiveSparklineHoverState');
+ expect(interactiveSparklineStateSource).toContain('const localHover = hoveredState();');
+ expect(interactiveSparklineStateSource).toContain('return localHover.x;');
+ expect(interactiveSparklineStateSource).toContain('timestamp: synchronizedHoverTimestamp()');
+ expect(interactiveSparklineStateSource).not.toContain('timestamp: activeHoverTimestamp()');
expect(interactiveSparklineModelSource).toContain('buildInteractiveSparklineChartData');
expect(interactiveSparklineModelSource).toContain('computeInteractiveSparklineHoverState');
diff --git a/frontend-modern/src/components/shared/__tests__/InteractiveSparkline.test.tsx b/frontend-modern/src/components/shared/__tests__/InteractiveSparkline.test.tsx
index b41118ceb8..42010e4825 100644
--- a/frontend-modern/src/components/shared/__tests__/InteractiveSparkline.test.tsx
+++ b/frontend-modern/src/components/shared/__tests__/InteractiveSparkline.test.tsx
@@ -73,6 +73,55 @@ describe('InteractiveSparkline hover behavior', () => {
expect(screen.queryByText('CPU')).toBeNull();
});
+ it('keeps the local hover cursor on the actual scrub position instead of snapping to the nearest sample timestamp', () => {
+ vi.useFakeTimers();
+ vi.setSystemTime(new Date('2024-01-01T12:00:00Z'));
+ const now = Date.now();
+ const windowStart = now - 60 * 60_000;
+
+ const { container } = render(() => (
+ <InteractiveSparkline
+ timeRange="1h"
+ rangeLabel="1h"
+ series={[
+ {
+ name: 'CPU',
+ color: '#ff0000',
+ data: [
+ { timestamp: windowStart + 5 * 60_000, value: 40 },
+ { timestamp: windowStart + 55 * 60_000, value: 50 },
+ ],
+ },
+ ]}
+ />
+ ));
+
+ const svg = container.querySelector('svg');
+ expect(svg).not.toBeNull();
+ if (!svg) return;
+
+ (svg as unknown as { getBoundingClientRect: () => DOMRect }).getBoundingClientRect = () =>
+ ({
+ left: 0,
+ top: 100,
+ width: 200,
+ height: 50,
+ right: 200,
+ bottom: 150,
+ x: 0,
+ y: 100,
+ toJSON: () => ({}),
+ }) as unknown as DOMRect;
+
+ fireEvent.mouseMove(svg, { clientX: 100, clientY: 120 });
+
+ const root = container.firstElementChild;
+ expect(svg.querySelector('line[stroke-dasharray="3 3"]')).toBeInTheDocument();
+ expect(
+ Number.parseFloat(root?.getAttribute('data-active-hover-cursor-x') ?? 'NaN'),
+ ).toBeCloseTo(100, 1);
+ });
+
it('publishes synchronized hover identity and clears it on leave', () => {
vi.useFakeTimers();
vi.setSystemTime(new Date('2024-01-01T12:00:00Z'));
diff --git a/frontend-modern/src/components/shared/useInteractiveSparklineState.ts b/frontend-modern/src/components/shared/useInteractiveSparklineState.ts
index 56c1894441..ed01017209 100644
--- a/frontend-modern/src/components/shared/useInteractiveSparklineState.ts
+++ b/frontend-modern/src/components/shared/useInteractiveSparklineState.ts
@@ -212,13 +212,17 @@ export function useInteractiveSparklineState(
const activeHoverTimestamp = createMemo<number | null>(() => {
return hoveredState()?.timestamp ?? synchronizedHoverTimestamp();
});
- const activeHoverCursorX = createMemo<number | null>(() =>
- getInteractiveSparklineCursorXForTimestamp({
+ const activeHoverCursorX = createMemo<number | null>(() => {
+ const localHover = hoveredState();
+ if (localHover) {
+ return localHover.x;
+ }
+ return getInteractiveSparklineCursorXForTimestamp({
chartData: chartData(),
- timestamp: activeHoverTimestamp(),
+ timestamp: synchronizedHoverTimestamp(),
vbW,
- }),
- );
+ });
+ });
const activeEmphasisSeriesIndex = createMemo(() =>
getInteractiveSparklineActiveEmphasisSeriesIndex({
highlightNearestSeriesOnHover: props.highlightNearestSeriesOnHover === true,