The best way to control Claude Code, Codex and more from any computer or phone
fix(acp): retain errors reported by idle work state (#21614)
Julius Marminge committed
Oct 19, 2026 at 16:32 UTC
012e4ec0566c6653095672b1ea98c2bea4b0ad83
4 files changed
+62
-7
packages/effect-acp/src/client.test.ts
+36
@@ -268,6 +268,42 @@ it.layer(NodeServices.layer)("effect-acp client", (it) => {
268
}),
269
);
270
271
+ it.effect("keeps the JSON-RPC error of a failed v2 idle", () =>
272
+ Effect.gen(function* () {
273
+ const { stdio, input } = yield* makeInMemoryStdio();
274
+ const delivered = yield* Deferred.make<AcpCompat.SessionNotification>();
275
+ const acp = yield* AcpClient.make(stdio);
276
+ yield* acp.handleSessionUpdate((notification) =>
277
+ Deferred.succeed(delivered, notification).pipe(Effect.asVoid),
278
+ );
279
+ const error = { code: -32000, message: "Please sign in to Claude", data: { retry: false } };
280
+ const idle = {
281
+ sessionUpdate: "state_update",
282
+ state: "idle",
283
+ stopReason: "error",
284
+ error,
285
+ } as const;
286
+
287
+ yield* Queue.offer(
288
+ input,
289
+ yield* encodeJsonl(SessionUpdateNotification, {
290
+ jsonrpc: "2.0",
291
+ method: "session/update",
292
+ params: {
293
+ sessionId: "session-1",
294
+ update: idle,
295
+ },
296
+ }),
297
+ );
298
+
299
+ const { update } = yield* Deferred.await(delivered);
300
+ assert.deepEqual(
301
+ update.sessionUpdate === "state_update" && update.state === "idle" ? update : undefined,
302
+ idle,
303
+ );
304
+ }),
305
+ );
306
+
307
it.effect("reports idle child termination and rejects later requests and notifications", () =>
308
Effect.gen(function* () {
309
const handle = yield* makeHandle();
packages/effect-acp/src/compat.ts
+1
@@ -317,6 +317,7 @@ export type SessionUpdate =
317
readonly state: "idle";
318
readonly stopReason?: StopReason | null;
319
readonly usage?: Usage | null;
320
+ readonly error?: V2.Error | null;
321
readonly _meta?: Meta;
322
}
323
| {
packages/effect-acp/src/protocol.test.ts
+5
-5
@@ -16,7 +16,7 @@ import * as Ref from "effect/Ref";
16
import * as TestClock from "effect/testing/TestClock";
17
import { ChildProcess, ChildProcessSpawner } from "effect/process";
18
19
-import { it, assert } from "@effect/vitest";
19
+import { it, assert, expect } from "@effect/vitest";
20
import * as NodeServices from "@effect/platform-node/NodeServices";
21
22
import * as AcpSchema from "./schema.ts";
@@ -283,18 +283,18 @@ it.layer(NodeServices.layer)("effect-acp protocol", (it) => {
283
assert.equal(transformCalls, 1);
284
285
const decodeFailed = events.find(({ stage }) => stage === "decode_failed");
286
- assert.deepInclude(decodeFailed?.payload as object, {
286
+ expect(decodeFailed?.payload).toMatchObject({
287
operation: "decode-notification-payload",
288
method: "session/update",
289
- issueSummary: "update.used missing",
289
+ issueSummary: expect.stringContaining("update.used missing"),
290
});
291
assert.lengthOf(
292
events.filter(({ stage }) => stage === "decode_failed"),
293
2,
294
);
295
assert.lengthOf(warnings, 1);
296
- assert.deepInclude(warnings[0] as object, {
297
- issueSummary: "update.used missing",
296
+ expect(warnings[0]).toMatchObject({
297
+ issueSummary: expect.stringContaining("update.used missing"),
298
});
299
assert.notInclude(encodeUnknownJsonString({ decodeFailed, warnings }), secret);
300
}),
packages/effect-acp/src/protocol.ts
+20
-2
@@ -84,7 +84,10 @@ export interface AcpPatchedProtocolOptions {
84
) => Effect.Effect<void, never>;
85
86
readonly transformSessionUpdate?: (
87
- notification: AcpSchema.UpdateSessionNotification | AcpSchemaV1.SessionNotification,
87
+ notification:
88
+ | AcpSchema.UpdateSessionNotification
89
+ | AcpSchemaV1.SessionNotification
90
+ | AcpCompat.SessionNotification,
91
) =>
92
| AcpSchema.UpdateSessionNotification
93
| AcpSchemaV1.SessionNotification
@@ -136,7 +139,22 @@ interface AcpOutgoingWriterState {
139
}
140
141
const decodeSessionUpdate = Schema.decodeUnknownEffect(
139
- Schema.Union([AcpSchema.UpdateSessionNotification, AcpSchemaV1.SessionNotification]),
142
+ Schema.Union([
143
+ // Claude ACP v2 reports prompt failures on idle; alpha.3 omits that field.
144
+ Schema.Struct({
145
+ ...AcpSchema.UpdateSessionNotification.fields,
146
+ update: Schema.Struct({
147
+ sessionUpdate: Schema.Literal("state_update"),
148
+ state: Schema.Literal("idle"),
149
+ stopReason: Schema.optionalKey(Schema.NullOr(AcpSchema.StopReason)),
150
+ usage: Schema.optionalKey(Schema.NullOr(AcpSchema.Usage)),
151
+ error: Schema.optionalKey(Schema.NullOr(AcpSchema.Error)),
152
+ _meta: AcpSchema.UpdateSessionNotification.fields._meta,
153
+ }),
154
+ }),
155
+ AcpSchema.UpdateSessionNotification,
156
+ AcpSchemaV1.SessionNotification,
157
+ ]),
158
);
159
const decodeElicitationComplete = Schema.decodeUnknownEffect(
160
AcpSchema.CompleteElicitationNotification,