dsh-session-delete
中文 | English
DSH(DeepSeek Harness)Web 侧栏增强插件:给会话加一个标记删除入口,就放在内置「归档」按钮旁边。标记后会话名被划掉,等 DSH 进程退出、下次启动时统一清除记录;标记期间只要该会话又被追加了对话,标记自动取消。
仓库名是 dsh-session-delete,包名是 dsh-session-delete-button——因为 npm 上 dsh-session-delete 已被另一个插件占用。安装时以包名为准。
中文
功能
| 入口 | 菜单项 | 行为 |
|---|
| 会话行悬停 | 归档图标右侧的垃圾桶按钮 | 标记删除(再点一次取消) |
会话行 … 菜单 | 标记删除 / 取消删除标记 | 同上 |
| 标记之后 | 会话行整行变灰并划掉 | 纯视觉标记,不删任何文件 |
为什么不立即删除
DSH 只要在 GUI 里打开过一个会话,就会把它连同日志写入权一直留在 Host 进程里,直到进程退出。此时删文件会得到"界面里还在、磁盘上没了"的坏状态,当前正在聊的会话更是不能删。所以删除做成两段:
- 标记(立即):只写一条记录
$DSH_HOME/session-delete-marks.json,随时可撤,任何会话都能标记——包括你正在打开看的那个;
- 清除(下次启动):DSH 启动时、还没有任何会话被打开,插件逐个删掉被标记会话的目录,并清算工作区账目。
行为细节
| 场景 | 结果 |
|---|
| 标记任意会话(含已打开、正在看的) | 立即生效:行变灰 + 划掉 |
| 再次点击 / 菜单「取消删除标记」 | 撤销标记,行恢复正常 |
| 标记后又往该会话发消息 | Host 收到 session/event 里的对话活动事件,自动取消标记 |
| 标记的 id 找不到记录 | 返回 404,提示"可能已经被清除" |
| DSH 启动时 | 删除标记对应目录,并 unarchive / detachSession |
解析出的路径不在 $DSH_HOME/sessions 内 | 拒绝删除,只记日志 |
只有真实对话活动会取消标记:user/message、assistant/message、developer/message、system/message、tool/call、tool/result、turn/start、turn/end。后台的 session/title(标题重新生成)、session/flush、压缩、模型切换等不会取消标记。
划掉效果用一条动态 CSS 实现([data-row-key="session:<id>"]{text-decoration:line-through}),随标记列表重写;页面重新可见时重新拉取标记,多标签页和"Host 自动取消标记"都能同步。
安装
本插件未发布到 npm,按 profile 本地安装:
git clone https://github.com/Firefly-Star/dsh-session-delete.git
$src = ".\dsh-session-delete"
$dst = "$env:DSH_HOME\profiles\web\node_modules\dsh-session-delete-button"
New-Item -ItemType Directory -Force -Path $dst | Out-Null
Copy-Item "$src\*.js","$src\package.json","$src\cordis.patch.yml" -Destination $dst -Force
再把 dsh-session-delete-button 追加到 $DSH_HOME\profiles\web\package.json 的 dsh.profile.bundles 数组末尾,然后重启 DSH(Host 半需要重启,浏览器半随页面刷新加载)。
该 profile 之后跑 pnpm install 会清掉手工放进 node_modules 的目录,需要重新复制。
组成
index.js(Host 半,Cordis 插件)
GET /dsh-session-delete-button/marks → { ok, ids }
POST /dsh-session-delete-button/mark → { sessionId, marked } → { ok, ids }
GET /dsh-session-delete-button/state → 诊断:live 会话、live agent、当前标记、标记文件路径
- 启动时执行一次 purge(异步,不阻塞启动)
client.js(浏览器半,dsh.client web bundle):注册官方插槽
sidebar.workspaces.session.row.action(order 101,紧跟归档 100)
sidebar.workspaces.session.menu.item(order 401,紧跟归档 400)
shell.overlay(Toast 提示)
cordis.patch.yml:随包分发的 profile 层,安装后自动挂载
兼容性
适配 DSH 0.2.0-rc.2:sessionPersistence.list() 的 { header } 快照、locate() 的 { path }、
workspaceRegistry 的 unarchiveSession / list() / detachSession、ctx.on('session/event'),
客户端插槽 API(ctx.slots / ctx.locale)与 data-row-key 行标记。Linux / Windows 均可(纯 node:fs,无 shell 调用)。
English
A DSH (DeepSeek Harness) sidebar enhancement: a mark-for-deletion action right beside the built-in archive button. A marked session is struck through immediately; its records are purged in one pass the next time DSH starts. If the session receives new conversation events while marked, the mark clears itself.
The repo is dsh-session-delete; the package name is dsh-session-delete-button (the former is already taken on npm by an unrelated plugin).
Why two phases
DSH keeps every session you have opened in the GUI live in the Host process — with write ownership of its log — until the process exits. Deleting those files out from under a live session leaves "still in the sidebar, gone on disk", and the session you are chatting in can never be deleted that way. So:
- Mark (immediate): one record in
$DSH_HOME/session-delete-marks.json, reversible, works for every session including the one you have open;
- Purge (next start): before any session is opened, the Host removes each marked session's directory and settles workspace accounting.
Details
- Marked rows are greyed out and struck through via a single generated CSS rule keyed by
data-row-key="session:<id>"; no DOM surgery.
- Real conversation events clear a mark (
user/message, assistant/message, developer/message, system/message, tool/call, tool/result, turn/start, turn/end). Background session/title refreshes, flushes, compaction and model switches do not.
- The purge only ever removes a directory that provably sits under
$DSH_HOME/sessions; anything else is refused and logged.
GET /dsh-session-delete-button/state reports live sessions, live agents, current marks and the mark-file path.
Install
Not published to npm. Clone, copy the package into your profile's node_modules (directory name must be dsh-session-delete-button), add dsh-session-delete-button to dsh.profile.bundles in $DSH_HOME/profiles/<profile>/package.json, restart DSH.
Compatibility
Targets DSH 0.2.0-rc.2 (session persistence snapshots, workspaceRegistry, session/event, client slot API, data-row-key). Linux and Windows.
License
MIT