Galaxy Shell / docs
Docs / Interface e recursos

System metrics in the bar

openspec/specs/system-metrics/spec.md · Editar no GitHub ↗

Esta página ainda não tem tradução em português. O conteúdo abaixo está em inglês.

Nesta página

System metrics in the bar

Purpose

The protected bar shows CPU, memory, network, disk, temperature and GPU indicators, and a protected panel shows nine labeled cards with the last minute of history.

Requirements

Requirement: Unknown values hide individually

The system SHALL hide each unknown indicator individually, treat zero as a valid idle reading, and keep initial throughput samples unknown until two counters exist. Full text: section Introduction.

Scenario: First sample

  • WHEN only one counter sample exists
  • THEN the throughput stays unknown and never becomes an invented spike

Requirement: No new agent route or tool

The system SHALL keep the existing authenticated route and renderer network boundaries and SHALL NOT add a new agent tool or route for metrics. Full text: section Introduction.

Scenario: Bar metrics

  • WHEN /api/metrics?view=bar is served
  • THEN it exposes only the numeric hardware summary in addition to CPU/memory

Requirement: Read-only Linux sources

The system SHALL read the Linux sources read-only in core/hardware-metrics.js, excluding loopback, bridges, veth and virtual VPN devices from network, and partitions, loop and stacked virtual devices from disk activity. Full text: section Introduction.

Scenario: Virtual interface

  • WHEN a veth or bridge interface carries traffic
  • THEN it is excluded to avoid counting traffic twice

Requirement: Rates are never invented

The system SHALL compute rates with monotonic elapsed time and match devices by identity. A first sample, counter reset, missing device or read error MUST NOT become an invented throughput spike, and a failure in one source MUST NOT suppress the others. Full text: section Introduction.

Scenario: Counter reset

  • WHEN a counter resets
  • THEN no throughput spike is shown

Requirement: Other platforms keep CPU and memory

The system SHALL leave the hardware indicators unavailable when the Linux sources are missing on another platform, and CPU/memory remain. Full text: section Introduction.

Scenario: Non-Linux platform

  • WHEN the Linux sources are missing
  • THEN the hardware indicators are unavailable and CPU/memory remain

Requirement: Bounded metrics group in the taskbar

The system SHALL bound the taskbar metrics group by --bar-metrics-max-width, wrapping whole buttons that do not fit into the existing clipped second row without overlapping the tray or clock. Full text: section Introduction.

Scenario: Not enough width

  • WHEN buttons do not fit within the limit
  • THEN whole buttons wrap into the clipped second row

Requirement: Persisted visible count

The system SHALL persist the profile setting metricsVisibleCount (0 to 9, default 2) through the protected POST /api/metrics-visible-count with exactly {count}, and unavailable sensors MUST NOT reserve an empty slot. Full text: section Resizable capacity and the graph panel.

Scenario: Resize

  • WHEN the user drags the separator or presses End
  • THEN the capacity changes, with End showing all nine slots

Requirement: Panel view excludes quota and credentials

The system SHALL poll /api/metrics?view=panel every two seconds while the panel is visible; that view MUST exclude plan quota and credentials. Hardware samples accompany the bounded 31-point in-memory history, and no history is written to disk. Full text: section Resizable capacity and the graph panel.

Scenario: Unavailable sensor

  • WHEN a sensor is unknown
  • THEN its card is labeled unavailable and the chart line breaks

Requirement: Protected panel without agent authority

The system SHALL register and migrate the system-metrics panel like tray overflow and reserve it against isolated plugins. No agent tool, generated HTML or scheduled turn SHALL gain metric-selection authority. Full text: section Resizable capacity and the graph panel.

Scenario: Agent attempt

  • WHEN an agent tool, generated HTML or scheduled turn targets metric selection
  • THEN it has no authority to do so

Requirement: Fresh installs seed the panel

The system SHALL seed system-metrics in scripts/link-interface.py with the same declaration and ordering as PanelRegistry.defaults(), and the installer MUST leave existing web-panels.json files untouched. Full text: section Resizable capacity and the graph panel.

Scenario: Existing profile

  • WHEN a profile already has web-panels.json
  • THEN the installer does not change it and the core's protected panel migration handles it

Status

Doc status: current contract. Checked 2026-11-10.

