From b182e0ac5b9cf3f281dfc5f0c41dda7ef6ff4751 Mon Sep 17 00:00:00 2001 From: cruldra Date: Sun, 13 Sep 2026 10:07:30 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(vscode):=20URI=20=E5=BC=80?= =?UTF-8?q?=E7=9A=84=E4=BC=9A=E8=AF=9D=E4=B8=8D=E5=86=8D=E7=99=BB=E8=AE=B0?= =?UTF-8?q?=E8=BF=9B=E4=BC=9A=E8=AF=9D=E7=AE=A1=E7=90=86=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit delegate-fix 等外部方通过 create-session URI 开的一次性会话, 不写入 .spx/session-names.json,也跳过 sessionId 轮询捕获; 面板内手动创建的会话仍照常登记。 Claude-Session: https://claude.ai/code/session_01Kgmb1LvrPmFX3NoUDB4zZC --- vscode/package.json | 2 +- vscode/src/panel/handlers/managedSessions.ts | 16 +++++++++++----- vscode/src/uri/createSessionUriHandler.ts | 1 + 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/vscode/package.json b/vscode/package.json index f78fbc7..a02f446 100644 --- a/vscode/package.json +++ b/vscode/package.json @@ -2,7 +2,7 @@ "publisher": "clurdra", "name": "superpowers-vscode-clurdra", "displayName": "Superpowers-clurdra", - "version": "0.2.131", + "version": "0.2.132", "packageManager": "pnpm@10.27.0", "description": "Superpowers specs and plans Kanban explorer", "author": "clurdra", diff --git a/vscode/src/panel/handlers/managedSessions.ts b/vscode/src/panel/handlers/managedSessions.ts index 7aaef77..f71297c 100644 --- a/vscode/src/panel/handlers/managedSessions.ts +++ b/vscode/src/panel/handlers/managedSessions.ts @@ -65,14 +65,17 @@ export interface CreateCcSessionTabOptions { cwd?: string /** 有 panel 时登记存活终端并推全量列表;panel 外触发(如 URI handler)传 null。 */ panel: KanbanWebviewPanel | null + /** 是否把会话登记进 managed store(会话管理列表);委派类一次性会话传 false。 */ + register: boolean } /** - * 创建 cc 会话终端 tab 并登记 managed store(核心逻辑,不要求 panel): + * 创建 cc 会话终端 tab(核心逻辑,不要求 panel): * - 启动命令统一由 buildCcCommand 构建(claude --dangerously-skip-permissions * --settings ''),prompt 非空时作为位置参数传入。 - * - 用 pollForNewSession 捕获新 sessionId(共享 projects 目录用轮询更可靠), + * - register 为 true 时用 pollForNewSession 捕获新 sessionId(共享 projects 目录用轮询更可靠), * 落进 workspaceRoot 的 .spx/session-names.json;有 panel 时再登记终端并推全量列表。 + * - register 为 false 时只开终端,不落 store、不进会话管理列表。 * * 校验失败时 showErrorMessage 并返回 undefined;成功返回终端名。 */ @@ -120,7 +123,10 @@ export async function createCcSessionTab(opts: CreateCcSessionTabOptions): Promi } // managed 会话的 projects 目录是繁忙共享目录,fs.watch 会漏 rename;改用轮询 diff。 - const watchPromise = pollForNewSession({ projectsDir: projDir, timeoutMs: 120_000 }) + // 不登记的会话无需捕获 sessionId,省掉这趟轮询。 + const watchPromise = opts.register + ? pollForNewSession({ projectsDir: projDir, timeoutMs: 120_000 }) + : null // 终端名:用户填了会话名字就用它,否则用默认 cc-会话。 // (VS Code 终端创建后不能改名,所以只在 createTerminal 时设定。) @@ -140,7 +146,7 @@ export async function createCcSessionTab(opts: CreateCcSessionTabOptions): Promi terminal.sendText(cmd) // Fire-and-forget:会话 jsonl 出现后写进 store;有 panel 再登记终端并推全量列表。 - watchPromise.then(async (sid) => { + watchPromise?.then(async (sid) => { if (!sid) { logger.add({ level: 'warn', @@ -191,7 +197,7 @@ export async function handleManagedSessionsCreate(panel: KanbanWebviewPanel, pro return } - const created = await createCcSessionTab({ workspaceRoot, profilePath, name, prompt, panel }) + const created = await createCcSessionTab({ workspaceRoot, profilePath, name, prompt, panel, register: true }) if (!created) return diff --git a/vscode/src/uri/createSessionUriHandler.ts b/vscode/src/uri/createSessionUriHandler.ts index 6eb2024..8c0f233 100644 --- a/vscode/src/uri/createSessionUriHandler.ts +++ b/vscode/src/uri/createSessionUriHandler.ts @@ -81,6 +81,7 @@ async function handleCreateSessionUri(uri: Uri): Promise { prompt, cwd, panel: null, + register: false, }) if (!created) return