diff --git a/frontend/src/App.css b/frontend/src/App.css index 4c9baf65..6c4ea072 100644 --- a/frontend/src/App.css +++ b/frontend/src/App.css @@ -278,10 +278,9 @@ body { } .node-name { - font-family: var(--font-mono); font-weight: 500; font-size: 13px; - letter-spacing: 0.3px; + letter-spacing: var(--tracking-name); color: var(--text-primary); white-space: nowrap; overflow: hidden; @@ -289,8 +288,7 @@ body { } .selected-node-header .node-name { - font-family: var(--font-mono); - letter-spacing: 0.3px; + font-weight: 600; } .node-project { @@ -936,7 +934,7 @@ body { } .tunnel-local code { - font-family: monospace; + font-family: var(--font-mono); background: rgba(0, 0, 0, 0.3); padding: 2px 6px; border-radius: 4px; @@ -1153,6 +1151,7 @@ body { .service-name { font-weight: 600; font-size: 14px; + letter-spacing: var(--tracking-name); color: var(--text-primary); } @@ -1305,7 +1304,7 @@ body { padding: 10px; max-height: 150px; overflow-y: auto; - font-family: monospace; + font-family: var(--font-mono); font-size: 11px; text-align: left; user-select: text; @@ -1381,6 +1380,7 @@ body { .cluster-name { font-size: 13px; font-weight: 500; + letter-spacing: var(--tracking-name); margin-bottom: 4px; white-space: nowrap; overflow: hidden; @@ -1468,7 +1468,7 @@ body { } .token-input { - font-family: monospace; + font-family: var(--font-mono); font-size: 13px; flex: 1; min-width: 0; @@ -1506,7 +1506,7 @@ body { .token-field-value { flex: 1; min-width: 0; - font-family: monospace; + font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.5px; color: var(--text-primary); @@ -1836,7 +1836,7 @@ body { .version-value { color: var(--text-primary); - font-family: monospace; + font-variant-numeric: tabular-nums; } .update-available-row { @@ -2013,7 +2013,7 @@ body { .stats-text { font-size: 11px; - font-family: monospace; + font-variant-numeric: tabular-nums; color: var(--text-secondary); display: flex; gap: 4px; diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 90af6e09..e1f94775 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -4,7 +4,7 @@ import { ConnectToNode, CancelConnection, GetSettings, SaveSettings, GetDeviceSe import { Search, Settings, Server, Activity, Save, Monitor, ArrowLeft, Terminal, Globe, Lock, Unlock, AlertTriangle, ChevronDown, ChevronRight, X, Plus, Check, AlertCircle, Cpu, Wifi, HardDrive, Clock, Hash, ExternalLink, Copy, Play, RefreshCw, Trash2, ArrowRight, Info, Download, Box, Layers, Shield, Moon, Sun, HelpCircle, Key, Plug, Unplug } from 'lucide-react'; import eveOsIcon from './assets/eve-os.png'; import Tooltip from './components/Tooltip'; -import DeviceInfoPanel, { formatWorkloadUsage } from './components/DeviceInfoPanel'; +import DeviceInfoPanel, { AppUsage, formatWorkloadUsage } from './components/DeviceInfoPanel'; import useDeviceInfo from './useDeviceInfo'; import About from './components/About'; import UpdateBanner from './components/UpdateBanner'; @@ -224,7 +224,7 @@ const PortComboBox = ({ value, onChange, exposedPorts = [], showCommonPorts = tr height: '34px', boxSizing: 'border-box', outline: 'none', - fontFamily: 'var(--font-mono)' + fontVariantNumeric: 'tabular-nums' }} /> {matchedPort && ( @@ -364,7 +364,7 @@ const PortComboBox = ({ value, onChange, exposedPorts = [], showCommonPorts = tr style={{ display: 'flex', alignItems: 'center', width: '100%' }} title={`${p.label} - ${p.description}`} > -
+
{p.port}
@@ -3410,12 +3410,24 @@ Do you want to try connecting anyway?`)) { } else if (e.key === 'Enter') { const node = getNodeAtIndex(selectedIndex); if (node) handleConnect(node); - } else if (e.metaKey && e.key === ',') { - e.preventDefault(); - setShowSettings(true); } }; + // Cmd+, (Ctrl+, on Windows/Linux) opens Settings from every view. Listened + // for on window rather than in handleKeyDown: that handler stops early on + // the device page, and only sees keys while focus is inside the container + // (focus drops to when a focused control unmounts). + useEffect(() => { + const onKeyDown = (e) => { + if ((e.metaKey || e.ctrlKey) && !e.altKey && !e.shiftKey && e.key === ',') { + e.preventDefault(); + setShowSettings(true); + } + }; + window.addEventListener('keydown', onKeyDown); + return () => window.removeEventListener('keydown', onKeyDown); + }, []); + const addNewCluster = () => { const newName = `Cluster ${config.clusters.length + 1}`; const newClusters = [...config.clusters, { name: newName, baseUrl: '', apiToken: '' }]; @@ -4412,7 +4424,7 @@ Do you want to try connecting anyway?`)) { style={{ padding: '8px 10px', cursor: 'pointer', background: editingCluster.baseUrl === u ? 'var(--bg-hover)' : 'transparent', - fontFamily: 'Menlo, monospace', fontSize: '13px', + fontSize: '13px', }} onMouseEnter={(e) => { e.currentTarget.style.background = 'var(--bg-hover)'; }} onMouseLeave={(e) => { e.currentTarget.style.background = editingCluster.baseUrl === u ? 'var(--bg-hover)' : 'transparent'; }} @@ -5088,7 +5100,7 @@ Do you want to try connecting anyway?`)) { padding: '3px 10px', borderRadius: '6px', fontSize: '11px', - fontFamily: 'monospace', + fontFamily: 'var(--font-mono)', whiteSpace: 'nowrap', border: '1px solid var(--border-subtle, rgba(255, 255, 255, 0.06))', color: 'inherit', @@ -5342,7 +5354,7 @@ Do you want to try connecting anyway?`)) { >
{k.valid ? k.type : 'unparseable line'} @@ -5381,7 +5393,7 @@ Do you want to try connecting anyway?`)) {
{k.fingerprint && (
{k.fingerprint} @@ -5391,7 +5403,7 @@ Do you want to try connecting anyway?`)) {
Memory: used / allocated to this app
}> - - {usage.text} - + ); })()} @@ -5637,7 +5647,7 @@ Do you want to try connecting anyway?`)) { borderRadius: '4px', padding: '2px 6px', fontSize: '11px', - fontFamily: 'monospace', + fontFamily: 'var(--font-mono)', color: 'var(--text-secondary)', cursor: 'pointer', display: 'flex', @@ -5747,7 +5757,7 @@ Do you want to try connecting anyway?`)) { borderRadius: '4px', padding: '2px 6px', fontSize: '11px', - fontFamily: 'monospace', + fontVariantNumeric: 'tabular-nums', color: 'var(--text-secondary)', cursor: 'pointer', display: 'flex', @@ -6356,7 +6366,7 @@ Do you want to try connecting anyway?`)) { borderRadius: '4px', padding: '2px 6px', fontSize: '13px', - fontFamily: 'monospace', + fontFamily: 'var(--font-mono)', cursor: 'pointer', width: '100%' }} @@ -6434,7 +6444,7 @@ Do you want to try connecting anyway?`)) { borderRadius: '4px', padding: '2px 6px', fontSize: '13px', - fontFamily: 'monospace', + fontFamily: 'var(--font-mono)', cursor: 'pointer' }} > diff --git a/frontend/src/App.test.jsx b/frontend/src/App.test.jsx index 57ae9712..21b8787d 100644 --- a/frontend/src/App.test.jsx +++ b/frontend/src/App.test.jsx @@ -2534,7 +2534,8 @@ describe('Device info section', () => { await openDevice(); const summary = await screen.findByTestId('device-summary'); expect(electronAPI.GetDeviceInfo).toHaveBeenCalledWith('node-1', 'Info-Dev'); - expect(summary).toHaveTextContent('EVE 16.6.0-lts · up 3d 5h · CPU 7.5% · Mem 2.5/8.0 GB'); + expect(summary).toHaveTextContent('EVE 16.6.0-lts · up 3d 5h'); + expect(screen.getByTestId('device-summary-usage')).toHaveAttribute('aria-label', 'CPU 7.5% · Mem 2.5/8.0 GB'); expect(deviceToggle()).toHaveAttribute('aria-expanded', 'false'); expect(screen.queryByText('UPTIME', { selector: '.status-label' })).not.toBeInTheDocument(); @@ -2653,8 +2654,11 @@ describe('Device info section', () => { ], })); await openDevice(); - await waitFor(() => expect(usageOf('docker-runtime')).toHaveTextContent('CPU 3.0% · 1.2 / 2.0 GB')); - expect(usageOf('compose-app')).toHaveTextContent('CPU 12% · 300 MB / 1.0 GB'); + await waitFor(() => expect(usageOf('docker-runtime')).toHaveAttribute('aria-label', 'CPU 3.0% · 1.2 / 2.0 GB')); + expect(usageOf('compose-app')).toHaveAttribute('aria-label', 'CPU 12% · 300 MB / 1.0 GB'); + // Rendered as gauges: a mini bar each for CPU and memory. + expect(usageOf('docker-runtime')).toHaveTextContent('CPU3.0%MEM1.2/2.0 GB'); + expect(within(usageOf('docker-runtime')).getAllByTestId('usage-bar')).toHaveLength(2); expect(usageOf('name-twin')).toBeNull(); // One read feeds both the Device section and the app rows. expect(electronAPI.GetDeviceInfo).toHaveBeenCalledTimes(1); @@ -2666,8 +2670,23 @@ describe('Device info section', () => { electronAPI.GetDeviceServices.mockResolvedValue(JSON.stringify([{ id: 'a1', name: 'my-app', status: 'RUN_STATE_HALTED', appType: 'APP_TYPE_VM' }])); electronAPI.GetDeviceInfo.mockResolvedValue(deviceInfo({ online: false })); await openDevice(); - await waitFor(() => expect(usageOf('my-app')).toHaveTextContent('256 MB / 1.0 GB')); + await waitFor(() => expect(usageOf('my-app')).toHaveAttribute('aria-label', '256 MB / 1.0 GB')); expect(usageOf('my-app')).not.toHaveTextContent('CPU'); + expect(within(usageOf('my-app')).getAllByTestId('usage-bar')).toHaveLength(1); + }); + + it('opens Settings with Cmd+, (or Ctrl+,) from the device page, wherever focus is', async () => { + await openDevice(); + await screen.findByText('Running Applications'); + // Focus outside the app container (e.g. after a focused control unmounted). + document.activeElement?.blur(); + fireEvent.keyDown(document.body, { key: ',', metaKey: true }); + await screen.findByRole('heading', { name: 'Configuration' }); + + fireEvent.click(document.querySelector('.settings-panel .close-btn')); + await waitFor(() => expect(screen.queryByRole('heading', { name: 'Configuration' })).not.toBeInTheDocument()); + fireEvent.keyDown(document.body, { key: ',', ctrlKey: true }); + await screen.findByRole('heading', { name: 'Configuration' }); }); it('shows no usage on app rows when device info has no data', async () => { diff --git a/frontend/src/components/DeviceInfoPanel.jsx b/frontend/src/components/DeviceInfoPanel.jsx index e15aeb9a..5637e353 100644 --- a/frontend/src/components/DeviceInfoPanel.jsx +++ b/frontend/src/components/DeviceInfoPanel.jsx @@ -126,16 +126,83 @@ const subStyle = { ...ellipsis, maxWidth: '100%', fontSize: '11px', color: 'var( // Thin usage bar, the same width under every resource value. `pct` is // clamped to 0-100 for display only. -const Bar = ({ pct }) => { +const Bar = ({ pct, width = '64px', height = '3px', style }) => { const clamped = Math.max(0, Math.min(100, pct)); const color = clamped >= 90 ? 'var(--color-danger)' : clamped >= 75 ? 'var(--color-warning)' : 'var(--color-success)'; return ( -
+
); }; +const meterLabel = { fontSize: '9px', fontWeight: 600, letterSpacing: '0.06em', color: 'var(--text-secondary)' }; +const meterValue = { fontSize: '11.5px', fontWeight: 500, color: 'var(--text-primary)', fontVariantNumeric: 'tabular-nums' }; + +// One gauge in AppUsage: tiny caps label, mini bar (when there is a ratio), +// value. +const Meter = ({ label, pct, value }) => ( + + {label} + {pct !== null && } + {value} + +); + +// Inset pill of Meters, so resource numbers read as metrics rather than as +// another label. `label` is the accessible name (the same numbers as text). +const UsagePill = ({ label, meters, ...rest }) => ( + + {meters.filter(Boolean).map((m) => )} + +); + +/** + * CPU / memory gauges for an app row in Running Applications. Same rules as + * formatWorkloadUsage (which also gives its accessible name): CPU is left + * out while the device is offline. Renders nothing when there is nothing to + * show. + */ +export const AppUsage = ({ workload: w, online, ...rest }) => { + const text = formatWorkloadUsage(w, online); + if (!text) return null; + const cpu = online ? num(w.cpuPercent) : null; + const used = num(w.memUsedMB); + const alloc = num(w.memAllocatedMB); + let mem = null; + if (used !== null && alloc !== null) mem = { pct: alloc > 0 ? (used / alloc) * 100 : null, value: formatMBPair(used, alloc, '/') }; + else if (alloc !== null) mem = { pct: null, value: `${formatMB(alloc)} alloc.` }; + else if (used !== null) mem = { pct: null, value: formatMB(used) }; + return ( + + ); +}; + +// Grid sub-line for a resource: a bar, with the percent used beside it when +// the value is not already a percent. +const ResourceSub = ({ pct, caption }) => ( +
+ + {caption && {caption}} +
+); + // Multi-line tooltip body. Passed as a node (not a string) so the Tooltip // keeps line breaks and does not add its "Copy" header. const TipLines = ({ lines }) => ( @@ -285,13 +352,20 @@ const DeviceInfoPanel = ({ info, failed, authFailed, isOnline, timeFormatOptions : storTotal !== null ? formatMB(storTotal) : storUsed !== null ? formatMB(storUsed) : '—'; + const memPct = memCommitted !== null && memTotal ? (memCommitted / memTotal) * 100 : null; + const storPct = storUsed !== null && storTotal ? (storUsed / storTotal) * 100 : null; + // --- Collapsed one-line summary: only the parts we actually have. --- - const summary = [ + // Facts as text, resources as gauges (same pill as the app rows). + const summaryText = [ info.eveVersion && `EVE ${eve.version}`, online ? (uptimeValue !== '—' && `up ${uptimeValue}`) : (bootAgo && `last boot ${bootAgo}`), - cpuPct !== null && `CPU ${formatPercent(cpuPct)}`, - memCommitted !== null && memTotal !== null && `Mem ${formatMBPair(memCommitted, memTotal, '/')}`, ].filter(Boolean).join(' · '); + const summaryMeters = [ + cpuPct !== null && { label: 'CPU', pct: cpuPct, value: formatPercent(cpuPct) }, + memPct !== null && { label: 'MEM', pct: memPct, value: formatMBPair(memCommitted, memTotal, '/') }, + ].filter(Boolean); + const summaryUsage = summaryMeters.map((m) => `${m.label === 'MEM' ? 'Mem' : m.label} ${m.value}`).join(' · '); return (
@@ -319,8 +393,11 @@ const DeviceInfoPanel = ({ info, failed, authFailed, isOnline, timeFormatOptions ? : } Device - {!expanded && summary && ( - {summary} + {!expanded && (summaryText || summaryMeters.length > 0) && ( + + {summaryText && {summaryText}} + {summaryMeters.length > 0 && } + )} {expanded && !online && ( offline · values are last reported @@ -351,19 +428,19 @@ const DeviceInfoPanel = ({ info, failed, authFailed, isOnline, timeFormatOptions label="CPU" tip={cpuTip} value={cpuPct !== null ? formatPercent(cpuPct) : '—'} - sub={cpuPct !== null && } + sub={cpuPct !== null && } /> } + sub={memPct !== null && } /> } + sub={storPct !== null && } />
)} diff --git a/frontend/src/components/DeviceInfoPanel.test.jsx b/frontend/src/components/DeviceInfoPanel.test.jsx index 7b0fd2e3..d5d571d3 100644 --- a/frontend/src/components/DeviceInfoPanel.test.jsx +++ b/frontend/src/components/DeviceInfoPanel.test.jsx @@ -1,9 +1,9 @@ import React from 'react'; -import { render, screen, fireEvent, waitFor } from '@testing-library/react'; +import { render, screen, fireEvent, waitFor, within } from '@testing-library/react'; import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest'; import DeviceInfoPanel, { - formatMB, formatMBPair, formatPercent, formatDuration, splitEveVersion, formatWorkloadUsage, EXPANDED_STORAGE_KEY, + formatMB, formatMBPair, formatPercent, formatDuration, splitEveVersion, formatWorkloadUsage, AppUsage, EXPANDED_STORAGE_KEY, } from './DeviceInfoPanel'; const NOW = new Date('2026-10-27T12:00:00Z'); @@ -61,7 +61,12 @@ describe('DeviceInfoPanel', () => { it('is collapsed by default, with a one-line summary in the title row', () => { renderPanel(); expect(screen.getByRole('button', { name: /Device/ })).toHaveAttribute('aria-expanded', 'false'); - expect(summary()).toHaveTextContent('EVE 16.6.0-lts · up 2d 2h · CPU 13% · Mem 2.6/7.6 GB'); + expect(summary()).toHaveTextContent('EVE 16.6.0-lts · up 2d 2h'); + // CPU / memory as gauges, named with the same numbers as text. + const usage = screen.getByTestId('device-summary-usage'); + expect(usage).toHaveAttribute('aria-label', 'CPU 13% · Mem 2.6/7.6 GB'); + expect(usage).toHaveTextContent('CPU13%MEM2.6/7.6 GB'); + expect(within(usage).getAllByTestId('usage-bar')).toHaveLength(2); // Platform suffix stays out of the summary too. expect(summary()).not.toHaveTextContent('kvm-amd64'); expect(screen.queryByText('UPTIME', { selector: '.status-label' })).not.toBeInTheDocument(); @@ -84,6 +89,10 @@ describe('DeviceInfoPanel', () => { // committed = 2048 apps + 640 EVE = 2688 MB = 2.6 GB of 7.6 GB expect(valueOf('MEMORY')).toHaveTextContent('2.6 GB / 7.6 GB'); expect(valueOf('STORAGE')).toHaveTextContent('33 GB / 120 GB'); + // Memory / storage bars carry the percent used; CPU's value already is one. + expect(valueOf('MEMORY')).toHaveTextContent(/34%$/); + expect(valueOf('STORAGE')).toHaveTextContent(/28%$/); + expect(valueOf('CPU')).toHaveTextContent(/^CPU13%$/); expand(); expect(screen.queryByText('UPTIME', { selector: '.status-label' })).not.toBeInTheDocument(); @@ -174,7 +183,8 @@ describe('DeviceInfoPanel', () => { it('offline: "last boot" instead of uptime, no CPU, values flagged as last reported', () => { renderPanel({ isOnline: false, info: info({ online: false, runState: 'RUN_STATE_OFFLINE', uptimeSec: undefined, cpu: { percent: 0, cores: 4 } }) }); - expect(summary()).toHaveTextContent('EVE 16.6.0-lts · last boot 2d 2h ago · Mem 2.6/7.6 GB'); + expect(summary()).toHaveTextContent('EVE 16.6.0-lts · last boot 2d 2h ago'); + expect(screen.getByTestId('device-summary-usage')).toHaveAttribute('aria-label', 'Mem 2.6/7.6 GB'); expect(summary()).not.toHaveTextContent('CPU'); expand(); expect(screen.queryByText('UPTIME', { selector: '.status-label' })).not.toBeInTheDocument(); @@ -201,7 +211,7 @@ describe('DeviceInfoPanel', () => { it('shows a dash for memory when the controller sent all zeros', () => { renderPanel({ info: info({ memory: { usedEveMB: 0, allocatedAppsMB: 0, allocatedEveMB: 0 } }) }); - expect(summary()).not.toHaveTextContent('Mem'); + expect(screen.getByTestId('device-summary-usage')).toHaveAttribute('aria-label', 'CPU 13%'); expand(); expect(valueOf('MEMORY')).toHaveTextContent('—'); expect(valueOf('MEMORY')).not.toHaveTextContent('0 MB'); @@ -311,4 +321,25 @@ describe('formatters', () => { expect(formatWorkloadUsage({}, true)).toBe(''); expect(formatWorkloadUsage(null, true)).toBe(''); }); + + it('renders app usage as CPU / MEM gauges with bars sized to the ratio', () => { + const w = { cpuPercent: 80, memUsedMB: 1229, memAllocatedMB: 2048 }; + const { container, rerender } = render(); + const u = screen.getByTestId('u'); + expect(u).toHaveAttribute('role', 'group'); + expect(u).toHaveAttribute('aria-label', 'CPU 80% · 1.2 / 2.0 GB'); + expect(u).toHaveTextContent('CPU80%MEM1.2/2.0 GB'); + const bars = screen.getAllByTestId('usage-bar'); + expect(bars).toHaveLength(2); + expect(bars[0].firstChild.style.width).toBe('80%'); + expect(parseFloat(bars[1].firstChild.style.width)).toBeCloseTo(60, 0); + + // Offline: no CPU gauge. Allocation only: value without a bar. + rerender(); + expect(screen.getByTestId('u')).toHaveTextContent('MEM512 MB alloc.'); + expect(screen.queryByTestId('usage-bar')).toBeNull(); + + rerender(); + expect(container).toBeEmptyDOMElement(); + }); }); diff --git a/frontend/src/components/TerminalView.jsx b/frontend/src/components/TerminalView.jsx index 79e97eaa..d1ac78db 100644 --- a/frontend/src/components/TerminalView.jsx +++ b/frontend/src/components/TerminalView.jsx @@ -416,7 +416,7 @@ const TerminalView = ({ port }) => { pointerEvents: 'none' }}> - {connectionInfo.nodeName} • {connectionInfo.targetInfo} + {connectionInfo.nodeName} • {connectionInfo.targetInfo}