Introduction¶
In the DeepSeek Harness (DSH) sidebar session row “⋯” menu, the native features include pin, rename, fork, and archive, but there is no entry to completely remove a session from disk. Archiving only changes the list status; session artifacts, projection caches, and workspace ledger ownership remain. Sub-agent sessions are independent artifacts stored at the same level as the parent session, so deleting only the parent session leaves orphaned rows that remain visible in the sidebar. Below we introduce the community plugin dsh-session-menu-delete (maintainer: Nay-1, category: client): it adds a “Delete Session” entry to the menu and performs cascading cleanup and fork protection according to DSH service boundaries.
What Is This¶
dsh-session-menu-delete registers the menu item via the Cordis slot sidebar.workspaces.session.menu.item, right after the built-in “Archive Session” (built-in order 400); this item’s order is 500. The icon uses primitives’ IconTrashOutlineRegular, rendered as a red destructive action with danger: true.
The native DSH sidebar only has archive, not delete; this plugin adds the delete capability and, on the host side, also cleans up sub-agent sessions (to avoid orphans), while not deleting sessions that the user has forked as copies.
- Directory page: https://www.skillhub.cn/plugins/Nay-1/dsh-session-menu-delete
- Source code and documentation: https://github.com/Nay-1/dsh-session-menu-delete
- License: MIT (see
package.jsonin the repo)
Core Features¶
Menu and Interaction¶
Clicking “Delete Session” has no secondary confirmation. The client half sends a request to POST /session-menu-delete/api/delete, and the host half handles disk and in-memory state in order.
When deleting the session currently open in the main view, the plugin will not automatically switch workspaces or clear the main view: the interface will remain on the deleted session, showing “session unavailable,” until you manually click another session in the sidebar or “New Session”. This is intentional design—deletion should not incidentally change what you are looking at; the earlier automatic startSession / clearMain logic has been removed from the client half.
Deletion Scope (Host Side)¶
The host half roughly handles the following items (if the session is still running, the agent is disposed first in DSH order, with a timeout; a timeout at any step will abort the entire deletion):
- Session artifact directory
<DSH_HOME>/sessions/<slug>/<sessionId>/ - Projection cache
<DSH_HOME>/storages/session_projcache/sessions/<id>.json - Workspace ledger: via
workspaceRegistry’sentity.detachSession(), rather than directly editingworkspace.json - The id in the archive / pinned collections
- Derived sub-agent sessions (cascade, see below)
- Image-type attachment objects referenced only by this deletion set (can be disabled, see below)
All operations are irreversible; there is no trash bin.
When detaching an agent, the plugin sends an additional agent/disposed event consistent with DSH’s shape, to avoid downstream modules not receiving the disposed signal for a long time because the detach edge was not emitted.
Cascade: Only Chain Sub-Agents, Don’t Touch Forks¶
Sub-agent session headers contain origin: "subagent" and parentSession; forked copies also have parentSession, but do not have the origin marker, so they do not enter the lineage graph. When deleting a parent session:
- Sub-agents (including multi-level delegation) will first delete descendants, then delete the target;
- Fork copies and their subtrees are uniformly preserved; content is self-contained (history is written into new artifacts via seed).
If you only want to delete the target and not cascade to sub-agents, pass {"cascade": false} in the request body. Before deletion, you can view descendants via a read-only interface:
GET /session-menu-delete/api/lineage?sessionId=<id>
Attachment Cleanup (Overview)¶
Image-type persistent objects are at <DSH_HOME>/attachments/v1/objects/<first 2 chars>/<sha256>; cache/attachments/request-images/ etc. are DSH request caches and are unrelated to this plugin. attachments/v1/file-objects/ and attachments/v1/files/ are not cleaned by this plugin.
By default, cleanup is done “in passing” when deleting a session: an object is deleted only when all references to an attachment fall within this deletion set (including cascaded sub-agents); those shared by forks or other sessions are left untouched. To disable the in-passing cleanup: {"attachments": false}.
Full-library orphan cleanup goes through POST /session-menu-delete/api/attachments/clean (requires confirm); the criteria simultaneously scans live session in-memory events (ownEvents()) and disk logs, to avoid misjudging “just viewed an image, reference not yet persisted” as an orphan. For mechanism details, see ATTACHMENT-CLEANUP.md in the repo.
When calling the plugin HTTP endpoints, the header x-dsh-plugin-call: 1 is required (the PowerShell examples in the README use this).
Installation and Activation¶
After placing the repo in any local directory, install using the absolute path of that directory (do not concatenate github:owner/repo based on the plugin name):
dsh plugin --profile desktop add "file:<本仓库所在目录的绝对路径>"
dsh plugin --profile <name> forwards the arguments to pnpm for dependency management.
After installation, you must make DSH load the plugin; choose one of the following:
- Enable it on the DSH “Plugins” page (this writes to
dsh.profile.bundles); - Or manually add
"dsh-session-menu-delete"to thedsh.profile.bundlesarray in~/.dsh/profiles/desktop/package.json.
Modifying lib/client.js can be hot-reloaded; modifying the host half usually requires restarting the DSH process (the README has a comparison table for how changes take effect in both halves; omitted here).
Runtime environment: package.json requires Node ^22.15.0 || >=24.0.0, with peer dependency cordis >=4.0.0-rc <5.
Typical Usage¶
Sidebar Deletion¶
- Open the “⋯” menu on the target session row in the sidebar.
- Click “Delete Session” (below Archive, the red trash can item).
- If deleting the session currently in the main view, switch to another session or click “New Session” yourself.
Preview Attachment Orphans and Cleanup (HTTP)¶
The following examples are from the README (the default plugin HTTP port depends on your local DSH; the example uses 127.0.0.1:19387):
$h = @{ "x-dsh-plugin-call" = "1" }
# 只读预览孤儿
Invoke-RestMethod "http://127.0.0.1:19387/session-menu-delete/api/attachments/orphans" -Headers $h | ConvertTo-Json -Depth 5
# 确认后删除(不带 confirm 同样只预览)
Invoke-RestMethod -Method Post "http://127.0.0.1:19387/session-menu-delete/api/attachments/clean" `
-Headers $h -ContentType "application/json" -Body '{"confirm":true}' | ConvertTo-Json -Depth 5
Applicable Scenarios and Notes¶
Who it’s for: Developers who need to completely delete sessions directly from the DSH desktop sidebar, want sub-agents to be cleaned up as well, and want fork copies preserved; and who can accept the “click to delete, no confirmation dialog” operation habit.
Permissions and security: The plugin reads and writes DSH_HOME and session artifacts under the DSH process permissions. Before installation, please review the source code and the MIT license yourself to confirm it meets your data retention policy. The community directory SkillHub is an independent site and has no official affiliation with DeepSeek / Huanfang.
Ecosystem background: DSH adopts the “everything is a plugin” extension approach; this plugin belongs to the client injection category (dsh.client.inject includes @deepseek-ai/dsh-client-ui-slots), working together with the host half to complete deletion and cleanup.
Conclusion¶
dsh-session-menu-delete completes the missing “Delete Session” in the sidebar, and on the host side cleans up artifacts, projections, ledgers, and sub-agents according to DSH service boundaries, while protecting fork sessions and shared attachments. For further information on menu order, dispose order, and attachment criteria, refer to the GitHub README and ATTACHMENT-CLEANUP.md.
- Directory page: https://www.skillhub.cn/plugins/Nay-1/dsh-session-menu-delete
- GitHub: https://github.com/Nay-1/dsh-session-menu-delete