dsh-session-delete: Truly Delete DSH Sessions (Including the Currently Viewed Session)

Foreword

DeepSeek Harness (DSH) stores each session as a separate directory on disk: <DSH_HOME>/sessions/<session-id>/. The built-in sidebar operations can archive sessions (hiding them from the list), but there is no option for “truly remove.”

Manually deleting directories on Windows often fails with EPERM because DSH still holds the write handle. On any platform, the row in the sidebar will also persist until the whole page is refreshed. Sessions that have only been opened once also stay resident in the DSH process; “switching to another session first” does not reliably bypass this—switching only changes the UI focus.

Below introduces the community plugin @tuweizhi/dsh-session-delete: it performs shutdown and unloading in the correct order, moves the directory away, and removes the row from the list immediately without needing a full page reload.

What is this

@tuweizhi/dsh-session-delete is a DSH client-side plugin maintained by TuWeiZhi. Its npm package name and installation identifier are @tuweizhi/dsh-session-delete, current version 0.1.0, license MIT.

It solves the problem of providing a recoverable “true delete” under the premise that the DSH process may still be occupying the session directory and the built-in sidebar can only archive, not delete.

  • Directory: https://www.skillhub.cn/plugins/TuWeiZhi/dsh-session-delete
  • Source & Docs: https://github.com/TuWeiZhi/dsh-session-delete

The community plugin directory is an independent site and has no official affiliation with DeepSeek or Fangyuan; it is recommended to check the source code and license yourself before installing. The plugin runs under the current DSH process permissions and will invoke internal services (e.g., sessions, agents).

Core Features

The following capabilities are derived from the project README and package.json descriptions.

Delete active sessions. First cancel and wait for the agent to be idle, then detach from the session/agent registry within the process to make the persistence layer flush to disk and release file handles, and finally move the directory on disk.

No full page reload. The Host side triggers the official api-session/removed event, causing the sidebar row to disappear instantly.

Main view fallback. If the deleted session is the currently focused one, the client will clear the main workspace and return to an empty state with no session, rather than pointing to a non-existent session.

Manually recoverable. The directory is moved to <DSH_HOME>/sessions-trash/<timestamp>__<session-id>, not shredded; exiting DSH allows moving the directory back to sessions/ to restore it.

Windows move retry. When antivirus or indexers may temporarily occupy the directory, retry fs.rename for EPERM/EBUSY/EACCES/ENOTEMPTY within about 6 seconds; if it still fails, report the error code.

Diagnostics endpoint. GET /dsh-session-delete/diag allows viewing the loaded version and whether the current DSH build exposes internal hooks like detachEntered; if behavior is abnormal after upgrading DSH, check here first.

Installation and Enablement

Add @tuweizhi/dsh-session-delete in the DSH Plugins page, or in a shell:

dsh plugin --profile <profile-name> add @tuweizhi/dsh-session-delete

Please replace <profile-name> with your actual profile name.

Installation will not take effect immediately for a running host: the host half-registers HTTP routes and event listeners, so restart DSH (or toggle the plugin switch in the Plugins page). The browser half-injects on the next page load.

Environment requirements (from original text):

  • DSH >= 0.2.1-alpha.1 (Development and verification targets include 0.2.2-rc.1)
  • Node.js >= 22.19.0

Typical Usage

  1. Right-click on any session (running, opened, or idle) in the sidebar.
  2. Select Delete session.
  3. After confirmation, the list row disappears immediately, and the directory enters sessions-trash.

There is no undo available in the UI. To recover a session: exit DSH and move the directory from trash back to sessions/:

# Replace path with your local DSH_HOME
mv "<DSH_HOME>/sessions-trash/2026-11-11T12-00-00-000Z__session-abc" "<DSH_HOME>/sessions/session-abc"

Applicable Scenarios and Notes

Who is it for: Harness users who need to clean up test sessions, remove “ghost rows” from the sidebar, or free up disk directories without uninstalling the entire DSH.

Difference from built-in archive: Archiving only hides list items; this plugin performs detach + directory migration, which is a stronger lifecycle operation.

After upgrading DSH: The plugin depends on several internal APIs; all calls perform feature detection, but if the upstream changes names or semantics, functionality may degrade—after upgrading, it is recommended to visit /dsh-session-delete/diag to verify.

Security and trust: The plugin will operate on the workspace registry queue, persistence, and the file system; you should read lib/index.js, lib/client.js, and the MIT license terms before installing.

Conclusion

@tuweizhi/dsh-session-delete fills the gap in the DSH sidebar where “can archive but cannot truly delete”: correct shutdown order, event-driven row removal, recoverable trash, and covers the “session currently being viewed,” which is the easiest scenario to get stuck when trying to manually delete.

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

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

Xiaoye