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.

Delete cascade orphans surfaced by Cleanup L

rcourtmanb99c3a2d0d6a
diff --git a/frontend-modern/src/api/__tests__/hostedSignup.test.ts b/frontend-modern/src/api/__tests__/hostedSignup.test.ts
deleted file mode 100644
index 20c9a7a2f3..0000000000
--- a/frontend-modern/src/api/__tests__/hostedSignup.test.ts
+++ /dev/null
@@ -1,142 +0,0 @@
-import { beforeEach, describe, expect, it, vi } from 'vitest';
-import { HostedSignupAPI } from '../hostedSignup';
-import { apiClient } from '@/utils/apiClient';
-
-vi.mock('@/utils/apiClient', () => ({
- apiClient: {
- fetch: vi.fn(),
- },
-}));
-
-describe('HostedSignupAPI', () => {
- beforeEach(() => {
- vi.clearAllMocks();
- });
-
- it('submits hosted signup with public request options', async () => {
- vi.mocked(apiClient.fetch).mockResolvedValueOnce(
- new Response(
- JSON.stringify({
- message: "If that email can finish signup, you'll receive a Pulse Account sign-in link shortly.",
- }),
- { status: 202 },
- ),
- );
-
- const result = await HostedSignupAPI.signup({
- email: '[email protected]',
- org_name: 'Acme',
- tier: 'power',
- });
-
- expect(apiClient.fetch).toHaveBeenCalledWith('/api/public/signup', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- },
- body: JSON.stringify({
- email: '[email protected]',
- org_name: 'Acme',
- tier: 'power',
- }),
- skipAuth: true,
- skipOrgContext: true,
- });
- expect(result).toEqual({
- ok: true,
- status: 202,
- data: {
- message: "If that email can finish signup, you'll receive a Pulse Account sign-in link shortly.",
- },
- });
- });
-
- it('returns structured error payload on failed signup', async () => {
- vi.mocked(apiClient.fetch).mockResolvedValueOnce(
- new Response(
- JSON.stringify({
- code: ' invalid_email ',
- message: ' Invalid email format ',
- details: {
- field: 'email',
- ignored: 123,
- },
- }),
- { status: 400 },
- ),
- );
-
- const result = await HostedSignupAPI.signup({
- email: 'bad',
- org_name: 'Acme',
- tier: 'starter',
- });
-
- expect(result).toEqual({
- ok: false,
- status: 400,
- error: {
- code: 'invalid_email',
- message: 'Invalid email format',
- details: {
- field: 'email',
- },
- },
- });
- });
-
- it('fails closed when an error response body is not valid JSON', async () => {
- vi.mocked(apiClient.fetch).mockResolvedValueOnce(
- new Response('not valid json', { status: 502 }),
- );
-
- const result = await HostedSignupAPI.signup({
- email: '[email protected]',
- org_name: 'Acme',
- tier: 'starter',
- });
-
- expect(result).toEqual({
- ok: false,
- status: 502,
- error: {
- code: 'request_failed',
- message: 'Request failed (502)',
- },
- });
- });
-
- it('requests public magic link with public request options', async () => {
- vi.mocked(apiClient.fetch).mockResolvedValueOnce(
- new Response(
- JSON.stringify({
- success: true,
- message: "If that email is registered, you'll receive a magic link shortly.",
- }),
- { status: 200 },
- ),
- );
-
- const result = await HostedSignupAPI.requestMagicLink('[email protected]');
-
- expect(apiClient.fetch).toHaveBeenCalledWith('/api/public/magic-link/request', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- },
- body: JSON.stringify({ email: '[email protected]', target: 'portal' }),
- skipAuth: true,
- skipOrgContext: true,
- });
- expect(result).toEqual({
- ok: true,
- status: 200,
- data: {
- success: true,
- message: "If that email is registered, you'll receive a magic link shortly.",
- },
- });
- });
-});
diff --git a/frontend-modern/src/api/hostedSignup.ts b/frontend-modern/src/api/hostedSignup.ts
deleted file mode 100644
index bceb459dbe..0000000000
--- a/frontend-modern/src/api/hostedSignup.ts
+++ /dev/null
@@ -1,88 +0,0 @@
-import { apiClient } from '@/utils/apiClient';
-import { normalizeStructuredAPIError, parseJSONSafe } from './responseUtils';
-
-export interface HostedSignupRequest {
- email: string;
- org_name: string;
- tier?: 'starter' | 'power' | 'max';
-}
-
-export interface HostedSignupResponse {
- org_id?: string;
- user_id?: string;
- checkout_url?: string;
- message: string;
-}
-
-export interface HostedMagicLinkResponse {
- success: boolean;
- message: string;
-}
-
-export interface HostedAPIError {
- code: string;
- message: string;
- details?: Record<string, string>;
-}
-
-export type HostedAPIResult<T> =
- | { ok: true; status: number; data: T }
- | { ok: false; status: number; error: HostedAPIError };
-
-export class HostedSignupAPI {
- static async signup(
- payload: HostedSignupRequest,
- ): Promise<HostedAPIResult<HostedSignupResponse>> {
- const response = await apiClient.fetch('/api/public/signup', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- },
- body: JSON.stringify(payload),
- skipAuth: true,
- skipOrgContext: true,
- });
-
- const body = await parseJSONSafe<HostedSignupResponse | HostedAPIError>(response);
- if (response.ok) {
- return {
- ok: true,
- status: response.status,
- data: body as HostedSignupResponse,
- };
- }
- return {
- ok: false,
- status: response.status,
- error: normalizeStructuredAPIError(body, response.status),
- };
- }
-
- static async requestMagicLink(email: string): Promise<HostedAPIResult<HostedMagicLinkResponse>> {
- const response = await apiClient.fetch('/api/public/magic-link/request', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- },
- body: JSON.stringify({ email, target: 'portal' }),
- skipAuth: true,
- skipOrgContext: true,
- });
-
- const body = await parseJSONSafe<HostedMagicLinkResponse | HostedAPIError>(response);
- if (response.ok) {
- return {
- ok: true,
- status: response.status,
- data: body as HostedMagicLinkResponse,
- };
- }
- return {
- ok: false,
- status: response.status,
- error: normalizeStructuredAPIError(body, response.status),
- };
- }
-}
diff --git a/frontend-modern/src/components/PMG/ServiceHealthBadge.tsx b/frontend-modern/src/components/PMG/ServiceHealthBadge.tsx
deleted file mode 100644
index 08b719999a..0000000000
--- a/frontend-modern/src/components/PMG/ServiceHealthBadge.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-import type { Component } from 'solid-js';
-import { createMemo } from 'solid-js';
-import { getServiceHealthPresentation } from '@/utils/serviceHealthPresentation';
-
-export const ServiceHealthBadge: Component<{ status: string; health?: string }> = (props) => {
- const statusInfo = createMemo(() => getServiceHealthPresentation(props.status, props.health));
-
- return (
- <span
- class={`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[10px] font-semibold uppercase ${statusInfo().bg} ${statusInfo().text}`}
- >
- <span class={`w-1.5 h-1.5 rounded-full ${statusInfo().dot}`} />
- {statusInfo().label}
- </span>
- );
-};
-
-export default ServiceHealthBadge;
diff --git a/frontend-modern/src/components/shared/collapsibleSearchInputModel.ts b/frontend-modern/src/components/shared/collapsibleSearchInputModel.ts
deleted file mode 100644
index aea577dc78..0000000000
--- a/frontend-modern/src/components/shared/collapsibleSearchInputModel.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import type { SearchInputProps } from './SearchInput';
-
-export interface CollapsibleSearchInputProps extends Omit<SearchInputProps, 'typeToSearch'> {
- triggerLabel?: string;
- fullWidthWhenExpanded?: boolean;
-}
-
-export const getCollapsibleSearchTriggerLabel = (triggerLabel?: string) =>
- triggerLabel ?? 'Search';
-
-export const shouldShowCollapsibleSearchExpanded = (isExpanded: boolean, value: string) =>
- isExpanded || value.trim().length > 0;
-
-export const getCollapsibleSearchRootClass = (options: {
- className?: string;
- fullWidthWhenExpanded?: boolean;
- showExpanded: boolean;
-}) => {
- const baseClass = options.className ?? '';
- if (!options.fullWidthWhenExpanded) return baseClass;
- const layoutClass = options.showExpanded
- ? 'order-last basis-full w-full'
- : 'shrink-0 md:ml-auto';
- return `${baseClass} ${layoutClass}`.trim();
-};
diff --git a/frontend-modern/src/components/shared/densityMapModel.ts b/frontend-modern/src/components/shared/densityMapModel.ts
deleted file mode 100644
index ff76611a0a..0000000000
--- a/frontend-modern/src/components/shared/densityMapModel.ts
+++ /dev/null
@@ -1,358 +0,0 @@
-import type { TimeRange } from '@/api/charts';
-import { timeRangeToMs } from '@/utils/timeRange';
-import type { InteractiveSparklineSeries } from './InteractiveSparkline';
-import type { SummaryChartHoverSync } from './contextualFocus';
-import type { SummaryCardInteractionState } from './summaryCardInteraction';
-
-export interface DensityMapProps {
- series: InteractiveSparklineSeries[];
- rangeLabel?: string;
- timeRange?: TimeRange;
- formatValue?: (value: number) => string;
- focusEmptyStateLabel?: string;
- hoverSourceKey?: string;
- hoverSync?: SummaryChartHoverSync | null;
- onHoverSyncChange?: (value: SummaryChartHoverSync | null) => void;
- highlightSeriesId?: string | null;
- interactionState?: SummaryCardInteractionState;
-}
-
-export interface DensityMapHoveredState {
- columnIndex: number;
- tooltipX: number;
- tooltipY: number;
- timestamp: number;
- value: number;
- seriesName: string;
- seriesColor: string;
- seriesIndex: number;
-}
-
-export interface DensityMapFocusDetail {
- peakValue: number | null;
- seriesColor: string;
- seriesId: string;
- seriesName: string;
-}
-
-export interface DensityMapChartData {
- series: InteractiveSparklineSeries[];
- grid: number[][];
- globalMax: number;
- windowStart: number;
- rangeMs: number;
- bucketDuration: number;
-}
-
-export const DENSITY_MAP_COLUMNS = 45;
-export const DENSITY_MAP_PADDING_Y = 2;
-export const DENSITY_MAP_PADDING_X = 2;
-
-export function clampDensityMapValue(value: number, min: number, max: number): number {
- return Math.max(min, Math.min(value, max));
-}
-
-export function formatDensityMapHoverTime(timestamp: number): string {
- return new Date(timestamp).toLocaleString([], {
- month: 'short',
- day: '2-digit',
- hour: '2-digit',
- minute: '2-digit',
- hour12: false,
- });
-}
-
-export function formatDensityMapValue(
- value: number,
- formatter?: (value: number) => string,
-): string {
- return formatter ? formatter(value) : `${value.toFixed(1)}`;
-}
-
-export function buildDensityMapChartData(options: {
- series: InteractiveSparklineSeries[];
- timeRange?: TimeRange;
- now?: number;
- highlightSeriesId?: string | null;
-}): DensityMapChartData {
- const range = options.timeRange || '1h';
- const rangeMs = timeRangeToMs(range);
- const windowEnd = options.now ?? Date.now();
- const windowStart = windowEnd - rangeMs;
- const bucketDuration = rangeMs / DENSITY_MAP_COLUMNS;
-
- const activeSeries = options.series.filter(
- (series) => series.data.length > 0 || series.id === options.highlightSeriesId,
- );
- const seriesWithVolume = activeSeries.map((series) => {
- let total = 0;
- for (const point of series.data) {
- if (point.timestamp >= windowStart) total += point.value;
- }
- return { series, total };
- });
- seriesWithVolume.sort((left, right) => right.total - left.total);
-
- const topSeriesEntries = seriesWithVolume.slice(0, 20);
- const highlightedEntry = options.highlightSeriesId
- ? seriesWithVolume.find((entry) => entry.series.id === options.highlightSeriesId)
- : undefined;
-
- if (
- highlightedEntry &&
- !topSeriesEntries.some((entry) => entry.series.id === highlightedEntry.series.id)
- ) {
- if (topSeriesEntries.length >= 20) {
- topSeriesEntries[topSeriesEntries.length - 1] = highlightedEntry;
- } else {
- topSeriesEntries.push(highlightedEntry);
- }
- }
-
- const topSeries = topSeriesEntries.map((entry) => entry.series);
- let globalMax = 0;
- const grid: { sum: number; count: number; max: number }[][] = topSeries.map(() =>
- Array(DENSITY_MAP_COLUMNS)
- .fill(null)
- .map(() => ({ sum: 0, count: 0, max: 0 })),
- );
-
- for (let row = 0; row < topSeries.length; row += 1) {
- for (const point of topSeries[row].data) {
- if (point.timestamp < windowStart || point.timestamp > windowEnd) continue;
- const column = Math.floor(((point.timestamp - windowStart) / rangeMs) * DENSITY_MAP_COLUMNS);
- const clampedColumn = clampDensityMapValue(column, 0, DENSITY_MAP_COLUMNS - 1);
-
- grid[row][clampedColumn].sum += point.value;
- grid[row][clampedColumn].count += 1;
- if (point.value > grid[row][clampedColumn].max) {
- grid[row][clampedColumn].max = point.value;
- }
- if (point.value > globalMax) {
- globalMax = point.value;
- }
- }
- }
-
- const cellData = topSeries.map((_, row) =>
- grid[row].map((cell) => (cell.count > 0 ? cell.max : 0)),
- );
-
- return {
- series: topSeries,
- grid: cellData,
- globalMax,
- windowStart,
- rangeMs,
- bucketDuration,
- };
-}
-
-export function getDensityMapCellOpacity(value: number, globalMax: number): number {
- if (value <= 0 || globalMax <= 0) return 0;
- const normalized = Math.log(1 + (value / globalMax) * 99) / Math.log(100);
- return clampDensityMapValue(normalized, 0.15, 1.0);
-}
-
-export function getDensityMapExternalSeriesIndex(
- data: DensityMapChartData,
- highlightSeriesId?: string | null,
-): number | null {
- if (!highlightSeriesId) return null;
- const index = data.series.findIndex((series) => series.id === highlightSeriesId);
- return index >= 0 ? index : null;
-}
-
-export function getDensityMapColumnIndexForTimestamp(
- data: DensityMapChartData,
- timestamp: number | null | undefined,
-): number | null {
- if (timestamp === null || timestamp === undefined || data.rangeMs <= 0) {
- return null;
- }
- const clampedTimestamp = clampDensityMapValue(
- timestamp,
- data.windowStart,
- data.windowStart + data.rangeMs,
- );
- return clampDensityMapValue(
- Math.floor(((clampedTimestamp - data.windowStart) / data.rangeMs) * DENSITY_MAP_COLUMNS),
- 0,
- DENSITY_MAP_COLUMNS - 1,
- );
-}
-
-export function buildDensityMapHoveredState(options: {
- clientX: number;
- clientY: number;
- rect: DOMRect;
- data: DensityMapChartData;
-}): DensityMapHoveredState | null {
- const { rect, data } = options;
- if (data.series.length === 0) return null;
-
- const mouseX = clampDensityMapValue(options.clientX - rect.left, 0, rect.width - 1);
- const mouseY = clampDensityMapValue(options.clientY - rect.top, 0, rect.height - 1);
- const column = Math.floor((mouseX / rect.width) * DENSITY_MAP_COLUMNS);
- const row = Math.floor((mouseY / rect.height) * data.series.length);
-
- if (row < 0 || row >= data.series.length || column < 0 || column >= DENSITY_MAP_COLUMNS) {
- return null;
- }
-
- const cellWidth = rect.width / DENSITY_MAP_COLUMNS;
- const cellHeight = rect.height / data.series.length;
-
- return {
- columnIndex: column,
- tooltipX: rect.left + column * cellWidth + cellWidth / 2,
- tooltipY: rect.top + row * cellHeight,
- timestamp: data.windowStart + column * data.bucketDuration,
- value: data.grid[row][column],
- seriesName: data.series[row].name || 'Unknown',
- seriesColor: data.series[row].color,
- seriesIndex: row,
- };
-}
-
-export function buildDensityMapSynchronizedHoveredState(options: {
- data: DensityMapChartData;
- hoverSync?: SummaryChartHoverSync | null;
-}): DensityMapHoveredState | null {
- const { data, hoverSync } = options;
- if (!hoverSync || data.series.length === 0 || data.rangeMs <= 0) {
- return null;
- }
-
- const seriesIndex = data.series.findIndex((series) => series.id === hoverSync.seriesId);
- if (seriesIndex < 0) {
- return null;
- }
-
- const clampedTimestamp = clampDensityMapValue(
- hoverSync.timestamp,
- data.windowStart,
- data.windowStart + data.rangeMs,
- );
- const column = clampDensityMapValue(
- Math.floor(((clampedTimestamp - data.windowStart) / data.rangeMs) * DENSITY_MAP_COLUMNS),
- 0,
- DENSITY_MAP_COLUMNS - 1,
- );
-
- return {
- columnIndex: column,
- tooltipX: 0,
- tooltipY: 0,
- timestamp: clampedTimestamp,
- value: data.grid[seriesIndex][column],
- seriesName: data.series[seriesIndex].name || 'Unknown',
- seriesColor: data.series[seriesIndex].color,
- seriesIndex,
- };
-}
-
-export function buildDensityMapSynchronizedReadout(options: {
- emptyValue?: string;
- formatValue?: (value: number) => string;
- hoverSourceKey?: string;
- hoverSync?: SummaryChartHoverSync | null;
- series: InteractiveSparklineSeries[];
- timeRange?: TimeRange;
-}): { empty?: boolean; timestamp: number; value: string } | null {
- const { hoverSync } = options;
- if (!hoverSync) {
- return null;
- }
- if (options.hoverSourceKey && hoverSync.sourceKey === options.hoverSourceKey) {
- return null;
- }
-
- const targetSeries = options.series.find((series) => series.id?.trim() === hoverSync.seriesId);
- if (!targetSeries) {
- return null;
- }
-
- const range = options.timeRange ?? '1h';
- const rangeMs = timeRangeToMs(range);
- const windowEnd = Date.now();
- const windowStart = windowEnd - rangeMs;
- const clampedTimestamp = clampDensityMapValue(hoverSync.timestamp, windowStart, windowEnd);
- const bucketDuration = rangeMs / DENSITY_MAP_COLUMNS;
- const bucketIndex = clampDensityMapValue(
- Math.floor(((clampedTimestamp - windowStart) / rangeMs) * DENSITY_MAP_COLUMNS),
- 0,
- DENSITY_MAP_COLUMNS - 1,
- );
- const bucketStart = windowStart + bucketIndex * bucketDuration;
- const bucketEnd = bucketStart + bucketDuration;
-
- let bucketMax: number | null = null;
- for (const point of targetSeries.data) {
- if (point.timestamp < windowStart || point.timestamp > windowEnd) {
- continue;
- }
- const inBucket =
- point.timestamp >= bucketStart &&
- (bucketIndex === DENSITY_MAP_COLUMNS - 1
- ? point.timestamp <= bucketEnd
- : point.timestamp < bucketEnd);
- if (!inBucket) {
- continue;
- }
- bucketMax = bucketMax === null ? point.value : Math.max(bucketMax, point.value);
- }
-
- if (bucketMax === null) {
- return {
- empty: true,
- timestamp: clampedTimestamp,
- value: options.emptyValue ?? 'No sample',
- };
- }
-
- return {
- timestamp: clampedTimestamp,
- value: formatDensityMapValue(bucketMax, options.formatValue),
- };
-}
-
-export function buildDensityMapFocusDetail(options: {
- activeHoveredState?: DensityMapHoveredState | null;
- data: DensityMapChartData;
- highlightSeriesId?: string | null;
-}): DensityMapFocusDetail | null {
- const activeHoveredState = options.activeHoveredState ?? null;
- const seriesIndex =
- activeHoveredState?.seriesIndex ??
- getDensityMapExternalSeriesIndex(options.data, options.highlightSeriesId);
- if (seriesIndex === null || seriesIndex < 0 || seriesIndex >= options.data.series.length) {
- return null;
- }
-
- const series = options.data.series[seriesIndex];
- const seriesId = series.id?.trim() || '';
- if (!seriesId) {
- return null;
- }
-
- const windowEnd = options.data.windowStart + options.data.rangeMs;
- const points = series.data.filter(
- (point) => point.timestamp >= options.data.windowStart && point.timestamp <= windowEnd,
- );
- let peakValue: number | null = null;
- for (const point of points) {
- peakValue = peakValue === null ? point.value : Math.max(peakValue, point.value);
- }
-
- return {
- peakValue,
- seriesColor: series.color,
- seriesId,
- seriesName: series.name || 'Unknown',
- };
-}
-
-export function hasDensityMapFocusActivity(detail: DensityMapFocusDetail): boolean {
- return detail.peakValue !== null;
-}
diff --git a/frontend-modern/src/components/shared/scrollToTopButtonModel.ts b/frontend-modern/src/components/shared/scrollToTopButtonModel.ts
deleted file mode 100644
index 50da08d9aa..0000000000
--- a/frontend-modern/src/components/shared/scrollToTopButtonModel.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-export const SCROLL_TO_TOP_BUTTON_THRESHOLD = 400;
-export const SCROLL_TO_TOP_BUTTON_ARIA_LABEL = 'Scroll to top';
-export const SCROLL_TO_TOP_BUTTON_BASE_CLASS =
- 'fixed bottom-6 right-6 z-30 flex h-9 w-9 items-center justify-center rounded-full bg-surface text-base-content shadow-sm transition-all duration-200 hover:bg-surface-hover border border-border md:bottom-6 bottom-20';
-export const SCROLL_TO_TOP_BUTTON_VISIBLE_CLASS = 'opacity-100 translate-y-0';
-export const SCROLL_TO_TOP_BUTTON_HIDDEN_CLASS = 'opacity-0 translate-y-2 pointer-events-none';
-
-export function findNearestScrollableAncestor(
- sentinel: HTMLElement | undefined,
- getStyle: (element: Element) => CSSStyleDeclaration = getComputedStyle,
-): HTMLElement | null {
- let element: HTMLElement | null = sentinel ?? null;
- while (element) {
- const { overflowY } = getStyle(element);
- if ((overflowY === 'auto' || overflowY === 'scroll') && element.scrollHeight > element.clientHeight) {
- return element;
- }
- element = element.parentElement;
- }
- return null;
-}
-
-export function isScrollToTopButtonVisible(scrollTop: number): boolean {
- return scrollTop > SCROLL_TO_TOP_BUTTON_THRESHOLD;
-}
-
-export function getScrollToTopButtonClass(visible: boolean): string {
- return `${SCROLL_TO_TOP_BUTTON_BASE_CLASS} ${
- visible ? SCROLL_TO_TOP_BUTTON_VISIBLE_CLASS : SCROLL_TO_TOP_BUTTON_HIDDEN_CLASS
- }`;
-}
diff --git a/frontend-modern/src/features/storageBackups/__tests__/diskLiveMetricPresentation.test.ts b/frontend-modern/src/features/storageBackups/__tests__/diskLiveMetricPresentation.test.ts
deleted file mode 100644
index f3782f5dde..0000000000
--- a/frontend-modern/src/features/storageBackups/__tests__/diskLiveMetricPresentation.test.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import { describe, expect, it } from 'vitest';
-import {
- getDiskLiveMetricFormattedValue,
- getDiskLiveMetricTextClass,
-} from '@/features/storageBackups/diskLiveMetricPresentation';
-
-describe('diskLiveMetricPresentation', () => {
- it('returns canonical ioTime urgency classes', () => {
- expect(getDiskLiveMetricTextClass(95, 'ioTime')).toBe(
- 'text-red-600 dark:text-red-400 font-bold',
- );
- expect(getDiskLiveMetricTextClass(60, 'ioTime')).toBe(
- 'text-yellow-600 dark:text-yellow-400 font-semibold',
- );
- expect(getDiskLiveMetricTextClass(20, 'ioTime')).toBe('text-muted');
- });
-
- it('returns canonical throughput classes', () => {
- expect(getDiskLiveMetricTextClass(120 * 1024 * 1024, 'read')).toBe(
- 'text-blue-600 dark:text-blue-400 font-semibold',
- );
- expect(getDiskLiveMetricTextClass(1024, 'write')).toBe('text-muted');
- });
-
- it('formats canonical live metric values', () => {
- expect(getDiskLiveMetricFormattedValue(72, 'ioTime')).toBe('72%');
- expect(getDiskLiveMetricFormattedValue(1024, 'read')).toBe('1.00 KB/s');
- });
-});
diff --git a/frontend-modern/src/features/storageBackups/__tests__/zfsHealthMapPresentation.test.ts b/frontend-modern/src/features/storageBackups/__tests__/zfsHealthMapPresentation.test.ts
deleted file mode 100644
index 2a943f15e7..0000000000
--- a/frontend-modern/src/features/storageBackups/__tests__/zfsHealthMapPresentation.test.ts
+++ /dev/null
@@ -1,69 +0,0 @@
-import { describe, expect, it } from 'vitest';
-import {
- getZfsHealthMapDeviceClass,
- getZfsHealthMapErrorSummaryClass,
- getZfsHealthMapMessageClass,
- getZfsHealthMapTooltipStyle,
- getZfsHealthMapDevices,
- getZfsHealthMapTooltipPresentation,
- ZFS_HEALTH_MAP_ROOT_CLASS,
- ZFS_HEALTH_MAP_TOOLTIP_CARD_CLASS,
- ZFS_HEALTH_MAP_TOOLTIP_NAME_CLASS,
- ZFS_HEALTH_MAP_TOOLTIP_PORTAL_CLASS,
- ZFS_HEALTH_MAP_TOOLTIP_STATE_ROW_CLASS,
- ZFS_HEALTH_MAP_TOOLTIP_STATE_TEXT_CLASS,
- ZFS_HEALTH_MAP_TOOLTIP_TRANSFORM,
- ZFS_HEALTH_MAP_TOOLTIP_TYPE_CLASS,
- isZfsHealthMapDeviceResilvering,
-} from '@/features/storageBackups/zfsHealthMapPresentation';
-import type { ZFSPool } from '@/types/api';
-
-const pool = {
- scan: 'resilver in progress',
- devices: [
- {
- name: 'sda',
- type: 'disk',
- state: 'ONLINE',
- message: '',
- readErrors: 1,
- writeErrors: 2,
- checksumErrors: 3,
- },
- ],
-} as unknown as ZFSPool;
-
-describe('zfsHealthMapPresentation', () => {
- it('builds canonical zfs device and tooltip state', () => {
- expect(ZFS_HEALTH_MAP_ROOT_CLASS).toBe('flex items-center gap-0.5');
- expect(ZFS_HEALTH_MAP_TOOLTIP_PORTAL_CLASS).toContain('z-[9999]');
- expect(ZFS_HEALTH_MAP_TOOLTIP_CARD_CLASS).toContain('border-border');
- expect(ZFS_HEALTH_MAP_TOOLTIP_NAME_CLASS).toContain('font-medium');
- expect(ZFS_HEALTH_MAP_TOOLTIP_TYPE_CLASS).toContain('text-muted');
- expect(ZFS_HEALTH_MAP_TOOLTIP_STATE_ROW_CLASS).toContain('border-t');
- expect(ZFS_HEALTH_MAP_TOOLTIP_STATE_TEXT_CLASS).toBe('font-semibold');
- expect(ZFS_HEALTH_MAP_TOOLTIP_TRANSFORM).toBe('translate(-50%, -100%)');
-
- const [device] = getZfsHealthMapDevices(pool);
- expect(device.name).toBe('sda');
- expect(isZfsHealthMapDeviceResilvering(pool, device)).toBe(true);
- expect(getZfsHealthMapTooltipPresentation(device)).toEqual({
- name: 'sda',
- type: 'disk',
- state: 'ONLINE',
- message: '',
- errorSummary: 'E: 1/2/3',
- hasErrors: true,
- });
- expect(getZfsHealthMapDeviceClass('bg-green-500', true)).toBe(
- 'w-2.5 h-3 rounded-sm transition-colors duration-200 bg-green-500 animate-pulse',
- );
- expect(getZfsHealthMapTooltipStyle(10, 20)).toEqual({
- left: '10px',
- top: '12px',
- transform: 'translate(-50%, -100%)',
- });
- expect(getZfsHealthMapErrorSummaryClass()).toBe('text-red-400');
- expect(getZfsHealthMapMessageClass()).toBe('text-muted mt-1 italic max-w-[200px] break-words');
- });
-});
diff --git a/frontend-modern/src/features/storageBackups/diskLiveMetricPresentation.ts b/frontend-modern/src/features/storageBackups/diskLiveMetricPresentation.ts
deleted file mode 100644
index b48902a745..0000000000
--- a/frontend-modern/src/features/storageBackups/diskLiveMetricPresentation.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { formatBytes } from '@/utils/format';
-
-export type DiskLiveMetricType = 'read' | 'write' | 'ioTime';
-
-export const getDiskLiveMetricTextClass = (
- value: number,
- type: DiskLiveMetricType,
-): string => {
- if (type === 'ioTime') {
- if (value > 90) return 'text-red-600 dark:text-red-400 font-bold';
- if (value > 50) return 'text-yellow-600 dark:text-yellow-400 font-semibold';
- return 'text-muted';
- }
-
- if (value > 100 * 1024 * 1024) {
- return 'text-blue-600 dark:text-blue-400 font-semibold';
- }
-
- return 'text-muted';
-};
-
-export const getDiskLiveMetricFormattedValue = (
- value: number,
- type: DiskLiveMetricType,
-): string => {
- if (type === 'ioTime') return `${Math.round(value)}%`;
- return `${formatBytes(value)}/s`;
-};
diff --git a/frontend-modern/src/features/storageBackups/zfsHealthMapPresentation.ts b/frontend-modern/src/features/storageBackups/zfsHealthMapPresentation.ts
deleted file mode 100644
index 2aeec2ee3a..0000000000
--- a/frontend-modern/src/features/storageBackups/zfsHealthMapPresentation.ts
+++ /dev/null
@@ -1,65 +0,0 @@
-import type { ZFSDevice, ZFSPool } from '@/types/api';
-
-export type ZfsHealthMapTooltipPresentation = {
- name: string;
- type: string;
- state: string;
- message: string;
- errorSummary: string;
- hasErrors: boolean;
-};
-
-export const ZFS_HEALTH_MAP_ROOT_CLASS = 'flex items-center gap-0.5';
-export const ZFS_HEALTH_MAP_TOOLTIP_PORTAL_CLASS = 'fixed z-[9999] pointer-events-none';
-export const ZFS_HEALTH_MAP_TOOLTIP_CARD_CLASS =
- 'bg-surface text-base-content text-[10px] rounded-md shadow-sm px-2 py-1.5 min-w-[120px] border border-border';
-export const ZFS_HEALTH_MAP_TOOLTIP_NAME_CLASS = 'font-medium mb-0.5 text-base-content';
-export const ZFS_HEALTH_MAP_TOOLTIP_TYPE_CLASS = 'text-muted mb-1';
-export const ZFS_HEALTH_MAP_TOOLTIP_STATE_ROW_CLASS = 'flex items-center gap-2 border-t border-border pt-1';
-export const ZFS_HEALTH_MAP_TOOLTIP_STATE_TEXT_CLASS = 'font-semibold';
-export const ZFS_HEALTH_MAP_TOOLTIP_TRANSFORM = 'translate(-50%, -100%)';
-
-export const getZfsHealthMapDevices = (pool: ZFSPool): ZFSDevice[] => pool.devices || [];
-
-export const getZfsHealthMapDeviceClass = (
- baseClass: string,
- resilvering: boolean,
-): string =>
- `w-2.5 h-3 rounded-sm transition-colors duration-200 ${baseClass} ${resilvering ? 'animate-pulse' : ''}`;
-
-export const getZfsHealthMapErrorSummaryClass = (): string => 'text-red-400';
-
-export const getZfsHealthMapMessageClass = (): string =>
- 'text-muted mt-1 italic max-w-[200px] break-words';
-
-export const getZfsHealthMapTooltipStyle = (x: number, y: number) => ({
- left: `${x}px`,
- top: `${y - 8}px`,
- transform: ZFS_HEALTH_MAP_TOOLTIP_TRANSFORM,
-});
-
-export const isZfsHealthMapDeviceResilvering = (
- pool: ZFSPool,
- device: ZFSDevice,
-): boolean => {
- const scan = pool.scan?.toLowerCase() || '';
- return scan.includes('resilver') || (device.message || '').toLowerCase().includes('resilver');
-};
-
-export const getZfsHealthMapTooltipPresentation = (
- device: ZFSDevice,
-): ZfsHealthMapTooltipPresentation => {
- const readErrors = device.readErrors || 0;
- const writeErrors = device.writeErrors || 0;
- const checksumErrors = device.checksumErrors || 0;
- const hasErrors = readErrors > 0 || writeErrors > 0 || checksumErrors > 0;
-
- return {
- name: device.name,
- type: device.type,
- state: device.state,
- message: device.message || '',
- errorSummary: hasErrors ? `E: ${readErrors}/${writeErrors}/${checksumErrors}` : '',
- hasErrors,
- };
-};
diff --git a/frontend-modern/src/hooks/__tests__/useDeployStream.test.ts b/frontend-modern/src/hooks/__tests__/useDeployStream.test.ts
deleted file mode 100644
index 52e617e291..0000000000
--- a/frontend-modern/src/hooks/__tests__/useDeployStream.test.ts
+++ /dev/null
@@ -1,426 +0,0 @@
-import { createRoot, createSignal } from 'solid-js';
-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
-
-const { loggerMock } = vi.hoisted(() => ({
- loggerMock: {
- info: vi.fn(),
- warn: vi.fn(),
- },
-}));
-vi.mock('@/utils/logger', () => ({ logger: loggerMock }));
-
-import { useDeployStream, type DeployStreamState } from '@/hooks/useDeployStream';
-
-class MockEventSource {
- static instances: MockEventSource[] = [];
-
- readonly url: string;
- onopen: ((event: Event) => void) | null = null;
- onmessage: ((event: MessageEvent) => void) | null = null;
- onerror: ((event: Event) => void) | null = null;
- readyState = 0;
- withCredentials = false;
- closed = false;
-
- constructor(url: string) {
- this.url = url;
- MockEventSource.instances.push(this);
- }
-
- close() {
- this.closed = true;
- this.readyState = 2;
- }
-
- emitOpen() {
- this.readyState = 1;
- this.onopen?.(new Event('open'));
- }
-
- emitMessage(payload: unknown, lastEventId = '') {
- const evt = { data: JSON.stringify(payload), lastEventId } as MessageEvent;
- this.onmessage?.(evt);
- }
-
- emitRawMessage(data: unknown, lastEventId = '') {
- const evt = { data, lastEventId } as MessageEvent;
- this.onmessage?.(evt);
- }
-
- emitError() {
- this.onerror?.(new Event('error'));
- }
-}
-
-describe('useDeployStream', () => {
- const originalEventSource = globalThis.EventSource;
-
- beforeEach(() => {
- vi.useFakeTimers();
- vi.clearAllMocks();
- MockEventSource.instances = [];
- (globalThis as unknown as { EventSource: typeof EventSource }).EventSource =
- MockEventSource as unknown as typeof EventSource;
- });
-
- afterEach(() => {
- vi.useRealTimers();
- (globalThis as unknown as { EventSource: typeof EventSource }).EventSource =
- originalEventSource;
- });
-
- it('opens SSE connection when eventsUrl is non-null', () => {
- let dispose!: () => void;
- createRoot((d) => {
- dispose = d;
- const [url] = createSignal<string | null>('/api/events');
- useDeployStream({ eventsUrl: url });
- });
-
- expect(MockEventSource.instances).toHaveLength(1);
- expect(MockEventSource.instances[0].url).toBe('/api/events');
-
- dispose();
- });
-
- it('does not open connection when eventsUrl is null', () => {
- let dispose!: () => void;
- createRoot((d) => {
- dispose = d;
- const [url] = createSignal<string | null>(null);
- useDeployStream({ eventsUrl: url });
- });
-
- expect(MockEventSource.instances).toHaveLength(0);
-
- dispose();
- });
-
- it('sets isStreaming to true on open', () => {
- let dispose!: () => void;
- let state!: DeployStreamState;
- createRoot((d) => {
- dispose = d;
- const [url] = createSignal<string | null>('/api/events');
- state = useDeployStream({ eventsUrl: url });
- });
-
- expect(state.isStreaming()).toBe(false);
- MockEventSource.instances[0].emitOpen();
- expect(state.isStreaming()).toBe(true);
-
- dispose();
- });
-
- it('appends events and calls onEvent callback', () => {
- const onEvent = vi.fn();
- let dispose!: () => void;
- let state!: DeployStreamState;
- createRoot((d) => {
- dispose = d;
- const [url] = createSignal<string | null>('/api/events');
- state = useDeployStream({ eventsUrl: url, onEvent });
- });
-
- const es = MockEventSource.instances[0];
- es.emitOpen();
- es.emitMessage({ id: 'e1', type: 'preflight_result', targetId: 't1', message: 'ok' });
-
- expect(state.events()).toHaveLength(1);
- expect(state.events()[0].id).toBe('e1');
- expect(onEvent).toHaveBeenCalledTimes(1);
- expect(onEvent).toHaveBeenCalledWith(expect.objectContaining({ id: 'e1' }));
-
- dispose();
- });
-
- it('deduplicates events by ID', () => {
- let dispose!: () => void;
- let state!: DeployStreamState;
- createRoot((d) => {
- dispose = d;
- const [url] = createSignal<string | null>('/api/events');
- state = useDeployStream({ eventsUrl: url });
- });
-
- const es = MockEventSource.instances[0];
- es.emitOpen();
- es.emitMessage({ id: 'e1', type: 'preflight_result', message: 'first' });
- es.emitMessage({ id: 'e1', type: 'preflight_result', message: 'duplicate' });
- es.emitMessage({ id: 'e2', type: 'install_output', message: 'second' });
-
- expect(state.events()).toHaveLength(2);
- expect(state.events()[0].id).toBe('e1');
- expect(state.events()[1].id).toBe('e2');
-
- dispose();
- });
-
- it('calls onComplete and closes on job_complete event', () => {
- const onComplete = vi.fn();
- let dispose!: () => void;
- let state!: DeployStreamState;
- createRoot((d) => {
- dispose = d;
- const [url] = createSignal<string | null>('/api/events');
- state = useDeployStream({ eventsUrl: url, onComplete });
- });
-
- const es = MockEventSource.instances[0];
- es.emitOpen();
- es.emitMessage({ type: 'job_complete', status: 'succeeded' });
-
- expect(onComplete).toHaveBeenCalledWith('succeeded');
- expect(es.closed).toBe(true);
- expect(state.isStreaming()).toBe(false);
-
- dispose();
- });
-
- it('calls onComplete with "unknown" when job_complete has no status', () => {
- const onComplete = vi.fn();
- let dispose!: () => void;
- createRoot((d) => {
- dispose = d;
- const [url] = createSignal<string | null>('/api/events');
- useDeployStream({ eventsUrl: url, onComplete });
- });
-
- const es = MockEventSource.instances[0];
- es.emitOpen();
- es.emitMessage({ type: 'job_complete' });
-
- expect(onComplete).toHaveBeenCalledWith('unknown');
-
- dispose();
- });
-
- it('reconnects with exponential backoff on error', () => {
- let dispose!: () => void;
- createRoot((d) => {
- dispose = d;
- const [url] = createSignal<string | null>('/api/events');
- useDeployStream({ eventsUrl: url });
- });
-
- expect(MockEventSource.instances).toHaveLength(1);
-
- // Error → reconnect after 1s
- MockEventSource.instances[0].emitError();
- vi.advanceTimersByTime(1000);
- expect(MockEventSource.instances).toHaveLength(2);
-
- // Error → reconnect after 2s
- MockEventSource.instances[1].emitError();
- vi.advanceTimersByTime(2000);
- expect(MockEventSource.instances).toHaveLength(3);
-
- // Error → reconnect after 4s
- MockEventSource.instances[2].emitError();
- vi.advanceTimersByTime(4000);
- expect(MockEventSource.instances).toHaveLength(4);
-
- dispose();
- });
-
- it('stops reconnecting after max attempts and calls onError', () => {
- const onError = vi.fn();
- let dispose!: () => void;
- createRoot((d) => {
- dispose = d;
- const [url] = createSignal<string | null>('/api/events');
- useDeployStream({ eventsUrl: url, onError });
- });
-
- const backoffMs = [1000, 2000, 4000, 8000, 15000];
- for (const delay of backoffMs) {
- const current = MockEventSource.instances[MockEventSource.instances.length - 1];
- current.emitError();
- vi.advanceTimersByTime(delay);
- }
-
- expect(MockEventSource.instances).toHaveLength(6); // initial + 5 reconnects
-
- // 6th error exceeds max
- MockEventSource.instances[5].emitError();
- vi.advanceTimersByTime(60000);
-
- expect(onError).toHaveBeenCalledTimes(1);
- expect(onError).toHaveBeenCalledWith('Connection lost after max retries');
- expect(MockEventSource.instances).toHaveLength(6);
-
- dispose();
- });
-
- it('resets reconnect counter on successful connection', () => {
- let dispose!: () => void;
- createRoot((d) => {
- dispose = d;
- const [url] = createSignal<string | null>('/api/events');
- useDeployStream({ eventsUrl: url });
- });
-
- // Fail twice
- MockEventSource.instances[0].emitError();
- vi.advanceTimersByTime(1000);
- MockEventSource.instances[1].emitError();
- vi.advanceTimersByTime(2000);
-
- // Succeed — resets counter
- MockEventSource.instances[2].emitOpen();
-
- // Error again — should use 1s delay (reset), not 4s
- MockEventSource.instances[2].emitError();
- vi.advanceTimersByTime(1000);
- expect(MockEventSource.instances).toHaveLength(4);
-
- dispose();
- });
-
- it('closes connection when eventsUrl changes to null', () => {
- let dispose!: () => void;
- let setUrl!: (url: string | null) => void;
- createRoot((d) => {
- dispose = d;
- const [url, _setUrl] = createSignal<string | null>('/api/events');
- setUrl = _setUrl;
- useDeployStream({ eventsUrl: url });
- });
-
- const es = MockEventSource.instances[0];
- es.emitOpen();
- expect(es.closed).toBe(false);
-
- setUrl(null);
- expect(es.closed).toBe(true);
-
- dispose();
- });
-
- it('opens new connection when eventsUrl changes to a new value', () => {
- let dispose!: () => void;
- let setUrl!: (url: string | null) => void;
- let state!: DeployStreamState;
- createRoot((d) => {
- dispose = d;
- const [url, _setUrl] = createSignal<string | null>('/api/events/1');
- setUrl = _setUrl;
- state = useDeployStream({ eventsUrl: url });
- });
-
- const first = MockEventSource.instances[0];
- first.emitOpen();
- first.emitMessage({ id: 'e1', type: 'preflight_result', message: 'msg' });
- expect(state.events()).toHaveLength(1);
-
- // Change URL — should close old, open new, reset events
- setUrl('/api/events/2');
- expect(first.closed).toBe(true);
- expect(MockEventSource.instances).toHaveLength(2);
- expect(MockEventSource.instances[1].url).toBe('/api/events/2');
- expect(state.events()).toHaveLength(0); // reset on new URL
-
- dispose();
- });
-
- it('drops oversized SSE payloads', () => {
- let dispose!: () => void;
- let state!: DeployStreamState;
- createRoot((d) => {
- dispose = d;
- const [url] = createSignal<string | null>('/api/events');
- state = useDeployStream({ eventsUrl: url });
- });
-
- const es = MockEventSource.instances[0];
- es.emitOpen();
-
- // Normal event
- es.emitMessage({ id: 'e1', type: 'preflight_result', message: 'ok' });
- expect(state.events()).toHaveLength(1);
-
- // Oversized event (>64KB)
- es.emitRawMessage('x'.repeat(65 * 1024));
- expect(state.events()).toHaveLength(1); // not added
- expect(loggerMock.warn).toHaveBeenCalledWith('[DeployStream] Dropping oversized SSE event');
-
- dispose();
- });
-
- it('ignores non-string SSE data', () => {
- let dispose!: () => void;
- let state!: DeployStreamState;
- createRoot((d) => {
- dispose = d;
- const [url] = createSignal<string | null>('/api/events');
- state = useDeployStream({ eventsUrl: url });
- });
-
- const es = MockEventSource.instances[0];
- es.emitOpen();
- es.emitRawMessage(42);
-
- expect(state.events()).toHaveLength(0);
-
- dispose();
- });
-
- it('ignores unparseable JSON', () => {
- let dispose!: () => void;
- let state!: DeployStreamState;
- createRoot((d) => {
- dispose = d;
- const [url] = createSignal<string | null>('/api/events');
- state = useDeployStream({ eventsUrl: url });
- });
-
- const es = MockEventSource.instances[0];
- es.emitOpen();
- es.emitRawMessage('not-valid-json');
-
- expect(state.events()).toHaveLength(0);
- expect(loggerMock.warn).toHaveBeenCalledWith('[DeployStream] Failed to parse SSE event');
-
- dispose();
- });
-
- it('cleans up on disposal', () => {
- let dispose!: () => void;
- createRoot((d) => {
- dispose = d;
- const [url] = createSignal<string | null>('/api/events');
- useDeployStream({ eventsUrl: url });
- });
-
- const es = MockEventSource.instances[0];
- es.emitOpen();
- expect(es.closed).toBe(false);
-
- dispose();
- expect(es.closed).toBe(true);
- });
-
- it('does not reconnect after intentional close', () => {
- let dispose!: () => void;
- let setUrl!: (url: string | null) => void;
- createRoot((d) => {
- dispose = d;
- const [url, _setUrl] = createSignal<string | null>('/api/events');
- setUrl = _setUrl;
- useDeployStream({ eventsUrl: url });
- });
-
- const es = MockEventSource.instances[0];
- es.emitOpen();
-
- // Close intentionally by setting url to null
- setUrl(null);
- expect(es.closed).toBe(true);
-
- // No reconnect should happen
- vi.advanceTimersByTime(60000);
- expect(MockEventSource.instances).toHaveLength(1);
-
- dispose();
- });
-});
diff --git a/frontend-modern/src/hooks/useDeployStream.ts b/frontend-modern/src/hooks/useDeployStream.ts
deleted file mode 100644
index 5ddcde4579..0000000000
--- a/frontend-modern/src/hooks/useDeployStream.ts
+++ /dev/null
@@ -1,208 +0,0 @@
-/**
- * SolidJS hook for consuming live deploy/preflight SSE events.
- *
- * Opens an EventSource when `eventsUrl()` is non-null, closes when null or on
- * component cleanup. Deduplicates events by ID (backend replays on reconnect).
- * Reconnects with exponential backoff: 1s -> 2s -> 4s -> 8s -> 15s, max 5 attempts.
- * Detects `job_complete` event type as terminal signal.
- */
-
-import { createSignal, createEffect, onCleanup, type Accessor } from 'solid-js';
-import type { DeployEvent } from '@/types/agentDeploy';
-import { logger } from '@/utils/logger';
-
-export interface UseDeployStreamOptions {
- /** Reactive URL — null = closed, string = open SSE connection. */
- eventsUrl: Accessor<string | null>;
- /** Called for each incoming deploy event. */
- onEvent?: (event: DeployEvent) => void;
- /** Called when a `job_complete` event is received, with the final job status. */
- onComplete?: (status: string) => void;
- /** Called on connection failure after max reconnect attempts. */
- onError?: (message: string) => void;
-}
-
-export interface DeployStreamState {
- isStreaming: Accessor<boolean>;
- events: Accessor<DeployEvent[]>;
- lastError: Accessor<string>;
-}
-
-const MAX_RECONNECT_ATTEMPTS = 5;
-const INITIAL_RECONNECT_DELAY_MS = 1000;
-const MAX_RECONNECT_DELAY_MS = 15000;
-const MAX_SSE_EVENT_DATA_CHARS = 64 * 1024;
-
-export function useDeployStream(opts: UseDeployStreamOptions): DeployStreamState {
- const [isStreaming, setIsStreaming] = createSignal(false);
- const [events, setEvents] = createSignal<DeployEvent[]>([]);
- const [lastError, setLastError] = createSignal('');
-
- // Track seen event IDs to deduplicate replays on reconnect.
- const seenIds = new Set<string>();
-
- let es: EventSource | undefined;
- let reconnectTimer: ReturnType<typeof setTimeout> | undefined;
- let reconnectAttempts = 0;
- let intentionalClose = false;
- let previousUrl: string | null = null;
-
- function disposeSource(source: EventSource | undefined) {
- if (!source) return;
- source.onopen = null;
- source.onmessage = null;
- source.onerror = null;
- source.close();
- }
-
- function clearReconnectTimer() {
- if (reconnectTimer !== undefined) {
- clearTimeout(reconnectTimer);
- reconnectTimer = undefined;
- }
- }
-
- function close() {
- intentionalClose = true;
- clearReconnectTimer();
- if (es) {
- disposeSource(es);
- es = undefined;
- }
- setIsStreaming(false);
- }
-
- function reset() {
- close();
- seenIds.clear();
- setEvents([]);
- setLastError('');
- reconnectAttempts = 0;
- intentionalClose = false;
- }
-
- function scheduleReconnect(url: string) {
- if (intentionalClose || !opts.eventsUrl()) return;
- if (reconnectAttempts >= MAX_RECONNECT_ATTEMPTS) {
- logger.warn(`[DeployStream] Max reconnect attempts (${MAX_RECONNECT_ATTEMPTS}) reached`);
- setLastError('Connection lost after max retries');
- opts.onError?.('Connection lost after max retries');
- return;
- }
- const delay = Math.min(
- INITIAL_RECONNECT_DELAY_MS * Math.pow(2, reconnectAttempts),
- MAX_RECONNECT_DELAY_MS,
- );
- reconnectAttempts++;
- logger.info(
- `[DeployStream] Reconnecting in ${delay}ms (attempt ${reconnectAttempts}/${MAX_RECONNECT_ATTEMPTS})`,
- );
- clearReconnectTimer();
- reconnectTimer = setTimeout(() => {
- if (opts.eventsUrl()) {
- open(url);
- }
- }, delay);
- }
-
- function open(url: string) {
- clearReconnectTimer();
- if (es) {
- disposeSource(es);
- es = undefined;
- }
- setIsStreaming(false);
- intentionalClose = false;
-
- try {
- const source = new EventSource(url);
- es = source;
-
- source.onopen = () => {
- if (es !== source) return;
- logger.info('[DeployStream] SSE connected');
- setIsStreaming(true);
- reconnectAttempts = 0;
- };
-
- source.onmessage = (msg) => {
- if (es !== source) return;
- try {
- const rawData = msg.data;
- if (typeof rawData !== 'string') return;
- if (rawData.length > MAX_SSE_EVENT_DATA_CHARS) {
- logger.warn('[DeployStream] Dropping oversized SSE event');
- return;
- }
-
- const parsed = JSON.parse(rawData) as unknown;
- if (!parsed || typeof parsed !== 'object') return;
-
- const event = parsed as DeployEvent;
-
- // Detect terminal `job_complete` event (synthetic from SSE handler).
- if (event.type === 'job_complete') {
- const status = (parsed as { status?: string }).status as string;
- close();
- opts.onComplete?.(status || 'unknown');
- return;
- }
-
- // Deduplicate by event ID.
- if (event.id && seenIds.has(event.id)) return;
- if (event.id) seenIds.add(event.id);
-
- setEvents((prev) => [...prev, event]);
- opts.onEvent?.(event);
- } catch {
- logger.warn('[DeployStream] Failed to parse SSE event');
- }
- };
-
- source.onerror = () => {
- if (es !== source) return;
- logger.warn('[DeployStream] SSE connection error');
- disposeSource(source);
- es = undefined;
- setIsStreaming(false);
- if (!intentionalClose && opts.eventsUrl()) {
- scheduleReconnect(url);
- } else if (!intentionalClose) {
- opts.onError?.('SSE connection error');
- }
- };
- } catch {
- if (es) {
- disposeSource(es);
- es = undefined;
- }
- setIsStreaming(false);
- if (!intentionalClose && opts.eventsUrl()) {
- scheduleReconnect(url);
- }
- }
- }
-
- // Reactively open/close based on eventsUrl signal.
- createEffect(() => {
- const url = opts.eventsUrl();
- if (url === previousUrl) return;
- previousUrl = url;
-
- if (url) {
- // New URL — reset state and open fresh connection.
- seenIds.clear();
- setEvents([]);
- setLastError('');
- reconnectAttempts = 0;
- intentionalClose = false;
- open(url);
- } else {
- close();
- }
- });
-
- onCleanup(() => reset());
-
- return { isStreaming, events, lastError };
-}
diff --git a/frontend-modern/src/stores/__tests__/diskMetricsHistory.test.ts b/frontend-modern/src/stores/__tests__/diskMetricsHistory.test.ts
deleted file mode 100644
index 2649423084..0000000000
--- a/frontend-modern/src/stores/__tests__/diskMetricsHistory.test.ts
+++ /dev/null
@@ -1,110 +0,0 @@
-import { describe, expect, it } from 'vitest';
-import {
- recordDiskMetric,
- getDiskMetricHistory,
- getLatestDiskMetric,
- getDiskMetricsVersion,
- getDiskMetricsStats,
-} from '@/stores/diskMetricsHistory';
-
-describe('diskMetricsHistory', () => {
- describe('recordDiskMetric', () => {
- it('records metric snapshot with correct values', () => {
- const before = getDiskMetricsVersion();
- const resourceId = `test-${Date.now()}-r1`;
- recordDiskMetric(resourceId, 1000, 500, 10, 5, 25);
- const after = getDiskMetricsVersion();
-
- expect(after).toBe(before + 1);
-
- const history = getDiskMetricHistory(resourceId, 60000);
- expect(history).toHaveLength(1);
- expect(history[0].readBps).toBe(1000);
- expect(history[0].writeBps).toBe(500);
- expect(history[0].readIops).toBe(10);
- expect(history[0].writeIops).toBe(5);
- expect(history[0].ioTime).toBe(25);
- });
-
- it('rounds values correctly', () => {
- const resourceId = `test-${Date.now()}-r2`;
- recordDiskMetric(resourceId, 1000.7, 500.3, 10.9, 5.1, 25.67);
-
- const history = getDiskMetricHistory(resourceId, 60000);
- expect(history[0].readBps).toBe(1001);
- expect(history[0].writeBps).toBe(500);
- expect(history[0].readIops).toBe(11);
- expect(history[0].writeIops).toBe(5);
- expect(history[0].ioTime).toBe(25.7);
- });
-
- it('stores metrics for different resources separately', () => {
- const resourceA = `test-${Date.now()}-ra`;
- const resourceB = `test-${Date.now()}-rb`;
- recordDiskMetric(resourceA, 1000, 500, 10, 5, 25);
- recordDiskMetric(resourceB, 2000, 1000, 20, 10, 50);
-
- const historyA = getDiskMetricHistory(resourceA, 60000);
- const historyB = getDiskMetricHistory(resourceB, 60000);
-
- expect(historyA).toHaveLength(1);
- expect(historyB).toHaveLength(1);
- expect(historyA[0].readBps).toBe(1000);
- expect(historyB[0].readBps).toBe(2000);
- });
-
- it('appends to existing history for same resource', () => {
- const resourceId = `test-${Date.now()}-r3`;
- recordDiskMetric(resourceId, 1000, 500, 10, 5, 25);
- recordDiskMetric(resourceId, 2000, 1000, 20, 10, 50);
-
- const history = getDiskMetricHistory(resourceId, 60000);
- expect(history).toHaveLength(2);
- });
- });
-
- describe('getDiskMetricHistory', () => {
- it('returns empty array for unknown resource', () => {
- const history = getDiskMetricHistory(`unknown-${Date.now()}`, 60000);
- expect(history).toEqual([]);
- });
- });
-
- describe('getLatestDiskMetric', () => {
- it('returns null for unknown resource', () => {
- const latest = getLatestDiskMetric(`unknown-${Date.now()}`);
- expect(latest).toBeNull();
- });
-
- it('returns most recent metric', () => {
- const resourceId = `test-${Date.now()}-r4`;
- recordDiskMetric(resourceId, 1000, 500, 10, 5, 25);
- recordDiskMetric(resourceId, 2000, 1000, 20, 10, 50);
- recordDiskMetric(resourceId, 3000, 1500, 30, 15, 75);
-
- const latest = getLatestDiskMetric(resourceId);
- expect(latest?.readBps).toBe(3000);
- });
- });
-
- describe('getDiskMetricsVersion', () => {
- it('increments when new metrics are recorded', () => {
- const before = getDiskMetricsVersion();
- const resourceId = `test-${Date.now()}-r5`;
- recordDiskMetric(resourceId, 1000, 500, 10, 5, 25);
- const after = getDiskMetricsVersion();
-
- expect(after).toBe(before + 1);
- });
- });
-
- describe('getDiskMetricsStats', () => {
- it('returns resource count and buffer size', () => {
- const stats = getDiskMetricsStats();
-
- expect(stats).toHaveProperty('resourceCount');
- expect(stats).toHaveProperty('bufferSize');
- expect(stats.bufferSize).toBe(2000);
- });
- });
-});
diff --git a/frontend-modern/src/stores/diskMetricsHistory.ts b/frontend-modern/src/stores/diskMetricsHistory.ts
deleted file mode 100644
index 37d15b8b8e..0000000000
--- a/frontend-modern/src/stores/diskMetricsHistory.ts
+++ /dev/null
@@ -1,145 +0,0 @@
-/**
- * Disk Metrics History Store
- *
- * Tracks time-series data for disk I/O (throughput/IOPS) using a ring buffer.
- * Separated from main metrics history because the data shape is different
- * (rates instead of 0-100% usage).
- */
-
-import { createSignal } from 'solid-js';
-
-export interface DiskMetricSnapshot {
- timestamp: number;
- readBps: number; // Bytes per second
- writeBps: number; // Bytes per second
- readIops: number; // Operations per second
- writeIops: number; // Operations per second
- ioTime: number; // % utilization (0-100) based on ioTimeMs
-}
-
-interface RingBuffer {
- buffer: DiskMetricSnapshot[];
- head: number; // Index of oldest item
- size: number; // Number of items currently stored
-}
-
-// Configuration
-const MAX_POINTS = 2000; // ~16 hours at 30s samples
-
-// Store - map of resourceId (e.g. "host:node1:sda") to ring buffer
-const diskMetricsHistoryMap = new Map<string, RingBuffer>();
-
-// Reactive version signal
-const [diskMetricsVersion, setDiskMetricsVersion] = createSignal(0);
-
-export function getDiskMetricsVersion(): number {
- return diskMetricsVersion();
-}
-
-function createRingBuffer(): RingBuffer {
- return {
- buffer: new Array(MAX_POINTS),
- head: 0,
- size: 0,
- };
-}
-
-function pushToRingBuffer(ring: RingBuffer, snapshot: DiskMetricSnapshot): void {
- const index = (ring.head + ring.size) % MAX_POINTS;
- ring.buffer[index] = snapshot;
-
- if (ring.size < MAX_POINTS) {
- ring.size++;
- } else {
- // Buffer is full, advance head (overwrite oldest)
- ring.head = (ring.head + 1) % MAX_POINTS;
- }
-}
-
-function getRingBufferData(ring: RingBuffer, cutoffTime: number): DiskMetricSnapshot[] {
- const result: DiskMetricSnapshot[] = [];
-
- for (let i = 0; i < ring.size; i++) {
- const index = (ring.head + i) % MAX_POINTS;
- const snapshot = ring.buffer[index];
-
- if (snapshot && snapshot.timestamp >= cutoffTime) {
- result.push(snapshot);
- }
- }
-
- return result;
-}
-
-/**
- * Record a new disk metric snapshot
- */
-export function recordDiskMetric(
- resourceId: string, // format: "nodeId:device" or "agentId:device"
- readBps: number,
- writeBps: number,
- readIops: number,
- writeIops: number,
- ioTime: number,
-): void {
- const now = Date.now();
- const snapshot: DiskMetricSnapshot = {
- timestamp: now,
- readBps: Math.round(readBps),
- writeBps: Math.round(writeBps),
- readIops: Math.round(readIops),
- writeIops: Math.round(writeIops),
- ioTime: Math.round(ioTime * 10) / 10,
- };
-
- let ring = diskMetricsHistoryMap.get(resourceId);
- if (!ring) {
- ring = createRingBuffer();
- diskMetricsHistoryMap.set(resourceId, ring);
- }
-
- pushToRingBuffer(ring, snapshot);
-
- // Trigger reactivity
- setDiskMetricsVersion((v) => v + 1);
-}
-
-/**
- * Get metric history for a disk
- */
-export function getDiskMetricHistory(
- resourceId: string,
- rangeMs: number = 3600000,
-): DiskMetricSnapshot[] {
- const ring = diskMetricsHistoryMap.get(resourceId);
- if (!ring) return [];
-
- const cutoffTime = Date.now() - rangeMs;
- return getRingBufferData(ring, cutoffTime);
-}
-
-/**
- * Get the latest snapshot
- */
-export function getLatestDiskMetric(resourceId: string): DiskMetricSnapshot | null {
- const ring = diskMetricsHistoryMap.get(resourceId);
- if (!ring || ring.size === 0) return null;
-
- const index = (ring.head + ring.size - 1) % MAX_POINTS;
- return ring.buffer[index];
-}
-
-// Stats for debugging
-export function getDiskMetricsStats() {
- return {
- resourceCount: diskMetricsHistoryMap.size,
- bufferSize: MAX_POINTS,
- };
-}
-
-if (import.meta.env.DEV) {
- (window as any).__diskMetricsHistory = {
- getStats: getDiskMetricsStats,
- getHistory: getDiskMetricHistory,
- };
-}
diff --git a/frontend-modern/src/utils/__tests__/deployStatusPresentation.test.ts b/frontend-modern/src/utils/__tests__/deployStatusPresentation.test.ts
deleted file mode 100644
index e9377860b1..0000000000
--- a/frontend-modern/src/utils/__tests__/deployStatusPresentation.test.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import { describe, expect, it } from 'vitest';
-import { getDeployStatusPresentation } from '@/utils/deployStatusPresentation';
-import type { DeployTargetStatus } from '@/types/agentDeploy';
-
-describe('deployStatusPresentation', () => {
- it('maps each deploy target status to a canonical label', () => {
- const cases: Array<[DeployTargetStatus, string]> = [
- ['pending', 'Pending'],
- ['preflighting', 'Checking'],
- ['ready', 'Ready'],
- ['installing', 'Installing'],
- ['enrolling', 'Enrolling'],
- ['verifying', 'Verifying'],
- ['succeeded', 'Deployed'],
- ['failed_retryable', 'Failed'],
- ['failed_permanent', 'Failed'],
- ['skipped_already_agent', 'Already monitored'],
- ['canceled', 'Canceled'],
- ];
-
- cases.forEach(([status, expected]) => {
- expect(getDeployStatusPresentation(status).label).toBe(expected);
- });
- });
-
- it('keeps progress states pulsing and failures explicit', () => {
- expect(getDeployStatusPresentation('preflighting').className).toContain('animate-pulse');
- expect(getDeployStatusPresentation('installing').className).toContain('animate-pulse');
- expect(getDeployStatusPresentation('failed_retryable').className).toContain('bg-red-100');
- expect(getDeployStatusPresentation('succeeded').className).toContain('bg-emerald-100');
- });
-
- it('falls back to pending for unknown or missing values', () => {
- expect(getDeployStatusPresentation(undefined)).toEqual(getDeployStatusPresentation('pending'));
- expect(getDeployStatusPresentation('bogus' as DeployTargetStatus)).toEqual(
- getDeployStatusPresentation('pending'),
- );
- });
-});
diff --git a/frontend-modern/src/utils/__tests__/pmgPresentation.test.ts b/frontend-modern/src/utils/__tests__/pmgPresentation.test.ts
deleted file mode 100644
index 65b4663009..0000000000
--- a/frontend-modern/src/utils/__tests__/pmgPresentation.test.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import { describe, expect, it } from 'vitest';
-import {
- getPMGDisconnectedState,
- getPMGSearchEmptyState,
- PMG_DISCONNECTED_STATE_TITLE,
- PMG_EMPTY_STATE_DESCRIPTION,
- PMG_EMPTY_STATE_TITLE,
- PMG_LOADING_STATE_DESCRIPTION,
- PMG_LOADING_STATE_TITLE,
- PMG_SEARCH_PLACEHOLDER,
-} from '../pmgPresentation';
-
-describe('pmgPresentation', () => {
- it('exports canonical PMG empty-state copy', () => {
- expect(PMG_EMPTY_STATE_TITLE).toBe('No Mail Gateways configured');
- expect(PMG_EMPTY_STATE_DESCRIPTION).toBe(
- 'Add a Proxmox Mail Gateway via Settings → Infrastructure to start collecting mail analytics and security metrics.',
- );
- expect(PMG_EMPTY_STATE_DESCRIPTION).not.toContain('Settings → Infrastructure → Proxmox');
- expect(PMG_LOADING_STATE_TITLE).toBe('Loading mail gateway data...');
- expect(PMG_LOADING_STATE_DESCRIPTION).toBe('Connecting to the monitoring service.');
- expect(PMG_DISCONNECTED_STATE_TITLE).toBe('Connection lost');
- expect(PMG_SEARCH_PLACEHOLDER).toBe('Search gateways...');
- });
-
- it('exports canonical PMG disconnected and search state helpers', () => {
- expect(getPMGDisconnectedState(true)).toEqual({
- title: 'Connection lost',
- description: 'Attempting to reconnect…',
- actionLabel: undefined,
- });
- expect(getPMGDisconnectedState(false)).toEqual({
- title: 'Connection lost',
- description: 'Unable to connect to the backend server',
- actionLabel: 'Reconnect now',
- });
- expect(getPMGSearchEmptyState('edge')).toEqual({
- description: 'No gateways match "edge"',
- actionLabel: 'Clear search',
- });
- });
-});
diff --git a/frontend-modern/src/utils/__tests__/pmgQueuePresentation.test.ts b/frontend-modern/src/utils/__tests__/pmgQueuePresentation.test.ts
deleted file mode 100644
index 801d726e3c..0000000000
--- a/frontend-modern/src/utils/__tests__/pmgQueuePresentation.test.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import { describe, expect, it } from 'vitest';
-import {
- getPMGOldestAgeTextClass,
- getPMGQueueSeverity,
- getPMGQueueTextClass,
-} from '@/utils/pmgQueuePresentation';
-
-describe('pmgQueuePresentation', () => {
- it('derives queue severity from total depth', () => {
- expect(getPMGQueueSeverity(5)).toBe('low');
- expect(getPMGQueueSeverity(40)).toBe('medium');
- expect(getPMGQueueSeverity(120)).toBe('high');
- });
-
- it('returns queue text classes', () => {
- expect(getPMGQueueTextClass(5, 'text-green-600')).toBe('text-green-600');
- expect(getPMGQueueTextClass(40, 'text-green-600')).toBe(
- 'text-yellow-600 dark:text-yellow-400',
- );
- expect(getPMGQueueTextClass(120, 'text-green-600')).toBe(
- 'text-red-600 dark:text-red-400',
- );
- });
-
- it('returns oldest-age warning class only when queue age is high', () => {
- expect(getPMGOldestAgeTextClass(1200)).toBe('');
- expect(getPMGOldestAgeTextClass(1900)).toBe('text-yellow-400');
- });
-});
diff --git a/frontend-modern/src/utils/__tests__/pmgThreatPresentation.test.ts b/frontend-modern/src/utils/__tests__/pmgThreatPresentation.test.ts
deleted file mode 100644
index 6340c1c444..0000000000
--- a/frontend-modern/src/utils/__tests__/pmgThreatPresentation.test.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { describe, expect, it } from 'vitest';
-import { getPMGThreatPresentation } from '@/utils/pmgThreatPresentation';
-
-describe('pmgThreatPresentation', () => {
- it('returns spam threat classes', () => {
- expect(getPMGThreatPresentation('spam')).toEqual({
- barClass: 'bg-orange-500',
- textClass: 'text-orange-600 dark:text-orange-400',
- });
- });
-
- it('returns virus threat classes', () => {
- expect(getPMGThreatPresentation('virus')).toEqual({
- barClass: 'bg-red-500',
- textClass: 'text-red-600 dark:text-red-400',
- });
- });
-
- it('returns quarantine threat classes', () => {
- expect(getPMGThreatPresentation('quarantine')).toEqual({
- barClass: 'bg-yellow-500',
- textClass: 'text-yellow-600 dark:text-yellow-400',
- });
- });
-});
diff --git a/frontend-modern/src/utils/deployStatusPresentation.ts b/frontend-modern/src/utils/deployStatusPresentation.ts
deleted file mode 100644
index 3431169bb2..0000000000
--- a/frontend-modern/src/utils/deployStatusPresentation.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-import type { DeployTargetStatus } from '@/types/agentDeploy';
-
-export interface DeployStatusPresentation {
- label: string;
- className: string;
-}
-
-const DEPLOY_STATUS_PRESENTATION: Record<DeployTargetStatus, DeployStatusPresentation> = {
- pending: { label: 'Pending', className: 'bg-surface-alt text-muted' },
- preflighting: {
- label: 'Checking',
- className: 'bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300 animate-pulse',
- },
- ready: {
- label: 'Ready',
- className: 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900 dark:text-emerald-300',
- },
- installing: {
- label: 'Installing',
- className: 'bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300 animate-pulse',
- },
- enrolling: {
- label: 'Enrolling',
- className: 'bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300 animate-pulse',
- },
- verifying: {
- label: 'Verifying',
- className: 'bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300 animate-pulse',
- },
- succeeded: {
- label: 'Deployed',
- className: 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900 dark:text-emerald-300',
- },
- failed_retryable: {
- label: 'Failed',
- className: 'bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300',
- },
- failed_permanent: {
- label: 'Failed',
- className: 'bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300',
- },
- skipped_already_agent: {
- label: 'Already monitored',
- className: 'bg-amber-100 text-amber-700 dark:bg-amber-900 dark:text-amber-300',
- },
- canceled: { label: 'Canceled', className: 'bg-surface-alt text-muted' },
-};
-
-export const getDeployStatusPresentation = (
- status?: DeployTargetStatus | null,
-): DeployStatusPresentation => DEPLOY_STATUS_PRESENTATION[status ?? 'pending'] ?? DEPLOY_STATUS_PRESENTATION.pending;
diff --git a/frontend-modern/src/utils/pmgPresentation.ts b/frontend-modern/src/utils/pmgPresentation.ts
deleted file mode 100644
index 7743702a34..0000000000
--- a/frontend-modern/src/utils/pmgPresentation.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import { getInfrastructureSettingsLocationLabel } from '@/utils/infrastructureSettingsPresentation';
-
-export const PMG_EMPTY_STATE_TITLE = 'No Mail Gateways configured';
-
-export const PMG_EMPTY_STATE_DESCRIPTION =
- `Add a Proxmox Mail Gateway via ${getInfrastructureSettingsLocationLabel()} to start collecting mail analytics and security metrics.`;
-
-export const PMG_LOADING_STATE_TITLE = 'Loading mail gateway data...';
-
-export const PMG_LOADING_STATE_DESCRIPTION = 'Connecting to the monitoring service.';
-
-export const PMG_DISCONNECTED_STATE_TITLE = 'Connection lost';
-
-export const PMG_SEARCH_PLACEHOLDER = 'Search gateways...';
-
-export function getPMGDisconnectedState(reconnecting: boolean) {
- return {
- title: PMG_DISCONNECTED_STATE_TITLE,
- description: reconnecting
- ? 'Attempting to reconnect…'
- : 'Unable to connect to the backend server',
- actionLabel: reconnecting ? undefined : 'Reconnect now',
- };
-}
-
-export function getPMGSearchEmptyState(term: string) {
- return {
- description: `No gateways match "${term}"`,
- actionLabel: 'Clear search',
- };
-}
diff --git a/frontend-modern/src/utils/pmgQueuePresentation.ts b/frontend-modern/src/utils/pmgQueuePresentation.ts
deleted file mode 100644
index 2d5cdc0621..0000000000
--- a/frontend-modern/src/utils/pmgQueuePresentation.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-export type PMGQueueSeverity = 'high' | 'medium' | 'low';
-
-export function getPMGQueueSeverity(total: number): PMGQueueSeverity {
- if (total > 100) return 'high';
- if (total > 20) return 'medium';
- return 'low';
-}
-
-export function getPMGQueueTextClass(total: number, lowClass = 'text-muted'): string {
- const severity = getPMGQueueSeverity(total);
- if (severity === 'high') return 'text-red-600 dark:text-red-400';
- if (severity === 'medium') return 'text-yellow-600 dark:text-yellow-400';
- return lowClass;
-}
-
-export function getPMGOldestAgeTextClass(seconds?: number | null): string {
- return (seconds || 0) > 1800 ? 'text-yellow-400' : '';
-}
diff --git a/frontend-modern/src/utils/pmgThreatPresentation.ts b/frontend-modern/src/utils/pmgThreatPresentation.ts
deleted file mode 100644
index 7ba54b4591..0000000000
--- a/frontend-modern/src/utils/pmgThreatPresentation.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-export type PMGThreatTone = 'spam' | 'virus' | 'quarantine';
-
-export interface PMGThreatPresentation {
- barClass: string;
- textClass: string;
-}
-
-export function getPMGThreatPresentation(tone: PMGThreatTone): PMGThreatPresentation {
- switch (tone) {
- case 'spam':
- return {
- barClass: 'bg-orange-500',
- textClass: 'text-orange-600 dark:text-orange-400',
- };
- case 'virus':
- return {
- barClass: 'bg-red-500',
- textClass: 'text-red-600 dark:text-red-400',
- };
- case 'quarantine':
- return {
- barClass: 'bg-yellow-500',
- textClass: 'text-yellow-600 dark:text-yellow-400',
- };
- }
-}