dsh-session-delete: Adding Recoverable Session Deletion to DSH

Introduction

In the DeepSeek Harness (DSH) sidebar, sessions can be archived, but the official persistence layer offers no “delete” interface. The dsh-client-ui-workspace documentation is explicit: There is no Session deletion—sessions can be archived but never deleted. Archived sessions still consume disk space and may still appear in search and list logic; to truly remove a session (along with its sub-agent sessions) from the sidebar and search, you must implement this capability yourself.

Enter the community plugin dsh-session-delete (Maintainer: xiaoxingyuemiao, Category: Client). It adds a light-red “Delete” option to the “…” menu on the session row. After a secondary confirmation, it moves the target session and all its child sessions to the $DSH_HOME/.dsh-session-trash/ recycle bin, and cleans up the workspace registry and projection cache. Deletion is reversible; bytes remain unchanged, and restoration can be performed via the API or by manually moving directories back.

What is this

dsh-session-delete is a client-side plugin for DSH: The Host side registers HTTP routes responsible for locating session directories, moving them to the trash, and cleaning up four registry/cache locations; the Client side mounts the sidebar menu item and confirmation dialog, ensuring the session row disappears immediately from the UI after deletion. Unlike the official “Archive,” deletion makes the session vanish completely from the sidebar and search index reconciliation logic. The files are placed in a trash bin outside the main DSH directory to avoid being scanned as a valid project directory under the sessions root.

Core Features

Entry & Interaction

  • Entry: Hover over a session row in the sidebar → “…” menu → “Delete” in the last group (placed after the official “Archive,” with a trash can icon).
  • Style: Light red, derived from the theme’s secondary error color; lighter than the official danger style in light themes.
  • Secondary Confirmation: A dialog pops up showing the session title, explaining that child sessions (sub-agents) will be deleted together and files moved to the trash; focus defaults to “Confirm Delete”, and Esc, clicking the mask, or “Cancel” can exit.
  • After Deletion: The sidebar immediately hides the row; a toast appears stating something like “Deleted session ‘xxx’, along with N child sessions, moved to trash”.

Cascade Deletion & Four-Point Cleanup

The plugin reads parentSessionId from all sessions to build a dependency tree, recursively collecting all descendants (at any depth) of the target session. It processes them one by one leaf-first, using a visited set to guard against circular references.

For every deleted session, four cleanups are performed (missing one easily leaves ghost rows or dirty data):

  1. Session directory → $DSH_HOME/.dsh-session-trash/<trashId>/session (uses rename for same-volume moves; copy-then-delete for cross-volume moves);
  2. storages/workspace.json: Removed from sessionIds, global.pinnedSessionIds, and global.archivedSessionIds;
  3. storages/session_projcache/sessions/<id>.json deleted;
  4. storages/session_projcache.json entry tables.sessions[<id>] removed.

The Client side marks the session row as hidden and uses a MutationObserver to re-mark rows after DSH re-renders, preventing the row from “reviving”. The dsh-session-query-sqlite dependency for session search reconciles before searching, so the plugin does not need to modify the index separately.

Trash & Restore

Each deleted session becomes a separate record in the trash. trash.json records the original path, workspace, and archive status prior to deletion. When restored, the session returns to its original workspace and reverts to its pre-deletion archive status.

Safety Boundaries (Summary)

Scenario Behavior
Running session exists in target or subtree Refuse to delete; must stop first
Cannot determine child sessions (roster unreadable) Abort; do not silently delete only parent
Partial descendant deletion failure Continue with others; return partial: true and failed[]
sessionId contains path separators or .. Refuse (Whitelist [A-Za-z0-9._~-])
Session directory not within sessions root Refuse
Original location occupied during restore Refuse, do not overwrite
Move failure Rollback trash directory; original session remains intact

The trash must be located outside the sessions root (.dsh-session-trash/); otherwise, DSH will still scan directories beneath it as valid sessions.

Installation & Enablement

The DSH Web client and Desktop client are two independent profiles; the plugin must be installed in each separately. Installation commands follow the repository README; after installation, you must restart DSH (The browser bundle is scanned into the startup graph at launch; the Client side will not load without a restart).

Web Client

dsh plugin --profile web add link:<absolute-path-to-this-directory>
# Example:
dsh plugin --profile web add link:D:\DSH插件\dsh-session-delete

Desktop Client (Electron)

The desktop profile is managed exclusively by the application; you must use the CLI bundled with the installation directory:

& "<DSH Install Dir>\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add link:D:\DSH插件\dsh-session-delete

Uninstall

dsh plugin --profile web remove dsh-session-delete

Uninstalling only removes the plugin; session files in the trash remain and must be restored or deleted manually.

Plugin version 1.0.0, License MIT, Runtime requirement Node >= 20 (see package.json).

Typical Usage

Open “…” → “Delete” → Confirm in the DSH sidebar for the target session. If there are child agent sessions, they will be moved to the trash together.

View Trash & Restore

The Host route listens on the local DSH process. Replace <port> with the current instance port:

# View trash
Invoke-RestMethod http://127.0.0.1:<port>/dsh-session-delete/api/list

# Restore (one at a time)
Invoke-RestMethod -Method Post -Uri http://127.0.0.1:<port>/dsh-session-delete/api/restore `
  -ContentType 'application/json' -Body '{"trashId":"<trashId from list>"}'

Manual restoration is also possible: Move .dsh-session-trash/<trashId>/session back to the originalDir listed in the manifest.

Diagnostics if row remains after deletion

Invoke-RestMethod 'http://127.0.0.1:<port>/dsh-session-delete/api/probe?sessionId=<session_id>'

Focus on onDisk (Is the directory still under the sessions root?), inHostList (Is it still in the host list?), inTrash (Is it in the trash?). A typical “Deleted successfully but row remains” scenario shows onDisk=false / inTrash=true / inHostList=true, indicating an issue with list snapshot convergence rather than the deletion itself.

Use Cases & Notes

Target Audience: Developers who open large numbers of sessions and sub-agents in DSH long-term, for whom archiving no longer satisfies the need to “clear them from the list and disk layout”; for scenarios requiring recoverable deletion rather than permanent erasure.

Please Note Before Use:

  • The plugin reads/writes $DSH_HOME and session directories with the current dsh process permissions; before installation, read the GitHub source and the MIT license to confirm behavior meets expectations.
  • Running sessions cannot be deleted (The entire subtree is refused if any running session exists within it); you must stop them before deleting.
  • The trash has no automatic cleanup; cascade deletion creates multiple independent records, requiring restoration via API or manual operation one by one.
  • Deletion does not clean up images/attachments referenced by the session (content-addressed, possibly shared with other sessions).
  • Immediate hiding relies on DOM conventions like data-row-key="session:<id>"; if DSH changes, the plugin must be updated accordingly.

For local verification, run node scripts/check.mjs in the plugin directory (Performs a full delete/restore flow on a temporary DSH_HOME; the README claims 40 assertions total).

Conclusion

The DSH ecosystem emphasizes “Everything is a plugin”; the SkillHub Directory Page and DeepSeek / High-Flyer have no official affiliation. Community plugins should be evaluated personally before installation. dsh-session-delete supplements the “real deletion” path with a trash bin + registry/cache cleanup where the official version only supports archiving, while retaining restoration and probe diagnostics. It is suitable for DSH users who require controllable cleanup of session trees.

  • Directory Page: https://www.skillhub.cn/plugins/xiaoxingyuemiao/dsh-session-delete
  • GitHub: https://github.com/xiaoxingyuemiao/dsh-session-delete
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye