Skip to content

Live CPU% in container/stack vitals#11

Merged
DonsWayo merged 1 commit into
mainfrom
feat/cpu-vitals
Jun 17, 2026
Merged

Live CPU% in container/stack vitals#11
DonsWayo merged 1 commit into
mainfrom
feat/cpu-vitals

Conversation

@DonsWayo

Copy link
Copy Markdown
Owner

Completes the instrument vitals: rows now show IP · CPU% · memory (memory shipped earlier; CPU was the gap from #1).

Changes

  • VitalsSampler (ConsaiCore) — pure, stateful value type that turns successive cumulative cpuUsageUsec readings into a CPU %, extracted from the view model so the sampling logic lives in the domain layer and is unit-testable (per SwiftUI guidance: business logic in services/models, not views).
  • ContainerEngine.cpuUsage(id:) via the SDK stats API; AppState fetches CPU + memory concurrently for running containers and carries last-known vitals so they don't blink between polls.
  • Row vitals render IP · cpu% · mem on a single line (fixedSize; the image truncates instead of wrapping).

Tests

cpuPercent math (incl. zero-window and counter-reset guards) + VitalsSampler first-reading/retain behavior. 23 ConsaiCore tests pass.

Notes

  • CPU is total across cores (can exceed 100% on multi-core), matching how the runtime reports usage.
  • Verified by swift build + swift test; panel screenshot refreshed in docs/screenshots/.

Closes #1

- VitalsSampler (ConsaiCore): pure, testable cpu%-from-cumulative-usec sampling, extracted
  from the view model so the domain logic lives in the domain layer
- ContainerEngine.cpuUsage(id:) via SDK stats; AppState samples cpu+mem concurrently and
  carries last-known vitals to avoid blink; vitals render IP · cpu% · mem on one line
- Tests: cpuPercent math + sampler first-reading/retain behavior (23 ConsaiCore tests pass)

Closes #1
@DonsWayo DonsWayo merged commit 73ec16f into main Jun 17, 2026
1 check passed
@DonsWayo DonsWayo deleted the feat/cpu-vitals branch June 17, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Live CPU% in container/stack vitals

1 participant