dsh-session-md-purge
Manifest validAdds a recoverable delete to the session context menu: the Host archives the session, detaches it from its project and moves the session directory plus the Markdown files that session wrote into $DSH_
dsh-session-md-purge
A DeepSeek Harness (DSH) plugin that makes deleting a session recoverable and cleans up the Markdown that session wrote.
It adds one red 删除会话 action to the session context menu. Selecting it:
- asks the Host which Markdown files the session wrote with the
write,editorapply_patchtools, and shows that list in a confirmation dialog; - archives the session through the Workspace registry — the durable archive set is what hides a sidebar row, and it also refuses a session with running work;
- detaches the session from its project;
- moves the session directory and those Markdown files under
$DSH_HOME/session-trash/<UTC stamp>/.
Nothing is hard-deleted, so a mistake can be undone by hand from the trash folder. A session with a running turn, subagent, task or active reminder is refused with HTTP 409 and left untouched.
Requirements
- DSH 0.2.2-rc.1 or newer (
engines.dsh). The plugin needs the authenticatedconnection.fetchHost bridge and the Workspace registry archive/detach API. - No npm dependencies. The optional
zstdbinary is used as a fast path to read the session log; without it the plugin falls back to the Host's session-query service.
Install
From a DSH profile, install the package from this repository:
dsh plugin --profile <profile> add github:Cui-CN/dsh-session-md-purge
Or use the prebuilt release tarball (no build step, no dependency install):
dsh plugin --profile <profile> add https://github.com/Cui-CN/dsh-session-md-purge/releases/latest/download/dsh-session-md-purge.tgz
In DSH Desktop, install through the app's plugin manager with the same source. Once the plugin market lists this repository, it can also be installed from the market UI.
After installing, refresh the page once so the client bundle loads. The action then appears in the session context menu.
What stays behind
$DSH_HOME/session-trash/<UTC stamp>/
<session directory> # moved as-is: log, lock and any other files
md/<absolute path without the filesystem root>
For example $HOME/Documents/report.md lands at
session-trash/<stamp>/md/Users/<name>/Documents/report.md, and a Windows
C:\Users\<name>\Documents\report.md lands at
session-trash/<stamp>/md/Users/<name>/Documents/report.md. Restoring is a
plain file move; the archived session can be unarchived from the market/plugin
UI or the workspace registry.
Client menu contract
The action is a data action, not a legacy component contribution:
ctx.contextMenus.register({ id, target: 'session', order, resolve }) returns
{ id: 'delete', label, danger: true, separatorBefore: true, failureLabel, run }.
The shared overlay dismisses the menu before calling run, so no menu remnant
stays on screen while the preview request and the confirmation dialog run.
Failures surface through ctx.contextMenus.notify(...).
The bundle declares dsh.client.inject for
@deepseek-ai/dsh-client-ui-context-menu and
@deepseek-ai/dsh-client-ui-workspace.
Host routes
| Route | Methods | Purpose |
|---|---|---|
/api/session.purge.preview | GET, HEAD | Existing Markdown files, their total size, and live / archived flags |
/api/session.purge | POST | { "sessionId": "..." }; archive, detach, move |
Both are registered on ctx.connection.fetch (requestBody: 'buffered'), so the
/api bridge performs browser/API authentication, Host/Origin trust checks and
body limits, and the handler receives a Fetch Request and returns a Fetch
Response. The routes answer 400 for a bad body or id, 404 for an unknown
session, 409 for a session with running work, and 500 when the registry or
the file move fails.
Scope and safety rails
- Only
.mdfiles named by this session's ownwrite/edit/apply_patchcalls are candidates, and only when they resolve under$HOME,/tmp,/private/tmpor/var/folders(or under$HOMEon Windows). - Application data and dependency trees are excluded even under
$HOME:Library,.dsh,.Trash,.config,.cache,.local,.npm,.pnpm-store, plus anynode_modulesor.gitsegment. - The confirmation dialog lists every file that will move before anything happens.
- A session with running work is refused; the Workspace registry archive gate is what enforces this.
- The compressed-log decompressor runs with a 20 s timeout, so a wedged
zstdchild fails the request instead of holding the route open. - The preview caches its scan keyed by the log's
mtime+size (at most 60 s), so the confirming click does not decompress the log twice and a stale list is never used after the log grows. - The client request uses a 30 s
AbortSignal.timeout.
Tests
node --test test/*.test.js
The suite fakes the Connection Fetch router, Workspace registry and session-query
services, and runs against a temporary $DSH_HOME; it never touches real
sessions.
Publishing
See PUBLISHING.md for the plugin-market listing steps.
License
MIT
Comments
Loading…
Similar plugins
Session management for DSH: archive or delete one session, archive/delete all sessions in a workspace, and restore archived sessions from the settings page — archiving backs up workspace metadata and
★ 0
↓ 283/wk
dsh plugin --profile web add dsh-session-deleteAdds a Delete session item to the sidebar session row menu that permanently removes the session log directory, projection cache and archive/pin membership and drops its row from the sidebar, plus an a
★ 0
dsh plugin --profile web add dsh-archive-workbenchby ashulam
Deletes a session from the sidebar session menu: its log and replay cache go to the Recycle Bin on Windows (a local trash folder elsewhere); a live session is queued for removal on the next start.
★ 0
MIT
JavaScript
Oct 30, 2026
dsh plugin --profile web add dsh-session-deleteby wuuuuu123-32
Adds delete and batch delete to the session list menu; sessions go to the Windows Recycle Bin instead of being erased, and the files a session produced are listed first so you decide whether to remove
★ 3
↓ 744/wk
MIT
JavaScript
Oct 17, 2026
dsh plugin --profile web add dsh-session-deleteby ozjxnxh
Adds delete and multi-select batch delete to the sidebar session menu, removing session chat logs with an automatic backup and one-click undo while leaving workspace files untouched.
★ 0
MIT
JavaScript
Oct 29, 2026
dsh plugin --profile web add dsh-session-trashby Baboo-ming
Permanently delete a DSH session from the sidebar session row menu (danger-styled) with a confirm modal and a seven-stage, independently-degrading deletion pipeline (validate → running guard → workspace ledger → archive set → on-disk logs → in-memory drop → broadcast).
★ 3
↓ 772/wk
MIT
JavaScript
Oct 17, 2026
dsh plugin --profile web add dsh-session-delete