Repository navigation
feat(ui): read host metrics from released CLIs through the machine shell (OH-59) - #33
Merged
Merged
Conversation
…ell (OH-59) Released CLIs (0.2.12 to 0.2.20) have no host-metrics capability, so every installed daemon showed "This machine CLI does not support host metrics". They all register the machine bash RPC, so when the capability is unsupported the UI now runs one fixed, read-only, argv-only command per platform (macOS, Linux, Windows) and interprets it with the same helpers as the CLI collector, now in @happier-dev/protocol. The capability stays preferred where present. The last good reading per Home/account/machine persists for a week, so rows show it marked stale after a restart or while a host is offline or unreadable, with the values first on the compact line. A host's platform can arrive after its first read starts; the store now re-reads once it arrives instead of sharing the read that started without it, and only when that read came back unsupported.
… retryable (OH-59) Review fixes for the released-CLI host metrics fallback: - macOS storage free space is df's Available column. On APFS, df's Used counts only the Data volume, so total minus Used understated use by about 2 points here (93.6% vs the CLI's statfs 95.8%). Linux keeps total minus Used, which GNU df defines as total minus free blocks. - Only a daemon without the shell handler (method not found or not available, thrown or as a result payload) is unsupported. Timeouts, dropped connections, failed spawns and unreadable output are read errors the next refresh retries, so the row no longer tells the user to install another CLI for a hiccup. - A read that missed the host's platform and came back unsupported re-reads with it instead of publishing that answer, so the row never flashes the unsupported message during the re-read. - Windows measures the drive holding the user profile, like the CLI collector, rather than HOMEDRIVE, which can name a network home folder in a domain. - The CPU sample, load average and utilization percentage definitions move into @happier-dev/protocol with the other shared interpreters; the CLI collector and the fallback both use them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
Every machine in the sidebar showed "This machine CLI does not support host metrics". The daily daemons run released CLIs (0.2.12–0.2.17), which have no
tool.machineMetricscapability. Every released CLI from 0.2.12 through 0.2.20 does register the machinebashRPC, so the app can now read those hosts without a new daemon.sync/ops/machineMetricsShell.ts): when the capability is unsupported,loadMachineMetricsruns one fixed, read-only, argv-only command for the host's platform throughmachineBash, using the shared 30 s capability budget. The commands aretop/vm_stat/sysctl/df/ioregon macOS,/proc/df/nvidia-smi/AMDgpu_busy_percenton Linux, and PowerShell CIM queries on Windows. Nothing is interpolated into the commands. The capability is still preferred when present.capacityUsageand the NVIDIA, Windows and Mac GPU parsers move from the CLI collector into@happier-dev/protocol, and both paths use them. Memory followsos.freemem(): free pages on macOS,MemAvailable(orMemFreeon kernels without it) on Linux, available memory on Windows.Availablecolumn, because on APFS theUsedcolumn counts only the Data volume. That matches the CLI's statfs reading (95.8% measured on this Mac, against 93.6% fromUsed). Windows measures the drive holding the user profile. The CPU-sample, load-average and percentage calculations are shared from protocol along with the parsers.docs/fork-development.mdanddocs/fork-production.md.Validation
machineMetrics.test.ts, 10 tests), the store's platform, source, persistence and race handling (machineMetricsStore.test.ts, 7), and the values-first compact line (MachineMonitoringSection.test.tsx, 4). The race was reproduced in the browser before its RED test.MemAvailable. One constructed Linux fixture covers the AMD/NVIDIA formats and is labelled as constructed.child_process.spawn(powershell.exe … -Command <script>, { shell: false })ran on the Windows host: exit 0 in 2.9 s with every field present.machines.monitoring.oh59.spec.ts(whole file): 4/4 pass. The new test serves a released-CLI host'sbashfrom this Mac's real commands, checks the live reading and the system-tools note, then disconnects the host and reloads to check that the saved reading shows first. With the fallback forced off, it fails with the original "does not support host metrics" text.machineBashcallers and locale tests (71 passed); CLI collector (1, after the CPU tests moved); protocol interpreters plus import-cycle and export guards (37). Typechecks pass for UI, CLI, protocol and tests. Docs: content checks and 47 guards pass.Independent review
A separate reviewer reported one major and four minor findings, and all five were confirmed against source and measurements:
Each behavior fix has a RED test, except the Windows drive change. That one is script-only and was checked through the daemon's exact spawn on the Windows host (drive C:, exit 0). The duplication fix is a refactor, covered by the moved tests. No security finding held up: the argv is a fixed constant chosen by a three-way platform switch.
Scope and deferrals
Tracks OH-59.