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.

Govern system logs presentation helper

rcourtmanb64577b6c871
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index a8c327a85f..3424092642 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -76,11 +76,12 @@ work extends shared components instead of creating new local variants.
53. `frontend-modern/src/components/shared/MonitoredSystemLimitWarningBanner.tsx`
54. `frontend-modern/src/components/Settings/SystemLogsPanel.tsx`
55. `frontend-modern/src/components/Settings/useSystemLogsPanelState.ts`
-56. `frontend-modern/src/components/Settings/__tests__/SystemLogsPanel.test.tsx`
-57. `frontend-modern/src/features/operations/OperationsPageSurface.tsx`
-58. `frontend-modern/src/features/operations/operationsPageModel.ts`
-59. `frontend-modern/src/pages/Operations.tsx`
-60. `frontend-modern/src/pages/__tests__/Operations.helpers.test.ts`
+56. `frontend-modern/src/utils/systemLogsPresentation.ts`
+57. `frontend-modern/src/components/Settings/__tests__/SystemLogsPanel.test.tsx`
+58. `frontend-modern/src/features/operations/OperationsPageSurface.tsx`
+59. `frontend-modern/src/features/operations/operationsPageModel.ts`
+60. `frontend-modern/src/pages/Operations.tsx`
+61. `frontend-modern/src/pages/__tests__/Operations.helpers.test.ts`
59. `frontend-modern/src/components/Settings/NetworkDiscoverySection.tsx`
60. `frontend-modern/src/components/Settings/NetworkBoundarySettingsSection.tsx`
61. `frontend-modern/src/components/Settings/networkSettingsModel.ts`
@@ -147,11 +148,13 @@ tag badge variant or importing a feature-local path into infrastructure
surfaces.
The system logs operations surface now follows the same shell/runtime split as
the other modernized settings panels: `frontend-modern/src/components/Settings/SystemLogsPanel.tsx`
-owns the operations framing and presentation helpers, while
+owns the operations framing and consumes the canonical stream-copy/status
+helpers from `frontend-modern/src/utils/systemLogsPresentation.ts`, while
`frontend-modern/src/components/Settings/useSystemLogsPanelState.ts` owns the
stream lifecycle, buffering, level updates, and download action. Future system
logs work must extend that split instead of pulling `EventSource`, API calls,
-or notification flow back into the panel render shell.
+notification flow, or customer-facing system-log copy back into the panel
+render shell.
Top-level route files are now also expected to stay thin when a feature owns
the real product surface. `frontend-modern/src/pages/Infrastructure.tsx` now
acts only as the route boundary, while
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index bf282d6aa7..860016865f 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -2099,6 +2099,7 @@
"frontend-modern/src/utils/aiSettingsPresentation.ts",
"frontend-modern/src/utils/reportingPresentation.ts",
"frontend-modern/src/utils/ssoProviderPresentation.ts",
+ "frontend-modern/src/utils/systemLogsPresentation.ts",
"frontend-modern/src/utils/systemSettingsPresentation.ts"
],
"verification": {
@@ -2236,6 +2237,19 @@
"frontend-modern/src/utils/__tests__/aiSettingsPresentation.test.ts"
]
},
+ {
+ "id": "system-logs-presentation-helper",
+ "label": "system logs presentation helper proof",
+ "match_prefixes": [],
+ "match_files": [
+ "frontend-modern/src/utils/systemLogsPresentation.ts"
+ ],
+ "allow_same_subsystem_tests": false,
+ "test_prefixes": [],
+ "exact_files": [
+ "frontend-modern/src/utils/__tests__/systemLogsPresentation.test.ts"
+ ]
+ },
{
"id": "dashboard-overview-feature-surface",
"label": "dashboard overview feature proof",
diff --git a/frontend-modern/src/components/Settings/SystemLogsPanel.tsx b/frontend-modern/src/components/Settings/SystemLogsPanel.tsx
index 20ec6d2235..cf81faa0d5 100644
--- a/frontend-modern/src/components/Settings/SystemLogsPanel.tsx
+++ b/frontend-modern/src/components/Settings/SystemLogsPanel.tsx
@@ -1,8 +1,11 @@
import { Component, For } from 'solid-js';
import OperationsPanel from '@/components/Settings/OperationsPanel';
import {
+ getSystemLogBufferSummary,
getSystemLogLineClass,
getSystemLogStreamPresentation,
+ SYSTEM_LOG_LEVEL_OPTIONS,
+ SYSTEM_LOGS_PANEL_COPY,
} from '@/utils/systemLogsPresentation';
import Download from 'lucide-solid/icons/download';
import Pause from 'lucide-solid/icons/pause';
@@ -19,24 +22,25 @@ export const SystemLogsPanel: Component = () => {
return (
<div class="space-y-6">
<OperationsPanel
- title="System Logs"
- description="Stream real-time system logs and download support bundles."
+ title={SYSTEM_LOGS_PANEL_COPY.title}
+ description={SYSTEM_LOGS_PANEL_COPY.description}
icon={<Terminal class="w-5 h-5" strokeWidth={2} />}
>
{/* Controls */}
<div class="p-4 sm:p-6">
<div class="flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4">
<div class="flex items-center space-x-3">
- <label class="text-sm font-medium text-base-content">Log Level:</label>
+ <label class="text-sm font-medium text-base-content">
+ {SYSTEM_LOGS_PANEL_COPY.levelLabel}
+ </label>
<select
value={state.level()}
onChange={(e) => void state.handleLevelChange(e.currentTarget.value)}
class="form-select min-h-10 sm:min-h-9 text-sm py-2.5 px-3 rounded-md border-border bg-surface text-muted focus:ring-primary-500 focus:border-primary-500"
>
- <option value="debug">Debug</option>
- <option value="info">Info</option>
- <option value="warn">Warn</option>
- <option value="error">Error</option>
+ <For each={SYSTEM_LOG_LEVEL_OPTIONS}>
+ {(option) => <option value={option.value}>{option.label}</option>}
+ </For>
</select>
</div>
@@ -46,14 +50,14 @@ export const SystemLogsPanel: Component = () => {
class={`min-h-10 sm:min-h-9 min-w-10 sm:min-w-9 p-2.5 rounded transition-colors ${
streamPresentation().pauseButtonClass
}`}
- title={state.isPaused() ? 'Resume Stream' : 'Pause Stream'}
+ title={streamPresentation().toggleTitle}
>
{state.isPaused() ? <Play size={18} /> : <Pause size={18} />}
</button>
<button
onClick={state.clearLogs}
class="min-h-10 sm:min-h-9 min-w-10 sm:min-w-9 p-2.5 rounded hover:bg-surface-hover text-muted transition-colors"
- title="Clear Logs"
+ title={SYSTEM_LOGS_PANEL_COPY.clearTitle}
>
<Trash2 size={18} />
</button>
@@ -63,7 +67,7 @@ export const SystemLogsPanel: Component = () => {
class="min-h-10 sm:min-h-9 flex items-center space-x-2 px-3 py-2.5 bg-primary-600 text-white rounded-md hover:bg-primary-700 text-sm font-medium transition-colors"
>
<Download size={16} />
- <span>Support Bundle</span>
+ <span>{SYSTEM_LOGS_PANEL_COPY.downloadLabel}</span>
</button>
</div>
</div>
@@ -86,15 +90,13 @@ export const SystemLogsPanel: Component = () => {
{state.logs().length === 0 && !state.isLoading() && (
<div class="h-full flex flex-col items-center justify-center ">
<Terminal size={48} class="mb-4 opacity-50" />
- <p>Waiting for logs...</p>
+ <p>{SYSTEM_LOGS_PANEL_COPY.emptyState}</p>
</div>
)}
</div>
<div class="text-xs text-muted flex justify-between px-1 pt-4">
- <span>
- Buffer: {state.logs().length} / {state.maxLogs} lines
- </span>
+ <span>{getSystemLogBufferSummary(state.logs().length, state.maxLogs)}</span>
<span class="flex items-center gap-2">
<div class={`w-2 h-2 rounded-full ${streamPresentation().indicatorClass}`}></div>
{streamPresentation().label}
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 38392ad8b5..851833cb61 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -4400,17 +4400,25 @@ describe('frontend resource type boundaries', () => {
expect(patrolRunPresentationSource).toContain('export function getToolCallsLoadingState');
expect(patrolRunPresentationSource).toContain('export function getToolCallsUnavailableState');
expect(systemLogsPanelSource).toContain('getSystemLogLineClass');
+ expect(systemLogsPanelSource).toContain('getSystemLogBufferSummary');
expect(systemLogsPanelSource).toContain('getSystemLogStreamPresentation');
+ expect(systemLogsPanelSource).toContain('SYSTEM_LOGS_PANEL_COPY');
+ expect(systemLogsPanelSource).toContain('SYSTEM_LOG_LEVEL_OPTIONS');
expect(systemLogsPanelSource).not.toContain('notificationStore.success');
expect(systemLogsPanelSource).not.toContain('new EventSource(');
expect(systemLogsPanelSource).not.toContain("log.includes('ERR')");
+ expect(systemLogsPanelSource).not.toContain("isPaused() ? 'Resume Stream' : 'Pause Stream'");
expect(systemLogsPanelSource).not.toContain("isPaused() ? 'Stream Paused' : 'Live'");
+ expect(systemLogsPanelSource).not.toContain('Waiting for logs...');
expect(systemLogsPanelSource).not.toContain(
"'bg-amber-100 text-amber-600 dark:bg-amber-900 dark:text-amber-400'",
);
expect(systemLogsPanelStateSource).toContain("window.location.href = '/api/logs/download'");
expect(systemLogsPanelStateSource).toContain('notificationStore.success');
expect(systemLogsPanelStateSource).toContain('new EventSource');
+ expect(systemLogsPresentationSource).toContain('export const SYSTEM_LOGS_PANEL_COPY');
+ expect(systemLogsPresentationSource).toContain('export const SYSTEM_LOG_LEVEL_OPTIONS');
+ expect(systemLogsPresentationSource).toContain('export function getSystemLogBufferSummary');
expect(systemLogsPresentationSource).toContain('export function getSystemLogLineClass');
expect(systemLogsPresentationSource).toContain(
'export function getSystemLogStreamPresentation',
diff --git a/frontend-modern/src/utils/__tests__/systemLogsPresentation.test.ts b/frontend-modern/src/utils/__tests__/systemLogsPresentation.test.ts
index cb3835e0ec..4b24ebcead 100644
--- a/frontend-modern/src/utils/__tests__/systemLogsPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/systemLogsPresentation.test.ts
@@ -1,10 +1,30 @@
import { describe, expect, it } from 'vitest';
import {
+ getSystemLogBufferSummary,
getSystemLogLineClass,
getSystemLogStreamPresentation,
+ SYSTEM_LOG_LEVEL_OPTIONS,
+ SYSTEM_LOGS_PANEL_COPY,
} from '@/utils/systemLogsPresentation';
describe('systemLogsPresentation', () => {
+ it('returns canonical system logs panel copy and level options', () => {
+ expect(SYSTEM_LOGS_PANEL_COPY).toEqual({
+ title: 'System Logs',
+ description: 'Stream live system logs and download support bundles.',
+ levelLabel: 'Log Level:',
+ clearTitle: 'Clear Log Output',
+ downloadLabel: 'Support Bundle',
+ emptyState: 'Waiting for log output.',
+ });
+ expect(SYSTEM_LOG_LEVEL_OPTIONS).toEqual([
+ { value: 'debug', label: 'Debug' },
+ { value: 'info', label: 'Info' },
+ { value: 'warn', label: 'Warn' },
+ { value: 'error', label: 'Error' },
+ ]);
+ });
+
it('maps log severity text to canonical classes', () => {
expect(getSystemLogLineClass('{"level":"error","msg":"boom"}')).toBe('text-red-400');
expect(getSystemLogLineClass('[WARN] something odd')).toBe('text-amber-400');
@@ -15,13 +35,19 @@ describe('systemLogsPresentation', () => {
it('maps live and paused stream state to canonical presentation', () => {
expect(getSystemLogStreamPresentation(false)).toEqual({
indicatorClass: 'bg-emerald-400 animate-pulse',
- label: 'Live',
+ label: 'Streaming',
pauseButtonClass: 'hover:bg-surface-hover text-muted',
+ toggleTitle: 'Pause Stream',
});
expect(getSystemLogStreamPresentation(true)).toEqual({
indicatorClass: 'bg-amber-400',
- label: 'Stream Paused',
+ label: 'Paused',
pauseButtonClass: 'bg-amber-100 text-amber-600 dark:bg-amber-900 dark:text-amber-400',
+ toggleTitle: 'Resume Stream',
});
});
+
+ it('formats the canonical log buffer summary', () => {
+ expect(getSystemLogBufferSummary(24, 500)).toBe('Buffer: 24 / 500 lines');
+ });
});
diff --git a/frontend-modern/src/utils/systemLogsPresentation.ts b/frontend-modern/src/utils/systemLogsPresentation.ts
index d5b07f19cc..def50f3e9d 100644
--- a/frontend-modern/src/utils/systemLogsPresentation.ts
+++ b/frontend-modern/src/utils/systemLogsPresentation.ts
@@ -2,8 +2,30 @@ export type SystemLogStreamPresentation = {
indicatorClass: string;
label: string;
pauseButtonClass: string;
+ toggleTitle: string;
};
+export type SystemLogLevelOption = {
+ value: 'debug' | 'info' | 'warn' | 'error';
+ label: string;
+};
+
+export const SYSTEM_LOGS_PANEL_COPY = {
+ title: 'System Logs',
+ description: 'Stream live system logs and download support bundles.',
+ levelLabel: 'Log Level:',
+ clearTitle: 'Clear Log Output',
+ downloadLabel: 'Support Bundle',
+ emptyState: 'Waiting for log output.',
+} as const;
+
+export const SYSTEM_LOG_LEVEL_OPTIONS: readonly SystemLogLevelOption[] = [
+ { value: 'debug', label: 'Debug' },
+ { value: 'info', label: 'Info' },
+ { value: 'warn', label: 'Warn' },
+ { value: 'error', label: 'Error' },
+] as const;
+
const ERROR_PATTERNS = ['"level":"error"', 'ERR', '[ERROR]'];
const WARNING_PATTERNS = ['"level":"warn"', 'WRN', '[WARN]'];
const DEBUG_PATTERNS = ['"level":"debug"', 'DBG', '[DEBUG]'];
@@ -11,13 +33,15 @@ const DEBUG_PATTERNS = ['"level":"debug"', 'DBG', '[DEBUG]'];
const STREAM_PRESENTATION: Record<'live' | 'paused', SystemLogStreamPresentation> = {
live: {
indicatorClass: 'bg-emerald-400 animate-pulse',
- label: 'Live',
+ label: 'Streaming',
pauseButtonClass: 'hover:bg-surface-hover text-muted',
+ toggleTitle: 'Pause Stream',
},
paused: {
indicatorClass: 'bg-amber-400',
- label: 'Stream Paused',
+ label: 'Paused',
pauseButtonClass: 'bg-amber-100 text-amber-600 dark:bg-amber-900 dark:text-amber-400',
+ toggleTitle: 'Resume Stream',
},
};
@@ -35,3 +59,7 @@ export function getSystemLogLineClass(log: string): string {
export function getSystemLogStreamPresentation(paused: boolean): SystemLogStreamPresentation {
return paused ? STREAM_PRESENTATION.paused : STREAM_PRESENTATION.live;
}
+
+export function getSystemLogBufferSummary(logCount: number, maxLogs: number): string {
+ return `Buffer: ${logCount} / ${maxLogs} lines`;
+}