🐛 fix(vscode): resume 会话用 resolveWorktreePath 避免误判 worktree 已清理

This commit is contained in:
2026-07-16 01:51:08 +08:00
parent aff4ee2758
commit b45257a38d
2 changed files with 25 additions and 4 deletions
+4 -3
View File
@@ -84,15 +84,16 @@ export async function handleResumeSession(panel: KanbanWebviewPanel, sessionId:
return
}
const workspaceRoot = workspace.workspaceFolders?.[0]?.uri.fsPath
// Implementation sessions live in a worktree; the caller can pass a
// workspace-relative `relCwd` so `--resume` runs from the right place.
// Implementation sessions live in a worktree; `relCwd` may be absolute /
// `~/...` / workspace-relative — must go through resolveWorktreePath
// (path.join(workspaceRoot, abs) would mangle absolute paths).
// If the worktree has since been cleaned up (typical: drop card to
// "完成" → auto `git worktree remove`), fall back to the workspace
// root instead of pointing the terminal at a missing directory.
let effectiveCwd: string | undefined = workspaceRoot
let cwdFallback = false
if (relCwd && workspaceRoot) {
const resolved = path.join(workspaceRoot, relCwd)
const resolved = resolveWorktreePath(relCwd, workspaceRoot)
if (fs.existsSync(resolved)) {
effectiveCwd = resolved
}