From 0ac59d569d6df6568e5750f056a53ad32fd678b1 Mon Sep 17 00:00:00 2001
From: Lars Nieuwenhuis <35393046+lnieuwenhuis@users.noreply.github.com>
Date: Wed, 1 Apr 2026 17:19:12 +0200
Subject: [PATCH 1/5] Feat: Added Trae IDE support for opening current working
directory (#1656)
---
apps/server/src/open.test.ts | 21 ++++++++-
apps/web/src/components/ChatView.browser.tsx | 46 +++++++++++++++++++
apps/web/src/components/Icons.tsx | 14 ++++++
apps/web/src/components/chat/OpenInPicker.tsx | 7 ++-
packages/contracts/src/editor.ts | 1 +
5 files changed, 87 insertions(+), 2 deletions(-)
diff --git a/apps/server/src/open.test.ts b/apps/server/src/open.test.ts
index 947a60ac2a..c612922fea 100644
--- a/apps/server/src/open.test.ts
+++ b/apps/server/src/open.test.ts
@@ -31,6 +31,15 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => {
args: ["/tmp/workspace"],
});
+ const traeLaunch = yield* resolveEditorLaunch(
+ { cwd: "/tmp/workspace", editor: "trae" },
+ "darwin",
+ );
+ assert.deepEqual(traeLaunch, {
+ command: "trae",
+ args: ["/tmp/workspace"],
+ });
+
const vscodeLaunch = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace", editor: "vscode" },
"darwin",
@@ -89,6 +98,15 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => {
args: ["--goto", "/tmp/workspace/src/open.ts:71:5"],
});
+ const traeLineAndColumn = yield* resolveEditorLaunch(
+ { cwd: "/tmp/workspace/src/open.ts:71:5", editor: "trae" },
+ "darwin",
+ );
+ assert.deepEqual(traeLineAndColumn, {
+ command: "trae",
+ args: ["--goto", "/tmp/workspace/src/open.ts:71:5"],
+ });
+
const vscodeLineAndColumn = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace/src/open.ts:71:5", editor: "vscode" },
"darwin",
@@ -256,6 +274,7 @@ it.layer(NodeServices.layer)("resolveAvailableEditors", (it) => {
const path = yield* Path.Path;
const dir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-editors-" });
+ yield* fs.writeFileString(path.join(dir, "trae.CMD"), "@echo off\r\n");
yield* fs.writeFileString(path.join(dir, "code-insiders.CMD"), "@echo off\r\n");
yield* fs.writeFileString(path.join(dir, "codium.CMD"), "@echo off\r\n");
yield* fs.writeFileString(path.join(dir, "explorer.CMD"), "MZ");
@@ -263,7 +282,7 @@ it.layer(NodeServices.layer)("resolveAvailableEditors", (it) => {
PATH: dir,
PATHEXT: ".COM;.EXE;.BAT;.CMD",
});
- assert.deepEqual(editors, ["vscode-insiders", "vscodium", "file-manager"]);
+ assert.deepEqual(editors, ["trae", "vscode-insiders", "vscodium", "file-manager"]);
}),
);
});
diff --git a/apps/web/src/components/ChatView.browser.tsx b/apps/web/src/components/ChatView.browser.tsx
index 33b9b62859..0e5f573d54 100644
--- a/apps/web/src/components/ChatView.browser.tsx
+++ b/apps/web/src/components/ChatView.browser.tsx
@@ -1407,6 +1407,52 @@ describe("ChatView timeline estimator parity (full app)", () => {
}
});
+ it("opens the project cwd with Trae when it is the only available editor", async () => {
+ setDraftThreadWithoutWorktree();
+
+ const mounted = await mountChatView({
+ viewport: DEFAULT_VIEWPORT,
+ snapshot: createDraftOnlySnapshot(),
+ configureFixture: (nextFixture) => {
+ nextFixture.serverConfig = {
+ ...nextFixture.serverConfig,
+ availableEditors: ["trae"],
+ };
+ },
+ });
+
+ try {
+ await waitForServerConfigToApply();
+ const openButton = await waitForElement(
+ () =>
+ Array.from(document.querySelectorAll("button")).find(
+ (button) => button.textContent?.trim() === "Open",
+ ) as HTMLButtonElement | null,
+ "Unable to find Open button.",
+ );
+ await vi.waitFor(() => {
+ expect(openButton.disabled).toBe(false);
+ });
+ openButton.click();
+
+ await vi.waitFor(
+ () => {
+ const openRequest = wsRequests.find(
+ (request) => request._tag === WS_METHODS.shellOpenInEditor,
+ );
+ expect(openRequest).toMatchObject({
+ _tag: WS_METHODS.shellOpenInEditor,
+ cwd: "/repo/project",
+ editor: "trae",
+ });
+ },
+ { timeout: 8_000, interval: 16 },
+ );
+ } finally {
+ await mounted.cleanup();
+ }
+ });
+
it("filters the open picker menu and opens VSCodium from the menu", async () => {
setDraftThreadWithoutWorktree();
diff --git a/apps/web/src/components/Icons.tsx b/apps/web/src/components/Icons.tsx
index 7d210fa173..3f4844af80 100644
--- a/apps/web/src/components/Icons.tsx
+++ b/apps/web/src/components/Icons.tsx
@@ -20,6 +20,20 @@ export const CursorIcon: Icon = (props) => (
);
+export const TraeIcon: Icon = (props) => (
+
+);
+
export const VisualStudioCode: Icon = (props) => {
const id = useId();
const maskId = `${id}-vscode-a`;
diff --git a/apps/web/src/components/chat/OpenInPicker.tsx b/apps/web/src/components/chat/OpenInPicker.tsx
index 6a956f6f42..bb5362439e 100644
--- a/apps/web/src/components/chat/OpenInPicker.tsx
+++ b/apps/web/src/components/chat/OpenInPicker.tsx
@@ -6,7 +6,7 @@ import { ChevronDownIcon, FolderClosedIcon } from "lucide-react";
import { Button } from "../ui/button";
import { Group, GroupSeparator } from "../ui/group";
import { Menu, MenuItem, MenuPopup, MenuShortcut, MenuTrigger } from "../ui/menu";
-import { AntigravityIcon, CursorIcon, Icon, VisualStudioCode, Zed } from "../Icons";
+import { AntigravityIcon, CursorIcon, Icon, TraeIcon, VisualStudioCode, Zed } from "../Icons";
import { isMacPlatform, isWindowsPlatform } from "~/lib/utils";
import { readNativeApi } from "~/nativeApi";
@@ -17,6 +17,11 @@ const resolveOptions = (platform: string, availableEditors: ReadonlyArray
Date: Wed, 1 Apr 2026 08:35:54 -0700
Subject: [PATCH 2/5] [codex] migrate Effect.fn in
apps/server/src/checkpointing/Layers/CheckpointDiffQuery.ts (#1622)
Co-authored-by: codex
---
.../server/src/checkpointing/Layers/CheckpointDiffQuery.ts | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/apps/server/src/checkpointing/Layers/CheckpointDiffQuery.ts b/apps/server/src/checkpointing/Layers/CheckpointDiffQuery.ts
index 5cf26c86da..bbb5a42931 100644
--- a/apps/server/src/checkpointing/Layers/CheckpointDiffQuery.ts
+++ b/apps/server/src/checkpointing/Layers/CheckpointDiffQuery.ts
@@ -21,8 +21,8 @@ const make = Effect.gen(function* () {
const projectionSnapshotQuery = yield* ProjectionSnapshotQuery;
const checkpointStore = yield* CheckpointStore;
- const getTurnDiff: CheckpointDiffQueryShape["getTurnDiff"] = (input) =>
- Effect.gen(function* () {
+ const getTurnDiff: CheckpointDiffQueryShape["getTurnDiff"] = Effect.fn("getTurnDiff")(
+ function* (input) {
const operation = "CheckpointDiffQuery.getTurnDiff";
if (input.fromTurnCount === input.toTurnCount) {
@@ -149,7 +149,8 @@ const make = Effect.gen(function* () {
}
return turnDiff;
- });
+ },
+ );
const getFullThreadDiff: CheckpointDiffQueryShape["getFullThreadDiff"] = (
input: OrchestrationGetFullThreadDiffInput,
From 15f0be848df55ce27a9c24e622cd58e987886240 Mon Sep 17 00:00:00 2001
From: Julius Marminge
Date: Wed, 1 Apr 2026 08:39:23 -0700
Subject: [PATCH 3/5] [codex] migrate Effect.fn in
apps/server/src/checkpointing/Layers/CheckpointStore.ts (#1623)
Co-authored-by: codex
---
.../checkpointing/Layers/CheckpointStore.ts | 265 +++++++++---------
1 file changed, 134 insertions(+), 131 deletions(-)
diff --git a/apps/server/src/checkpointing/Layers/CheckpointStore.ts b/apps/server/src/checkpointing/Layers/CheckpointStore.ts
index 0a1d7abb9d..184ec96323 100644
--- a/apps/server/src/checkpointing/Layers/CheckpointStore.ts
+++ b/apps/server/src/checkpointing/Layers/CheckpointStore.ts
@@ -86,139 +86,140 @@ const makeCheckpointStore = Effect.gen(function* () {
Effect.catch(() => Effect.succeed(false)),
);
- const captureCheckpoint: CheckpointStoreShape["captureCheckpoint"] = (input) =>
- Effect.gen(function* () {
- const operation = "CheckpointStore.captureCheckpoint";
+ const captureCheckpoint: CheckpointStoreShape["captureCheckpoint"] = Effect.fn(
+ "captureCheckpoint",
+ )(function* (input) {
+ const operation = "CheckpointStore.captureCheckpoint";
- yield* Effect.acquireUseRelease(
- fs.makeTempDirectory({ prefix: "t3-fs-checkpoint-" }),
- (tempDir) =>
- Effect.gen(function* () {
- const tempIndexPath = path.join(tempDir, `index-${randomUUID()}`);
- const commitEnv: NodeJS.ProcessEnv = {
- ...process.env,
- GIT_INDEX_FILE: tempIndexPath,
- GIT_AUTHOR_NAME: "T3 Code",
- GIT_AUTHOR_EMAIL: "t3code@users.noreply.github.com",
- GIT_COMMITTER_NAME: "T3 Code",
- GIT_COMMITTER_EMAIL: "t3code@users.noreply.github.com",
- };
+ yield* Effect.acquireUseRelease(
+ fs.makeTempDirectory({ prefix: "t3-fs-checkpoint-" }),
+ Effect.fn("captureCheckpoint.withTempDirectory")(function* (tempDir) {
+ const tempIndexPath = path.join(tempDir, `index-${randomUUID()}`);
+ const commitEnv: NodeJS.ProcessEnv = {
+ ...process.env,
+ GIT_INDEX_FILE: tempIndexPath,
+ GIT_AUTHOR_NAME: "T3 Code",
+ GIT_AUTHOR_EMAIL: "t3code@users.noreply.github.com",
+ GIT_COMMITTER_NAME: "T3 Code",
+ GIT_COMMITTER_EMAIL: "t3code@users.noreply.github.com",
+ };
- const headExists = yield* hasHeadCommit(input.cwd);
- if (headExists) {
- yield* git.execute({
- operation,
- cwd: input.cwd,
- args: ["read-tree", "HEAD"],
- env: commitEnv,
- });
- }
+ const headExists = yield* hasHeadCommit(input.cwd);
+ if (headExists) {
+ yield* git.execute({
+ operation,
+ cwd: input.cwd,
+ args: ["read-tree", "HEAD"],
+ env: commitEnv,
+ });
+ }
- yield* git.execute({
- operation,
- cwd: input.cwd,
- args: ["add", "-A", "--", "."],
- env: commitEnv,
- });
+ yield* git.execute({
+ operation,
+ cwd: input.cwd,
+ args: ["add", "-A", "--", "."],
+ env: commitEnv,
+ });
- const writeTreeResult = yield* git.execute({
- operation,
- cwd: input.cwd,
- args: ["write-tree"],
- env: commitEnv,
- });
- const treeOid = writeTreeResult.stdout.trim();
- if (treeOid.length === 0) {
- return yield* new GitCommandError({
- operation,
- command: "git write-tree",
- cwd: input.cwd,
- detail: "git write-tree returned an empty tree oid.",
- });
- }
+ const writeTreeResult = yield* git.execute({
+ operation,
+ cwd: input.cwd,
+ args: ["write-tree"],
+ env: commitEnv,
+ });
+ const treeOid = writeTreeResult.stdout.trim();
+ if (treeOid.length === 0) {
+ return yield* new GitCommandError({
+ operation,
+ command: "git write-tree",
+ cwd: input.cwd,
+ detail: "git write-tree returned an empty tree oid.",
+ });
+ }
- const message = `t3 checkpoint ref=${input.checkpointRef}`;
- const commitTreeResult = yield* git.execute({
- operation,
- cwd: input.cwd,
- args: ["commit-tree", treeOid, "-m", message],
- env: commitEnv,
- });
- const commitOid = commitTreeResult.stdout.trim();
- if (commitOid.length === 0) {
- return yield* new GitCommandError({
- operation,
- command: "git commit-tree",
- cwd: input.cwd,
- detail: "git commit-tree returned an empty commit oid.",
- });
- }
+ const message = `t3 checkpoint ref=${input.checkpointRef}`;
+ const commitTreeResult = yield* git.execute({
+ operation,
+ cwd: input.cwd,
+ args: ["commit-tree", treeOid, "-m", message],
+ env: commitEnv,
+ });
+ const commitOid = commitTreeResult.stdout.trim();
+ if (commitOid.length === 0) {
+ return yield* new GitCommandError({
+ operation,
+ command: "git commit-tree",
+ cwd: input.cwd,
+ detail: "git commit-tree returned an empty commit oid.",
+ });
+ }
- yield* git.execute({
- operation,
- cwd: input.cwd,
- args: ["update-ref", input.checkpointRef, commitOid],
- });
- }),
- (tempDir) => fs.remove(tempDir, { recursive: true }),
- ).pipe(
- Effect.catchTags({
- PlatformError: (error) =>
- Effect.fail(
- new CheckpointInvariantError({
- operation: "CheckpointStore.captureCheckpoint",
- detail: "Failed to capture checkpoint.",
- cause: error,
- }),
- ),
- }),
- );
- });
+ yield* git.execute({
+ operation,
+ cwd: input.cwd,
+ args: ["update-ref", input.checkpointRef, commitOid],
+ });
+ }),
+ (tempDir) => fs.remove(tempDir, { recursive: true }),
+ ).pipe(
+ Effect.catchTags({
+ PlatformError: (error) =>
+ Effect.fail(
+ new CheckpointInvariantError({
+ operation: "CheckpointStore.captureCheckpoint",
+ detail: "Failed to capture checkpoint.",
+ cause: error,
+ }),
+ ),
+ }),
+ );
+ });
const hasCheckpointRef: CheckpointStoreShape["hasCheckpointRef"] = (input) =>
resolveCheckpointCommit(input.cwd, input.checkpointRef).pipe(
Effect.map((commit) => commit !== null),
);
- const restoreCheckpoint: CheckpointStoreShape["restoreCheckpoint"] = (input) =>
- Effect.gen(function* () {
- const operation = "CheckpointStore.restoreCheckpoint";
+ const restoreCheckpoint: CheckpointStoreShape["restoreCheckpoint"] = Effect.fn(
+ "restoreCheckpoint",
+ )(function* (input) {
+ const operation = "CheckpointStore.restoreCheckpoint";
- let commitOid = yield* resolveCheckpointCommit(input.cwd, input.checkpointRef);
+ let commitOid = yield* resolveCheckpointCommit(input.cwd, input.checkpointRef);
- if (!commitOid && input.fallbackToHead === true) {
- commitOid = yield* resolveHeadCommit(input.cwd);
- }
+ if (!commitOid && input.fallbackToHead === true) {
+ commitOid = yield* resolveHeadCommit(input.cwd);
+ }
- if (!commitOid) {
- return false;
- }
+ if (!commitOid) {
+ return false;
+ }
- yield* git.execute({
- operation,
- cwd: input.cwd,
- args: ["restore", "--source", commitOid, "--worktree", "--staged", "--", "."],
- });
- yield* git.execute({
- operation,
- cwd: input.cwd,
- args: ["clean", "-fd", "--", "."],
- });
-
- const headExists = yield* hasHeadCommit(input.cwd);
- if (headExists) {
- yield* git.execute({
- operation,
- cwd: input.cwd,
- args: ["reset", "--quiet", "--", "."],
- });
- }
-
- return true;
+ yield* git.execute({
+ operation,
+ cwd: input.cwd,
+ args: ["restore", "--source", commitOid, "--worktree", "--staged", "--", "."],
+ });
+ yield* git.execute({
+ operation,
+ cwd: input.cwd,
+ args: ["clean", "-fd", "--", "."],
});
- const diffCheckpoints: CheckpointStoreShape["diffCheckpoints"] = (input) =>
- Effect.gen(function* () {
+ const headExists = yield* hasHeadCommit(input.cwd);
+ if (headExists) {
+ yield* git.execute({
+ operation,
+ cwd: input.cwd,
+ args: ["reset", "--quiet", "--", "."],
+ });
+ }
+
+ return true;
+ });
+
+ const diffCheckpoints: CheckpointStoreShape["diffCheckpoints"] = Effect.fn("diffCheckpoints")(
+ function* (input) {
const operation = "CheckpointStore.diffCheckpoints";
let fromCommitOid = yield* resolveCheckpointCommit(input.cwd, input.fromCheckpointRef);
@@ -247,24 +248,26 @@ const makeCheckpointStore = Effect.gen(function* () {
});
return result.stdout;
- });
+ },
+ );
- const deleteCheckpointRefs: CheckpointStoreShape["deleteCheckpointRefs"] = (input) =>
- Effect.gen(function* () {
- const operation = "CheckpointStore.deleteCheckpointRefs";
+ const deleteCheckpointRefs: CheckpointStoreShape["deleteCheckpointRefs"] = Effect.fn(
+ "deleteCheckpointRefs",
+ )(function* (input) {
+ const operation = "CheckpointStore.deleteCheckpointRefs";
- yield* Effect.forEach(
- input.checkpointRefs,
- (checkpointRef) =>
- git.execute({
- operation,
- cwd: input.cwd,
- args: ["update-ref", "-d", checkpointRef],
- allowNonZeroExit: true,
- }),
- { discard: true },
- );
- });
+ yield* Effect.forEach(
+ input.checkpointRefs,
+ (checkpointRef) =>
+ git.execute({
+ operation,
+ cwd: input.cwd,
+ args: ["update-ref", "-d", checkpointRef],
+ allowNonZeroExit: true,
+ }),
+ { discard: true },
+ );
+ });
return {
isGitRepository,
From c542ce336965261dd01c6e670b603434596e3527 Mon Sep 17 00:00:00 2001
From: Julius Marminge
Date: Wed, 1 Apr 2026 08:44:38 -0700
Subject: [PATCH 4/5] [codex] migrate Effect.fn in
apps/server/src/git/Layers/ClaudeTextGeneration.ts (#1625)
Co-authored-by: codex
---
.../src/git/Layers/ClaudeTextGeneration.ts | 216 +++++++++---------
1 file changed, 105 insertions(+), 111 deletions(-)
diff --git a/apps/server/src/git/Layers/ClaudeTextGeneration.ts b/apps/server/src/git/Layers/ClaudeTextGeneration.ts
index 7d620be3a6..99ca21b06d 100644
--- a/apps/server/src/git/Layers/ClaudeTextGeneration.ts
+++ b/apps/server/src/git/Layers/ClaudeTextGeneration.ts
@@ -66,7 +66,7 @@ const makeClaudeTextGeneration = Effect.gen(function* () {
* Spawn the Claude CLI with structured JSON output and return the parsed,
* schema-validated result.
*/
- const runClaudeJson = ({
+ const runClaudeJson = Effect.fn("runClaudeJson")(function* ({
operation,
cwd,
prompt,
@@ -82,131 +82,125 @@ const makeClaudeTextGeneration = Effect.gen(function* () {
prompt: string;
outputSchemaJson: S;
modelSelection: ClaudeModelSelection;
- }): Effect.Effect =>
- Effect.gen(function* () {
- const jsonSchemaStr = JSON.stringify(toJsonSchemaObject(outputSchemaJson));
- const normalizedOptions = normalizeClaudeModelOptionsWithCapabilities(
- getClaudeModelCapabilities(modelSelection.model),
- modelSelection.options,
- );
- const settings = {
- ...(typeof normalizedOptions?.thinking === "boolean"
- ? { alwaysThinkingEnabled: normalizedOptions.thinking }
- : {}),
- ...(normalizedOptions?.fastMode ? { fastMode: true } : {}),
- };
+ }): Effect.fn.Return {
+ const jsonSchemaStr = JSON.stringify(toJsonSchemaObject(outputSchemaJson));
+ const normalizedOptions = normalizeClaudeModelOptionsWithCapabilities(
+ getClaudeModelCapabilities(modelSelection.model),
+ modelSelection.options,
+ );
+ const settings = {
+ ...(typeof normalizedOptions?.thinking === "boolean"
+ ? { alwaysThinkingEnabled: normalizedOptions.thinking }
+ : {}),
+ ...(normalizedOptions?.fastMode ? { fastMode: true } : {}),
+ };
- const claudeSettings = yield* Effect.map(
- serverSettingsService.getSettings,
- (settings) => settings.providers.claudeAgent,
- ).pipe(Effect.catch(() => Effect.undefined));
+ const claudeSettings = yield* Effect.map(
+ serverSettingsService.getSettings,
+ (settings) => settings.providers.claudeAgent,
+ ).pipe(Effect.catch(() => Effect.undefined));
- const runClaudeCommand = Effect.gen(function* () {
- const command = ChildProcess.make(
- claudeSettings?.binaryPath || "claude",
- [
- "-p",
- "--output-format",
- "json",
- "--json-schema",
- jsonSchemaStr,
- "--model",
- resolveApiModelId(modelSelection),
- ...(normalizedOptions?.effort ? ["--effort", normalizedOptions.effort] : []),
- ...(Object.keys(settings).length > 0 ? ["--settings", JSON.stringify(settings)] : []),
- "--dangerously-skip-permissions",
- ],
- {
- cwd,
- shell: process.platform === "win32",
- stdin: {
- stream: Stream.encodeText(Stream.make(prompt)),
- },
+ const runClaudeCommand = Effect.fn("runClaudeJson.runClaudeCommand")(function* () {
+ const command = ChildProcess.make(
+ claudeSettings?.binaryPath || "claude",
+ [
+ "-p",
+ "--output-format",
+ "json",
+ "--json-schema",
+ jsonSchemaStr,
+ "--model",
+ resolveApiModelId(modelSelection),
+ ...(normalizedOptions?.effort ? ["--effort", normalizedOptions.effort] : []),
+ ...(Object.keys(settings).length > 0 ? ["--settings", JSON.stringify(settings)] : []),
+ "--dangerously-skip-permissions",
+ ],
+ {
+ cwd,
+ shell: process.platform === "win32",
+ stdin: {
+ stream: Stream.encodeText(Stream.make(prompt)),
},
+ },
+ );
+
+ const child = yield* commandSpawner
+ .spawn(command)
+ .pipe(
+ Effect.mapError((cause) =>
+ normalizeCliError("claude", operation, cause, "Failed to spawn Claude CLI process"),
+ ),
);
- const child = yield* commandSpawner
- .spawn(command)
- .pipe(
+ const [stdout, stderr, exitCode] = yield* Effect.all(
+ [
+ readStreamAsString(operation, child.stdout),
+ readStreamAsString(operation, child.stderr),
+ child.exitCode.pipe(
Effect.mapError((cause) =>
- normalizeCliError("claude", operation, cause, "Failed to spawn Claude CLI process"),
+ normalizeCliError("claude", operation, cause, "Failed to read Claude CLI exit code"),
),
- );
+ ),
+ ],
+ { concurrency: "unbounded" },
+ );
- const [stdout, stderr, exitCode] = yield* Effect.all(
- [
- readStreamAsString(operation, child.stdout),
- readStreamAsString(operation, child.stderr),
- child.exitCode.pipe(
- Effect.mapError((cause) =>
- normalizeCliError(
- "claude",
- operation,
- cause,
- "Failed to read Claude CLI exit code",
- ),
- ),
+ if (exitCode !== 0) {
+ const stderrDetail = stderr.trim();
+ const stdoutDetail = stdout.trim();
+ const detail = stderrDetail.length > 0 ? stderrDetail : stdoutDetail;
+ return yield* new TextGenerationError({
+ operation,
+ detail:
+ detail.length > 0
+ ? `Claude CLI command failed: ${detail}`
+ : `Claude CLI command failed with code ${exitCode}.`,
+ });
+ }
+
+ return stdout;
+ });
+
+ const rawStdout = yield* runClaudeCommand().pipe(
+ Effect.scoped,
+ Effect.timeoutOption(CLAUDE_TIMEOUT_MS),
+ Effect.flatMap(
+ Option.match({
+ onNone: () =>
+ Effect.fail(
+ new TextGenerationError({ operation, detail: "Claude CLI request timed out." }),
),
- ],
- { concurrency: "unbounded" },
- );
+ onSome: (value) => Effect.succeed(value),
+ }),
+ ),
+ );
- if (exitCode !== 0) {
- const stderrDetail = stderr.trim();
- const stdoutDetail = stdout.trim();
- const detail = stderrDetail.length > 0 ? stderrDetail : stdoutDetail;
- return yield* new TextGenerationError({
+ const envelope = yield* Schema.decodeEffect(Schema.fromJsonString(ClaudeOutputEnvelope))(
+ rawStdout,
+ ).pipe(
+ Effect.catchTag("SchemaError", (cause) =>
+ Effect.fail(
+ new TextGenerationError({
operation,
- detail:
- detail.length > 0
- ? `Claude CLI command failed: ${detail}`
- : `Claude CLI command failed with code ${exitCode}.`,
- });
- }
-
- return stdout;
- });
-
- const rawStdout = yield* runClaudeCommand.pipe(
- Effect.scoped,
- Effect.timeoutOption(CLAUDE_TIMEOUT_MS),
- Effect.flatMap(
- Option.match({
- onNone: () =>
- Effect.fail(
- new TextGenerationError({ operation, detail: "Claude CLI request timed out." }),
- ),
- onSome: (value) => Effect.succeed(value),
+ detail: "Claude CLI returned unexpected output format.",
+ cause,
}),
),
- );
+ ),
+ );
- const envelope = yield* Schema.decodeEffect(Schema.fromJsonString(ClaudeOutputEnvelope))(
- rawStdout,
- ).pipe(
- Effect.catchTag("SchemaError", (cause) =>
- Effect.fail(
- new TextGenerationError({
- operation,
- detail: "Claude CLI returned unexpected output format.",
- cause,
- }),
- ),
+ return yield* Schema.decodeEffect(outputSchemaJson)(envelope.structured_output).pipe(
+ Effect.catchTag("SchemaError", (cause) =>
+ Effect.fail(
+ new TextGenerationError({
+ operation,
+ detail: "Claude returned invalid structured output.",
+ cause,
+ }),
),
- );
-
- return yield* Schema.decodeEffect(outputSchemaJson)(envelope.structured_output).pipe(
- Effect.catchTag("SchemaError", (cause) =>
- Effect.fail(
- new TextGenerationError({
- operation,
- detail: "Claude returned invalid structured output.",
- cause,
- }),
- ),
- ),
- );
- });
+ ),
+ );
+ });
// ---------------------------------------------------------------------------
// TextGenerationShape methods
From 3488ca3570060449d3855eeba79a40e1f9938f9c Mon Sep 17 00:00:00 2001
From: Julius Marminge
Date: Wed, 1 Apr 2026 08:44:49 -0700
Subject: [PATCH 5/5] [codex] migrate Effect.fn in
apps/server/src/persistence/Migrations.ts (#1632)
Co-authored-by: codex
---
apps/server/src/persistence/Migrations.ts | 27 ++++++++++++-----------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/apps/server/src/persistence/Migrations.ts b/apps/server/src/persistence/Migrations.ts
index c759665f06..47102471ac 100644
--- a/apps/server/src/persistence/Migrations.ts
+++ b/apps/server/src/persistence/Migrations.ts
@@ -92,19 +92,20 @@ export interface RunMigrationsOptions {
*
* @returns Effect containing array of executed migrations
*/
-export const runMigrations = ({ toMigrationInclusive }: RunMigrationsOptions = {}) =>
- Effect.gen(function* () {
- yield* Effect.log(
- toMigrationInclusive === undefined
- ? "Running all migrations..."
- : `Running migrations 1 through ${toMigrationInclusive}...`,
- );
- const executedMigrations = yield* run({ loader: makeMigrationLoader(toMigrationInclusive) });
- yield* Effect.log("Migrations ran successfully").pipe(
- Effect.annotateLogs({ migrations: executedMigrations.map(([id, name]) => `${id}_${name}`) }),
- );
- return executedMigrations;
- });
+export const runMigrations = Effect.fn("runMigrations")(function* ({
+ toMigrationInclusive,
+}: RunMigrationsOptions = {}) {
+ yield* Effect.log(
+ toMigrationInclusive === undefined
+ ? "Running all migrations..."
+ : `Running migrations 1 through ${toMigrationInclusive}...`,
+ );
+ const executedMigrations = yield* run({ loader: makeMigrationLoader(toMigrationInclusive) });
+ yield* Effect.log("Migrations ran successfully").pipe(
+ Effect.annotateLogs({ migrations: executedMigrations.map(([id, name]) => `${id}_${name}`) }),
+ );
+ return executedMigrations;
+});
/**
* Layer that runs migrations when the layer is built.