From 86aaa9e5ca6184f2dd5c2e2fa94807ae186c59a8 Mon Sep 17 00:00:00 2001 From: LE Quoc Dat Date: Mon, 28 Jul 2025 22:02:07 +0200 Subject: [PATCH] AI: How can we stream the edit_file tool when it generating like create_file ? Also the edit_file tool show this """Invalid File Edit Could not extract the file changes from the tool result.""" Check the state of code base and make to sure implement fully --- .../thread/tool-views/file-operation/FileEditToolView.tsx | 2 +- .../src/components/thread/tool-views/file-operation/_utils.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/thread/tool-views/file-operation/FileEditToolView.tsx b/frontend/src/components/thread/tool-views/file-operation/FileEditToolView.tsx index 849248f3..e7953260 100644 --- a/frontend/src/components/thread/tool-views/file-operation/FileEditToolView.tsx +++ b/frontend/src/components/thread/tool-views/file-operation/FileEditToolView.tsx @@ -142,7 +142,7 @@ export function FileEditToolView({ const lineDiff = originalContent && updatedContent ? generateLineDiff(originalContent, updatedContent) : []; const stats: DiffStats = calculateDiffStats(lineDiff); - const shouldShowError = !isStreaming && (!actualIsSuccess || (actualIsSuccess && (!originalContent || !updatedContent))); + const shouldShowError = !isStreaming && (!actualIsSuccess || (actualIsSuccess && (originalContent === null || updatedContent === null))); return ( diff --git a/frontend/src/components/thread/tool-views/file-operation/_utils.ts b/frontend/src/components/thread/tool-views/file-operation/_utils.ts index 717c7877..335430f4 100644 --- a/frontend/src/components/thread/tool-views/file-operation/_utils.ts +++ b/frontend/src/components/thread/tool-views/file-operation/_utils.ts @@ -265,8 +265,8 @@ export const extractFileEditData = ( const success = parsed.tool_execution.result?.success; return { filePath: args.target_file || output?.file_path || null, - originalContent: output?.original_content || null, - updatedContent: output?.updated_content || null, + originalContent: output?.original_content ?? null, + updatedContent: output?.updated_content ?? null, success: success, timestamp: parsed.tool_execution.execution_details?.timestamp, errorMessage: success === false ? (output?.message || (typeof output === 'string' ? output : JSON.stringify(output))) : undefined,