Skip to content

Commit e1a149c

Browse files
committed
fix(apply-patch): fallback to cwd basename for partial preview path
1 parent d172b5e commit e1a149c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/core/tools/ApplyPatchTool.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,10 @@ export class ApplyPatchTool extends BaseTool<"apply_patch"> {
452452
override async handlePartial(task: Task, block: ToolUse<"apply_patch">): Promise<void> {
453453
const patch: string | undefined = block.params.patch
454454
const candidateRelPath = this.extractFirstPathFromPatch(patch)
455-
const fallbackRelPath = ""
456-
const resolvedRelPath = candidateRelPath ?? fallbackRelPath
455+
const fallbackDisplayPath = path.basename(task.cwd) || "workspace"
456+
const resolvedRelPath = candidateRelPath ?? ""
457457
const absolutePath = path.resolve(task.cwd, resolvedRelPath)
458+
const displayPath = candidateRelPath ? getReadablePath(task.cwd, candidateRelPath) : fallbackDisplayPath
458459

459460
let patchPreview: string | undefined
460461
if (patch) {
@@ -465,7 +466,7 @@ export class ApplyPatchTool extends BaseTool<"apply_patch"> {
465466

466467
const sharedMessageProps: ClineSayTool = {
467468
tool: "appliedDiff",
468-
path: getReadablePath(task.cwd, resolvedRelPath),
469+
path: displayPath,
469470
diff: patchPreview || "Parsing patch...",
470471
isOutsideWorkspace: isPathOutsideWorkspace(absolutePath),
471472
}

0 commit comments

Comments
 (0)