dsh: 工作区注册 —— 邮件会话挂进 DSH GUI 的项目分组
ctx.get('workspaceRegistry') 可选注入:workspaceRegistry 不存在时
(非 GUI 模式/headless profile)跳过,不影响会话功能。
create(cwd) 先注册目录,attachSession(sessionId) 再绑定会话。
失败只影响 GUI 分组,不影响邮件收发。
顺带清掉上一个 commit 里的重复代码块。
This commit is contained in:
@ -624,6 +624,29 @@ export function apply(ctx: any, config: PluginConfig): void {
|
||||
});
|
||||
}
|
||||
|
||||
// 把会话挂进工作区注册表 —— 这是让 DSH GUI 把它从「未分组」挪进对应项目
|
||||
// 的唯一路径。不挂的后果:会话永远落在 Ungrouped,人类在侧栏看不到它
|
||||
// 与项目的从属关系,也无法用 DSH 的工作区级操作(批量归档、重命名等)。
|
||||
//
|
||||
// 失败不可怕:会话本身已经能用了,只是 GUI 分组不对。最常见失败是
|
||||
// 邮件里的 cwd 在 DSH 主机上不存在(跨主机场景),此时 mkdirSync
|
||||
// 建不出目录,workspaceRegistry.create 也报错。
|
||||
if (cwd && handle) {
|
||||
try {
|
||||
const wr: any = (ctx as any).get?.('workspaceRegistry');
|
||||
if (wr?.create) {
|
||||
const ws = await wr.create(cwd, cwd.split('/').pop() || cwd);
|
||||
if (ws?.attachSession) {
|
||||
await ws.attachSession(attemptSessionId as any);
|
||||
}
|
||||
}
|
||||
} catch (e: any) {
|
||||
// 工作区注册失败不影响会话功能:只有 GUI 分组会受影响。
|
||||
// 日志用 console.error 才进 journalctl(ctx.logger 不进)。
|
||||
console.error(`[dsh-mail-bridge] 工作区注册失败(不影响功能): ${e?.message || e}`);
|
||||
}
|
||||
}
|
||||
|
||||
const watching = awaitFirstTurn(handle.agent);
|
||||
handle.agent.followup(userMessage(promptText));
|
||||
const outcome = await watching;
|
||||
|
||||
Reference in New Issue
Block a user