Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion packages/desktop/src/executors/base/DiffMetadataExtractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class DiffMetadataExtractor {
return null;
}

private extractClaudeEdit(metadata: Record<string, unknown>): DiffMetadata[] | null {
private async extractClaudeEdit(metadata: Record<string, unknown>): Promise<DiffMetadata[] | null> {
const input = metadata.input as Record<string, unknown> | undefined;
if (!input) return null;

Expand All @@ -64,6 +64,23 @@ export class DiffMetadataExtractor {

if (!filePath || oldString === undefined || newString === undefined) return null;

// Read the current file content to get the full file after edit
const currentContent = await this.readFileIfExists(filePath);

// If we can read the file, the edit has been applied, so currentContent is the new full content
// We need to reconstruct the old full content by reversing the edit
if (currentContent !== null) {
// The file now contains newString where oldString used to be
// Reconstruct old content: replace newString back with oldString
const fullOldContent = currentContent.replace(newString, oldString);
return [{
filePath,
oldString: fullOldContent,
newString: currentContent,
}];
}

// Fallback: return the partial strings if file can't be read
return [{
filePath,
oldString,
Expand Down
Loading
Loading