@devries-cameron20 / t3code Mirror · read-only / commits / 7a8bab5d9d
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 24, 22:45 UTC

[codex] Keep PTY spawn errors structural (#3325)

Co-authored-by: codex <codex@users.noreply.github.com>

Julius Marminge committed Jun 20, 2026 at 10:58 UTC 7a8bab5d9df80e06782033d1ee252400e6f048b1
2 files changed +35 -3
apps/server/src/terminal/PtyAdapter.test.ts new
+34
@@ -0,0 +1,34 @@
1 +import { assert, describe, it } from "@effect/vitest";
2 +import * as Schema from "effect/Schema";
3 +
4 +import * as PtyAdapter from "./PtyAdapter.ts";
5 +
6 +const isPtySpawnError = Schema.is(PtyAdapter.PtySpawnError);
7 +
8 +describe("PtySpawnError", () => {
9 + it("derives messages from structural context while preserving the full cause chain", () => {
10 + const spawnCause = new Error("spawn /bin/zsh ENOENT");
11 + const adapterError = new PtyAdapter.PtySpawnError({
12 + adapter: "node-pty",
13 + shell: "/bin/zsh",
14 + cause: spawnCause,
15 + });
16 + const managerError = new PtyAdapter.PtySpawnError({
17 + adapter: "terminal-manager",
18 + attemptedShells: ["/bin/zsh -o nopromptsp", "/bin/bash"],
19 + cause: adapterError,
20 + });
21 +
22 + assert(isPtySpawnError(managerError));
23 + assert.strictEqual(
24 + managerError.message,
25 + "Failed to spawn PTY process with terminal-manager. Tried shells: /bin/zsh -o nopromptsp, /bin/bash.",
26 + );
27 + assert.strictEqual(
28 + adapterError.message,
29 + "Failed to spawn PTY process '/bin/zsh' with node-pty.",
30 + );
31 + assert.strictEqual(managerError.cause, adapterError);
32 + assert.strictEqual(adapterError.cause, spawnCause);
33 + });
34 +});
apps/server/src/terminal/PtyAdapter.ts
+1 -3
@@ -25,9 +25,7 @@ export class PtySpawnError extends Schema.TaggedErrorClass<PtySpawnError>()("Pty
25 this.attemptedShells === undefined || this.attemptedShells.length === 0
26 ? ""
27 : ` Tried shells: ${this.attemptedShells.join(", ")}.`;
28 - const causeMessage =
29 - this.cause instanceof Error && this.cause.message.length > 0 ? ` ${this.cause.message}` : "";
30 - return `Failed to spawn PTY process${shell} with ${this.adapter}.${attemptedShells}${causeMessage}`;
28 + return `Failed to spawn PTY process${shell} with ${this.adapter}.${attemptedShells}`;
29 }
30 }
31