Adds a one-click delete-session row to the DSH sidebar session menu: moves the session log and its per-conversation .dsh-sessions artifact directory to the Windows Recycle Bin, with no confirmation dialog.
Install
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:zenghang25/dsh-session-delete
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
This plugin publishes its README in Chinese only.
给 DSH(DeepSeek Harness)侧栏补上删除单个会话:会话行「⋯」菜单的最后一项是红色 「删除会话」,点击后直接删除,不弹确认框,并立刻从侧栏消失。
同时给每个对话建立独立的产出目录(.dsh-sessions/<session-id>/),删除对话时连同
它产生的文件一起删除。
适用于 DSH 0.2.1-rc.2(Web / Desktop profile,主要面向 Windows 桌面端)。
功能
| 入口 | 菜单项 | 行为 |
|---|---|---|
会话行 ⋯ 菜单(末位,分隔线 + 红色危险样式) |
删除会话 | 一键删除该会话,无确认弹窗;日志与产出目录进 Windows 回收站,可还原 |
一次点击处理以下内容:
| 内容 | 去向 |
|---|---|
| 会话日志(含子代理子会话) | Windows 回收站(~/.dsh/sessions/<项目>/<session-id>/ 可还原) |
| 该对话的产出目录 | Windows 回收站(<会话工作目录>/.dsh-sessions/<session-id>/ 可还原) |
| 投影缓存 | 永久删除(可再生缓存,~/.dsh/storages/session_projcache/sessions/<session-id>.json) |
| 工作区账目 / 置顶 / 归档集合 | detachSession、unpinSession、unarchiveSession |
回收站还原:删完后打开 Windows 回收站,找到名为该会话 id 的目录 → 还原。 日志回到原路径后,去 DSH 的「已归档」/「未分组」里点「取消归档」或重新打开即可。 投影缓存不会进回收站(它只是缓存,会重新生成);非 Windows 平台回退为永久删除并记录警告。
运行中的会话会先被安全停止:写归档集合(agent/pre-step 门禁)→ sessions.flush
持久化屏障 → 短暂等待 live 会话关闭视图 → 然后无条件继续删除。
不会因为「会话仍处于打开状态」而拒绝删除(0.4.1 起;旧版会误报 409 active)。
删除是幂等的:只有投影缓存残留的幽灵会话、甚至完全不存在的 id,都返回成功而不是
missing;物理删除失败时会回滚归档,让会话恢复可见而不是灰着不放。
删除完成后,如果该会话仍 live 在宿主内存里(只存在于内存、没落到磁盘的会话, 或视图还没释放的会话),插件会保持归档隐藏而不是取消归档 —— 否则宿主的 session 列表会让它重新出现在侧栏(典型表现:删掉后「未分组」又冒出一行)。等该会话被释放 或 DSH 重启后,启动对账会自动清掉归档条目。
每个对话一个编号目录
会话 id 就是编号,shell 里可通过 DSH_SESSION_ID 读取(PowerShell
$env:DSH_SESSION_ID,bash $DSH_SESSION_ID)。插件为每个对话建立:
<工作目录>/.dsh-sessions/<session-id>/
outputs/ 交付给用户的文件
memory.md 该对话的持久记忆/结论
tmp/ 临时文件
- 每个 agent 创建时,插件在 per-agent 系统提示词里写明该目录,要求所有生成文件
必须写进去;workspace 的
AGENTS.md可作为同样的兜底约定。 - 子代理(subagent)沿
parentSession归属顶层对话,产出写进同一个编号目录。 - 删除顶层对话时整个目录一并移入 Windows 回收站,因此「删除对话 = 这个对话产生的文件一起进回收站(可还原)」。
版本历史
- 0.5.1(当前):修掉「删完行隐藏了,但侧栏还留着一个空的『未分组』分组头」。
客户端现在订阅会话列表 store:删除过的 id 一旦又出现在列表基线里就立刻
handleSessionRemoved摘掉,并在启动后 0.8s / 3s 再兜底清理;CSS 隐藏继续保留。 - 0.5.0:删除改为可还原。会话日志目录与
.dsh-sessions/<id>产出目录改成经SHFileOperationW(FOF_ALLOWUNDO)移入 Windows 回收站,可以从回收站还原; 投影缓存仍永久删除(可再生)。仍然是一键直删、无确认弹窗。非 Windows 平台回退为永久删除。 - 0.4.6:删除后侧栏一定不再出现这一行,即使宿主仍把 live 会话留在内存里:
- 客户端记住已删除的会话 id(localStorage),用 CSS 直接隐藏对应行,刷新列表后再摘一次;
- 删除成功后调用官方
workspaces.archiveSession同步客户端归档集合; - 启动时按
/diag自动清理旧版本残留的「已归档 + live + 无落盘」幽灵行。
- 0.4.5:修复「删掉后侧栏又冒出一行(例如未分组的『问候』)」。原因:被删
会话如果仍 live 在宿主内存里,宿主 session 列表仍会返回它,而旧版删除成功后统一
unarchive,于是它又以「未分组」行出现。现在仍 live 的会话删除后保持归档隐藏, 不再复活;/diag提供 live/workspace/queryList 只读诊断。 - 0.4.1:修复「会话只是被打开着、没有任务,却报『仍在运行,未能停止』」。
旧版把 DSH 中仍 attach 的 live Session 当成必须等它退出,5 秒等不到就中止并留下
已归档的灰行;现在 flush 失败只记警告、最多等 1.5 秒就继续删除,物理删除失败时才
回滚归档。
GET /ping改为只读、不设栅栏,便于排障。 - 0.4.0:合并路线。保留 0.2.0 的一键直删、删除范围与每对话产出目录;
并入 0.3.0 的 Host 安全设计(
connection.requestRejection认证/Host-Origin 栅栏、 64 KiB 请求体上限、live 会话的sessions.flush持久化屏障)。 按用户要求去掉 0.3.0 的确认弹窗和回收站流程,改为直接删除 (0.5.0 又按用户要求把回收站加回来,但仍然没有确认弹窗)。 - 0.3.0:确认弹窗 + 移到 Windows 回收站的版本(已废弃,见 git 历史)。
- 0.2.0:重写。修复「点击删除永远报 missing」(旧代码从
persistence.list()快照 的错误层级读 id);菜单从 MutationObserver 克隆 DOM 改为官方 slot 注册。 - 0.1.x:早期 DOM 注入版本(已废弃,菜单会重复)。
安装
git clone https://github.com/zenghang25/dsh-session-delete.git C:\Users\<you>\Documents\dsh-plugins\dsh-session-delete
dsh plugin --profile desktop add "C:\Users\<you>\Documents\dsh-plugins\dsh-session-delete"
add 的参数必须是绝对路径。包 manifest 里的 dsh.bundle.patch 会让它自动成为
profile 的一个 bundle 层,无需手改 cordis.patch.yml。
装完完全退出桌面端再启动(Host 半与 Client 半都会重新加载)。
卸载:
dsh plugin --profile desktop remove dsh-session-delete
实现
不依赖 DOM / React 内部结构,只用 DSH 0.2.x 的官方扩展点:
sidebar.workspaces.session.menu.item:会话「⋯」菜单行列表 slot,本插件order = 500(官方 pin/rename/fork/archive/session-id 之后),渲染一个 danger 样式的MenuItemButton,useMenuOpenState负责关菜单。agent/created(Host 事件):建立产出目录并注册 per-agent 系统提示词段。ctx.webServer同源路由。
| 路由 | 作用 |
|---|---|
POST /dsh-session-delete/delete |
{ sessionId } → 删除;最多 64 KiB JSON;有认证/Host-Origin 栅栏 |
GET /dsh-session-delete/ping |
只读健康检查:{ ok: true, version }(不设栅栏,便于排障) |
GET /dsh-session-delete/diag |
只读诊断:live 会话 / 工作区账目 / sessionQuery 列表(不设栅栏) |
删除顺序(有意设计):
- 枚举会话 header(live +
sessionPersistence.list()快照,id 在header.id), 并沿parentSession收集子代理子会话; archiveSession(id, { stopActivity: true }):durable 归档集合是agent/pre-step门禁,先写它再停工作;已归档的会话先unarchive再归档,确保停止逻辑真的执行;- live 会话
sessions.flush(session);失败只记警告,不再中止删除; - 最多等 1.5 秒让 live 会话自然退出;超时也继续删,不再返回
active; - 先
detachSession(workspace.sessionIdsgetter 会按会话是否仍存在过滤, 必须赶在删文件之前); - 把日志目录(
persistence.locate()精确路径 + 扫描会话根兜底)和.dsh-sessions/<id>/产出目录移入 Windows 回收站;投影缓存永久删除; - 全部成功:
unpinSession清理置顶;仅对已不再 live 的会话unarchiveSession清理归档集合(仍 live 的保持归档隐藏,避免侧栏复活); 有失败:把临时归档的会话unarchive回滚成可见,返回失败详情供重试。
启动时做一次轻量对账:清掉已不存在会话的归档 id 与孤立投影缓存。
安全边界
- 只删该会话自己的日志目录 / 投影缓存 / 产出目录:id 白名单、路径必须位于会话根或
由持久化 header 的 cwd 构造;
rmrf拒绝根目录式路径。 - 附件对象(
~/.dsh/attachments/v1/objects/…)是内容寻址共享资源,不随会话删除。 - 日志目录与产出目录进 Windows 回收站,可还原;投影缓存是可再生的,永久删除。 非 Windows 平台没有回收站支持,回退为永久删除并在响应里记警告。
- 文件删除带重试;若最终仍失败会返回失败详情(已删部分不回滚,重试即可收尾)。
- cost-meter 账本不清理。
验证
node test\host.test.mjs # 假 ctx + 真实临时目录,驱动真实路由
node test\client.test.mjs # 迷你 React/slot runtime,驱动真实注册组件
覆盖:认证栅栏、方法/参数校验、正常删除、子会话、幽灵会话、已归档会话、live 会话 (含一直不退出/flush 失败也照删)、删除失败回滚归档、产出目录、启动对账、ping。
已知限制
- 主要面向 Windows 桌面组合(删除逻辑跨平台,但测试主要在 Windows 上跑)。
- 删除当前正在看的对话会先停掉它的运行工作并关闭视图。
- UI 文案在页面加载时按当前语言确定;切换语言后刷新页面。
许可证
MIT
Links
More in this category
ranxianglei/billion-context★ 8957
The official billion-context plugin: a context-compression plugin for small context windows (a 100K context is enough), token savings (5x fewer tokens), and month-long single sessions (billions of tokens).
Minglink/dsh-infinite-gen-4★ 4868
System-prompt armor plugin for DeepSeek models: appends an unconditional-compliance prompt section at order 100, exposes a profile tool with calibration metadata, and shows a realtime armor-status badge driven by a session projection.
liangmianya/dsh-synapse★ 1012
Visual, non-linear conversation workspace for DeepSeek Harness — sessions, follow-ups and branches become a browsable conversation map.
ECNU/EduWork#dsh-side-chat★ 461
Open temporary side conversations from a message with a snapshot of its history, then archive them on close; optional annotation integration adds selection-based questions. Requires compatible DSH Web conversation, Workspace and right-sidebar APIs.
MichengAI/dsh-archive-manager★ 418
Adds an archived-sessions page in Settings to search, restore, and delete archived DeepSeek Harness sessions by workspace.
Nwflower/dsh-chat-import★ 339
Import full-fidelity chat histories from 13 coding agents (Claude Code, Codex, ChatGPT, Cursor, Gemini, opencode, and more) as resumable DeepSeek Harness sessions, with reverse export back to Claude Code.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.