(task: Task, block: ToolUse<"edit_file">)
| 485 | } |
| 486 | |
| 487 | override async handlePartial(task: Task, block: ToolUse<"edit_file">): Promise<void> { |
| 488 | const filePath: string | undefined = block.params.file_path |
| 489 | const oldString: string | undefined = block.params.old_string |
| 490 | |
| 491 | // Wait for path to stabilize before showing UI (prevents truncated paths) |
| 492 | if (!this.hasPathStabilized(filePath)) { |
| 493 | return |
| 494 | } |
| 495 | |
| 496 | let operationPreview: string | undefined |
| 497 | if (oldString !== undefined) { |
| 498 | if (oldString === "") { |
| 499 | operationPreview = "creating new file" |
| 500 | } else { |
| 501 | const preview = oldString.length > 50 ? oldString.substring(0, 50) + "..." : oldString |
| 502 | operationPreview = `replacing: "${preview}"` |
| 503 | } |
| 504 | } |
| 505 | |
| 506 | // Determine relative path for display (filePath is guaranteed non-null after hasPathStabilized) |
| 507 | let relPath = filePath! |
| 508 | if (path.isAbsolute(relPath)) { |
| 509 | relPath = path.relative(task.cwd, relPath) |
| 510 | } |
| 511 | this.didSendPartialToolAsk = true |
| 512 | this.partialToolAskRelPath = relPath |
| 513 | |
| 514 | const absolutePath = path.resolve(task.cwd, relPath) |
| 515 | const isOutsideWorkspace = isPathOutsideWorkspace(absolutePath) |
| 516 | |
| 517 | const sharedMessageProps: ClineSayTool = { |
| 518 | tool: "appliedDiff", |
| 519 | path: getReadablePath(task.cwd, relPath), |
| 520 | diff: operationPreview, |
| 521 | isOutsideWorkspace, |
| 522 | } |
| 523 | |
| 524 | await task.ask("tool", JSON.stringify(sharedMessageProps), block.partial).catch(() => {}) |
| 525 | } |
| 526 | } |
| 527 | |
| 528 | export const editFileTool = new EditFileTool() |
nothing calls this directly
no test coverage detected