The best way to control Claude Code, Codex and more from any computer or phone
fix(server): preserve whitespace in ACP history replay (#37505)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Wout Stiens committed
Nov 16, 2026 at 07:25 UTC
e8bfabaa398f98031bf09c0f1496225e38365cbf
2 files changed
+20
-10
apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts
+15
-4
@@ -3384,19 +3384,30 @@ describe("AcpAdapterV2", () => {
3384
yield* replay("user_message_chunk", "u1", "lo");
3385
yield* replay("agent_message_chunk", "a1", "hi");
3386
yield* replay("user_message_chunk", "u2", "next");
3387
- yield* replay("agent_message_chunk", "a1", " there");
3387
+ yield* replay("agent_message_chunk", "a1", " ");
3388
+ yield* replay("agent_message_chunk", "a1", "there");
3389
+ yield* replay("agent_message_chunk", "a3", "\t");
3390
+ yield* replay("agent_message_chunk", "a3", "code");
3391
+ yield* replay("agent_message_chunk", "a4", "\n\n");
3392
const first = yield* runtime.readThreadSnapshot({ providerThread });
3393
yield* replay("agent_message_chunk", "a2", "done");
3390
- yield* replay("user_message_chunk", "u2", " one");
3394
+ yield* replay("user_message_chunk", "u2", "\n");
3395
+ yield* replay("user_message_chunk", "u2", "\tone");
3396
const second = yield* runtime.readThreadSnapshot({ providerThread });
3397
3398
const texts = (snapshot: typeof first) =>
3399
snapshot.messages.map((message) => `${message.role}:${message.text}`);
3395
- assert.deepEqual(texts(first), ["user:hello", "assistant:hi there", "user:next"]);
3400
+ assert.deepEqual(texts(first), [
3401
+ "user:hello",
3402
+ "assistant:hi there",
3403
+ "user:next",
3404
+ "assistant:\tcode",
3405
+ ]);
3406
assert.deepEqual(texts(second), [
3407
"user:hello",
3408
"assistant:hi there",
3399
- "user:next one",
3409
+ "user:next\n\tone",
3410
+ "assistant:\tcode",
3411
"assistant:done",
3412
]);
3413
}).pipe(Effect.provide(layerTest), Effect.scoped),
packages/provider-acp/src/server/adapter.ts
+5
-6
@@ -5539,11 +5539,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
5539
const lateMonitorChatter =
5540
/<monitor-event\b/i.test(text) ||
5541
/Monitor\s+["']?[0-9a-f-]{8,}["']?\s+ended/i.test(text);
5542
- if (
5543
- text.trim().length > 0 &&
5544
- lateBackgroundMutations.length === 0 &&
5545
- !lateMonitorChatter
5546
- ) {
5542
+ if (lateBackgroundMutations.length === 0 && !lateMonitorChatter) {
5543
yield* appendLoadedHistory(
5544
notification,
5545
update.sessionUpdate === "user_message_chunk"
@@ -9766,7 +9762,10 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
9762
const state = yield* Ref.get(snapshot);
9763
const messages = state.order.flatMap((key) => {
9764
const message = state.messages.get(key);
9769
- return message === undefined ? [] : [message];
9765
+ return message === undefined ||
9766
+ (message.text.trim().length === 0 && message.attachments.length === 0)
9767
+ ? []
9768
+ : [message];
9769
});
9770
const now = yield* DateTime.now;
9771
return {