fix(agent-manager): clean busySessions in forget and call before worktree removal

This commit is contained in:
marius-kilocode
2026-07-07 13:42:43 +02:00
parent 19a4a4f191
commit 04b7ef1a47
2 changed files with 7 additions and 3 deletions
@@ -1110,8 +1110,8 @@ export class AgentManagerProvider implements Disposable {
return null
}
const orphaned = state.removeWorktree(worktreeId)
this.naming.forget(worktreeId)
const orphaned = state.removeWorktree(worktreeId)
if (this.diffs.shouldStopForWorktree(worktree.path, orphaned)) {
this.diffs.stop()
}
@@ -124,9 +124,13 @@ export class BranchNamingController {
}
/** Drop in-memory bookkeeping for a worktree whose arming ended without a
* rename (worktree removed, session moved/deleted). Safe to call for any
* id; no-ops when nothing is held. */
* rename (worktree removed, session moved/deleted). Also clears the armed
* session from the busy set. Call before the worktree is removed from state
* so the session is still resolvable. Safe to call for any id; no-ops when
* nothing is held. */
forget(id: string): void {
const worktree = this.deps.state()?.getWorktree(id)
if (worktree?.autoNameSessionId) this.busySessions.delete(worktree.autoNameSessionId)
this.pending.delete(id)
this.model.delete(id)
this.idleAttempted.delete(id)