Skip to content
Python

fix(gui): the summary names the files a patch changes (OPE-238)

Devika Verma2aa4512382f4
diff --git a/surfaces/gui/src/components/UnaskedSummary.test.tsx b/surfaces/gui/src/components/UnaskedSummary.test.tsx
index d9e8aec8..f54f151a 100644
--- a/surfaces/gui/src/components/UnaskedSummary.test.tsx
+++ b/surfaces/gui/src/components/UnaskedSummary.test.tsx
@@ -1,7 +1,7 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { cleanup, fireEvent, render, screen, within } from "@testing-library/react";
import { Transcript } from "./Transcript";
-import { exitCodeOf } from "./UnaskedSummary";
+import { exitCodeOf, patchSummary } from "./UnaskedSummary";
import type { Item } from "../types";
afterEach(cleanup);
@@ -220,6 +220,69 @@ describe("changes made without asking (OPE-238)", () => {
});
});
+// A patch names its files in its headers. The summary says what happened to each one,
+// instead of "Edited files" (seen live: a patch that only deleted old-notes.txt read as
+// "Edited files", 26 Oct 2026).
+describe("patch rows name their files", () => {
+ const patchTurn = (name: string, args: any): Item[] => [
+ { kind: "user", text: "tidy up" },
+ { kind: "tool", id: "t1", callId: "c1", name, args, status: "ok", approvalOrigin: "reviewer" },
+ { kind: "assistant", text: "Done." },
+ ];
+ const rowText = (items: Item[]) => {
+ render(<Transcript items={items} onApprove={vi.fn()} />);
+ fireEvent.click(screen.getByTestId("unasked-summary-head"));
+ return within(screen.getByTestId("unasked-group-files")).getByTestId("unasked-item-line").textContent;
+ };
+
+ it("a patch that only deletes a file says Deleted <file>", () => {
+ const patch = "*** Begin Patch\n*** Delete File: old-notes.txt\n*** End Patch";
+ const text = rowText(patchTurn("apply_patch", { patch }));
+ expect(text).toBe("Deleted old-notes.txt");
+ expect(text).not.toContain("Edited files");
+ });
+
+ it("a patch touching several files names each with what happened to it", () => {
+ const patch =
+ "*** Begin Patch\n*** Add File: summary.txt\n+done\n*** Update File: notes.md\n@@\n-a\n+b\n" +
+ "*** Delete File: old-notes.txt\n*** Update File: draft.md\n*** Move to: final.md\n@@\n-x\n+y\n*** End Patch";
+ expect(rowText(patchTurn("apply_patch", { patch }))).toBe(
+ "Created summary.txt · Edited notes.md · Deleted old-notes.txt · Moved draft.md to final.md",
+ );
+ });
+
+ it("a unified diff that removes a file says Deleted <file>", () => {
+ const diff = "--- a/old-notes.txt\n+++ /dev/null\n@@ -1 +0,0 @@\n-old\n";
+ expect(rowText(patchTurn("apply_unified_diff", { diff }))).toBe("Deleted old-notes.txt");
+ });
+
+ it("a unified diff that creates or edits files names them", () => {
+ const diff =
+ "--- /dev/null\n+++ b/summary.txt\n@@ -0,0 +1 @@\n+done\n" +
+ "--- a/notes.md\n+++ b/notes.md\n@@ -1 +1 @@\n-a\n+b\n";
+ expect(rowText(patchTurn("apply_unified_diff", { diff }))).toBe("Created summary.txt · Edited notes.md");
+ });
+
+ it("a write to one file still shows its path, as before", () => {
+ const text = rowText(patchTurn("write_file", { path: "docs/summary.md", content: "x" }));
+ expect(text).toBe("Wrote docs/summary.md");
+ });
+});
+
+describe("patchSummary", () => {
+ it("reads Codex-style patch headers", () => {
+ expect(patchSummary("apply_patch", { patch: "*** Begin Patch\n*** Delete File: a.txt\n*** End Patch" })).toEqual([
+ { verb: "deleted", path: "a.txt" },
+ ]);
+ });
+
+ it("returns nothing for a patch with no headers it understands", () => {
+ expect(patchSummary("apply_patch", { patch: "garbage" })).toEqual([]);
+ expect(patchSummary("apply_patch", {})).toEqual([]);
+ expect(patchSummary("write_file", { path: "a.txt" })).toEqual([]);
+ });
+});
+
describe("exitCodeOf", () => {
it("reads the exit code from a JSON result, a truncated one, or not at all", () => {
expect(exitCodeOf('{"exit_code": 0}')).toBe(0);
diff --git a/surfaces/gui/src/components/UnaskedSummary.tsx b/surfaces/gui/src/components/UnaskedSummary.tsx
index 41e2fa75..1c644e17 100644
--- a/surfaces/gui/src/components/UnaskedSummary.tsx
+++ b/surfaces/gui/src/components/UnaskedSummary.tsx
@@ -94,6 +94,46 @@ function Diff({ tool }: { tool: ToolItem }) {
);
}
+export type PatchChange = { verb: "created" | "edited" | "deleted" | "moved"; path: string; to?: string };
+
+// What a patch does to each file, from its headers, so the summary names the files instead
+// of "Edited files". Codex-style patches (`*** Add/Update/Delete File:`, `*** Move to:`) and
+// unified diffs (`--- a/x` / `+++ b/x`, with /dev/null for a created or deleted file).
+export function patchSummary(name: string, args: any): PatchChange[] {
+ const a = args && typeof args === "object" ? args : {};
+ const changes: PatchChange[] = [];
+ if (name === "apply_patch") {
+ for (const raw of lines(a.patch)) {
+ const m = /^\*\*\* (Add|Update|Delete) File: (.+)$/.exec(raw.trim());
+ if (m) {
+ const verb = m[1] === "Add" ? "created" : m[1] === "Delete" ? "deleted" : "edited";
+ changes.push({ verb, path: m[2].trim() });
+ continue;
+ }
+ const move = /^\*\*\* Move to: (.+)$/.exec(raw.trim());
+ const last = changes[changes.length - 1];
+ if (move && last && last.verb === "edited") {
+ last.verb = "moved";
+ last.to = move[1].trim();
+ }
+ }
+ } else if (name === "apply_unified_diff") {
+ const strip = (p: string) => p.trim().replace(/^[ab]\//, "");
+ let from = "";
+ for (const raw of lines(a.diff)) {
+ if (raw.startsWith("--- ")) from = raw.slice(4).trim();
+ else if (raw.startsWith("+++ ")) {
+ const to = raw.slice(4).trim();
+ if (to === "/dev/null") changes.push({ verb: "deleted", path: strip(from) });
+ else if (from === "/dev/null") changes.push({ verb: "created", path: strip(to) });
+ else changes.push({ verb: "edited", path: strip(to) });
+ from = "";
+ }
+ }
+ }
+ return changes.filter((c) => c.path);
+}
+
function UnaskedItem({ tool, onOpenAudit }: { tool: ToolItem; onOpenAudit?: (callId: string) => void }) {
const { t } = useTranslation();
const line = humanizeTool(tool.name, tool.args);
@@ -101,13 +141,28 @@ function UnaskedItem({ tool, onOpenAudit }: { tool: ToolItem; onOpenAudit?: (cal
const isCommand = COMMAND_TOOLS.has(tool.name);
const exit = isCommand ? exitCodeOf(tool.preview) : null;
const failed = tool.status !== "ok";
+ const patched = patchSummary(tool.name, tool.args);
return (
<div data-testid="unasked-item" className="py-0.5">
<div className="flex items-baseline gap-2 px-2">
<span className={"w-3.5 text-center text-label shrink-0 " + (failed || (exit !== null && exit !== 0) ? "text-danger" : "text-ok")}>●</span>
- <span className="min-w-0 text-ui leading-relaxed">
+ <span className="min-w-0 text-ui leading-relaxed" data-testid="unasked-item-line">
{isCommand ? (
<code className="font-mono text-meta text-ink break-all">{String(tool.args?.command ?? "")}</code>
+ ) : patched.length ? (
+ patched.map((change, i) => (
+ <span key={i}>
+ {i > 0 && <span className="text-faint"> · </span>}
+ <span className="text-muted">{t(`transcript.unasked.${change.verb}`)} </span>
+ <span className="font-mono text-meta text-ink break-all">{change.path}</span>
+ {change.to && (
+ <>
+ <span className="text-muted"> {t("transcript.unasked.moved_to")} </span>
+ <span className="font-mono text-meta text-ink break-all">{change.to}</span>
+ </>
+ )}
+ </span>
+ ))
) : path ? (
<>
<span className="text-muted">{line.pre}</span>
diff --git a/surfaces/gui/src/locales/en.json b/surfaces/gui/src/locales/en.json
index b9fdc8fe..139b54d4 100644
--- a/surfaces/gui/src/locales/en.json
+++ b/surfaces/gui/src/locales/en.json
@@ -298,7 +298,12 @@
"exit": "exit {{code}}",
"audit": "audit log",
"more_lines": "… {{count}} more lines",
- "more_lines_one": "… {{count}} more line"
+ "more_lines_one": "… {{count}} more line",
+ "created": "Created",
+ "edited": "Edited",
+ "deleted": "Deleted",
+ "moved": "Moved",
+ "moved_to": "to"
}
},
"rail": {
diff --git a/surfaces/gui/src/locales/zh.json b/surfaces/gui/src/locales/zh.json
index 851d6336..07487cdd 100644
--- a/surfaces/gui/src/locales/zh.json
+++ b/surfaces/gui/src/locales/zh.json
@@ -293,7 +293,12 @@
"group_other": "其他操作",
"exit": "退出码 {{code}}",
"audit": "审计日志",
- "more_lines": "… 还有 {{count}} 行"
+ "more_lines": "… 还有 {{count}} 行",
+ "created": "新建",
+ "edited": "编辑",
+ "deleted": "删除",
+ "moved": "移动",
+ "moved_to": "至"
}
},
"rail": {