- Home
- Plugins
- Sessions & Messages
- dsh-session-delete
dsh-session-delete
regularsyr7/dsh-session-delete
Delete a DSH session for real: its log directory, projection cache, rewind snapshots and workspace-registry references move into one restorable trash bundle, and a matching restore tool puts them back. Dry-run by default.
Install
dsh plugin --profile web add github:regularsyr7/dsh-session-deleteREADME
@rainybox/dsh-session-delete
Delete a DSH session for real. The "delete session" action in the DSH session list only removes
the row; the session leaves four footprints on disk. This plugin collects all four and moves,
never shreds them into a single restorable trash bundle, so session_restore can put every byte back.
It ships a host-side tool pair (session_delete / session_restore), a right-click entry in the
session list (red "Delete session"), and a confirmation dialog rendered on shell.overlay.
Install
Install from npm, or straight from source:
npm i @rainybox/dsh-session-delete
# or from source:
git clone https://github.com/RegularsYr7/dsh-session-delete.git
cd dsh-session-delete
dsh plugin --profile desktop add link:$PWD
or add "@rainybox/dsh-session-delete": "link:/absolute/path/to/dsh-session-delete" to the dependencies of
~/.dsh/profiles/desktop/package.json (keep link:, not file: — file: is copied into a
frozen snapshot and later edits stop taking effect), add @rainybox/dsh-session-delete to dsh.profile.bundles,
then pnpm install and restart DSH. Client modules are only scanned when the registry is
constructed, so a new dsh.client declaration never appears on a hot reload.
Requires DSH >=0.2.2-rc.1 <0.3.0-0 and Node >=22.12.0.
TL;DR
session_delete { session_id, dry_run: false, confirm: true }— plan first, then move.session_restore { bundle }or{ session_id }— move the bundle back where it came from.dry_rundefaults to true; nothing touches disk untilconfirm=trueas well.- A live
session.lockblocks the delete unlessforce=true.
The full behaviour reference (paths, HTTP routes, host rules, GUI details) follows in Chinese.
@rainybox/dsh-session-delete(harness 侧实现)
DSH 的「删除会话」在 UI 上只是把会话从列表里拿掉,磁盘上还有四处落点。本插件把四处一起收口,
并且只搬不删:所有目标整体挪进一个回收集合包,session_restore 可原样搬回。
一次删除会动到什么
| 落点 | 路径 | 说明 |
|---|---|---|
| 会话日志目录 | $DSH_HOME/sessions/<workspace-slug>/session-<id>/ | session.v4.jsonl.zstd + session.lock |
| 投影缓存 | $DSH_HOME/storages/** 下以会话 id 命名的文件 | session_projcache/sessions/session-<id>.json 等 |
| 回滚快照 | $DSH_HOME/rewind-snapshots/<session-id>/ | dsh-rewind-plugin 的 SnapshotStore 根目录 |
| 工作区注册表 | $DSH_HOME/storages/workspace.json | workspaces[].sessionIds、global.archivedSessionIds、global.pinnedSessionIds |
暴露给 harness 的工具
session_delete— 参数:session_id(必填)、dry_run(默认 true)、confirm、force、include_rewind、trash_dir。 默认只出计划;真删必须dry_run=false+confirm=true;session.lock存在时拒绝,除非force=true。session_restore— 参数:bundle或session_id(+trash_dir、overwrite)。
GUI(浏览器半边)
client.js 给会话右键菜单加一条红色「删除会话 / Delete session」(order: 700,separatorBefore + afterContent),
点开是在 shell.overlay 上的确认框:挂载即跑 dry-run 并把将被移走的 targets / 文件数 / 字节数摊开,
有 session.lock 时强制要求勾「仍要删除(强制)」,成功后 sessions.refresh() 清掉侧栏幽灵行。
三条宿主规则(踩过才知道):
package.json必须有exports["./client"],否则宿主抛client-modules: <pkg> declares dsh.client but exports no "./client" bundledsh.client.platform必须是"web",其它值直接返回null、不挂载ClientModuleRegistry只在构造期扫一遍 loader entries,之后靠internal/plugin事件增量 flush, 没有 rescan —— 新增/修改dsh.client声明必须重启 DSH 才会进模块图
HTTP 路由(浏览器侧用文档相对路径 fetch('api/session.delete')):
| 路由 | 方法 | 用途 |
|---|---|---|
/api/session.delete | POST | body {sessionId, dryRun, confirm, force},返回与 session_delete 同形 |
/api/session.restore | POST | body {bundle?, sessionId?, overwrite?} |
两者都只对 owner Peer 可达(ConnectionFetchRoute 契约,其它 Peer 403);ToolArgsError → 400,其余 → 500。
注册
dsh plugin --profile desktop add link:$PWD
或在 profile 的 package.json dsh.profile.bundles 里加上 @rainybox/dsh-session-delete 后 pnpm install。
用 link: 不要用 file: —— file: 会被 pnpm 复制成冻结副本,之后改 client.js / src/index.js 都不生效。
Related plugins
billion-context
ranxianglei/billion-context
dsh-web-ui (dsh-chat-recovery)
zhu1090093659/dsh-web-ui
dsh-synapse
liangmianya/dsh-synapse
EduWork (dsh-message-edit)
ecnu/eduwork