mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 15:02:32 +00:00
Fix edit tool diff not showing in TUI
The async diff preview computation could race with tool execution, causing editDiffPreview to contain an error (file already modified) while the actual tool result had the correct diff in details.diff. Fix: prioritize result.details.diff over editDiffPreview when the tool has executed successfully. The preview is only used before tool execution completes.
This commit is contained in:
parent
746ec9eb01
commit
0f81b09625
1 changed files with 6 additions and 1 deletions
|
|
@ -479,8 +479,13 @@ export class ToolExecutionComponent extends Container {
|
|||
if (errorText) {
|
||||
text += `\n\n${theme.fg("error", errorText)}`;
|
||||
}
|
||||
} else if (this.result?.details?.diff) {
|
||||
// Tool executed successfully - use the diff from result
|
||||
// This takes priority over editDiffPreview which may have a stale error
|
||||
// due to race condition (async preview computed after file was modified)
|
||||
text += `\n\n${renderDiff(this.result.details.diff, { filePath: rawPath })}`;
|
||||
} else if (this.editDiffPreview) {
|
||||
// Use cached diff preview (works both before and after execution)
|
||||
// Use cached diff preview (before tool executes)
|
||||
if ("error" in this.editDiffPreview) {
|
||||
text += `\n\n${theme.fg("error", this.editDiffPreview.error)}`;
|
||||
} else if (this.editDiffPreview.diff) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue