✨ feat(vscode): URI 开的会话不再登记进会话管理列表
delegate-fix 等外部方通过 create-session URI 开的一次性会话, 不写入 .spx/session-names.json,也跳过 sessionId 轮询捕获; 面板内手动创建的会话仍照常登记。 Claude-Session: https://claude.ai/code/session_01Kgmb1LvrPmFX3NoUDB4zZC
This commit is contained in:
1 parent
5bfd759822
commit
b182e0ac5b
3 files changed
+13
-6
No files matched your search
@@ -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 '<profilePath>'),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
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@ async function handleCreateSessionUri(uri: Uri): Promise<void> {
|
||||
prompt,
|
||||
cwd,
|
||||
panel: null,
|
||||
register: false,
|
||||
})
|
||||
if (!created)
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user