History

Refine server diagnostics Effect idioms

Cursor Agent committed 4 months ago

Commit a58caad1 parent 4414f923 files · +150 −71Browse files

Showing the changes to apps/server/src/workspace/WorkspaceFileSystem.ts (1 of 3 files). Show all

Unified · Split

apps/server/src/workspace/WorkspaceFileSystem.ts+26−24
@@ -140,30 +140,32 @@ export const make = Effect.gen(function* () { · 139 unmodified lines
140 relativePath: input.relativePath,140 relativePath: input.relativePath,
141 });141 });
142 142
143 const realWorkspaceRoot = yield* Effect.tryPromise({143 const realWorkspaceRoot = yield* fileSystem.realPath(input.cwd).pipe(
144 try: () => NodeFSP.realpath(input.cwd),144 Effect.mapError(
145 catch: (cause) =>145 (cause) =>
146 new WorkspaceFileSystemOperationError({146 new WorkspaceFileSystemOperationError({
147 workspaceRoot: input.cwd,147 workspaceRoot: input.cwd,
148 relativePath: input.relativePath,148 relativePath: input.relativePath,
149 resolvedPath: target.absolutePath,149 resolvedPath: target.absolutePath,
150 operationPath: input.cwd,150 operationPath: input.cwd,
151 operation: "realpath-workspace-root",151 operation: "realpath-workspace-root",
152 cause,152 cause,
153 }),153 }),
154 });154 ),
155 const realTargetPath = yield* Effect.tryPromise({155 );
156 try: () => NodeFSP.realpath(target.absolutePath),156 const realTargetPath = yield* fileSystem.realPath(target.absolutePath).pipe(
157 catch: (cause) =>157 Effect.mapError(
158 new WorkspaceFileSystemOperationError({158 (cause) =>
159 workspaceRoot: input.cwd,159 new WorkspaceFileSystemOperationError({
160 relativePath: input.relativePath,160 workspaceRoot: input.cwd,
161 resolvedPath: target.absolutePath,161 relativePath: input.relativePath,
162 operationPath: target.absolutePath,162 resolvedPath: target.absolutePath,
163 operation: "realpath-target",163 operationPath: target.absolutePath,
164 cause,164 operation: "realpath-target",
165 }),165 cause,
166 });166 }),
167 ),
168 );
167 const relativeRealPath = path.relative(realWorkspaceRoot, realTargetPath);169 const relativeRealPath = path.relative(realWorkspaceRoot, realTargetPath);
168 if (170 if (
169 relativeRealPath.startsWith(`..${path.sep}`) ||171 relativeRealPath.startsWith(`..${path.sep}`) ||