@mcf171/dsh-session-delete: Adds Permanent Session Deletion to DSH Web GUI

Introduction

When managing sessions via the Web GUI in DeepSeek Harness (dsh), the ⋯ menu for session rows in the official 0.2.x sidebar typically only includes rename, fork, pin, and archive options. There is no entry to “delete this session and clear its logs.” Archiving only hides the session from the main list, but the log directory at <DSH_HOME>/sessions/... remains on disk. This lacks a one-step deletion action for experimental sessions, mistakenly created branches, or when disk space needs to be freed.

Below is an introduction to the community plugin @mcf171/dsh-session-delete (maintainer: mcf171, MIT License, current package version 0.1.0). Without hijacking the sidebar DOM, it utilizes official extension points to add a “Delete Session” menu item and a Delete hotkey. After confirmation, it follows a fixed order to archive, delete the log directory, and broadcast a UI removal event, causing the row to immediately disappear from the sidebar.

What is this

@mcf171/dsh-session-delete is a bundle-patch type plugin that supplements the DSH Web GUI with a permanent session deletion action: the host side registers an origin-routed path, and the client side registers the session row menu and hotkey. The code under lib/ is handwritten JavaScript; changes take effect after restarting DSH, with no separate compilation step required.

  • Directory Page: https://www.skillhub.cn/plugins/mcf171/dsh-session-delete
  • Source Code & Documentation: https://github.com/mcf171/dsh-session-delete

SkillHub is a community plugin directory and has no official affiliation with DeepSeek / High-Flyer. Please review the repository source code and license yourself before installation. The plugin executes file deletion under the current dsh process permissions, deleting only the log directory of the specific session. This action is irreversible and relies on a confirmation dialog for safeguarding.

Core Functions

Deletion Flow (Fixed Order)

A single deletion performs three tasks in the following order; the sequence cannot be swapped:

  1. Archive First: Calls workspaceRegistry.archiveSession(id). This is the official persistence hiding mechanism; the main list will no longer display the session, and subsequent list refreshes will not bring it back. If the session is currently running a turn, archiving will be rejected with the prompt “The session is running, please stop it before deleting” (consistent with official activity checks).
  2. Then Delete Log Directory: Deletes <DSH_HOME>/sessions/<projectKey(cwd)>/<sessionId>/. If the directory does not exist, it skips the step; repeated deletions are idempotent and do not throw errors.
  3. Broadcast api-session/removed: Reuses the official session/disposed → api-session/removed relay. Upon receiving the event, the client immediately removes the row from the UI.

Archiving must happen before deleting logs: attempting to archive after logs are deleted will throw WorkspaceUnknownSessionError.

Interface and Hotkeys

  • Adds “Delete Session” to the session row ⋯ menu. It features a trash can icon on the left (consistent with the official style), a Delete hotkey hint on the right, and is marked with a danger color.
  • The Delete hotkey acts on the currently selected session, following the same flow as clicking the menu (Reject if running → Confirmation dialog → Delete). It does not trigger in the following cases: focus is in an input box or editable area, the Delete key is pressed with Ctrl/Shift/Alt/Cmd, or there is no currently selected session.

Design Boundaries (Explicitly stated in README)

  • UI registration is done via the official slot sidebar.workspaces.session.menu.item; it does not listen to or rewrite the sidebar DOM.
  • The “running” check is consistent with the official list: agents.get(id).status === 'running', blocking only sessions currently running a turn.
  • Deletion uses node:fs, locating the target path according to the projectKey / encodeSegment rules of @deepseek-ai/dsh-session-persistence-jsonl, following DSH_HOME.
  • Do not call sessions.refresh() after deletion: The list = persistent scan + active sessions in memory. An immediate refresh might add the just-removed row back. Cleanup relies on archiving and broadcasting.
  • SessionStore has no removal API; opened session objects may remain in memory until the process restarts. This does not affect usage, as the row has disappeared from the UI and will no longer write to the deleted logs.

Installation and Activation

The materials do not provide commands like dsh plugin add github:...; you need to attach the package to a profile (the following uses profile web and path <DSH_HOME>\profiles\web as an example).

1. Place into the profile’s node_modules

The scoped package is located in the @mcf171\ subdirectory. Copy example (PowerShell):

$dest = '<DSH_HOME>\profiles\web\node_modules\@mcf171\dsh-session-delete'
New-Item -ItemType Directory -Path (Split-Path $dest) -Force | Out-Null
Copy-Item '<LocalDirectory>' $dest -Recurse -Force
Remove-Item "$dest\.git" -Recurse -Force -ErrorAction SilentlyContinue

You can also use a directory link (symlink) for easier immediate effect when modifying source code; however, some Windows environments may return Access denied when creating links in this location. If blocked, revert to copying. After modifying code, you need to re-copy and restart.

2. Register dependencies and bundle

Edit <DSH_HOME>\profiles\web\package.json:

{
  "dependencies": {
    "@mcf171/dsh-session-delete": "link:<AbsolutePathToLocalDirectory>"
  },
  "dsh": {
    "profile": {
      "bundles": [
        "@mcf171/dsh-session-delete"
      ]
    }
  }
}

For bundle-patch type plugins, only register in bundles; do not write a same-named insert line in the profile’s cordis.patch.yml, otherwise it may cause duplicate registration leading to plugin tree loading failure.

3. Restart DSH

Host plugins are only loaded at startup; a restart is required after changes.

Runtime Environment: package.json requires Node ^22.19.0 || >=24.0.0, with a peer dependency on @deepseek-ai/cordis ^4.0.1.

Typical Usage

  1. After restarting DSH, open the Web GUI (The root path returns 401 without a token; the startup log contains ?token=…, which must be included for verification).
  2. Select the session to clean up in the sidebar; if the session is running a turn, stop it before deleting.
  3. Open the row’s ⋯ menu and click “Delete Session”, or press Delete when focus is not in an input box.
  4. Confirm in the dialog; upon success, the row disappears from the sidebar, and the corresponding log directory is deleted.

Uninstallation: Remove @mcf171/dsh-session-delete from dsh.profile.bundles and delete node_modules\@mcf171\dsh-session-delete.

Use Cases and Notes

Suitable for: DSH users who need to thoroughly remove experimental sessions, mistakenly created forks, or free up disk space in <DSH_HOME>/sessions via the Web GUI; those who prefer consistency with official archive/persistence rules and want the UI to evolve with official slots rather than DOM injection.

Notes:

  • pnpm install or plugin market reinstallation might clear manually copied packages within the profile (as they are not in the lockfile resolution). After upgrading DSH, you should also verify that “Delete Session” is still in the menu; if not, redo installation steps 1 and 2.
  • The plugin only deletes the log directory; the deleted session ID might remain in workspace ownership records. The README explains this as a harmless remnant.
  • If you suspect path rules have changed after a DSH upgrade, you can run self-tests in the plugin directory:
node test/format-check.mjs
node test/client-check.mjs

Conclusion

@mcf171/dsh-session-delete uses the three steps of official archiving + log deletion + api-session/removed to fill the gap in the 0.2.x Web GUI for permanent deletion entry, while constraining running sessions and accidental touch scenarios. Refer to the SkillHub directory page and GitHub README for details.

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

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

Xiaoye