From e9543d37ce70bd8c7c617be384b1452dcfd35d35 Mon Sep 17 00:00:00 2001 From: cruldra Date: Sat, 25 Jul 2026 01:59:22 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(vscode):=20=E5=AF=BC?= =?UTF-8?q?=E5=85=A5/=E6=81=A2=E5=A4=8D=E4=BC=9A=E8=AF=9D=E6=97=B6?= =?UTF-8?q?=E4=BB=8E=20transcript=20=E6=8E=A8=E6=96=AD=20profilePath?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vscode/src/panel/handlers/managedSessions.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/vscode/src/panel/handlers/managedSessions.ts b/vscode/src/panel/handlers/managedSessions.ts index db5ca68..74bfa75 100644 --- a/vscode/src/panel/handlers/managedSessions.ts +++ b/vscode/src/panel/handlers/managedSessions.ts @@ -6,6 +6,7 @@ import { pollForNewSession, projectsDirFor } from '../../cc/sessionWatcher' import { logger } from '../../logging/logger' import { listImportableNamedSessions } from '../../sessions/importableNamedSessions' import { readManagedSessions, writeManagedSessions } from '../../sessions/managedStore' +import { inferProfilePathForSession } from '../../sessions/sessionProfileInference' import { resolveProfilePath } from '../../cc/profiles' /** 默认会话名:有 prompt 取前 20 字符,否则用短 id(前 8 位)。 */ @@ -221,8 +222,18 @@ export async function handleManagedSessionsResume(panel: KanbanWebviewPanel, ses const data = await readManagedSessions(workspaceRoot) const target = data.sessions.find(s => s.id === sessionId) + // store 缺 profilePath 时从 transcript 推断并回写,避免 resume 落到 default profile。 + let storedProfile = target?.profilePath + if ((!storedProfile || storedProfile.trim() === '') && target) { + const inferred = await inferProfilePathForSession(sessionId, projectsDirFor(workspaceRoot)) + if (inferred) { + storedProfile = inferred + target.profilePath = inferred + await writeManagedSessions(workspaceRoot, data) + } + } const effectiveProfilePath = resolveProfilePath( - target?.profilePath && target.profilePath.trim() !== '' ? target.profilePath : undefined, + storedProfile && storedProfile.trim() !== '' ? storedProfile : undefined, ) if (effectiveProfilePath.includes('\'')) { void window.showErrorMessage( @@ -286,7 +297,7 @@ export async function handleManagedSessionsListImportable(panel: KanbanWebviewPa } /** - * 把已 /rename 的会话登记进 managed store(不写 profilePath、不 resume)。 + * 把已 /rename 的会话登记进 managed store(推断成功时写 profilePath,不 resume)。 * id 已存在时幂等,仍推送全量列表。 */ export async function handleManagedSessionsImport( @@ -307,10 +318,12 @@ export async function handleManagedSessionsImport( const data = await readManagedSessions(workspaceRoot) const existing = data.sessions.find(s => s.id === trimmedId) if (!existing) { + const inferred = await inferProfilePathForSession(trimmedId, projectsDirFor(workspaceRoot)) data.sessions.push({ id: trimmedId, name: trimmedName, createdAt: Date.now(), + ...(inferred ? { profilePath: inferred } : {}), }) await writeManagedSessions(workspaceRoot, data) }