Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

Mirror agent version; plugin install & UI improvements

Juan Denis930705fa3bb3
diff --git a/agent/cmd/agent/main.go b/agent/cmd/agent/main.go
index f37075c4..62019b67 100644
--- a/agent/cmd/agent/main.go
+++ b/agent/cmd/agent/main.go
@@ -16,8 +16,10 @@ import (
"github.com/serverkit/agent/internal/config"
"github.com/serverkit/agent/internal/logger"
"github.com/serverkit/agent/internal/setupui"
+ pollclient "github.com/serverkit/agent/internal/transport/poll"
"github.com/serverkit/agent/internal/tray"
"github.com/serverkit/agent/internal/updater"
+ wsclient "github.com/serverkit/agent/internal/ws"
"github.com/spf13/cobra"
)
@@ -27,14 +29,16 @@ var (
GitCommit = "unknown"
)
-// Mirror Version into the agent package at startup so /status reports the
-// real version. ldflags set main.Version but the IPC reads agent.Version
-// — they're two distinct package-level vars and were silently drifting,
-// which is why the UI showed "vdev" while `serverkit-agent version`
-// correctly printed "1.6.10".
+// Mirror Version into every package that surfaces it in user-visible
+// strings. ldflags set main.Version, but the agent / ws / poll packages
+// each have their own Version var — they were silently drifting, which
+// is why the panel UI displayed "ServerKit-Agent-Poll/dev" even when
+// `serverkit-agent version` correctly printed the build tag.
func init() {
if Version != "dev" {
agent.Version = Version
+ wsclient.Version = Version
+ pollclient.Version = Version
}
}
diff --git a/agent/internal/transport/poll/client.go b/agent/internal/transport/poll/client.go
index cc5f37a2..97d3a839 100644
--- a/agent/internal/transport/poll/client.go
+++ b/agent/internal/transport/poll/client.go
@@ -34,6 +34,13 @@ import (
"github.com/serverkit/agent/pkg/protocol"
)
+// Version is the agent version string surfaced in the User-Agent
+// header. Defaults to "dev"; main.go's init() mirrors the ldflags-set
+// main.Version into this on release builds. Was previously a hardcoded
+// "dev" literal which made the panel display "ServerKit-Agent-Poll/dev"
+// regardless of the actual built version.
+var Version = "dev"
+
// Client is the polling-mode transport. Mirrors the surface of ws.Client
// so agent.Agent doesn't need to know which transport is wired up.
type Client struct {
@@ -378,7 +385,7 @@ func (c *Client) postJSON(ctx context.Context, path, token string, body interfac
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
- req.Header.Set("User-Agent", "ServerKit-Agent-Poll/dev")
+ req.Header.Set("User-Agent", "ServerKit-Agent-Poll/"+Version)
if token != "" {
req.Header.Set("X-Session-Token", token)
}
diff --git a/agent/internal/ws/client.go b/agent/internal/ws/client.go
index 3910eeeb..22617775 100644
--- a/agent/internal/ws/client.go
+++ b/agent/internal/ws/client.go
@@ -20,6 +20,13 @@ import (
"github.com/serverkit/agent/pkg/protocol"
)
+// Version is the agent version string surfaced in the User-Agent
+// header. Defaults to "dev"; main.go's init() mirrors the ldflags-set
+// main.Version into this when a release build runs.
+var Version = "dev"
+
+func agentVersion() string { return Version }
+
// MessageHandler is the callback fired on inbound packets. Aliased to the
// transport package so ws.Client implements transport.Transport without
// adapter glue.
@@ -133,7 +140,7 @@ func (c *Client) Connect(ctx context.Context) error {
headers := http.Header{}
headers.Set("X-Agent-ID", c.auth.AgentID())
headers.Set("X-API-Key-Prefix", c.auth.GetAPIKeyPrefix())
- headers.Set("User-Agent", fmt.Sprintf("ServerKit-Agent/%s", "dev"))
+ headers.Set("User-Agent", fmt.Sprintf("ServerKit-Agent/%s", agentVersion()))
// Bypass ngrok's interstitial / browser-warning behaviour for free-tier
// tunnels. Harmless when the panel isn't behind ngrok.
headers.Set("ngrok-skip-browser-warning", "true")
diff --git a/backend/app/services/plugin_service.py b/backend/app/services/plugin_service.py
index 78e870f2..1accebde 100644
--- a/backend/app/services/plugin_service.py
+++ b/backend/app/services/plugin_service.py
@@ -23,28 +23,74 @@ from app.models.plugin import InstalledPlugin
logger = logging.getLogger(__name__)
-# Resolve paths relative to the backend directory
+# Resolve paths relative to the backend directory.
# __file__ = backend/app/services/plugin_service.py
# _APP_DIR = backend/app/
# _BACKEND_ROOT = backend/
# _PROJECT_ROOT = ServerKit/
+#
+# Both targets are env-var overridable. The defaults work for native dev
+# (backend run from a checkout). They break in Docker because the backend
+# image only contains /app — the host's frontend directory isn't mounted —
+# so dockerized panels MUST set SERVERKIT_FRONTEND_PLUGINS_DIR (and bind
+# mount the corresponding host folder) when installing plugins that ship
+# a frontend.
_APP_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
_BACKEND_ROOT = os.path.dirname(_APP_DIR)
_PROJECT_ROOT = os.path.dirname(_BACKEND_ROOT)
-BACKEND_PLUGINS_DIR = os.path.join(_APP_DIR, 'plugins')
-FRONTEND_PLUGINS_DIR = os.path.join(_PROJECT_ROOT, 'frontend', 'src', 'plugins')
+BACKEND_PLUGINS_DIR = os.environ.get(
+ 'SERVERKIT_BACKEND_PLUGINS_DIR',
+ os.path.join(_APP_DIR, 'plugins'),
+)
+FRONTEND_PLUGINS_DIR = os.environ.get(
+ 'SERVERKIT_FRONTEND_PLUGINS_DIR',
+ os.path.join(_PROJECT_ROOT, 'frontend', 'src', 'plugins'),
+)
-def _ensure_dirs():
- os.makedirs(BACKEND_PLUGINS_DIR, exist_ok=True)
- os.makedirs(FRONTEND_PLUGINS_DIR, exist_ok=True)
- # Ensure __init__.py exists in backend plugins dir
+
+def _ensure_backend_dir():
+ """Create the backend plugin dir; raise a useful error if we can't."""
+ try:
+ os.makedirs(BACKEND_PLUGINS_DIR, exist_ok=True)
+ except OSError as e:
+ raise ValueError(
+ f"Cannot create backend plugin directory at {BACKEND_PLUGINS_DIR}: {e}. "
+ f"Set SERVERKIT_BACKEND_PLUGINS_DIR to a writable path."
+ )
init_path = os.path.join(BACKEND_PLUGINS_DIR, '__init__.py')
if not os.path.exists(init_path):
with open(init_path, 'w') as f:
f.write('')
+def _ensure_frontend_dir():
+ """Create the frontend plugin dir on demand. Called only when a plugin
+ actually ships frontend content — plugins without frontends never need
+ this directory and shouldn't fail just because it doesn't exist (a
+ common case in Docker)."""
+ try:
+ os.makedirs(FRONTEND_PLUGINS_DIR, exist_ok=True)
+ except OSError as e:
+ raise ValueError(
+ f"This plugin ships a frontend, but the panel can't write to "
+ f"the frontend plugin directory ({FRONTEND_PLUGINS_DIR}): {e}.\n\n"
+ f"If the panel runs in Docker, this is expected — the container "
+ f"sees only /app, not the host's frontend folder. Two fixes:\n"
+ f" • Bind-mount the host's frontend/src/plugins into the "
+ f"container and set SERVERKIT_FRONTEND_PLUGINS_DIR to that path.\n"
+ f" • Or run the backend natively for plugin development.\n\n"
+ f"You can also install the backend half only by stripping the "
+ f"frontend/ folder from the plugin zip, but the UI half won't load."
+ )
+
+
+def _ensure_dirs():
+ """Backwards-compatible eager init for backend dir only. Frontend dir is
+ lazy now — see _ensure_frontend_dir."""
+ _ensure_backend_dir()
+
+
def _resolve_github_url(url):
"""Convert a GitHub repo URL to the latest release zip download URL.
@@ -157,17 +203,45 @@ def install_from_url(url, user_id=None):
def install_from_path(path, user_id=None):
- """Install a plugin from a local directory.
+ """Install a plugin from a local directory on the panel host.
Useful during plugin development: point at the working tree, install,
iterate. Internally we zip the folder in memory and reuse the same
install pipeline as URL/upload installs so behavior is identical.
+
+ Note: "local" here means local to the *panel backend*, not to the
+ user's browser. If the backend runs in Docker, browser-host paths
+ won't resolve — the user should either bind-mount their plugin
+ source into the container or use install_from_zip via the upload
+ endpoint instead.
"""
if not path:
raise ValueError('path is required')
+
+ raw = path
+
+ # Windows path on a non-Windows panel host is the most common
+ # foot-gun (typical case: backend in Docker, dev on Windows). Detect
+ # and reject with a helpful message before os.path.abspath turns it
+ # into garbage like /app/C:\Users\...
+ if os.name != 'nt' and len(path) >= 3 and path[1:3] == ':\\':
+ raise ValueError(
+ f"'{raw}' looks like a Windows path, but the panel backend is "
+ f"running on {os.name!r} (likely a Linux container). The folder "
+ f"install runs on the panel host's filesystem, not your browser's. "
+ f"Either bind-mount your plugin source into the backend container, "
+ f"or use 'Upload Zip' instead."
+ )
+
path = os.path.abspath(os.path.expanduser(path))
if not os.path.isdir(path):
- raise ValueError(f'Not a directory: {path}')
+ raise ValueError(
+ f"Not a directory: {path}\n"
+ f"This path is resolved on the panel backend ({os.name!r}), not "
+ f"your browser. If the backend runs in Docker, the path must "
+ f"exist inside the container — bind-mount the source folder or "
+ f"use 'Upload Zip'."
+ )
if not os.path.exists(os.path.join(path, 'plugin.json')):
raise ValueError(f'No plugin.json in {path}')
@@ -270,17 +344,30 @@ def _install_from_buffer(buf, source_url, source_type, user_id=None):
db.session.commit()
try:
- # Extract backend files
- backend_dest = os.path.join(BACKEND_PLUGINS_DIR, slug)
- frontend_dest = os.path.join(FRONTEND_PLUGINS_DIR, slug)
-
+ # First pass — figure out what the archive contains. This lets us
+ # bail early with a useful error if the plugin needs a frontend
+ # dir we can't write to (the dockerized panel case).
has_backend = False
has_frontend = False
+ for member in zf.namelist():
+ rel = member[len(prefix):] if prefix else member
+ if not rel or rel.endswith('/'):
+ continue
+ if rel.startswith('backend/'):
+ has_backend = True
+ elif rel.startswith('frontend/'):
+ has_frontend = True
+
+ if has_frontend:
+ _ensure_frontend_dir() # raises with a helpful message on failure
+
+ backend_dest = os.path.join(BACKEND_PLUGINS_DIR, slug)
+ frontend_dest = os.path.join(FRONTEND_PLUGINS_DIR, slug)
# Clean old install
if os.path.exists(backend_dest):
shutil.rmtree(backend_dest)
- if os.path.exists(frontend_dest):
+ if has_frontend and os.path.exists(frontend_dest):
shutil.rmtree(frontend_dest)
for member in zf.namelist():
@@ -290,14 +377,12 @@ def _install_from_buffer(buf, source_url, source_type, user_id=None):
continue
if rel_path.startswith('backend/'):
- has_backend = True
out_path = os.path.join(backend_dest, rel_path[len('backend/'):])
os.makedirs(os.path.dirname(out_path), exist_ok=True)
with zf.open(member) as src, open(out_path, 'wb') as dst:
dst.write(src.read())
elif rel_path.startswith('frontend/'):
- has_frontend = True
out_path = os.path.join(frontend_dest, rel_path[len('frontend/'):])
os.makedirs(os.path.dirname(out_path), exist_ok=True)
with zf.open(member) as src, open(out_path, 'wb') as dst:
@@ -407,7 +492,18 @@ def _regenerate_frontend_manifest():
This file tells the frontend which plugins are installed and where
their components/styles live so Vite can include them.
+
+ Best-effort: if the frontend dir doesn't exist (e.g. a pure backend
+ plugin install where no frontend was ever extracted, or a Docker
+ panel without the bind mount), we just log and move on rather than
+ failing the install.
"""
+ if not os.path.isdir(FRONTEND_PLUGINS_DIR):
+ logger.info(
+ f'Skipping frontend manifest regeneration: '
+ f'{FRONTEND_PLUGINS_DIR} does not exist'
+ )
+ return
manifest_path = os.path.join(FRONTEND_PLUGINS_DIR, 'plugins-manifest.json')
plugins = InstalledPlugin.query.filter(
diff --git a/frontend/src/pages/Docker.jsx b/frontend/src/pages/Docker.jsx
index 6420690d..daf95d0c 100644
--- a/frontend/src/pages/Docker.jsx
+++ b/frontend/src/pages/Docker.jsx
@@ -1,12 +1,20 @@
-import React, { useState, useEffect, useCallback, createContext, useContext } from 'react';
+import React, { useState, useEffect, useMemo, useRef, createContext, useContext } from 'react';
import useTabParam from '../hooks/useTabParam';
import api from '../services/api';
import { useToast } from '../contexts/ToastContext';
import { useConfirm } from '../hooks/useConfirm';
import { ConfirmDialog } from '../components/ConfirmDialog';
+import TargetPicker from '../components/TargetPicker';
+import LogToolbar from '../components/log-viewer/LogToolbar';
+import LogContent from '../components/log-viewer/LogContent';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Textarea } from '@/components/ui/textarea';
+import {
+ Box, Layers, HardDrive, Network as NetworkIcon, Search, X, RefreshCw,
+ Trash2, Play, Square, RotateCw, Terminal as TerminalLucide, FileText,
+ Cpu,
+} from 'lucide-react';
// Server context for Docker operations
const ServerContext = createContext({ serverId: 'local', serverName: 'Local' });
@@ -219,12 +227,6 @@ const Docker = () => {
{ id: 'networks', label: 'Networks' }
];
- function handleServerChange(e) {
- const serverId = e.target.value;
- const server = servers.find(s => s.id === serverId) || { id: 'local', name: 'Local' };
- setSelectedServer(server);
- }
-
const serverContextValue = {
serverId: selectedServer.id,
serverName: selectedServer.name,
@@ -233,23 +235,13 @@ const Docker = () => {
return (
<ServerContext.Provider value={serverContextValue}>
- <div className="page-container docker-page-new">
- <div className="docker-page-header">
- <div className="docker-page-title">
- <h2>Docker Management</h2>
- <div className="docker-page-subtitle">Manage Containers, Images, and Networks</div>
+ <div className="page-container docker-page-new dx-page">
+ <div className="page-header">
+ <div className="page-header-content">
+ <h1>Docker</h1>
+ <p className="page-description">Manage containers, images, networks, and volumes</p>
</div>
- <div className="docker-page-actions">
- <div className="server-selector">
- <ServerSelectorIcon />
- <select value={selectedServer.id} onChange={handleServerChange}>
- {servers.map(server => (
- <option key={server.id} value={server.id} disabled={server.status === 'offline'}>
- {server.name} {server.status === 'offline' ? '(Offline)' : ''}
- </option>
- ))}
- </select>
- </div>
+ <div className="page-header-actions">
{activeTab === 'containers' && <RunContainerButton />}
{activeTab === 'images' && <PullImageButton />}
{activeTab === 'networks' && <CreateNetworkButton />}
@@ -257,73 +249,93 @@ const Docker = () => {
</div>
</div>
- <div className="docker-stats-row">
- <div className="docker-stat-card">
- <div className="docker-stat-label">Containers</div>
- <div className="docker-stat-value">{stats.containers.total}</div>
- <div className="docker-stat-meta">
- <span className="docker-stat-running">{stats.containers.running} Running</span>
- <span className="docker-stat-stopped">{stats.containers.stopped} Stopped</span>
- </div>
- </div>
- <div className="docker-stat-card">
- <div className="docker-stat-label">Images</div>
- <div className="docker-stat-value">{stats.images.total}</div>
- <div className="docker-stat-meta">{stats.images.size} Disk Usage</div>
- </div>
- <div className="docker-stat-card">
- <div className="docker-stat-label">Volumes</div>
- <div className="docker-stat-value">{stats.volumes.total}</div>
- <div className="docker-stat-meta">Persistent Data</div>
+ <div className="lv-header">
+ <div className="lv-header-target">
+ <span className="lv-header-label">Server</span>
+ <TargetPicker
+ feature="docker"
+ value={selectedServer.id === 'local'
+ ? { kind: 'local' }
+ : { kind: 'agent', server_id: selectedServer.id, name: selectedServer.name }}
+ onChange={(v) => {
+ if (v.kind === 'local') setSelectedServer({ id: 'local', name: 'Local (this server)' });
+ else setSelectedServer({ id: v.server_id, name: v.name });
+ }}
+ />
</div>
- <div className="docker-stat-card">
- <div className="docker-stat-label">Networks</div>
- <div className="docker-stat-value">{stats.networks.total}</div>
- <div className="docker-stat-meta">Bridge / Host / None</div>
+ <div className="lv-header-stats">
+ <PruneButton onPruned={loadStats} />
</div>
</div>
- <div className="docker-panel">
- <div className="docker-panel-header">
- <div className="docker-panel-tabs">
- {tabs.map(tab => (
- <div
- key={tab.id}
- className={`docker-panel-tab ${activeTab === tab.id ? 'active' : ''}`}
- onClick={() => setActiveTab(tab.id)}
- >
- {tab.label}
- </div>
- ))}
+ <div className="dx-stats-row">
+ <div className="dx-stat" data-kind="containers">
+ <div className="dx-stat-icon"><Box size={18} /></div>
+ <div className="dx-stat-body">
+ <div className="dx-stat-label">Containers</div>
+ <div className="dx-stat-value">{stats.containers.total}</div>
+ <div className="dx-stat-meta">
+ <span className="dx-pill running"><span className="dot" />{stats.containers.running} running</span>
+ <span className="dx-pill stopped"><span className="dot" />{stats.containers.stopped} stopped</span>
+ </div>
</div>
- <div className="docker-panel-actions">
- <PruneButton onPruned={loadStats} />
+ </div>
+ <div className="dx-stat" data-kind="images">
+ <div className="dx-stat-icon"><Layers size={18} /></div>
+ <div className="dx-stat-body">
+ <div className="dx-stat-label">Images</div>
+ <div className="dx-stat-value">{stats.images.total}</div>
+ <div className="dx-stat-meta">
+ <span className="dx-stat-sub">{stats.images.size} on disk</span>
+ </div>
</div>
</div>
-
- <div className="docker-panel-content">
- {activeTab === 'containers' && <ContainersTab onStatsChange={loadStats} />}
- {activeTab === 'compose' && <ComposeTab onStatsChange={loadStats} />}
- {activeTab === 'images' && <ImagesTab onStatsChange={loadStats} />}
- {activeTab === 'networks' && <NetworksTab onStatsChange={loadStats} />}
- {activeTab === 'volumes' && <VolumesTab onStatsChange={loadStats} />}
+ <div className="dx-stat" data-kind="volumes">
+ <div className="dx-stat-icon"><HardDrive size={18} /></div>
+ <div className="dx-stat-body">
+ <div className="dx-stat-label">Volumes</div>
+ <div className="dx-stat-value">{stats.volumes.total}</div>
+ <div className="dx-stat-meta">
+ <span className="dx-stat-sub">Persistent data</span>
+ </div>
+ </div>
+ </div>
+ <div className="dx-stat" data-kind="networks">
+ <div className="dx-stat-icon"><NetworkIcon size={18} /></div>
+ <div className="dx-stat-body">
+ <div className="dx-stat-label">Networks</div>
+ <div className="dx-stat-value">{stats.networks.total}</div>
+ <div className="dx-stat-meta">
+ <span className="dx-stat-sub">Bridge · Host · None</span>
+ </div>
+ </div>
</div>
</div>
+
+ <div className="dx-tabs">
+ {tabs.map(tab => (
+ <button
+ key={tab.id}
+ className={`dx-tab ${activeTab === tab.id ? 'active' : ''}`}
+ onClick={() => setActiveTab(tab.id)}
+ >
+ {tab.label}
+ </button>
+ ))}
+ </div>
+
+ <div className="dx-panel">
+ {activeTab === 'containers' && <ContainersTab onStatsChange={loadStats} />}
+ {activeTab === 'compose' && <ComposeTab onStatsChange={loadStats} />}
+ {activeTab === 'images' && <ImagesTab onStatsChange={loadStats} />}
+ {activeTab === 'networks' && <NetworksTab onStatsChange={loadStats} />}
+ {activeTab === 'volumes' && <VolumesTab onStatsChange={loadStats} />}
+ </div>
</div>
</ServerContext.Provider>
);
};
-// Server Selector Icon
-const ServerSelectorIcon = () => (
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
- <rect x="2" y="2" width="20" height="8" rx="2" ry="2"/>
- <rect x="2" y="14" width="20" height="8" rx="2" ry="2"/>
- <line x1="6" y1="6" x2="6.01" y2="6"/>
- <line x1="6" y1="18" x2="6.01" y2="18"/>
- </svg>
-);
-
// Action Buttons
const RunContainerButton = () => {
const [showModal, setShowModal] = useState(false);
@@ -413,24 +425,8 @@ const PruneButton = ({ onPruned }) => {
);
};
-// Resource Bar Component
-const ResourceBar = ({ label, value, color }) => {
- const numValue = parseFloat(value) || 0;
- return (
- <div className="docker-res-container">
- <span className="docker-res-label">{label}</span>
- <div className="docker-res-track">
- <div
- className="docker-res-fill"
- style={{ width: `${Math.min(numValue, 100)}%`, backgroundColor: color }}
- />
- </div>
- <span className="docker-res-value">{numValue.toFixed(0)}%</span>
- </div>
- );
-};
-
-// Icon Actions
+// Icon Action button used by remaining (legacy) tabs (Images, Networks, Volumes).
+// Containers tab now renders cards with full action buttons inline.
const IconAction = ({ title, onClick, color, children, disabled }) => (
<button
className="docker-icon-action"
@@ -443,49 +439,7 @@ const IconAction = ({ title, onClick, color, children, disabled }) => (
</button>
);
-// Icons
-const LogsIcon = () => (
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
- <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
- <polyline points="14 2 14 8 20 8"/>
- <line x1="16" y1="13" x2="8" y2="13"/>
- <line x1="16" y1="17" x2="8" y2="17"/>
- </svg>
-);
-
-const TerminalIcon = () => (
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
- <polyline points="4 17 10 11 4 5"/>
- <line x1="12" y1="19" x2="20" y2="19"/>
- </svg>
-);
-
-const RestartIcon = () => (
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
- <polyline points="23 4 23 10 17 10"/>
- <polyline points="1 20 1 14 7 14"/>
- <path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/>
- </svg>
-);
-
-const StopIcon = () => (
- <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor">
- <rect x="6" y="6" width="12" height="12"/>
- </svg>
-);
-
-const PlayIcon = () => (
- <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor">
- <polygon points="5 3 19 12 5 21 5 3"/>
- </svg>
-);
-
-const TrashIcon = () => (
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
- <polyline points="3 6 5 6 21 6"/>
- <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>
- </svg>
-);
+const TrashIcon = () => <Trash2 size={14} />;
// Containers Tab
const ContainersTab = ({ onStatsChange }) => {
@@ -609,7 +563,17 @@ const ContainersTab = ({ onStatsChange }) => {
return ports.length > 0 ? ports : ['-'];
}
+ const [statusFilter, setStatusFilter] = useState('all');
+
+ const counts = useMemo(() => {
+ const c = { all: containers.length, running: 0, stopped: 0 };
+ containers.forEach(x => { if (x.state === 'running') c.running++; else c.stopped++; });
+ return c;
+ }, [containers]);
+
const filteredContainers = containers.filter(c => {
+ if (statusFilter === 'running' && c.state !== 'running') return false;
+ if (statusFilter === 'stopped' && c.state === 'running') return false;
if (!searchTerm) return true;
const search = searchTerm.toLowerCase();
return c.name?.toLowerCase().includes(search) ||
@@ -618,122 +582,167 @@ const ContainersTab = ({ onStatsChange }) => {
});
if (loading) {
- return <div className="docker-loading">Loading containers...</div>;
+ return <div className="lv-content-loading" style={{ padding: 60 }}>Loading containers…</div>;
}
return (
- <div>
- <div className="docker-table-header">
- <label className="docker-filter-toggle">
- <input
- type="checkbox"
- checked={showAll}
- onChange={(e) => setShowAll(e.target.checked)}
- />
- Show stopped
- </label>
- <Input
- type="text"
- className="docker-search"
- placeholder="Search ID or Name..."
- value={searchTerm}
- onChange={(e) => setSearchTerm(e.target.value)}
- />
+ <div className="dx-tab-pane">
+ <div className="dx-tab-toolbar">
+ <div className="proc-filter-chips">
+ {[
+ { id: 'all', label: 'All', count: counts.all },
+ { id: 'running', label: 'Running', count: counts.running },
+ { id: 'stopped', label: 'Stopped', count: counts.stopped },
+ ].map(c => (
+ <button
+ key={c.id}
+ className={`filter-chip ${statusFilter === c.id ? 'active' : ''}`}
+ onClick={() => setStatusFilter(c.id)}
+ disabled={c.id !== 'all' && c.count === 0}
+ >
+ <span>{c.label}</span>
+ <span className="filter-chip-count">{c.count}</span>
+ </button>
+ ))}
+ </div>
+ <div className="dx-tab-toolbar-right">
+ <div className="lv-search-field" style={{ minWidth: 240 }}>
+ <Search size={13} className="lv-search-field-icon" />
+ <input
+ type="text"
+ placeholder="Filter name or image…"
+ value={searchTerm}
+ onChange={(e) => setSearchTerm(e.target.value)}
+ />
+ {searchTerm && (
+ <button className="lv-search-field-clear" onClick={() => setSearchTerm('')}>
+ <X size={11} />
+ </button>
+ )}
+ </div>
+ <button
+ className="lv-icon-btn"
+ onClick={loadContainers}
+ title="Refresh"
+ >
+ <RefreshCw size={13} className={loading ? 'spinning' : ''} />
+ </button>
+ </div>
</div>
{filteredContainers.length === 0 ? (
- <div className="docker-empty">
- <h3>No containers</h3>
- <p>Run your first container to get started.</p>
+ <div className="lv-empty-hint" style={{ padding: 60, minHeight: 240 }}>
+ <Box size={32} />
+ <p>{containers.length === 0 ? 'No containers yet. Run your first one.' : 'No containers match the current filters.'}</p>
</div>
) : (
- <table className="docker-table">
- <thead>
- <tr>
- <th>Container</th>
- <th>Image</th>
- <th>Status</th>
- <th>Bindings</th>
- <th>Resources</th>
- <th className="text-right">Actions</th>
- </tr>
- </thead>
- <tbody>
- {filteredContainers.map(container => {
- const stats = parseStats(containerStats[container.id]);
- const isRunning = container.state === 'running';
- const ports = formatPorts(container.ports);
-
- return (
- <tr key={container.id}>
- <td>
- <span className="docker-container-name">{container.name}</span>
- <span className="docker-container-id">{container.id?.substring(0, 9)}</span>
- </td>
- <td>
- <span className="docker-image-tag">{container.image}</span>
- </td>
- <td>
- <span className={`docker-status-pill ${isRunning ? 'running' : 'exited'}`}>
- <span className="docker-status-dot" />
- {isRunning ? 'Running' : 'Exited'}
- </span>
- <div className="docker-status-detail">{container.status}</div>
- </td>
- <td>
- <span className={`docker-ports ${!isRunning ? 'faded' : ''}`}>
- {Array.isArray(ports) ? ports.map((p, i) => (
- <span key={i}>{p}{i < ports.length - 1 && <br />}</span>
- )) : ports}
- </span>
- </td>
- <td>
- <div className={!isRunning ? 'faded' : ''}>
- <ResourceBar
- label="CPU"
- value={stats.cpu}
- color={stats.cpu > 50 ? '#F59E0B' : '#6366F1'}
- />
- <ResourceBar
- label="RAM"
- value={stats.memory}
- color="#10B981"
- />
+ <div className="dx-container-grid">
+ {filteredContainers.map(container => {
+ const stats = parseStats(containerStats[container.id]);
+ const isRunning = container.state === 'running';
+ const ports = formatPorts(container.ports);
+ return (
+ <div
+ key={container.id}
+ className={`dx-container-card ${isRunning ? 'is-running' : 'is-stopped'}`}
+ onClick={() => setSelectedContainer(container)}
+ >
+ <div className="dx-card-head">
+ <div className="dx-card-title">
+ <span className={`dx-status-dot ${isRunning ? 'running' : 'stopped'}`} />
+ <h4 title={container.name}>{container.name}</h4>
+ </div>
+ <span className={`dx-status-pill ${isRunning ? 'running' : 'stopped'}`}>
+ {isRunning ? 'Running' : 'Exited'}
+ </span>
+ </div>
+ <div className="dx-card-image">
+ <Layers size={11} />
+ <span title={container.image}>{container.image}</span>
+ </div>
+ <div className="dx-card-detail">{container.status}</div>
+ {isRunning && Array.isArray(ports) && ports[0] !== '-' && (
+ <div className="dx-card-ports">
+ {ports.slice(0, 3).map((p, i) => (
+ <span key={i} className="dx-port-pill">{p}</span>
+ ))}
+ {ports.length > 3 && <span className="dx-port-more">+{ports.length - 3}</span>}
+ </div>
+ )}
+ {isRunning && (
+ <div className="dx-card-resources">
+ <div className="dx-res">
+ <span className="dx-res-label"><Cpu size={10} /> CPU</span>
+ <div className="dx-res-track">
+ <div className="dx-res-fill cpu" style={{ width: `${Math.min(stats.cpu, 100)}%` }} />
+ </div>
+ <span className="dx-res-value">{stats.cpu.toFixed(1)}%</span>
</div>
- </td>
- <td className="docker-actions-cell">
- <IconAction title="Logs" onClick={() => setSelectedContainer(container)}>
- <LogsIcon />
- </IconAction>
- {isRunning && (
- <>
- <IconAction title="Terminal" onClick={() => setExecContainer(container)}>
- <TerminalIcon />
- </IconAction>
- <IconAction title="Restart" onClick={() => handleAction(container.id, 'restart')}>
- <RestartIcon />
- </IconAction>
- <IconAction title="Stop" onClick={() => handleAction(container.id, 'stop')} color="#EF4444">
- <StopIcon />
- </IconAction>
- </>
- )}
- {!isRunning && (
- <>
- <IconAction title="Start" onClick={() => handleAction(container.id, 'start')} color="#10B981">
- <PlayIcon />
- </IconAction>
- <IconAction title="Delete" onClick={() => handleAction(container.id, 'remove')} color="#EF4444">
- <TrashIcon />
- </IconAction>
- </>
- )}
- </td>
- </tr>
- );
- })}
- </tbody>
- </table>
+ <div className="dx-res">
+ <span className="dx-res-label">RAM</span>
+ <div className="dx-res-track">
+ <div className="dx-res-fill mem" style={{ width: `${Math.min(stats.memory, 100)}%` }} />
+ </div>
+ <span className="dx-res-value">{stats.memory.toFixed(1)}%</span>
+ </div>
+ </div>
+ )}
+ <div className="dx-card-actions" onClick={(e) => e.stopPropagation()}>
+ <button
+ className="svc-action-btn ghost"
+ onClick={() => setSelectedContainer(container)}
+ title="Logs"
+ >
+ <FileText size={12} /> Logs
+ </button>
+ {isRunning && (
+ <>
+ <button
+ className="svc-action-btn ghost"
+ onClick={() => setExecContainer(container)}
+ title="Exec"
+ >
+ <TerminalLucide size={12} /> Exec
+ </button>
+ <button
+ className="svc-action-btn"
+ onClick={() => handleAction(container.id, 'restart')}
+ title="Restart"
+ >
+ <RotateCw size={12} /> Restart
+ </button>
+ <button
+ className="svc-action-btn"
+ onClick={() => handleAction(container.id, 'stop')}
+ title="Stop"
+ >
+ <Square size={12} /> Stop
+ </button>
+ </>
+ )}
+ {!isRunning && (
+ <>
+ <button
+ className="svc-action-btn primary"
+ onClick={() => handleAction(container.id, 'start')}
+ title="Start"
+ >
+ <Play size={12} /> Start
+ </button>
+ <button
+ className="svc-action-btn danger"
+ onClick={() => handleAction(container.id, 'remove')}
+ title="Remove"
+ >
+ <Trash2 size={12} /> Remove
+ </button>
+ </>
+ )}
+ </div>
+ </div>
+ );
+ })}
+ </div>
)}
{selectedContainer && (
@@ -1581,13 +1590,27 @@ const ContainerLogsModal = ({ container, onClose }) => {
const [logs, setLogs] = useState('');
const [loading, setLoading] = useState(true);
const [tail, setTail] = useState(200);
+ const [searchPattern, setSearchPattern] = useState('');
+ const [appliedSearch, setAppliedSearch] = useState('');
+ const [autoRefresh, setAutoRefresh] = useState(false);
+ const [showLineNumbers, setShowLineNumbers] = useState(true);
+ const [wrapLines, setWrapLines] = useState(true);
+ const contentRef = useRef(null);
+ const intervalRef = useRef(null);
useEffect(() => {
loadLogs();
- }, [container, tail]);
+ }, [container, tail]); // eslint-disable-line
- async function loadLogs() {
- setLoading(true);
+ useEffect(() => {
+ if (autoRefresh) {
+ intervalRef.current = setInterval(() => loadLogs(false), 3000);
+ }
+ return () => { if (intervalRef.current) clearInterval(intervalRef.current); };
+ }, [autoRefresh, tail]); // eslint-disable-line
+
+ async function loadLogs(showSpinner = true) {
+ if (showSpinner) setLoading(true);
try {
let data;
if (isRemote) {
@@ -1596,7 +1619,10 @@ const ContainerLogsModal = ({ container, onClose }) => {
} else {
data = await api.getContainerLogs(container.id, tail);
}
- setLogs(data.logs || 'No logs available');
+ setLogs(data.logs || '');
+ if (autoRefresh && contentRef.current) {
+ contentRef.current.scrollTop = contentRef.current.scrollHeight;
+ }
} catch (err) {
setLogs('Failed to load logs: ' + (err.message || 'Unknown error'));
} finally {
@@ -1604,34 +1630,90 @@ const ContainerLogsModal = ({ container, onClose }) => {
}
}
+ function handleDownload() {
+ if (!logs) return;
+ const blob = new Blob([logs], { type: 'text/plain' });
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement('a');
+ a.href = url;
+ a.download = `${container.name}-${Date.now()}.log`;
+ a.click();
+ URL.revokeObjectURL(url);
+ }
+
return (
- <div className="modal-overlay" onClick={onClose}>
- <div className="modal modal-lg" onClick={e => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Logs: {container.name}</h2>
- <button className="modal-close" onClick={onClose}>&times;</button>
- </div>
- <div className="modal-body">
- <div className="logs-controls flex items-center gap-2 mb-2">
- <label>Lines:</label>
- <select value={tail} onChange={(e) => setTail(Number(e.target.value))} className="py-2 px-2">
- <option value={50}>50</option>
- <option value={100}>100</option>
- <option value={200}>200</option>
- <option value={500}>500</option>
- <option value={1000}>1000</option>
- </select>
+ <>
+ <div className="preview-drawer-backdrop" onClick={onClose} />
+ <aside className="preview-drawer">
+ <header className="preview-drawer-header">
+ <Box size={20} style={{ color: 'var(--accent-primary)' }} />
+ <div className="preview-drawer-title">
+ <h3>{container.name}</h3>
+ <p className="preview-drawer-path">{container.image} · {container.id?.substring(0, 12)}</p>
</div>
- <pre className="log-viewer">{loading ? 'Loading...' : logs}</pre>
+ <button className="preview-drawer-close" onClick={onClose}>
+ <X size={18} />
+ </button>
+ </header>
+
+ <div className="preview-drawer-meta">
+ <div className="meta-item">
+ <span className="meta-label">Status</span>
+ <span className="meta-value">{container.state || container.status}</span>
+ </div>
+ <div className="meta-item">
+ <span className="meta-label">Image</span>
+ <span className="meta-value mono">{container.image}</span>
+ </div>
+ <div className="meta-item meta-item-wide">
+ <span className="meta-label">ID</span>
+ <span className="meta-value mono">{container.id}</span>
+ </div>
+ {container.ports && (
+ <div className="meta-item meta-item-wide">
+ <span className="meta-label">Ports</span>
+ <span className="meta-value mono">{container.ports || '—'}</span>
+ </div>
+ )}
</div>
- <div className="modal-actions">
- <Button variant="outline" onClick={loadLogs} disabled={loading}>
- {loading ? 'Loading...' : 'Refresh'}
- </Button>
- <Button onClick={onClose}>Close</Button>
+
+ <LogToolbar
+ searchPattern={searchPattern}
+ onSearchChange={setSearchPattern}
+ onSearchSubmit={() => setAppliedSearch(searchPattern)}
+ onSearchClear={() => { setSearchPattern(''); setAppliedSearch(''); }}
+ lineCount={tail}
+ onLineCountChange={(n) => setTail(n)}
+ autoRefresh={autoRefresh}
+ onAutoRefreshToggle={() => setAutoRefresh(!autoRefresh)}
+ showLineNumbers={showLineNumbers}
+ onToggleLineNumbers={() => setShowLineNumbers(!showLineNumbers)}
+ wrapLines={wrapLines}
+ onToggleWrap={() => setWrapLines(!wrapLines)}
+ isFullscreen={false}
+ onToggleFullscreen={() => {}}
+ onRefresh={() => loadLogs()}
+ onDownload={handleDownload}
+ onClear={() => {}}
+ onScrollToBottom={() => {
+ if (contentRef.current) contentRef.current.scrollTop = contentRef.current.scrollHeight;
+ }}
+ canAct={true}
+ />
+
+ <div className="preview-drawer-body">
+ <LogContent
+ ref={contentRef}
+ content={logs}
+ loading={loading}
+ emptyMessage="No log output."
+ showLineNumbers={showLineNumbers}
+ wrapLines={wrapLines}
+ searchPattern={appliedSearch}
+ />
</div>
- </div>
- </div>
+ </aside>
+ </>
);
};
diff --git a/frontend/src/pages/Marketplace.jsx b/frontend/src/pages/Marketplace.jsx
index 8a0c8e1c..1e20ec2c 100644
--- a/frontend/src/pages/Marketplace.jsx
+++ b/frontend/src/pages/Marketplace.jsx
@@ -259,9 +259,11 @@ const Marketplace = () => {
{installSource === 'path' && (
<>
<p className="text-muted">
- Absolute path to a plugin folder on the panel host (must contain
- <code> plugin.json</code>). Useful for plugin development —
- edit, install, repeat.
+ Absolute path to a plugin folder <strong>on the panel host</strong>
+ — not on your local machine. If the backend runs in Docker, the
+ path must exist inside the container (bind-mount the folder, or
+ use <em>Upload Zip</em> instead). Folder must contain
+ <code> plugin.json</code>.
</p>
<div className="plugin-install-row">
<Input
diff --git a/frontend/src/pages/Terminal.jsx b/frontend/src/pages/Terminal.jsx
index 4c69b425..7b08d38d 100644
--- a/frontend/src/pages/Terminal.jsx
+++ b/frontend/src/pages/Terminal.jsx
@@ -4,9 +4,6 @@ import api from '../services/api';
import { useToast } from '../contexts/ToastContext';
import { useConfirm } from '../hooks/useConfirm';
import { ConfirmDialog } from '../components/ConfirmDialog';
-import { ProcessTable, ProcessDetailsPanel } from '../components/ProcessTable';
-import { ServiceCard, ServicesGrid } from '../components/ServiceCard';
-import { JournalControls } from '../components/JournalControls';
import TargetPicker from '../components/TargetPicker';
import LogFileList from '../components/log-viewer/LogFileList';
import LogToolbar from '../components/log-viewer/LogToolbar';
@@ -15,7 +12,7 @@ import { formatBytes, logKindFromPath } from '../components/log-viewer/logHelper
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs';
-import { FileText, Clock, AlertCircle } from 'lucide-react';
+import { FileText, Clock, AlertCircle, Search, X, RefreshCw, AlertTriangle, Activity, Play, Square, RotateCw } from 'lucide-react';
const VALID_TABS = ['logs', 'journal', 'processes', 'services'];
@@ -400,127 +397,403 @@ const LogFilesTab = () => {
);
};
+const COMMON_JOURNAL_UNITS = [
+ { id: 'nginx', label: 'Nginx', kind: 'nginx' },
+ { id: 'apache2', label: 'Apache', kind: 'apache' },
+ { id: 'mysql', label: 'MySQL', kind: 'database' },
+ { id: 'mariadb', label: 'MariaDB', kind: 'database' },
+ { id: 'postgresql', label: 'PostgreSQL', kind: 'database' },
+ { id: 'php-fpm', label: 'PHP-FPM', kind: 'php' },
+ { id: 'docker', label: 'Docker', kind: 'default' },
+ { id: 'sshd', label: 'SSH', kind: 'security' },
+ { id: 'cron', label: 'Cron', kind: 'system' },
+ { id: 'systemd', label: 'systemd', kind: 'system' },
+ { id: 'fail2ban', label: 'fail2ban', kind: 'security' },
+ { id: 'ufw', label: 'UFW', kind: 'security' },
+];
+
+const PRIORITY_OPTIONS = [
+ { value: '', label: 'All' },
+ { value: '0', label: 'Emergency' },
+ { value: '1', label: 'Alert' },
+ { value: '2', label: 'Critical' },
+ { value: '3', label: 'Error' },
+ { value: '4', label: 'Warning' },
+ { value: '5', label: 'Notice' },
+ { value: '6', label: 'Info' },
+ { value: '7', label: 'Debug' },
+];
+
+const JOURNAL_PREFS = {
+ showLineNumbers: 'serverkit-journal-line-numbers',
+ wrapLines: 'serverkit-journal-wrap',
+ lineCount: 'serverkit-journal-line-count',
+};
+
+const REMOTE_JOURNAL_SUPPORTED = new Set([]);
+
const JournalTab = () => {
- const [logs, setLogs] = useState('');
+ const toast = useToast();
+ const [target, setTarget] = useState({ kind: 'local' });
+ const isRemote = target.kind === 'agent';
+
+ const [logContent, setLogContent] = useState('');
const [loading, setLoading] = useState(false);
const [unavailable, setUnavailable] = useState(false);
const [unit, setUnit] = useState('');
- const [lineCount, setLineCount] = useState(100);
+ const [unitInput, setUnitInput] = useState('');
+ const [lineCount, setLineCount] = useState(() => {
+ const v = parseInt(localStorage.getItem(JOURNAL_PREFS.lineCount), 10);
+ return Number.isFinite(v) ? v : 200;
+ });
const [priority, setPriority] = useState('');
const [source, setSource] = useState('');
const [sourceLabel, setSourceLabel] = useState('');
- const [commonUnits] = useState([
- 'nginx', 'apache2', 'mysql', 'mariadb', 'postgresql',
- 'php-fpm', 'docker', 'sshd', 'cron', 'systemd'
- ]);
+ const [autoRefresh, setAutoRefresh] = useState(false);
+ const [searchPattern, setSearchPattern] = useState('');
+ const [appliedSearch, setAppliedSearch] = useState('');
+ const [showLineNumbers, setShowLineNumbers] = useState(() => localStorage.getItem(JOURNAL_PREFS.showLineNumbers) !== 'false');
+ const [wrapLines, setWrapLines] = useState(() => localStorage.getItem(JOURNAL_PREFS.wrapLines) !== 'false');
+ const [isFullscreen, setIsFullscreen] = useState(false);
+ const [unitFilter, setUnitFilter] = useState('');
+ const [lastUpdated, setLastUpdated] = useState(null);
+ const contentRef = useRef(null);
+ const intervalRef = useRef(null);
const isJournalctl = source === 'journalctl' || source === '';
- async function loadJournalLogs() {
- setLoading(true);
+ useEffect(() => { localStorage.setItem(JOURNAL_PREFS.showLineNumbers, showLineNumbers); }, [showLineNumbers]);
+ useEffect(() => { localStorage.setItem(JOURNAL_PREFS.wrapLines, wrapLines); }, [wrapLines]);
+ useEffect(() => { localStorage.setItem(JOURNAL_PREFS.lineCount, lineCount); }, [lineCount]);
+
+ useEffect(() => {
+ loadJournalLogs();
+ }, [target.kind, target.server_id]); // eslint-disable-line react-hooks/exhaustive-deps
+
+ useEffect(() => {
+ if (autoRefresh) {
+ intervalRef.current = setInterval(() => loadJournalLogs(false), 3000);
+ }
+ return () => { if (intervalRef.current) clearInterval(intervalRef.current); };
+ }, [autoRefresh, unit, lineCount, priority]); // eslint-disable-line
+
+ async function loadJournalLogs(showSpinner = true) {
+ if (isRemote && !REMOTE_JOURNAL_SUPPORTED.has('read')) {
+ setLogContent('');
+ setSource('');
+ setUnavailable(false);
+ setLoading(false);
+ return;
+ }
+ if (showSpinner) setLoading(true);
setUnavailable(false);
try {
const data = await api.getJournalLogs(unit || null, lineCount);
- setLogs(data.lines?.join('\n') || 'No logs available');
+ setLogContent(data.lines?.join('\n') || '');
setSource(data.source || '');
setSourceLabel(data.source_label || '');
+ setLastUpdated(new Date());
+ if (autoRefresh && contentRef.current) {
+ contentRef.current.scrollTop = contentRef.current.scrollHeight;
+ }
} catch (err) {
const msg = err.message || '';
if (msg.includes('No system log source available') || msg.includes('unavailable')) {
setUnavailable(true);
} else {
- setLogs(`Error: ${msg}`);
+ setLogContent(`Error: ${msg}`);
}
} finally {
setLoading(false);
}
}
- useEffect(() => {
- loadJournalLogs();
- }, []);
+ function pickUnit(u) {
+ setUnit(u);
+ setUnitInput(u);
+ setTimeout(() => loadJournalLogs(), 0);
+ }
+
+ function clearUnit() {
+ setUnit('');
+ setUnitInput('');
+ setTimeout(() => loadJournalLogs(), 0);
+ }
+
+ function applyUnitInput() {
+ setUnit(unitInput);
+ setTimeout(() => loadJournalLogs(), 0);
+ }
+
+ function handleDownload() {
+ if (!logContent) return;
+ const blob = new Blob([logContent], { type: 'text/plain' });
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement('a');
+ a.href = url;
+ a.download = `journal-${unit || 'all'}-${Date.now()}.log`;
+ a.click();
+ URL.revokeObjectURL(url);
+ }
+
+ function scrollToBottom() {
+ if (contentRef.current) contentRef.current.scrollTop = contentRef.current.scrollHeight;
+ }
+
+ const filteredUnits = useMemo(() => {
+ if (!unitFilter.trim()) return COMMON_JOURNAL_UNITS;
+ const q = unitFilter.toLowerCase();
+ return COMMON_JOURNAL_UNITS.filter(u => u.id.includes(q) || u.label.toLowerCase().includes(q));
+ }, [unitFilter]);
+
+ const visibleLineCount = useMemo(() => {
+ if (!logContent) return 0;
+ return logContent.split('\n').filter(Boolean).length;
+ }, [logContent]);
if (unavailable) {
return (
- <div className="journal-container">
- <div className="empty-state">
- <svg viewBox="0 0 24 24" width="48" height="48">
- <rect x="3" y="3" width="18" height="18" rx="2" ry="2"/>
- <line x1="9" y1="9" x2="15" y2="9"/>
- <line x1="9" y1="13" x2="15" y2="13"/>
- <line x1="9" y1="17" x2="11" y2="17"/>
- </svg>
- <h3>System Logs Unavailable</h3>
+ <div className="lv-page">
+ <div className="lv-empty-hint" style={{ minHeight: 400 }}>
+ <AlertCircle size={48} />
+ <h3 style={{ margin: 0, color: 'var(--text-primary)' }}>System Logs Unavailable</h3>
<p>
- No system log source was found on this server.
- Neither <code>journalctl</code>, <code>/var/log/syslog</code>,
- nor the Windows Event Log are available.
- </p>
- <p className="text-muted">
- Use the <strong>Log Files</strong> tab to browse available log files instead.
+ No system log source was found. Neither <code>journalctl</code>,
+ <code> /var/log/syslog</code>, nor the Windows Event Log are available.
</p>
+ <p>Use the <strong>Log Files</strong> tab to browse available log files instead.</p>
</div>
</div>
);
}
return (
- <div className="journal-container">
- <JournalControls
- unit={unit}
- onUnitChange={setUnit}
- unitLabel={isJournalctl ? 'Service/Unit' : 'Filter by service'}
- quickUnits={commonUnits}
- showQuickUnits={isJournalctl}
- lineCount={lineCount}
- onLineCountChange={setLineCount}
- priority={priority}
- onPriorityChange={setPriority}
- showPriority={isJournalctl}
- loading={loading}
- onLoad={loadJournalLogs}
- />
-
- {!isJournalctl && source && (
- <div className="journal-source-notice">
- <svg viewBox="0 0 24 24" width="16" height="16">
- <circle cx="12" cy="12" r="10"/>
- <line x1="12" y1="16" x2="12" y2="12"/>
- <line x1="12" y1="8" x2="12.01" y2="8"/>
- </svg>
- <span>
- Reading from <strong>{sourceLabel}</strong> — journalctl is not available on this system
+ <div className={`lv-page ${isFullscreen ? 'fullscreen' : ''}`}>
+ <div className="lv-header">
+ <div className="lv-header-target">
+ <span className="lv-header-label">Source</span>
+ <TargetPicker feature="logs" value={target} onChange={setTarget} />
+ {isRemote && (
+ <span className="lv-header-hint">
+ <AlertCircle size={12} />
+ Remote journal isn&apos;t available yet for {target.name}.
+ </span>
+ )}
+ {!isJournalctl && source && (
+ <span className="lv-header-hint" style={{
+ background: 'rgba(59, 130, 246, 0.1)',
+ borderColor: 'rgba(59, 130, 246, 0.25)',
+ color: '#60a5fa',
+ }}>
+ <AlertCircle size={12} />
+ Reading from <strong>&nbsp;{sourceLabel}</strong>
+ </span>
+ )}
+ </div>
+ <div className="lv-header-stats">
+ {unit && (
+ <span className="lv-stat">
+ <span className="lv-stat-label">Unit</span>
+ <span className="lv-stat-value">{unit}</span>
+ </span>
+ )}
+ <span className="lv-stat">
+ <span className="lv-stat-label">Showing</span>
+ <span className="lv-stat-value">{visibleLineCount.toLocaleString()} lines</span>
</span>
+ {lastUpdated && (
+ <span className="lv-stat">
+ <Clock size={12} />
+ {lastUpdated.toLocaleTimeString()}
+ </span>
+ )}
+ </div>
+ </div>
+
+ <div className="lv-layout">
+ <div className="lv-sidebar">
+ <div className="lv-sidebar-header">
+ <div className="lv-search">
+ <input
+ type="text"
+ value={unitInput}
+ onChange={(e) => setUnitInput(e.target.value)}
+ onKeyDown={(e) => e.key === 'Enter' && applyUnitInput()}
+ placeholder="Type unit name…"
+ style={{ paddingLeft: 8 }}
+ />
+ </div>
+ <button className="lv-icon-btn" onClick={applyUnitInput} title="Apply unit filter">
+ <Search size={13} />
+ </button>
+ </div>
+
+ <div className="lv-sidebar-body">
+ <div className="lv-group">
+ <button
+ className={`lv-file ${!unit ? 'active' : ''}`}
+ onClick={clearUnit}
+ style={{ gridTemplateColumns: '8px 1fr', gridTemplateAreas: '"dot name" "dot name"' }}
+ >
+ <span className="lv-file-dot" />
+ <span className="lv-file-name">All services</span>
+ </button>
+ </div>
+
+ <div className="lv-group">
+ <div className="lv-group-header" style={{ cursor: 'default' }}>
+ <span style={{ width: 12 }} />
+ <span>Common units</span>
+ <span className="lv-group-count">{filteredUnits.length}</span>
+ </div>
+ <div className="lv-group-files">
+ {filteredUnits.map(u => (
+ <button
+ key={u.id}
+ className={`lv-file ${unit === u.id ? 'active' : ''}`}
+ onClick={() => pickUnit(u.id)}
+ style={{ gridTemplateColumns: '8px 1fr', gridTemplateAreas: '"dot name" "dot name"' }}
+ >
+ <span className={`lv-file-dot kind-${u.kind}`} />
+ <span className="lv-file-name">{u.label}</span>
+ </button>
+ ))}
+ {filteredUnits.length === 0 && (
+ <div className="lv-empty-hint" style={{ padding: 12 }}>
+ <p>No matching units.</p>
+ </div>
+ )}
+ </div>
+ </div>
+
+ {isJournalctl && (
+ <div className="lv-group">
+ <div className="lv-group-header" style={{ cursor: 'default' }}>
+ <span style={{ width: 12 }} />
+ <span>Priority</span>
+ </div>
+ <div className="lv-group-files">
+ {PRIORITY_OPTIONS.map(opt => (
+ <button
+ key={opt.value}
+ className={`lv-file ${priority === opt.value ? 'active' : ''}`}
+ onClick={() => { setPriority(opt.value); setTimeout(loadJournalLogs, 0); }}
+ style={{ gridTemplateColumns: '8px 1fr', gridTemplateAreas: '"dot name" "dot name"' }}
+ >
+ <span className="lv-file-dot" style={{ background: priorityColor(opt.value) }} />
+ <span className="lv-file-name">{opt.label}</span>
+ </button>
+ ))}
+ </div>
+ </div>
+ )}
+ </div>
</div>
- )}
- <div className="journal-viewer">
- <pre>{loading ? 'Loading journal logs...' : logs}</pre>
+ <div className="lv-viewer">
+ {unit && (
+ <div className="lv-viewer-path">
+ <span className="lv-viewer-path-dot kind-system" />
+ <code>journalctl -u {unit}</code>
+ </div>
+ )}
+
+ <LogToolbar
+ searchPattern={searchPattern}
+ onSearchChange={setSearchPattern}
+ onSearchSubmit={() => setAppliedSearch(searchPattern)}
+ onSearchClear={() => { setSearchPattern(''); setAppliedSearch(''); }}
+ lineCount={lineCount}
+ onLineCountChange={(n) => { setLineCount(n); setTimeout(loadJournalLogs, 0); }}
+ autoRefresh={autoRefresh}
+ onAutoRefreshToggle={() => setAutoRefresh(!autoRefresh)}
+ showLineNumbers={showLineNumbers}
+ onToggleLineNumbers={() => setShowLineNumbers(!showLineNumbers)}
+ wrapLines={wrapLines}
+ onToggleWrap={() => setWrapLines(!wrapLines)}
+ isFullscreen={isFullscreen}
+ onToggleFullscreen={() => setIsFullscreen(!isFullscreen)}
+ onRefresh={() => loadJournalLogs()}
+ onDownload={handleDownload}
+ onClear={() => toast.error('Journal logs cannot be truncated from the panel.')}
+ onScrollToBottom={scrollToBottom}
+ canAct={!loading && !isRemote}
+ />
+
+ <LogContent
+ ref={contentRef}
+ content={logContent}
+ loading={loading}
+ emptyMessage={
+ isRemote
+ ? `Remote journal isn't supported yet for ${target.name}.`
+ : 'Loading journal…'
+ }
+ showLineNumbers={showLineNumbers}
+ wrapLines={wrapLines}
+ searchPattern={appliedSearch}
+ />
+ </div>
</div>
</div>
);
};
+function priorityColor(value) {
+ if (value === '0' || value === '1' || value === '2') return '#ef4444';
+ if (value === '3') return '#f87171';
+ if (value === '4') return '#f59e0b';
+ if (value === '5' || value === '6') return '#60a5fa';
+ if (value === '7') return '#94a3b8';
+ return '#71717a';
+}
+
const ProcessesTab = () => {
const toast = useToast();
const { confirm, confirmState, handleConfirm, handleCancel } = useConfirm();
+
+ const [target, setTarget] = useState({ kind: 'local' });
+ const isRemote = target.kind === 'agent';
+
const [processes, setProcesses] = useState([]);
const [loading, setLoading] = useState(true);
const [sortBy, setSortBy] = useState('cpu');
- const [limit, setLimit] = useState(50);
+ const [sortDir, setSortDir] = useState('desc');
+ const [limit, setLimit] = useState(100);
const [searchTerm, setSearchTerm] = useState('');
+ const [statusFilter, setStatusFilter] = useState('all');
+ const [userFilter, setUserFilter] = useState(null);
const [selectedProcess, setSelectedProcess] = useState(null);
+ const [autoRefresh, setAutoRefresh] = useState(false);
+ const [lastUpdated, setLastUpdated] = useState(null);
+
+ const intervalRef = useRef(null);
useEffect(() => {
loadProcesses();
- }, [sortBy, limit]);
+ }, [sortBy, limit, target.kind, target.server_id]); // eslint-disable-line
+
+ useEffect(() => {
+ if (autoRefresh) {
+ intervalRef.current = setInterval(() => loadProcesses(false), 4000);
+ }
+ return () => { if (intervalRef.current) clearInterval(intervalRef.current); };
+ }, [autoRefresh, sortBy, limit]); // eslint-disable-line
- async function loadProcesses() {
+ async function loadProcesses(showSpinner = true) {
+ if (isRemote) {
+ setProcesses([]);
+ setLoading(false);
+ return;
+ }
+ if (showSpinner) setLoading(true);
try {
const data = await api.getProcesses(limit, sortBy);
setProcesses(data.processes || []);
+ setLastUpdated(new Date());
} catch (err) {
console.error('Failed to load processes:', err);
+ toast.error(`Failed: ${err.message}`);
} finally {
setLoading(false);
}
@@ -528,81 +801,370 @@ const ProcessesTab = () => {
async function handleKillProcess(pid, force = false) {
const confirmMsg = force
- ? `Force kill process ${pid}? This may cause data loss.`
- : `Kill process ${pid}?`;
- const confirmed = await confirm({ title: force ? 'Force Kill Process' : 'Kill Process', message: confirmMsg, variant: force ? 'danger' : 'warning' });
+ ? `Force-kill PID ${pid}? Unsaved data may be lost.`
+ : `Kill PID ${pid}?`;
+ const confirmed = await confirm({
+ title: force ? 'Force-kill process' : 'Kill process',
+ message: confirmMsg,
+ variant: force ? 'danger' : 'warning',
+ confirmText: force ? 'Force kill' : 'Kill',
+ });
if (!confirmed) return;
-
try {
await api.killProcess(pid, force);
- toast.success(`Process ${pid} killed successfully`);
+ toast.success(`PID ${pid} killed`);
loadProcesses();
setSelectedProcess(null);
} catch (err) {
- toast.error(`Failed to kill process: ${err.message}`);
+ toast.error(`Failed: ${err.message}`);
}
}
- const filteredProcesses = processes.filter(p =>
- p.name?.toLowerCase().includes(searchTerm.toLowerCase()) ||
- p.command?.toLowerCase().includes(searchTerm.toLowerCase()) ||
- String(p.pid).includes(searchTerm)
- );
-
- if (loading) {
- return <div className="loading">Loading processes...</div>;
+ function toggleSort(col) {
+ if (sortBy === col) {
+ setSortDir(sortDir === 'asc' ? 'desc' : 'asc');
+ } else {
+ setSortBy(col);
+ setSortDir(col === 'name' || col === 'user' ? 'asc' : 'desc');
+ }
}
+ const userGroups = useMemo(() => {
+ const map = new Map();
+ for (const p of processes) {
+ const u = p.user || 'unknown';
+ map.set(u, (map.get(u) || 0) + 1);
+ }
+ return [...map.entries()].sort((a, b) => b[1] - a[1]);
+ }, [processes]);
+
+ const statusCounts = useMemo(() => {
+ const counts = { all: processes.length, running: 0, sleeping: 0, stopped: 0, zombie: 0 };
+ for (const p of processes) {
+ const s = (p.status || '').toLowerCase();
+ if (s === 'running') counts.running++;
+ else if (s === 'sleeping') counts.sleeping++;
+ else if (s === 'stopped') counts.stopped++;
+ else if (s === 'zombie') counts.zombie++;
+ }
+ return counts;
+ }, [processes]);
+
+ const totalCpu = useMemo(() => processes.reduce((s, p) => s + (p.cpu_percent || 0), 0), [processes]);
+ const totalMem = useMemo(() => processes.reduce((s, p) => s + (p.memory_info?.rss || 0), 0), [processes]);
+
+ const filtered = useMemo(() => {
+ let list = processes;
+ if (userFilter) list = list.filter(p => (p.user || 'unknown') === userFilter);
+ if (statusFilter !== 'all') list = list.filter(p => (p.status || '').toLowerCase() === statusFilter);
+ const q = searchTerm.toLowerCase();
+ if (q) {
+ list = list.filter(p =>
+ p.name?.toLowerCase().includes(q) ||
+ p.command?.toLowerCase().includes(q) ||
+ String(p.pid).includes(q)
+ );
+ }
+ const dir = sortDir === 'asc' ? 1 : -1;
+ const sorted = [...list];
+ sorted.sort((a, b) => {
+ switch (sortBy) {
+ case 'pid': return ((a.pid || 0) - (b.pid || 0)) * dir;
+ case 'name': return (a.name || '').localeCompare(b.name || '') * dir;
+ case 'user': return (a.user || '').localeCompare(b.user || '') * dir;
+ case 'memory': return ((a.memory_percent || 0) - (b.memory_percent || 0)) * dir;
+ case 'cpu':
+ default: return ((a.cpu_percent || 0) - (b.cpu_percent || 0)) * dir;
+ }
+ });
+ return sorted;
+ }, [processes, userFilter, statusFilter, searchTerm, sortBy, sortDir]);
+
return (
- <div className="processes-container">
- <div className="processes-toolbar">
- <div className="toolbar-left">
- <div className="search-input">
- <svg viewBox="0 0 24 24" width="16" height="16">
- <circle cx="11" cy="11" r="8"/>
- <line x1="21" y1="21" x2="16.65" y2="16.65"/>
- </svg>
- <Input
+ <div className="proc-page">
+ <div className="lv-header">
+ <div className="lv-header-target">
+ <span className="lv-header-label">Source</span>
+ <TargetPicker feature="processes" value={target} onChange={setTarget} />
+ {isRemote && (
+ <span className="lv-header-hint">
+ <AlertCircle size={12} />
+ Remote process control isn&apos;t available yet for {target.name}.
+ </span>
+ )}
+ </div>
+ <div className="lv-header-stats">
+ <span className="lv-stat">
+ <span className="lv-stat-label">Total</span>
+ <span className="lv-stat-value">{processes.length}</span>
+ </span>
+ <span className="lv-stat">
+ <span className="lv-stat-label">CPU</span>
+ <span className="lv-stat-value">{totalCpu.toFixed(1)}%</span>
+ </span>
+ <span className="lv-stat">
+ <span className="lv-stat-label">Memory</span>
+ <span className="lv-stat-value">{formatMemory(totalMem)}</span>
+ </span>
+ {lastUpdated && (
+ <span className="lv-stat">
+ <Clock size={12} />
+ {lastUpdated.toLocaleTimeString()}
+ </span>
+ )}
+ </div>
+ </div>
+
+ <div className="proc-toolbar">
+ <div className="proc-filter-chips">
+ {[
+ { id: 'all', label: 'All', count: statusCounts.all },
+ { id: 'running', label: 'Running', count: statusCounts.running },
+ { id: 'sleeping', label: 'Sleeping', count: statusCounts.sleeping },
+ { id: 'stopped', label: 'Stopped', count: statusCounts.stopped },
+ { id: 'zombie', label: 'Zombie', count: statusCounts.zombie },
+ ].map(c => (
+ <button
+ key={c.id}
+ className={`filter-chip ${statusFilter === c.id ? 'active' : ''}`}
+ onClick={() => setStatusFilter(c.id)}
+ disabled={c.id !== 'all' && c.count === 0}
+ >
+ <span>{c.label}</span>
+ <span className="filter-chip-count">{c.count}</span>
+ </button>
+ ))}
+ </div>
+ <div className="proc-toolbar-right">
+ <div className="lv-search-field">
+ <Search size={13} className="lv-search-field-icon" />
+ <input
type="text"
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
- placeholder="Search processes..."
+ placeholder="Filter PID, name, command…"
/>
+ {searchTerm && (
+ <button className="lv-search-field-clear" onClick={() => setSearchTerm('')}>
+ <X size={11} />
+ </button>
+ )}
</div>
- </div>
- <div className="toolbar-right">
- <select value={sortBy} onChange={(e) => setSortBy(e.target.value)}>
- <option value="cpu">Sort by CPU</option>
- <option value="memory">Sort by Memory</option>
- <option value="pid">Sort by PID</option>
- <option value="name">Sort by Name</option>
- </select>
- <select value={limit} onChange={(e) => setLimit(parseInt(e.target.value))}>
- <option value={25}>25 processes</option>
- <option value={50}>50 processes</option>
- <option value={100}>100 processes</option>
+ <select
+ className="lv-select"
+ value={limit}
+ onChange={(e) => setLimit(parseInt(e.target.value, 10))}
+ >
+ <option value={25}>Top 25</option>
+ <option value={50}>Top 50</option>
+ <option value={100}>Top 100</option>
+ <option value={250}>Top 250</option>
</select>
- <Button variant="outline" size="sm" onClick={loadProcesses}>
- Refresh
- </Button>
+ <button
+ className={`lv-chip ${autoRefresh ? 'active' : ''}`}
+ onClick={() => setAutoRefresh(!autoRefresh)}
+ disabled={isRemote}
+ >
+ <span className={`lv-pulse ${autoRefresh ? 'on' : ''}`} />
+ <span>Live</span>
+ </button>
+ <button className="lv-icon-btn" onClick={() => loadProcesses()} title="Refresh">
+ <RefreshCw size={13} className={loading ? 'spinning' : ''} />
+ </button>
</div>
</div>
- <ProcessTable
- processes={filteredProcesses}
- selectedPid={selectedProcess?.pid}
- onSelect={setSelectedProcess}
- onKill={(p) => handleKillProcess(p.pid)}
- onForceKill={(p) => handleKillProcess(p.pid, true)}
- formatMemory={formatMemory}
- getStatusVariant={getStatusVariant}
- />
+ <div className="proc-layout">
+ <aside className="proc-sidebar">
+ <div className="lv-sidebar-header">
+ <span className="lv-header-label" style={{ paddingLeft: 8 }}>Users</span>
+ </div>
+ <div className="lv-sidebar-body">
+ <button
+ className={`lv-file ${!userFilter ? 'active' : ''}`}
+ onClick={() => setUserFilter(null)}
+ style={{ gridTemplateColumns: '8px 1fr auto', gridTemplateAreas: '"dot name size" "dot name size"' }}
+ >
+ <span className="lv-file-dot" style={{ background: '#6366f1' }} />
+ <span className="lv-file-name">All users</span>
+ <span className="lv-file-size">{processes.length}</span>
+ </button>
+ {userGroups.map(([user, count]) => (
+ <button
+ key={user}
+ className={`lv-file ${userFilter === user ? 'active' : ''}`}
+ onClick={() => setUserFilter(user)}
+ style={{ gridTemplateColumns: '8px 1fr auto', gridTemplateAreas: '"dot name size" "dot name size"' }}
+ >
+ <span className="lv-file-dot" style={{ background: hashColor(user) }} />
+ <span className="lv-file-name">{user}</span>
+ <span className="lv-file-size">{count}</span>
+ </button>
+ ))}
+ </div>
+ </aside>
+
+ <div className="proc-main">
+ {loading ? (
+ <div className="lv-content-loading">Loading processes…</div>
+ ) : filtered.length === 0 ? (
+ <div className="lv-empty-hint" style={{ minHeight: 320 }}>
+ <p>No processes match your filters.</p>
+ </div>
+ ) : (
+ <div className="proc-table-wrap">
+ <table className="proc-table">
+ <thead>
+ <tr>
+ <th onClick={() => toggleSort('pid')} className={sortBy === 'pid' ? 'active' : ''}>
+ PID {sortBy === 'pid' && (sortDir === 'asc' ? '↑' : '↓')}
+ </th>
+ <th onClick={() => toggleSort('name')} className={sortBy === 'name' ? 'active' : ''}>
+ Process {sortBy === 'name' && (sortDir === 'asc' ? '↑' : '↓')}
+ </th>
+ <th onClick={() => toggleSort('user')} className={sortBy === 'user' ? 'active' : ''}>
+ User {sortBy === 'user' && (sortDir === 'asc' ? '↑' : '↓')}
+ </th>
+ <th onClick={() => toggleSort('cpu')} className={sortBy === 'cpu' ? 'active' : ''}>
+ CPU {sortBy === 'cpu' && (sortDir === 'asc' ? '↑' : '↓')}
+ </th>
+ <th onClick={() => toggleSort('memory')} className={sortBy === 'memory' ? 'active' : ''}>
+ Memory {sortBy === 'memory' && (sortDir === 'asc' ? '↑' : '↓')}
+ </th>
+ <th>Status</th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ {filtered.map(p => {
+ const cpu = Math.min(Number(p.cpu_percent) || 0, 100);
+ const mem = Math.min(Number(p.memory_percent) || 0, 100);
+ const isSelected = selectedProcess?.pid === p.pid;
+ return (
+ <tr
+ key={p.pid}
+ className={isSelected ? 'selected' : ''}
+ onClick={() => setSelectedProcess(p)}
+ >
+ <td className="mono">{p.pid}</td>
+ <td>
+ <div className="proc-name-cell">
+ <span className="proc-name">{p.name}</span>
+ {p.command && (
+ <span className="proc-cmd" title={p.command}>{p.command}</span>
+ )}
+ </div>
+ </td>
+ <td>
+ <span className="proc-user-tag">
+ <span className="proc-user-dot" style={{ background: hashColor(p.user) }} />
+ {p.user}
+ </span>
+ </td>
+ <td>
+ <div className="proc-bar-cell">
+ <span className="proc-bar-value">{cpu.toFixed(1)}%</span>
+ <div className="proc-bar"><div className="proc-bar-fill cpu" style={{ width: `${cpu}%` }} /></div>
+ </div>
+ </td>
+ <td>
+ <div className="proc-bar-cell">
+ <span className="proc-bar-value">{formatMemory(p.memory_info?.rss)}</span>
+ <div className="proc-bar"><div className="proc-bar-fill mem" style={{ width: `${mem}%` }} /></div>
+ </div>
+ </td>
+ <td>
+ <span className={`proc-status status-${(p.status || '').toLowerCase()}`}>
+ <span className="proc-status-dot" />
+ {p.status}
+ </span>
+ </td>
+ <td className="proc-actions" onClick={(e) => e.stopPropagation()}>
+ <button className="lv-icon-btn" onClick={() => handleKillProcess(p.pid)} title="Kill (SIGTERM)">
+ <X size={13} />
+ </button>
+ <button className="lv-icon-btn danger" onClick={() => handleKillProcess(p.pid, true)} title="Force kill (SIGKILL)">
+ <AlertTriangle size={13} />
+ </button>
+ </td>
+ </tr>
+ );
+ })}
+ </tbody>
+ </table>
+ </div>
+ )}
+ </div>
+ </div>
+
+ {selectedProcess && (
+ <>
+ <div className="preview-drawer-backdrop" onClick={() => setSelectedProcess(null)} />
+ <aside className="preview-drawer">
+ <header className="preview-drawer-header">
+ <Activity size={20} style={{ color: 'var(--accent-primary)' }} />
+ <div className="preview-drawer-title">
+ <h3>{selectedProcess.name}</h3>
+ <p className="preview-drawer-path">PID {selectedProcess.pid} · {selectedProcess.user}</p>
+ </div>
+ <button className="preview-drawer-close" onClick={() => setSelectedProcess(null)}>
+ <X size={18} />
+ </button>
+ </header>
+ <div className="preview-drawer-meta">
+ <div className="meta-item">
+ <span className="meta-label">PID</span>
+ <span className="meta-value mono">{selectedProcess.pid}</span>
+ </div>
+ <div className="meta-item">
+ <span className="meta-label">User</span>
+ <span className="meta-value">{selectedProcess.user}</span>
+ </div>
+ <div className="meta-item">
+ <span className="meta-label">Status</span>
+ <span className="meta-value">{selectedProcess.status}</span>
+ </div>
+ <div className="meta-item">
+ <span className="meta-label">Threads</span>
+ <span className="meta-value">{selectedProcess.num_threads ?? '—'}</span>
+ </div>
+ <div className="meta-item">
+ <span className="meta-label">CPU</span>
+ <span className="meta-value">{(selectedProcess.cpu_percent || 0).toFixed(2)}%</span>
+ </div>
+ <div className="meta-item">
+ <span className="meta-label">Memory</span>
+ <span className="meta-value">{formatMemory(selectedProcess.memory_info?.rss)}</span>
+ </div>
+ <div className="meta-item meta-item-wide">
+ <span className="meta-label">Started</span>
+ <span className="meta-value">
+ {selectedProcess.create_time
+ ? new Date(selectedProcess.create_time * 1000).toLocaleString()
+ : '—'}
+ </span>
+ </div>
+ </div>
+ <div className="preview-drawer-actions">
+ <button className="drawer-action-btn" onClick={() => handleKillProcess(selectedProcess.pid)}>
+ <X size={14} /> Kill (SIGTERM)
+ </button>
+ <button className="drawer-action-btn danger" onClick={() => handleKillProcess(selectedProcess.pid, true)}>
+ <AlertTriangle size={14} /> Force kill (SIGKILL)
+ </button>
+ </div>
+ <div className="preview-drawer-body" style={{ padding: 16 }}>
+ {selectedProcess.command && (
+ <>
+ <div className="meta-label" style={{ marginBottom: 6 }}>Command</div>
+ <pre className="proc-command">{selectedProcess.command}</pre>
+ </>
+ )}
+ </div>
+ </aside>
+ </>
+ )}
- <ProcessDetailsPanel
- process={selectedProcess}
- onClose={() => setSelectedProcess(null)}
- formatMemory={formatMemory}
- />
<ConfirmDialog
isOpen={confirmState.isOpen}
title={confirmState.title}
@@ -617,35 +1179,82 @@ const ProcessesTab = () => {
);
};
+// Stable colour from a string — used to tag users by colour.
+function hashColor(str) {
+ if (!str) return '#71717a';
+ const palette = ['#6366f1', '#10b981', '#f59e0b', '#ec4899', '#14b8a6', '#a855f7', '#0ea5e9', '#fb7185'];
+ let h = 0;
+ for (let i = 0; i < str.length; i++) h = (h * 31 + str.charCodeAt(i)) | 0;
+ return palette[Math.abs(h) % palette.length];
+}
+
const ServicesTab = () => {
const toast = useToast();
+ const { confirm, confirmState, handleConfirm, handleCancel } = useConfirm();
+
+ const [target, setTarget] = useState({ kind: 'local' });
+ const isRemote = target.kind === 'agent';
+
const [services, setServices] = useState([]);
const [loading, setLoading] = useState(true);
const [actionLoading, setActionLoading] = useState(null);
+ const [statusFilter, setStatusFilter] = useState('all');
+ const [searchTerm, setSearchTerm] = useState('');
const [selectedService, setSelectedService] = useState(null);
const [serviceLogs, setServiceLogs] = useState('');
- const [showLogsModal, setShowLogsModal] = useState(false);
+ const [logsLoading, setLogsLoading] = useState(false);
+ const [logSearch, setLogSearch] = useState('');
+ const [appliedLogSearch, setAppliedLogSearch] = useState('');
+ const [logLineCount, setLogLineCount] = useState(200);
+ const [logShowLineNumbers, setLogShowLineNumbers] = useState(true);
+ const [logWrap, setLogWrap] = useState(true);
+ const [logAutoRefresh, setLogAutoRefresh] = useState(false);
+ const logContentRef = useRef(null);
+ const logIntervalRef = useRef(null);
useEffect(() => {
loadServices();
- }, []);
+ }, [target.kind, target.server_id]); // eslint-disable-line
+
+ useEffect(() => {
+ if (logAutoRefresh && selectedService) {
+ logIntervalRef.current = setInterval(() => loadServiceLogs(selectedService, false), 3000);
+ }
+ return () => { if (logIntervalRef.current) clearInterval(logIntervalRef.current); };
+ }, [logAutoRefresh, selectedService, logLineCount, appliedLogSearch]); // eslint-disable-line
async function loadServices() {
+ if (isRemote) {
+ setServices([]);
+ setLoading(false);
+ return;
+ }
+ setLoading(true);
try {
const data = await api.getServicesStatus();
setServices(data.services || []);
} catch (err) {
- console.error('Failed to load services:', err);
+ toast.error(`Failed: ${err.message}`);
} finally {
setLoading(false);
}
}
- async function handleServiceAction(serviceName, action) {
+ async function handleAction(serviceName, action) {
+ const isDestructive = action === 'stop' || action === 'restart';
+ if (isDestructive) {
+ const ok = await confirm({
+ title: action === 'stop' ? 'Stop service' : 'Restart service',
+ message: `${action === 'stop' ? 'Stop' : 'Restart'} ${serviceName}?`,
+ variant: 'warning',
+ confirmText: action === 'stop' ? 'Stop' : 'Restart',
+ });
+ if (!ok) return;
+ }
setActionLoading(`${serviceName}-${action}`);
try {
await api.controlService(serviceName, action);
- toast.success(`Service ${serviceName} ${action}ed successfully`);
+ toast.success(`${serviceName} ${action}ed`);
await loadServices();
} catch (err) {
toast.error(`Failed to ${action} ${serviceName}: ${err.message}`);
@@ -654,126 +1263,337 @@ const ServicesTab = () => {
}
}
- async function viewServiceLogs(serviceName) {
- setSelectedService(serviceName);
- setShowLogsModal(true);
+ async function loadServiceLogs(serviceName, showSpinner = true) {
+ if (showSpinner) setLogsLoading(true);
try {
- const data = await api.getJournalLogs(serviceName, 100);
- setServiceLogs(data.lines?.join('\n') || 'No logs available');
+ const data = await api.getJournalLogs(serviceName, logLineCount);
+ setServiceLogs(data.lines?.join('\n') || '');
+ if (logAutoRefresh && logContentRef.current) {
+ logContentRef.current.scrollTop = logContentRef.current.scrollHeight;
+ }
} catch (err) {
- setServiceLogs(`Error loading logs: ${err.message}`);
+ setServiceLogs(`Error: ${err.message}`);
+ } finally {
+ setLogsLoading(false);
}
}
- function getServiceStatusVariant(status) {
- if (status === 'running' || status === 'active') return 'success';
- if (status === 'stopped' || status === 'inactive') return 'secondary';
- if (status === 'failed') return 'destructive';
- return 'warning';
+ function openServiceDrawer(service) {
+ setSelectedService(service);
+ setLogSearch('');
+ setAppliedLogSearch('');
+ loadServiceLogs(service.name);
+ }
+
+ function closeServiceDrawer() {
+ setSelectedService(null);
+ setLogAutoRefresh(false);
+ setServiceLogs('');
}
- if (loading) {
- return <div className="loading">Loading services...</div>;
+ function statusKind(status) {
+ const s = (status || '').toLowerCase();
+ if (s === 'running' || s === 'active') return 'running';
+ if (s === 'failed') return 'failed';
+ if (s === 'stopped' || s === 'inactive' || s === 'dead') return 'stopped';
+ return 'other';
}
+ const counts = useMemo(() => {
+ const c = { all: services.length, running: 0, stopped: 0, failed: 0 };
+ for (const s of services) {
+ const k = statusKind(s.status);
+ if (k === 'running') c.running++;
+ else if (k === 'stopped') c.stopped++;
+ else if (k === 'failed') c.failed++;
+ }
+ return c;
+ }, [services]);
+
+ const filtered = useMemo(() => {
+ let list = services;
+ if (statusFilter !== 'all') list = list.filter(s => statusKind(s.status) === statusFilter);
+ const q = searchTerm.toLowerCase();
+ if (q) {
+ list = list.filter(s =>
+ s.name?.toLowerCase().includes(q) ||
+ s.description?.toLowerCase().includes(q)
+ );
+ }
+ return list.slice().sort((a, b) => {
+ const ak = statusKind(a.status), bk = statusKind(b.status);
+ const order = { failed: 0, running: 1, other: 2, stopped: 3 };
+ if (ak !== bk) return (order[ak] ?? 4) - (order[bk] ?? 4);
+ return (a.name || '').localeCompare(b.name || '');
+ });
+ }, [services, statusFilter, searchTerm]);
+
return (
- <div className="services-container">
- <div className="services-toolbar">
- <Button variant="outline" size="sm" onClick={loadServices}>
- <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
- <polyline points="23 4 23 10 17 10"/>
- <path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/>
- </svg>
- Refresh
- </Button>
+ <div className="svc-page">
+ <div className="lv-header">
+ <div className="lv-header-target">
+ <span className="lv-header-label">Source</span>
+ <TargetPicker feature="services" value={target} onChange={setTarget} />
+ {isRemote && (
+ <span className="lv-header-hint">
+ <AlertCircle size={12} />
+ Remote service control isn&apos;t available yet for {target.name}.
+ </span>
+ )}
+ </div>
+ <div className="lv-header-stats">
+ <span className="lv-stat">
+ <span className="lv-stat-label">Total</span>
+ <span className="lv-stat-value">{services.length}</span>
+ </span>
+ <button
+ className="lv-icon-btn"
+ onClick={loadServices}
+ title="Refresh"
+ >
+ <RefreshCw size={13} className={loading ? 'spinning' : ''} />
+ </button>
+ </div>
</div>
- {services.length === 0 ? (
- <div className="empty-state">
- <p>No services found</p>
+ <div className="svc-toolbar">
+ <div className="proc-filter-chips">
+ {[
+ { id: 'all', label: 'All', count: counts.all },
+ { id: 'running', label: 'Running', count: counts.running },
+ { id: 'failed', label: 'Failed', count: counts.failed },
+ { id: 'stopped', label: 'Stopped', count: counts.stopped },
+ ].map(c => (
+ <button
+ key={c.id}
+ className={`filter-chip ${statusFilter === c.id ? 'active' : ''}`}
+ onClick={() => setStatusFilter(c.id)}
+ disabled={c.id !== 'all' && c.count === 0}
+ >
+ <span>{c.label}</span>
+ <span className="filter-chip-count">{c.count}</span>
+ </button>
+ ))}
+ </div>
+ <div className="lv-search-field" style={{ minWidth: 260 }}>
+ <Search size={13} className="lv-search-field-icon" />
+ <input
+ type="text"
+ value={searchTerm}
+ onChange={(e) => setSearchTerm(e.target.value)}
+ placeholder="Filter services…"
+ />
+ {searchTerm && (
+ <button className="lv-search-field-clear" onClick={() => setSearchTerm('')}>
+ <X size={11} />
+ </button>
+ )}
+ </div>
+ </div>
+
+ {loading ? (
+ <div className="lv-content-loading" style={{ minHeight: 320 }}>Loading services…</div>
+ ) : filtered.length === 0 ? (
+ <div className="lv-empty-hint" style={{ minHeight: 320 }}>
+ <p>{services.length === 0 ? 'No services found.' : 'No services match the current filters.'}</p>
</div>
) : (
- <ServicesGrid>
- {services.map(service => {
- const meta = [
- service.pid && { label: 'PID', value: service.pid },
- service.memory && { label: 'Memory', value: service.memory },
- ].filter(Boolean);
- const isRunning = service.status === 'running' || service.status === 'active';
+ <div className="svc-grid">
+ {filtered.map(service => {
+ const kind = statusKind(service.status);
+ const isRunning = kind === 'running';
+ const isFailed = kind === 'failed';
return (
- <ServiceCard
+ <div
key={service.name}
- name={service.name}
- description={service.description}
- status={service.status}
- statusVariant={getServiceStatusVariant(service.status)}
- meta={meta}
- actions={
- <>
- {isRunning ? (
- <>
- <Button
- variant="outline"
- size="sm"
- onClick={() => handleServiceAction(service.name, 'restart')}
- disabled={actionLoading === `${service.name}-restart`}
- >
- {actionLoading === `${service.name}-restart` ? '...' : 'Restart'}
- </Button>
- <Button
- variant="outline"
- size="sm"
- onClick={() => handleServiceAction(service.name, 'stop')}
- disabled={actionLoading === `${service.name}-stop`}
- >
- {actionLoading === `${service.name}-stop` ? '...' : 'Stop'}
- </Button>
- </>
- ) : (
- <Button
- size="sm"
- onClick={() => handleServiceAction(service.name, 'start')}
- disabled={actionLoading === `${service.name}-start`}
+ className={`svc-card status-${kind}`}
+ onClick={() => openServiceDrawer(service)}
+ >
+ <div className="svc-card-head">
+ <div className="svc-card-title">
+ <span className={`svc-status-dot status-${kind}`} />
+ <h4>{service.name}</h4>
+ </div>
+ <span className={`svc-status-pill status-${kind}`}>
+ {service.status || 'unknown'}
+ </span>
+ </div>
+ {service.description && (
+ <p className="svc-card-desc" title={service.description}>
+ {service.description}
+ </p>
+ )}
+ <div className="svc-card-meta">
+ {service.pid && (
+ <span><span className="svc-meta-label">PID</span> {service.pid}</span>
+ )}
+ {service.memory && (
+ <span><span className="svc-meta-label">Mem</span> {service.memory}</span>
+ )}
+ </div>
+ <div className="svc-card-actions" onClick={(e) => e.stopPropagation()}>
+ {isRunning ? (
+ <>
+ <button
+ className="svc-action-btn"
+ onClick={() => handleAction(service.name, 'restart')}
+ disabled={actionLoading === `${service.name}-restart`}
>
- {actionLoading === `${service.name}-start` ? '...' : 'Start'}
- </Button>
- )}
- <Button
- variant="outline"
- size="sm"
- onClick={() => viewServiceLogs(service.name)}
+ <RotateCw size={12} /> Restart
+ </button>
+ <button
+ className="svc-action-btn"
+ onClick={() => handleAction(service.name, 'stop')}
+ disabled={actionLoading === `${service.name}-stop`}
+ >
+ <Square size={12} /> Stop
+ </button>
+ </>
+ ) : (
+ <button
+ className={`svc-action-btn primary ${isFailed ? 'danger' : ''}`}
+ onClick={() => handleAction(service.name, 'start')}
+ disabled={actionLoading === `${service.name}-start`}
>
- Logs
- </Button>
- </>
- }
- />
+ <Play size={12} /> Start
+ </button>
+ )}
+ <button
+ className="svc-action-btn ghost"
+ onClick={() => openServiceDrawer(service)}
+ >
+ <FileText size={12} /> Logs
+ </button>
+ </div>
+ </div>
);
})}
- </ServicesGrid>
+ </div>
)}
- {/* Service Logs Modal */}
- {showLogsModal && (
- <div className="modal-overlay" onClick={() => setShowLogsModal(false)}>
- <div className="modal modal-lg" onClick={e => e.stopPropagation()}>
- <div className="modal-header">
- <h2>Logs: {selectedService}</h2>
- <button className="modal-close" onClick={() => setShowLogsModal(false)}>&times;</button>
- </div>
- <div className="modal-body">
- <div className="modal-log-viewer">
- <pre>{serviceLogs}</pre>
+ {selectedService && (
+ <>
+ <div className="preview-drawer-backdrop" onClick={closeServiceDrawer} />
+ <aside className="preview-drawer">
+ <header className="preview-drawer-header">
+ <span className={`svc-status-dot status-${statusKind(selectedService.status)}`} style={{ width: 12, height: 12 }} />
+ <div className="preview-drawer-title">
+ <h3>{selectedService.name}</h3>
+ <p className="preview-drawer-path">
+ {selectedService.description || `journalctl -u ${selectedService.name}`}
+ </p>
</div>
+ <button className="preview-drawer-close" onClick={closeServiceDrawer}>
+ <X size={18} />
+ </button>
+ </header>
+
+ <div className="preview-drawer-meta">
+ <div className="meta-item">
+ <span className="meta-label">Status</span>
+ <span className="meta-value">{selectedService.status || 'unknown'}</span>
+ </div>
+ {selectedService.pid && (
+ <div className="meta-item">
+ <span className="meta-label">PID</span>
+ <span className="meta-value mono">{selectedService.pid}</span>
+ </div>
+ )}
+ {selectedService.memory && (
+ <div className="meta-item">
+ <span className="meta-label">Memory</span>
+ <span className="meta-value">{selectedService.memory}</span>
+ </div>
+ )}
</div>
- <div className="modal-footer">
- <Button variant="outline" onClick={() => setShowLogsModal(false)}>
- Close
- </Button>
+
+ <div className="preview-drawer-actions">
+ {statusKind(selectedService.status) === 'running' ? (
+ <>
+ <button
+ className="drawer-action-btn"
+ onClick={() => handleAction(selectedService.name, 'restart')}
+ disabled={actionLoading === `${selectedService.name}-restart`}
+ >
+ <RotateCw size={14} /> Restart
+ </button>
+ <button
+ className="drawer-action-btn"
+ onClick={() => handleAction(selectedService.name, 'stop')}
+ disabled={actionLoading === `${selectedService.name}-stop`}
+ >
+ <Square size={14} /> Stop
+ </button>
+ </>
+ ) : (
+ <button
+ className="drawer-action-btn"
+ onClick={() => handleAction(selectedService.name, 'start')}
+ disabled={actionLoading === `${selectedService.name}-start`}
+ >
+ <Play size={14} /> Start
+ </button>
+ )}
</div>
- </div>
- </div>
+
+ <LogToolbar
+ searchPattern={logSearch}
+ onSearchChange={setLogSearch}
+ onSearchSubmit={() => setAppliedLogSearch(logSearch)}
+ onSearchClear={() => { setLogSearch(''); setAppliedLogSearch(''); }}
+ lineCount={logLineCount}
+ onLineCountChange={(n) => { setLogLineCount(n); setTimeout(() => loadServiceLogs(selectedService.name), 0); }}
+ autoRefresh={logAutoRefresh}
+ onAutoRefreshToggle={() => setLogAutoRefresh(!logAutoRefresh)}
+ showLineNumbers={logShowLineNumbers}
+ onToggleLineNumbers={() => setLogShowLineNumbers(!logShowLineNumbers)}
+ wrapLines={logWrap}
+ onToggleWrap={() => setLogWrap(!logWrap)}
+ isFullscreen={false}
+ onToggleFullscreen={() => {}}
+ onRefresh={() => loadServiceLogs(selectedService.name)}
+ onDownload={() => {
+ if (!serviceLogs) return;
+ const blob = new Blob([serviceLogs], { type: 'text/plain' });
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement('a');
+ a.href = url;
+ a.download = `${selectedService.name}-${Date.now()}.log`;
+ a.click();
+ URL.revokeObjectURL(url);
+ }}
+ onClear={() => toast.error('Journal logs cannot be truncated.')}
+ onScrollToBottom={() => {
+ if (logContentRef.current) logContentRef.current.scrollTop = logContentRef.current.scrollHeight;
+ }}
+ canAct={true}
+ />
+
+ <div className="preview-drawer-body">
+ <LogContent
+ ref={logContentRef}
+ content={serviceLogs}
+ loading={logsLoading}
+ emptyMessage="No log output."
+ showLineNumbers={logShowLineNumbers}
+ wrapLines={logWrap}
+ searchPattern={appliedLogSearch}
+ />
+ </div>
+ </aside>
+ </>
)}
+
+ <ConfirmDialog
+ isOpen={confirmState.isOpen}
+ title={confirmState.title}
+ message={confirmState.message}
+ confirmText={confirmState.confirmText}
+ cancelText={confirmState.cancelText}
+ variant={confirmState.variant}
+ onConfirm={handleConfirm}
+ onCancel={handleCancel}
+ />
</div>
);
};
diff --git a/frontend/src/styles/pages/_docker.scss b/frontend/src/styles/pages/_docker.scss
index b0023fcc..05a1e444 100644
--- a/frontend/src/styles/pages/_docker.scss
+++ b/frontend/src/styles/pages/_docker.scss
@@ -735,3 +735,365 @@
}
}
}
+
+// ============================================
+// DOCKER REDESIGN (dx-*)
+// ============================================
+.dx-page {
+ display: flex;
+ flex-direction: column;
+ gap: $space-3;
+}
+
+.dx-stats-row {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
+ gap: $space-3;
+}
+
+.dx-stat {
+ display: flex;
+ align-items: center;
+ gap: $space-3;
+ padding: $space-4;
+ background: $bg-card;
+ border: 1px solid $border-default;
+ border-radius: $radius-lg;
+ @include transition(all);
+
+ &:hover {
+ border-color: $border-hover;
+ transform: translateY(-1px);
+ box-shadow: $shadow-md;
+ }
+
+ &[data-kind='containers'] .dx-stat-icon { color: #3b82f6; background: rgba(59, 130, 246, 0.12); }
+ &[data-kind='images'] .dx-stat-icon { color: #8b5cf6; background: rgba(139, 92, 246, 0.12); }
+ &[data-kind='volumes'] .dx-stat-icon { color: #10b981; background: rgba(16, 185, 129, 0.12); }
+ &[data-kind='networks'] .dx-stat-icon { color: #f59e0b; background: rgba(245, 158, 11, 0.12); }
+}
+
+.dx-stat-icon {
+ width: 40px;
+ height: 40px;
+ border-radius: $radius-md;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ flex-shrink: 0;
+}
+
+.dx-stat-body {
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+ min-width: 0;
+ flex: 1;
+}
+
+.dx-stat-label {
+ font-size: 9px;
+ font-weight: $font-weight-semibold;
+ color: $text-tertiary;
+ text-transform: uppercase;
+ letter-spacing: 0.06em;
+}
+
+.dx-stat-value {
+ font-size: $font-size-2xl;
+ font-weight: $font-weight-semibold;
+ color: $text-primary;
+ line-height: 1;
+}
+
+.dx-stat-meta {
+ display: flex;
+ gap: $space-2;
+ margin-top: 2px;
+ flex-wrap: wrap;
+}
+
+.dx-stat-sub {
+ font-size: $font-size-xs;
+ color: $text-tertiary;
+}
+
+.dx-pill {
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ padding: 1px 7px;
+ border-radius: $radius-full;
+ font-size: 10px;
+ font-weight: $font-weight-medium;
+ background: $bg-tertiary;
+ color: $text-secondary;
+
+ .dot {
+ width: 6px;
+ height: 6px;
+ border-radius: 50%;
+ background: $text-tertiary;
+ }
+
+ &.running {
+ background: fade($success, 12%);
+ color: $success;
+ .dot { background: $success; }
+ }
+ &.stopped {
+ background: $bg-tertiary;
+ color: $text-tertiary;
+ }
+}
+
+// ─── Tabs (replaces docker-panel-tabs) ──────────
+.dx-tabs {
+ display: flex;
+ gap: $space-1;
+ padding: 4px;
+ background: $bg-card;
+ border: 1px solid $border-default;
+ border-radius: $radius-lg;
+ overflow-x: auto;
+ scrollbar-width: thin;
+}
+
+.dx-tab {
+ background: transparent;
+ border: none;
+ padding: 8px $space-4;
+ border-radius: $radius-md;
+ color: $text-secondary;
+ font-size: $font-size-sm;
+ font-weight: $font-weight-medium;
+ cursor: pointer;
+ white-space: nowrap;
+ @include transition(all);
+
+ &:hover { background: $bg-hover; color: $text-primary; }
+ &.active {
+ background: $accent-glow;
+ color: $accent-primary;
+ }
+}
+
+.dx-panel {
+ background: $bg-card;
+ border: 1px solid $border-default;
+ border-radius: $radius-lg;
+ overflow: hidden;
+ min-height: 400px;
+}
+
+.dx-tab-pane {
+ padding: $space-3;
+}
+
+.dx-tab-toolbar {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ gap: $space-3;
+ padding-bottom: $space-3;
+ margin-bottom: $space-3;
+ border-bottom: 1px solid $border-subtle;
+ flex-wrap: wrap;
+}
+
+.dx-tab-toolbar-right {
+ display: flex;
+ align-items: center;
+ gap: $space-2;
+ flex-wrap: wrap;
+}
+
+// ─── Container card grid ─────────────────────────
+.dx-container-grid {
+ display: grid;
+ gap: $space-3;
+ grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
+}
+
+.dx-container-card {
+ position: relative;
+ background: $bg-elevated;
+ border: 1px solid $border-default;
+ border-radius: $radius-lg;
+ padding: $space-3 $space-4 $space-4;
+ display: flex;
+ flex-direction: column;
+ gap: $space-2;
+ cursor: pointer;
+ @include transition(all);
+ overflow: hidden;
+
+ &::before {
+ content: '';
+ position: absolute;
+ left: 0; top: 0; bottom: 0;
+ width: 3px;
+ background: $border-default;
+ }
+
+ &.is-running::before { background: $success; }
+ &.is-stopped::before { background: $text-tertiary; }
+
+ &:hover {
+ border-color: $border-hover;
+ transform: translateY(-2px);
+ box-shadow: $shadow-md;
+ }
+}
+
+.dx-card-head {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ gap: $space-2;
+}
+
+.dx-card-title {
+ display: flex;
+ align-items: center;
+ gap: $space-2;
+ min-width: 0;
+ flex: 1;
+
+ h4 {
+ margin: 0;
+ font-size: $font-size-sm;
+ font-weight: $font-weight-semibold;
+ color: $text-primary;
+ @include truncate();
+ }
+}
+
+.dx-status-dot {
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ flex-shrink: 0;
+
+ &.running { background: $success; box-shadow: 0 0 0 3px fade($success, 16%); }
+ &.stopped { background: $text-tertiary; }
+}
+
+.dx-status-pill {
+ display: inline-flex;
+ padding: 1px 8px;
+ border-radius: $radius-full;
+ font-size: 10px;
+ font-weight: $font-weight-semibold;
+ text-transform: uppercase;
+ letter-spacing: 0.04em;
+ background: $bg-tertiary;
+ color: $text-tertiary;
+
+ &.running { background: fade($success, 14%); color: $success; }
+ &.stopped { background: $bg-tertiary; color: $text-tertiary; }
+}
+
+.dx-card-image {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ color: $text-tertiary;
+ font-family: $font-mono;
+ font-size: $font-size-xs;
+
+ span { @include truncate(); }
+ svg { color: #8b5cf6; flex-shrink: 0; }
+}
+
+.dx-card-detail {
+ font-size: $font-size-xs;
+ color: $text-secondary;
+ @include truncate();
+}
+
+.dx-card-ports {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 4px;
+}
+
+.dx-port-pill {
+ display: inline-flex;
+ align-items: center;
+ padding: 1px 6px;
+ background: $bg-tertiary;
+ border-radius: $radius-sm;
+ font-family: $font-mono;
+ font-size: 10px;
+ color: $text-secondary;
+ @include truncate();
+ max-width: 220px;
+}
+
+.dx-port-more {
+ display: inline-flex;
+ align-items: center;
+ padding: 1px 6px;
+ background: $bg-tertiary;
+ border-radius: $radius-sm;
+ font-size: 10px;
+ color: $text-tertiary;
+}
+
+.dx-card-resources {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ margin-top: $space-1;
+}
+
+.dx-res {
+ display: grid;
+ grid-template-columns: 50px 1fr 50px;
+ gap: $space-2;
+ align-items: center;
+}
+
+.dx-res-label {
+ display: inline-flex;
+ align-items: center;
+ gap: 3px;
+ font-size: 10px;
+ color: $text-tertiary;
+ text-transform: uppercase;
+ letter-spacing: 0.04em;
+ font-weight: $font-weight-semibold;
+}
+
+.dx-res-track {
+ height: 4px;
+ background: $border-default;
+ border-radius: $radius-sm;
+ overflow: hidden;
+}
+
+.dx-res-fill {
+ height: 100%;
+ @include transition(width);
+
+ &.cpu { background: $accent-primary; }
+ &.mem { background: #10b981; }
+}
+
+.dx-res-value {
+ text-align: right;
+ font-family: $font-mono;
+ font-size: 10px;
+ color: $text-secondary;
+}
+
+.dx-card-actions {
+ display: flex;
+ gap: $space-1;
+ flex-wrap: wrap;
+ padding-top: $space-2;
+ margin-top: auto;
+ border-top: 1px solid $border-subtle;
+}
+
diff --git a/frontend/src/styles/pages/_terminal.scss b/frontend/src/styles/pages/_terminal.scss
index 3289293a..b9e516cc 100644
--- a/frontend/src/styles/pages/_terminal.scss
+++ b/frontend/src/styles/pages/_terminal.scss
@@ -661,6 +661,435 @@ $lk-default: #71717a;
font-weight: $font-weight-semibold;
}
+// ============================================
+// PROCESSES TAB (proc-*)
+// ============================================
+.proc-page {
+ display: flex;
+ flex-direction: column;
+ gap: $space-3;
+ height: calc(100vh - 220px);
+ min-height: 540px;
+}
+
+.proc-toolbar {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ gap: $space-3;
+ padding: $space-2 $space-3;
+ background: $bg-card;
+ border: 1px solid $border-default;
+ border-radius: $radius-lg;
+ flex-wrap: wrap;
+}
+
+.proc-filter-chips {
+ display: flex;
+ gap: $space-2;
+ flex-wrap: wrap;
+}
+
+.proc-toolbar-right {
+ display: flex;
+ align-items: center;
+ gap: $space-2;
+ flex-wrap: wrap;
+}
+
+.proc-layout {
+ display: grid;
+ grid-template-columns: 220px 1fr;
+ gap: $space-3;
+ flex: 1;
+ min-height: 0;
+
+ @media (max-width: $breakpoint-lg) {
+ grid-template-columns: 1fr;
+ grid-template-rows: 200px 1fr;
+ }
+}
+
+.proc-sidebar {
+ background: $bg-card;
+ border: 1px solid $border-default;
+ border-radius: $radius-lg;
+ display: flex;
+ flex-direction: column;
+ overflow: hidden;
+ min-height: 0;
+}
+
+.proc-main {
+ background: $bg-card;
+ border: 1px solid $border-default;
+ border-radius: $radius-lg;
+ overflow: hidden;
+ display: flex;
+ flex-direction: column;
+ min-height: 0;
+}
+
+.proc-table-wrap {
+ flex: 1;
+ overflow: auto;
+ scrollbar-width: thin;
+
+ &::-webkit-scrollbar { width: 8px; height: 8px; }
+ &::-webkit-scrollbar-thumb { background: $border-default; border-radius: $radius-sm; }
+}
+
+.proc-table {
+ width: 100%;
+ border-collapse: collapse;
+ font-size: $font-size-sm;
+
+ thead th {
+ position: sticky;
+ top: 0;
+ background: $bg-elevated;
+ text-align: left;
+ padding: $space-2 $space-3;
+ font-size: $font-size-xs;
+ font-weight: $font-weight-semibold;
+ text-transform: uppercase;
+ letter-spacing: 0.04em;
+ color: $text-tertiary;
+ cursor: pointer;
+ @include transition(color);
+ z-index: 1;
+ border-bottom: 1px solid $border-default;
+ user-select: none;
+
+ &:hover { color: $text-secondary; }
+ &.active { color: $accent-primary; }
+ }
+
+ tbody tr {
+ border-bottom: 1px solid $border-subtle;
+ cursor: pointer;
+ @include transition(background);
+
+ &:hover { background: $bg-hover; }
+ &.selected { background: $accent-glow; }
+ }
+
+ td {
+ padding: $space-2 $space-3;
+ vertical-align: middle;
+ }
+
+ .mono { font-family: $font-mono; font-size: $font-size-xs; }
+}
+
+.proc-name-cell {
+ display: flex;
+ flex-direction: column;
+ min-width: 0;
+ max-width: 320px;
+}
+
+.proc-name {
+ color: $text-primary;
+ font-weight: $font-weight-medium;
+ @include truncate();
+}
+
+.proc-cmd {
+ font-family: $font-mono;
+ font-size: 10px;
+ color: $text-tertiary;
+ @include truncate();
+}
+
+.proc-user-tag {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ color: $text-secondary;
+}
+
+.proc-user-dot {
+ width: 6px;
+ height: 6px;
+ border-radius: 50%;
+}
+
+.proc-bar-cell {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ min-width: 80px;
+}
+
+.proc-bar-value {
+ font-family: $font-mono;
+ font-size: $font-size-xs;
+ color: $text-secondary;
+}
+
+.proc-bar {
+ height: 3px;
+ background: $border-default;
+ border-radius: $radius-sm;
+ overflow: hidden;
+}
+
+.proc-bar-fill {
+ height: 100%;
+ @include transition(width);
+
+ &.cpu { background: $accent-primary; }
+ &.mem { background: #a855f7; }
+}
+
+.proc-status {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ padding: 2px 8px;
+ border-radius: $radius-full;
+ font-size: $font-size-xs;
+ font-weight: $font-weight-medium;
+ background: $bg-tertiary;
+ color: $text-secondary;
+}
+
+.proc-status-dot {
+ width: 6px;
+ height: 6px;
+ border-radius: 50%;
+ background: $text-tertiary;
+}
+
+.proc-status.status-running { background: fade($success, 12%); color: $success;
+ .proc-status-dot { background: $success; } }
+.proc-status.status-sleeping { background: fade($info, 10%); color: $info;
+ .proc-status-dot { background: $info; } }
+.proc-status.status-stopped { background: fade($danger, 10%); color: $danger;
+ .proc-status-dot { background: $danger; } }
+.proc-status.status-zombie { background: fade($warning, 12%); color: $warning;
+ .proc-status-dot { background: $warning; } }
+.proc-status.status-disk-sleep { background: fade($warning, 10%); color: $warning;
+ .proc-status-dot { background: $warning; } }
+
+.proc-actions {
+ display: flex;
+ gap: 2px;
+ justify-content: flex-end;
+}
+
+.proc-command {
+ font-family: $font-mono;
+ font-size: $font-size-xs;
+ color: $text-secondary;
+ background: $bg-body;
+ border: 1px solid $border-default;
+ padding: $space-3;
+ border-radius: $radius-md;
+ margin: 0;
+ overflow-x: auto;
+ white-space: pre-wrap;
+ word-break: break-all;
+}
+
+// ============================================
+// SERVICES TAB (svc-*)
+// ============================================
+.svc-page {
+ display: flex;
+ flex-direction: column;
+ gap: $space-3;
+}
+
+.svc-toolbar {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ gap: $space-3;
+ padding: $space-2 $space-3;
+ background: $bg-card;
+ border: 1px solid $border-default;
+ border-radius: $radius-lg;
+ flex-wrap: wrap;
+}
+
+.svc-grid {
+ display: grid;
+ gap: $space-3;
+ grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
+}
+
+.svc-card {
+ position: relative;
+ background: $bg-card;
+ border: 1px solid $border-default;
+ border-radius: $radius-lg;
+ padding: $space-4;
+ display: flex;
+ flex-direction: column;
+ gap: $space-3;
+ cursor: pointer;
+ @include transition(all);
+ overflow: hidden;
+
+ &::before {
+ content: '';
+ position: absolute;
+ left: 0; top: 0; bottom: 0;
+ width: 3px;
+ background: $border-default;
+ @include transition(background);
+ }
+
+ &.status-running::before { background: $success; }
+ &.status-failed::before { background: $danger; }
+ &.status-stopped::before { background: $text-tertiary; }
+ &.status-other::before { background: $warning; }
+
+ &:hover {
+ border-color: $border-hover;
+ transform: translateY(-1px);
+ box-shadow: $shadow-md;
+ }
+
+ &.status-failed {
+ background: linear-gradient(135deg, fade($danger, 4%), $bg-card 60%);
+ }
+}
+
+.svc-card-head {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ gap: $space-2;
+}
+
+.svc-card-title {
+ display: flex;
+ align-items: center;
+ gap: $space-2;
+ min-width: 0;
+
+ h4 {
+ margin: 0;
+ font-size: $font-size-sm;
+ font-weight: $font-weight-semibold;
+ color: $text-primary;
+ @include truncate();
+ font-family: $font-mono;
+ }
+}
+
+.svc-status-dot {
+ display: inline-block;
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ background: $text-tertiary;
+ flex-shrink: 0;
+
+ &.status-running { background: $success; box-shadow: 0 0 0 3px fade($success, 18%); }
+ &.status-failed { background: $danger; box-shadow: 0 0 0 3px fade($danger, 18%); }
+ &.status-stopped { background: $text-tertiary; }
+ &.status-other { background: $warning; }
+}
+
+.svc-status-pill {
+ display: inline-flex;
+ align-items: center;
+ padding: 2px 8px;
+ border-radius: $radius-full;
+ font-size: 10px;
+ font-weight: $font-weight-semibold;
+ text-transform: uppercase;
+ letter-spacing: 0.04em;
+ background: $bg-tertiary;
+ color: $text-tertiary;
+
+ &.status-running { background: fade($success, 14%); color: $success; }
+ &.status-failed { background: fade($danger, 14%); color: $danger; }
+ &.status-stopped { background: $bg-tertiary; color: $text-tertiary; }
+ &.status-other { background: fade($warning, 12%); color: $warning; }
+}
+
+.svc-card-desc {
+ margin: 0;
+ font-size: $font-size-xs;
+ color: $text-secondary;
+ line-height: 1.5;
+ display: -webkit-box;
+ -webkit-line-clamp: 2;
+ -webkit-box-orient: vertical;
+ overflow: hidden;
+}
+
+.svc-card-meta {
+ display: flex;
+ gap: $space-4;
+ font-size: $font-size-xs;
+ color: $text-tertiary;
+ font-family: $font-mono;
+}
+
+.svc-meta-label {
+ color: $text-tertiary;
+ font-weight: $font-weight-semibold;
+ text-transform: uppercase;
+ letter-spacing: 0.04em;
+ margin-right: 2px;
+ font-size: 9px;
+}
+
+.svc-card-actions {
+ display: flex;
+ gap: $space-1;
+ margin-top: auto;
+ padding-top: $space-3;
+ border-top: 1px solid $border-subtle;
+ flex-wrap: wrap;
+}
+
+.svc-action-btn {
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ padding: 5px 10px;
+ background: $bg-elevated;
+ border: 1px solid $border-default;
+ border-radius: $radius-sm;
+ color: $text-primary;
+ font-size: $font-size-xs;
+ font-weight: $font-weight-medium;
+ cursor: pointer;
+ @include transition(all);
+
+ &:hover:not(:disabled) {
+ background: $bg-hover;
+ border-color: $border-hover;
+ }
+ &:disabled { opacity: 0.5; cursor: not-allowed; }
+
+ &.primary {
+ background: $accent-primary;
+ border-color: $accent-primary;
+ color: white;
+ &:hover:not(:disabled) { background: $accent-hover; border-color: $accent-hover; }
+ }
+ &.danger {
+ background: $danger;
+ border-color: $danger;
+ color: white;
+ &:hover:not(:disabled) { background: $danger-hover; border-color: $danger-hover; }
+ }
+ &.ghost {
+ background: transparent;
+ border-color: transparent;
+ color: $text-secondary;
+ &:hover:not(:disabled) { background: $bg-hover; color: $text-primary; }
+ }
+}
+
// ============================================
// JOURNAL TAB
// ============================================