| ... | @@ -93,23 +93,24 @@ export const BunPtyAdapterLive = Layer.effect( | ... | @@ -93,23 +93,24 @@ export const BunPtyAdapterLive = Layer.effect( |
| 93 | return yield* Effect.die("Bun PTY terminal support is unavailable on Windows."); | 93 | return yield* Effect.die("Bun PTY terminal support is unavailable on Windows."); |
| 94 | } | 94 | } |
| 95 | return { | 95 | return { |
| 96 | spawn: (input) => { | 96 | spawn: (input) => |
| 97 | let processHandle: BunPtyProcess | null = null; | 97 | Effect.sync(() => { |
| 98 | const command = [input.shell, ...(input.args ?? [])]; | 98 | let processHandle: BunPtyProcess | null = null; |
| 99 | const subprocess = Bun.spawn(command, { | 99 | const command = [input.shell, ...(input.args ?? [])]; |
| 100 | cwd: input.cwd, | 100 | const subprocess = Bun.spawn(command, { |
| 101 | env: input.env, | 101 | cwd: input.cwd, |
| 102 | terminal: { | 102 | env: input.env, |
| 103 | cols: input.cols, | 103 | terminal: { |
| 104 | rows: input.rows, | 104 | cols: input.cols, |
| 105 | data: (_terminal, data) => { | 105 | rows: input.rows, |
| 106 | processHandle?.emitData(data); | 106 | data: (_terminal, data) => { |
| | 107 | processHandle?.emitData(data); |
| | 108 | }, |
| 107 | }, | 109 | }, |
| 108 | }, | 110 | }); |
| 109 | }); | 111 | processHandle = new BunPtyProcess(subprocess); |
| 110 | processHandle = new BunPtyProcess(subprocess); | 112 | return processHandle; |
| 111 | return Effect.succeed(processHandle); | 113 | }), |
| 112 | }, | | |
| 113 | } satisfies PtyAdapterShape; | 114 | } satisfies PtyAdapterShape; |
| 114 | }), | 115 | }), |
| 115 | ); | 116 | ); |