🐛 fix(vscode): resume 测试会话时按 testProfilePath 解析 settings

This commit is contained in:
2026-07-09 08:17:23 +08:00
parent f39e61aa7f
commit 38f15a6fe1
+18 -12
View File
@@ -1270,6 +1270,7 @@ export async function handleStartTestSession(panel: KanbanWebviewPanel, issueNum
* `issue-${N}-测试`、命令 `claude ... --resume ${sessionId}`。 * `issue-${N}-测试`、命令 `claude ... --resume ${sessionId}`。
* *
* cwd 优先用 worktreerelCwd 存在且在磁盘上),否则退回 workspaceRoot。 * cwd 优先用 worktreerelCwd 存在且在磁盘上),否则退回 workspaceRoot。
* profile 与 start 对称:resolveTestProfilePathtestProfilePath > profilePath > 默认)。
* in-flight 锁 key `${issueNumber}:test`。 * in-flight 锁 key `${issueNumber}:test`。
*/ */
export async function handleResumeTestSession(panel: KanbanWebviewPanel, sessionId: string, issueNumber: number, _relCwd?: string): Promise<void> { export async function handleResumeTestSession(panel: KanbanWebviewPanel, sessionId: string, issueNumber: number, _relCwd?: string): Promise<void> {
@@ -1285,23 +1286,15 @@ export async function handleResumeTestSession(panel: KanbanWebviewPanel, session
panel.resumeInFlight.add(lockKey) panel.resumeInFlight.add(lockKey)
try { try {
// 与实施会话不同,profile 不影响 --resumeclaude 从 jsonl 重建会话),
// 但仍用实施 profile 保持一致。
const effectiveProfilePath = panel.resolveImplementProfilePath(undefined)
if (effectiveProfilePath.includes('\'')) {
void window.showErrorMessage(
`resume 失败:profilePath 含单引号,拒绝执行 (${effectiveProfilePath})`,
)
return
}
// claude 的 session jsonl 落在「cwd 派生的 projects 目录」下:start 时进了 worktree // claude 的 session jsonl 落在「cwd 派生的 projects 目录」下:start 时进了 worktree
// resume 也必须在 worktree 才找得到这条会话;worktree 已清理才回退主 worktreemain)。 // resume 也必须在 worktree 才找得到这条会话;worktree 已清理才回退主 worktreemain)。
// cwd / profile / branch 同一次 readIssueState 读完,避免多发请求。
const workspaceRoot = workspace.workspaceFolders?.[0]?.uri.fsPath const workspaceRoot = workspace.workspaceFolders?.[0]?.uri.fsPath
let effectiveCwd = workspaceRoot let effectiveCwd = workspaceRoot
// 顺带读出 branch 给 impl-tab-pre-create 钩子用,避免下面再发一轮 // 顺带读出 branch 给 impl-tab-pre-create 钩子用;读不到就空字符串。
// detectRepo/getToken/readIssueState 请求;读不到就空字符串。
let branchForHook = '' let branchForHook = ''
let profilePath: string | undefined
let testProfilePath: string | undefined
if (workspaceRoot) { if (workspaceRoot) {
const remote = await detectRepo(workspaceRoot) const remote = await detectRepo(workspaceRoot)
const token = remote ? await getToken(panel.context, remote.host) : undefined const token = remote ? await getToken(panel.context, remote.host) : undefined
@@ -1311,6 +1304,10 @@ export async function handleResumeTestSession(panel: KanbanWebviewPanel, session
const worktreePathRel = typeof stateObj?.worktreePath === 'string' ? stateObj.worktreePath : undefined const worktreePathRel = typeof stateObj?.worktreePath === 'string' ? stateObj.worktreePath : undefined
if (stateObj && typeof stateObj.branch === 'string') if (stateObj && typeof stateObj.branch === 'string')
branchForHook = stateObj.branch branchForHook = stateObj.branch
if (typeof stateObj?.profilePath === 'string' && stateObj.profilePath.length > 0)
profilePath = stateObj.profilePath
if (typeof stateObj?.testProfilePath === 'string' && stateObj.testProfilePath.length > 0)
testProfilePath = stateObj.testProfilePath
effectiveCwd = await resolveTestSessionCwd(workspaceRoot, worktreePathRel) effectiveCwd = await resolveTestSessionCwd(workspaceRoot, worktreePathRel)
} }
catch (err) { catch (err) {
@@ -1324,6 +1321,15 @@ export async function handleResumeTestSession(panel: KanbanWebviewPanel, session
} }
} }
// --settings 决定 provider/model/鉴权,resume 也必须与 start 一致解析 profile。
const effectiveProfilePath = resolveTestProfilePath(panel, testProfilePath, profilePath)
if (effectiveProfilePath.includes('\'')) {
void window.showErrorMessage(
`resume 失败:profilePath 含单引号,拒绝执行 (${effectiveProfilePath})`,
)
return
}
const terminalName = `issue-${issueNumber}-测试` const terminalName = `issue-${issueNumber}-测试`
const existingByName = panel.findExistingTerminal(terminalName) const existingByName = panel.findExistingTerminal(terminalName)
if (existingByName) { if (existingByName) {