Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/kilo-vscode/src/agent-manager/WorktreeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import * as path from "path"
import * as fs from "fs"
import { randomUUID } from "crypto"
import simpleGit, { type SimpleGit } from "simple-git"

const TEMP_PREFIX = ".kilo-delete-"
import { generateBranchName, sanitizeBranchName } from "./branch-name"
import type { GitOps } from "./GitOps"
import { execWithShellEnv } from "./shell-env"
Expand All @@ -29,6 +27,9 @@ import {
type BranchListItem,
} from "./git-import"

const TEMP_PREFIX = ".kilo-delete-"
const RM_OPTS: fs.RmOptions = { recursive: true, force: true, maxRetries: 3, retryDelay: 200 }

interface WorktreeInfo {
branch: string
path: string
Expand Down Expand Up @@ -388,7 +389,7 @@ export class WorktreeManager {
if (branch) await this.deleteBranch(branch)

// 4. Background delete — fire-and-forget, cross-platform
fs.promises.rm(temp, { recursive: true, force: true }).catch((err) => {
fs.promises.rm(temp, RM_OPTS).catch((err) => {
this.log(`Background cleanup failed for ${temp}: ${err}`)
})
}
Expand All @@ -411,7 +412,7 @@ export class WorktreeManager {
for (const e of entries) {
if (e.isDirectory() && e.name.startsWith(TEMP_PREFIX)) {
const stale = path.join(this.dir, e.name)
fs.promises.rm(stale, { recursive: true, force: true }).catch((err) => {
fs.promises.rm(stale, RM_OPTS).catch((err) => {
this.log(`Failed to clean orphaned temp dir ${stale}: ${err}`)
})
}
Expand Down
Loading