✨ feat(vscode): 会话管理支持导入已 /rename 的命名会话
This commit is contained in:
@@ -4,6 +4,7 @@ import { window, workspace } from 'vscode'
|
||||
import { buildCcCommand } from '../../cc/ccCommand'
|
||||
import { pollForNewSession, projectsDirFor } from '../../cc/sessionWatcher'
|
||||
import { logger } from '../../logging/logger'
|
||||
import { listImportableNamedSessions } from '../../sessions/importableNamedSessions'
|
||||
import { readManagedSessions, writeManagedSessions } from '../../sessions/managedStore'
|
||||
import { resolveProfilePath } from '../../cc/profiles'
|
||||
|
||||
@@ -270,3 +271,48 @@ export async function handleManagedSessionsDelete(panel: KanbanWebviewPanel, ses
|
||||
panel.managedTerminals.delete(sessionId)
|
||||
await pushManagedSessions(panel)
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出当前工作区可导入的命名会话(jsonl 有 custom-title 且尚未在 managed store)。
|
||||
*/
|
||||
export async function handleManagedSessionsListImportable(panel: KanbanWebviewPanel): Promise<void> {
|
||||
const workspaceRoot = workspace.workspaceFolders?.[0]?.uri.fsPath
|
||||
if (!workspaceRoot) {
|
||||
panel.postMessage({ type: 'managed-sessions/importable', sessions: [] })
|
||||
return
|
||||
}
|
||||
const sessions = await listImportableNamedSessions(workspaceRoot)
|
||||
panel.postMessage({ type: 'managed-sessions/importable', sessions })
|
||||
}
|
||||
|
||||
/**
|
||||
* 把已 /rename 的会话登记进 managed store(不写 profilePath、不 resume)。
|
||||
* id 已存在时幂等,仍推送全量列表。
|
||||
*/
|
||||
export async function handleManagedSessionsImport(
|
||||
panel: KanbanWebviewPanel,
|
||||
sessionId: string,
|
||||
name: string,
|
||||
): Promise<void> {
|
||||
const workspaceRoot = workspace.workspaceFolders?.[0]?.uri.fsPath
|
||||
if (!workspaceRoot) {
|
||||
void window.showErrorMessage('请先打开一个工作区文件夹')
|
||||
return
|
||||
}
|
||||
const trimmedId = sessionId.trim()
|
||||
const trimmedName = name.trim()
|
||||
if (!trimmedId || !trimmedName)
|
||||
return
|
||||
|
||||
const data = await readManagedSessions(workspaceRoot)
|
||||
const existing = data.sessions.find(s => s.id === trimmedId)
|
||||
if (!existing) {
|
||||
data.sessions.push({
|
||||
id: trimmedId,
|
||||
name: trimmedName,
|
||||
createdAt: Date.now(),
|
||||
})
|
||||
await writeManagedSessions(workspaceRoot, data)
|
||||
}
|
||||
await pushManagedSessions(panel)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user