🐛 fix(vscode): worktreePath 消费侧统一解析 ~/绝对/相对,修复带 ~ 的存量工单与绝对路径 worktree 误判

新增 resolveWorktreePath(stored, workspaceRoot) 三态合一解析:开头 ~ 展开为 home、
已是绝对原样、相对拼到 workspaceRoot。替换全部消费点,原先「判 isAbsolute 再 join」
不认 ~、issueLoader 算 worktreeExists 更是裸 join 连绝对路径都拼坏。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-24 03:01:08 +08:00
co-authored by Claude Opus 4.7
parent 9a69aeed48
commit 5e7a3d20d9
4 changed files with 28 additions and 23 deletions
+15
View File
@@ -7,6 +7,21 @@
*/
import { execFile } from 'node:child_process'
import * as os from 'node:os'
import * as path from 'node:path'
/**
* 把存储的 worktreePath 解析成可用的绝对路径。三态合一:
* 开头 `~` → 展开为 homegit/execFile 不走 shell,自己不展开 `~`
* 存量工单里可能存了带 `~` 的字面量);已是绝对 → 原样;
* 相对 → 拼到 workspaceRoot 下(旧的 .claude/worktrees/<hash> 方案)。
*/
export function resolveWorktreePath(stored: string, workspaceRoot: string): string {
let p = stored
if (p.startsWith('~'))
p = path.join(os.homedir(), p.slice(1))
return path.isAbsolute(p) ? p : path.join(workspaceRoot, p)
}
export interface WorktreeOpts {
/** Absolute path to the main workspace root. */