From faf9d87071672e41206a190270d34e4485d0e6d0 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 1 Jul 2026 16:11:08 +0000 Subject: [PATCH] Format Effect refactors Co-authored-by: Julius Marminge --- .../src/diagnostics/ProcessDiagnostics.ts | 6 +- .../src/workspace/WorkspaceFileSystem.ts | 57 ++++++++++++------- 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/apps/server/src/diagnostics/ProcessDiagnostics.ts b/apps/server/src/diagnostics/ProcessDiagnostics.ts index 3e09ad0766..296855d1eb 100644 --- a/apps/server/src/diagnostics/ProcessDiagnostics.ts +++ b/apps/server/src/diagnostics/ProcessDiagnostics.ts @@ -132,7 +132,9 @@ const WindowsCimProcessRecord = Schema.Struct({ }); type WindowsCimProcessRecord = typeof WindowsCimProcessRecord.Type; const decodeWindowsCimProcessRecord = Schema.decodeUnknownOption(WindowsCimProcessRecord); -const decodeWindowsCimProcessJson = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Unknown)); +const decodeWindowsCimProcessJson = Schema.decodeUnknownOption( + Schema.fromJsonString(Schema.Unknown), +); function parsePositiveInt(value: string): number | null { const parsed = Number.parseInt(value, 10); @@ -257,7 +259,7 @@ export function parseWindowsProcessRows(output: string): ReadonlyArray [], onSome: (parsed) => { const rows: ProcessRow[] = []; - const records = Array.isArray(parsed) ? parsed : [parsed]; + const records = Array.isArray(parsed) ? parsed : [parsed]; for (const record of records) { const row = normalizeWindowsProcessRow(record); if (Option.isSome(row)) rows.push(row.value); diff --git a/apps/server/src/workspace/WorkspaceFileSystem.ts b/apps/server/src/workspace/WorkspaceFileSystem.ts index 263f576241..b4a1b2f63c 100644 --- a/apps/server/src/workspace/WorkspaceFileSystem.ts +++ b/apps/server/src/workspace/WorkspaceFileSystem.ts @@ -131,20 +131,22 @@ export const make = Effect.gen(function* () { const workspacePaths = yield* WorkspacePaths.WorkspacePaths; const workspaceEntries = yield* WorkspaceEntries.WorkspaceEntries; - const operationError = ( - input: ProjectReadFileInput | ProjectWriteFileInput, - resolvedPath: string, - operationPath: string, - operation: WorkspaceFileSystemOperationError["operation"], - ) => (cause: unknown) => - new WorkspaceFileSystemOperationError({ - workspaceRoot: input.cwd, - relativePath: input.relativePath, - resolvedPath, - operationPath, - operation, - cause, - }); + const operationError = + ( + input: ProjectReadFileInput | ProjectWriteFileInput, + resolvedPath: string, + operationPath: string, + operation: WorkspaceFileSystemOperationError["operation"], + ) => + (cause: unknown) => + new WorkspaceFileSystemOperationError({ + workspaceRoot: input.cwd, + relativePath: input.relativePath, + resolvedPath, + operationPath, + operation, + cause, + }); const readFile: WorkspaceFileSystem["Service"]["readFile"] = Effect.fn( "WorkspaceFileSystem.readFile", @@ -203,10 +205,12 @@ export const make = Effect.gen(function* () { const fileBytes = bytesToRead === 0 ? new Uint8Array() - : yield* file.readAlloc(bytesToRead).pipe( - Effect.map(Option.getOrElse(() => new Uint8Array())), - Effect.mapError(operationError(input, realTargetPath, realTargetPath, "read")), - ); + : yield* file + .readAlloc(bytesToRead) + .pipe( + Effect.map(Option.getOrElse(() => new Uint8Array())), + Effect.mapError(operationError(input, realTargetPath, realTargetPath, "read")), + ); if (fileBytes.includes(0)) { return yield* new WorkspaceBinaryFileError({ workspaceRoot: input.cwd, @@ -237,12 +241,21 @@ export const make = Effect.gen(function* () { .makeDirectory(path.dirname(target.absolutePath), { recursive: true }) .pipe( Effect.mapError( - operationError(input, target.absolutePath, path.dirname(target.absolutePath), "make-directory"), + operationError( + input, + target.absolutePath, + path.dirname(target.absolutePath), + "make-directory", + ), + ), + ); + yield* fileSystem + .writeFileString(target.absolutePath, input.contents) + .pipe( + Effect.mapError( + operationError(input, target.absolutePath, target.absolutePath, "write-file"), ), ); - yield* fileSystem.writeFileString(target.absolutePath, input.contents).pipe( - Effect.mapError(operationError(input, target.absolutePath, target.absolutePath, "write-file")), - ); yield* workspaceEntries.refresh(input.cwd); return { relativePath: target.relativePath }; });