From daab29af4649f0510f2fe23c14a99f6c740ae680 Mon Sep 17 00:00:00 2001 From: Zero Liu Date: Fri, 3 Jul 2026 12:53:47 +0800 Subject: [PATCH] docs(agent-mode): note AgentDiffView + edit-diff sourcing; formatting Phase 6: document the read-only AgentDiffView and where edit diffs are sourced in agentMode/AGENTS.md, and apply prettier formatting. Full jest suite (4384 tests), eslint (incl. boundaries), and the production build are all green. Co-Authored-By: Claude Opus 4.8 --- src/agentMode/AGENTS.md | 6 ++++++ src/agentMode/sdk/sdkEditResult.test.ts | 24 +++++++++++++++++++++--- src/agentMode/ui/ActionCard.tsx | 7 ++----- src/agentMode/ui/editDiff.ts | 5 +---- 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/agentMode/AGENTS.md b/src/agentMode/AGENTS.md index f8da0aa9..b808b71c 100644 --- a/src/agentMode/AGENTS.md +++ b/src/agentMode/AGENTS.md @@ -94,6 +94,12 @@ Then in either case: - "Knows about a specific binary, install path, BYOK keys, vendor models" → `backends//` - "React component or modal" → `ui/` (generic) or `backends//` (backend-specific) +- "Read-only `AgentDiffView` (editor pane, view type + `copilot-agent-diff-view`, opened via `openAgentDiffView`) rendering an + agent edit diff — sourced from the Claude SDK's `tool_use_result` + (`structuredPatch`/`originalFile`, parsed in `sdk/sdkEditResult.ts`) for + completed edits, from ACP `{type:"diff"}` content otherwise, and + synthesized from tool input for permission-card previews" → `ui/` - "Canonical-store skill discovery, symlink lifecycle, SKILL.md parser/serializer, Skills settings tab (reads `backends/registry.ts` for the brand list)" → `skills/` diff --git a/src/agentMode/sdk/sdkEditResult.test.ts b/src/agentMode/sdk/sdkEditResult.test.ts index 5cbeb270..f81f5b06 100644 --- a/src/agentMode/sdk/sdkEditResult.test.ts +++ b/src/agentMode/sdk/sdkEditResult.test.ts @@ -52,7 +52,13 @@ describe("readSdkFileEditResult", () => { newString: "$& $$ $` $1", originalFile: "before TOKEN after", structuredPatch: [ - { oldStart: 1, oldLines: 1, newStart: 1, newLines: 1, lines: ["-before TOKEN after", "+before $& $$ $` $1 after"] }, + { + oldStart: 1, + oldLines: 1, + newStart: 1, + newLines: 1, + lines: ["-before TOKEN after", "+before $& $$ $` $1 after"], + }, ], userModified: false, replaceAll: false, @@ -71,7 +77,13 @@ describe("readSdkFileEditResult", () => { newString: "X", originalFile: "dup then dup", structuredPatch: [ - { oldStart: 1, oldLines: 1, newStart: 1, newLines: 1, lines: ["-dup then dup", "+X then dup"] }, + { + oldStart: 1, + oldLines: 1, + newStart: 1, + newLines: 1, + lines: ["-dup then dup", "+X then dup"], + }, ], userModified: false, replaceAll: false, @@ -106,7 +118,13 @@ describe("readSdkFileEditResult", () => { filePath: "/vault/note.md", content: "the full new file body", structuredPatch: [ - { oldStart: 1, oldLines: 1, newStart: 1, newLines: 1, lines: ["-old", "+the full new file body"] }, + { + oldStart: 1, + oldLines: 1, + newStart: 1, + newLines: 1, + lines: ["-old", "+the full new file body"], + }, ], originalFile: "old", }; diff --git a/src/agentMode/ui/ActionCard.tsx b/src/agentMode/ui/ActionCard.tsx index 1267047d..20123e6d 100644 --- a/src/agentMode/ui/ActionCard.tsx +++ b/src/agentMode/ui/ActionCard.tsx @@ -35,8 +35,7 @@ export const ActionCard: React.FC = ({ part, inline }) => { // A completed edit whose before/after we can resolve gets the pane treatment: // an inline +/− chip and a whole-row click that opens the diff view. Non-edit // tools yield null here, so they keep the classic expand/file-open behavior. - const editDiff = - part.status === "completed" ? deriveEditDiff(part, summaryCtx) : null; + const editDiff = part.status === "completed" ? deriveEditDiff(part, summaryCtx) : null; const isEditWithDiff = editDiff !== null; const stats = editDiff ? diffStats(editDiff) : null; @@ -57,9 +56,7 @@ export const ActionCard: React.FC = ({ part, inline }) => { ? (summary.targetPath?.(part, summaryCtx) ?? null) : null; - const openDiff = editDiff - ? () => openAgentDiffView(app, editDiff) - : undefined; + const openDiff = editDiff ? () => openAgentDiffView(app, editDiff) : undefined; const rowInteractive = isEditWithDiff || expandable; const headerClasses = cn( diff --git a/src/agentMode/ui/editDiff.ts b/src/agentMode/ui/editDiff.ts index 46484e47..8b7def28 100644 --- a/src/agentMode/ui/editDiff.ts +++ b/src/agentMode/ui/editDiff.ts @@ -26,10 +26,7 @@ interface EditInput { * with `toolSummaries` so the alias list can't drift between the two. */ export function rawEditPath(input: unknown): string | null { - const i = input as - | { file_path?: unknown; filePath?: unknown; path?: unknown } - | null - | undefined; + const i = input as { file_path?: unknown; filePath?: unknown; path?: unknown } | null | undefined; if (typeof i?.file_path === "string") return i.file_path; if (typeof i?.filePath === "string") return i.filePath; if (typeof i?.path === "string") return i.path;