MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / handlePartial

Method handlePartial

src/core/tools/SearchReplaceTool.ts:242–275  ·  view source on GitHub ↗
(task: Task, block: ToolUse<"search_replace">)

Source from the content-addressed store, hash-verified

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
278export const searchReplaceTool = new SearchReplaceTool()

Callers

nothing calls this directly

Calls 3

isPathOutsideWorkspaceFunction · 0.90
getReadablePathFunction · 0.90
askMethod · 0.80

Tested by

no test coverage detected