+ {/* Header */}
+
+
+
+
+
+
+
{config.title}
+
{processedFilePath}
+
+
+
+ {toolContent && (
+
+ {isSuccess ? 'Success' : 'Failed'}
+
+ )}
+
+
+ {/* File Content for create and rewrite operations */}
+ {operation !== "delete" && fileContent && (
+
+ {/* IDE Header */}
+
+
+ {isMarkdown ?
+ :
+
+ }
+ {fileName}
+
+
+ {fileType}
+
+
+
+ {/* File Content */}
+
+
+ {contentLines.map((line, idx) => (
+
+
+ {idx + 1}
+
+
+ {line || ' '}
+
+
+ ))}
+
+
+
+
+ )}
+
+ {/* Debug info for delete operations with missing file path */}
+ {showDebugInfo && (
+
+
+
Debug Info: Unable to extract file path
+
+
+
Raw Assistant Content:
+
+ {assistantContent || "No content"}
+
+
+
+ )}
+
+ {/* Delete view with unknown path */}
+ {operation === "delete" && !processedFilePath && (
+
+
+
+
+
+
File Deleted
+
+
A file has been deleted but the path could not be determined
+
+
+ {/* Status footer */}
+
+
+ {isSuccess ? (
+
+ ) : (
+
+ )}
+
+ {isSuccess ? config.successMessage : `Failed to delete file`}
+
+
+
+
+ )}
+
+ {/* Delete view */}
+ {operation === "delete" && processedFilePath && (
+
+
+
+
+
+
File Deleted
+
+ {processedFilePath}
+
+
This file has been permanently removed
+
+
+ {/* Status footer */}
+
+
+ {isSuccess ? (
+
+ ) : (
+
+ )}
+
+ {isSuccess ? config.successMessage : `Failed to delete file`}
+
+
+
+
+ )}
+
+ {/* Status footer - only show for non-delete operations as delete has its own */}
+ {operation !== "delete" && (
+
+
+ {isSuccess ? (
+
+ ) : (
+
+ )}
+
+ {isSuccess ? config.successMessage : `Failed to ${operation} file`}
+
+
+
+ )}
+
+ {/* Timestamps */}
+
+ {assistantTimestamp && (
+
+ Requested:
+ {formatTimestamp(assistantTimestamp)}
+
+ )}
+ {toolTimestamp && (
+
+ Completed:
+ {formatTimestamp(toolTimestamp)}
+
+ )}
+
+
+ );
+}
\ No newline at end of file
diff --git a/frontend/src/components/thread/tool-views/FileRewriteToolView.tsx b/frontend/src/components/thread/tool-views/FileRewriteToolView.tsx
deleted file mode 100644
index 591631da..00000000
--- a/frontend/src/components/thread/tool-views/FileRewriteToolView.tsx
+++ /dev/null
@@ -1,122 +0,0 @@
-import React from "react";
-import { FileCode, FileSymlink, Replace, CheckCircle, AlertTriangle } from "lucide-react";
-import { ToolViewProps } from "./types";
-import { extractFilePath, extractFileContent, getFileType, formatTimestamp } from "./utils";
-import { GenericToolView } from "./GenericToolView";
-
-export function FileRewriteToolView({
- assistantContent,
- toolContent,
- assistantTimestamp,
- toolTimestamp,
- isSuccess = true
-}: ToolViewProps) {
- const filePath = extractFilePath(assistantContent);
- const fileContent = extractFileContent(assistantContent, 'full-file-rewrite');
-
- if (!filePath || !fileContent) {
- return (
-
-
-
-
-
-
-
-
File Rewrite
-
-
-
- {toolContent && (
-
- {isSuccess ? 'Success' : 'Failed'}
-
- )}
-
-
-
- {/* IDE Header */}
-
-
- {isMarkdown ?
- :
-
- }
- {fileName}
-
-
- {fileType}
-
-
-
- {/* File Path Bar */}
-
-
- {/* IDE Content Area */}
-
-
- {contentLines.map((line, idx) => (
-
-
- {idx + 1}
-
-
- {line || ' '}
-
-
- ))}
- {/* Add an empty line at the end */}
-
-
-
-
- {/* Status Footer */}
- {isSuccess ? (
-
-
- {fileName} rewritten successfully
-
- ) : (
-
-
-
Failed to rewrite file
-
- )}
-
-
-
- {assistantTimestamp && (
-
Called: {formatTimestamp(assistantTimestamp)}
- )}
- {toolTimestamp && (
-
Result: {formatTimestamp(toolTimestamp)}
- )}
-
-
- );
-}
\ No newline at end of file
diff --git a/frontend/src/components/thread/tool-views/utils.ts b/frontend/src/components/thread/tool-views/utils.ts
index bf1d5038..70388bf5 100644
--- a/frontend/src/components/thread/tool-views/utils.ts
+++ b/frontend/src/components/thread/tool-views/utils.ts
@@ -85,16 +85,53 @@ export function extractFilePath(content: string | undefined): string | null {
}
// Look for file_path in different formats
- const filePathMatch = content.match(/file_path=["']([\s\S]*?)["']/);
- if (filePathMatch) return filePathMatch[1];
+ const filePathMatch = content.match(/file_path=["']([\s\S]*?)["']/i) ||
+ content.match(/target_file=["']([\s\S]*?)["']/i) ||
+ content.match(/path=["']([\s\S]*?)["']/i);
+ if (filePathMatch) {
+ const path = filePathMatch[1].trim();
+ // Handle newlines and return first line if multiple lines
+ return cleanFilePath(path);
+ }
// Look for file_path in XML-like tags
- const xmlFilePathMatch = content.match(/