Introduction

The protected bar shows CPU, memory, download, upload, filesystem usage, physical disk throughput, CPU temperature, GPU load and GPU temperature. Every indicator is a React button with a Portuguese accessible label and tooltip; it opens the existing system monitor action. Unknown values hide individually. Zero is a valid idle reading; initial throughput samples are unknown until two counters exist.

SystemMetrics samples every two seconds and /api/metrics?view=bar exposes only the numeric hardware summary in addition to CPU/memory. The existing authenticated route and renderer network boundaries stay in place. No new agent tool or route is added. The history contract of CPU/memory is unchanged.

Linux sources, read-only in core/hardware-metrics.js:

  • Network: RX/TX byte counters of physical /sys/class/net/*/device interfaces. Loopback, bridges, veth and virtual VPN devices are excluded to avoid counting traffic twice. Both directions are shown as decimal B/s, kB/s or MB/s.
  • Disk usage: statfs of the active profile directory, used blocks out of total blocks. This measures that filesystem, not every mounted filesystem.
  • Disk activity: combined read/write rates of whole physical /sys/block devices with a device link. Partitions, loop and stacked virtual devices are excluded. Sector counters use 512-byte units; the tooltip separates read and write rates.
  • Temperatures: hottest valid CPU hwmon channel from k10temp, coretemp, zenpower or cpu_thermal, and hottest GPU channel from amdgpu, nouveau, i915 or xe. Values are converted from millidegrees Celsius; unknown sensors are not relabeled as CPU. CPU control-temperature offsets remain those reported by the driver.
  • GPU load: gpu_busy_percent of DRM cards that expose this interface (notably AMD); the highest available card value is used. Other drivers may provide no load value. No vendor CLI or extra driver is installed. Multi-GPU load and temperature are independent maxima, not necessarily from the same card.

Rates use monotonic elapsed time and match devices by identity. A first sample, counter reset, missing device or read error never becomes an invented throughput spike. A failure in one source does not suppress the others. Missing Linux sources on other platforms leave these indicators unavailable; CPU/memory remain.

The taskbar metrics group is bounded by --bar-metrics-max-width (by default, half the output width minus six --space-4xl units for the other controls). Whole buttons that do not fit wrap into the existing clipped second row; icons and text do not overlap the tray or clock. Profile CSS can adjust that limit.

Sources: kernel block statistics, hwmon units and interfaces, AMDGPU sensors and load.

Changes to collection or React need host/core activation once. Appearance changes continue to use the profile theme copy and live CSS flow.

Resizable capacity and the graph panel

Office starts with two available indicators in the bar. Drag its left separator left to reveal more, right to hide more. Left/Right keys adjust capacity, Home hides all and End shows all nine slots. The profile setting metricsVisibleCount (0 to 9, default 2) persists through the protected POST /api/metrics-visible-count with exactly {count}. The bar poll returns this preference; unavailable sensors never reserve an empty slot. The tray uses the same React resize handle, with its existing capacity and persistence.

Since 2026-11-09 the Office figures are compact (openspec/specs/ui-themes/spec.md): a small icon and the number in tabular numerals, two to a column at the height of the clock, so one slot of the handle is half a column. A chart icon after them stays available even when every indicator is visible. It opens the protected system-metrics panel, so the Office bar shows no "Métricas do sistema" label while the metrics show (with them off, the label is back); the Glass top bar keeps that label. Nine labeled cards show readings and the last minute of history. Gaps in unavailable readings break the chart line. Unknown sensors are labeled unavailable; a short initial history is labeled collecting. The panel polls /api/metrics?view=panel every two seconds while visible; that view excludes plan quota and credentials. Hardware samples accompany the existing bounded 31-point in-memory history; no history is written to disk.

The protected panel is registered and migrated like tray overflow and is reserved against isolated plugins. It uses the shared protected React panel runtime, semantic tokens and stylesheet revision. No agent tool, generated HTML or scheduled turn gains metric-selection authority. Publication and host/core activation remain separate.

Fresh home installations seed system-metrics in scripts/link-interface.py with the same declaration and ordering as PanelRegistry.defaults(). The interface-link test compares the complete lists to catch drift. Existing web-panels.json files remain untouched by the installer; the core's protected panel migration handles existing profiles.