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(recovery): constrain long-range activity timeline

rcourtman3448f7f1480f
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 309693b458..a8bca5539e 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -928,6 +928,10 @@ of spending a disproportionate slice of the screen on chart chrome. The range
picker and legend should share one compact control row, and the activity strip
should not burn a separate descriptive subtitle row once the headline metrics
already explain the chart context.
+That same timeline contract must keep long-range activity fully constrained to
+the card width. Extended ranges such as `365d` should compress their day
+columns to fit the available plot width instead of carrying per-column minimum
+widths that make the chart overflow its containing card.
That telemetry header should also avoid derivative pace rows once the chart
already carries the rhythm. Total points, active days, and issue cues can
stay, but average-per-day style readouts should not re-expand the strip into a
diff --git a/frontend-modern/src/components/Recovery/RecoveryActivitySection.tsx b/frontend-modern/src/components/Recovery/RecoveryActivitySection.tsx
index 91fc36cf95..f3217fa0dd 100644
--- a/frontend-modern/src/components/Recovery/RecoveryActivitySection.tsx
+++ b/frontend-modern/src/components/Recovery/RecoveryActivitySection.tsx
@@ -19,8 +19,7 @@ import {
} from '@/utils/recoveryDatePresentation';
import {
getRecoveryTimelineAxisLabelClass,
- getRecoveryTimelineBarMinWidthClass,
- getRecoveryTimelineLabelEvery,
+ getRecoveryTimelineAxisTicks,
RECOVERY_TIMELINE_LEGEND_ITEM_CLASS,
RECOVERY_TIMELINE_RANGE_GROUP_CLASS,
} from '@/utils/recoveryTimelineChartPresentation';
@@ -81,6 +80,8 @@ interface RecoveryActivitySectionProps {
const rangeOptions: Array<7 | 30 | 90 | 365> = [7, 30, 90, 365];
function RecoveryActivitySectionContent(props: RecoveryActivitySectionProps): JSX.Element {
+ const timelineAxisTicks = () => getRecoveryTimelineAxisTicks(props.timeline().points.length);
+
return (
<>
<div class="mb-2 flex flex-col gap-1.5">
@@ -372,33 +373,29 @@ function RecoveryActivitySectionContent(props: RecoveryActivitySectionProps): JS
</For>
</div>
- <div class="pointer-events-none absolute inset-x-0 bottom-0 h-4 flex items-end gap-[3px]">
- <For each={props.timeline().points}>
- {(point, index) => {
- const showLabel =
- index() % getRecoveryTimelineLabelEvery(props.timeline().points.length) === 0 ||
- index() === props.timeline().points.length - 1;
+ <div class="pointer-events-none absolute inset-x-0 bottom-0 h-4">
+ <For each={timelineAxisTicks()}>
+ {(tick) => {
+ const point = props.timeline().points[tick.index];
const isSelected = props.selectedDateKey() === point.key;
- const barMinWidth = getRecoveryTimelineBarMinWidthClass(
- props.isMobile,
- props.chartRangeDays(),
- );
+ const alignmentClass =
+ tick.align === 'start'
+ ? 'left-0 text-left'
+ : tick.align === 'end'
+ ? 'left-full -translate-x-full text-right'
+ : '-translate-x-1/2 text-center';
+
return (
- <div
- class={`relative flex-1 ${props.isMobile ? '' : 'shrink-0'} ${barMinWidth}`}
+ <span
+ class={`absolute bottom-0 whitespace-nowrap text-[9px] ${
+ isSelected
+ ? getRecoveryTimelineAxisLabelClass(true)
+ : getRecoveryTimelineAxisLabelClass(false)
+ } ${alignmentClass}`}
+ style={{ left: `${tick.positionPct}%` }}
>
- <Show when={showLabel}>
- <span
- class={`absolute bottom-0 left-1/2 -translate-x-1/2 whitespace-nowrap text-[9px] ${
- isSelected
- ? getRecoveryTimelineAxisLabelClass(true)
- : getRecoveryTimelineAxisLabelClass(false)
- }`}
- >
- {getRecoveryCompactAxisLabel(point.key, props.chartRangeDays())}
- </span>
- </Show>
- </div>
+ {getRecoveryCompactAxisLabel(point.key, props.chartRangeDays())}
+ </span>
);
}}
</For>
diff --git a/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx b/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx
index a5ea5438a5..6ddc32a17f 100644
--- a/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx
+++ b/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx
@@ -177,6 +177,30 @@ describe('Recovery', () => {
};
}
if (u.pathname === '/api/recovery/series') {
+ const from = u.searchParams.get('from');
+ const to = u.searchParams.get('to');
+ if (from && to) {
+ const fromDate = new Date(from);
+ const toDate = new Date(to);
+ const daySpan = Math.round((toDate.getTime() - fromDate.getTime()) / (24 * 60 * 60 * 1000));
+ if (daySpan >= 300) {
+ return {
+ data: Array.from({ length: 365 }, (_, index) => {
+ const pointDate = new Date(fromDate);
+ pointDate.setDate(pointDate.getDate() + index);
+ const isoDay = pointDate.toISOString().slice(0, 10);
+ const recent = index > 320 ? 1 : 0;
+ return {
+ day: isoDay,
+ total: recent,
+ snapshot: 0,
+ local: 0,
+ remote: recent,
+ };
+ }),
+ };
+ }
+ }
return {
data: [
{ day: '2026-02-13', total: 1, snapshot: 1, local: 0, remote: 0 },
@@ -1405,6 +1429,32 @@ describe('Recovery', () => {
});
});
+ it('renders sparse 365d timeline ticks instead of one label slot per day', async () => {
+ mockLocationSearch = '?view=events&range=365';
+
+ const { container } = render(() => <Recovery />);
+
+ await waitFor(() => {
+ expect(screen.getByRole('tab', { name: /recovery events/i })).toHaveAttribute(
+ 'aria-selected',
+ 'true',
+ );
+ });
+
+ const labels = await waitFor(() => {
+ const labelsRow = container
+ .querySelector('[data-testid="recovery-activity-bars"]')
+ ?.parentElement?.querySelector('.pointer-events-none.absolute.inset-x-0.bottom-0.h-4');
+ const renderedLabels = Array.from(labelsRow?.querySelectorAll('span') || []);
+ expect(renderedLabels.length).toBeGreaterThan(0);
+ return renderedLabels;
+ });
+
+ expect(labels.length).toBeLessThan(50);
+ expect(labels[0]?.textContent).toBeTruthy();
+ expect(labels.at(-1)?.textContent).toBeTruthy();
+ });
+
it('clears the shared recovery search query on Escape', async () => {
mockLocationSearch = '?q=gdfdgd';
render(() => <Recovery />);
diff --git a/frontend-modern/src/utils/__tests__/recoveryTimelineChartPresentation.test.ts b/frontend-modern/src/utils/__tests__/recoveryTimelineChartPresentation.test.ts
index 16b8e1aa7b..5375eb8c16 100644
--- a/frontend-modern/src/utils/__tests__/recoveryTimelineChartPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/recoveryTimelineChartPresentation.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest';
import {
getRecoveryTimelineAxisLabelClass,
+ getRecoveryTimelineAxisTicks,
getRecoveryTimelineBarMinWidthClass,
getRecoveryTimelineLabelEvery,
RECOVERY_TIMELINE_LEGEND_ITEM_CLASS,
@@ -20,6 +21,7 @@ describe('recoveryTimelineChartPresentation', () => {
expect(getRecoveryTimelineBarMinWidthClass(false, 7)).toBe('min-w-[28px]');
expect(getRecoveryTimelineBarMinWidthClass(false, 30)).toBe('min-w-[14px]');
expect(getRecoveryTimelineBarMinWidthClass(false, 90)).toBe('min-w-[8px]');
+ expect(getRecoveryTimelineBarMinWidthClass(false, 365)).toBe('');
});
it('derives label cadence from day count', () => {
@@ -27,4 +29,19 @@ describe('recoveryTimelineChartPresentation', () => {
expect(getRecoveryTimelineLabelEvery(15)).toBe(3);
expect(getRecoveryTimelineLabelEvery(60)).toBe(10);
});
+
+ it('renders only visible axis ticks for long ranges', () => {
+ expect(getRecoveryTimelineAxisTicks(0)).toEqual([]);
+ expect(getRecoveryTimelineAxisTicks(7)).toHaveLength(7);
+ expect(getRecoveryTimelineAxisTicks(30).map((tick) => tick.index)).toEqual([
+ 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 29,
+ ]);
+ expect(getRecoveryTimelineAxisTicks(365).map((tick) => tick.index)).toEqual([
+ 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170,
+ 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330,
+ 340, 350, 360, 364,
+ ]);
+ expect(getRecoveryTimelineAxisTicks(365).at(0)?.align).toBe('start');
+ expect(getRecoveryTimelineAxisTicks(365).at(-1)?.align).toBe('end');
+ });
});
diff --git a/frontend-modern/src/utils/recoveryTimelineChartPresentation.ts b/frontend-modern/src/utils/recoveryTimelineChartPresentation.ts
index 891b6e92af..65553f9e50 100644
--- a/frontend-modern/src/utils/recoveryTimelineChartPresentation.ts
+++ b/frontend-modern/src/utils/recoveryTimelineChartPresentation.ts
@@ -2,6 +2,12 @@ export const RECOVERY_TIMELINE_LEGEND_ITEM_CLASS = 'flex items-center gap-1';
export const RECOVERY_TIMELINE_RANGE_GROUP_CLASS =
'inline-flex rounded border border-border bg-surface p-0.5 text-xs';
+export interface RecoveryTimelineAxisTick {
+ index: number;
+ positionPct: number;
+ align: 'start' | 'center' | 'end';
+}
+
export function getRecoveryTimelineAxisLabelClass(selected: boolean): string {
return selected ? 'font-semibold text-blue-700 dark:text-blue-300' : 'text-muted';
}
@@ -13,6 +19,7 @@ export function getRecoveryTimelineBarMinWidthClass(
if (isMobile) return '';
if (days === 7) return 'min-w-[28px]';
if (days === 30) return 'min-w-[14px]';
+ if (days === 365) return '';
return 'min-w-[8px]';
}
@@ -21,3 +28,25 @@ export function getRecoveryTimelineLabelEvery(dayCount: number): number {
if (dayCount <= 30) return 3;
return 10;
}
+
+export function getRecoveryTimelineAxisTicks(dayCount: number): RecoveryTimelineAxisTick[] {
+ if (dayCount <= 0) return [];
+
+ const labelEvery = getRecoveryTimelineLabelEvery(dayCount);
+ const lastIndex = dayCount - 1;
+ const ticks: RecoveryTimelineAxisTick[] = [];
+
+ for (let index = 0; index < dayCount; index += 1) {
+ const isBoundary = index === 0 || index === lastIndex;
+ if (!isBoundary && index % labelEvery !== 0) continue;
+
+ const positionPct = dayCount === 1 ? 0 : (index / lastIndex) * 100;
+ ticks.push({
+ index,
+ positionPct,
+ align: index === 0 ? 'start' : index === lastIndex ? 'end' : 'center',
+ });
+ }
+
+ return ticks;
+}