前言¶
DeepSeek Harness(DSH)的 Web UI 側欄裏,會話右鍵菜單長期只有置頂、重命名、分叉、歸檔等項。在 DSH 0.1.7-rc.2 及相近版本上,既沒有「刪除會話」入口,主機端會話控制器也沒有 delete RPC;dsh-session-persistence-jsonl 的文檔寫明:不刪除會話文件,日誌在 root 下累積,直到外部移除,seam 無刪除接口。
若你本地試過很多會話、派生緩存和子智能體分支,側欄會越來越長,磁盤上的 sessions/ 與 storages/ 也會一直留着。社區插件 dsh-plugin-session-delete(維護者 PanChengN,分類:客戶端)用官方 Slot 機制在菜單里加一行「刪除會話」,並把「從磁盤真正刪掉」做成主機 HTTP 端點。本文介紹其定位、刪除範圍、安裝方式與使用注意;插件爲非官方社區作品,與 DeepSeek 官方無關。
這是什麼¶
dsh-plugin-session-delete 是一個 DSH bundle:客戶端半向 sidebar.workspaces.session.menu.item 註冊菜單行(order 500);主機半註冊 POST /api/dsh-session-delete,按會話 id 清理 $DSH_HOME(默認 ~/.dsh)下的會話目錄、派生緩存、工作區引用,並在條件允許時連帶刪除子智能體會話。
倉庫根目錄即插件目錄(package.json 在根上),無需單獨構建。當前資料中的版本爲 1.0.2,許可 MIT © 2026 NIUpc。
核心功能¶
側欄菜單¶
安裝並重啓 DSH 後,在工作區側欄對某條會話右鍵,菜單中會多出一行 「刪除會話」。確認後調用主機 API,刪除成功則側欄該行會更新消失(見下文「界面更新」)。
刪除範圍(一次操作清四處)¶
全部路徑基於 $DSH_HOME:
sessions/<工作區>/<session-id>/— 會話正文與寫鎖storages/session_projcache/sessions/<id>.json— 派生緩存(標題等)storages/workspace.json—global.archivedSessionIds與各工作區的sessionIds引用- 子智能體會話 — 當運行環境提供
zlib.zstdDecompressSync時,會刪除header.parentSession指向被刪會話的會話;不可用時跳過,響應裏帶zstd: false
會話 id 的兩種落盤形式(session-<uuid> 與裸 <uuid>)都會識別。
主機 API¶
刪除由主機半處理,請求格式如下:
POST /api/dsh-session-delete
content-type: application/json
{ "sessionId": "session-xxxxxxxx-...." }
成功時響應示例(字段含義以倉庫 README 爲準):
{
"ok": true,
"sessionId": "session-....",
"removedSessions": 1,
"removedChildren": 0,
"removedCaches": 1,
"workspace": { "archived": 0, "groups": 1 },
"emitted": 2,
"zstd": true
}
常見失敗:400 missing-session-id、400 invalid-json、405 method-not-allowed、500 <message>。
刪除後界面如何更新¶
刪除成功後,主機向客戶端發 api-session/removed 事件;客戶端 ClientSessions.handleSessionRemoved 從列表快照移除該 id,側欄拼行時對無 summary 的 id 直接跳過,該行會立刻消失。若約 400ms 後 id 仍在快照裏,客戶端會退一步調用一次 sessions.refresh(),不會整頁 location.reload()。
插件組成(便於覈對源碼)¶
| 文件 | 作用 |
|---|---|
package.json |
bundle 清單:dsh.bundle.patch + dsh.client |
cordis.patch.yml |
插入主機行 session-delete |
index.js |
主機半:註冊 POST /api/dsh-session-delete |
client.js |
客戶端半:註冊側欄菜單行 |
locale/{zh,en}.json |
插件卡片標題與描述 |
icon.svg |
插件卡片圖標 |
包名 @local/dsh-bundle-session-delete,cordis 行 id 爲 session-delete,HTTP 路由爲 /api/dsh-session-delete。同一 profile 內不要裝兩份(會 ambiguous-install 或重複註冊路由)。
安裝與啓用¶
安裝有兩種方式,差別在於 profile 是否綁定本地目錄。
方式 A:Git 地址(推薦)¶
側欄 Plugins → Add plugin,填寫:
github:PanChengN/dsh-plugin-session-delete
也可填 https://github.com/PanChengN/dsh-plugin-session-delete。鎖版本可加 #<tag>,例如:
github:PanChengN/dsh-plugin-session-delete#v1.0.1
點 Enable now,再重啓 DeepSeek Harness(新 bundle 的瀏覽器模塊需一次進程重啓纔會進入模塊表)。裝完後依賴記錄在 profile 裏,與任何本地 clone 目錄無關,可隨時刪掉本地目錄。
方式 B:本地路徑(改插件源碼時用)¶
在 Add plugin 裏粘貼 clone 目錄的絕對路徑。CLI 對 desktop profile 會拒絕:
$ dsh plugin --profile desktop add <...>
error: profile "desktop" is managed exclusively by the Electron application
此種安裝會在 profile 寫成 link:<目錄>,刪目錄會導致懸空引用;日常用請選方式 A。從 B 遷到 A:先在 Plugins Remove 路徑安裝的那份,再按方式 A 添加並重啓。
典型用法¶
- 按方式 A 安裝並重啓 DSH。
- 在側欄找到要清理的會話,右鍵 → 刪除會話,在瀏覽器原生確認框中確認。
- 側欄對應行應消失;若需排查,可看主機日誌或對照 API 響應裏的
removedSessions、removedCaches等字段。
菜單確認框目前爲瀏覽器原生 confirm(),不是 DSH 自帶 overlay 風格;README 標明未硬性阻止刪除「當前正在進行的對話」,僅確認文案提示。
卸載與誤刪目錄¶
- Git 地址安裝:Plugins 頁面 Remove 即可。
- 本地路徑安裝:須先在 GUI Disable / Remove,再刪 clone 目錄;勿直接
rm -rf已啓用插件的目錄。
若目錄已被刪而 profile 仍引用,啓動可能異常,日誌可能出現無法解析 @local/dsh-bundle-session-delete 的提示。倉庫提供救援腳本(默認 dry-run,加 --apply 寫入,改動前會備份):
python3 dsh-plugin-session-delete/scripts/fix-stale-install.py
python3 dsh-plugin-session-delete/scripts/fix-stale-install.py --apply
$DSH_HOME 不是 ~/.dsh 時用 --dsh-home /path。也可按 README「手工救援」編輯 package.json、cordis.yml 並刪除懸空符號鏈接。
適用場景與注意¶
適合誰:長期在 DSH 裏開大量會話、需要把磁盤與會話列表一起收乾淨,且接受非官方插件維護節奏的用戶。
運行權限:插件與當前 DSH 進程同權,可讀寫 $DSH_HOME 下會話與存儲;安裝前請自行閱讀倉庫源碼與 MIT 許可證,確認刪除行爲符合預期。
已知限制(來自 README):主機內存中的工作區成員關係要等重啓才徹底清掉(側欄表現通常已正常);無 zstd 時不會刪子智能體會話鏈。
DSH 生態強調「一切皆插件」;插件目錄頁託管於 SkillHub 等社區站點,與 DeepSeek / 幻方無官方從屬關係。
鏈接¶
- 目錄頁:https://www.skillhub.cn/plugins/PanChengN/dsh-plugin-session-delete
- 源碼與完整說明:https://github.com/PanChengN/dsh-plugin-session-delete