feat(ssh): collect remote host resource metrics over the relay
What
Adds a relay-side host.metrics probe that reports the SSH host's own resource usage: total/free/used memory, memory usage percent, CPU core count, 1/5/15-minute load averages, and uptime.
New API: orca.ssh.getHostMetrics({ targetId }) → { metrics | null }.
Why
Orca's existing resource-usage surface reflects the local machine (os.* in the Electron main process). When agents run on an SSH execution host, the remote box's CPU/memory/load was previously unobservable. Because the relay executes on that host, os.* there reads the remote machine directly — no extra SSH round-trip.
How
src/relay/host-metrics-handler.ts— registershost.metrics; collection is a pure, unit-testedbuildHostResourceMetrics()fed fromnode:os.src/main/ipc/ssh.ts—ssh:getHostMetricsforwards through the active multiplexer; disconnected host →{ metrics: null }.src/shared/host-resource-metrics-types.ts—HostResourceMetrics/HostMetricsResult(field names aligned with the existingHostMemory).- preload — exposes
ssh.getHostMetrics.
Robustness / cross-platform
Every numeric field is clamped: NaN/negative/undefined → safe values, free memory never exceeds total, core count floors at 1 (renderers can divide by cores safely). Windows hosts report [0,0,0] load without special-casing. Satisfies the SSH use case + Cross-Platform requirements in AGENTS.md.
Scope
Backend only; the status-bar / panel surface that renders remote metrics for the active SSH execution host is a follow-up.
Test plan
- [x]
vitest— 4 unit tests (usage math, NaN/negative clamping, free>total guard, Windows-style zero load) - [x]
typecheck(node + cli + web) clean - [x]
oxlintclean on changed files - [ ] Manual: connect an SSH host, call
getHostMetrics, confirm remote load/memory matchuptime/free -bon that box
📝 Walkthrough
Walkthrough
This PR adds a host resource metrics feature for SSH targets. A new shared type module defines HostResourceMetrics and HostMetricsResult. A relay-side HostMetricsHandler registers a host.metrics request handler, collecting memory, CPU core count, load averages, uptime, and platform via Node's os module, with input sanitization (clampNumber, buildHostResourceMetrics) and unit tests. The handler is wired into the relay's main(). On the main process, a new ssh:getHostMetrics IPC handler resolves the target's active SSH multiplexer and forwards a host.metrics request, returning { metrics: null } when unavailable. The preload layer exposes this as api.ssh.getHostMetrics({ targetId }).
Sequence Diagram(s)
sequenceDiagram
participant Renderer
participant Preload
participant MainIPC as ssh.ts IPC handler
participant Multiplexer
participant RelayDispatcher
participant HostMetricsHandler
participant OS as os module
Renderer->>Preload: api.ssh.getHostMetrics({ targetId })
Preload->>MainIPC: ipcRenderer.invoke('ssh:getHostMetrics')
MainIPC->>Multiplexer: lookup active channel for targetId
Multiplexer->>RelayDispatcher: request('host.metrics')
RelayDispatcher->>HostMetricsHandler: dispatch 'host.metrics'
HostMetricsHandler->>OS: read memory, cpus, loadavg, uptime
HostMetricsHandler->>HostMetricsHandler: buildHostResourceMetrics(input)
HostMetricsHandler-->>RelayDispatcher: HostMetricsResult
RelayDispatcher-->>MainIPC: HostMetricsResult
MainIPC-->>Preload: HostMetricsResult
Preload-->>Renderer: Promise<HostMetricsResult>
Compact metadata
- Files changed: 7
- Lines added/removed: approximately +185/-0
- Estimated review effort: Medium
Related issues: None specified Related PRs: None specified Suggested labels: feature, relay, ipc, preload Suggested reviewers: None specified
Poem A rabbit peeked beneath the hood, Found memory, load, and CPU good. It clamped the noise, it capped the strain, Then sent it down the relay chain. From host to hop to render's door— Metrics hop, forevermore! 🐇📊
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Description check | ⚠️ Warning | The description covers the change well but omits required template sections like Screenshots, AI Review Report, Security Audit, and Notes. | Reformat the PR body to the repository template and add the missing sections, including screenshots/no visual change, AI review, security audit, and notes. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title clearly summarizes the main change: collecting remote SSH host resource metrics over the relay. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Thank you for this, @huhuhulululu! The legacy SSH relay this probe ran on has been removed: SSH hosts now run Orca's managed remote server, and the Resource Manager now asks each server for its own memory and process samples (#27263), which covers the remote host's resource usage. Closing as superseded, with thanks for pushing on this.