在 DSH Web 界面补全"删除会话"能力:会话顶垃圾桶按钮、侧栏"..."菜单注入删除项、Agent 工具 workbench_session_delete,删除会话日志、投影缓存与工作区记账。
- 语言
- JavaScript
- 分支
- main
安装
$ dsh plugin --profile web add github:lsz-asd/dsh-plugin-session-delete在终端中运行以上命令,通过 dsh CLI 安装此插件。可在右上角切换 Profile。 第一次用 dsh?看这篇新手教程
对话式安装
帮我安装 DeepSeek Harness 插件 lsz-asd/dsh-plugin-session-delete:先查看仓库 https://github.com/lsz-asd/dsh-plugin-session-delete 确认安全性,然后执行安装命令并验证插件加载成功。
把这段指令粘贴给 DSH Web GUI 里的助手,由它代你完成安装与验证。
一句话定位
在 DSH Web 界面补全官方缺失的"删除会话"能力:会话顶部新增垃圾桶按钮、侧栏会话行的"..."菜单里动态注入"删除会话"项,并为 Agent 暴露 workbench_session_delete 工具;点击后会弹出带勾选确认的风险对话框,确认后会从磁盘日志、投影缓存与工作区记账三个地方同步摘除该会话。
核心能力
- 会话顶部动作区新增垃圾桶按钮(注册到
conversation.session.header.actions插槽,order 30),运行中的会话会显示警告 tooltip - 侧栏会话行 "..." 菜单里注入"删除会话"项(通过 MutationObserver 监听 DOM 动态插入,标题精确/去 fork 后缀/包含三段匹配会话 id),点击不切换当前会话
- 共享删除对话框(root 级
shell.overlay):展示会话名与序列号、运行中警告、风险说明,必须勾选"我已了解后果,确认删除"才能点确认;中英文文案跟随界面语言,未加载 locale 服务时按浏览器语言回退 - Host 端暴露两条 HTTP 路由:
GET /__chameleon/session/list(列出 id / 标题 / 创建时间 / 运行状态)和POST /__chameleon/session/delete(删除指定会话) - 注册 Agent 工具
workbench_session_delete,参数为sessionId,删除后返回是否清掉了日志目录、投影缓存行、工作区记账 - 删除链路完整覆盖三种存储:磁盘日志目录
~/.dsh/sessions/<slug>/<id>/、投影缓存域session_projcache的sessions表、workspace 域的workspaces.sessionIds与全局archivedSessionIds;清理前先 flush 活动会话,先确认日志目录消失再解除工作区记账,避免半删除导致会话落入"未分组"
技术实现
- 语言: JavaScript(ESM,
"type": "module") - 关键依赖:
@deepseek-ai/dsh-tools(peer 依赖,用于defineTool注册 Agent 工具)、@deepseek-ai/dsh-client-runtime(client 端注入目标)、@deepseek-ai/dsh-client-ui-primitives(Modal、IconTrashOutline16)、node:fs/node:path/node:os(host 端清理磁盘日志) - 架构模式: 标准 DSH 双端插件 + cordis bundle 行注入。
cordis.patch.yml固定 bundle 行 idchameleon-session-delete,方便重装/补丁定向更新。src/index.js是 host 半:通过ctx.tools.register注册工具,并用ctx.webServer.register(含ctx.inject(['webServer'])兜底分支)暴露两个路由;src/client.js通过window.__ModuleLoader__.load注册 factory,按client-modules协议用React.createElement渲染两个插槽组件 + 一个全局删除对话框,并通过MutationObserver给侧栏菜单注入菜单项 - 入口文件:
src/index.js(host 入口apply)+src/client.js(client 入口apply,通过package.json#exports["."]和"./client"暴露)
适用场景
当你在 DSH Web 里跑久了会话列表越来越长、归档已经不够用,或者编辑 harness 时会话历史不同步出现了"坏掉"的会话没法下线,本插件给你一个明确的删除入口;如果你让 Agent 在编辑模式里管理会话,它也能通过 workbench_session_delete 工具自己调用,避免你手动清。
前置依赖与兼容性
| 依赖 | 最低版本 | 说明 |
|---|---|---|
| DSH | ^0.1.0-rc.6 | peer 依赖 @deepseek-ai/dsh-tools ^0.1.0-rc.6;依赖 host 服务 ctx.agents / ctx.sessions / ctx.storageDomain / ctx.webServer / ctx.tools,依赖 client 服务 slots / sessions / locale(locale 可选,缺时按浏览器语言回退) |
| Node | >= 20 | package.json#engines.node 声明 |
| 平台 | macOS / Windows / Linux | 跨平台;client 端 dsh.client.platform 显式声明 web,但 client.js 同时被 desktop shell 加载;host 端只使用 fs/path/os 等内置模块 |
| 原生模块 | 无 | host 仅依赖 node 内置 node:fs node:path node:os,无任何 native binding |
安装方式
dsh plugin --profile web add github:lsz-asd/dsh-plugin-session-delete
配置项
本插件无需额外配置。删除按钮、对话框文案、风险确认勾选、HTTP 路由路径、Agent 工具名 workbench_session_delete 均为插件内置行为,安装后即生效。
常见问题
Q: 安装后必须重启 web 才能生效吗?
A: 是的。Host 端通过 cordis bundle 行注入,需要重启 dsh web 才能加载新路由和工具;客户端模块同理,不重启 profile 不会生效。
Q: 能不能删除正在运行的会话?
A: 能,但服务端会先调用 agent.cancel({kind:'user'}) 并 await agent.whenIdle()(最长 15 秒),确认停止后才执行删除;客户端对话框会用 ⚠ 警告告知用户此操作将中断正在进行的任务。
Q: 删除不彻底、回到"未分组"是怎么修好的?
A: v0.3.1 起同时清理原始 uuid 与 session-<uuid> 两种 id 形式;先删除磁盘日志并确认成功后再解除工作区记账;删除前先 flush 活动会话,避免 dispose 阶段重建日志目录。
Q: 侧栏"..."菜单里为什么不是原生菜单项?
A: rc.6 版本的 session-row "..." 菜单(重命名/fork/归档)硬编码在 ui-workspace 中、没有任何扩展插槽,所以本插件通过 MutationObserver 监听 DOM、向菜单动态注入"删除会话"项,标签颜色与官方错误色保持一致。
Q: "删除会话"按钮在桌面客户端能用吗?
A: 能。client.js 同时被 web 平台注入(dsh.client.platform: web)和 desktop shell 加载;会话顶按钮按 sessionId 派发,DOM 注入的侧栏项按标题匹配,共享同一个删除对话框。
Q: 怎么卸载?
A: 运行 dsh plugin --profile web remove github:lsz-asd/dsh-plugin-session-delete 并重启 profile;由于 cordis bundle 行 id 固定为 chameleon-session-delete,重装/卸载都走同一行,无需手工清理。
Q: 删除一个会话会动到哪些数据?
A: 删除 ~/.dsh/sessions/<slug>/<id>/ 下的日志目录、清掉投影缓存域(storageDomain.session_projcache 的 sessions 表行)、从 workspace 域的 workspaces.sessionIds 数组和 global.archivedSessionIds 数组中摘除;删除后客户端列表立刻刷新,无需手动刷新页面。
Q: 会话 ID 校验严格吗?
A: 严格。Host 端只接受符合 (session-)?<uuid> 正则的 ID,否则返回 400 invalid session id;侧栏点击时按客户端 list store 做精确 / 去 fork 后缀 / 包含三段匹配,未命中会回退到 /__chameleon/session/list 再找一次,仍找不到则弹出"未找到会话"提示。
上手难度
入门 — 安装一行命令即可,没有配置项,UI 直接在会话顶部和侧栏菜单里出现,点击即用。
已知问题与限制
- 侧栏菜单项是 DOM 注入而非官方插槽:rc.6 的 session-row "..." 菜单硬编码在 ui-workspace 中,本插件用 MutationObserver 监听
[role=menu]元素并向打开的菜单追加按钮;官方若在后续版本调整菜单结构或样式,需要相应更新匹配逻辑(src/client.js:447-451) - 会话 ID 仅接受 UUID 格式(含可选的
session-前缀),自定义格式的会话 ID 会被 400 拒绝(src/index.js:33) - 删除运行中会话的最长等待时间固定 15 秒(
agent.whenIdle+setTimeout);若 Agent 任务陷入死循环,仍可能超时失败,需要二次删除(src/index.js:165-182) - 客户端默认走
locale服务拿中英文文案;当 profile 没有加载 locale 服务时,仅靠浏览器语言嗅探(navigator.languages),其他语言环境会回退到中文(src/client.js:170-178) - 删除日志目录的清理路径是
process.env.DSH_HOME || ~/.dsh/sessions/;若用户自定义DSH_HOME但客户端仍按默认 home 查询,可能与服务端检索不一致(src/index.js:44-46)
你是否困扰于 web 端无法删除对话?是否觉得归档对话键只是隐藏对话,删除得不够彻底?是否在尝试编辑 harness 时遇到对话话历史无法同步,而损坏的对话又无法删除?这个插件可以帮你!
在 DeepSeek Harness 界面里安全地彻底删除会话。 在会话顶部添加垃圾桶按钮,侧栏会话行 "..." 菜单内添加"删除会话"项,点击后出现风险确认弹窗(需勾选);确认后会删除会话日志、投影缓存与工作区记账;运行中的会话会有提示,若仍选择删除会停止运行并删除。可在web中使用,并且理论上兼容一切web套壳的客户端。
添加agent工具让agent可以删除会话。 工具名workbench_session_delete
安装
dsh plugin --profile <profile> add file:C:/path/to/dsh-plugin-session-delete
重启 profile 生效。
功能
- 会话头部垃圾桶按钮
- 侧栏会话行 "..." 菜单注入"删除会话"项
RiskConfirmation风险确认:勾选"我已了解后果"后确认可用- 删除链路:会话目录 + 投影缓存 + 工作区记账(经活动 storageDomain,内存/磁盘一致)
workbench_session_delete工具:agent 可直接删除会话
后续开发计划
- 添加更多针对会话的操作工具和选项
- 将已有的针对会话的选项做成工具提供给agent
更新日志
- v0.3.1(2026-08-14):修复删除会话后残留日志导致会话跑到「未分组」的问题。删除时同时清理原始 id 与
session-前缀两种 id 形式;先删除磁盘日志并确认成功后再解除工作区记账,避免半删除会话脱离原分组;删除前先 flush 活动会话,防止 dispose 阶段回写/重建日志目录。 - v0.3.0(2026-08-14):新增英文适配(i18n)。删除对话框、头部垃圾桶按钮与侧栏「删除会话」菜单项的全部文案接入客户端 zh/en 字典,跟随界面语言(设置中的语言或浏览器语言)自动切换并即时生效;未加载 locale 服务的环境会按浏览器语言回退到内置中英文字典。
dsh-plugin-session-delete
Frustrated that sessions can't be deleted from the web client? Bothered by abandoned or mistyped conversations cluttering your sidebar? Ever tried editing your harness only to find the session history out of sync — with a corrupted session that just won't go away? This plugin has your back!
Safely delete sessions from the DeepSeek Harness UI. Adds a trash button at the top of the conversation and a "Delete session" item to the sidebar session-row "..." menu; clicking either opens a risk-consent dialog (checkbox required). On confirm, the session log, projection cache and workspace accounting are removed. Running sessions show a warning — if you still choose to delete, the session is stopped and then deleted. Works in the web, and is theoretically compatible with any web-shell-based client.
Also adds an agent tool so agents can delete sessions. Tool name: workbench_session_delete
Installation
dsh plugin --profile <profile> add file:C:/path/to/dsh-plugin-session-delete
Restart the profile to apply.
Features
- Trash button at the top of the conversation
- "Delete session" item injected into the sidebar session-row "..." menu
RiskConfirmationrisk-consent dialog: confirm is only enabled after ticking "I understand the consequences"- Delete chain: session log + projection cache + workspace accounting (through the active storageDomain, so in-memory state and on-disk units stay consistent)
workbench_session_deletetool: agents can delete sessions directly
Roadmap
- Add more session-operation tools and options
- Expose the existing session options to agents as tools
Changelog
- v0.3.1 (2026-08-14): Fixed deleted sessions being left as "Ungrouped" rows after a partial delete. The host now cleans both raw UUID and
session--prefixed id forms, deletes the on-disk log and confirms it before removing workspace accounting (so a failed delete cannot detach a session from its group), and flushes a live session before detaching it to prevent dispose-time rewrites from recreating the log directory. - v0.3.0 (2026-08-14): Added English adaptation (i18n). All copy of the delete dialog, the header trash button and the sidebar "Delete session" menu item now lives in client zh/en dictionaries and follows the UI language (the language setting or the browser language), updating live on switch; environments without the locale service fall back to the built-in dictionaries by browser language.
查看使用指南 →
该插件的安装步骤、关键要点、FAQ 与兼容性说明(基于已收录字段派生)。
收录徽章
[](https://deepseek-plugin.org/plugins/lsz-asd/dsh-plugin-session-delete)把这段 markdown 粘贴到你的 GitHub README,链接回本插件详情页。徽章只声明已被本站收录,不代表安全认证。