Skip to content

Commit f9e1449

Browse files
fix(ui): label patch file operations accurately
1 parent 459c70e commit f9e1449

9 files changed

Lines changed: 332 additions & 86 deletions

File tree

‎ui/src/e2e/chat-tool-turn-outcome.e2e.test.ts‎

Lines changed: 145 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,25 @@ async function captureToolActivityProof(page: import("playwright").Page, name: s
2929
await page.screenshot({ path: path.join(artifactDir, `${name}.png`), fullPage: true });
3030
}
3131

32+
async function captureFactrowProof(
33+
page: import("playwright").Page,
34+
activity: import("playwright").Locator,
35+
theme: "dark" | "light",
36+
) {
37+
const artifactDir = process.env.OPENCLAW_CONTROL_UI_E2E_ARTIFACT_DIR?.trim();
38+
if (!artifactDir) {
39+
return;
40+
}
41+
const state = process.env.OPENCLAW_FACTROW_PROOF_STATE?.trim() || "after";
42+
await fs.mkdir(artifactDir, { recursive: true });
43+
await page.locator(".chat-main").screenshot({
44+
path: path.join(artifactDir, `factrow-${state}-${theme}-context.png`),
45+
});
46+
await activity.screenshot({
47+
path: path.join(artifactDir, `factrow-${state}-${theme}-rows.png`),
48+
});
49+
}
50+
3251
async function expandCompletedWorkGroups(page: import("playwright").Page) {
3352
const workSummaries = page.locator(".chat-work-group > .chat-activity-group__summary");
3453
await workSummaries.first().waitFor();
@@ -85,7 +104,10 @@ suite.define(() => {
85104
});
86105

87106
it("pairs a canonical parallel batch and renders per-file patch sections", async () => {
88-
const context = await suite.browser.newContext({ viewport: { height: 900, width: 1200 } });
107+
const context = await suite.browser.newContext({
108+
locale: "en-US",
109+
viewport: { height: 900, width: 1200 },
110+
});
89111
const page = await context.newPage();
90112
await installMockGateway(page, {
91113
historyMessages: [
@@ -138,7 +160,7 @@ suite.define(() => {
138160
await page.goto(`${suite.server.baseUrl}chat`);
139161
const activity = page.locator(".chat-group--activity .chat-activity-group__summary");
140162
await activity.waitFor();
141-
expect(await activity.textContent()).toContain("Read a file, edited 2 files");
163+
expect(await activity.textContent()).toContain("Read a file, edited a file, created a file");
142164
if ((await activity.getAttribute("aria-expanded")) !== "true") {
143165
await activity.click();
144166
}
@@ -171,6 +193,127 @@ suite.define(() => {
171193
await context.close();
172194
});
173195

196+
it("preserves mixed producer-recorded file operations in a realistic agent turn", async () => {
197+
const context = await suite.browser.newContext({
198+
colorScheme: "light",
199+
locale: "en-US",
200+
viewport: { height: 760, width: 1120 },
201+
});
202+
const page = await context.newPage();
203+
const timestamp = Date.UTC(2026, 7, 11, 18, 30);
204+
await installMockGateway(page, {
205+
historyMessages: [
206+
{
207+
role: "user",
208+
content:
209+
"Please update the release helper: add the summary module, fix the stable-channel plan, remove the legacy formatter, and run the focused test.",
210+
timestamp,
211+
},
212+
{
213+
role: "assistant",
214+
content: [
215+
{
216+
type: "text",
217+
text: "I’ll make those three scoped file changes, then run the focused release-plan test.",
218+
},
219+
],
220+
timestamp: timestamp + 1_000,
221+
},
222+
{
223+
role: "assistant",
224+
content: [
225+
{
226+
type: "toolCall",
227+
id: "call-release-patch",
228+
name: "apply_patch",
229+
arguments: {
230+
changes: [
231+
{
232+
path: "src/release/release-summary.ts",
233+
kind: { type: "add" },
234+
diff: "export function formatReleaseSummary(version: string) {\n return `Release ${version} is ready.`;\n}\n",
235+
},
236+
{
237+
path: "src/release/release-plan.ts",
238+
kind: { type: "update" },
239+
diff: [
240+
"@@ -8,3 +8,3 @@",
241+
"-export const releaseChannel = 'beta';",
242+
"+export const releaseChannel = 'stable';",
243+
].join("\n"),
244+
},
245+
{
246+
path: "src/release/legacy-format.ts",
247+
kind: { type: "delete" },
248+
diff: "export const legacyReleaseFormat = true;\n",
249+
},
250+
],
251+
},
252+
},
253+
{
254+
type: "toolCall",
255+
id: "call-release-test",
256+
name: "exec",
257+
arguments: { command: "pnpm test src/release/release-plan.test.ts" },
258+
},
259+
],
260+
timestamp: timestamp + 2_000,
261+
},
262+
{
263+
role: "toolResult",
264+
toolCallId: "call-release-patch",
265+
toolName: "apply_patch",
266+
content: [{ type: "text", text: "Applied patch" }],
267+
timestamp: timestamp + 3_000,
268+
},
269+
{
270+
role: "toolResult",
271+
toolCallId: "call-release-test",
272+
toolName: "exec",
273+
content: [{ type: "text", text: "PASS src/release/release-plan.test.ts (8 tests)" }],
274+
timestamp: timestamp + 4_000,
275+
},
276+
{
277+
role: "assistant",
278+
content: [
279+
{
280+
type: "text",
281+
text: "Done. The summary module is in place, the stable-channel plan is updated, the legacy formatter is removed, and all 8 focused tests pass.",
282+
},
283+
],
284+
timestamp: timestamp + 5_000,
285+
},
286+
],
287+
});
288+
289+
await page.goto(`${suite.server.baseUrl}chat`);
290+
await page.getByText("Done. The summary module is in place", { exact: false }).waitFor();
291+
const activity = page.locator(".chat-group--activity");
292+
const summary = activity.locator(".chat-activity-group__summary");
293+
if ((await summary.getAttribute("aria-expanded")) !== "true") {
294+
await summary.click();
295+
}
296+
297+
const patchRow = activity.locator(".chat-tool-msg-summary", { hasText: "3 files" });
298+
const commandRow = activity.locator(".chat-tool-msg-summary", {
299+
hasText: "pnpm test src/release/release-plan.test.ts",
300+
});
301+
await patchRow.waitFor();
302+
await commandRow.waitFor();
303+
await captureFactrowProof(page, activity, "light");
304+
305+
await page.emulateMedia({ colorScheme: "dark" });
306+
await expect
307+
.poll(() => page.evaluate(() => document.documentElement.dataset.themeMode))
308+
.toBe("dark");
309+
await captureFactrowProof(page, activity, "dark");
310+
expect(await summary.textContent()).toContain(
311+
"Ran a command, edited a file, created a file, deleted a file",
312+
);
313+
expect(await patchRow.locator(".chat-tool-row__verb").textContent()).toBe("Changed");
314+
await context.close();
315+
});
316+
174317
it("shows native tool input when the result sorts before its call", async () => {
175318
const context = await suite.browser.newContext({ viewport: { height: 800, width: 1200 } });
176319
const page = await context.newPage();

‎ui/src/i18n/locales/en.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5327,6 +5327,15 @@ export const en: TranslationMap = {
53275327
edit: "Edit",
53285328
editing: "Editing",
53295329
edited: "Edited",
5330+
create: "Create",
5331+
creating: "Creating",
5332+
created: "Created",
5333+
delete: "Delete",
5334+
deleting: "Deleting",
5335+
deleted: "Deleted",
5336+
change: "Change",
5337+
changing: "Changing",
5338+
changed: "Changed",
53305339
write: "Write",
53315340
writing: "Writing",
53325341
wrote: "Wrote",
@@ -5342,6 +5351,8 @@ export const en: TranslationMap = {
53425351
editsMany: "edited {count} files",
53435352
writesOne: "created a file",
53445353
writesMany: "created {count} files",
5354+
deletesOne: "deleted a file",
5355+
deletesMany: "deleted {count} files",
53455356
searchesOne: "ran a search",
53465357
searchesMany: "ran {count} searches",
53475358
fetchesOne: "fetched a page",

‎ui/src/lib/chat/tool-call-grouping.test.ts‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe("summarizeToolGroup", () => {
8686
},
8787
},
8888
],
89-
"Edited 2 files",
89+
"Edited a file, created a file",
9090
],
9191
[
9292
"structured Codex change targets",
@@ -101,7 +101,19 @@ describe("summarizeToolGroup", () => {
101101
},
102102
},
103103
],
104-
"Edited 2 files",
104+
"Edited a file, created a file",
105+
],
106+
[
107+
"deleted Codex targets",
108+
[
109+
{
110+
name: "apply_patch",
111+
args: {
112+
changes: [{ path: "src/obsolete.ts", kind: { type: "delete" } }],
113+
},
114+
},
115+
],
116+
"Deleted a file",
105117
],
106118
["one generic tool by name", [{ name: "mcp__linear" }], "Used mcp__linear"],
107119
[

0 commit comments

Comments
 (0)