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, 06:00 UTC
fix(provider-acp): a running tool shows the file a location-only update names (#39147)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Soroush Baraouf committed
Nov 19, 2026 at 10:16 UTC
541be77b1bb758a413df0b9dd40c09d57cf52dc0
3 files changed
+135
-7
packages/provider-acp/src/server/runtimeModel.test.ts
+13
-6
@@ -17,6 +17,7 @@ import {
17
sessionUpdateIsReplay,
18
syntheticLoadSessionResponseFromInitialize,
19
toolCallProgressLength,
20
+ toolCallVisibleOutputChanged,
21
withTrackedPermissionToolCall,
22
type AcpToolCallState,
23
} from "./runtimeModel.ts";
@@ -335,7 +336,6 @@ describe("AcpRuntimeModel", () => {
336
update: {
337
sessionUpdate: "tool_call_update",
338
toolCallId: "read-1",
338
- kind: "read",
339
...(locations === undefined ? {} : { locations }),
340
},
341
} satisfies EffectAcpSchema.SessionNotification);
@@ -351,14 +351,21 @@ describe("AcpRuntimeModel", () => {
351
const cleared = mergeToolCallState(created, toolCall([]));
352
expect(cleared.data.locations).toEqual([]);
353
expect(mergeToolCallState(created, toolCall(null)).data.locations).toEqual([]);
354
- expect(
354
+ const emits = (previous: AcpToolCallState, next: AcpToolCallState) =>
355
decideToolCallUpdateEmission({
356
- previous: created,
357
- next: cleared,
356
+ previous,
357
+ next,
358
lastEmittedDetailLength: 0,
359
skippedSinceEmit: 0,
360
- }).emit,
361
- ).toBe(true);
360
+ }).emit;
361
+ expect(emits(created, cleared)).toBe(true);
362
+ expect(toolCallVisibleOutputChanged(created, cleared)).toBe(true);
363
+ const relocated = mergeToolCallState(cleared, toolCall([{ path: "/workspace/src/app.ts" }]));
364
+ expect(emits(cleared, relocated)).toBe(true);
365
+ expect(toolCallVisibleOutputChanged(cleared, relocated)).toBe(true);
366
+ const repeated = mergeToolCallState(relocated, toolCall([{ path: "/workspace/src/app.ts" }]));
367
+ expect(emits(relocated, repeated)).toBe(false);
368
+ expect(toolCallVisibleOutputChanged(relocated, repeated)).toBe(false);
369
});
370
371
it("clears explicitly nulled ACP v2 tool call fields and replaces raw input", () => {
packages/provider-acp/src/server/runtimeModel.ts
+13
-1
@@ -1035,12 +1035,19 @@ function toolCallContentTexts(state: AcpToolCallState): string {
1035
.join("\u0000");
1036
}
1037
1038
+function toolCallLocationsChanged(previous: AcpToolCallState, next: AcpToolCallState): boolean {
1039
+ const before = previous.data.locations;
1040
+ const after = next.data.locations;
1041
+ return before !== after && JSON.stringify(before) !== JSON.stringify(after);
1042
+}
1043
+
1044
export function toolCallVisibleOutputChanged(
1045
previous: AcpToolCallState,
1046
next: AcpToolCallState,
1047
): boolean {
1048
return (
1049
previous.detail !== next.detail ||
1050
+ toolCallLocationsChanged(previous, next) ||
1051
toolCallContentTexts(previous) !== toolCallContentTexts(next) ||
1052
JSON.stringify(previous.data.rawOutput) !== JSON.stringify(next.data.rawOutput)
1053
);
@@ -1053,7 +1060,12 @@ export function decideToolCallUpdateEmission(
1060
if (next.status === "completed" || next.status === "failed") {
1061
return { emit: true, skippedSinceEmit: 0 };
1062
}
1056
- if (previous === undefined || previous.title !== next.title || previous.status !== next.status) {
1063
+ if (
1064
+ previous === undefined ||
1065
+ previous.title !== next.title ||
1066
+ previous.status !== next.status ||
1067
+ toolCallLocationsChanged(previous, next)
1068
+ ) {
1069
return { emit: true, skippedSinceEmit: 0 };
1070
}
1071
if (previous.detail === next.detail && toolCallOutputUnchanged(previous, next)) {
scripts/scenarios/acp-location-only-update-names-edited-file.e2e.ts
new
+109
@@ -0,0 +1,109 @@
1
+// @effect-diagnostics nodeBuiltinImport:off -- The scenario stages a local ACP executable and its release gate.
2
+import * as NodeFSP from "node:fs/promises";
3
+import * as NodePath from "node:path";
4
+
5
+import { expect } from "e2e";
6
+
7
+import { T3_HOME } from "../e2e.config.ts";
8
+import { makeState, runPromise, test, WEB } from "./t3.ts";
9
+
10
+const FILE = "location-proof.ts";
11
+const ACP = `
12
+import { unwatchFile, watchFile } from "node:fs";
13
+import { createInterface } from "node:readline";
14
+
15
+const [file, gate] = process.argv.slice(2);
16
+const sessionId = "location-scenario";
17
+const send = (message) => process.stdout.write(JSON.stringify({ jsonrpc: "2.0", ...message }) + "\\n");
18
+const update = (update) => send({ method: "session/update", params: { sessionId, update } });
19
+for await (const line of createInterface({ input: process.stdin })) {
20
+ const { id, method } = JSON.parse(line);
21
+ if (id === undefined) continue;
22
+ if (method === "initialize") {
23
+ send({ id, result: { protocolVersion: 1, agentInfo: { name: "location-agent", version: "1.0.0" }, agentCapabilities: {}, authMethods: [] } });
24
+ } else if (method === "session/new") {
25
+ send({ id, result: { sessionId } });
26
+ } else if (method === "session/prompt") {
27
+ update({ sessionUpdate: "tool_call", toolCallId: "edit-1", title: "Edit", kind: "edit", status: "in_progress" });
28
+ // The agent names the file it edits only after announcing the tool call.
29
+ update({ sessionUpdate: "tool_call_update", toolCallId: "edit-1", locations: [{ path: file }] });
30
+ watchFile(gate, { interval: 100 }, (stat) => {
31
+ if (stat.nlink === 0) return;
32
+ unwatchFile(gate);
33
+ update({ sessionUpdate: "tool_call_update", toolCallId: "edit-1", status: "completed" });
34
+ send({ id, result: { stopReason: "end_turn" } });
35
+ });
36
+ } else {
37
+ send({ id, error: { code: -32601, message: "Method not found" } });
38
+ }
39
+}
40
+`;
41
+
42
+test(
43
+ "A running ACP edit names the file a location-only tool_call_update reports",
44
+ WEB,
45
+ async ({ t3, app, screen }) => {
46
+ const project = await t3.project("demo", { [`src/${FILE}`]: "export {};\n" });
47
+ const script = NodePath.join(project, "location-acp.mjs");
48
+ const gate = NodePath.join(project, "release-edit");
49
+ const settingsPath = NodePath.join(T3_HOME, "userdata/settings.json");
50
+ const originalSettings = await NodeFSP.readFile(settingsPath, "utf8");
51
+ const settings = JSON.parse(originalSettings);
52
+ await NodeFSP.writeFile(script, ACP);
53
+ settings.providerInstances["location-agent"] = {
54
+ driver: "acpRegistry",
55
+ displayName: "Location Agent",
56
+ enabled: true,
57
+ config: {
58
+ source: "local",
59
+ commandPath: process.execPath,
60
+ commandArgs: [script, NodePath.join(project, "src", FILE), gate],
61
+ },
62
+ };
63
+ try {
64
+ await NodeFSP.writeFile(settingsPath, JSON.stringify(settings));
65
+ const { cli } = makeState(T3_HOME);
66
+ // The watcher reloads settings asynchronously. Retry only before a thread was created.
67
+ let threadId: string | undefined;
68
+ for (let attempt = 0; attempt < 8 && threadId === undefined; attempt++) {
69
+ const started = await runPromise(
70
+ cli(
71
+ [
72
+ "thread",
73
+ "start",
74
+ project,
75
+ "Edit the proof file.",
76
+ "--title",
77
+ "Location-only update",
78
+ "--provider",
79
+ "location-agent",
80
+ "--model",
81
+ "default",
82
+ "--json",
83
+ ],
84
+ [0, 1],
85
+ ),
86
+ );
87
+ if (!started.stdout.includes("threadId")) continue;
88
+ threadId = (JSON.parse(started.stdout) as { threadId: string }).threadId;
89
+ }
90
+ if (threadId === undefined) throw new Error("Could not start the location agent's turn.");
91
+
92
+ await t3.open({ threadId });
93
+ await screen.getByText("Working for", { exact: false }).first().waitFor({ timeout: 60_000 });
94
+ try {
95
+ await expect(screen.getByRole("button", /^demo\/src\/location-proof\.ts$/)).toBeVisible({
96
+ timeout: 15_000,
97
+ });
98
+ } finally {
99
+ await app.screenshot("running-edit-row");
100
+ }
101
+ } finally {
102
+ try {
103
+ await NodeFSP.writeFile(gate, "");
104
+ } finally {
105
+ await NodeFSP.writeFile(settingsPath, originalSettings);
106
+ }
107
+ }
108
+ },
109
+);