Skip to content

Batch D: async metrics collection, fix HTML/JS drift, add tests + CI - #1

Open
dkurokawa wants to merge 1 commit into
masterfrom
refactor/batch-d-async-drift
Open

dkurokawa wants to merge 1 commit into
masterfrom
refactor/batch-d-async-drift

Conversation

@dkurokawa

Copy link
Copy Markdown
Owner

Batch D of the OSS repo cleanup (dkurokawa/move#33). Local compile + typecheck + test all green.

Performance / correctness

  • Non-blocking collection: replaced blocking execSync (memory/disk/cpu/gpu) with a shared async execFile helper (src/metrics/exec.ts). The extension host event loop no longer stalls on every 5-second tick; MetricsCollector's Promise.all is now genuinely parallel. No shell is spawned (pipes/redirects moved into JS), which also removes shell-injection surface.
  • Dead subprocess removed: getCpuTopProcesses() ran ps every tick but its output (cpuTop) was never rendered by the webview. Dropped it (and the unused CpuTopProcess type).
  • iostat drift: disk I/O read speed is now macOS-only. The fixed column index assumed macOS iostat layout and produced wrong numbers on Linux (different format/units).

HTML/JS drift

  • The webview main.js wrote #mp-chip-name and #mp-uptime, but those elements had been dropped from the provider HTML (their CSS .mp-header* / .mp-pulse was left orphaned). Restored the header so the already-computed chip name + uptime render again. Header update moved into the shared dispatch so it works in both detailed and compact views.

Maintainability / tests

  • Extracted the fragile regex output parsers into pure functions and covered them with vitest unit tests (test/parsers.test.ts), using fixtures captured from real command output.
  • Deduplicated the per-process memory breakdown that was copy-pasted across the macOS/Linux/Windows paths into a single buildBreakdown helper.
  • Added GitHub Actions CI (compile + tests, Node 18/20), Marketplace/CI README badges, CHANGELOG, version bump to 0.2.1.

Note for the maintainer (out of scope here)

This PR targets master, which holds the live 0.2.x code. The repo's default branch is main, which is diverged and stale (only feat: initial release v0.1.0). Visitors to the repo currently land on the older branch. Worth reconciling main/master separately (pick one canonical branch) — I left it untouched rather than force-reconcile branches.

Batch D of the OSS repo cleanup (dkurokawa/move#33).

Performance / correctness:
- Replace blocking execSync (memory/disk/cpu/gpu) with non-blocking execFile
  via a shared exec helper, so the extension host event loop no longer stalls
  on every 5s collection tick. Collector Promise.all is now genuinely parallel.
- Stop collecting the top-CPU-process list every tick: it was never rendered
  by the webview and spawned an extra `ps` subprocess each update (dead output).
- Report disk I/O read speed on macOS only; the fixed `iostat` column index
  produced wrong numbers on Linux (different output format / units).

HTML/JS drift:
- Restore the header (chip name + uptime) the webview HTML had dropped, so the
  values the frontend already computes render again (uses existing orphan CSS).
  Header update moved into the shared dispatch so it works in both view modes.

Maintainability / tests:
- Extract the fragile regex output parsers into pure functions and cover them
  with vitest unit tests using fixtures captured from real command output.
- Deduplicate the per-process memory breakdown copy-pasted across the
  macOS/Linux/Windows paths into one buildBreakdown helper.
- Add GitHub Actions CI (compile + tests, Node 18/20), Marketplace/CI README
  badges, CHANGELOG, version bump to 0.2.1.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant