(task: Task, block: ToolUse<"search_replace">)
| 240 | } |
| 241 | |
| 242 | override async handlePartial(task: Task, block: ToolUse<"search_replace">): Promise<void> { |
| 243 | const filePath: string | undefined = block.params.file_path |
| 244 | const oldString: string | undefined = block.params.old_string |
| 245 | |
| 246 | // Wait for path to stabilize before showing UI (prevents truncated paths) |
| 247 | if (!this.hasPathStabilized(filePath)) { |
| 248 | return |
| 249 | } |
| 250 | |
| 251 | let operationPreview: string | undefined |
| 252 | if (oldString) { |
| 253 | // Show a preview of what will be replaced |
| 254 | const preview = oldString.length > 50 ? oldString.substring(0, 50) + "..." : oldString |
| 255 | operationPreview = `replacing: "${preview}"` |
| 256 | } |
| 257 | |
| 258 | // Determine relative path for display (filePath is guaranteed non-null after hasPathStabilized) |
| 259 | let relPath = filePath! |
| 260 | if (path.isAbsolute(relPath)) { |
| 261 | relPath = path.relative(task.cwd, relPath) |
| 262 | } |
| 263 | |
| 264 | const absolutePath = path.resolve(task.cwd, relPath) |
| 265 | const isOutsideWorkspace = isPathOutsideWorkspace(absolutePath) |
| 266 | |
| 267 | const sharedMessageProps: ClineSayTool = { |
| 268 | tool: "appliedDiff", |
| 269 | path: getReadablePath(task.cwd, relPath), |
| 270 | diff: operationPreview, |
| 271 | isOutsideWorkspace, |
| 272 | } |
| 273 | |
| 274 | await task.ask("tool", JSON.stringify(sharedMessageProps), block.partial).catch(() => {}) |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | export const searchReplaceTool = new SearchReplaceTool() |
nothing calls this directly
no test coverage detected