[codex] Remove project setup error constructor wrappers (#3329)

Co-authored-by: codex <[email protected]>
This commit is contained in:
Julius Marmingeandcodex authored and GitHub committed 2026-06-20 11:28:33 -07:00
1 parent 5b1b35c773
commit 833c8ab7c6
2 files changed
+101 -41

No files matched your search

@@ -3,11 +3,16 @@ import { type OrchestrationProject, ProjectId } from "@t3tools/contracts";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import * as Option from "effect/Option";
import * as Schema from "effect/Schema";
import * as ProjectionSnapshotQuery from "../orchestration/Services/ProjectionSnapshotQuery.ts";
import * as TerminalManager from "../terminal/Manager.ts";
import * as ProjectSetupScriptRunner from "./ProjectSetupScriptRunner.ts";
const isProjectSetupScriptOperationError = Schema.is(
ProjectSetupScriptRunner.ProjectSetupScriptOperationError,
);
const makeProject = (scripts: OrchestrationProject["scripts"]): OrchestrationProject => ({
id: ProjectId.make("project-1"),
title: "Project",
@@ -145,4 +150,50 @@ describe("ProjectSetupScriptRunner", () => {
}).pipe(Effect.provide(testLayer(project, { open, write })));
},
);
it.effect("keeps terminal failures as the exact cause of a structured operation error", () => {
const rootCause = new Error("stat failed");
const terminalError = new TerminalManager.TerminalCwdError({
cwd: "/repo/worktrees/a",
reason: "statFailed",
cause: rootCause,
});
const project = makeProject([
{
id: "setup",
name: "Setup",
command: "bun install",
icon: "configure",
runOnWorktreeCreate: true,
},
]);
return Effect.gen(function* () {
const runner = yield* ProjectSetupScriptRunner.ProjectSetupScriptRunner;
const error = yield* runner
.runForThread({
threadId: "thread-1",
projectId: "project-1",
worktreePath: "/repo/worktrees/a",
})
.pipe(Effect.flip);
expect(isProjectSetupScriptOperationError(error)).toBe(true);
if (isProjectSetupScriptOperationError(error)) {
expect(error.operation).toBe("openTerminal");
expect(error.threadId).toBe("thread-1");
expect(error.projectId).toBe("project-1");
expect(error.worktreePath).toBe("/repo/worktrees/a");
expect(error.cause).toBe(terminalError);
expect(terminalError.cause).toBe(rootCause);
}
}).pipe(
Effect.provide(
testLayer(project, {
open: () => Effect.fail(terminalError),
write: () => Effect.die("unexpected write"),
}),
),
);
});
});