Skip to content

Commit 83e48ea

Browse files
authored
removes approval diff (#181)
1 parent 67b7efc commit 83e48ea

2 files changed

Lines changed: 67 additions & 20 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/**
2+
* Copyright 2026 GoodRx, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { buildProposedFileChanges } from '../fileChanges';
18+
19+
describe('buildProposedFileChanges', () => {
20+
it('keeps workspace edit approvals as before-and-after previews instead of fake diffs', () => {
21+
const [change] = buildProposedFileChanges({
22+
toolCallId: 'tool-1',
23+
sourceTool: 'workspace.edit_file',
24+
input: {
25+
path: '/workspace/sample-service/app.js',
26+
oldText: 'before',
27+
newText: 'after',
28+
},
29+
});
30+
31+
expect(change).toMatchObject({
32+
id: 'tool-1:sample-service/app.js',
33+
toolCallId: 'tool-1',
34+
sourceTool: 'workspace.edit_file',
35+
path: '/workspace/sample-service/app.js',
36+
displayPath: 'sample-service/app.js',
37+
stage: 'awaiting-approval',
38+
unifiedDiff: null,
39+
beforeTextPreview: 'before',
40+
afterTextPreview: 'after',
41+
});
42+
});
43+
44+
it('keeps workspace writes as preview-only changes', () => {
45+
const [change] = buildProposedFileChanges({
46+
toolCallId: 'tool-2',
47+
sourceTool: 'workspace.write_file',
48+
input: {
49+
path: '/workspace/sample-service/README.md',
50+
content: '# Sample service',
51+
},
52+
});
53+
54+
expect(change).toMatchObject({
55+
id: 'tool-2:sample-service/README.md',
56+
toolCallId: 'tool-2',
57+
sourceTool: 'workspace.write_file',
58+
path: '/workspace/sample-service/README.md',
59+
displayPath: 'sample-service/README.md',
60+
stage: 'awaiting-approval',
61+
unifiedDiff: null,
62+
beforeTextPreview: null,
63+
afterTextPreview: '# Sample service',
64+
});
65+
});
66+
});

‎src/server/services/agent/fileChanges.ts‎

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -92,25 +92,6 @@ function countChangedLines(value: string): number {
9292
return value.split('\n').length;
9393
}
9494

95-
function buildUnifiedDiff(path: string, before: string, after: string): string | null {
96-
if (before === after) {
97-
return null;
98-
}
99-
100-
const displayPath = trimWorkspacePrefix(path);
101-
const beforeLines = before.split('\n');
102-
const afterLines = after.split('\n');
103-
104-
return [
105-
`diff --git a/${displayPath} b/${displayPath}`,
106-
`--- a/${displayPath}`,
107-
`+++ b/${displayPath}`,
108-
`@@ -1,${beforeLines.length} +1,${afterLines.length} @@`,
109-
...beforeLines.map((line) => `-${line}`),
110-
...afterLines.map((line) => `+${line}`),
111-
].join('\n');
112-
}
113-
11495
function unwrapToolPayload(value: unknown): unknown {
11596
if (!isRecord(value) || !Array.isArray(value.content)) {
11697
return value;
@@ -270,7 +251,7 @@ export function buildProposedFileChanges({
270251
additions: countChangedLines(args.newText),
271252
deletions: countChangedLines(args.oldText),
272253
truncated: false,
273-
unifiedDiff: buildUnifiedDiff(args.path, args.oldText, args.newText),
254+
unifiedDiff: null,
274255
beforeTextPreview: args.oldText,
275256
afterTextPreview: args.newText,
276257
summary: `Proposed update to ${trimWorkspacePrefix(args.path)}`,

0 commit comments

Comments
 (0)