From 601d9ba36d1c8f6d1e180a0c5cc1d5597906d33a Mon Sep 17 00:00:00 2001 From: Leo <45218470+ngleo@users.noreply.github.com> Date: Sat, 28 Jun 2025 19:02:44 +0100 Subject: fix edit retrigger (#2306) --- packages/core/src/tools/write-file.test.ts | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'packages/core/src/tools/write-file.test.ts') diff --git a/packages/core/src/tools/write-file.test.ts b/packages/core/src/tools/write-file.test.ts index 4646f30a..3f9825c6 100644 --- a/packages/core/src/tools/write-file.test.ts +++ b/packages/core/src/tools/write-file.test.ts @@ -567,5 +567,49 @@ describe('WriteFileTool', () => { expect(fs.existsSync(filePath)).toBe(true); expect(fs.readFileSync(filePath, 'utf8')).toBe(content); }); + + it('should include modification message when proposed content is modified', async () => { + const filePath = path.join(rootDir, 'new_file_modified.txt'); + const content = 'New file content modified by user'; + mockEnsureCorrectFileContent.mockResolvedValue(content); + + const params = { + file_path: filePath, + content, + modified_by_user: true, + }; + const result = await tool.execute(params, abortSignal); + + expect(result.llmContent).toMatch(/User modified the `content`/); + }); + + it('should not include modification message when proposed content is not modified', async () => { + const filePath = path.join(rootDir, 'new_file_unmodified.txt'); + const content = 'New file content not modified'; + mockEnsureCorrectFileContent.mockResolvedValue(content); + + const params = { + file_path: filePath, + content, + modified_by_user: false, + }; + const result = await tool.execute(params, abortSignal); + + expect(result.llmContent).not.toMatch(/User modified the `content`/); + }); + + it('should not include modification message when modified_by_user is not provided', async () => { + const filePath = path.join(rootDir, 'new_file_unmodified.txt'); + const content = 'New file content not modified'; + mockEnsureCorrectFileContent.mockResolvedValue(content); + + const params = { + file_path: filePath, + content, + }; + const result = await tool.execute(params, abortSignal); + + expect(result.llmContent).not.toMatch(/User modified the `content`/); + }); }); }); -- cgit v1.2.3