@devries-cameron20 / t3code Mirror · read-only / commits / 06752526b3
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] Structure unavailable Bun PTY operations (#3394)

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

Julius Marminge committed Jun 20, 2026 at 10:57 UTC 06752526b3354a560d647251676eb9d5c8a50e82
2 files changed +32 -2
apps/server/src/terminal/BunPtyAdapter.test.ts new
+17
@@ -0,0 +1,17 @@
1 +import { expect, it } from "@effect/vitest";
2 +
3 +import { BunPtyOperationUnavailableError } from "./BunPtyAdapter.ts";
4 +
5 +it("describes unavailable Bun PTY operations structurally", () => {
6 + const error = new BunPtyOperationUnavailableError({
7 + operation: "resize",
8 + pid: 42,
9 + });
10 +
11 + expect(error).toMatchObject({
12 + _tag: "BunPtyOperationUnavailableError",
13 + operation: "resize",
14 + pid: 42,
15 + });
16 + expect(error.message).toBe("Bun PTY resize is unavailable for process 42.");
17 +});
apps/server/src/terminal/BunPtyAdapter.ts
+15 -2
@@ -2,10 +2,23 @@
2
3 import * as Effect from "effect/Effect";
4 import * as Layer from "effect/Layer";
5 +import * as Schema from "effect/Schema";
6 import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
7
8 import * as PtyAdapter from "./PtyAdapter.ts";
9
10 +export class BunPtyOperationUnavailableError extends Schema.TaggedErrorClass<BunPtyOperationUnavailableError>()(
11 + "BunPtyOperationUnavailableError",
12 + {
13 + operation: Schema.Literals(["write", "resize"]),
14 + pid: Schema.Number,
15 + },
16 +) {
17 + override get message(): string {
18 + return `Bun PTY ${this.operation} is unavailable for process ${this.pid}.`;
19 + }
20 +}
21 +
22 class BunPtyProcess implements PtyAdapter.PtyProcess {
23 private readonly dataListeners = new Set<(data: string) => void>();
24 private readonly exitListeners = new Set<(event: PtyAdapter.PtyExitEvent) => void>();
@@ -33,14 +46,14 @@ class BunPtyProcess implements PtyAdapter.PtyProcess {
46
47 write(data: string): void {
48 if (!this.process.terminal) {
36 - throw new Error("Bun PTY terminal handle is unavailable");
49 + throw new BunPtyOperationUnavailableError({ operation: "write", pid: this.pid });
50 }
51 this.process.terminal.write(data);
52 }
53
54 resize(cols: number, rows: number): void {
55 if (!this.process.terminal?.resize) {
43 - throw new Error("Bun PTY resize is unavailable");
56 + throw new BunPtyOperationUnavailableError({ operation: "resize", pid: this.pid });
57 }
58 this.process.terminal.resize(cols, rows);
59 }