Skip to content

Commit 2d2dacd

Browse files
t3dotggclaude
andcommitted
fix(acp): give no diff preview when any diff is an unplaced snippet
Beside another diff, a snippet was returned as the patch and the other diff was dropped. Treat any snippet like an omitted diff; the checkpoint diff shows the change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 7698786 commit 2d2dacd

2 files changed

Lines changed: 26 additions & 10 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,19 @@ describe("acpToolCallDiffPatch", () => {
282282
newStr: "const target = 100;",
283283
});
284284
}
285+
// Beside another diff, the snippet is neither a patch nor a placed edit.
286+
const twoDiffs = [
287+
...content,
288+
{
289+
type: "diff",
290+
path: "/repo/b.ts",
291+
oldText: "b\n",
292+
newText: "B\n",
293+
patch: { text: "@@ -1 +1 @@\n-b\n+B\n" },
294+
},
295+
];
296+
assert.isUndefined(acpToolCallDiffPatch(twoDiffs));
297+
assert.isUndefined(acpToolCallSnippetEdit(twoDiffs));
285298
});
286299

287300
it("builds per-file patches from ACP hunks and recorded old/new text", () => {

‎packages/provider-acp/src/server/adapter.ts‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -956,20 +956,22 @@ export function acpToolCallSnippetEdit(content: unknown) {
956956
: undefined;
957957
}
958958

959-
/** A flavor marked the diff `omitted`: too large to preview; the checkpoint diff shows it. */
960-
function acpToolCallDiffOmitted(content: unknown): boolean {
959+
/**
960+
* No preview when a flavor marked a diff `omitted` (too large) or `snippet` (line unknown);
961+
* the checkpoint diff shows it.
962+
*/
963+
function acpToolCallDiffUnpreviewable(content: unknown): boolean {
961964
return (
962965
Array.isArray(content) &&
963-
content.some((entry) => unknownRecord(unknownRecord(entry)?.patch)?.format === "omitted")
966+
content.some((entry) => {
967+
const format = unknownRecord(unknownRecord(entry)?.patch)?.format;
968+
return format === "omitted" || format === "snippet";
969+
})
964970
);
965971
}
966972

967973
export function acpToolCallDiffPatch(content: unknown): string | undefined {
968-
if (
969-
!Array.isArray(content) ||
970-
acpToolCallSnippetEdit(content) !== undefined ||
971-
acpToolCallDiffOmitted(content)
972-
) {
974+
if (!Array.isArray(content) || acpToolCallDiffUnpreviewable(content)) {
973975
return undefined;
974976
}
975977
const diffs = content.flatMap((entry) => {
@@ -3980,12 +3982,13 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
39803982
case "delete":
39813983
case "move": {
39823984
const snippet = acpToolCallSnippetEdit(toolCall.data.content);
3983-
const omitted = acpToolCallDiffOmitted(toolCall.data.content);
3985+
const unpreviewable = acpToolCallDiffUnpreviewable(toolCall.data.content);
39843986
turnItem = {
39853987
...base,
39863988
type: "file_change",
39873989
fileName: path ?? toolCall.title ?? "File change",
3988-
...(snippet ?? (omitted || diffText === undefined ? {} : { diffStr: diffText })),
3990+
...(snippet ??
3991+
(unpreviewable || diffText === undefined ? {} : { diffStr: diffText })),
39893992
};
39903993
break;
39913994
}

0 commit comments

Comments
 (0)