From 201f6547be4e80c846a468330dd4a5091a70505e Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 20 Jun 2026 16:11:45 +0000 Subject: [PATCH] Yield tagged workspace read errors directly Co-authored-by: Julius Marminge --- .../src/workspace/WorkspaceFileSystem.ts | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/apps/server/src/workspace/WorkspaceFileSystem.ts b/apps/server/src/workspace/WorkspaceFileSystem.ts index 5af54b2a9d..8f52c1985e 100644 --- a/apps/server/src/workspace/WorkspaceFileSystem.ts +++ b/apps/server/src/workspace/WorkspaceFileSystem.ts @@ -135,26 +135,22 @@ export const make = Effect.gen(function* () { relativeRealPath === ".." || path.isAbsolute(relativeRealPath) ) { - return yield* Effect.fail( - new WorkspaceReadFileResolvedOutsideRootError({ - cwd: input.cwd, - relativePath: target.relativePath, - realWorkspaceRoot, - realTargetPath, - }), - ); + return yield* new WorkspaceReadFileResolvedOutsideRootError({ + cwd: input.cwd, + relativePath: target.relativePath, + realWorkspaceRoot, + realTargetPath, + }); } const handle = yield* fileSystem.open(realTargetPath, { flag: "r" }); const stat = yield* handle.stat; if (stat.type !== "File") { - return yield* Effect.fail( - new WorkspaceReadFileNotFileError({ - cwd: input.cwd, - relativePath: target.relativePath, - fileType: stat.type, - }), - ); + return yield* new WorkspaceReadFileNotFileError({ + cwd: input.cwd, + relativePath: target.relativePath, + fileType: stat.type, + }); } const byteLength = Number(stat.size); const bytesToRead = Math.min(byteLength, PROJECT_READ_FILE_MAX_BYTES); @@ -163,13 +159,11 @@ export const make = Effect.gen(function* () { const fileBytes = buffer.subarray(0, Number(bytesRead)); const nulByteOffset = fileBytes.indexOf(0); if (nulByteOffset !== -1) { - return yield* Effect.fail( - new WorkspaceReadFileBinaryFileError({ - cwd: input.cwd, - relativePath: target.relativePath, - nulByteOffset, - }), - ); + return yield* new WorkspaceReadFileBinaryFileError({ + cwd: input.cwd, + relativePath: target.relativePath, + nulByteOffset, + }); } const contents = new TextDecoder("utf-8").decode(fileBytes); return {