From 6164a937aea1711713ec7184ccd10c676ebb2e78 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 17 Apr 2026 19:54:49 -0700 Subject: [PATCH] decoders --- packages/effect-acp/src/_internal/stdio.ts | 7 +++++-- packages/effect-codex-app-server/src/_internal/stdio.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/effect-acp/src/_internal/stdio.ts b/packages/effect-acp/src/_internal/stdio.ts index b175756892..8ddb4d37d0 100644 --- a/packages/effect-acp/src/_internal/stdio.ts +++ b/packages/effect-acp/src/_internal/stdio.ts @@ -9,7 +9,6 @@ import { ChildProcessSpawner } from "effect/unstable/process"; import * as AcpError from "../errors.ts"; const encoder = new TextEncoder(); -const decoder = new TextDecoder(); export const makeChildStdio = (handle: ChildProcessSpawner.ChildProcessHandle) => Stdio.make({ @@ -25,6 +24,7 @@ export const makeChildStdio = (handle: ChildProcessSpawner.ChildProcessHandle) = export const makeInMemoryStdio = Effect.fn("makeInMemoryStdio")(function* () { const input = yield* Queue.unbounded>(); const output = yield* Queue.unbounded(); + const decoder = new TextDecoder(); return { stdio: Stdio.make({ @@ -32,7 +32,10 @@ export const makeInMemoryStdio = Effect.fn("makeInMemoryStdio")(function* () { stdin: Stream.fromQueue(input), stdout: () => Sink.forEach((chunk: string | Uint8Array) => - Queue.offer(output, typeof chunk === "string" ? chunk : decoder.decode(chunk)), + Queue.offer( + output, + typeof chunk === "string" ? chunk : decoder.decode(chunk, { stream: true }), + ), ), stderr: () => Sink.drain, }), diff --git a/packages/effect-codex-app-server/src/_internal/stdio.ts b/packages/effect-codex-app-server/src/_internal/stdio.ts index 7698198dca..ced07fb53e 100644 --- a/packages/effect-codex-app-server/src/_internal/stdio.ts +++ b/packages/effect-codex-app-server/src/_internal/stdio.ts @@ -9,7 +9,6 @@ import { ChildProcessSpawner } from "effect/unstable/process"; import * as CodexError from "../errors.ts"; const encoder = new TextEncoder(); -const decoder = new TextDecoder(); export const makeChildStdio = (handle: ChildProcessSpawner.ChildProcessHandle) => Stdio.make({ @@ -25,6 +24,7 @@ export const makeChildStdio = (handle: ChildProcessSpawner.ChildProcessHandle) = export const makeInMemoryStdio = Effect.fn("makeInMemoryStdio")(function* () { const input = yield* Queue.unbounded>(); const output = yield* Queue.unbounded(); + const decoder = new TextDecoder(); return { stdio: Stdio.make({