Use Effect FileSystem in workspace services#3535
Draft
cursor[bot] wants to merge 4 commits into
Draft
Conversation
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>
Contributor
There was a problem hiding this comment.
One Effect convention issue found: use Effect.catchTags rather than Effect.catchTag for handling statically known tagged failures.
Posted via Macroscope — Effect Service Conventions
Comment on lines
+191
to
202
| Effect.catchTag("PlatformError", (cause) => | ||
| cause.reason._tag === "PermissionDenied" | ||
| ? Effect.succeed([]) | ||
| : Effect.fail( | ||
| new WorkspaceEntriesReadDirectoryError({ | ||
| cwd: input.cwd, | ||
| partialPath: input.partialPath, | ||
| parentPath, | ||
| cause, | ||
| }), | ||
| ), | ||
| ), |
Contributor
There was a problem hiding this comment.
Use Effect.catchTags({ ... }) instead of Effect.catchTag for known tagged failures (the convention applies even when handling a single tag). The branch on cause.reason._tag for PermissionDenied remains a valid structural check inside the handler.
Suggested change
| Effect.catchTag("PlatformError", (cause) => | |
| cause.reason._tag === "PermissionDenied" | |
| ? Effect.succeed([]) | |
| : Effect.fail( | |
| new WorkspaceEntriesReadDirectoryError({ | |
| cwd: input.cwd, | |
| partialPath: input.partialPath, | |
| parentPath, | |
| cause, | |
| }), | |
| ), | |
| ), | |
| Effect.catchTags({ | |
| PlatformError: (cause) => | |
| cause.reason._tag === "PermissionDenied" | |
| ? Effect.succeed([]) | |
| : Effect.fail( | |
| new WorkspaceEntriesReadDirectoryError({ | |
| cwd: input.cwd, | |
| partialPath: input.partialPath, | |
| parentPath, | |
| cause, | |
| }), | |
| ), | |
| }), |
Posted via Macroscope — Effect Service Conventions
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 Changed
WorkspaceFileSystem.readFileto use EffectFileSystemrealpath/open/stat/read APIs instead ofnode:fs/promiseswrapped inEffect.tryPromise.WorkspaceEntries.browseto use EffectFileSystem.readDirectory/statand structuredPlatformErrorhandling for permission-denied directory reads.PlatformErrorcauses and override the file-system service capability instead of mockingnode:fs/promises.Why
These changes make the workspace subsystem more idiomatic Effect: I/O now flows through Effect services, errors stay structured, and tests can override the granular file-system capability without module mocks.
UI Changes
Not applicable; no UI changes.
Checklist
Note
Replace Node.js
fs/promiseswith EffectFileSystemin workspace servicesWorkspaceFileSystem.tsreplacesNodeFSPcalls with EffectFileSystemforrealPath,open,stat, andreadinreadFile, usingEffect.scopedinstead of manual acquire/release.WorkspaceEntries.tsreplacesNodeFSP.readdirwithfileSystem.readDirectory+ per-entryfileSystem.statto filter for directories; onlyPermissionDeniederrors return an empty listing — other failures surface asWorkspaceEntriesReadDirectoryError.FileSystemlayer and assertPlatformErrorcauses (e.g.NotFound,PermissionDenied) instead of Node.jsErrnoExceptioncodes.PlatformErroras the wrapped cause rather than Node.js errors, changing the error structure visible to callers.Macroscope summarized 40624c1.