From 38f15a6fe1d73c1262f2f6e6dc0c65953c81ddca Mon Sep 17 00:00:00 2001 From: cruldra Date: Thu, 9 Jul 2026 08:17:23 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(vscode):=20resume=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BC=9A=E8=AF=9D=E6=97=B6=E6=8C=89=20testPr?= =?UTF-8?q?ofilePath=20=E8=A7=A3=E6=9E=90=20settings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vscode/src/panel/handlers/sessions.ts | 30 ++++++++++++++++----------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/vscode/src/panel/handlers/sessions.ts b/vscode/src/panel/handlers/sessions.ts index efb2a14..63b7198 100644 --- a/vscode/src/panel/handlers/sessions.ts +++ b/vscode/src/panel/handlers/sessions.ts @@ -1270,6 +1270,7 @@ export async function handleStartTestSession(panel: KanbanWebviewPanel, issueNum * `issue-${N}-测试`、命令 `claude ... --resume ${sessionId}`。 * * cwd 优先用 worktree(relCwd 存在且在磁盘上),否则退回 workspaceRoot。 + * profile 与 start 对称:resolveTestProfilePath(testProfilePath > profilePath > 默认)。 * in-flight 锁 key `${issueNumber}:test`。 */ export async function handleResumeTestSession(panel: KanbanWebviewPanel, sessionId: string, issueNumber: number, _relCwd?: string): Promise { @@ -1285,23 +1286,15 @@ export async function handleResumeTestSession(panel: KanbanWebviewPanel, session panel.resumeInFlight.add(lockKey) try { - // 与实施会话不同,profile 不影响 --resume(claude 从 jsonl 重建会话), - // 但仍用实施 profile 保持一致。 - const effectiveProfilePath = panel.resolveImplementProfilePath(undefined) - if (effectiveProfilePath.includes('\'')) { - void window.showErrorMessage( - `resume 失败:profilePath 含单引号,拒绝执行 (${effectiveProfilePath})`, - ) - return - } - // claude 的 session jsonl 落在「cwd 派生的 projects 目录」下:start 时进了 worktree, // resume 也必须在 worktree 才找得到这条会话;worktree 已清理才回退主 worktree(main)。 + // cwd / profile / branch 同一次 readIssueState 读完,避免多发请求。 const workspaceRoot = workspace.workspaceFolders?.[0]?.uri.fsPath let effectiveCwd = workspaceRoot - // 顺带读出 branch 给 impl-tab-pre-create 钩子用,避免下面再发一轮 - // detectRepo/getToken/readIssueState 请求;读不到就空字符串。 + // 顺带读出 branch 给 impl-tab-pre-create 钩子用;读不到就空字符串。 let branchForHook = '' + let profilePath: string | undefined + let testProfilePath: string | undefined if (workspaceRoot) { const remote = await detectRepo(workspaceRoot) 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 if (stateObj && typeof stateObj.branch === 'string') 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) } 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 existingByName = panel.findExistingTerminal(terminalName) if (existingByName) {