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

Method handlePartial

src/core/tools/EditFileTool.ts:487–525  ·  view source on GitHub ↗
(task: Task, block: ToolUse<"edit_file">)

Source from the content-addressed store, hash-verified

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
528export const editFileTool = new EditFileTool()

Callers

nothing calls this directly

Calls 3

isPathOutsideWorkspaceFunction · 0.90
getReadablePathFunction · 0.90
askMethod · 0.80

Tested by

no test coverage detected