dsh-session-cleaner: Permanent Deletion and Cross-Workspace Moving in the Session Menu

Introduction

In DeepSeek Harness (DSH), the sidebar session row’s “…” menu offers built-in actions like rename and archive by default. However, when you need to permanently clear a session—along with the derived data DSH leaves on disk—or migrate a session from the current workspace to another, the built-in capabilities often lack the necessary granularity. Simply changing the workspace affiliation in the registry is also unreliable: DSH performs reconciliation based on the immutable cwd in the session header, meaning the change might be reverted during the next sync.

Below is an introduction to the community plugin dsh-session-cleaner (maintainer yuanxinbin520). It adds a separate group at the bottom of the session “…” menu containing exactly two actions: move across workspaces and thorough session deletion. The plugin is deliberately lightweight, with no npm dependencies and no build steps. It targets the web-side UI (the dshhub category includes “Session Management” and “Web UI”; the SkillHub directory page classifies it as a workflow tool).

What is this

dsh-session-cleaner is a DSH plugin that registers two rows in the Session “…” menu with orders 500 and 600, following the built-in Rename / Archive rows (pin 100, rename 200, fork 300, archive 400). The first row includes separatorBefore, creating a visually distinct group at the bottom:

Menu Item Order Function
Move to another workspace… 500 True cross-workspace migration: rewrites cwd, moves artifacts, and swaps workspace bookkeeping
Thoroughly delete session… 600 Permanently deletes the session and all derived data after a confirmation dialog

The host half registers a prefix route on ctx.webServer; the client calls it via same-origin fetch. Changes are serialized by session ID, requiring no additional auth headers.

What Thorough Deletion Removes

The confirmation dialog explains the scope first, and the result view reports the actual items removed. The processing scope based on the documentation is as follows:

Data Processing Method
Session log directory ($DSH_HOME/sessions/<project>/session-<id>/) Entire directory deleted, including all format generations (v4/v3/v2/v1) and temp/backup files
Live session / agent cancel + dispose, removed from agent registry, broadcasts session/disposed so clients remove the row immediately
Workspace membership Removed from sessionIds in all workspaces
Archive / Pinned flags Removed from archivedSessionIds and pinnedSessionIds
Projection cache (per-session) Deletes $DSH_HOME/storages/session_projcache/sessions/<id>.json (and .lock/.tmp)
Projection cache (legacy aggregate file) Removes the row from tables.sessions in storages/session_projcache.json and writes a .bak file

attachments/ and cache/ are content-addressed and shared across multiple sessions; they are not exclusively owned by a single session, so the plugin does not touch these trees.

Security boundaries (excerpt from README):

  • The directory is deleted only if the first line header of the artifact proves the session id; otherwise, it reports existed: false and leaves the directory untouched.
  • The path must be <sessions>/<project>/<session>, and the two levels of subdirectories must not be symlinks/junctions (checked again before deletion).
  • Session IDs undergo path traversal validation (e.g., ../evil returns HTTP 400).
  • Deletion only reads the header frame; truncated logs can still be deleted. The move path decodes the full log, so truncated logs are rejected for rewriting.

Cross-Workspace Move Semantics

Moving is not just a registry change; it is a real migration. The steps are summarized as follows:

  1. Validates source/target directories; existing target artifacts are not overwritten.
  2. Decodes the full multi-frame log, rewrites the header’s cwd, and maintains the format generation (v3/v4) and filename consistency.
  3. Atomically publishes the artifact (hides the old file first; restores it on failure).
  4. Running sessions are not torn down: The in-memory header and writer are retargeted in-place, and subsequent events are written to the new file.
  5. Swaps workspace bookkeeping (detaches from the old workspace, attaches to the target); if any step fails, the entire move is rolled back.
  6. Cleans up the old directory and refolds the projection cache.

No page refresh is required after moving a session that is currently open.

Installation and Activation

Environment requirements: DSH >= 0.2.0-rc.1 (README notes testing on 0.2.0-rc.2); Node >= 22.15 (uses the built-in node:zlib Zstandard API).

For the Web profile, choose one of the following installation methods (commands from the official README):

# Install from npm (recommended, no need to access GitHub)
dsh plugin --profile web add @beiwen/dsh-session-cleaner

# Install from GitHub, pinned to a release tag
dsh plugin --profile web add github:yuanxinbin520/dsh-session-cleaner#v0.1.2

# HTTPS (when the network blocks SSH port 22)
dsh plugin --profile web add https://github.com/yuanxinbin520/dsh-session-cleaner.git

The npm package name is @beiwen/dsh-session-cleaner. The unscoped dsh-session-cleaner belongs to an unrelated package on npm; do not install it using the bare name.

If the github: installation reports ssh: connect to host github.com port 22: Connection refused, you can switch to the HTTPS format or configure GitHub to use port 443 in ~/.ssh/config. On Windows, if git reports certificate issues behind a TLS inspection proxy, you can set GitHub’s sslBackend to schannel as per the README, or simply use the npm spec to bypass git.

Desktop profile cannot be installed via dsh plugin --profile desktop (the command will refuse). You should paste @beiwen/dsh-session-cleaner into Settings → Plugins (configure an npm mirror if GitHub is unreachable) or run install_bundle @beiwen/dsh-session-cleaner via the plugin manager. A profile restart (or page refresh for the web client) is required for the plugin to take effect after installation.

The plugin reads and writes session and projection cache paths under $DSH_HOME with the permissions of the current DSH process. It is recommended to review the source code and MIT license on the GitHub repository before installing.

Typical Usage

  1. After installing and activating the plugin, open any session row in the sidebar and click “…”.
  2. In the new group at the bottom of the menu:
    • Select Move to another workspace…: The Host lists workspaces and current affiliation via GET /session-cleaner/api/workspaces?sessionId=.... After selection, it submits { sessionId, targetWorkspaceId } via POST /session-cleaner/api/move.
    • Select Thoroughly delete session…: After verifying the scope in the confirmation dialog, it submits { sessionId } via POST /session-cleaner/api/delete.
  3. When deleting the session currently being viewed, the row disappears, but the interface might remain on the empty conversation page; a manual refresh is required (known limitation in README).

Batch operations are not supported; organizing large numbers of sessions requires a different session-manager class plugin.

Use Cases and Notes

Who is it for

  • Developers who need to “clean delete” a session compliantly and auditably (including projection caches for which DSH provides no cleanup interface).
  • Users who want to migrate a session to another workspace along with its cwd semantics without interrupting currently open sessions.

Limitations and Notes

  • If the Host rewrites the aggregate session_projcache.json at runtime, pruned rows may reappear; per-session cache files are unaffected; cleaning up after DSH stops is the safest approach.
  • Requires the sessionPersistence backend to provide locate(); otherwise, the plugin exits with an error and does not delete blindly.
  • No batch deletion/move operations.

The DSH ecosystem emphasizes “Everything is a plugin”; SkillHub is a community directory and has no official affiliation with DeepSeek or High-Flyer.

Conclusion

dsh-session-cleaner fills two gaps in the session “…” menu: thorough deletion with confirmation and result feedback (including projection cache), and rollback-capable, live-session-friendly cross-workspace moves. If you primarily use DSH on the web side, you can install @beiwen/dsh-session-cleaner using the npm or GitHub commands described above.

羽毛球分组比赛记分
小程序二维码

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

Xiaoye