@devries-cameron20 / t3code Mirror · read-only / commits / db0ae7b6e1
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 21, 14:45 UTC

fix(acp): a blank line from an ACP agent no longer ends the session (#28851)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Victor committed Nov 14, 2026 at 07:32 UTC db0ae7b6e1b7f4ba03aaa191374556429b146f47
2 files changed +27 -2
packages/effect-acp/src/protocol.test.ts
+25
@@ -531,6 +531,31 @@ it.layer(NodeServices.layer)("effect-acp protocol", (it) => {
531 }),
532 );
533
534 + it.effect("skips blank lines between agent messages", () =>
535 + Effect.gen(function* () {
536 + const { stdio, input } = yield* makeInMemoryStdio();
537 + const outcome = yield* Deferred.make<string>();
538 + const transport = yield* AcpProtocol.makeAcpPatchedProtocol({
539 + stdio,
540 + serverRequestMethods: new Set(),
541 + onTermination: (error) => Deferred.succeed(outcome, error._tag).pipe(Effect.asVoid),
542 + });
543 + yield* transport.incoming.pipe(
544 + Stream.runForEach((notification) => Deferred.succeed(outcome, notification._tag)),
545 + Effect.forkScoped,
546 + );
547 +
548 + const update = encodeUnknownJsonString({
549 + jsonrpc: "2.0",
550 + method: "session/update",
551 + params: { sessionId: "session-1", update: { sessionUpdate: "plan", entries: [] } },
552 + });
553 + yield* Queue.offer(input, encoder.encode(`\n\r\n \t\n${update}\n\n`));
554 +
555 + assert.equal(yield* Deferred.await(outcome), "SessionUpdate");
556 + }),
557 + );
558 +
559 it.effect("logs decode failures without copying the cause or wire payload", () =>
560 Effect.gen(function* () {
561 const secret = "acp-wire-secret-sentinel";
packages/effect-acp/src/protocol.ts
+2 -2
@@ -173,7 +173,7 @@ const decodeElicitationComplete = Schema.decodeUnknownEffect(
173 );
174 const parserFactory = RpcSerialization.ndJsonRpc();
175 // ndJsonRpc skips lines that are not JSON. A malformed agent line has to end the
176 -// session, so frames are split here and each one goes through the strict codec.
176 +// session, so frames are split here and each nonblank one goes through the strict codec.
177 const makeStrictNdJsonRpcParser = () => {
178 const codec = RpcSerialization.jsonRpc().makeUnsafe();
179 const decoder = new TextDecoder();
@@ -197,7 +197,7 @@ const makeStrictNdJsonRpcParser = () => {
197 }
198 const lines = (buffer + chunk.slice(0, lastNewline)).split("\n");
199 buffer = chunk.slice(lastNewline + 1);
200 - return lines.flatMap(decodeLine);
200 + return lines.flatMap((line) => (line.trim() === "" ? [] : decodeLine(line)));
201 },
202 // A truncated final line is left to the exit status, which explains a crash better.
203 end: (): ReadonlyArray<AcpDecodedWireMessage> => {