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.

Split system logs runtime owner

rcourtman0531a00ce825
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 852afbe9d6..6b6977efc2 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -68,10 +68,12 @@ work extends shared components instead of creating new local variants.
46. `frontend-modern/src/components/SetupWizard/__tests__/SetupCompletionPreview.test.tsx`
47. `frontend-modern/src/components/shared/MonitoredSystemLimitWarningBanner.tsx`
48. `frontend-modern/src/components/Settings/SystemLogsPanel.tsx`
-49. `frontend-modern/src/features/operations/OperationsPageSurface.tsx`
-50. `frontend-modern/src/features/operations/operationsPageModel.ts`
-51. `frontend-modern/src/pages/Operations.tsx`
-52. `frontend-modern/src/pages/__tests__/Operations.helpers.test.ts`
+49. `frontend-modern/src/components/Settings/useSystemLogsPanelState.ts`
+50. `frontend-modern/src/components/Settings/__tests__/SystemLogsPanel.test.tsx`
+51. `frontend-modern/src/features/operations/OperationsPageSurface.tsx`
+52. `frontend-modern/src/features/operations/operationsPageModel.ts`
+53. `frontend-modern/src/pages/Operations.tsx`
+54. `frontend-modern/src/pages/__tests__/Operations.helpers.test.ts`
## Shared Boundaries
@@ -115,6 +117,13 @@ The subsystem registry now also requires explicit proof-policy coverage for all
shared runtime files, and shared-component guardrails fail if raw table
composition is reintroduced in new shared components outside the canonical
allowlist.
+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
+`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.
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 05d29e0e5b..cce2e7b024 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -1769,6 +1769,7 @@
"frontend-modern/src/components/Settings/useDiagnosticsPanelState.ts",
"frontend-modern/src/components/Settings/useReportingPanelState.ts",
"frontend-modern/src/components/Settings/useSSOProvidersState.ts",
+ "frontend-modern/src/components/Settings/useSystemLogsPanelState.ts",
"frontend-modern/src/components/SetupWizard/SetupCompletionPreview.tsx",
"frontend-modern/src/components/SetupWizard/SetupWizard.tsx",
"frontend-modern/src/features/operations/operationsPageModel.ts",
@@ -1856,6 +1857,7 @@
"frontend-modern/src/components/Settings/reportingPanelModel.ts",
"frontend-modern/src/components/Settings/SystemLogsPanel.tsx",
"frontend-modern/src/components/Settings/useReportingPanelState.ts",
+ "frontend-modern/src/components/Settings/useSystemLogsPanelState.ts",
"frontend-modern/src/features/operations/operationsPageModel.ts",
"frontend-modern/src/features/operations/OperationsPageSurface.tsx",
"frontend-modern/src/pages/Operations.tsx",
@@ -1867,6 +1869,7 @@
"frontend-modern/src/__tests__/App.architecture.test.ts",
"frontend-modern/src/components/Settings/__tests__/reportingPanelModel.test.ts",
"frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts",
+ "frontend-modern/src/components/Settings/__tests__/SystemLogsPanel.test.tsx",
"frontend-modern/src/pages/__tests__/Operations.helpers.test.ts",
"frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts",
"frontend-modern/src/utils/__tests__/reportingPresentation.test.ts"
diff --git a/frontend-modern/src/components/Settings/SystemLogsPanel.tsx b/frontend-modern/src/components/Settings/SystemLogsPanel.tsx
index 94b2474cd6..20ec6d2235 100644
--- a/frontend-modern/src/components/Settings/SystemLogsPanel.tsx
+++ b/frontend-modern/src/components/Settings/SystemLogsPanel.tsx
@@ -1,8 +1,5 @@
-import { Component, createSignal, onMount, onCleanup, For } from 'solid-js';
+import { Component, For } from 'solid-js';
import OperationsPanel from '@/components/Settings/OperationsPanel';
-import { apiFetchJSON } from '@/utils/apiClient';
-import { notificationStore } from '@/stores/notifications';
-import { logger } from '@/utils/logger';
import {
getSystemLogLineClass,
getSystemLogStreamPresentation,
@@ -12,97 +9,12 @@ import Pause from 'lucide-solid/icons/pause';
import Play from 'lucide-solid/icons/play';
import Trash2 from 'lucide-solid/icons/trash-2';
import Terminal from 'lucide-solid/icons/terminal';
+import { useSystemLogsPanelState } from './useSystemLogsPanelState';
export const SystemLogsPanel: Component = () => {
- const [logs, setLogs] = createSignal<string[]>([]);
- const [isPaused, setIsPaused] = createSignal(false);
- const [level, setLevel] = createSignal('info');
- const [isLoading, setIsLoading] = createSignal(true);
+ const state = useSystemLogsPanelState();
- let logContainer: HTMLDivElement | undefined;
- let eventSource: EventSource | null = null;
- let disposed = false;
- const MAX_LOGS = 1000;
-
- const fetchLevel = async () => {
- try {
- const res = (await apiFetchJSON('/api/logs/level')) as { level?: string };
- if (res.level && !disposed) setLevel(res.level);
- } catch (e) {
- logger.error('Failed to fetch log level', e);
- }
- };
-
- const connectStream = () => {
- if (disposed) return;
-
- // Use relative path which works with the proxy setup
- const url = '/api/logs/stream';
-
- eventSource = new EventSource(url);
-
- eventSource.onmessage = (event) => {
- if (disposed || isPaused()) return;
-
- const cleanData = event.data;
-
- setLogs((prev) => {
- const newLogs = [...prev, cleanData];
- if (newLogs.length > MAX_LOGS) {
- return newLogs.slice(newLogs.length - MAX_LOGS);
- }
- return newLogs;
- });
-
- // Auto-scroll
- if (logContainer) {
- logContainer.scrollTop = logContainer.scrollHeight;
- }
- };
-
- eventSource.onerror = () => {
- if (disposed) return;
- // Browser handles reconnection, but let's log it
- logger.debug('SSE stream disconnected, reconnecting...');
- };
- };
-
- onMount(() => {
- void (async () => {
- await fetchLevel();
- if (disposed) return;
- connectStream();
- setIsLoading(false);
- })();
- });
-
- onCleanup(() => {
- disposed = true;
- if (eventSource) {
- eventSource.close();
- eventSource = null;
- }
- });
-
- const handleLevelChange = async (newLevel: string) => {
- try {
- await apiFetchJSON('/api/logs/level', {
- method: 'POST',
- body: JSON.stringify({ level: newLevel }),
- });
- setLevel(newLevel);
- notificationStore.success(`Log level set to ${newLevel}`);
- } catch (e) {
- logger.error('Error setting log level', e);
- notificationStore.error('Failed to set log level');
- }
- };
-
- const handleDownload = () => {
- window.location.href = '/api/logs/download';
- };
-
- const streamPresentation = () => getSystemLogStreamPresentation(isPaused());
+ const streamPresentation = () => getSystemLogStreamPresentation(state.isPaused());
return (
<div class="space-y-6">
@@ -117,8 +29,8 @@ export const SystemLogsPanel: Component = () => {
<div class="flex items-center space-x-3">
<label class="text-sm font-medium text-base-content">Log Level:</label>
<select
- value={level()}
- onChange={(e) => handleLevelChange(e.currentTarget.value)}
+ 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>
@@ -130,16 +42,16 @@ export const SystemLogsPanel: Component = () => {
<div class="flex items-center space-x-2">
<button
- onClick={() => setIsPaused(!isPaused())}
+ onClick={state.togglePaused}
class={`min-h-10 sm:min-h-9 min-w-10 sm:min-w-9 p-2.5 rounded transition-colors ${
streamPresentation().pauseButtonClass
}`}
- title={isPaused() ? 'Resume Stream' : 'Pause Stream'}
+ title={state.isPaused() ? 'Resume Stream' : 'Pause Stream'}
>
- {isPaused() ? <Play size={18} /> : <Pause size={18} />}
+ {state.isPaused() ? <Play size={18} /> : <Pause size={18} />}
</button>
<button
- onClick={() => setLogs([])}
+ 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"
>
@@ -147,7 +59,7 @@ export const SystemLogsPanel: Component = () => {
</button>
<div class="h-6 w-px bg-surface-hover mx-2"></div>
<button
- onClick={handleDownload}
+ onClick={state.handleDownload}
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} />
@@ -160,10 +72,10 @@ export const SystemLogsPanel: Component = () => {
{/* Terminal View */}
<div class="p-4 sm:p-6">
<div
- ref={logContainer}
+ ref={state.setLogContainer}
class="bg-slate-950 text-slate-300 font-mono text-xs p-4 rounded-md h-[500px] overflow-y-auto whitespace-pre-wrap leading-relaxed border border-border-subtle scrollbar-thin scrollbar-thumb-slate-700 scrollbar-track-transparent"
>
- <For each={logs()}>
+ <For each={state.logs()}>
{(log) => (
<div class="animate-enter border-b border-border-subtle last:border-0 pb-0.5 mb-0.5 hover:bg-surface-hover px-1 -mx-1 rounded">
<span class={getSystemLogLineClass(log)}>{log}</span>
@@ -171,7 +83,7 @@ export const SystemLogsPanel: Component = () => {
)}
</For>
- {logs().length === 0 && !isLoading() && (
+ {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>
@@ -181,7 +93,7 @@ export const SystemLogsPanel: Component = () => {
<div class="text-xs text-muted flex justify-between px-1 pt-4">
<span>
- Buffer: {logs().length} / {MAX_LOGS} lines
+ Buffer: {state.logs().length} / {state.maxLogs} lines
</span>
<span class="flex items-center gap-2">
<div class={`w-2 h-2 rounded-full ${streamPresentation().indicatorClass}`}></div>
diff --git a/frontend-modern/src/components/Settings/__tests__/SystemLogsPanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/SystemLogsPanel.test.tsx
new file mode 100644
index 0000000000..b7ce63b58f
--- /dev/null
+++ b/frontend-modern/src/components/Settings/__tests__/SystemLogsPanel.test.tsx
@@ -0,0 +1,16 @@
+import { describe, expect, it } from 'vitest';
+import systemLogsPanelSource from '../SystemLogsPanel.tsx?raw';
+import systemLogsPanelStateSource from '../useSystemLogsPanelState.ts?raw';
+
+describe('SystemLogsPanel architecture', () => {
+ it('keeps system logs split into shell and runtime owners', () => {
+ expect(systemLogsPanelSource).toContain('./useSystemLogsPanelState');
+ expect(systemLogsPanelSource).not.toContain('createSignal(');
+ expect(systemLogsPanelSource).not.toContain('new EventSource(');
+ expect(systemLogsPanelSource).not.toContain("apiFetchJSON('/api/logs/level'");
+ expect(systemLogsPanelStateSource).toContain('new EventSource');
+ expect(systemLogsPanelStateSource).toContain("apiFetchJSON('/api/logs/level'");
+ expect(systemLogsPanelStateSource).toContain("window.location.href = '/api/logs/download'");
+ expect(systemLogsPanelStateSource).toContain('notificationStore.success');
+ });
+});
diff --git a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
index 56c5b5e5ba..26548c3d98 100644
--- a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
@@ -87,6 +87,8 @@ import diagnosticsStateSource from '../useDiagnosticsPanelState.ts?raw';
import reportingPanelModelSource from '../reportingPanelModel.ts?raw';
import reportingPanelSource from '../ReportingPanel.tsx?raw';
import reportingPanelStateSource from '../useReportingPanelState.ts?raw';
+import systemLogsPanelSource from '../SystemLogsPanel.tsx?raw';
+import systemLogsPanelStateSource from '../useSystemLogsPanelState.ts?raw';
import rbacFeatureGateSectionSource from '../RBACFeatureGateSection.tsx?raw';
import rbacFeatureGateStateSource from '../useRBACFeatureGateState.ts?raw';
import rolesPanelSource from '../RolesPanel.tsx?raw';
@@ -165,6 +167,7 @@ const extractedModules = [
'../useRelaySettingsPanelState.ts',
'../useDiagnosticsPanelState.ts',
'../useReportingPanelState.ts',
+ '../useSystemLogsPanelState.ts',
'../useSSOProvidersState.ts',
'../ssoProvidersModel.ts',
'../ProxmoxSettingsPanel.tsx',
@@ -406,6 +409,16 @@ describe('Settings architecture guardrails', () => {
expect(billingAdminOrganizationsTableSource).toContain('Billing state JSON');
});
+ it('keeps system logs split into shell and runtime owners', () => {
+ expect(systemLogsPanelSource).toContain('./useSystemLogsPanelState');
+ expect(systemLogsPanelSource).not.toContain('createSignal(');
+ expect(systemLogsPanelSource).not.toContain('new EventSource(');
+ expect(systemLogsPanelSource).not.toContain("apiFetchJSON('/api/logs/level'");
+ expect(systemLogsPanelStateSource).toContain('new EventSource');
+ expect(systemLogsPanelStateSource).toContain("apiFetchJSON('/api/logs/level'");
+ expect(systemLogsPanelStateSource).toContain('notificationStore.success');
+ });
+
it('does not re-inline extracted tab and header metadata definitions', () => {
expect(settingsSource).not.toMatch(/\b(?:const|let|var)\s+baseTabGroups\s*=/);
expect(settingsSource).not.toMatch(/\b(?:const|let|var)\s+SETTINGS_HEADER_META\s*=/);
diff --git a/frontend-modern/src/components/Settings/useSystemLogsPanelState.ts b/frontend-modern/src/components/Settings/useSystemLogsPanelState.ts
new file mode 100644
index 0000000000..0766d0cae1
--- /dev/null
+++ b/frontend-modern/src/components/Settings/useSystemLogsPanelState.ts
@@ -0,0 +1,117 @@
+import { createSignal, onCleanup, onMount } from 'solid-js';
+import { apiFetchJSON } from '@/utils/apiClient';
+import { notificationStore } from '@/stores/notifications';
+import { logger } from '@/utils/logger';
+
+const MAX_LOGS = 1000;
+
+export function useSystemLogsPanelState() {
+ const [logs, setLogs] = createSignal<string[]>([]);
+ const [isPaused, setIsPaused] = createSignal(false);
+ const [level, setLevel] = createSignal('info');
+ const [isLoading, setIsLoading] = createSignal(true);
+
+ let logContainer: HTMLDivElement | undefined;
+ let eventSource: EventSource | null = null;
+ let disposed = false;
+
+ const setLogContainer = (element: HTMLDivElement | undefined) => {
+ logContainer = element;
+ };
+
+ const scrollToBottom = () => {
+ if (logContainer) {
+ logContainer.scrollTop = logContainer.scrollHeight;
+ }
+ };
+
+ const fetchLevel = async () => {
+ try {
+ const res = (await apiFetchJSON('/api/logs/level')) as { level?: string };
+ if (res.level && !disposed) setLevel(res.level);
+ } catch (error) {
+ logger.error('Failed to fetch log level', error);
+ }
+ };
+
+ const connectStream = () => {
+ if (disposed) return;
+
+ eventSource = new EventSource('/api/logs/stream');
+
+ eventSource.onmessage = (event) => {
+ if (disposed || isPaused()) return;
+
+ setLogs((prev) => {
+ const next = [...prev, event.data];
+ if (next.length > MAX_LOGS) {
+ return next.slice(next.length - MAX_LOGS);
+ }
+ return next;
+ });
+
+ scrollToBottom();
+ };
+
+ eventSource.onerror = () => {
+ if (disposed) return;
+ logger.debug('SSE stream disconnected, reconnecting...');
+ };
+ };
+
+ const handleLevelChange = async (newLevel: string) => {
+ try {
+ await apiFetchJSON('/api/logs/level', {
+ method: 'POST',
+ body: JSON.stringify({ level: newLevel }),
+ });
+ setLevel(newLevel);
+ notificationStore.success(`Log level set to ${newLevel}`);
+ } catch (error) {
+ logger.error('Error setting log level', error);
+ notificationStore.error('Failed to set log level');
+ }
+ };
+
+ const handleDownload = () => {
+ window.location.href = '/api/logs/download';
+ };
+
+ const togglePaused = () => {
+ setIsPaused((prev) => !prev);
+ };
+
+ const clearLogs = () => {
+ setLogs([]);
+ };
+
+ onMount(() => {
+ void (async () => {
+ await fetchLevel();
+ if (disposed) return;
+ connectStream();
+ setIsLoading(false);
+ })();
+ });
+
+ onCleanup(() => {
+ disposed = true;
+ if (eventSource) {
+ eventSource.close();
+ eventSource = null;
+ }
+ });
+
+ return {
+ clearLogs,
+ handleDownload,
+ handleLevelChange,
+ isLoading,
+ isPaused,
+ level,
+ logs,
+ maxLogs: MAX_LOGS,
+ setLogContainer,
+ togglePaused,
+ };
+}
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 084d097ab2..11c2763c83 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -347,6 +347,7 @@ import thresholdSliderPresentationSource from '@/utils/thresholdSliderPresentati
import emptyStatePresentationSource from '@/utils/emptyStatePresentation.ts?raw';
import reportingPanelSource from '@/components/Settings/ReportingPanel.tsx?raw';
import systemLogsPanelSource from '@/components/Settings/SystemLogsPanel.tsx?raw';
+import systemLogsPanelStateSource from '@/components/Settings/useSystemLogsPanelState.ts?raw';
import systemLogsPresentationSource from '@/utils/systemLogsPresentation.ts?raw';
import patrolEmptyStatePresentationSource from '@/utils/patrolEmptyStatePresentation.ts?raw';
import patrolRunPresentationSource from '@/utils/patrolRunPresentation.ts?raw';
@@ -2915,6 +2916,7 @@ describe('frontend resource type boundaries', () => {
expect(operationsPageModelSource).toContain('export function buildOperationsPath');
expect(reportingPanelSource).toContain('OperationsPanel');
expect(systemLogsPanelSource).toContain('OperationsPanel');
+ expect(systemLogsPanelSource).toContain('./useSystemLogsPanelState');
expect(patrolIntelligenceSurfaceSource).toContain('getPatrolSummaryPresentation');
expect(patrolIntelligenceSurfaceSource).toContain('getAIQuickstartCreditsPresentation');
expect(patrolIntelligenceSurfaceSource).not.toContain(
@@ -2965,11 +2967,16 @@ describe('frontend resource type boundaries', () => {
expect(patrolRunPresentationSource).toContain('export function getToolCallsUnavailableState');
expect(systemLogsPanelSource).toContain('getSystemLogLineClass');
expect(systemLogsPanelSource).toContain('getSystemLogStreamPresentation');
+ expect(systemLogsPanelSource).not.toContain('notificationStore.success');
+ expect(systemLogsPanelSource).not.toContain('new EventSource(');
expect(systemLogsPanelSource).not.toContain("log.includes('ERR')");
expect(systemLogsPanelSource).not.toContain("isPaused() ? 'Stream Paused' : 'Live'");
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 function getSystemLogLineClass');
expect(systemLogsPresentationSource).toContain(
'export function getSystemLogStreamPresentation',
diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.py
index a771585960..e5d8903f6b 100644
--- a/scripts/release_control/subsystem_lookup_test.py
+++ b/scripts/release_control/subsystem_lookup_test.py
@@ -2638,6 +2638,28 @@ class SubsystemLookupTest(unittest.TestCase):
],
)
+ def test_lookup_paths_assigns_system_logs_runtime_owner_to_frontend_primitives(self) -> None:
+ result = lookup_paths(
+ ["frontend-modern/src/components/Settings/useSystemLogsPanelState.ts"]
+ )
+ self.assertEqual(result["unowned_runtime_files"], [])
+
+ file_entry = result["files"][0]
+ self.assertEqual(file_entry["classification"], "runtime")
+ self.assertEqual(len(file_entry["matches"]), 1)
+
+ match = file_entry["matches"][0]
+ self.assertEqual(match["subsystem"], "frontend-primitives")
+ self.assertEqual(
+ match["contract"],
+ "docs/release-control/v6/internal/subsystems/frontend-primitives.md",
+ )
+ self.assertEqual(match["lane_context"]["lane_id"], "L8")
+ self.assertEqual(
+ match["verification_requirement"]["id"],
+ "route-shell-and-operations",
+ )
+
def test_lookup_paths_assigns_unified_resource_metrics_targets_runtime(self) -> None:
result = lookup_paths(["internal/unifiedresources/metrics_targets.go"])
self.assertEqual(result["unowned_runtime_files"], [])