Skip to content

Refine server code with idiomatic Effect patterns#3769

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

Refine server code with idiomatic Effect patterns#3769
cursor[bot] wants to merge 4 commits into
mainfrom
cursor/idiomatic-effect-patterns-4ebe

Conversation

@cursor

@cursor cursor Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What Changed

  • Switched WorkspaceFileSystem.readFile realpath checks from node:fs/promises / Effect.tryPromise to the Effect FileSystem.realPath service.
  • Refactored trace diagnostics parsing helpers and aggregation state to use Option internally instead of null sentinels.
  • Updated trace diagnostics tests to encode JSON fixtures through Schema.UnknownFromJsonString.

Why

This keeps these server paths more idiomatic and testable with Effect services and typed Option values, while preserving the existing behavior and structured error mapping.

UI Changes

Not applicable; server/test-only 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

Validation:

  • PATH="/home/ubuntu/.nvm/versions/node/v24.18.0/bin:$PATH" pnpm exec vp test run src/diagnostics/TraceDiagnostics.test.ts src/workspace/WorkspaceFileSystem.test.ts (from apps/server)
  • PATH="/home/ubuntu/.nvm/versions/node/v24.18.0/bin:$PATH" pnpm exec vp check
  • PATH="/home/ubuntu/.nvm/versions/node/v24.18.0/bin:$PATH" pnpm exec vp run typecheck
Open in Web View Automation 

Note

Refactor trace diagnostics and file system utilities to use idiomatic Effect patterns

  • Converts internal null-based optional handling in TraceDiagnostics.ts to use Option throughout, replacing nullable returns on helpers like toStringValue, toNumberValue, and unixNanoToDateTime.
  • Relaxes span validation in aggregateTraceDiagnostics so spans missing startTimeUnixNano are still counted; firstSpanAt remains None when no span has a start time, while lastSpanAt always reflects the latest end time.
  • Replaces NodeFSP.realpath with the injected FileSystem service in WorkspaceFileSystem.ts, making WorkspaceFileSystemOperationError.cause a PlatformError instead of a Node.js ErrnoException.
  • Behavioral Change: callers inspecting WorkspaceFileSystemOperationError.cause will now receive a PlatformError with a reason._tag of 'NotFound' rather than a Node.js error with ENOENT.

Macroscope summarized ec4f089.

cursoragent and others added 4 commits July 7, 2026 16:07
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
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 Jul 7, 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