Skip to content

Make process diagnostics parsing more idiomatic Effect#3583

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/idiomatic-effect-patterns-dde4
Draft

Make process diagnostics parsing more idiomatic Effect#3583
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/idiomatic-effect-patterns-dde4

Conversation

@cursor

@cursor cursor Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

What Changed

  • Decode Windows process diagnostics JSON with Schema.fromJsonString and per-record Schema parsing instead of JSON.parse plus ad-hoc record traversal.
  • Normalize optional/null Windows process fields through Option and keep the process-query timeout as an effect/Duration.
  • Updated the adjacent ProcessDiagnostics tests to use assert from @effect/vitest and added a mocked Windows ChildProcessSpawner test for the Schema decoding path.

Why

This keeps process diagnostics easier to test and maintain with native Effect primitives while preserving the existing behavior of skipping malformed Windows records instead of failing the whole diagnostics read.

UI Changes

Not applicable; server diagnostics/test-only behavior, no UI changes.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Verification:

  • PATH="/home/ubuntu/.nvm/versions/node/v24.18.0/bin:$PATH" pnpm --dir apps/server run test src/diagnostics/ProcessDiagnostics.test.ts (7 tests passed)
  • PATH="/home/ubuntu/.nvm/versions/node/v24.18.0/bin:$PATH" pnpm exec vp check (passed with existing warnings)
  • PATH="/home/ubuntu/.nvm/versions/node/v24.18.0/bin:$PATH" pnpm exec vp run typecheck (passed)
Open in Web View Automation 

Note

Refactor Windows process diagnostics parsing to use Effect Schema

  • Replaces ad-hoc JSON parsing in parseWindowsProcessRows with schema-driven decoding via WindowsProcessRecord and WindowsProcessJson schemas in ProcessDiagnostics.ts.
  • Adds normalizeWindowsProcessRecord to validate PIDs, derive command from CommandLine or Name, default empty Status to 'Live', clamp negative CPU%, and round WorkingSetSize.
  • Invalid records now return Option.none and are skipped silently; invalid JSON yields an empty array instead of throwing.
  • Replaces PROCESS_QUERY_TIMEOUT_MS with a Duration-based constant passed directly to Effect.timeoutOption.
  • Behavioral Change: whitespace-only Status values now default to 'Live'; previously they would propagate as-is.

Macroscope summarized 5b499fd.

cursoragent and others added 2 commits June 27, 2026 16:11
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant