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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
refactor: remove legacy DISABLE_AUTH flag and enhance authentication UX
rcourtmane07336dd9f38
diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.mdindex f63ab830d9..87a25b1d5f 100644--- a/docs/CONFIGURATION.md+++ b/docs/CONFIGURATION.md@@ -42,7 +42,6 @@ API_TOKEN=abc123... # Optional: seed a primary API token (auto-API_TOKENS=token-one,token-two # Optional: comma-separated list of API tokens# Security settings-DISABLE_AUTH=true # Disable authentication entirelyPULSE_AUDIT_LOG=true # Enable security audit logging# Proxy/SSO Authentication (see docs/PROXY_AUTH.md for full details)@@ -63,6 +62,7 @@ PROXY_AUTH_LOGOUT_URL=/logout # URL for SSO logout- Changes to this file are applied immediately without restart (v4.3.9+)- **DO NOT** put port configuration here - use system.json or systemd overrides- Copy `.env.example` from the repository for a ready-to-edit template+- Locked out? Create `<data-path>/.auth_recovery`, restart Pulse, and sign in from localhost to reset credentials. Remove the file afterwards.---@@ -397,7 +397,8 @@ These should be set in the .env file for security:- `PULSE_AUTH_USER`, `PULSE_AUTH_PASS` - Basic authentication- `API_TOKEN` - Primary API token (auto-hashed if you supply the raw value)- `API_TOKENS` - Comma-separated list of additional API tokens (plain or SHA3-256 hashed)-- `DISABLE_AUTH` - Set to `true` to disable authentication entirely++> Locked out? Create `<data-path>/.auth_recovery`, restart Pulse, and sign in from localhost. Delete the flag file and restart again to restore normal authentication.#### OIDC Variables (optional overrides)Set these environment variables to manage single sign-on without using the UI. When present, the OIDC form is locked read-only.diff --git a/docs/DOCKER.md b/docs/DOCKER.mdindex 943ccb18c0..2886c06665 100644--- a/docs/DOCKER.md+++ b/docs/DOCKER.md@@ -317,9 +317,10 @@ docker run -d --name pulse \| `PULSE_AUTH_PASS` | Admin password (plain text auto-hashed or bcrypt hash) | `super-secret-password` or `$2a$12$...` || `API_TOKEN` | Legacy single API token (optional fallback) | `openssl rand -hex 24` || `API_TOKENS` | Comma-separated list of API tokens (plain or SHA3-256 hashed) | `ansible-token,docker-agent-token` |-| `DISABLE_AUTH` | Disable authentication entirely | `false` || `PULSE_AUDIT_LOG` | Enable security audit logging | `false` |+> Locked out while testing a container? Create `/data/.auth_recovery`, restart the container, and connect from localhost to reset credentials. Remove the flag file and restart again to restore normal authentication.+### Network| Variable | Description | Default ||----------|-------------|---------|diff --git a/docs/OIDC.md b/docs/OIDC.mdindex f789157e91..4dc806252c 100644--- a/docs/OIDC.md+++ b/docs/OIDC.md@@ -45,7 +45,7 @@ OIDC is optional. Pulse continues to ship with the familiar username/password fl- First-run setup still prompts you to create an admin credential or you can pre-seed it via `PULSE_AUTH_USER` / `PULSE_AUTH_PASS`.- If OIDC is **enabled**, the login page shows both the password form and the **Continue with Single Sign-On** button. Either path issues the same session cookie (`pulse_session`).-- To run **password-only**, leave OIDC disabled (the default). To go **OIDC-only**, set `DISABLE_AUTH=true` after you confirm SSO works.+- To run **password-only**, leave OIDC disabled (the default). For an **OIDC-first** experience, enable OIDC and rotate the local admin password to a randomly generated value; Pulse always keeps the password form available for emergency access.- The `allowedGroups`, `allowedDomains`, and `allowedEmails` settings only affect OIDC logins; password authentication continues to honour the account you created locally.## Provider Cheat-Sheetdiff --git a/docs/REVERSE_PROXY.md b/docs/REVERSE_PROXY.mdindex d56a7d41d5..ee8b28d7b0 100644--- a/docs/REVERSE_PROXY.md+++ b/docs/REVERSE_PROXY.md@@ -13,20 +13,9 @@ Pulse uses WebSockets for real-time updates. Your reverse proxy **MUST** support## Authentication with Reverse Proxy-If you're using authentication at the reverse proxy level (Authentik, Authelia, etc.), you can disable Pulse's built-in authentication to avoid double login prompts:+Pulse always enforces its own authentication. If you want to delegate sign-in to your reverse proxy (Authentik, Authelia, etc.), configure Pulse's **Proxy Authentication** integration under *Settings → Security*. That lets Pulse trust the authenticated user provided by the proxy while keeping per-user roles, API tokens, and audit logging intact.-```bash-# In your .env file or environment-DISABLE_AUTH=true-```--When `DISABLE_AUTH=true` is set:-- Pulse's built-in authentication is completely bypassed-- All endpoints become accessible without authentication-- The reverse proxy handles all authentication and authorization-- A warning is logged on startup to confirm auth is disabled--⚠️ **Warning**: Only use `DISABLE_AUTH=true` if your reverse proxy provides authentication. Never expose Pulse directly to the internet with authentication disabled.+> **Note:** The legacy `DISABLE_AUTH` environment variable has been removed. If it still exists in your deployment, Pulse will log a warning at startup and ignore it. Remove the variable and restart Pulse to silence the warning.## Nginxdiff --git a/frontend-modern/src/App.tsx b/frontend-modern/src/App.tsxindex ab6fa1ea5d..b560bddc7d 100644--- a/frontend-modern/src/App.tsx+++ b/frontend-modern/src/App.tsx@@ -118,6 +118,31 @@ function App() {};const alertsActivation = useAlertsActivation();+ let hasPreloadedRoutes = false;+ let hasFetchedVersionInfo = false;+ const preloadLazyRoutes = () => {+ if (hasPreloadedRoutes || typeof window === 'undefined') {+ return;+ }+ hasPreloadedRoutes = true;+ const loaders: Array<() => Promise<unknown>> = [+ () => import('./components/Storage/Storage'),+ () => import('./components/Backups/Backups'),+ () => import('./components/Replication/Replication'),+ () => import('./components/PMG/MailGateway'),+ () => import('./components/Hosts/HostsOverview'),+ () => import('./pages/Alerts'),+ () => import('./components/Settings/Settings'),+ () => import('./components/Docker/DockerHosts'),+ ];++ loaders.forEach((load) => {+ void load().catch((error) => {+ console.warn('[App] Failed to preload route module', error);+ });+ });+ };+const fallbackState: State = {nodes: [],vms: [],@@ -214,9 +239,46 @@ function App() {}});- onMount(() => {- void alertsActivation.refreshConfig();- void alertsActivation.refreshActiveAlerts();+ createEffect(() => {+ if (!isLoading() && !needsAuth()) {+ if (typeof window === 'undefined') {+ return;+ }+ if (!hasPreloadedRoutes) {+ // Defer to the next tick so we don't contend with initial render+ window.setTimeout(preloadLazyRoutes, 0);+ }+ }+ });++ createEffect(() => {+ if (isLoading() || needsAuth() || hasFetchedVersionInfo) {+ return;+ }+ hasFetchedVersionInfo = true;++ UpdatesAPI.getVersion()+ .then((version) => {+ setVersionInfo(version);+ // Check for updates after loading version info (non-blocking)+ updateStore.checkForUpdates();+ })+ .catch((error) => {+ console.error('Failed to load version:', error);+ });+ });++ let alertsInitialized = false;+ createEffect(() => {+ const ready = !isLoading() && !needsAuth();+ if (ready && !alertsInitialized) {+ alertsInitialized = true;+ void alertsActivation.refreshConfig();+ void alertsActivation.refreshActiveAlerts();+ }+ if (!ready) {+ alertsInitialized = false;+ }});// No longer need tab state management - using router now@@ -316,49 +378,34 @@ function App() {// First check security status to see if auth is configuredtry {const securityRes = await apiFetch('/api/security/status');- const securityData = await securityRes.json();- console.log('[App] Security status:', securityData);- // Check if auth is disabled via DISABLE_AUTH- if (securityData.disabled === true) {- console.log('[App] Auth is disabled via DISABLE_AUTH, skipping authentication');+ if (securityRes.status === 401) {+ console.warn(+ '[App] Security status request returned 401. Clearing stored credentials and showing login.',+ );+ try {+ const { clearAuth } = await import('./utils/apiClient');+ clearAuth();+ } catch (clearError) {+ console.warn('[App] Failed to clear stored auth after 401:', clearError);+ }setHasAuth(false);- setNeedsAuth(false);- // Initialize WebSocket immediately since no auth needed- setWsStore(acquireWsStore());+ setNeedsAuth(true);+ return;+ }- // Load theme preference from server for cross-device sync- // Only use server preference if no local preference exists- if (!hasLocalPreference) {- try {- const systemSettings = await SettingsAPI.getSystemSettings();- if (systemSettings.theme && systemSettings.theme !== '') {- const prefersDark = systemSettings.theme === 'dark';- setDarkMode(prefersDark);- localStorage.setItem(STORAGE_KEYS.DARK_MODE, String(prefersDark));- if (prefersDark) {- document.documentElement.classList.add('dark');- } else {- document.documentElement.classList.remove('dark');- }- }- setHasLoadedServerTheme(true);- } catch (error) {- console.error('Failed to load theme from server:', error);- }- }+ if (!securityRes.ok) {+ throw new Error(`Security status request failed with status ${securityRes.status}`);+ }- // Load version info even when auth is disabled- UpdatesAPI.getVersion()- .then((version) => {- setVersionInfo(version);- // Check for updates after loading version info (non-blocking)- updateStore.checkForUpdates();- })- .catch((error) => console.error('Failed to load version:', error));+ const securityData = await securityRes.json();+ console.log('[App] Security status:', securityData);- setIsLoading(false);- return;+ // Detect legacy DISABLE_AUTH flag (now ignored) so we can surface a warning+ if (securityData.deprecatedDisableAuth === true) {+ console.warn(+ '[App] Legacy DISABLE_AUTH flag detected; authentication remains enabled. Remove the flag and restart Pulse to silence this warning.',+ );}const authConfigured = securityData.hasAuthentication || false;@@ -504,23 +551,17 @@ function App() {}} catch (error) {console.error('Auth check error:', error);- // On error, try to proceed without auth- setNeedsAuth(false);- setWsStore(acquireWsStore());-- // Theme is already applied on initialization, no need to reapply+ try {+ const { clearAuth } = await import('./utils/apiClient');+ clearAuth();+ } catch (clearError) {+ console.warn('[App] Failed to clear stored auth after auth check error:', clearError);+ }+ setHasAuth(false);+ setNeedsAuth(true);} finally {setIsLoading(false);}-- // Load version info- UpdatesAPI.getVersion()- .then((version) => {- setVersionInfo(version);- // Check for updates after loading version info (non-blocking)- updateStore.checkForUpdates();- })- .catch((error) => console.error('Failed to load version:', error));});const handleLogin = () => {@@ -655,6 +696,61 @@ function App() {);}+function ConnectionStatusBadge(props: {+ connected: () => boolean;+ reconnecting: () => boolean;+ class?: string;+}) {+ return (+ <div+ class={`group status text-xs rounded-full flex items-center justify-center transition-all duration-500 ease-in-out px-1.5 ${+ props.connected()+ ? 'connected bg-green-200 dark:bg-green-700 text-green-700 dark:text-green-300 min-w-6 h-6 group-hover:px-3'+ : props.reconnecting()+ ? 'reconnecting bg-yellow-200 dark:bg-yellow-700 text-yellow-700 dark:text-yellow-300 py-1'+ : 'disconnected bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300 min-w-6 h-6 group-hover:px-3'+ } ${props.class ?? ''}`}+ >+ <Show when={props.reconnecting()}>+ <svg class="animate-spin h-3 w-3 flex-shrink-0" fill="none" viewBox="0 0 24 24">+ <circle+ class="opacity-25"+ cx="12"+ cy="12"+ r="10"+ stroke="currentColor"+ stroke-width="4"+ ></circle>+ <path+ class="opacity-75"+ fill="currentColor"+ d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"+ ></path>+ </svg>+ </Show>+ <Show when={props.connected()}>+ <span class="h-2.5 w-2.5 rounded-full bg-green-600 dark:bg-green-400 flex-shrink-0"></span>+ </Show>+ <Show when={!props.connected() && !props.reconnecting()}>+ <span class="h-2.5 w-2.5 rounded-full bg-gray-600 dark:bg-gray-400 flex-shrink-0"></span>+ </Show>+ <span+ class={`whitespace-nowrap overflow-hidden transition-all duration-500 ${+ props.connected() || (!props.connected() && !props.reconnecting())+ ? 'max-w-0 group-hover:max-w-[100px] group-hover:ml-2 group-hover:mr-1 opacity-0 group-hover:opacity-100'+ : 'max-w-[100px] ml-1 opacity-100'+ }`}+ >+ {props.connected()+ ? 'Connected'+ : props.reconnecting()+ ? 'Reconnecting...'+ : 'Disconnected'}+ </span>+ </div>+ );+}+function AppLayout(props: {connected: () => boolean;reconnecting: () => boolean;@@ -844,85 +940,47 @@ function AppLayout(props: {return (<div class="pulse-shell">{/* Header */}- <div class="header mb-3 flex flex-col gap-3 sm:grid sm:grid-cols-[1fr_auto_1fr] sm:items-center sm:gap-0">- <div class="flex items-center gap-2 sm:gap-2 sm:col-start-2 sm:col-end-3 sm:justify-self-center">- <svg- width="20"- height="20"- viewBox="0 0 256 256"- xmlns="http://www.w3.org/2000/svg"- class={`pulse-logo ${props.connected() && props.dataUpdated() ? 'animate-pulse-logo' : ''}`}- >- <title>Pulse Logo</title>- <circle- class="pulse-bg fill-blue-600 dark:fill-blue-500"- cx="128"- cy="128"- r="122"- />- <circle- class="pulse-ring fill-none stroke-white stroke-[14] opacity-[0.92]"- cx="128"- cy="128"- r="84"- />- <circle- class="pulse-center fill-white dark:fill-[#dbeafe]"- cx="128"- cy="128"- r="26"- />- </svg>- <span class="text-lg font-medium text-gray-800 dark:text-gray-200">Pulse</span>- <Show when={props.versionInfo()?.channel === 'rc'}>- <span class="text-xs px-1.5 py-0.5 bg-orange-500 text-white rounded font-bold">- RC- </span>- </Show>- </div>- <div class="header-controls flex w-full flex-wrap items-center gap-3 justify-start sm:col-start-3 sm:col-end-4 sm:w-auto sm:justify-end sm:justify-self-end">- <div class="flex w-full flex-wrap items-center gap-2 justify-start sm:w-auto sm:justify-end">- <div- class={`group status text-xs rounded-full flex items-center justify-center transition-all duration-500 ease-in-out px-1.5 ${- props.connected()- ? 'connected bg-green-200 dark:bg-green-700 text-green-700 dark:text-green-300 min-w-6 h-6 group-hover:px-3'- : props.reconnecting()- ? 'reconnecting bg-yellow-200 dark:bg-yellow-700 text-yellow-700 dark:text-yellow-300 py-1'- : 'disconnected bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300 min-w-6 h-6 group-hover:px-3'- }`}+ <div class="header mb-3 flex flex-wrap items-center gap-2 sm:grid sm:grid-cols-[1fr_auto_1fr] sm:items-center sm:gap-0">+ <div class="flex flex-1 items-center gap-2 sm:flex-initial sm:gap-2 sm:col-start-2 sm:col-end-3 sm:justify-self-center">+ <div class="flex items-center gap-2">+ <svg+ width="20"+ height="20"+ viewBox="0 0 256 256"+ xmlns="http://www.w3.org/2000/svg"+ class={`pulse-logo ${props.connected() && props.dataUpdated() ? 'animate-pulse-logo' : ''}`}>- <Show when={props.reconnecting()}>- <svg class="animate-spin h-3 w-3 flex-shrink-0" fill="none" viewBox="0 0 24 24">- <circle- class="opacity-25"- cx="12"- cy="12"- r="10"- stroke="currentColor"- stroke-width="4"- ></circle>- <path- class="opacity-75"- fill="currentColor"- d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"- ></path>- </svg>- </Show>- <Show when={props.connected()}>- <span class="h-2.5 w-2.5 rounded-full bg-green-600 dark:bg-green-400 flex-shrink-0"></span>- </Show>- <Show when={!props.connected() && !props.reconnecting()}>- <span class="h-2.5 w-2.5 rounded-full bg-gray-600 dark:bg-gray-400 flex-shrink-0"></span>- </Show>- <span class={`whitespace-nowrap overflow-hidden transition-all duration-500 ${props.connected() || (!props.connected() && !props.reconnecting()) ? 'max-w-0 group-hover:max-w-[100px] group-hover:ml-2 group-hover:mr-1 opacity-0 group-hover:opacity-100' : 'max-w-[100px] ml-1 opacity-100'}`}>- {props.connected()- ? 'Connected'- : props.reconnecting()- ? 'Reconnecting...'- : 'Disconnected'}+ <title>Pulse Logo</title>+ <circle+ class="pulse-bg fill-blue-600 dark:fill-blue-500"+ cx="128"+ cy="128"+ r="122"+ />+ <circle+ class="pulse-ring fill-none stroke-white stroke-[14] opacity-[0.92]"+ cx="128"+ cy="128"+ r="84"+ />+ <circle+ class="pulse-center fill-white dark:fill-[#dbeafe]"+ cx="128"+ cy="128"+ r="26"+ />+ </svg>+ <span class="text-lg font-medium text-gray-800 dark:text-gray-200">Pulse</span>+ <Show when={props.versionInfo()?.channel === 'rc'}>+ <span class="text-xs px-1.5 py-0.5 bg-orange-500 text-white rounded font-bold">+ RC</span>- </div>- <Show when={props.hasAuth() && !props.needsAuth()}>+ </Show>+ </div>+ </div>+ <div class="header-controls flex w-full flex-wrap items-center gap-2 justify-end sm:col-start-3 sm:col-end-4 sm:w-auto sm:justify-end sm:justify-self-end">+ <Show when={props.hasAuth() && !props.needsAuth()}>+ <div class="flex items-center gap-2"><Show when={props.proxyAuthInfo()?.username}><span class="text-xs px-2 py-1 text-gray-600 dark:text-gray-400">{props.proxyAuthInfo()?.username}@@ -955,8 +1013,13 @@ function AppLayout(props: {Logout</span></button>- </Show>- </div>+ </div>+ </Show>+ <ConnectionStatusBadge+ connected={props.connected}+ reconnecting={props.reconnecting}+ class="flex-shrink-0"+ /></div></div>diff --git a/frontend-modern/src/components/Docker/DockerHostSummaryTable.tsx b/frontend-modern/src/components/Docker/DockerHostSummaryTable.tsxindex 37f5dacf45..ef35be76a3 100644--- a/frontend-modern/src/components/Docker/DockerHostSummaryTable.tsx+++ b/frontend-modern/src/components/Docker/DockerHostSummaryTable.tsx@@ -115,7 +115,7 @@ export const DockerHostSummaryTable: Component<DockerHostSummaryTableProps> = (preturn (<Card padding="none" class="mb-4 overflow-hidden">- <ScrollableTable minWidth="720px">+ <ScrollableTable minWidth="720px" persistKey="docker-host-summary"><table class="w-full border-collapse"><thead><tr class="bg-gray-50 dark:bg-gray-700/50 text-gray-600 dark:text-gray-300 border-b border-gray-200 dark:border-gray-600">diff --git a/frontend-modern/src/components/Docker/DockerHosts.tsx b/frontend-modern/src/components/Docker/DockerHosts.tsxindex 2b5de33c78..239cbc32bb 100644--- a/frontend-modern/src/components/Docker/DockerHosts.tsx+++ b/frontend-modern/src/components/Docker/DockerHosts.tsx@@ -1,393 +1,33 @@import type { Component } from 'solid-js';-import { For, Show, createMemo, createSignal, createEffect, on, onMount, onCleanup } from 'solid-js';-import type { DockerHost, DockerContainer, Alert } from '@/types/api';-import { formatBytes, formatRelativeTime, formatUptime } from '@/utils/format';+import { Show, createMemo, createSignal, onMount, onCleanup } from 'solid-js';+import type { DockerHost } from '@/types/api';import { Card } from '@/components/shared/Card';-import { ScrollableTable } from '@/components/shared/ScrollableTable';import { EmptyState } from '@/components/shared/EmptyState';-import { MetricBar } from '@/components/Dashboard/MetricBar';import { DockerFilter } from './DockerFilter';-import { getAlertStyles } from '@/utils/alerts';-// import type { DockerHostSummary } from './DockerHostSummaryTable';-import { renderDockerStatusBadge } from './DockerStatusBadge';+import { DockerSummaryStatsBar } from './DockerSummaryStats';+import { DockerUnifiedTable } from './DockerUnifiedTable';import { useWebSocket } from '@/App';-import { useAlertsActivation } from '@/stores/alertsActivation';+import { useDebouncedValue } from '@/hooks/useDebouncedValue';interface DockerHostsProps {hosts: DockerHost[];- activeAlerts?: Record<string, Alert> | any; // Can be Store or plain object+ activeAlerts?: Record<string, unknown> | any;}-interface ContainerEntry {- host: DockerHost;- container: DockerContainer;-}--// Drawer state storage-const drawerState = new Map<string, boolean>();--const buildContainerId = (container: DockerContainer, hostId: string) => {- return `${hostId}-${container.id}`;-};--// Unused - kept for potential future use-// const formatContainerStatus = (container: DockerContainer) => {-// const primary = container.state || container.status || 'unknown';-// if (container.health) {-// return `${primary} · ${container.health}`;-// }-// return primary;-// };--// Unused - kept for potential future use-// const DockerGroupHeader: Component<{-// host: DockerHost;-// colspan: number;-// onToggle: (hostId: string) => void;-// selected: boolean;-// }> = (props) => {-// const lastSeenRelative = () =>-// props.host.lastSeen ? formatRelativeTime(props.host.lastSeen) : '—';-// const lastSeenAbsolute = () =>-// props.host.lastSeen ? formatAbsoluteTime(props.host.lastSeen) : '—';-//-// return (-// <tr class="bg-gray-50 dark:bg-gray-800/60">-// <td-// colSpan={props.colspan}-// class="py-1 pr-2 pl-3 text-[11px] sm:text-xs font-medium text-gray-700 dark:text-gray-200"-// >-// <div class="flex flex-wrap items-center justify-between gap-3">-// <div class="flex flex-wrap items-center gap-2 sm:gap-3">-// <button-// type="button"-// class={`text-sm font-semibold text-gray-900 dark:text-gray-100 hover:text-blue-600 dark:hover:text-blue-400 transition-colors ${-// props.selected ? 'underline' : ''-// }`}-// onClick={() => props.onToggle(props.host.id)}-// >-// {props.host.displayName}-// </button>-// <Show when={props.host.displayName !== props.host.hostname}>-// <span class="text-xs text-gray-500 dark:text-gray-400">({props.host.hostname})</span>-// </Show>-// {renderDockerStatusBadge(props.host.status)}-// </div>-// <div class="flex items-center gap-3 text-xs text-gray-500 dark:text-gray-400">-// <span>-// Last update {lastSeenRelative()} ({lastSeenAbsolute()})-// </span>-// <Show when={props.host.agentVersion}>-// <span-// class={-// props.host.agentVersion?.includes('dev') || props.host.agentVersion?.startsWith('0.1')-// ? 'px-2 py-0.5 rounded bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-400 font-medium'-// : 'px-2 py-0.5 rounded bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 font-medium'-// }-// title={-// props.host.agentVersion?.includes('dev') || props.host.agentVersion?.startsWith('0.1')-// ? 'Outdated - Update recommended for auto-update feature'-// : 'Up to date - Auto-update enabled'-// }-// >-// v{props.host.agentVersion}-// </span>-// </Show>-// <Show when={props.host.intervalSeconds}>-// <span>{props.host.intervalSeconds}s interval</span>-// </Show>-// </div>-// </div>-// </td>-// </tr>-// );-// };--const DockerContainerRow: Component<{- entry: ContainerEntry;- onHostSelect: (hostId: string) => void;- activeAlerts?: Record<string, Alert>;-}> = (props) => {- const { container, host } = props.entry;- const alertsActivation = useAlertsActivation();- const alertsEnabled = createMemo(() => alertsActivation.activationState() === 'active');- const containerId = createMemo(() => buildContainerId(container, host.id));- const [drawerOpen, setDrawerOpen] = createSignal(drawerState.get(containerId()) ?? false);-- // Get alert styles for this container- const containerResourceId = createMemo(() => `docker:${host.id}/${container.id}`);- const defaultAlertStyles = {- hasUnacknowledgedAlert: false,- hasAcknowledgedOnlyAlert: false,- severity: null as 'critical' | 'warning' | null,- hasAlert: false,- alertCount: 0,- unacknowledgedCount: 0,- acknowledgedCount: 0,- rowClass: '',- indicatorClass: '',- badgeClass: '',- };-- const alertStyles = createMemo(() => {- if (!alertsEnabled()) return defaultAlertStyles;- if (!props.activeAlerts) return defaultAlertStyles;- try {- // Convert Store to plain object if needed- const alertsObj = typeof props.activeAlerts === 'object' ? { ...props.activeAlerts } : props.activeAlerts;- return getAlertStyles(containerResourceId(), alertsObj, alertsEnabled()) || defaultAlertStyles;- } catch (e) {- console.warn('Error getting alert styles for container:', containerResourceId(), e);- return defaultAlertStyles;- }- });-- const cpuPercent = Math.max(0, Math.min(100, container.cpuPercent ?? 0));- const memoryPercent = Math.max(0, Math.min(100, container.memoryPercent ?? 0));- const memoryLabel = (() => {- if (!container.memoryUsageBytes && !container.memoryLimitBytes) return undefined;- if (!container.memoryLimitBytes) return `${formatBytes(container.memoryUsageBytes || 0)} used`;- return `${formatBytes(container.memoryUsageBytes || 0)}/${formatBytes(container.memoryLimitBytes)}`;- })();-- const uptime = () => (container.uptimeSeconds ? formatUptime(container.uptimeSeconds) : '—');- // const startedAt = () => (container.startedAt ? formatAbsoluteTime(container.startedAt) : null);- const isRunning = () => (container.state?.toLowerCase() === 'running');-- // Check if we have additional info to show in drawer- const hasDrawerContent = createMemo(() => {- return (- (container.ports && container.ports.length > 0) ||- (container.networks && container.networks.length > 0) ||- container.createdAt ||- container.image ||- (isRunning() && container.uptimeSeconds)- );- });-- // const handleHostClick = (event: MouseEvent) => {- // event.preventDefault();- // props.onHostSelect(host.id);- // };-- const toggleDrawer = (event: MouseEvent) => {- if (!hasDrawerContent()) return;- const target = event.target as HTMLElement;- if (target.closest('a, button, [data-prevent-toggle]')) {- return;- }- setDrawerOpen((prev) => !prev);- };-- // Sync drawer state- createEffect(on(containerId, (id) => {- const stored = drawerState.get(id);- if (stored !== undefined) {- setDrawerOpen(stored);- } else {- setDrawerOpen(false);- }- }));-- createEffect(() => {- drawerState.set(containerId(), drawerOpen());- });-- // Match GuestRow styling with alert highlighting- const hasUnacknowledgedAlert = createMemo(- () => alertStyles()?.hasUnacknowledgedAlert ?? false,- );- const hasAcknowledgedOnlyAlert = createMemo(- () => alertStyles()?.hasAcknowledgedOnlyAlert ?? false,- );- const showAlertHighlight = createMemo(- () => hasUnacknowledgedAlert() || hasAcknowledgedOnlyAlert(),- );- const alertAccentColor = createMemo(() => {- if (!showAlertHighlight()) return undefined;- if (hasUnacknowledgedAlert()) {- const severity = alertStyles()?.severity;- return severity === 'critical' ? '#ef4444' : '#eab308';- }- return '#9ca3af';- });+type StatsFilter = { type: 'host-status' | 'container-state' | 'service-health'; value: string } | null;- const rowClass = () => {- const base = 'transition-all duration-200 relative';- const hover = 'hover:shadow-sm';- const severity = alertStyles()?.severity;- const alertBg = hasUnacknowledgedAlert()- ? severity === 'critical'- ? 'bg-red-50 dark:bg-red-950/30'- : 'bg-yellow-50 dark:bg-yellow-950/20'- : '';- const defaultHover = hasUnacknowledgedAlert()- ? ''- : 'hover:bg-gray-50 dark:hover:bg-gray-700/30';- const stoppedDimming = !isRunning() ? 'opacity-60' : '';- const clickable = hasDrawerContent() ? 'cursor-pointer' : '';- const expanded = drawerOpen() && !hasUnacknowledgedAlert()- ? 'bg-gray-50 dark:bg-gray-800/40'- : '';- return `${base} ${hover} ${defaultHover} ${alertBg} ${stoppedDimming} ${clickable} ${expanded}`;- };+export const DockerHosts: Component<DockerHostsProps> = (props) => {+ const { initialDataReceived, reconnecting, connected } = useWebSocket();- const rowStyle = createMemo(() => {- if (!showAlertHighlight()) return {};- const color = alertAccentColor();- if (!color) return {};- return {- 'box-shadow': `inset 4px 0 0 0 ${color}`,- };+ const sortedHosts = createMemo(() => {+ const hosts = props.hosts || [];+ return [...hosts].sort((a, b) => {+ const aName = a.displayName || a.hostname || a.id || '';+ const bName = b.displayName || b.hostname || b.id || '';+ return aName.localeCompare(bName);+ });});- return (- <>- <tr class={rowClass()} style={rowStyle()} onClick={toggleDrawer} aria-expanded={drawerOpen()}>- {/* Container Name */}- <td class="py-0.5 pr-2 pl-4 relative overflow-hidden">- <div class="flex items-center gap-2 overflow-hidden">- <span class="text-sm font-medium text-gray-900 dark:text-gray-100 truncate" title={container.name || container.id.slice(0, 12)}>- {container.name || container.id.slice(0, 12)}- </span>- </div>- </td>-- {/* Status */}- <td class="py-0.5 px-2 overflow-hidden">- <div class="flex h-[24px] items-center gap-1 overflow-hidden">- {renderDockerStatusBadge(container.state || container.status)}- <Show when={container.health}>- <span class="text-xs text-gray-500 dark:text-gray-400 truncate">({container.health})</span>- </Show>- </div>- </td>-- {/* CPU */}- <td class="py-0.5 px-2 overflow-hidden">- <Show when={isRunning() && container.cpuPercent !== undefined} fallback={<span class="text-sm text-gray-400">-</span>}>- <MetricBar value={cpuPercent} label={`${cpuPercent.toFixed(0)}%`} type="cpu" />- </Show>- </td>-- {/* Memory */}- <td class="py-0.5 px-2 overflow-hidden">- <Show when={isRunning() && container.memoryPercent !== undefined} fallback={<span class="text-sm text-gray-400">-</span>}>- <MetricBar value={memoryPercent} label={`${memoryPercent.toFixed(0)}%`} sublabel={memoryLabel} type="memory" />- </Show>- </td>-- {/* Restarts */}- <td class="py-0.5 px-2 text-sm text-gray-600 dark:text-gray-400 align-middle overflow-hidden">- <span class="truncate">- {container.restartCount ?? 0}- <Show when={container.exitCode !== 0 && container.exitCode !== undefined}>- <span class="text-xs text-gray-500 dark:text-gray-400"> (Exit {container.exitCode})</span>- </Show>- </span>- </td>- </tr>-- {/* Drawer - Additional Info */}- <Show when={drawerOpen() && hasDrawerContent()}>- <tr- class={`text-[11px] ${- isRunning()- ? 'bg-gray-50/60 text-gray-600 dark:bg-gray-800/40 dark:text-gray-300'- : 'bg-gray-100/70 text-gray-400 dark:bg-gray-900/30 dark:text-gray-500'- }`}- >- <td class="px-4 py-2" colSpan={5}>- <div class="grid w-full gap-3 sm:grid-cols-2 lg:grid-cols-3">- {/* Network & IPs */}- <Show when={container.networks && container.networks.length > 0}>- <div class="rounded border border-gray-200 bg-white/70 p-2 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">- <div class="text-[11px] font-medium text-gray-700 dark:text-gray-200">Network</div>- <div class="mt-1 space-y-1">- <For each={container.networks}>- {(network) => (- <div class="flex flex-wrap items-center gap-1 text-gray-600 dark:text-gray-300">- <span class="font-medium">{network.name}</span>- <Show when={network.ipv4 || network.ipv6}>- <span class="text-gray-400 dark:text-gray-500">•</span>- <Show when={network.ipv4}>- <span class="rounded bg-blue-100 px-1.5 py-0.5 text-blue-700 dark:bg-blue-900/40 dark:text-blue-200">- {network.ipv4}- </span>- </Show>- <Show when={network.ipv6}>- <span class="rounded bg-purple-100 px-1.5 py-0.5 text-purple-700 dark:bg-purple-900/40 dark:text-purple-200">- {network.ipv6}- </span>- </Show>- </Show>- </div>- )}- </For>- </div>- </div>- </Show>-- {/* Ports */}- <Show when={container.ports && container.ports.length > 0}>- <div class="rounded border border-gray-200 bg-white/70 p-2 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">- <div class="text-[11px] font-medium text-gray-700 dark:text-gray-200">Ports</div>- <div class="mt-1 flex flex-wrap gap-1">- <For each={container.ports}>- {(port) => (- <Show when={port.publicPort} fallback={- <span class="text-xs text-gray-600 dark:text-gray-300">{port.privatePort}/{port.protocol}</span>- }>- <span class="rounded bg-blue-100 px-1.5 py-0.5 text-blue-700 dark:bg-blue-900/40 dark:text-blue-200">- {port.publicPort}→{port.privatePort}- </span>- </Show>- )}- </For>- </div>- </div>- </Show>-- {/* Container Info */}- <div class="rounded border border-gray-200 bg-white/70 p-2 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">- <div class="text-[11px] font-medium text-gray-700 dark:text-gray-200">Info</div>- <div class="mt-1 space-y-1 text-gray-600 dark:text-gray-300">- <Show when={container.image}>- <div class="flex items-start gap-1">- <span class="text-gray-500 dark:text-gray-400 min-w-[50px]">Image:</span>- <span class="break-all">{container.image}</span>- </div>- </Show>- <Show when={isRunning()}>- <div class="flex items-start gap-1">- <span class="text-gray-500 dark:text-gray-400 min-w-[50px]">Uptime:</span>- <span>{uptime()}</span>- </div>- </Show>- <Show when={container.createdAt}>- <div class="flex items-start gap-1">- <span class="text-gray-500 dark:text-gray-400 min-w-[50px]">Created:</span>- <span>{formatRelativeTime(container.createdAt!)}</span>- </div>- </Show>- <Show when={container.startedAt}>- <div class="flex items-start gap-1">- <span class="text-gray-500 dark:text-gray-400 min-w-[50px]">Started:</span>- <span>{formatRelativeTime(container.startedAt!)}</span>- </div>- </Show>- </div>- </div>- </div>- </td>- </tr>- </Show>- </>- );-};--export const DockerHosts: Component<DockerHostsProps> = (props) => {- const { initialDataReceived, reconnecting, connected } = useWebSocket();const isLoading = createMemo(() => {if (typeof initialDataReceived === 'function') {const hostCount = Array.isArray(props.hosts) ? props.hosts.length : 0;@@ -395,232 +35,67 @@ export const DockerHosts: Component<DockerHostsProps> = (props) => {}return false;});- const sortedHosts = createMemo(() => {- const hosts = props.hosts || [];- return [...hosts].sort((a, b) => a.displayName.localeCompare(b.displayName));- });- const [selectedHostId, setSelectedHostId] = createSignal<string | null>(null);const [search, setSearch] = createSignal('');+ const debouncedSearch = useDebouncedValue(search, 250);++ const [statsFilter, setStatsFilter] = createSignal<StatsFilter>(null);- // Keyboard listener to auto-focus searchlet searchInputRef: HTMLInputElement | undefined;- const handleKeyDown = (e: KeyboardEvent) => {- // Don't interfere if user is already typing in an input- const target = e.target as HTMLElement;- if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable) {- return;- }+ const focusSearchInput = () => {+ queueMicrotask(() => searchInputRef?.focus());+ };++ const handleKeyDown = (event: KeyboardEvent) => {+ const target = event.target as HTMLElement;- // Don't interfere with modifier key shortcuts (except Shift for capitals)- if (e.ctrlKey || e.metaKey || e.altKey) {+ if (event.key === 'Escape' && statsFilter()) {+ event.preventDefault();+ setStatsFilter(null);return;}- // Focus search on printable characters and start typing- if (e.key.length === 1 && searchInputRef) {- e.preventDefault();- searchInputRef.focus();- setSearch(search() + e.key);+ if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable) {+ return;}- };-- onMount(() => {- document.addEventListener('keydown', handleKeyDown);- });-- onCleanup(() => {- document.removeEventListener('keydown', handleKeyDown);- });-- // Unused - kept for potential future use- // const hostSummaries = createMemo<DockerHostSummary[]>(() => {- // return sortedHosts().map((host) => {- // const containers = host.containers || [];- // const runningCount = containers.filter((ct) => ct.state?.toLowerCase() === 'running').length;- // const totalCount = containers.length;- //- // const cpuUsage = containers.reduce((acc, ct) => acc + (ct.cpuPercent || 0), 0);- // const cpuPercent = Number.isFinite(cpuUsage)- // ? Math.min(100, Math.max(0, Number(cpuUsage.toFixed(1))))- // : 0;- //- // const memoryUsed = containers.reduce((acc, ct) => acc + (ct.memoryUsageBytes || 0), 0);- // const memoryPercent = host.totalMemoryBytes- // ? Math.min(100, Math.max(0, Number(((memoryUsed / host.totalMemoryBytes) * 100).toFixed(1))))- // : 0;- //- // const runningPercent = totalCount > 0- // ? Math.min(100, Math.max(0, Number(((runningCount / totalCount) * 100).toFixed(1))))- // : 0;- //- // const memoryLabel = host.totalMemoryBytes- // ? `${formatBytes(memoryUsed)} / ${formatBytes(host.totalMemoryBytes)}`- // : undefined;- //- // return {- // host,- // cpuPercent,- // memoryPercent,- // memoryLabel,- // runningPercent,- // runningCount,- // totalCount,- // uptimeSeconds: host.uptimeSeconds,- // lastSeenRelative: host.lastSeen ? formatRelativeTime(host.lastSeen) : '—',- // lastSeenAbsolute: host.lastSeen ? formatAbsoluteTime(host.lastSeen) : '—',- // } satisfies DockerHostSummary;- // });- // });-- const searchTerms = createMemo(() =>- search()- .toLowerCase()- .split(/[\s,]+/)- .map((term) => term.trim())- .filter(Boolean),- );-- const matchesTerm = (host: DockerHost, container: DockerContainer, term: string) => {- const [prefix, value] = term.includes(':') ? term.split(/:(.+)/) : [null, term];- const target = value || term;- const tokens = [- container.name,- container.image,- container.id,- container.state,- container.status,- host.displayName,- host.hostname,- host.status,- ];-- if (container.labels) {- Object.entries(container.labels).forEach(([key, val]) => {- tokens.push(`${key}:${val}`);- });+ if (event.ctrlKey || event.metaKey || event.altKey) {+ return;}- const hasToken = (list: (string | undefined)[]) =>- list- .filter(Boolean)- .some((entry) => entry!.toLowerCase().includes(target));-- if (prefix) {- switch (prefix) {- case 'host':- return hasToken([host.displayName, host.hostname]);- case 'name':- return hasToken([container.name]);- case 'image':- return hasToken([container.image]);- case 'state':- return hasToken([container.state, container.status]);- case 'id':- return hasToken([container.id]);- case 'label':- if (!container.labels) return false;- return Object.entries(container.labels).some(([key, val]) =>- `${key}:${val}`.toLowerCase().includes(target),- );- default:- return hasToken(tokens);- }+ if (event.key.length === 1 && searchInputRef) {+ event.preventDefault();+ focusSearchInput();+ setSearch((prev) => prev + event.key);}-- return hasToken(tokens);};- const matchesSearch = (host: DockerHost, container: DockerContainer) => {- const terms = searchTerms();- if (terms.length === 0) return true;- return terms.every((term) => matchesTerm(host, container, term));- };+ onMount(() => document.addEventListener('keydown', handleKeyDown));+ onCleanup(() => document.removeEventListener('keydown', handleKeyDown));- const groupedContainers = createMemo(() => {- const selectedHost = selectedHostId();- const groups = new Map<string, ContainerEntry[]>();+ const handleStatsFilterChange = (filter: StatsFilter) => {+ if (!filter) {+ setStatsFilter(null);+ return;+ }- sortedHosts().forEach((host) => {- if (selectedHost && host.id !== selectedHost) {- return;+ setStatsFilter((current) => {+ if (current && current.type === filter.type && current.value === filter.value) {+ return null;}-- (host.containers || []).forEach((container) => {- if (!matchesSearch(host, container)) return;-- const entry = { host, container };- const existing = groups.get(host.id);- if (existing) {- existing.push(entry);- } else {- groups.set(host.id, [entry]);- }- });+ return filter;});-- return sortedHosts()- .filter((host) => !selectedHost || host.id === selectedHost)- .map((host) => ({ host, containers: groups.get(host.id) ?? [] }))- .filter((group) => group.containers.length > 0);- });-- const hasContainers = createMemo(() => {- const groups = groupedContainers();- return groups && groups.length > 0 && groups.some(g => g.containers.length > 0);- });-- const toggleHostSelection = (hostId: string) => {- setSelectedHostId((current) => (current === hostId ? null : hostId));};- const activeHostName = createMemo(() => {- const id = selectedHostId();- if (!id) return undefined;- const host = sortedHosts().find((item) => item.id === id);- return host?.displayName;- });-- // Get containers for selected host- const selectedHostContainers = createMemo(() => {- const hostId = selectedHostId();- if (!hostId) return [];-- const host = sortedHosts().find(h => h.id === hostId);- if (!host) return [];-- return (host.containers || [])- .filter(container => matchesSearch(host, container))- .map(container => ({ host, container }));- });-- const selectedHost = createMemo(() => {- const hostId = selectedHostId();- return hostId ? sortedHosts().find(h => h.id === hostId) : null;- });-return (<div class="space-y-0"><Show when={isLoading()}><Card padding="lg"><EmptyStateicon={- <svg- class="h-12 w-12 animate-spin text-blue-500"- fill="none"- viewBox="0 0 24 24"- stroke="currentColor"- >- <circle- class="opacity-25"- cx="12"- cy="12"- r="10"- stroke="currentColor"- stroke-width="4"- />+ <svg class="h-12 w-12 animate-spin text-blue-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">+ <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4" /><pathclass="opacity-75"fill="currentColor"@@ -645,472 +120,50 @@ export const DockerHosts: Component<DockerHostsProps> = (props) => {when={sortedHosts().length === 0}fallback={<>- {/* Filters */}<DockerFiltersearch={search}setSearch={setSearch}- activeHostName={activeHostName()}- onClearHost={() => setSelectedHostId(null)}- onReset={() => setSelectedHostId(null)}- searchInputRef={(el) => (searchInputRef = el)}+ onReset={() => {+ setSearch('');+ setStatsFilter(null);+ }}+ searchInputRef={(el) => {+ searchInputRef = el;+ }}/>- {/* Master-Detail Layout */}- <div class="flex gap-4">- {/* Left: Host List - Only show if more than 1 host */}- <Show when={sortedHosts().length > 1}>- <Card padding="none" class="w-72 flex-shrink-0 overflow-hidden">- <div class="bg-gray-50 dark:bg-gray-800 px-4 py-2 border-b border-gray-200 dark:border-gray-700">- <h3 class="text-sm font-semibold text-gray-900 dark:text-gray-100">Docker Hosts</h3>- <p class="text-xs text-gray-500 dark:text-gray-400 mt-0.5">{sortedHosts().length} {sortedHosts().length === 1 ? 'host' : 'hosts'}</p>- </div>- <div class="divide-y divide-gray-200 dark:divide-gray-700">- <For each={sortedHosts()}>- {(host) => {- const isSelected = () => selectedHostId() === host.id;- const containerCount = (host.containers || []).length;- const runningCount = (host.containers || []).filter(c => c.state?.toLowerCase() === 'running').length;- const tokenRevokedAt = host.tokenRevokedAt;- const tokenRevoked = typeof tokenRevokedAt === 'number';- const tokenRevokedRelative = tokenRevokedAt ? formatRelativeTime(tokenRevokedAt) : '';- const tokenRevokedTitle = tokenRevokedAt ? new Date(tokenRevokedAt).toLocaleString() : '';-- // Check for alerts on this host's containers- const hostAlerts = createMemo(() => {- if (!props.activeAlerts) return { hasAlerts: false, criticalCount: 0, warningCount: 0 };-- const containers = host.containers || [];- let criticalCount = 0;- let warningCount = 0;-- containers.forEach(container => {- const resourceId = `docker:${host.id}/${container.id}`;- try {- const alertsObj = typeof props.activeAlerts === 'object' ? { ...props.activeAlerts } : props.activeAlerts;- const alerts = Object.values(alertsObj).filter((alert: any) => alert?.resourceId === resourceId);- alerts.forEach((alert: any) => {- if (alert.level === 'critical') criticalCount++;- else if (alert.level === 'warning') warningCount++;- });- } catch (_e) {- // Ignore errors- }- });-- return { hasAlerts: criticalCount > 0 || warningCount > 0, criticalCount, warningCount };- });-- const buttonClass = () => {- const alerts = hostAlerts();- let base = 'w-full text-left px-4 py-2.5 transition-all duration-200 relative';-- if (isSelected()) {- base += ' bg-blue-100 dark:bg-blue-900/40';- } else if (alerts.criticalCount > 0) {- base += ' bg-red-50 dark:bg-red-950/30 hover:bg-red-100 dark:hover:bg-red-950/40';- } else if (alerts.warningCount > 0) {- base += ' bg-yellow-50 dark:bg-yellow-950/20 hover:bg-yellow-100 dark:hover:bg-yellow-950/30';- } else {- base += ' hover:bg-blue-50 dark:hover:bg-blue-900/20';- }-- if (tokenRevoked) {- base += ' opacity-60';- }-- return base;- };-- const buttonStyle = () => {- const alerts = hostAlerts();- if (!alerts.hasAlerts) return {};-- const color = alerts.criticalCount > 0 ? '#ef4444' : '#eab308';- return {- 'box-shadow': `inset 4px 0 0 0 ${color}`,- };- };-- return (- <button- type="button"- onClick={() => toggleHostSelection(host.id)}- class={buttonClass()}- style={buttonStyle()}- >- {/* Host name and status */}- <div class="flex items-center justify-between gap-2">- <div class="flex items-center gap-2 min-w-0 flex-1">- <span class={`text-sm font-medium truncate ${isSelected() ? 'text-blue-900 dark:text-blue-100' : 'text-gray-900 dark:text-gray-100'}`} title={host.displayName}>- {host.displayName}- </span>- {renderDockerStatusBadge(host.status)}- <Show when={tokenRevoked}>- <span class="inline-flex items-center gap-1 rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-semibold text-amber-700 dark:bg-amber-900/40 dark:text-amber-300">- <svg class="h-3 w-3" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">- <path fill-rule="evenodd" d="M8.257 3.099c.764-1.36 2.722-1.36 3.486 0l6.518 11.62c.75 1.338-.213 3.005-1.743 3.005H3.482c-1.53 0-2.493-1.667-1.743-3.005l6.518-11.62ZM11 5a1 1 0 1 0-2 0v4.5a1 1 0 1 0 2 0V5Zm0 8a1 1 0 1 0-2 0 1 1 0 0 0 2 0Z" clip-rule="evenodd" />- </svg>- Token revoked- </span>- </Show>- </div>- <Show when={hostAlerts().hasAlerts}>- <span- class={`text-[9px] px-1.5 py-0.5 rounded font-medium flex-shrink-0 ${- hostAlerts().criticalCount > 0- ? 'bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-400'- : 'bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-400'- }`}- title={`${hostAlerts().criticalCount} critical, ${hostAlerts().warningCount} warning alerts`}- >- ⚠ {hostAlerts().criticalCount + hostAlerts().warningCount}- </span>- </Show>- </div>-- {/* Container count */}- <div class="flex items-center justify-between text-xs text-gray-600 dark:text-gray-400 mt-1">- <span>{runningCount}/{containerCount} running</span>- <Show when={host.lastSeen}>- <span class="text-[10px] text-gray-500 dark:text-gray-400">{formatRelativeTime(host.lastSeen!)}</span>- </Show>- </div>- <Show when={tokenRevoked}>- <div class="mt-1 flex items-center gap-1 text-[10px] font-semibold text-amber-700 dark:text-amber-300" title={tokenRevokedTitle}>- <svg class="h-3.5 w-3.5 flex-shrink-0" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">- <path fill-rule="evenodd" d="M8.257 3.099c.764-1.36 2.722-1.36 3.486 0l6.518 11.62c.75 1.338-.213 3.005-1.743 3.005H3.482c-1.53 0-2.493-1.667-1.743-3.005l6.518-11.62ZM11 5a1 1 0 1 0-2 0v4.5a1 1 0 1 0 2 0V5Zm0 8a1 1 0 1 0-2 0 1 1 0 0 0 2 0Z" clip-rule="evenodd" />- </svg>- <span class="truncate">Token revoked {tokenRevokedRelative} — data stale</span>- </div>- </Show>- </button>- );- }}- </For>- </div>- </Card>- </Show>-- {/* Right: Container List */}- <div class="flex-1 min-w-0">- <Show- when={selectedHost()}- fallback={- <Show- when={hasContainers()}- fallback={- <Card padding="lg">- <EmptyState- title="No containers found"- description={- search().trim()- ? 'No containers match your search.'- : 'No containers on any host'- }- />- </Card>- }- >- <Card padding="none" class="overflow-hidden">- <ScrollableTable>- <table class="w-full border-collapse table-fixed">- <colgroup>- <col style="width: 25%" />- <col style="width: 15%" />- <col style="width: 20%" />- <col style="width: 20%" />- <col style="width: 20%" />- </colgroup>- <thead>- <tr class="bg-gray-50 dark:bg-gray-700/50 text-gray-600 dark:text-gray-300 border-b border-gray-200 dark:border-gray-600">- <th class="pl-4 pr-2 py-1.5 text-left text-[11px] sm:text-xs font-medium uppercase tracking-wider">- Container- </th>- <th class="px-2 py-1.5 text-left text-[11px] sm:text-xs font-medium uppercase tracking-wider">- Status- </th>- <th class="px-2 py-1.5 text-left text-[11px] sm:text-xs font-medium uppercase tracking-wider">- CPU- </th>- <th class="px-2 py-1.5 text-left text-[11px] sm:text-xs font-medium uppercase tracking-wider">- Memory- </th>- <th class="px-2 py-1.5 text-left text-[11px] sm:text-xs font-medium uppercase tracking-wider">- Restarts- </th>- </tr>- </thead>- <tbody>- <For each={groupedContainers()}>- {(group) => (- <>- {/* Host Section Header */}- <tr class="bg-gray-50 dark:bg-gray-900/40">- <td colspan="5" class="px-4 py-2 border-t-2 border-b border-gray-200 dark:border-gray-700">- <div class="flex items-center justify-between">- <div class="flex items-center gap-3">- <h3 class="text-sm font-bold text-gray-900 dark:text-gray-100">{group.host.displayName}</h3>- <Show when={group.host.displayName !== group.host.hostname}>- <span class="text-xs text-gray-500 dark:text-gray-400">({group.host.hostname})</span>- </Show>- {renderDockerStatusBadge(group.host.status)}- <Show when={typeof group.host.tokenRevokedAt === 'number'}>- <span class="inline-flex items-center gap-1 rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-semibold text-amber-700 dark:bg-amber-900/40 dark:text-amber-300">- <svg class="h-3 w-3" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">- <path fill-rule="evenodd" d="M8.257 3.099c.764-1.36 2.722-1.36 3.486 0l6.518 11.62c.75 1.338-.213 3.005-1.743 3.005H3.482c-1.53 0-2.493-1.667-1.743-3.005l6.518-11.62ZM11 5a1 1 0 1 0-2 0v4.5a1 1 0 1 0 2 0V5Zm0 8a1 1 0 1 0-2 0 1 1 0 0 0 2 0Z" clip-rule="evenodd" />- </svg>- Token revoked- </span>- </Show>- <span class="text-xs text-gray-600 dark:text-gray-400">- {group.containers.length} {group.containers.length === 1 ? 'container' : 'containers'}- </span>- </div>- <div class="flex items-center gap-4 text-xs text-gray-500 dark:text-gray-400">- <Show when={group.host.lastSeen}>- <span>Updated {formatRelativeTime(group.host.lastSeen!)}</span>- </Show>- <Show when={group.host.agentVersion}>- <span>Agent {group.host.agentVersion}</span>- </Show>- <Show when={typeof group.host.tokenRevokedAt === 'number'}>- <span class="flex items-center gap-1 text-amber-700 dark:text-amber-300">- <svg class="h-3 w-3" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">- <path fill-rule="evenodd" d="M8.257 3.099c.764-1.36 2.722-1.36 3.486 0l6.518 11.62c.75 1.338-.213 3.005-1.743 3.005H3.482c-1.53 0-2.493-1.667-1.743-3.005l6.518-11.62ZM11 5a1 1 0 1 0-2 0v4.5a1 1 0 1 0 2 0V5Zm0 8a1 1 0 1 0-2 0 1 1 0 0 0 2 0Z" clip-rule="evenodd" />- </svg>- <span>Revoked {formatRelativeTime(group.host.tokenRevokedAt!)}</span>- </span>- </Show>- </div>- </div>- </td>- </tr>- {/* Host Containers */}- <For each={group.containers}>- {(entry) => <DockerContainerRow entry={entry} onHostSelect={toggleHostSelection} activeAlerts={props.activeAlerts} />}- </For>- </>- )}- </For>- </tbody>- </table>- </ScrollableTable>- </Card>- </Show>- }- >- {(host) => (- <Show- when={selectedHostContainers().length > 0}- fallback={- <Card padding="lg">- <EmptyState- title="No containers found"- description={- search().trim()- ? 'No containers match your search.'- : `No containers on ${host().displayName}`- }- />- </Card>- }- >- <Card padding="none" class="overflow-hidden">- {/* Host Info Header */}- <div class="bg-gray-50 dark:bg-gray-900/40 border-b-2 border-gray-200 dark:border-gray-700 px-4 py-3">- <div class="flex items-center justify-between mb-3">- <div class="flex items-center gap-3">- <h3 class="text-base font-bold text-gray-900 dark:text-gray-100">{host().displayName}</h3>- <Show when={host().displayName !== host().hostname}>- <span class="text-sm text-gray-500 dark:text-gray-400">({host().hostname})</span>- </Show>- {renderDockerStatusBadge(host().status)}- <Show when={typeof host().tokenRevokedAt === 'number'}>- <span class="inline-flex items-center gap-1 rounded-full bg-amber-100 px-2 py-0.5 text-[11px] font-semibold text-amber-700 dark:bg-amber-900/40 dark:text-amber-300">- <svg class="h-3.5 w-3.5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">- <path fill-rule="evenodd" d="M8.257 3.099c.764-1.36 2.722-1.36 3.486 0l6.518 11.62c.75 1.338-.213 3.005-1.743 3.005H3.482c-1.53 0-2.493-1.667-1.743-3.005l6.518-11.62ZM11 5a1 1 0 1 0-2 0v4.5a1 1 0 1 0 2 0V5Zm0 8a1 1 0 1 0-2 0 1 1 0 0 0 2 0Z" clip-rule="evenodd" />- </svg>- Token revoked- </span>- </Show>- <span class="text-sm text-gray-600 dark:text-gray-400">- {selectedHostContainers().length} {selectedHostContainers().length === 1 ? 'container' : 'containers'}- </span>- </div>- <div class="flex items-center gap-3">- <Show when={host().agentVersion}>- <span- class={`text-[10px] px-2 py-0.5 rounded font-medium ${- host().agentVersion?.includes('dev') || host().agentVersion?.startsWith('0.1')- ? 'bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-400'- : 'bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400'- }`}- >- Agent {host().agentVersion}- </span>- </Show>- <Show when={host().lastSeen}>- <span class="text-xs text-gray-500 dark:text-gray-400">Updated {formatRelativeTime(host().lastSeen!)}</span>- </Show>- <Show when={typeof host().tokenRevokedAt === 'number'}>- <span class="flex items-center gap-1 text-xs font-semibold text-amber-700 dark:text-amber-300">- <svg class="h-3 w-3" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">- <path fill-rule="evenodd" d="M8.257 3.099c.764-1.36 2.722-1.36 3.486 0l6.518 11.62c.75 1.338-.213 3.005-1.743 3.005H3.482c-1.53 0-2.493-1.667-1.743-3.005l6.518-11.62ZM11 5a1 1 0 1 0-2 0v4.5a1 1 0 1 0 2 0V5Zm0 8a1 1 0 1 0-2 0 1 1 0 0 0 2 0Z" clip-rule="evenodd" />- </svg>- <span>Revoked {formatRelativeTime(host().tokenRevokedAt!)}</span>- </span>- </Show>- </div>- </div>-- <Show when={typeof host().tokenRevokedAt === 'number'}>- <div class="mt-2 flex items-start gap-2 rounded-md bg-amber-100/70 px-3 py-2 text-xs text-amber-800 dark:bg-amber-900/20 dark:text-amber-200">- <svg class="h-4 w-4 flex-shrink-0" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">- <path fill-rule="evenodd" d="M8.257 3.099c.764-1.36 2.722-1.36 3.486 0l6.518 11.62c.75 1.338-.213 3.005-1.743 3.005H3.482c-1.53 0-2.493-1.667-1.743-3.005l6.518-11.62ZM11 5a1 1 0 1 0-2 0v4.5a1 1 0 1 0 2 0V5Zm0 8a1 1 0 1 0-2 0 1 1 0 0 0 2 0Z" clip-rule="evenodd" />- </svg>- <div class="space-y-1">- <div class="font-semibold">Agent token was revoked {formatRelativeTime(host().tokenRevokedAt!)}</div>- <div class="text-[11px] font-medium">No new telemetry will arrive until the agent is reconfigured.</div>- </div>- </div>- </Show>-- {/* Host Metrics */}- <Show when={host().status?.toLowerCase() === 'online' || host().status?.toLowerCase() === 'running'}>- <div class="grid grid-cols-3 gap-4">- {/* CPU */}- <div>- <div class="text-[10px] text-gray-500 dark:text-gray-400 mb-1">CPU Usage</div>- <MetricBar- value={(() => {- const total = (host().containers || [])- .filter(c => c.state?.toLowerCase() === 'running')- .reduce((sum, c) => sum + (c.cpuPercent || 0), 0);- return Math.min(100, Math.max(0, total));- })()}- label={`${(() => {- const total = (host().containers || [])- .filter(c => c.state?.toLowerCase() === 'running')- .reduce((sum, c) => sum + (c.cpuPercent || 0), 0);- return Math.min(100, Math.max(0, total)).toFixed(0);- })()}%`}- type="cpu"- />- </div>-- {/* Memory */}- <div>- <div class="text-[10px] text-gray-500 dark:text-gray-400 mb-1">Memory Usage</div>- <MetricBar- value={(() => {- if (!host().totalMemoryBytes) return 0;- const usedBytes = (host().containers || [])- .reduce((sum, c) => sum + (c.memoryUsageBytes || 0), 0);- return Math.min(100, Math.max(0, (usedBytes / host().totalMemoryBytes) * 100));- })()}- label={`${(() => {- if (!host().totalMemoryBytes) return '0';- const usedBytes = (host().containers || [])- .reduce((sum, c) => sum + (c.memoryUsageBytes || 0), 0);- return Math.min(100, Math.max(0, (usedBytes / host().totalMemoryBytes) * 100)).toFixed(0);- })()}%`}- sublabel={(() => {- if (!host().totalMemoryBytes) return undefined;- const usedBytes = (host().containers || [])- .reduce((sum, c) => sum + (c.memoryUsageBytes || 0), 0);- return `${formatBytes(usedBytes)}/${formatBytes(host().totalMemoryBytes)}`;- })()}- type="memory"- />- </div>-- {/* Uptime */}- <div>- <div class="text-[10px] text-gray-500 dark:text-gray-400 mb-1">Host Uptime</div>- <div class="text-sm font-medium text-gray-900 dark:text-gray-100">- {host().uptimeSeconds ? formatUptime(host().uptimeSeconds) : '—'}- </div>- </div>- </div>- </Show>- </div>+ <Card padding="lg">+ <DockerSummaryStatsBar+ hosts={sortedHosts()}+ onFilterChange={handleStatsFilterChange}+ activeFilter={statsFilter()}+ />+ </Card>- {/* Containers Table */}- <ScrollableTable>- <table class="w-full border-collapse table-fixed">- <colgroup>- <col style="width: 25%" />- <col style="width: 15%" />- <col style="width: 20%" />- <col style="width: 20%" />- <col style="width: 20%" />- </colgroup>- <thead>- <tr class="bg-gray-50 dark:bg-gray-700/50 text-gray-600 dark:text-gray-300 border-b border-gray-200 dark:border-gray-600">- <th class="pl-4 pr-2 py-1.5 text-left text-[11px] sm:text-xs font-medium uppercase tracking-wider">- Container- </th>- <th class="px-2 py-1.5 text-left text-[11px] sm:text-xs font-medium uppercase tracking-wider">- Status- </th>- <th class="px-2 py-1.5 text-left text-[11px] sm:text-xs font-medium uppercase tracking-wider">- CPU- </th>- <th class="px-2 py-1.5 text-left text-[11px] sm:text-xs font-medium uppercase tracking-wider">- Memory- </th>- <th class="px-2 py-1.5 text-left text-[11px] sm:text-xs font-medium uppercase tracking-wider">- Restarts- </th>- </tr>- </thead>- <tbody class="divide-y divide-gray-200 dark:divide-gray-700">- <For each={selectedHostContainers()}>- {(entry) => (- <DockerContainerRow- entry={entry}- onHostSelect={toggleHostSelection}- activeAlerts={props.activeAlerts}- />- )}- </For>- </tbody>- </table>- </ScrollableTable>- </Card>- </Show>- )}- </Show>- </div>- </div>+ <DockerUnifiedTable+ hosts={sortedHosts()}+ searchTerm={debouncedSearch()}+ statsFilter={statsFilter()}+ /></>}>- <Card padding="lg">- <EmptyState- icon={- <svg- class="h-12 w-12 text-gray-400"- fill="none"- viewBox="0 0 24 24"- stroke="currentColor"- >- <path- stroke-linecap="round"- stroke-linejoin="round"- stroke-width="2"- d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"- />- </svg>- }- title="No Docker hosts configured"- description={- <span>- Deploy the Pulse Docker agent on at least one Docker host to light up this tab. As soon as an agent reports in, container metrics appear automatically.- </span>- }- />- </Card>+ <Card padding="lg">+ <EmptyState+ icon={+ <svg class="h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">+ <path+ stroke-linecap="round"+ stroke-linejoin="round"+ stroke-width="2"+ d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"+ />+ </svg>+ }+ title="No Docker hosts configured"+ description="Deploy the Pulse Docker agent on at least one Docker host to light up this tab. As soon as an agent reports in, container metrics appear automatically."+ />+ </Card></Show></Show></div>diff --git a/frontend-modern/src/components/Docker/DockerSummaryStats.tsx b/frontend-modern/src/components/Docker/DockerSummaryStats.tsxnew file mode 100644index 0000000000..1626ea60ba--- /dev/null+++ b/frontend-modern/src/components/Docker/DockerSummaryStats.tsx@@ -0,0 +1,350 @@+import type { Component } from 'solid-js';+import { Show, createMemo } from 'solid-js';+import type { DockerHost } from '@/types/api';++interface StatCardProps {+ label: string;+ value: number | string;+ sublabel?: string;+ variant?: 'default' | 'success' | 'warning' | 'error' | 'info';+ onClick?: () => void;+ isActive?: boolean;+}++const StatCard: Component<StatCardProps> = (props) => {+ const baseClass = 'flex flex-col gap-1 px-4 py-3 rounded-lg border transition-all duration-200';++ const variantClass = () => {+ if (props.isActive) {+ return 'bg-blue-100 dark:bg-blue-900/40 border-blue-300 dark:border-blue-700 ring-2 ring-blue-500/20';+ }++ switch (props.variant) {+ case 'success':+ return 'bg-green-50 dark:bg-green-950/20 border-green-200 dark:border-green-800';+ case 'warning':+ return 'bg-yellow-50 dark:bg-yellow-950/20 border-yellow-200 dark:border-yellow-800';+ case 'error':+ return 'bg-red-50 dark:bg-red-950/20 border-red-200 dark:border-red-800';+ case 'info':+ return 'bg-blue-50 dark:bg-blue-950/20 border-blue-200 dark:border-blue-800';+ default:+ return 'bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700';+ }+ };++ const hoverClass = () => props.onClick ? 'cursor-pointer hover:shadow-md hover:scale-[1.02]' : '';++ return (+ <button+ type="button"+ class={`${baseClass} ${variantClass()} ${hoverClass()}`}+ onClick={props.onClick}+ disabled={!props.onClick}+ >+ <div class="text-2xl font-bold text-gray-900 dark:text-gray-100">+ {props.value}+ </div>+ <div class="text-xs font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wide">+ {props.label}+ </div>+ <Show when={props.sublabel}>+ <div class="text-xs text-gray-500 dark:text-gray-500">+ {props.sublabel}+ </div>+ </Show>+ </button>+ );+};++export interface DockerSummaryStats {+ hosts: {+ total: number;+ online: number;+ degraded: number;+ offline: number;+ };+ containers: {+ total: number;+ running: number;+ stopped: number;+ error: number;+ };+ services?: {+ total: number;+ healthy: number;+ degraded: number;+ };+ resources?: {+ avgCpu: number | null;+ avgMemory: number | null;+ };+}++type SummaryFilter = { type: 'host-status' | 'container-state' | 'service-health'; value: string } | null;++interface DockerSummaryStatsProps {+ hosts: DockerHost[];+ onFilterChange?: (filter: SummaryFilter) => void;+ activeFilter?: { type: string; value: string } | null;+}++export const DockerSummaryStatsBar: Component<DockerSummaryStatsProps> = (props) => {+ const stats = (): DockerSummaryStats => {+ const hosts = props.hosts || [];++ // Host stats+ let onlineHosts = 0;+ let degradedHosts = 0;+ let offlineHosts = 0;++ hosts.forEach((host) => {+ const status = host.status?.toLowerCase() ?? 'unknown';+ switch (status) {+ case 'online':+ onlineHosts++;+ break;+ case 'degraded':+ case 'warning':+ case 'maintenance':+ degradedHosts++;+ break;+ case 'offline':+ case 'error':+ case 'unreachable':+ offlineHosts++;+ break;+ default:+ degradedHosts++;+ break;+ }+ });++ // Container stats+ let totalContainers = 0;+ let runningContainers = 0;+ let stoppedContainers = 0;+ let errorContainers = 0;++ // Service stats+ let totalServices = 0;+ let healthyServices = 0;+ let degradedServices = 0;++ // Resource stats+ let totalCpu = 0;+ let totalMemory = 0;+ let cpuSamples = 0;+ let memorySamples = 0;++ hosts.forEach(host => {+ // Count containers+ const containers = host.containers || [];+ totalContainers += containers.length;++ containers.forEach(container => {+ const state = container.state?.toLowerCase();+ if (state === 'running') {+ runningContainers++;+ // Sum CPU/Memory for running containers+ if (typeof container.cpuPercent === 'number' && !Number.isNaN(container.cpuPercent)) {+ totalCpu += container.cpuPercent;+ cpuSamples++;+ }+ if (typeof container.memoryPercent === 'number' && !Number.isNaN(container.memoryPercent)) {+ totalMemory += container.memoryPercent;+ memorySamples++;+ }+ } else if (state === 'exited' || state === 'stopped' || state === 'created' || state === 'paused') {+ stoppedContainers++;+ } else if (state === 'restarting' || state === 'dead' || state === 'removing' || state === 'error' || state === 'failed') {+ errorContainers++;+ }+ });++ // Count services+ const services = host.services || [];+ totalServices += services.length;++ services.forEach(service => {+ const desired = service.desiredTasks ?? 0;+ const running = service.runningTasks ?? 0;+ if (desired > 0 && running >= desired) {+ healthyServices++;+ } else if (desired > 0) {+ degradedServices++;+ }+ });+ });++ return {+ hosts: {+ total: hosts.length,+ online: onlineHosts,+ degraded: degradedHosts,+ offline: offlineHosts,+ },+ containers: {+ total: totalContainers,+ running: runningContainers,+ stopped: stoppedContainers,+ error: errorContainers,+ },+ services: totalServices > 0 ? {+ total: totalServices,+ healthy: healthyServices,+ degraded: degradedServices,+ } : undefined,+ resources: (cpuSamples > 0 || memorySamples > 0) ? {+ avgCpu: cpuSamples > 0 ? totalCpu / cpuSamples : null,+ avgMemory: memorySamples > 0 ? totalMemory / memorySamples : null,+ } : undefined,+ };+ };++ const summary = createMemo(stats);++ const hostSublabel = () => {+ const hosts = summary().hosts;+ const parts = [`${hosts.online} online`];+ if (hosts.degraded > 0) {+ parts.push(`${hosts.degraded} degraded`);+ }+ if (hosts.offline > 0) {+ parts.push(`${hosts.offline} offline`);+ }+ return parts.join(', ');+ };++ const servicesSublabel = () => {+ const services = summary().services;+ if (!services) return '';+ const parts = [`${services.healthy} healthy`];+ if (services.degraded > 0) {+ parts.push(`${services.degraded} degraded`);+ }+ return parts.join(', ');+ };++ const resourceValue = () => {+ const avgCpu = summary().resources?.avgCpu ?? null;+ return avgCpu !== null ? Math.round(avgCpu) : '—';+ };++ const resourceSublabel = () => {+ const avgMemory = summary().resources?.avgMemory ?? null;+ if (avgMemory === null) return undefined;+ return `${Math.round(avgMemory)}% mem`;+ };++ const resourceVariant = (): StatCardProps['variant'] => {+ const avgCpu = summary().resources?.avgCpu ?? null;+ if (avgCpu === null) return 'info';+ if (avgCpu > 80) return 'error';+ if (avgCpu > 60) return 'warning';+ return 'info';+ };++ const isActive = (type: string, value: string) => {+ return props.activeFilter?.type === type && props.activeFilter?.value === value;+ };++ return (+ <div class="space-y-3">+ <div class="flex items-center justify-between">+ <h2 class="text-sm font-semibold text-gray-700 dark:text-gray-300 uppercase tracking-wide">+ Overview+ </h2>+ <Show when={props.activeFilter}>+ <button+ type="button"+ onClick={() => props.onFilterChange?.(null)}+ class="text-xs font-medium text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300"+ >+ Clear filter+ </button>+ </Show>+ </div>++ <div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3">+ {/* Hosts */}+ <StatCard+ label="Total Hosts"+ value={summary().hosts.total}+ sublabel={hostSublabel()}+ variant="default"+ />++ <Show when={summary().hosts.degraded > 0}>+ <StatCard+ label="Degraded Hosts"+ value={summary().hosts.degraded}+ variant="warning"+ onClick={() => props.onFilterChange?.({ type: 'host-status', value: 'degraded' })}+ isActive={isActive('host-status', 'degraded')}+ />+ </Show>++ <Show when={summary().hosts.offline > 0}>+ <StatCard+ label="Offline Hosts"+ value={summary().hosts.offline}+ variant="error"+ onClick={() => props.onFilterChange?.({ type: 'host-status', value: 'offline' })}+ isActive={isActive('host-status', 'offline')}+ />+ </Show>++ {/* Containers */}+ <StatCard+ label="Running"+ value={summary().containers.running}+ sublabel={`of ${summary().containers.total} containers`}+ variant="success"+ onClick={() => props.onFilterChange?.({ type: 'container-state', value: 'running' })}+ isActive={isActive('container-state', 'running')}+ />++ <Show when={summary().containers.stopped > 0}>+ <StatCard+ label="Stopped"+ value={summary().containers.stopped}+ variant="warning"+ onClick={() => props.onFilterChange?.({ type: 'container-state', value: 'stopped' })}+ isActive={isActive('container-state', 'stopped')}+ />+ </Show>++ <Show when={summary().containers.error > 0}>+ <StatCard+ label="Error"+ value={summary().containers.error}+ variant="error"+ onClick={() => props.onFilterChange?.({ type: 'container-state', value: 'error' })}+ isActive={isActive('container-state', 'error')}+ />+ </Show>++ {/* Services */}+ <Show when={summary().services}>+ <StatCard+ label="Services"+ value={summary().services!.total}+ sublabel={servicesSublabel()}+ variant={summary().services!.degraded > 0 ? 'warning' : 'success'}+ />+ </Show>++ {/* Resources */}+ <Show when={summary().resources}>+ <StatCard+ label="Avg CPU"+ value={resourceValue()}+ sublabel={resourceSublabel()}+ variant={resourceVariant()}+ />+ </Show>+ </div>+ </div>+ );+};diff --git a/frontend-modern/src/components/Docker/DockerTree.tsx b/frontend-modern/src/components/Docker/DockerTree.tsxnew file mode 100644index 0000000000..c20bd352c1--- /dev/null+++ b/frontend-modern/src/components/Docker/DockerTree.tsx@@ -0,0 +1,331 @@+import { Component, For, Show } from 'solid-js';+import type {+ DockerContainer,+ DockerHost,+ DockerService,+ DockerTask,+} from '@/types/api';+import { Card } from '@/components/shared/Card';++export type DockerTreeSelection =+ | { type: 'host'; hostId: string; id: string }+ | { type: 'service'; hostId: string; id: string }+ | { type: 'task'; hostId: string; serviceKey: string; id: string }+ | { type: 'container'; hostId: string; id: string };++export interface DockerTreeTaskEntry {+ nodeId: string;+ task: DockerTask;+}++export interface DockerTreeServiceEntry {+ key: string;+ service: DockerService;+ tasks: DockerTreeTaskEntry[];+}++export interface DockerTreeContainerEntry {+ nodeId: string;+ container: DockerContainer;+}++export interface DockerTreeHostEntry {+ host: DockerHost;+ hostId: string;+ containers: DockerContainer[];+ services: DockerTreeServiceEntry[];+ standaloneContainers: DockerTreeContainerEntry[];+}++interface ExpandState {+ isExpanded: () => boolean;+ toggle: () => void;+ setExpanded: (value: boolean) => void;+}++interface DockerTreeProps {+ hosts: DockerTreeHostEntry[];+ selected?: DockerTreeSelection | null;+ onSelect?: (selection: DockerTreeSelection) => void;+ getHostState: (hostId: string) => ExpandState;+ getServiceState: (serviceKey: string) => ExpandState;+}++export const DockerTree: Component<DockerTreeProps> = (props) => {+ const isNodeSelected = (node: DockerTreeSelection) => {+ const current = props.selected;+ if (!current) return false;+ return (+ current.type === node.type &&+ current.hostId === node.hostId &&+ current.id === node.id+ );+ };++ const hostDisplayName = (host: DockerHost) =>+ host.displayName || host.hostname || host.id || 'Unknown host';++ const hostStatusVariant = (host: DockerHost) => {+ const status = host.status?.toLowerCase() ?? 'unknown';+ if (status === 'online') {+ return 'bg-green-500';+ }+ if (+ status === 'offline' ||+ status === 'error' ||+ status === 'down' ||+ status === 'unreachable'+ ) {+ return 'bg-red-500';+ }+ return 'bg-yellow-500';+ };++ const taskStatusVariant = (task: DockerTask) => {+ const state = task.currentState?.toLowerCase() ?? '';+ if (state === 'running') return 'bg-green-500';+ if (state === 'failed' || state === 'error') return 'bg-red-500';+ return 'bg-yellow-500';+ };++ const describeTaskLabel = (task: DockerTask) => {+ if (task.slot !== undefined && task.slot !== null) {+ return `${task.containerName || task.containerId || 'Task'}:${task.slot}`;+ }+ return task.containerName || task.containerId || task.id?.slice(0, 12) || 'Task';+ };++ return (+ <Card+ padding="none"+ class="bg-white dark:bg-slate-900/60 p-2"+ >+ <nav class="space-y-1.5 text-xs">+ <For each={props.hosts}>+ {(entry) => {+ const hostState = props.getHostState(entry.hostId);++ const selectHost = () => {+ hostState.setExpanded(true);+ props.onSelect?.({+ type: 'host',+ hostId: entry.hostId,+ id: entry.hostId,+ });+ };++ return (+ <div class="space-y-0.5">+ <div class="flex items-start gap-1.5">+ {/*+ Small expand/collapse control for the host section. We avoid re-rendering+ the entire row by leaving the host summary text in a separate button.+ */}+ <button+ type="button"+ onClick={() => hostState.toggle()}+ aria-label={+ hostState.isExpanded() ? 'Collapse host section' : 'Expand host section'+ }+ class="mt-0 h-4 w-4 flex items-center justify-center rounded border border-transparent text-slate-500 hover:text-sky-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-sky-500"+ >+ <svg+ class={`h-3 w-3 transition-transform duration-150 ${+ hostState.isExpanded() ? 'rotate-90' : ''+ }`}+ viewBox="0 0 20 20"+ fill="currentColor"+ >+ <path d="M6 4l6 6-6 6" />+ </svg>+ </button>++ <button+ type="button"+ onClick={selectHost}+ class={`flex w-full items-center gap-2 truncate rounded border border-transparent px-1.5 py-0.5 text-left text-[12px] font-medium transition-colors ${+ isNodeSelected({ type: 'host', hostId: entry.hostId, id: entry.hostId })+ ? 'bg-sky-100 text-sky-800 dark:bg-sky-900/40 dark:text-sky-200'+ : 'hover:bg-slate-100 dark:hover:bg-slate-800/50'+ }`}+ >+ <span+ class={`h-2 w-2 flex-shrink-0 rounded-full ${hostStatusVariant(entry.host)}`}+ aria-hidden="true"+ />+ <span class="truncate text-slate-700 dark:text-slate-100">{hostDisplayName(entry.host)}</span>+ </button>+ </div>++ <Show when={hostState.isExpanded()}>+ <div class="space-y-1 border-l border-slate-200 pl-2 dark:border-slate-700">+ <Show when={entry.services.length > 0}>+ <div class="space-y-0.5">+ <div class="text-[11px] font-semibold uppercase tracking-tight text-slate-400 dark:text-slate-500">+ Services+ </div>+ <div class="space-y-0.5">+ <For each={entry.services}>+ {(serviceEntry) => {+ const serviceState = props.getServiceState(serviceEntry.key);++ const selectService = () => {+ hostState.setExpanded(true);+ props.onSelect?.({+ type: 'service',+ hostId: entry.hostId,+ id: serviceEntry.key,+ });+ };++ const selectTask = (taskNodeId: string) => {+ hostState.setExpanded(true);+ serviceState.setExpanded(true);+ props.onSelect?.({+ type: 'task',+ hostId: entry.hostId,+ serviceKey: serviceEntry.key,+ id: taskNodeId,+ });+ };++ return (+ <div class="space-y-0.5">+ <div class="flex items-start gap-1.5">+ <Show when={serviceEntry.tasks.length > 0}>+ <button+ type="button"+ aria-label={+ serviceState.isExpanded()+ ? 'Collapse task list'+ : 'Expand task list'+ }+ class="mt-0.5 h-3.5 w-3.5 flex items-center justify-center rounded border border-transparent text-slate-400 hover:text-sky-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-sky-500"+ onClick={(event) => {+ event.stopPropagation();+ serviceState.toggle();+ }}+ >+ <svg+ class={`h-3 w-3 transition-transform duration-150 ${+ serviceState.isExpanded() ? 'rotate-90' : ''+ }`}+ viewBox="0 0 20 20"+ fill="currentColor"+ >+ <path d="M6 4l6 6-6 6" />+ </svg>+ </button>+ </Show>+ <button+ type="button"+ onClick={selectService}+ class={`flex min-h-[24px] w-full items-center gap-1.5 rounded px-1.5 py-0.5 text-left text-[11px] transition-colors ${+ isNodeSelected({+ type: 'service',+ hostId: entry.hostId,+ id: serviceEntry.key,+ })+ ? 'bg-sky-50 text-sky-700 dark:bg-sky-900/30 dark:text-sky-200'+ : 'hover:bg-slate-100 dark:hover:bg-slate-800/50'+ }`}+ >+ <span class="truncate text-slate-600 dark:text-slate-200">+ {serviceEntry.service.name || serviceEntry.service.id}+ </span>+ </button>+ </div>++ <Show when={serviceEntry.tasks.length > 0 && serviceState.isExpanded()}>+ <div class="space-y-0.5 border-l border-slate-200 pl-2 dark:border-slate-700">+ <For each={serviceEntry.tasks}>+ {(taskEntry) => {+ const task = taskEntry.task;+ return (+ <button+ type="button"+ onClick={() => selectTask(taskEntry.nodeId)}+ class={`flex w-full items-center gap-1.5 rounded px-1.5 py-0.5 text-left text-[11px] transition-colors ${+ isNodeSelected({+ type: 'task',+ hostId: entry.hostId,+ serviceKey: serviceEntry.key,+ id: taskEntry.nodeId,+ })+ ? 'bg-sky-100 text-sky-700 dark:bg-sky-900/40 dark:text-sky-200'+ : 'hover:bg-slate-100 dark:hover:bg-slate-800/50'+ }`}+ >+ <span+ class={`h-1.5 w-1.5 flex-shrink-0 rounded-full ${taskStatusVariant(task)}`}+ aria-hidden="true"+ />+ <span class="truncate text-slate-500 dark:text-slate-300">+ {describeTaskLabel(task)}+ </span>+ </button>+ );+ }}+ </For>+ </div>+ </Show>+ </div>+ );+ }}+ </For>+ </div>+ </div>+ </Show>++ <Show when={entry.standaloneContainers.length > 0}>+ <div class="space-y-0.5">+ <div class="text-[11px] font-semibold uppercase tracking-tight text-slate-400 dark:text-slate-500">+ Standalone Containers+ </div>+ <div class="space-y-0.5">+ <For each={entry.standaloneContainers}>+ {(containerEntry) => {+ const container = containerEntry.container;+ const selectContainer = () => {+ hostState.setExpanded(true);+ props.onSelect?.({+ type: 'container',+ hostId: entry.hostId,+ id: containerEntry.nodeId,+ });+ };++ return (+ <button+ type="button"+ onClick={selectContainer}+ class={`flex w-full items-center gap-1.5 rounded px-1.5 py-0.5 text-left text-[11px] transition-colors ${+ isNodeSelected({+ type: 'container',+ hostId: entry.hostId,+ id: containerEntry.nodeId,+ })+ ? 'bg-sky-50 text-sky-700 dark:bg-sky-900/30 dark:text-sky-200'+ : 'hover:bg-slate-100 dark:hover:bg-slate-800/50'+ }`}+ >+ <span class="truncate text-slate-600 dark:text-slate-200">+ {container.name || container.id || 'Unknown container'}+ </span>+ </button>+ );+ }}+ </For>+ </div>+ </div>+ </Show>+ </div>+ </Show>+ </div>+ );+ }}+ </For>+ </nav>+ </Card>+ );+};diff --git a/frontend-modern/src/components/Docker/DockerUnifiedTable.tsx b/frontend-modern/src/components/Docker/DockerUnifiedTable.tsxnew file mode 100644index 0000000000..248b98d9a0--- /dev/null+++ b/frontend-modern/src/components/Docker/DockerUnifiedTable.tsx@@ -0,0 +1,1240 @@+import { Component, For, Show, batch, createSignal, createMemo, createEffect, onCleanup } from 'solid-js';+import type { DockerHost, DockerContainer, DockerService, DockerTask } from '@/types/api';+import { Card } from '@/components/shared/Card';+import { ScrollableTable } from '@/components/shared/ScrollableTable';+import { MetricBar } from '@/components/Dashboard/MetricBar';+import {+ DockerTree,+ type DockerTreeHostEntry,+ type DockerTreeSelection,+ type DockerTreeServiceEntry,+} from './DockerTree';++interface DockerUnifiedTableProps {+ hosts: DockerHost[];+ searchTerm?: string;+ statsFilter?: { type: 'host-status' | 'container-state' | 'service-health'; value: string } | null;+}++const findContainerForTask = (containers: DockerContainer[], task: DockerTask) => {+ if (!containers.length) return undefined;++ const taskId = task.containerId?.toLowerCase() ?? '';+ const taskName = task.containerName?.toLowerCase() ?? '';+ const taskNameBase = taskName.split('.')[0] || taskName;++ return containers.find((container) => {+ const id = container.id?.toLowerCase() ?? '';+ const name = container.name?.toLowerCase() ?? '';++ const idMatch =+ !!taskId &&+ (id === taskId || id.includes(taskId) || taskId.includes(id));++ const nameMatch =+ !!taskName &&+ (name === taskName ||+ name.includes(taskName) ||+ taskName.includes(name) ||+ (!!taskNameBase && (name === taskNameBase || name.includes(taskNameBase))));++ return idMatch || nameMatch;+ });+};++const OFFLINE_HOST_STATUSES = new Set(['offline', 'error', 'unreachable', 'down', 'disconnected']);+const DEGRADED_HOST_STATUSES = new Set(['degraded', 'warning', 'maintenance', 'partial', 'initializing', 'unknown']);++const STOPPED_CONTAINER_STATES = new Set(['exited', 'stopped', 'created', 'paused']);+const ERROR_CONTAINER_STATES = new Set(['restarting', 'dead', 'removing', 'failed', 'error', 'oomkilled', 'unhealthy']);++// Persistent state for expanded hosts and services+const hostExpandState = new Map<string, boolean>();+const hostExpandSignals = new Map<string, ReturnType<typeof createSignal<boolean>>>();+const serviceExpandState = new Map<string, boolean>();+const serviceExpandSignals = new Map<string, ReturnType<typeof createSignal<boolean>>>();++const getTaskNodeId = (serviceKey: string, task: DockerTask, index: number) => {+ if (task.id) {+ return `${serviceKey}:task:${task.id}`;+ }+ if (task.containerId) {+ return `${serviceKey}:task:${task.containerId}`;+ }+ if (task.containerName) {+ return `${serviceKey}:task:${task.containerName}`;+ }+ if (task.slot !== undefined && task.slot !== null) {+ return `${serviceKey}:task:slot-${task.slot}`;+ }+ return `${serviceKey}:task:${index}`;+};++// Docker Host Group Header Component (matches NodeGroupHeader style)+interface DockerHostHeaderProps {+ host: DockerHost;+ colspan: number;+ isExpanded: boolean;+ onToggle: () => void;+ isActive?: boolean;+}++const DockerHostHeader: Component<DockerHostHeaderProps> = (props) => {+ const status = () => props.host.status?.toLowerCase() ?? 'unknown';+ const isOnline = () => status() === 'online';+ const isOffline = () => OFFLINE_HOST_STATUSES.has(status());+ const displayName = () => props.host.displayName || props.host.hostname || props.host.id;++ const totalContainers = () => (props.host.containers?.length || 0);+ const runningContainers = () =>+ (props.host.containers?.filter((c) => c.state?.toLowerCase() === 'running').length || 0);+ const totalServices = () => (props.host.services?.length || 0);++ return (+ <tr class="bg-gray-50 dark:bg-gray-900/40">+ <td+ colspan={props.colspan}+ class={`py-1 pr-2 pl-4 text-[12px] sm:text-sm font-semibold text-slate-700 dark:text-slate-100 ${+ props.isActive ? 'bg-sky-50 dark:bg-sky-900/30' : ''+ }`}+ >+ <button+ type="button"+ onClick={props.onToggle}+ class={`flex flex-wrap items-center gap-3 w-full text-left transition-colors duration-150 hover:text-sky-600 dark:hover:text-sky-400 ${+ isOffline() ? 'opacity-60' : ''+ } ${props.isActive ? 'text-sky-700 dark:text-sky-300' : ''}`}+ title={isOnline() ? 'Online' : isOffline() ? 'Offline' : 'Degraded'}+ >+ {/* Expand/collapse arrow */}+ <svg+ class={`h-4 w-4 transition-transform duration-200 ${props.isExpanded ? 'rotate-90' : ''}`}+ fill="none"+ viewBox="0 0 24 24"+ stroke="currentColor"+ >+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />+ </svg>++ <span>{displayName()}</span>++ {/* Status badge */}+ {(() => {+ if (isOnline()) {+ return (+ <span class="rounded px-2 py-0.5 text-[10px] font-medium whitespace-nowrap bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300">+ Online+ </span>+ );+ }+ if (isOffline()) {+ return (+ <span class="rounded px-2 py-0.5 text-[10px] font-medium whitespace-nowrap bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300">+ Offline+ </span>+ );+ }+ return (+ <span class="rounded px-2 py-0.5 text-[10px] font-medium whitespace-nowrap bg-yellow-100 text-yellow-700 dark:bg-yellow-900/40 dark:text-yellow-300">+ Degraded+ </span>+ );+ })()}++ {/* Container count */}+ <Show when={totalContainers() > 0}>+ <span class="text-[10px] text-slate-500 dark:text-slate-400">+ {runningContainers()}/{totalContainers()} containers running+ </span>+ </Show>++ {/* Service count */}+ <Show when={totalServices() > 0}>+ <span class="text-[10px] text-slate-500 dark:text-slate-400">+ {totalServices()} services+ </span>+ </Show>+ </button>+ </td>+ </tr>+ );+};++// Service Row Component (expandable for task containers)+interface ServiceRowProps {+ service: DockerService;+ hostId: string;+ tasks: DockerTreeServiceEntry['tasks'];+ containers: DockerContainer[];+ isExpanded: boolean;+ onToggle: () => void;+ isSelected?: boolean;+ rowRef?: (row: HTMLTableRowElement | null) => void;+ selectedTaskId?: string | null;+ onTaskMount?: (taskNodeId: string, row: HTMLTableRowElement) => void;+ onTaskUnmount?: (taskNodeId: string) => void;+}++const ServiceRow: Component<ServiceRowProps> = (props) => {+ const desiredTasks = () => props.service.desiredTasks ?? 0;+ const runningTasks = () => props.service.runningTasks ?? 0;+ const isHealthy = () => desiredTasks() > 0 && runningTasks() >= desiredTasks();+ const hasTasks = () => props.tasks.length > 0;++ onCleanup(() => {+ props.rowRef?.(null);+ });++ const healthBadge = () => {+ if (desiredTasks() === 0) {+ return (+ <span class="rounded px-2 py-0.5 text-[10px] font-medium whitespace-nowrap bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300">+ No tasks+ </span>+ );+ }+ if (isHealthy()) {+ return (+ <span class="rounded px-2 py-0.5 text-[10px] font-medium whitespace-nowrap bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300">+ Healthy+ </span>+ );+ }+ return (+ <span class="rounded px-2 py-0.5 text-[10px] font-medium whitespace-nowrap bg-yellow-100 text-yellow-700 dark:bg-yellow-900/40 dark:text-yellow-300">+ Degraded ({runningTasks()}/{desiredTasks()})+ </span>+ );+ };++ return (+ <>+ <tr+ ref={(row) => row && props.rowRef?.(row)}+ class={`border-t border-gray-100 dark:border-gray-800 hover:bg-gray-50 dark:hover:bg-gray-800/50 ${+ props.isSelected ? 'bg-sky-50 dark:bg-sky-900/30' : ''+ }`}+ >+ <td class="pl-8 pr-2 py-2 text-sm text-gray-900 dark:text-gray-100">+ <button+ type="button"+ onClick={props.onToggle}+ class={`flex items-center gap-2 w-full text-left ${+ props.isSelected ? 'text-sky-700 dark:text-sky-300' : ''+ }`}+ disabled={!hasTasks()}+ >+ {/* Expand arrow - only show if there are tasks */}+ <Show when={hasTasks()}>+ <svg+ class={`h-3 w-3 transition-transform duration-200 flex-shrink-0 ${props.isExpanded ? 'rotate-90' : ''}`}+ fill="none"+ viewBox="0 0 24 24"+ stroke="currentColor"+ >+ <path+ stroke-linecap="round"+ stroke-linejoin="round"+ stroke-width="2"+ d="M9 5l7 7-7 7"+ />+ </svg>+ </Show>+ <span class="font-medium truncate">{props.service.name || props.service.id}</span>+ </button>+ </td>+ <td class="px-2 py-2 text-xs text-gray-600 dark:text-gray-400">+ <div class="truncate" title={props.service.image || undefined}>+ {props.service.image || 'Image not specified'}+ </div>+ <Show when={props.service.mode}>+ <div class="mt-1 text-[10px] text-gray-500 dark:text-gray-400 whitespace-nowrap">+ {props.service.mode}+ </div>+ </Show>+ </td>+ <td class="px-2 py-2 text-xs">{healthBadge()}</td>+ </tr>++ {/* Task Containers Drawer */}+ <Show when={props.isExpanded && hasTasks()}>+ <tr class="bg-gray-50 dark:bg-gray-900/60">+ <td colSpan={3} class="px-4 py-3 pl-12">+ <div class="space-y-2">+ <h4 class="text-xs font-semibold text-gray-700 dark:text-gray-300 uppercase tracking-wide">+ Task Containers ({props.tasks.length})+ </h4>+ <div class="overflow-x-auto">+ <table class="min-w-full text-xs">+ <thead>+ <tr class="text-gray-600 dark:text-gray-400 border-b border-gray-200 dark:border-gray-700">+ <th class="text-left py-1 pr-2 font-medium">Task/Container</th>+ <th class="text-left py-1 px-2 font-medium">Node</th>+ <th class="text-left py-1 px-2 font-medium">State</th>+ <th class="text-left py-1 px-2 font-medium">CPU</th>+ <th class="text-left py-1 px-2 font-medium">Memory</th>+ <th class="text-left py-1 px-2 font-medium">Started</th>+ </tr>+ </thead>+ <tbody class="divide-y divide-gray-100 dark:divide-gray-800">+ <For each={props.tasks}>+ {(taskEntry) => {+ const task = taskEntry.task;+ const currentState = task.currentState?.toLowerCase() || 'unknown';+ const stateBadge = () => {+ if (currentState === 'running') {+ return 'bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300';+ }+ if (currentState === 'failed') {+ return 'bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300';+ }+ return 'bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300';+ };++ // Find the corresponding container for this task+ const container = findContainerForTask(props.containers, task);++ const hasCpuData = () =>+ typeof container?.cpuPercent === 'number' && !Number.isNaN(container.cpuPercent);+ const hasMemData = () =>+ typeof container?.memoryPercent === 'number' && !Number.isNaN(container.memoryPercent);+ const cpuPercent = () => (hasCpuData() ? container!.cpuPercent : 0);+ const memPercent = () => (hasMemData() ? container!.memoryPercent : 0);++ const taskLabel = () => {+ const name = task.containerName || task.containerId?.slice(0, 12) || '—';+ if (task.slot !== undefined && task.slot !== null) {+ return `${name}.${task.slot}`;+ }+ return name;+ };++ onCleanup(() => {+ props.onTaskUnmount?.(taskEntry.nodeId);+ });++ return (+ <tr+ ref={(row) => row && props.onTaskMount?.(taskEntry.nodeId, row)}+ class={`hover:bg-gray-100 dark:hover:bg-gray-800/70 ${+ props.selectedTaskId === taskEntry.nodeId ? 'bg-sky-50 dark:bg-sky-900/30' : ''+ }`}+ >+ <td class="py-0.5 pr-2 text-gray-900 dark:text-gray-100" title={task.id}>+ {taskLabel()}+ </td>+ <td class="py-0.5 px-2 text-gray-600 dark:text-gray-400">+ {task.nodeName || task.nodeId || '—'}+ </td>+ <td class="py-0.5 px-2">+ <span+ class={`rounded px-2 py-0.5 text-[10px] font-medium whitespace-nowrap ${stateBadge()}`}+ >+ {task.currentState || 'Unknown'}+ </span>+ </td>+ <td class="py-0.5 px-2">+ <Show when={hasCpuData()} fallback={<span class="text-xs text-gray-400">—</span>}>+ <MetricBar value={cpuPercent()} label={`${cpuPercent().toFixed(1)}%`} />+ </Show>+ </td>+ <td class="py-0.5 px-2">+ <Show when={hasMemData()} fallback={<span class="text-xs text-gray-400">—</span>}>+ <MetricBar value={memPercent()} label={`${memPercent().toFixed(1)}%`} type="memory" />+ </Show>+ </td>+ <td class="py-0.5 px-2 text-gray-600 dark:text-gray-400 text-[10px]">+ {(() => {+ const timestamp = task.startedAt || task.createdAt;+ if (!timestamp) return '—';+ // Handle both Unix timestamps (number) and ISO strings (from backend time.Time)+ const date = typeof timestamp === 'number'+ ? new Date(timestamp * 1000)+ : new Date(timestamp);+ return date.toLocaleString();+ })()}+ </td>+ </tr>+ );+ }}+ </For>+ </tbody>+ </table>+ </div>+ </div>+ </td>+ </tr>+ </Show>+ </>+ );+};++// Container Row Component+interface ContainerRowProps {+ container: DockerContainer;+ indent?: boolean;+ isSelected?: boolean;+ rowRef?: (row: HTMLTableRowElement | null) => void;+}++const ContainerRow: Component<ContainerRowProps> = (props) => {+ const formatPorts = () => {+ if (!props.container.ports || props.container.ports.length === 0) return '—';+ return props.container.ports+ .map((p) => {+ if (p.publicPort) {+ return `${p.publicPort}:${p.privatePort}/${p.protocol}`;+ }+ return `${p.privatePort}/${p.protocol}`;+ })+ .join(', ');+ };++ const stateBadge = () => {+ const state = props.container.state?.toLowerCase() || 'unknown';+ if (state === 'running') {+ return (+ <span class="rounded px-2 py-0.5 text-[10px] font-medium whitespace-nowrap bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300">+ Running+ </span>+ );+ }+ if (state === 'exited' || state === 'stopped') {+ return (+ <span class="rounded px-2 py-0.5 text-[10px] font-medium whitespace-nowrap bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300">+ Stopped+ </span>+ );+ }+ return (+ <span class="rounded px-2 py-0.5 text-[10px] font-medium whitespace-nowrap bg-yellow-100 text-yellow-700 dark:bg-yellow-900/40 dark:text-yellow-300">+ {state}+ </span>+ );+ };++ const hasCpuData = () =>+ typeof props.container.cpuPercent === 'number' && !Number.isNaN(props.container.cpuPercent);+ const hasMemData = () =>+ typeof props.container.memoryPercent === 'number' && !Number.isNaN(props.container.memoryPercent);+ const cpuPercent = () => (hasCpuData() ? props.container.cpuPercent! : 0);+ const memPercent = () => (hasMemData() ? props.container.memoryPercent! : 0);++ onCleanup(() => {+ props.rowRef?.(null);+ });++ return (+ <tr+ ref={(row) => row && props.rowRef?.(row)}+ class={`border-t border-gray-100 dark:border-gray-800 hover:bg-gray-50 dark:hover:bg-gray-800/50 ${+ props.isSelected ? 'bg-sky-50 dark:bg-sky-900/30' : ''+ }`}+ >+ <td+ class={`${props.indent ? 'pl-8' : 'pl-4'} pr-2 py-0.5 text-sm text-gray-900 dark:text-gray-100 truncate`}+ title={props.container.name || props.container.id}+ >+ {props.container.name || props.container.id?.slice(0, 12)}+ </td>+ <td class="px-2 py-0.5 text-xs text-gray-600 dark:text-gray-400">+ <span class="truncate max-w-[10rem]" title={props.container.image || undefined}>+ {props.container.image || 'Image not specified'}+ </span>+ </td>+ <td class="px-2 py-0.5 text-xs">{stateBadge()}</td>+ <td class="px-2 py-0.5">+ <Show when={hasCpuData()} fallback={<span class="text-xs text-gray-400">—</span>}>+ <MetricBar value={cpuPercent()} label={`${cpuPercent().toFixed(1)}%`} />+ </Show>+ </td>+ <td class="px-2 py-0.5 w-[100px]">+ <Show when={hasMemData()} fallback={<span class="text-xs text-gray-400">—</span>}>+ <MetricBar value={memPercent()} label={`${memPercent().toFixed(1)}%`} type="memory" />+ </Show>+ </td>+ <td class="px-2 py-0.5 text-xs text-gray-600 dark:text-gray-400 truncate max-w-[10rem]" title={formatPorts()}>+ <span class="truncate">{formatPorts()}</span>+ </td>+ </tr>+ );+};++export const DockerUnifiedTable: Component<DockerUnifiedTableProps> = (props) => {+ // Track expanded state for each host+ const getHostExpandState = (hostId: string) => {+ if (!hostExpandState.has(hostId)) {+ hostExpandState.set(hostId, true);+ }+ if (!hostExpandSignals.has(hostId)) {+ hostExpandSignals.set(+ hostId,+ createSignal(hostExpandState.get(hostId) ?? true),+ );+ }++ const [isExpanded, setIsExpanded] = hostExpandSignals.get(hostId)!;++ const setExpanded = (value: boolean) =>+ setIsExpanded(() => {+ hostExpandState.set(hostId, value);+ return value;+ });++ return {+ isExpanded,+ toggle: () =>+ setIsExpanded((prev) => {+ const next = !prev;+ hostExpandState.set(hostId, next);+ return next;+ }),+ setExpanded,+ };+ };++ // Track expanded state for each service+ const getServiceExpandState = (serviceKey: string) => {+ if (!serviceExpandSignals.has(serviceKey)) {+ serviceExpandSignals.set(+ serviceKey,+ createSignal(serviceExpandState.get(serviceKey) ?? false),+ );+ }++ const [isExpanded, setIsExpanded] = serviceExpandSignals.get(serviceKey)!;++ const setExpanded = (value: boolean) =>+ setIsExpanded(() => {+ serviceExpandState.set(serviceKey, value);+ return value;+ });++ return {+ isExpanded,+ toggle: () =>+ setIsExpanded((prev) => {+ const next = !prev;+ serviceExpandState.set(serviceKey, next);+ return next;+ }),+ setExpanded,+ };+ };++ const normalizeContainerState = (state?: string | null, status?: string | null) => {+ const lowerState = state?.toLowerCase().trim();+ if (lowerState) return lowerState;+ const lowerStatus = status?.toLowerCase().trim();+ if (!lowerStatus) return '';+ if (lowerStatus.startsWith('up')) return 'running';+ if (lowerStatus.startsWith('exited')) return 'exited';+ if (lowerStatus.startsWith('created')) return 'created';+ if (lowerStatus.startsWith('paused')) return 'paused';+ if (lowerStatus.includes('restarting')) return 'restarting';+ if (lowerStatus.includes('unhealthy')) return 'unhealthy';+ if (lowerStatus.includes('dead')) return 'dead';+ if (lowerStatus.includes('removing')) return 'removing';+ return lowerStatus;+ };++ const matchesContainerStateFilter = (filterValue: string, container?: DockerContainer | null) => {+ if (!container) return false;+ const state = normalizeContainerState(container.state, container.status);+ if (filterValue === 'running') {+ return state === 'running';+ }+ if (filterValue === 'stopped') {+ return STOPPED_CONTAINER_STATES.has(state);+ }+ if (filterValue === 'error') {+ return ERROR_CONTAINER_STATES.has(state);+ }+ return true;+ };++ const matchesTaskStateFilter = (filterValue: string, task: DockerTask, container?: DockerContainer | null) => {+ if (!filterValue) return true;+ if (container && matchesContainerStateFilter(filterValue, container)) {+ return true;+ }++ const current = task.currentState?.toLowerCase() ?? '';+ if (filterValue === 'running') {+ return current === 'running';+ }+ if (filterValue === 'stopped') {+ return current === 'complete' || current === 'shutdown' || current === 'stopped';+ }+ if (filterValue === 'error') {+ return current === 'failed' || current === 'error';+ }+ return true;+ };++ const hostMatchesFilter = (host: DockerHost) => {+ const filter = props.statsFilter;+ if (!filter || filter.type !== 'host-status') {+ return true;+ }+ const status = host.status?.toLowerCase() ?? 'unknown';+ switch (filter.value) {+ case 'offline':+ return OFFLINE_HOST_STATUSES.has(status);+ case 'degraded':+ return DEGRADED_HOST_STATUSES.has(status);+ case 'online':+ return status === 'online';+ default:+ return true;+ }+ };++ // Parse search terms+ const searchTerms = createMemo(() => {+ const term = props.searchTerm || '';+ return term+ .toLowerCase()+ .split(/[\s,]+/)+ .map((t) => t.trim())+ .filter(Boolean);+ });++ // Check if a container matches search terms+ const containerMatchesSearch = (host: DockerHost, container: DockerContainer) => {+ const terms = searchTerms();+ if (terms.length === 0) return true;++ return terms.every((term) => {+ const [prefix, value] = term.includes(':') ? term.split(/:(.+)/) : [null, term];+ const target = value || term;++ const tokens = [+ container.name,+ container.image,+ container.id,+ container.state,+ container.status,+ host.displayName,+ host.hostname,+ ];++ const hasToken = (list: (string | undefined)[]) =>+ list+ .filter(Boolean)+ .some((entry) => entry!.toLowerCase().includes(target));++ if (prefix) {+ switch (prefix) {+ case 'host':+ return hasToken([host.displayName, host.hostname]);+ case 'name':+ return hasToken([container.name]);+ case 'image':+ return hasToken([container.image]);+ case 'state':+ return hasToken([container.state, container.status]);+ case 'id':+ return hasToken([container.id]);+ default:+ return hasToken(tokens);+ }+ }++ return hasToken(tokens);+ });+ };++ // Check if a service matches search terms+ const serviceMatchesSearch = (host: DockerHost, service: DockerService) => {+ const terms = searchTerms();+ if (terms.length === 0) return true;++ return terms.every((term) => {+ const [prefix, value] = term.includes(':') ? term.split(/:(.+)/) : [null, term];+ const target = value || term;++ const tokens = [+ service.name,+ service.id,+ service.image,+ host.displayName,+ host.hostname,+ ];++ const hasToken = (list: (string | undefined)[]) =>+ list+ .filter(Boolean)+ .some((entry) => entry!.toLowerCase().includes(target));++ if (prefix) {+ switch (prefix) {+ case 'host':+ return hasToken([host.displayName, host.hostname]);+ case 'name':+ case 'service':+ return hasToken([service.name, service.id]);+ case 'image':+ return hasToken([service.image]);+ default:+ return hasToken(tokens);+ }+ }++ return hasToken(tokens);+ });+ };++ // Sort hosts alphabetically+ const sortedHosts = createMemo(() => {+ const hosts = props.hosts || [];+ return [...hosts].sort((a, b) => {+ const aName = a.displayName || a.hostname || a.id || '';+ const bName = b.displayName || b.hostname || b.id || '';+ return aName.localeCompare(bName);+ });+ });++ const containerFilterValue = () =>+ props.statsFilter?.type === 'container-state' ? props.statsFilter.value : null;++const visibleHosts = createMemo<DockerTreeHostEntry[]>(() => {+ const results: DockerTreeHostEntry[] = [];+ const hosts = sortedHosts();+ const filterValue = containerFilterValue();++ hosts.forEach((host, index) => {+ if (!hostMatchesFilter(host)) {+ return;+ }++ const hostId =+ host.id ||+ host.hostname ||+ host.displayName ||+ `host-${index}`;++ const hostContainers = host.containers || [];+ const hostTasks = host.tasks || [];++ const referencedContainers = new Set<string>();+ hostTasks.forEach((task) => {+ if (task.containerId) referencedContainers.add(task.containerId);+ if (task.containerName) referencedContainers.add(task.containerName);+ });++ const standalone = hostContainers+ .filter((container) => {+ const id = container.id || '';+ const name = container.name || '';++ if (referencedContainers.has(id) || referencedContainers.has(name)) {+ return false;+ }++ if (!containerMatchesSearch(host, container)) {+ return false;+ }++ if (filterValue && !matchesContainerStateFilter(filterValue, container)) {+ return false;+ }++ return true;+ })+ .map((container, idx) => ({+ container,+ nodeId: container.id+ ? `${hostId}:container:${container.id}`+ : container.name+ ? `${hostId}:container:${container.name}`+ : `${hostId}:container:${idx}`,+ }));++ const services = (host.services || []).reduce<DockerTreeServiceEntry[]>((rows, service) => {+ if (!serviceMatchesSearch(host, service)) {+ return rows;+ }++ const filteredTasks = hostTasks.filter((task) => {+ const matchesService =+ (task.serviceId && task.serviceId === service.id) ||+ (!task.serviceId && task.serviceName && task.serviceName === service.name);+ if (!matchesService) return false;++ if (!filterValue) return true;+ const container = findContainerForTask(hostContainers, task);+ return matchesTaskStateFilter(filterValue, task, container);+ });++ if (filterValue && filteredTasks.length === 0) {+ return rows;+ }++ const identifier = service.id || service.name || 'service';+ const serviceKey = `${hostId}:${identifier}`;++ const tasks = filteredTasks.map((task, idx) => ({+ task,+ nodeId: getTaskNodeId(serviceKey, task, idx),+ }));++ rows.push({+ key: serviceKey,+ service,+ tasks,+ });++ return rows;+ }, []);++ if (services.length === 0 && standalone.length === 0) {+ return;+ }++ results.push({+ host,+ hostId,+ containers: hostContainers,+ services,+ standaloneContainers: standalone,+ });+ });++ return results;+});++ const [selectedNode, setSelectedNode] = createSignal<DockerTreeSelection | null>(null);+ const [isMobileTreeOpen, setIsMobileTreeOpen] = createSignal(false);++ const displayedHosts = createMemo(() => {+ const hosts = visibleHosts();+ const selection = selectedNode();+ if (!selection) return hosts;+ if (selection.type === 'host') {+ const match = hosts.find((host) => host.hostId === selection.hostId);+ return match ? [match] : hosts;+ }+ return hosts.filter((host) => host.hostId === selection.hostId);+ });++ const hostRefs = new Map<string, HTMLElement>();+ const serviceRefs = new Map<string, HTMLTableRowElement>();+ const taskRefs = new Map<string, HTMLTableRowElement>();+ const containerRefs = new Map<string, HTMLTableRowElement>();++ const assignHostRef = (hostId: string, el: HTMLElement | null | undefined) => {+ if (el) {+ hostRefs.set(hostId, el);+ } else {+ hostRefs.delete(hostId);+ }+ };++ const assignServiceRef = (serviceKey: string, el: HTMLTableRowElement | null | undefined) => {+ if (el) {+ serviceRefs.set(serviceKey, el);+ } else {+ serviceRefs.delete(serviceKey);+ }+ };++ const registerTaskRef = (nodeId: string, row: HTMLTableRowElement) => {+ taskRefs.set(nodeId, row);+ };++ const unregisterTaskRef = (nodeId: string) => {+ taskRefs.delete(nodeId);+ };++ const assignContainerRef = (nodeId: string, el: HTMLTableRowElement | null | undefined) => {+ if (el) {+ containerRefs.set(nodeId, el);+ } else {+ containerRefs.delete(nodeId);+ }+ };++ const scrollToSelection = (selection: DockerTreeSelection, smooth = true) => {+ if (typeof window === 'undefined') return false;++ const verticalScroll = (+ element?: Element | null,+ block: ScrollLogicalPosition = 'nearest',+ ) => {+ if (!element) return false;+ const rect = element.getBoundingClientRect();+ const topAllowance = 96;+ const bottomAllowance = window.innerHeight - 32;++ if (rect.top >= topAllowance && rect.bottom <= bottomAllowance) {+ return true;+ }++ element.scrollIntoView({+ behavior: smooth ? 'smooth' : 'auto',+ block,+ inline: 'nearest',+ });+ return true;+ };++ if (selection.type === 'host') {+ return verticalScroll(hostRefs.get(selection.hostId), 'start');+ }++ if (selection.type === 'service') {+ return verticalScroll(serviceRefs.get(selection.id), 'nearest');+ }++ if (selection.type === 'task') {+ return verticalScroll(taskRefs.get(selection.id), 'center');+ }++ if (selection.type === 'container') {+ return verticalScroll(containerRefs.get(selection.id), 'nearest');+ }++ return false;+ };++ const handleTreeSelect = (selection: DockerTreeSelection) => {+ batch(() => {+ setSelectedNode(selection);++ const hostState = getHostExpandState(selection.hostId);+ hostState.setExpanded(true);++ if (selection.type === 'task') {+ const serviceState = getServiceExpandState(selection.serviceKey);+ serviceState.setExpanded(true);+ }+ });++ setIsMobileTreeOpen(false);+ };++ const buildSelectionFingerprint = (selection: DockerTreeSelection) => {+ switch (selection.type) {+ case 'host':+ return `host:${selection.hostId}`;+ case 'service':+ return `service:${selection.hostId}:${selection.id}`;+ case 'task':+ return `task:${selection.hostId}:${selection.serviceKey}:${selection.id}`;+ case 'container':+ return `container:${selection.hostId}:${selection.id}`;+ default:+ return '';+ }+ };++ let lastScrollFingerprint = '';++ const attemptScrollToSelection = (+ selection: DockerTreeSelection,+ fingerprint: string,+ remainingAttempts = 8,+ ) => {+ if (remainingAttempts <= 0) return;+ const didScroll = scrollToSelection(selection, remainingAttempts === 8);+ if (didScroll) {+ lastScrollFingerprint = fingerprint;+ } else if (typeof window !== 'undefined') {+ requestAnimationFrame(() =>+ attemptScrollToSelection(selection, fingerprint, remainingAttempts - 1),+ );+ }+ };++ createEffect(() => {+ const selection = selectedNode();+ if (!selection) return;+ const hosts = visibleHosts();+ const hostEntry = hosts.find((entry) => entry.hostId === selection.hostId);+ if (!hostEntry) {+ setSelectedNode(null);+ return;+ }++ if (selection.type === 'service') {+ const exists = hostEntry.services.some((service) => service.key === selection.id);+ if (!exists) {+ setSelectedNode({ type: 'host', hostId: hostEntry.hostId, id: hostEntry.hostId });+ return;+ }+ } else if (selection.type === 'task') {+ const serviceEntry = hostEntry.services.find((service) => service.key === selection.serviceKey);+ if (!serviceEntry) {+ setSelectedNode({ type: 'host', hostId: hostEntry.hostId, id: hostEntry.hostId });+ return;+ }+ const taskExists = serviceEntry.tasks.some((task) => task.nodeId === selection.id);+ if (!taskExists) {+ setSelectedNode({ type: 'service', hostId: hostEntry.hostId, id: serviceEntry.key });+ return;+ }+ } else if (selection.type === 'container') {+ const exists = hostEntry.standaloneContainers.some((container) => container.nodeId === selection.id);+ if (!exists) {+ setSelectedNode({ type: 'host', hostId: hostEntry.hostId, id: hostEntry.hostId });+ return;+ }+ }++ const fingerprint = buildSelectionFingerprint(selection);+ if (!fingerprint || fingerprint === lastScrollFingerprint) return;++ attemptScrollToSelection(selection, fingerprint);+ });++ const hasVisibleHosts = createMemo(() => visibleHosts().length > 0);++ return (+ <div class="flex flex-col gap-4 lg:flex-row">+ <Show when={hasVisibleHosts()}>+ <div class="flex justify-end lg:hidden">+ <button+ type="button"+ onClick={() => setIsMobileTreeOpen(true)}+ class="inline-flex items-center gap-2 rounded-md border border-slate-300 bg-white px-3 py-1.5 text-sm font-medium text-slate-600 shadow-sm transition hover:border-slate-400 hover:text-slate-700 dark:border-slate-600 dark:bg-slate-800 dark:text-slate-200 dark:hover:border-slate-500"+ aria-label="Browse Docker hosts"+ >+ <svg class="h-4 w-4" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">+ <path d="M4 4h12v2H4V4zm0 5h12v2H4V9zm0 5h12v2H4v-2z" />+ </svg>+ Browse Hosts+ </button>+ </div>+ </Show>++ <Show when={hasVisibleHosts()}>+ <aside class="hidden lg:block lg:w-72 lg:flex-shrink-0 lg:sticky lg:top-20 lg:self-start">+ <DockerTree+ hosts={visibleHosts()}+ selected={selectedNode()}+ onSelect={handleTreeSelect}+ getHostState={getHostExpandState}+ getServiceState={getServiceExpandState}+ />+ </aside>+ </Show>++ <Show when={hasVisibleHosts() && isMobileTreeOpen()}>+ <div class="lg:hidden">+ <div+ class="fixed inset-0 z-40 bg-slate-900/40 backdrop-blur-sm"+ onClick={() => setIsMobileTreeOpen(false)}+ />+ <aside class="fixed inset-y-0 left-0 z-50 flex w-72 max-w-full flex-col bg-white shadow-xl dark:bg-slate-900">+ <div class="flex items-center justify-between border-b border-slate-200 px-4 py-3 dark:border-slate-700">+ <h2 class="text-sm font-semibold text-slate-700 dark:text-slate-200">Docker Hosts</h2>+ <button+ type="button"+ class="rounded-md p-1 text-slate-500 transition hover:text-slate-700 dark:text-slate-300 dark:hover:text-slate-100"+ onClick={() => setIsMobileTreeOpen(false)}+ aria-label="Close host navigation"+ >+ <svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">+ <path+ fill-rule="evenodd"+ d="M10 8.586l4.95-4.95 1.414 1.414L11.414 10l4.95 4.95-1.414 1.414L10 11.414l-4.95 4.95-1.414-1.414L8.586 10l-4.95-4.95L5.05 3.636 10 8.586z"+ clip-rule="evenodd"+ />+ </svg>+ </button>+ </div>+ <div class="flex-1 overflow-y-auto px-2 pb-6">+ <DockerTree+ hosts={visibleHosts()}+ selected={selectedNode()}+ onSelect={handleTreeSelect}+ getHostState={getHostExpandState}+ getServiceState={getServiceExpandState}+ />+ </div>+ </aside>+ </div>+ </Show>++ <div class="flex-1 min-w-0 space-y-6">+ <For each={displayedHosts()}>+ {(entry) => {+ const hostState = getHostExpandState(entry.hostId);+ const currentSelection = () => selectedNode();+ const isHostActive = () => currentSelection()?.hostId === entry.hostId;++ const displayedServices = createMemo(() => {+ const selection = currentSelection();+ if (!selection || selection.type === 'host') return entry.services;+ if (selection.type === 'service') {+ return entry.services.filter((service) => service.key === selection.id);+ }+ if (selection.type === 'task') {+ return entry.services.filter((service) => service.key === selection.serviceKey);+ }+ return [];+ });++ const displayedStandaloneContainers = createMemo(() => {+ const selection = currentSelection();+ if (!selection || selection.type === 'host') return entry.standaloneContainers;+ if (selection.type === 'container') {+ return entry.standaloneContainers.filter((container) => container.nodeId === selection.id);+ }+ return [];+ });++ const shouldShowServices = createMemo(() => displayedServices().length > 0);+ const shouldShowContainers = createMemo(() => displayedStandaloneContainers().length > 0);++ return (+ <section+ id={`host-${entry.hostId}`}+ ref={(el) => assignHostRef(entry.hostId, el)}+ class="space-y-4 scroll-mt-28 min-w-0"+ >+ <Card+ padding="none"+ class={`overflow-hidden ${isHostActive() ? 'ring-1 ring-sky-400' : ''}`}+ >+ <table class="w-full border-collapse">+ <tbody>+ <DockerHostHeader+ host={entry.host}+ colspan={6}+ isExpanded={hostState.isExpanded()}+ onToggle={hostState.toggle}+ isActive={isHostActive()}+ />+ </tbody>+ </table>+ </Card>++ <Show when={hostState.isExpanded()}>+ <div class="space-y-4">+ <Show when={shouldShowServices()}>+ <Card padding="none" class="overflow-hidden">+ <ScrollableTable persistKey={`services-${entry.hostId}`} minWidth="680px">+ <table class="w-full border-collapse">+ <thead>+ <tr class="bg-gray-50 dark:bg-gray-700/50 text-gray-600 dark:text-gray-300 border-b border-gray-200 dark:border-gray-600">+ <th class="pl-4 pr-2 py-1 text-left text-[11px] sm:text-xs font-medium uppercase tracking-wider">+ Service+ </th>+ <th class="px-2 py-1 text-left text-[11px] sm:text-xs font-medium uppercase tracking-wider">+ Image+ </th>+ <th class="px-2 py-1 text-left text-[11px] sm:text-xs font-medium uppercase tracking-wider">+ Status+ </th>+ </tr>+ </thead>+ <tbody class="divide-y divide-gray-200 dark:divide-gray-700">+ <For each={displayedServices()}>+ {(serviceEntry) => {+ const serviceState = getServiceExpandState(serviceEntry.key);+ const serviceSelected = () => {+ const selection = selectedNode();+ if (!selection) return false;+ if (selection.type === 'service') {+ return selection.id === serviceEntry.key;+ }+ if (selection.type === 'task') {+ return selection.serviceKey === serviceEntry.key;+ }+ return false;+ };+ const selectedTaskId = () => {+ const selection = selectedNode();+ if (selection?.type === 'task' && selection.serviceKey === serviceEntry.key) {+ return selection.id;+ }+ return null;+ };++ onCleanup(() => {+ serviceRefs.delete(serviceEntry.key);+ });++ return (+ <ServiceRow+ service={serviceEntry.service}+ hostId={entry.hostId}+ tasks={serviceEntry.tasks}+ containers={entry.containers}+ isExpanded={serviceState.isExpanded()}+ onToggle={serviceState.toggle}+ isSelected={serviceSelected()}+ rowRef={(row) => assignServiceRef(serviceEntry.key, row)}+ selectedTaskId={selectedTaskId()}+ onTaskMount={registerTaskRef}+ onTaskUnmount={unregisterTaskRef}+ />+ );+ }}+ </For>+ </tbody>+ </table>+ </ScrollableTable>+ </Card>+ </Show>++ <Show when={shouldShowContainers()}>+ <Card padding="none" class="overflow-hidden">+ <ScrollableTable persistKey={`containers-${entry.hostId}`}>+ <table class="w-full border-collapse">+ <thead>+ <tr class="bg-gray-50 dark:bg-gray-700/50 text-gray-600 dark:text-gray-300 border-b border-gray-200 dark:border-gray-600">+ <th class="pl-4 pr-2 py-1 text-left text-[11px] sm:text-xs font-medium uppercase tracking-wider">+ Container+ </th>+ <th class="px-2 py-1 text-left text-[11px] sm:text-xs font-medium uppercase tracking-wider">+ Image+ </th>+ <th class="px-2 py-1 text-left text-[11px] sm:text-xs font-medium uppercase tracking-wider">+ Status+ </th>+ <th class="px-2 py-1 text-left text-[11px] sm:text-xs font-medium uppercase tracking-wider">+ CPU+ </th>+ <th class="px-2 py-1 text-left text-[11px] sm:text-xs.font-medium uppercase tracking-wider">+ Memory+ </th>+ <th class="px-2 py-1 text-left text-[11px] sm:text-xs font-medium uppercase tracking-wider">+ Ports+ </th>+ </tr>+ </thead>+ <tbody class="divide-y divide-gray-200 dark:divide-gray-700">+ <For each={displayedStandaloneContainers()}>+ {(containerEntry) => {+ const isContainerSelected = () =>+ selectedNode()?.type === 'container' &&+ selectedNode()?.id === containerEntry.nodeId;++ return (+ <ContainerRow+ container={containerEntry.container}+ indent={false}+ isSelected={isContainerSelected()}+ rowRef={(row) => assignContainerRef(containerEntry.nodeId, row)}+ />+ );+ }}+ </For>+ </tbody>+ </table>+ </ScrollableTable>+ </Card>+ </Show>+ </div>+ </Show>+ </section>+ );+ }}+ </For>+ </div>+ </div>+ );+};diff --git a/frontend-modern/src/components/FirstRunSetup.tsx b/frontend-modern/src/components/FirstRunSetup.tsxindex 7cf198ce84..239e4350c6 100644--- a/frontend-modern/src/components/FirstRunSetup.tsx+++ b/frontend-modern/src/components/FirstRunSetup.tsx@@ -8,7 +8,9 @@ import { SectionHeader } from '@/components/shared/SectionHeader';import { showTokenReveal } from '@/stores/tokenReveal';import type { APITokenRecord } from '@/api/security';-export const FirstRunSetup: Component = () => {+export const FirstRunSetup: Component<{ force?: boolean; showLegacyBanner?: boolean }> = (+ props,+) => {const [username, setUsername] = createSignal('admin');const [password, setPassword] = createSignal('');const [confirmPassword, setConfirmPassword] = createSignal('');@@ -110,6 +112,7 @@ export const FirstRunSetup: Component = () => {username: username(),password: finalPassword,apiToken: token,+ force: props.force ?? false,}),});@@ -214,6 +217,20 @@ IMPORTANT: Keep these credentials secure!return (<div class="min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100 dark:from-gray-900 dark:to-gray-800 flex items-center justify-center p-4"><div class="w-full max-w-2xl">+ <Show when={props.showLegacyBanner}>+ <div class="mb-6 rounded-xl border border-amber-300 bg-amber-50/80 dark:border-amber-700 dark:bg-amber-900/40 p-4 text-amber-900 dark:text-amber-100">+ <h2 class="text-lg font-semibold mb-2">Authentication forced off via environment</h2>+ <p class="text-sm mb-3">+ Pulse detected the legacy <code class="font-mono text-xs">DISABLE_AUTH</code> flag. Complete the+ setup below to rotate credentials, then remove the environment variable and restart Pulse.+ </p>+ <p class="text-xs text-amber-700 dark:text-amber-200">+ If you still need a temporary bypass after rotating, create <code class="font-mono text-xs">.auth_recovery</code>+ in the Pulse data directory and restart. Remove the file and restart again once you regain access.+ </p>+ </div>+ </Show>+{/* Logo/Header */}<div class="text-center mb-8"><div class="flex items-center justify-center gap-2 mb-4">diff --git a/frontend-modern/src/components/Login.tsx b/frontend-modern/src/components/Login.tsxindex 5cccff343e..b351cdad36 100644--- a/frontend-modern/src/components/Login.tsx+++ b/frontend-modern/src/components/Login.tsx@@ -17,6 +17,10 @@ interface SecurityStatus {oidcIssuer?: string;oidcClientId?: string;oidcEnvOverrides?: Record<string, boolean>;+ disabled?: boolean;+ deprecatedDisableAuth?: boolean;+ message?: string;+ apiTokenConfigured?: boolean;}export const Login: Component<LoginProps> = (props) => {@@ -261,6 +265,10 @@ export const Login: Component<LoginProps> = (props) => {// Debug loggingconsole.log('[Login] Render - loadingAuth:', loadingAuth(), 'authStatus:', authStatus());+ const legacyDisableAuth = () => authStatus()?.deprecatedDisableAuth === true;+ const showFirstRunSetup = () =>+ authStatus()?.hasAuthentication === false || legacyDisableAuth();+return (<Showwhen={!loadingAuth()}@@ -274,7 +282,7 @@ export const Login: Component<LoginProps> = (props) => {}><Show- when={authStatus()?.hasAuthentication === false}+ when={showFirstRunSetup()}fallback={<LoginForm{...{@@ -304,7 +312,10 @@ export const Login: Component<LoginProps> = (props) => {</div>}>- <FirstRunSetup />+ <FirstRunSetup+ force={legacyDisableAuth()}+ showLegacyBanner={legacyDisableAuth()}+ /></Suspense></Show></Show>diff --git a/frontend-modern/src/components/Settings/DockerAgents.tsx b/frontend-modern/src/components/Settings/DockerAgents.tsxindex 5d87bba3af..1c8da1d0b4 100644--- a/frontend-modern/src/components/Settings/DockerAgents.tsx+++ b/frontend-modern/src/components/Settings/DockerAgents.tsx@@ -43,20 +43,6 @@ export const DockerAgents: Component = () => {const [latestRecord, setLatestRecord] = createSignal<APITokenRecord | null>(null);const [tokenName, setTokenName] = createSignal('');- const [expandedHosts, setExpandedHosts] = createSignal<Set<string>>(new Set());- const isHostExpanded = (id: string) => expandedHosts().has(id);- const toggleHostExpanded = (id: string) => {- setExpandedHosts((prev) => {- const next = new Set(prev);- if (next.has(id)) {- next.delete(id);- } else {- next.add(id);- }- return next;- });- };-const pulseUrl = () => {if (typeof window !== 'undefined') {const protocol = window.location.protocol;@@ -818,19 +804,35 @@ WantedBy=multi-user.target`;</div></Show>- <div class="flex items-center justify-between">- <h3 class="text-base font-semibold text-gray-900 dark:text-gray-100">- Reporting Docker hosts ({dockerHosts().length})- </h3>- <Show when={hiddenCount() > 0}>- <button- type="button"- onClick={() => setShowHidden(!showHidden())}- class="px-3 py-1.5 text-xs font-medium rounded transition-colors bg-gray-100 text-gray-700 hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600"+ <div class="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">+ <div>+ <h3 class="text-base font-semibold text-gray-900 dark:text-gray-100">+ Reporting Docker hosts ({dockerHosts().length})+ </h3>+ <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">+ Use this list to enroll or retire agents. For live health and troubleshooting, open the Docker monitoring view.+ </p>+ </div>+ <div class="flex flex-wrap items-center justify-end gap-2">+ <a+ href="/docker"+ class="inline-flex items-center gap-2 rounded-lg border border-blue-200 bg-blue-50 px-3 py-1.5 text-xs font-semibold text-blue-700 transition-colors hover:bg-blue-100 dark:border-blue-600/60 dark:bg-blue-900/30 dark:text-blue-200 dark:hover:bg-blue-900/50">- {showHidden() ? 'Hide' : 'Show'} hidden ({hiddenCount()})- </button>- </Show>+ <svg class="h-3.5 w-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">+ <path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7" />+ </svg>+ Open Docker monitoring+ </a>+ <Show when={hiddenCount() > 0}>+ <button+ type="button"+ onClick={() => setShowHidden(!showHidden())}+ class="px-3 py-1.5 text-xs font-medium rounded transition-colors bg-gray-100 text-gray-700 hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600"+ >+ {showHidden() ? 'Hide' : 'Show'} hidden ({hiddenCount()})+ </button>+ </Show>+ </div></div><Show@@ -862,110 +864,58 @@ WantedBy=multi-user.target`;<tr class="border-b border-gray-200 dark:border-gray-700"><th class="text-left py-3 px-4 font-medium text-gray-600 dark:text-gray-400">Host</th><th class="text-left py-3 px-4 font-medium text-gray-600 dark:text-gray-400">Status</th>- <th class="text-left py-3 px-4 font-medium text-gray-600 dark:text-gray-400">Containers</th>- <th class="text-left py-3 px-4 font-medium text-gray-600 dark:text-gray-400">Docker Version</th>- <th class="text-left py-3 px-4 font-medium text-gray-600 dark:text-gray-400">Agent Version</th>+ <th class="text-left py-3 px-4 font-medium text-gray-600 dark:text-gray-400">Agent & Docker</th><th class="text-left py-3 px-4 font-medium text-gray-600 dark:text-gray-400">Last Seen</th>- <th class="py-3 px-4" />+ <th class="text-right py-3 px-4 font-medium text-gray-600 dark:text-gray-400">Actions</th></tr></thead><tbody class="divide-y divide-gray-200 dark:divide-gray-700"><For each={dockerHosts()}>{(host) => {const isOnline = host.status?.toLowerCase() === 'online';- const runningContainers = host.containers?.filter(c => c.state?.toLowerCase() === 'running').length || 0;const displayName = getDisplayName(host);const commandStatus = host.command?.status ?? null;- const commandInProgress = commandStatus === 'queued' || commandStatus === 'dispatched' || commandStatus === 'acknowledged';+ const commandInProgress =+ commandStatus === 'queued' ||+ commandStatus === 'dispatched' ||+ commandStatus === 'acknowledged';const commandFailed = commandStatus === 'failed';const commandCompleted = commandStatus === 'completed';- const services = host.services ?? [];- const serviceCount = services.length;- const taskCount = host.tasks?.length ?? 0;- const swarm = host.swarm;- const expanded = isHostExpanded(host.id);- const unhealthyServiceCount = services.filter(service => {- const desired = service.desiredTasks ?? 0;- const running = service.runningTasks ?? 0;- return desired > 0 && running < desired;- }).length;- const missingReplicaCount = services.reduce((total, service) => {- const desired = service.desiredTasks ?? 0;- const running = service.runningTasks ?? 0;- if (desired <= 0 || running >= desired) {- return total;- }- return total + (desired - running);- }, 0);const offlineActionLabel = commandFailed? 'Force remove host': host.pendingUninstall? 'Clean up pending host': 'Remove offline host';+ const tokenRevoked = typeof host.tokenRevokedAt === 'number';+ const tokenRevokedRelative = tokenRevoked ? formatRelativeTime(host.tokenRevokedAt!) : '';return (- <>- <tr class={`${isOnline ? 'bg-white dark:bg-gray-900' : 'bg-gray-50 dark:bg-gray-800/50 opacity-60'}`}>- <td class="py-3 px-4">- <div class="font-medium text-gray-900 dark:text-gray-100">{host.displayName}</div>- <div class="text-xs text-gray-500 dark:text-gray-400">{host.hostname}</div>- <Show when={host.os || host.architecture}>- <div class="text-xs text-gray-400 dark:text-gray-500 mt-1">- {host.os}- <Show when={host.os && host.architecture}>- <span class="mx-1">•</span>- </Show>- {host.architecture}- </div>- </Show>- <Show when={swarm || serviceCount > 0}>- <div class="mt-2 flex flex-wrap items-center gap-2 text-xs text-gray-500 dark:text-gray-400">- <Show when={swarm}>- <span- class={`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-semibold uppercase tracking-wide ${- swarm?.nodeRole === 'manager'- ? 'bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-200'- : 'bg-gray-200 text-gray-700 dark:bg-gray-700 dark:text-gray-200'- }`}- >- {swarm?.nodeRole ?? 'unknown'}- </span>- <span>scope: {swarm?.scope ?? 'node'}</span>- </Show>- <span>services: {serviceCount}</span>- <span>tasks: {taskCount}</span>- <Show when={serviceCount > 0}>- <span- class={`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide ${- unhealthyServiceCount > 0- ? 'bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300'- : 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-200'- }`}- title={- unhealthyServiceCount > 0- ? `${unhealthyServiceCount} service(s) missing ${missingReplicaCount} replica(s)`- : 'All reported services are meeting their desired replica count'- }- >- {unhealthyServiceCount > 0- ? `${unhealthyServiceCount} degraded`- : 'All healthy'}- </span>- </Show>- </div>- </Show>- <Show when={swarm || serviceCount > 0 || taskCount > 0}>- <button- type="button"- class="mt-2 text-xs font-semibold text-blue-600 hover:text-blue-700 focus:outline-none disabled:opacity-50"- onClick={() => toggleHostExpanded(host.id)}- >- {expanded ? 'Hide details' : 'Show details'}- </button>- </Show>- </td>- <td class="py-3 px-4">- <div class="flex items-center gap-2">+ <tr class={`${isOnline ? 'bg-white dark:bg-gray-900' : 'bg-gray-50 dark:bg-gray-800/50 opacity-60'}`}>+ <td class="py-3 px-4 align-top">+ <div class="font-medium text-gray-900 dark:text-gray-100">{displayName}</div>+ <div class="text-xs text-gray-500 dark:text-gray-400">{host.hostname}</div>+ <Show when={host.os || host.architecture}>+ <div class="mt-1 text-xs text-gray-400 dark:text-gray-500">+ {host.os}+ <Show when={host.os && host.architecture}>+ <span class="mx-1">•</span>+ </Show>+ {host.architecture}+ </div>+ </Show>+ <Show when={host.hidden}>+ <span class="mt-2 inline-flex items-center rounded-full bg-gray-200 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-gray-700 dark:bg-gray-700 dark:text-gray-200">+ Hidden+ </span>+ </Show>+ <Show when={tokenRevoked}>+ <div class="mt-2 text-xs text-amber-600 dark:text-amber-300">+ Token revoked {tokenRevokedRelative}+ </div>+ </Show>+ </td>+ <td class="py-3 px-4 align-top">+ <div class="flex flex-wrap items-center gap-2"><spanclass={`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${isOnline@@ -977,7 +927,7 @@ WantedBy=multi-user.target`;</span><Show when={commandInProgress}><span class="inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium bg-yellow-100 text-yellow-700 dark:bg-yellow-900/40 dark:text-yellow-300">- <svg class="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">+ <svg class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>Stopping@@ -985,7 +935,7 @@ WantedBy=multi-user.target`;</Show><Show when={commandFailed}><span class="inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300">- <svg class="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">+ <svg class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.364 5.636l-12.728 12.728M5.636 5.636l12.728 12.728" /></svg>Failed@@ -993,38 +943,39 @@ WantedBy=multi-user.target`;</Show><Show when={commandCompleted}><span class="inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300">- <svg class="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">+ <svg class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" /></svg>Stopped</span></Show></div>+ <Show when={host.pendingUninstall}>+ <div class="mt-2 text-xs text-gray-500 dark:text-gray-400">+ Stop command queued; waiting for acknowledgement.+ </div>+ </Show></td>- <td class="py-3 px-4">- <div class="text-gray-900 dark:text-gray-100">- {runningContainers} / {host.containers?.length || 0}+ <td class="py-3 px-4 align-top">+ <div class="text-sm font-medium text-gray-900 dark:text-gray-100">+ {host.dockerVersion ? `Docker ${host.dockerVersion}` : 'Docker version unavailable'}</div>- <div class="text-xs text-gray-500 dark:text-gray-400">running</div>- </td>- <td class="py-3 px-4">- <div class="text-gray-900 dark:text-gray-100">{host.dockerVersion || '—'}</div>- </td>- <td class="py-3 px-4">- <div class="text-gray-900 dark:text-gray-100">{host.agentVersion || '—'}</div><div class="text-xs text-gray-500 dark:text-gray-400">- every {host.intervalSeconds || 0}s+ Agent {host.agentVersion ? `v${host.agentVersion}` : 'not reporting'}+ <Show when={host.intervalSeconds}>+ <span> (every {host.intervalSeconds}s)</span>+ </Show></div></td>- <td class="py-3 px-4">+ <td class="py-3 px-4 align-top"><div class="text-gray-900 dark:text-gray-100">{host.lastSeen ? formatRelativeTime(host.lastSeen) : '—'}</div><div class="text-xs text-gray-500 dark:text-gray-400">- {host.lastSeen ? formatAbsoluteTime(host.lastSeen) : '—'}+ {host.lastSeen ? formatAbsoluteTime(host.lastSeen) : 'Awaiting first report'}</div></td>- <td class="py-3 px-4 text-right">+ <td class="py-3 px-4 text-right align-top"><Showwhen={host.hidden}fallback={@@ -1032,39 +983,42 @@ WantedBy=multi-user.target`;<Show when={commandInProgress || commandCompleted}><buttontype="button"- class="text-xs font-semibold text-blue-600 disabled:opacity-50 disabled:cursor-not-allowed"+ class="text-xs font-semibold text-blue-600 disabled:cursor-not-allowed disabled:opacity-50"disabled>{commandCompleted ? 'Cleaning up…' : 'Stopping…'}</button></Show>- <Show when={commandFailed} fallback={- <Show- when={!isOnline}- fallback={+ <Show+ when={commandFailed}+ fallback={+ <Show+ when={!isOnline}+ fallback={+ <button+ type="button"+ class="text-xs font-semibold text-red-600 hover:text-red-700 disabled:cursor-not-allowed disabled:opacity-50"+ onClick={() => openRemoveModal(host)}+ disabled={isRemovingHost(host.id)}+ >+ {isRemovingHost(host.id) ? 'Working…' : 'Remove'}+ </button>+ }+ ><buttontype="button"- class="text-xs font-semibold text-red-600 hover:text-red-700 disabled:opacity-50 disabled:cursor-not-allowed"- onClick={() => openRemoveModal(host)}+ class="text-xs font-semibold text-blue-600 hover:text-blue-700 disabled:cursor-not-allowed disabled:opacity-50"+ onClick={() => handleCleanupOfflineHost(host.id, displayName)}disabled={isRemovingHost(host.id)}>- {isRemovingHost(host.id) ? 'Working…' : 'Remove'}+ {isRemovingHost(host.id) ? 'Cleaning up…' : offlineActionLabel}</button>- }- >- <button- type="button"- class="text-xs font-semibold text-blue-600 hover:text-blue-700 disabled:opacity-50 disabled:cursor-not-allowed"- onClick={() => handleCleanupOfflineHost(host.id, displayName)}- disabled={isRemovingHost(host.id)}- >- {isRemovingHost(host.id) ? 'Cleaning up…' : offlineActionLabel}- </button>- </Show>- }>+ </Show>+ }+ ><buttontype="button"- class="text-xs font-semibold text-red-600 hover:text-red-700 disabled:opacity-50 disabled:cursor-not-allowed"+ class="text-xs font-semibold text-red-600 hover:text-red-700 disabled:cursor-not-allowed disabled:opacity-50"onClick={() => handleCleanupOfflineHost(host.id, displayName)}disabled={isRemovingHost(host.id)}>@@ -1076,7 +1030,7 @@ WantedBy=multi-user.target`;><buttontype="button"- class="text-xs font-semibold text-blue-600 hover:text-blue-700 disabled:opacity-50 disabled:cursor-not-allowed"+ class="text-xs font-semibold text-blue-600 hover:text-blue-700 disabled:cursor-not-allowed disabled:opacity-50"onClick={() => handleUnhideHost(host.id, displayName)}disabled={isRemovingHost(host.id)}>@@ -1085,173 +1039,8 @@ WantedBy=multi-user.target`;</Show></td></tr>- <Show when={expanded}>- <tr class="bg-gray-50 dark:bg-gray-800/40">- <td colSpan={7} class="px-4 py-4">- <div class="space-y-4 text-sm">- <Show when={swarm}>- <div class="rounded-lg border border-sky-100 bg-sky-50 px-3 py-2 text-xs text-sky-900 dark:border-sky-800 dark:bg-sky-900/40 dark:text-sky-100">- <div class="flex flex-wrap gap-3">- <div><span class="font-semibold">Role:</span> {swarm?.nodeRole ?? 'unknown'}</div>- <div><span class="font-semibold">Scope:</span> {swarm?.scope ?? 'node'}</div>- <Show when={swarm?.clusterName || swarm?.clusterId}>- <div><span class="font-semibold">Cluster:</span> {swarm?.clusterName || swarm?.clusterId}</div>- </Show>- <Show when={swarm?.error}>- <div class="text-red-600 dark:text-red-300"><span class="font-semibold">Error:</span> {swarm?.error}</div>- </Show>- </div>- </div>- </Show>-- <Show when={serviceCount > 0}>- <div class="space-y-2">- <h4 class="text-sm font-semibold text-gray-900 dark:text-gray-100">Services ({serviceCount})</h4>- <div class="grid gap-3 md:grid-cols-2 xl:grid-cols-3">- <For each={host.services}>- {(service) => {- const desired = service.desiredTasks ?? 0;- const running = service.runningTasks ?? 0;- const completed = service.completedTasks;- const missing = desired > running ? desired - running : 0;- const statusLabel =- desired <= 0- ? 'Idle'- : missing === 0- ? 'Healthy'- : missing >= desired- ? 'Down'- : 'Degraded';- const statusColor =- missing === 0- ? 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-200'- : 'bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300';-- return (- <div class="rounded-lg border border-gray-200 bg-white p-3 shadow-sm dark:border-gray-700 dark:bg-gray-900">- <div class="flex items-center justify-between gap-2">- <div class="font-semibold text-gray-900 dark:text-gray-100 truncate">{service.name || service.id}</div>- <div class="flex items-center gap-2">- <Show when={service.mode}>- <span class="text-[10px] uppercase tracking-wide text-gray-500 dark:text-gray-400">- {service.mode}- </span>- </Show>- <span- class={`inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide ${statusColor}`}- >- {statusLabel}- </span>- </div>- </div>- <div class="mt-2 space-y-1 text-xs text-gray-500 dark:text-gray-400">- <div>- Tasks: {running} / {desired}- <Show when={missing > 0}>- <span class="ml-1 text-red-600 dark:text-red-300">(-{missing})</span>- </Show>- </div>- <Show when={completed !== undefined}>- <div>Completed: {completed}</div>- </Show>- <Show when={service.stack}>- <div>Stack: {service.stack}</div>- </Show>- </div>- <Show when={service.image}>- <div class="mt-2 text-xs text-gray-500 dark:text-gray-400 truncate">{service.image}</div>- </Show>- <Show when={(service.endpointPorts?.length ?? 0) > 0}>- <div class="mt-2 text-xs text-gray-500 dark:text-gray-400">- Ports:{' '}- <For each={service.endpointPorts}>- {(port, index) => (- <span>- {index() > 0 && ', '}- {port.publishedPort ?? '—'} → {port.targetPort ?? '—'} {port.protocol ? port.protocol.toUpperCase() : ''}- </span>- )}- </For>- </div>- </Show>- <Show when={service.updateStatus?.state || service.updateStatus?.message}>- <div class="mt-2 text-xs text-gray-500 dark:text-gray-400">- Update: {service.updateStatus?.state || 'pending'}- <Show when={service.updateStatus?.message}>- <span class="ml-1">({service.updateStatus?.message})</span>- </Show>- </div>- </Show>- </div>- );- }}- </For>- </div>- </div>- </Show>-- <Show when={taskCount > 0}>- <div class="space-y-2">- <h4 class="text-sm font-semibold text-gray-900 dark:text-gray-100">Tasks ({taskCount})</h4>- <div class="overflow-x-auto rounded-lg border border-gray-200 dark:border-gray-700">- <table class="min-w-full text-xs">- <thead class="bg-gray-50 text-gray-600 dark:bg-gray-800 dark:text-gray-300">- <tr>- <th class="px-3 py-2 text-left font-semibold">Service</th>- <th class="px-3 py-2 text-left font-semibold">Slot</th>- <th class="px-3 py-2 text-left font-semibold">State</th>- <th class="px-3 py-2 text-left font-semibold">Container</th>- <th class="px-3 py-2 text-left font-semibold">Updated</th>- </tr>- </thead>- <tbody class="divide-y divide-gray-200 dark:divide-gray-700">- <For each={host.tasks}>- {(task) => (- <tr class="bg-white dark:bg-gray-900">- <td class="px-3 py-2 text-gray-700 dark:text-gray-300">{task.serviceName || task.serviceId || '—'}</td>- <td class="px-3 py-2 text-gray-700 dark:text-gray-300">{task.slot ?? '—'}</td>- <td class="px-3 py-2">- <span- class={`inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-semibold ${- task.currentState?.toLowerCase() === 'running'- ? 'bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300'- : 'bg-gray-200 text-gray-700 dark:bg-gray-700 dark:text-gray-200'- }`}- >- {task.currentState ?? 'unknown'}- </span>- </td>- <td class="px-3 py-2 text-gray-700 dark:text-gray-300">- {task.containerName || task.containerId?.slice(0, 12) || '—'}- </td>- <td class="px-3 py-2 text-gray-500 dark:text-gray-400">- {task.updatedAt- ? formatRelativeTime(task.updatedAt)- : task.startedAt- ? formatRelativeTime(task.startedAt)- : '—'}- </td>- </tr>- )}- </For>- </tbody>- </table>- </div>- </div>- </Show>-- <Show when={serviceCount === 0 && taskCount === 0}>- <div class="text-xs text-gray-500 dark:text-gray-400">- No Swarm services or tasks reported yet.- </div>- </Show>- </div>- </td>- </tr>- </Show>- </>- );- }}+ );+ }}</For></tbody></table>diff --git a/frontend-modern/src/components/Settings/QuickSecuritySetup.tsx b/frontend-modern/src/components/Settings/QuickSecuritySetup.tsxindex 3a7c10641e..5615e2eeb6 100644--- a/frontend-modern/src/components/Settings/QuickSecuritySetup.tsx+++ b/frontend-modern/src/components/Settings/QuickSecuritySetup.tsx@@ -96,6 +96,11 @@ export const QuickSecuritySetup: Component<QuickSecuritySetupProps> = (props) =>});if (!response.ok) {+ if (response.status === 401 || response.status === 403) {+ throw new Error(+ 'Pulse detected a legacy DISABLE_AUTH flag. Remove that environment flag and restart Pulse before enabling security here.',+ );+ }const error = await response.text();throw new Error(error || 'Failed to setup security');}diff --git a/frontend-modern/src/components/Settings/Settings.tsx b/frontend-modern/src/components/Settings/Settings.tsxindex 858464b895..e18c6d08f5 100644--- a/frontend-modern/src/components/Settings/Settings.tsx+++ b/frontend-modern/src/components/Settings/Settings.tsx@@ -687,6 +687,7 @@ const Settings: Component<SettingsProps> = (props) => {null,);const [showQuickSecuritySetup, setShowQuickSecuritySetup] = createSignal(false);+ const authDisabledByEnv = createMemo(() => Boolean(securityStatus()?.deprecatedDisableAuth));const [showQuickSecurityWizard, setShowQuickSecurityWizard] = createSignal(false);const formatRelativeTime = (timestamp?: number) => {@@ -973,6 +974,12 @@ const Settings: Component<SettingsProps> = (props) => {}};+ createEffect(() => {+ if (authDisabledByEnv() && showQuickSecuritySetup()) {+ setShowQuickSecuritySetup(false);+ }+ });+const updateDiscoveredNodesFromServers = (servers: RawDiscoveredServer[] | undefined | null,options: { merge?: boolean } = {},@@ -4228,23 +4235,45 @@ const Settings: Component<SettingsProps> = (props) => {</svg></div><SectionHeader title="Authentication disabled" size="sm" class="flex-1" />- <button- type="button"- onClick={() => setShowQuickSecuritySetup(!showQuickSecuritySetup())}- class="px-3 py-1.5 text-xs font-medium rounded-lg border border-amber-300 text-amber-800 bg-amber-100/50 hover:bg-amber-100 transition-colors dark:border-amber-700 dark:text-amber-200 dark:bg-amber-900/30 dark:hover:bg-amber-900/40 whitespace-nowrap"+ <Show+ when={!authDisabledByEnv()}+ fallback={+ <span class="px-3 py-1.5 text-xs font-semibold rounded-lg border border-amber-300 text-amber-800 bg-amber-100/60 dark:border-amber-700 dark:text-amber-100 dark:bg-amber-900/40 whitespace-nowrap">+ Controlled by DISABLE_AUTH+ </span>+ }>- Setup- </button>+ <button+ type="button"+ onClick={() => setShowQuickSecuritySetup(!showQuickSecuritySetup())}+ class="px-3 py-1.5 text-xs font-medium rounded-lg border border-amber-300 text-amber-800 bg-amber-100/50 hover:bg-amber-100 transition-colors dark:border-amber-700 dark:text-amber-200 dark:bg-amber-900/30 dark:hover:bg-amber-900/40 whitespace-nowrap"+ >+ Setup+ </button>+ </Show></div></div>{/* Content */}<div class="p-6"><p class="text-sm text-amber-700 dark:text-amber-300 mb-4">- DISABLE_AUTH is set, or auth isn't configured yet. Set up password authentication to protect your Pulse instance.+ <Show+ when={authDisabledByEnv()}+ fallback={+ <>+ Authentication is currently disabled. Set up password authentication to protect your Pulse instance.+ </>+ }+ >+ Authentication settings are locked by the legacy{' '}+ <code class="font-mono text-xs text-amber-800 dark:text-amber-200">+ DISABLE_AUTH+ </code>{' '}+ environment variable. Remove it from your deployment and restart Pulse before enabling security from this page.+ </Show></p>- <Show when={showQuickSecuritySetup()}>+ <Show when={showQuickSecuritySetup() && !authDisabledByEnv()}><QuickSecuritySetuponConfigured={() => {setShowQuickSecuritySetup(false);@@ -4297,13 +4326,22 @@ const Settings: Component<SettingsProps> = (props) => {>Change password</button>- <button- type="button"- onClick={() => setShowQuickSecurityWizard(!showQuickSecurityWizard())}- class="px-4 py-2 text-sm font-medium border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"+ <Show+ when={!authDisabledByEnv()}+ fallback={+ <span class="px-4 py-2 text-sm font-semibold border border-amber-300 text-amber-800 bg-amber-50 dark:border-amber-700 dark:text-amber-200 dark:bg-amber-900/30 rounded-lg">+ Remove DISABLE_AUTH to rotate credentials+ </span>+ }>- Rotate credentials- </button>+ <button+ type="button"+ onClick={() => setShowQuickSecurityWizard(!showQuickSecurityWizard())}+ class="px-4 py-2 text-sm font-medium border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"+ >+ Rotate credentials+ </button>+ </Show><div class="flex-1"></div><div class="text-xs text-gray-600 dark:text-gray-400"><span class="font-medium text-gray-800 dark:text-gray-200">User:</span>{' '}@@ -4311,7 +4349,7 @@ const Settings: Component<SettingsProps> = (props) => {</div></div>- <Show when={showQuickSecurityWizard()}>+ <Show when={!authDisabledByEnv() && showQuickSecurityWizard()}><div class="mt-4 pt-4 border-t border-gray-200 dark:border-gray-700"><QuickSecuritySetupmode="rotate"diff --git a/frontend-modern/src/components/shared/Card.tsx b/frontend-modern/src/components/shared/Card.tsxindex 2ec370877f..d343d56351 100644--- a/frontend-modern/src/components/shared/Card.tsx+++ b/frontend-modern/src/components/shared/Card.tsx@@ -33,7 +33,7 @@ export function Card(props: CardProps) {);const [local, rest] = splitProps(merged, ['tone', 'padding', 'hoverable', 'border', 'class']);- const baseClass = 'rounded-lg shadow-sm transition-shadow duration-200';+ const baseClass = 'rounded-lg shadow-sm transition-shadow duration-200 max-w-full';const toneClass = toneClassMap[local.tone];const paddingClass = paddingClassMap[local.padding];const borderClass = local.border ? 'border border-gray-200 dark:border-gray-700' : '';diff --git a/frontend-modern/src/components/shared/ScrollableTable.tsx b/frontend-modern/src/components/shared/ScrollableTable.tsxindex 387cff7f06..7e3a113e16 100644--- a/frontend-modern/src/components/shared/ScrollableTable.tsx+++ b/frontend-modern/src/components/shared/ScrollableTable.tsx@@ -5,33 +5,51 @@ interface ScrollableTableProps {children: JSX.Element;class?: string;minWidth?: string;+ persistKey?: string;}+const scrollPositions = new Map<string, number>();+export const ScrollableTable: Component<ScrollableTableProps> = (props) => {const [showLeftFade, setShowLeftFade] = createSignal(false);const [showRightFade, setShowRightFade] = createSignal(false);let scrollContainer: HTMLDivElement | undefined;- const checkScroll = () => {+ const checkScroll = (scrollLeftValue?: number) => {if (!scrollContainer) return;- const { scrollLeft, scrollWidth, clientWidth } = scrollContainer;+ const scrollLeft = scrollLeftValue ?? scrollContainer.scrollLeft;+ const { scrollWidth, clientWidth } = scrollContainer;setShowLeftFade(scrollLeft > 0);setShowRightFade(scrollLeft < scrollWidth - clientWidth - 1);};onMount(() => {- checkScroll();- window.addEventListener('resize', checkScroll);+ const initialLeft = props.persistKey ? scrollPositions.get(props.persistKey) ?? 0 : 0;+ if (scrollContainer) {+ scrollContainer.scrollLeft = initialLeft;+ }+ checkScroll(initialLeft);++ const resizeHandler = () => checkScroll();+ window.addEventListener('resize', resizeHandler);onCleanup(() => {- window.removeEventListener('resize', checkScroll);+ window.removeEventListener('resize', resizeHandler);});});createEffect(() => {if (scrollContainer) {- scrollContainer.addEventListener('scroll', checkScroll);- return () => scrollContainer?.removeEventListener('scroll', checkScroll);+ const handler = () => {+ if (!scrollContainer) return;+ const left = scrollContainer.scrollLeft;+ if (props.persistKey) {+ scrollPositions.set(props.persistKey, left);+ }+ checkScroll(left);+ };+ scrollContainer.addEventListener('scroll', handler, { passive: true });+ return () => scrollContainer?.removeEventListener('scroll', handler);}});@@ -51,7 +69,9 @@ export const ScrollableTable: Component<ScrollableTableProps> = (props) => {<style>{`.overflow-x-auto::-webkit-scrollbar { display: none; }`}</style>- <div style={{ 'min-width': props.minWidth || 'auto' }}>{props.children}</div>+ <div style={{ 'min-width': props.minWidth || 'auto' }}>+ {props.children}+ </div></div>{/* Right fade */}diff --git a/frontend-modern/src/hooks/useDebouncedValue.ts b/frontend-modern/src/hooks/useDebouncedValue.tsnew file mode 100644index 0000000000..53da585c22--- /dev/null+++ b/frontend-modern/src/hooks/useDebouncedValue.ts@@ -0,0 +1,22 @@+import { createSignal, createEffect, onCleanup, Accessor } from 'solid-js';++/**+ * Creates a debounced version of a signal value+ * @param value - The signal accessor to debounce+ * @param delay - Delay in milliseconds (default: 300ms)+ * @returns Debounced signal accessor+ */+export function useDebouncedValue<T>(value: Accessor<T>, delay: number = 300): Accessor<T> {+ const [debouncedValue, setDebouncedValue] = createSignal<T>(value());++ createEffect(() => {+ const currentValue = value();+ const timer = setTimeout(() => {+ setDebouncedValue(() => currentValue);+ }, delay);++ onCleanup(() => clearTimeout(timer));+ });++ return debouncedValue;+}diff --git a/frontend-modern/src/stores/alertsActivation.ts b/frontend-modern/src/stores/alertsActivation.tsindex ae9bcffad1..d61e229d97 100644--- a/frontend-modern/src/stores/alertsActivation.ts+++ b/frontend-modern/src/stores/alertsActivation.ts@@ -136,7 +136,3 @@ export const useAlertsActivation = () => ({deactivate,snooze,});--// Initialize on module load-refreshConfig();-refreshActiveAlerts();diff --git a/frontend-modern/src/types/api.ts b/frontend-modern/src/types/api.tsindex f9ba00e34d..26982e3d67 100644--- a/frontend-modern/src/types/api.ts+++ b/frontend-modern/src/types/api.ts@@ -207,10 +207,10 @@ export interface DockerTask {message?: string;containerId?: string;containerName?: string;- createdAt?: number;- updatedAt?: number;- startedAt?: number;- completedAt?: number;+ createdAt?: number | string; // Unix timestamp or ISO string+ updatedAt?: number | string; // Unix timestamp or ISO string+ startedAt?: number | string; // Unix timestamp or ISO string+ completedAt?: number | string; // Unix timestamp or ISO string}export interface DockerSwarmInfo {diff --git a/frontend-modern/src/types/config.ts b/frontend-modern/src/types/config.tsindex 364c8a4ede..6dc0219d90 100644--- a/frontend-modern/src/types/config.ts+++ b/frontend-modern/src/types/config.ts@@ -113,6 +113,9 @@ export interface SecurityStatus {proxyAuthLogoutURL?: string;authUsername?: string;authLastModified?: string;+ disabled?: boolean; // legacy field (removed backend support)+ deprecatedDisableAuth?: boolean;+ message?: string;}/**diff --git a/internal/api/auth.go b/internal/api/auth.goindex 02778d796b..960c804790 100644--- a/internal/api/auth.go+++ b/internal/api/auth.go@@ -186,7 +186,7 @@ func min(a, b int) int {// CheckAuth checks both basic auth and API tokenfunc CheckAuth(cfg *config.Config, w http.ResponseWriter, r *http.Request) bool {- // Check proxy auth first if configured (even if DISABLE_AUTH is true)+ // Check proxy auth first if configuredif cfg.ProxyAuthSecret != "" {if valid, username, _ := CheckProxyAuth(cfg, r); valid {// Set username in response header for frontend@@ -198,7 +198,7 @@ func CheckAuth(cfg *config.Config, w http.ResponseWriter, r *http.Request) bool}}- // Check for OIDC session cookie (even if DISABLE_AUTH is true)+ // Check for OIDC session cookieif cfg.OIDC != nil && cfg.OIDC.Enabled {if cookie, err := r.Cookie("pulse_session"); err == nil && cookie.Value != "" {if ValidateSession(cookie.Value) {@@ -212,13 +212,6 @@ func CheckAuth(cfg *config.Config, w http.ResponseWriter, r *http.Request) bool}}- // If auth is explicitly disabled, allow all access- // (but only after checking proxy and OIDC auth above)- if cfg.DisableAuth {- w.Header().Set("X-Auth-Disabled", "true")- return true- }-// If no auth is configured at all, allow access unless OIDC is enabledif cfg.AuthUser == "" && cfg.AuthPass == "" && !cfg.HasAPITokens() && cfg.ProxyAuthSecret == "" {if cfg.OIDC != nil && cfg.OIDC.Enabled {diff --git a/internal/api/diagnostics.go b/internal/api/diagnostics.goindex 360efb2cef..a4a6cc2384 100644--- a/internal/api/diagnostics.go+++ b/internal/api/diagnostics.go@@ -53,7 +53,7 @@ type DiagnosticsInfo struct {// MemorySourceStat aggregates memory-source usage per instance.type MemorySourceStat struct {- Instance string `json:"instance"`+ Instance string `json:"instance"`Source string `json:"source"`NodeCount int `json:"nodeCount"`LastUpdated string `json:"lastUpdated"`@@ -74,9 +74,9 @@ const diagnosticsCacheTTL = 45 * time.Secondvar (diagnosticsMetricsOnce sync.Once- diagnosticsCacheMu sync.RWMutex- diagnosticsCache DiagnosticsInfo- diagnosticsCacheTimestamp time.Time+ diagnosticsCacheMu sync.RWMutex+ diagnosticsCache DiagnosticsInfo+ diagnosticsCacheTimestamp time.TimediagnosticsCacheHits = prometheus.NewCounter(prometheus.CounterOpts{Namespace: "pulse",@@ -639,7 +639,7 @@ func buildAPITokenDiagnostic(cfg *config.Config, monitor *monitoring.Monitor) *A}diag := &APITokenDiagnostic{- Enabled: cfg.APITokenEnabled && !cfg.DisableAuth,+ Enabled: cfg.APITokenEnabled,TokenCount: len(cfg.APITokens),}@@ -670,9 +670,7 @@ func buildAPITokenDiagnostic(cfg *config.Config, monitor *monitoring.Monitor) *Adiag.RecommendTokenSetup = len(cfg.APITokens) == 0diag.RecommendTokenRotation = envTokens || legacyToken- if cfg.DisableAuth {- appendNote("Authentication is disabled (DISABLE_AUTH=1). Re-enable it to use per-agent API tokens.")- } else if !cfg.APITokenEnabled && len(cfg.APITokens) > 0 {+ if !cfg.APITokenEnabled && len(cfg.APITokens) > 0 {appendNote("API token authentication is currently disabled. Enable it under Settings → Security so agents can use dedicated tokens.")} else if diag.RecommendTokenSetup {appendNote("No API tokens are configured. Open Settings → Security to generate dedicated tokens for each automation or agent.")diff --git a/internal/api/router.go b/internal/api/router.goindex 6f840c9392..7372ab49ad 100644--- a/internal/api/router.go+++ b/internal/api/router.go@@ -294,47 +294,6 @@ func (r *Router) setupRoutes() {if req.Method == http.MethodGet {w.Header().Set("Content-Type", "application/json")- // Check if auth is globally disabled- if r.config.DisableAuth {- // Even with auth disabled, check for OIDC sessions- oidcCfg := r.ensureOIDCConfig()- oidcUsername := ""- if oidcCfg != nil && oidcCfg.Enabled {- if cookie, err := req.Cookie("pulse_session"); err == nil && cookie.Value != "" {- if ValidateSession(cookie.Value) {- oidcUsername = GetSessionUsername(cookie.Value)- }- }- }-- // Even with auth disabled, report API token status for API access- apiTokenHint := r.config.PrimaryAPITokenHint()-- response := map[string]interface{}{- "configured": false,- "disabled": true,- "message": "Authentication is disabled via DISABLE_AUTH environment variable",- "apiTokenConfigured": r.config.HasAPITokens(),- "apiTokenHint": apiTokenHint,- "hasAuthentication": false,- }-- // Add OIDC info if available- if oidcCfg != nil {- response["oidcEnabled"] = oidcCfg.Enabled- response["oidcIssuer"] = oidcCfg.IssuerURL- response["oidcClientId"] = oidcCfg.ClientID- response["oidcUsername"] = oidcUsername- response["oidcLogoutURL"] = oidcCfg.LogoutURL- if len(oidcCfg.EnvOverrides) > 0 {- response["oidcEnvOverrides"] = oidcCfg.EnvOverrides- }- }-- json.NewEncoder(w).Encode(response)- return- }-// Check for basic auth configuration// Check both environment variables and loaded configoidcCfg := r.ensureOIDCConfig()@@ -446,6 +405,11 @@ func (r *Router) setupRoutes() {}}+ if r.config.DisableAuthEnvDetected {+ status["deprecatedDisableAuth"] = true+ status["message"] = "DISABLE_AUTH is deprecated and no longer disables authentication. Remove the environment variable and restart Pulse to manage authentication from the UI."+ }+json.NewEncoder(w).Encode(status)} else {http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)@@ -1172,31 +1136,6 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {// Check if we need authenticationneedsAuth := true- // Check if auth is globally disabled- // BUT still check for API tokens if provided (for API access when auth is disabled)- if r.config.DisableAuth {- // Check if an API token was provided- providedToken := req.Header.Get("X-API-Token")- if providedToken == "" {- providedToken = req.URL.Query().Get("token")- }-- // If a valid API token is provided, allow access even with DisableAuth- if providedToken != "" && r.config.HasAPITokens() {- if _, ok := r.config.ValidateAPIToken(providedToken); ok {- needsAuth = false- w.Header().Set("X-Auth-Method", "api-token")- } else {- http.Error(w, "Invalid API token", http.StatusUnauthorized)- return- }- } else {- // No API token provided with DisableAuth - allow open access- needsAuth = false- w.Header().Set("X-Auth-Disabled", "true")- }- }-// Recovery mechanism: Check if recovery mode is enabledrecoveryFile := filepath.Join(r.config.DataPath, ".auth_recovery")if _, err := os.Stat(recoveryFile); err == nil {@@ -1336,10 +1275,11 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {// CSRF is only needed when using session-based auth// Only skip CSRF for initial setup when no auth is configuredskipCSRF := false- if (req.URL.Path == "/api/security/quick-setup" || req.URL.Path == "/api/security/apply-restart") &&- r.config.AuthUser == "" && r.config.AuthPass == "" {- // Only skip CSRF for initial setup and restart when no auth exists- skipCSRF = true+ if req.URL.Path == "/api/security/quick-setup" || req.URL.Path == "/api/security/apply-restart" {+ if (r.config.AuthUser == "" && r.config.AuthPass == "") || r.config.DisableAuthEnvDetected {+ // Allow bootstrap or legacy recovery runs without CSRF token+ skipCSRF = true+ }}// Skip CSRF for setup-script-url endpoint (generates temporary tokens, not a state change)if req.URL.Path == "/api/setup-script-url" {@@ -2272,7 +2212,7 @@ func (r *Router) handleState(w http.ResponseWriter, req *http.Request) {log.Debug().Msg("[DEBUG] handleState: Before auth check")// Use standard auth check (supports both basic auth and API tokens) unless auth is disabled- if !r.config.DisableAuth && !CheckAuth(r.config, w, req) {+ if !CheckAuth(r.config, w, req) {writeErrorResponse(w, http.StatusUnauthorized, "unauthorized","Authentication required", nil)returndiff --git a/internal/api/router_integration_test.go b/internal/api/router_integration_test.goindex 95da9615a2..d58f300577 100644--- a/internal/api/router_integration_test.go+++ b/internal/api/router_integration_test.go@@ -48,7 +48,6 @@ func newIntegrationServerWithConfig(t *testing.T, customize func(*config.Config)BackendPort: 7655,ConfigPath: tmpDir,DataPath: tmpDir,- DisableAuth: true,DemoMode: false,AllowedOrigins: "*",ConcurrentPolling: true,@@ -205,7 +204,6 @@ func TestProtectedEndpointsRequireAuthentication(t *testing.T) {}srv := newIntegrationServerWithConfig(t, func(cfg *config.Config) {- cfg.DisableAuth = falsecfg.AuthUser = "admin"cfg.AuthPass = passwordHash})@@ -252,7 +250,6 @@ func TestAPIOnlyModeRequiresToken(t *testing.T) {}srv := newIntegrationServerWithConfig(t, func(cfg *config.Config) {- cfg.DisableAuth = falsecfg.AuthUser = ""cfg.AuthPass = ""cfg.APITokenEnabled = true@@ -352,33 +349,6 @@ func TestConfigNodesUsesMockTopology(t *testing.T) {}}-func TestSecurityStatusReflectsDisableAuth(t *testing.T) {- srv := newIntegrationServer(t)-- res, err := http.Get(srv.server.URL + "/api/security/status")- if err != nil {- t.Fatalf("security status request failed: %v", err)- }- defer res.Body.Close()-- if res.StatusCode != http.StatusOK {- t.Fatalf("unexpected status: got %d want %d", res.StatusCode, http.StatusOK)- }-- var payload map[string]any- if err := json.NewDecoder(res.Body).Decode(&payload); err != nil {- t.Fatalf("decode security status response: %v", err)- }-- disabled, ok := payload["disabled"].(bool)- if !ok {- t.Fatalf("security status response missing disabled flag")- }- if !disabled {- t.Fatalf("expected authentication disabled flag to be true")- }-}-func TestMockModeToggleEndpoint(t *testing.T) {srv := newIntegrationServer(t)@@ -432,7 +402,6 @@ func TestAuthenticatedEndpointsRequireToken(t *testing.T) {const apiToken = "test-token"srv := newIntegrationServerWithConfig(t, func(cfg *config.Config) {- cfg.DisableAuth = falsecfg.APITokenEnabled = truerecord, err := config.NewAPITokenRecord(apiToken, "Integration test token", nil)if err != nil {@@ -606,7 +575,6 @@ func TestWebSocketSendsInitialState(t *testing.T) {func TestSessionCookieAllowsAuthenticatedAccess(t *testing.T) {srv := newIntegrationServerWithConfig(t, func(cfg *config.Config) {- cfg.DisableAuth = falsecfg.APITokenEnabled = falsehashedPass, err := internalauth.HashPassword("super-secure-pass")if err != nil {diff --git a/internal/api/security_setup_fix.go b/internal/api/security_setup_fix.goindex 0100dd1c98..4a1657c0af 100644--- a/internal/api/security_setup_fix.go+++ b/internal/api/security_setup_fix.go@@ -83,6 +83,10 @@ func handleQuickSecuritySetupFixed(r *Router) http.HandlerFunc {return}+ if r.config.DisableAuthEnvDetected {+ setupRequest.Force = true+ }+if r.config.AuthUser != "" && r.config.AuthPass != "" && !setupRequest.Force {log.Info().Msg("Security setup skipped - password auth already configured")response := map[string]interface{}{@@ -367,10 +371,8 @@ PULSE_AUDIT_LOG=true// HandleRegenerateAPIToken generates a new API token and updates the .env filefunc (r *Router) HandleRegenerateAPIToken(w http.ResponseWriter, rq *http.Request) {- // Only require authentication if auth is already configured AND not disabled- // This allows users to set up API-only access without password auth- // When auth is disabled, allow API token generation for API-only access- if !r.config.DisableAuth && (r.config.AuthUser != "" || r.config.AuthPass != "") && !CheckAuth(r.config, w, rq) {+ // Require authentication when password auth is configured+ if (r.config.AuthUser != "" || r.config.AuthPass != "") && !CheckAuth(r.config, w, rq) {return}@@ -522,7 +524,7 @@ func (r *Router) HandleValidateAPIToken(w http.ResponseWriter, rq *http.Request)// Require authentication to prevent unauthenticated token guessing oracle// Use same auth logic as regenerate-token endpoint- if !r.config.DisableAuth && (r.config.AuthUser != "" || r.config.AuthPass != "") && !CheckAuth(r.config, w, rq) {+ if (r.config.AuthUser != "" || r.config.AuthPass != "") && !CheckAuth(r.config, w, rq) {return}diff --git a/internal/config/config.go b/internal/config/config.goindex f220b3e37e..664f39fbe7 100644--- a/internal/config/config.go+++ b/internal/config/config.go@@ -110,15 +110,15 @@ type Config struct {LogCompress bool `envconfig:"LOG_COMPRESS" default:"true"`// Security settings- APIToken string `envconfig:"API_TOKEN"`- APITokenEnabled bool `envconfig:"API_TOKEN_ENABLED" default:"false"`- APITokens []APITokenRecord `json:"-"`- AuthUser string `envconfig:"PULSE_AUTH_USER"`- AuthPass string `envconfig:"PULSE_AUTH_PASS"`- DisableAuth bool `envconfig:"DISABLE_AUTH" default:"false"`- DemoMode bool `envconfig:"DEMO_MODE" default:"false"` // Read-only demo mode- AllowedOrigins string `envconfig:"ALLOWED_ORIGINS" default:"*"`- IframeEmbeddingAllow string `envconfig:"IFRAME_EMBEDDING_ALLOW" default:"SAMEORIGIN"`+ APIToken string `envconfig:"API_TOKEN"`+ APITokenEnabled bool `envconfig:"API_TOKEN_ENABLED" default:"false"`+ APITokens []APITokenRecord `json:"-"`+ AuthUser string `envconfig:"PULSE_AUTH_USER"`+ AuthPass string `envconfig:"PULSE_AUTH_PASS"`+ DisableAuthEnvDetected bool `json:"-"`+ DemoMode bool `envconfig:"DEMO_MODE" default:"false"` // Read-only demo mode+ AllowedOrigins string `envconfig:"ALLOWED_ORIGINS" default:"*"`+ IframeEmbeddingAllow string `envconfig:"IFRAME_EMBEDDING_ALLOW" default:"SAMEORIGIN"`// Proxy authentication settingsProxyAuthSecret string `envconfig:"PROXY_AUTH_SECRET"`@@ -878,17 +878,20 @@ func Load() (*Config, error) {log.Info().Msg("Migrated legacy API token into token record store")}}- // Check if auth is disabled- disableAuthEnv := os.Getenv("DISABLE_AUTH")- log.Debug().Str("DISABLE_AUTH_ENV", disableAuthEnv).Msg("Checking DISABLE_AUTH environment variable")- if disableAuthEnv != "" {- cfg.DisableAuth = disableAuthEnv == "true" || disableAuthEnv == "1"- log.Debug().Bool("DisableAuth", cfg.DisableAuth).Msg("DisableAuth set from environment")- if cfg.DisableAuth {- log.Warn().Msg("⚠️ AUTHENTICATION DISABLED - Pulse is running without authentication!")+ // Detect deprecated DISABLE_AUTH flag and strip it from the runtime env so downstream+ // components behave as if it were never set.+ if disableAuthEnv := os.Getenv("DISABLE_AUTH"); disableAuthEnv != "" {+ cfg.DisableAuthEnvDetected = true+ if err := os.Unsetenv("DISABLE_AUTH"); err != nil {+ log.Warn().+ Str("DISABLE_AUTH", disableAuthEnv).+ Err(err).+ Msg("Failed to remove legacy DISABLE_AUTH environment variable; continuing with authentication enabled")+ } else {+ log.Warn().+ Str("DISABLE_AUTH", disableAuthEnv).+ Msg("Removed legacy DISABLE_AUTH environment variable. Authentication remains enabled.")}- } else {- log.Debug().Bool("DisableAuth", cfg.DisableAuth).Msg("DISABLE_AUTH not set, DisableAuth remains")}// Check if demo mode is enableddiff --git a/internal/mock/generator.go b/internal/mock/generator.goindex b70b5cbec1..2d27a4218e 100644--- a/internal/mock/generator.go+++ b/internal/mock/generator.go@@ -1036,13 +1036,17 @@ func generateDockerHosts(config MockConfig) []models.DockerHost {containers[idx].CPUPercent = clampFloat(containers[idx].CPUPercent+35, 5, 190)}+ // Determine initial status - only mark last host as offline for testingstatus := "online"+ explicitlyOffline := falseif hostCount > 2 && i == hostCount-1 {status = "offline"+ explicitlyOffline = true}lastSeen := now.Add(-time.Duration(rand.Intn(20)) * time.Second)- if status == "offline" {+ if explicitlyOffline {+ // If host is explicitly offline, stop all containers and update metricslastSeen = now.Add(-time.Duration(5+rand.Intn(20)) * time.Minute)for idx := range containers {exitCode := containers[idx].ExitCode@@ -1060,9 +1064,8 @@ func generateDockerHosts(config MockConfig) []models.DockerHost {containers[idx].FinishedAt = &finishedcontainers[idx].Status = fmt.Sprintf("Exited (%d) %s ago", exitCode, formatDurationForStatus(now.Sub(finished)))}- }-- if status != "offline" {+ } else {+ // For hosts not explicitly offline, calculate status based on container healthrunning := 0unhealthy := 0for _, ct := range containers {@@ -1075,15 +1078,17 @@ func generateDockerHosts(config MockConfig) []models.DockerHost {}}- if running == 0 {+ // Only mark as offline if there are containers but none are running+ // (Swarm-only hosts with no standalone containers should stay online)+ if len(containers) > 0 && running == 0 {status = "offline"lastSeen = now.Add(-time.Duration(3+rand.Intn(5)) * time.Minute)- } else if unhealthy > 0 || float64(len(containers)-running)/float64(len(containers)) > 0.35 {+ } else if unhealthy > 0 || (len(containers) > 0 && float64(len(containers)-running)/float64(len(containers)) > 0.35) {status = "degraded"if lastSeen.After(now.Add(-30 * time.Second)) {lastSeen = now.Add(-35 * time.Second)}- } else if status != "offline" {+ } else {status = "online"}}@@ -3677,6 +3682,12 @@ func generateDockerServicesAndTasks(hostname string, containers []models.DockerCcurrentState = []string{"failed", "shutdown", "pending", "starting"}[rand.Intn(4)]}+ // Create a unique container name for each task+ taskContainerName := container.Name+ if slots > 1 {+ taskContainerName = fmt.Sprintf("%s.%d", container.Name, slot+1)+ }+taskID := fmt.Sprintf("%s-task-%d", serviceID, slot)task := models.DockerTask{ID: taskID,@@ -3687,26 +3698,30 @@ func generateDockerServicesAndTasks(hostname string, containers []models.DockerCNodeName: hostname,DesiredState: "running",CurrentState: currentState,- ContainerID: container.ID,- ContainerName: container.Name,+ ContainerID: fmt.Sprintf("%s-%d", container.ID, slot),+ ContainerName: taskContainerName,CreatedAt: now.Add(-time.Duration(rand.Intn(48)) * time.Hour),}- if container.StartedAt != nil {+ // Set varied start times for each task (not all identical)+ if currentState == "running" {+ startTime := now.Add(-time.Duration(30+rand.Intn(3600*24)) * time.Second)+ task.StartedAt = &startTime+ } else if container.StartedAt != nil && (currentState == "failed" || currentState == "shutdown") {started := *container.StartedAttask.StartedAt = &started}- if container.FinishedAt != nil {- finished := *container.FinishedAt- task.CompletedAt = &finished- }- if currentState == "running" {- task.StartedAt = ptrTime(now.Add(-time.Duration(30+rand.Intn(3600)) * time.Second))- }if currentState == "failed" || currentState == "shutdown" {task.Error = "container exit"task.Message = "Replica exited unexpectedly"+ if container.FinishedAt != nil {+ finished := *container.FinishedAt+ task.CompletedAt = &finished+ } else {+ completedTime := now.Add(-time.Duration(rand.Intn(3600)) * time.Second)+ task.CompletedAt = &completedTime+ }}agg.tasks = append(agg.tasks, task)diff --git a/mock.env b/mock.envindex 76bfa94692..ac3fa6f292 100644--- a/mock.env+++ b/mock.env@@ -12,7 +12,7 @@# Documentation: docs/development/MOCK_MODE.md# Enable/disable mock mode (false = use real Proxmox infrastructure)-PULSE_MOCK_MODE=true+PULSE_MOCK_MODE=false# Number of mock nodes to generate (mix of clustered and standalone)# First 5 nodes form a cluster, remaining nodes are standalonediff --git a/scripts/hot-dev.sh b/scripts/hot-dev.shindex bc60615350..2b6858d4a1 100755--- a/scripts/hot-dev.sh+++ b/scripts/hot-dev.sh@@ -182,8 +182,23 @@ if [[ ${PULSE_MOCK_MODE:-false} == "true" ]]; thenmkdir -p "$PULSE_DATA_DIR"echo "[hot-dev] Mock mode: Using isolated data directory: ${PULSE_DATA_DIR}"else- export PULSE_DATA_DIR=/etc/pulse- echo "[hot-dev] Production mode: Using production config: ${PULSE_DATA_DIR}"+ DEV_CONFIG_DIR="${ROOT_DIR}/tmp/dev-config"+ mkdir -p "$DEV_CONFIG_DIR"+ export PULSE_DATA_DIR="${DEV_CONFIG_DIR}"++ DEV_KEY_FILE="${DEV_CONFIG_DIR}/.encryption.key"+ if [[ ! -f "${DEV_KEY_FILE}" ]]; then+ openssl rand -hex 32 > "${DEV_KEY_FILE}"+ chmod 600 "${DEV_KEY_FILE}"+ echo "[hot-dev] Generated dev encryption key at ${DEV_KEY_FILE}"+ fi++ # Only set the encryption key if the user hasn't provided one explicitly+ if [[ -z ${PULSE_ENCRYPTION_KEY:-} ]]; then+ export PULSE_ENCRYPTION_KEY="$(<"${DEV_KEY_FILE}")"+ fi++ echo "[hot-dev] Production mode: Using dev config directory: ${PULSE_DATA_DIR}"fi./pulse &diff --git a/scripts/sync-production-config.sh b/scripts/sync-production-config.shindex 64cf0c5572..a257029e8d 100755--- a/scripts/sync-production-config.sh+++ b/scripts/sync-production-config.sh@@ -18,8 +18,10 @@ echo " Source: $PROD_DIR"echo " Target: $DEV_DIR"echo ""-# CRITICAL: Always sync production encryption key to dev-# This ensures dev can decrypt production's encrypted config files+# Track whether we have the production encryption key available+HAVE_PROD_KEY=false++# CRITICAL: Always sync production encryption key to dev when it existsif [ -f "$PROD_DIR/.encryption.key" ]; thenif [ ! -f "$DEV_DIR/.encryption.key" ]; thencp -f "$PROD_DIR/.encryption.key" "$DEV_DIR/.encryption.key"@@ -37,10 +39,25 @@ if [ -f "$PROD_DIR/.encryption.key" ]; thenecho "✓ Dev encryption key matches production"fifi+ HAVE_PROD_KEY=true+else+ echo "⚠ Production encryption key not found. Using dev-only key."+ if [ ! -f "$DEV_DIR/.encryption.key" ]; then+ # Generate a dev-only encryption key so backend can start+ openssl rand -hex 32 > "$DEV_DIR/.encryption.key"+ chmod 600 "$DEV_DIR/.encryption.key"+ echo "✓ Generated dev encryption key at $DEV_DIR/.encryption.key"+ else+ echo "✓ Reusing existing dev encryption key"+ fi+ # Remove encrypted artifacts that rely on the missing production key+ find "$DEV_DIR" -maxdepth 1 -type f -name 'nodes.enc*' -exec rm -f {} \;+ rm -f "$DEV_DIR/email.enc" "$DEV_DIR/webhooks.enc"+ echo "✓ Cleared encrypted production artifacts from dev config"fi# Copy nodes configuration - WITH VALIDATION-if [ -f "$PROD_DIR/nodes.enc" ]; then+if [ "$HAVE_PROD_KEY" = true ] && [ -f "$PROD_DIR/nodes.enc" ]; then# Check if production nodes.enc is valid (not corrupted)# Only sync if destination doesn't exist OR production file is newer OR dev copy is corruptedSHOULD_SYNC=false@@ -84,6 +101,11 @@ elif [ -f "$PROD_DIR/nodes.json" ]; thenecho "✓ Synced nodes configuration (unencrypted)"fi+# If we had to clear encrypted nodes, ensure we start from a clean slate+if [ "$HAVE_PROD_KEY" = false ]; then+ rm -f "$DEV_DIR/nodes.json"+fi+# Copy system settings (but keep dev-specific log level)if [ -f "$PROD_DIR/system.json" ]; thencp -f "$PROD_DIR/system.json" "$DEV_DIR/system.json"@@ -96,15 +118,15 @@ if [ -f "$PROD_DIR/guest_metadata.json" ]; thenecho "✓ Synced guest metadata"fi-# Copy email config if it exists-if [ -f "$PROD_DIR/email.enc" ]; then+# Copy email config if it exists and we have the key+if [ "$HAVE_PROD_KEY" = true ] && [ -f "$PROD_DIR/email.enc" ]; thencp -f "$PROD_DIR/email.enc" "$DEV_DIR/email.enc"chmod 600 "$DEV_DIR/email.enc"echo "✓ Synced email configuration"fi-# Copy webhook config if it exists-if [ -f "$PROD_DIR/webhooks.enc" ]; then+# Copy webhook config if it exists and we have the key+if [ "$HAVE_PROD_KEY" = true ] && [ -f "$PROD_DIR/webhooks.enc" ]; thencp -f "$PROD_DIR/webhooks.enc" "$DEV_DIR/webhooks.enc"chmod 600 "$DEV_DIR/webhooks.enc"echo "✓ Synced webhook configuration"@@ -122,4 +144,4 @@ mkdir -p "$DEV_DIR/alerts" 2>/dev/null || trueecho ""echo "✓ Production config synced to dev environment"echo " Source: $PROD_DIR"-echo " Target: $DEV_DIR"\ No newline at end of file+echo " Target: $DEV_DIR"diff --git a/scripts/toggle-mock.sh b/scripts/toggle-mock.shindex b3b42ddf33..214e7cd78f 100755--- a/scripts/toggle-mock.sh+++ b/scripts/toggle-mock.sh@@ -12,6 +12,8 @@ NC='\033[0m' # No ColorMOCK_ENV_FILE="/opt/pulse/mock.env"ROOT_DIR="/opt/pulse"BACKEND_PORT=7656+DEV_DATA_DIR="${ROOT_DIR}/tmp/dev-config"+DEV_KEY_FILE="${DEV_DATA_DIR}/.encryption.key"# Create default mock.env if it doesn't existif [ ! -f "$MOCK_ENV_FILE" ]; then@@ -85,7 +87,15 @@ restart_backend() {if [ "$PULSE_MOCK_MODE" = "true" ]; thenexport PULSE_DATA_DIR=/opt/pulse/tmp/mock-dataelse- export PULSE_DATA_DIR=/etc/pulse+ mkdir -p "$DEV_DATA_DIR"+ export PULSE_DATA_DIR="$DEV_DATA_DIR"+ if [ ! -f "$DEV_KEY_FILE" ]; then+ openssl rand -hex 32 > "$DEV_KEY_FILE"+ chmod 600 "$DEV_KEY_FILE"+ fi+ if [ -z "${PULSE_ENCRYPTION_KEY:-}" ]; then+ export PULSE_ENCRYPTION_KEY="$(<"$DEV_KEY_FILE")"+ fifiexport PORT=$BACKEND_PORT@@ -116,8 +126,8 @@ show_status() {echo " Docker containers/host: ${PULSE_MOCK_DOCKER_CONTAINERS:-0}"echo " Data dir: ${PULSE_DATA_DIR:-/opt/pulse/tmp/mock-data}"else- echo -e "${BLUE}Mock Mode: DISABLED${NC} (using real Proxmox nodes)"- echo " Data dir: /etc/pulse"+ echo -e "${BLUE}Mock Mode: DISABLED${NC}"+ echo " Data dir: ${DEV_DATA_DIR}"fi}@@ -152,7 +162,7 @@ disable_mock() {sed -i 's/PULSE_MOCK_MODE=.*/PULSE_MOCK_MODE=false/' "$MOCK_ENV_FILE"touch "$MOCK_ENV_FILE"echo -e "${GREEN}✓ Mock mode disabled!${NC}"- echo "Using real Proxmox nodes"+ echo "Using local dev configuration"echo ""restart_backend}