dsh-session-delete
给 DeepSeek Harness(DSH)加一个会话删除按钮 —— 悬停即现,二次确认,真删文件。
DSH 内置只有「归档」:会话从侧栏隐藏,日志原样留在磁盘。本插件补上缺失的一环——真正把会话从磁盘删掉。
行为
- 鼠标悬停侧栏任意会话行,在归档 / 置顶快捷按钮旁出现一个垃圾桶按钮。
- 点击弹出确认框:会话标题、「此操作不可撤销」说明、
取消/永久删除。 - 确认后浏览器调用 Host 路由
POST /api/session/delete,Host 删除磁盘文件并返回结果,页面刷新,该会话消失。
删除的文件与记录:
| 路径 | 内容 | 处理 |
|---|---|---|
<DSH_HOME>/sessions/<workspace>/<session>/ |
会话完整日志(zstd JSONL,含所有轮次与工具调用) | 删除 |
<DSH_HOME>/storages/session_projcache/sessions/<session>.json |
标题、todos、用量、上下文压力等投影缓存 | 删除 |
<DSH_HOME>/storages/workspace.json 中的 sessionIds |
工作区记账 | 自动摘除(不手改也能自愈) |
不做的事:不动 attachments/(内容哈希去重、跨会话共享),不动 archivedSessionIds / pinnedSessionIds(被删 id 成为无害孤儿,注册表在下次成员写入时剪枝)。
安全边界
- 正在运行的会话拒绝删除(
409 session/live):正在写的日志被删会损坏对话,必须先关闭该会话。所以当前打开的这条永远删不掉——这是特性,不是 bug。 - 路径闸门:目标必须是
<DSH_HOME>/sessions的严格子目录,否则400拒绝,防止符号链接 / 手工构造的 id 越界删除。 - 只接受 owner 浏览器:路由注册在 Connection 的 exact fetch registry 上(
/api前缀),非 owner principal 一律 403。 - 鉴权失败不出网:删除只发生在本机 Host 进程内,不经过任何外部服务。
安装
前置:Node.js ≥ 18 仅用于跑测试;DSH 桌面版或 dsh CLI profile(0.2.2-rc.1 起验证)。
方式 A:链接安装(推荐,仓库即安装源)
git clone git@github.com:cchenxi/dsh-session-delete.git D:\workspace\repositories\dsh-session-delete
pwsh -File D:\workspace\repositories\dsh-session-delete\scripts\install.ps1
脚本会在 profile 的 plugins\session-delete 建立指向仓库的 junction(目录联接),并打印需要追加到 cordis.patch.yml 的片段。仓库更新后重启 DSH 即生效,无需重新拷贝。
方式 B:手工安装
把仓库放到任意目录(例如
D:\workspace\repositories\dsh-session-delete)。在 profile 的
plugins下建立联接或直接拷贝:$profile = "$env:USERPROFILE\.dsh\profiles\desktop" New-Item -ItemType Junction -Path "$profile\plugins\session-delete" ` -Target "D:\workspace\repositories\dsh-session-delete"在
<profile>\cordis.patch.yml末尾追加:- insert: - id: session-delete name: "./plugins/session-delete/lib/index.js"完全退出 DSH 再打开(托盘 → 退出,确认没有
DeepSeek Harness进程)。
为什么不放
node_modules:profile 不是 npm 工程,pnpm install会把不在dependencies里的包当 extraneous 清掉;相对路径引用不受影响。
验证安装
- 悬停会话行,出现垃圾桶按钮;
- 点击后弹出中文确认框;
- 确认一个已关闭的会话后,侧栏条目消失、
<DSH_HOME>\sessions下对应目录消失。
卸载
删除 cordis.patch.yml 里那段 insert,再删掉 plugins\session-delete,重启 DSH。
开发
cd D:\workspace\repositories\dsh-session-delete
node test/plugin.test.mjs
测试不启动 DSH:Host 半侧用 mock ctx(内存 Service 替身)跑通路由、路径闸门、live 拒绝、404/405;浏览器半侧在 node:vm 里执行 bundle,校验 __ModuleLoader__ 注册 id、apply/inject 导出与两个槽位注册。
lib/index.js Host 半侧:Cordis 插件,注册 exact Fetch route,执行删除
lib/client.js 浏览器半侧:__ModuleLoader__.load CJS factory,槽位 + 对话框
依赖的 DSH 公共面(均为插件可用接口,无 monkey patch):
- Client:
ctx.slots(inject/register)、ctx.locale、@deepseek-ai/dsh-client-ui-primitives(可选:Tooltip / Modal / Button / 图标,缺失时降级为原生元素); - Host:
ctx.connection.fetch、ctx.sessionPersistence、ctx.sessions、ctx.workspaceRegistry、ctx.effect。
License
MIT © chenxi
English
dsh-session-delete adds the missing "delete" verb to DeepSeek Harness sessions.
- Hover a session row → a trash button appears next to archive/pin.
- Click → a confirm dialog naming the session and warning that deletion is permanent.
- Confirm →
POST /api/session/delete→ the Host removes the session's log directory, its projection-cache record, and its workspace accounting slot → the page reloads.
Safety: live sessions are refused (409), targets must live under <DSH_HOME>/sessions, and the route is owner-only via the Connection exact-fetch registry.
Install (PowerShell):
pwsh -File scripts/install.ps1
# then append to <profile>\cordis.patch.yml:
# - insert:
# - id: session-delete
# name: "./plugins/session-delete/lib/index.js"
# and restart DSH completely.
Uninstall: drop the insert entry, remove plugins\session-delete, restart.
MIT © chenxi
No comments yet. Be the first to write one.