Preface¶
The DeepSeek Harness (DSH) sidebar can archive sessions, but the platform itself has no “delete session” action. Archived logs, projection caches, and markers remain in ~/.dsh, causing disk usage to keep growing. Sometimes “ghost rows” appear in the sidebar that cannot be clicked or opened, or after a parent session is deleted, its subagent sessions become orphan records that cannot be managed individually.
dsh-session-cleaner (npm package name dsh-session-maintenance) is a DSH plugin published by community maintainer C-S-N-Y, categorized as a “memory”-related capability. It adds “Permanently delete session” and “Clean up invalid sessions” entries in the sidebar, performs host-side validation before truly deleting traces of archived sessions, and scans for and cleans up ghost markers and orphan sessions. The plugin has zero dependencies and zero build steps, and includes a host-side Remote endpoint as well as Chinese and English client UIs.
Below is an explanation covering positioning, features, installation, usage, and safety constraints. All facts come from the GitHub README.
What This Is¶
In one sentence: a destructive cleanup tool that only deletes archived sessions, accompanied by read-only scanning and optional batch cleanup.
| Item | Description |
|---|---|
| Repository | C-S-N-Y/dsh-session-cleaner |
| Directory page | skillhub.cn plugin page |
| Version (package.json) | 0.2.0 |
| License | MIT |
| Requirements | Node ≥ 20; DSH desktop installed and dsh CLI available |
Deletion uses rmSync, which does not go to the trash and is irrecoverable. The README explicitly recommends first trying it out with fake sessions generated by npm run make-fixture, and not practicing deletion on real conversations.
Core Features¶
Permanently Delete Archived Sessions¶
For an archived session, a single cleanup covers: log directory, projection cache, archive marker, and workspace membership slot. The sidebar “…” menu gains Permanently delete session…; the confirmation dialog displays the full session id, working directory, creation time, size on disk, whether it belongs to a workspace, etc., so you can verify before deleting. After a successful deletion the sidebar row disappears immediately; if the UI notification fails, press F5 to refresh (no need to restart DSH).
Clean Up Invalid Sessions¶
The sidebar footer Clean up invalid sessions opens a panel. Scanning itself is read-only; after listing three categories of problems, it executes the corresponding action:
| Category | Meaning | Cleanup method |
|---|---|---|
| Ghost session | The archived set still holds the id, but it can no longer be deleted normally | Remove marker, delete leftover files, notify page to remove row |
| Sidebar ghost row | No trace on disk, but a row still exists in host memory | Stop activity and remove row |
| Orphan session | A subagent session whose parent session has been deleted | Files are deleted only if explicitly checked (irreversible) |
The panel provides Diagnose, which shows host-side memory session count, archived set, and “in memory but not on disk” situations.
“Stop and Delete”¶
Sessions opened in DSH often leave their Agents hanging in host memory indefinitely; this does not mean they are still working. The platform provides no remove/detach API. If a session is still held by a live Agent, normal deletion is rejected (rejection code session/attached). In the “Stop and delete” path the plugin: uses workspaceRegistry.archiveSession(id, { stopActivity: true }) to stop activity, polls until running work and active descendants are cleared (default cap of 4 seconds, adjustable via the DSH_SM_RELEASE_TIMEOUT_MS environment variable), then calls ctx.sessions.flush(session) to persist state, and only then deletes files. If it cannot stop, it returns session/stop-timeout and will not force-delete.
Installation and Enablement¶
Prerequisites: DSH desktop, dsh CLI, local git and Node ≥ 20.
The README gives two installation methods. The one tested on the author’s machine is “clone + local link”; if the GitHub spec installation errors, you can fall back to the former.
Method A: Clone and install via link (README example uses PowerShell)
git clone https://github.com/C-S-N-Y/dsh-session-cleaner.git "$env:USERPROFILE\.dsh\plugins\dsh-session-cleaner"
dsh plugin --profile desktop add link:"$env:USERPROFILE\.dsh\plugins\dsh-session-cleaner"
After installation, it is recommended to verify the profile’s package.json dependency, the node_modules link, and the session-maintenance entry in cordis.patch.yml with disabled: false (do not duplicate insert in the patch). Finally restart DSH once — host plugins are only loaded at process startup.
Method B: GitHub spec (pnpm git path)
dsh plugin --profile desktop add github:C-S-N-Y/dsh-session-cleaner
The README notes this path has not been tested in the author’s environment.
Uninstall
dsh plugin --profile desktop remove dsh-session-maintenance
Then restart DSH.
Typical Usage¶
Delete a Session¶
- Sidebar “…” → Archive that session;
- Sidebar “…” → Permanently delete session…;
- In the dialog, verify the id, path, size, and other info, then confirm;
- If prompted that it is still held by an Agent, use Stop and delete.
Clean Up Invalid Sessions¶
- Open Clean up invalid sessions at the sidebar footer;
- You can click Diagnose first to view a host snapshot;
- Handle ghosts and sidebar ghost rows according to the list; orphan sessions require checking before deletion;
- Execute cleanup.
For development/troubleshooting, after cloning the repository you can run commands inside the plugin directory (not dependent on the DSH process):
npm test
npm run make-fixture -- --cwd <temp directory>
node test/session-trace.mjs <sessionId>
Safety Design and Rejection Rules¶
Before deletion, checks are performed one by one; if any is not satisfied a structured rejection is returned (not a silent failure):
| Rule | Description | Rejection code |
|---|---|---|
| I1 | Still held by a live Agent | session/attached |
| I2 | Still has running work | session/running-work |
| I3 | Has live subagent descendants | session/descendants-active |
| I5 | Not archived | session/not-archived |
The disk-side core (lib/core.js) additionally has S1–S4: sessionId format validation, path must be under <DSH_HOME>/sessions with realpath to prevent escape, directory name must match the sessionId and contain log files, and if uncertain it will not delete and will write a warnings entry. The deletion order is: first remove the archive marker and workspace slot, then delete files; if file deletion fails, the marker is rolled back.
The host Remote namespace sessionMaintenance exposes the main endpoints: probe (read-only pre-check), delete (destructive, optional force:true), scanJunk (read-only), cleanupJunk (orphans require explicit input), diagnose (read-only).
Use Cases and Caveats¶
Who it’s for: long-term DSH users who archive many sessions and want to reclaim disk space; those encountering sidebar ghost rows or subagent orphans taking up space; those who want an extra layer of confirmation beyond “archive” before permanently deleting.
Be aware:
- The plugin reads and writes
DSH_HOME(default~/.dsh) with the current dsh process permissions, and does not touch paths outside it; you should review the source code and the MIT license yourself before installing. - It does not clean up attachments, provide scheduled reminders, or do cross-profile GC; subagent sessions do not appear as separate rows in the sidebar and can only be managed via “Clean up invalid sessions”.
- The DSH ecosystem philosophy is “everything is a plugin”; skillhub.cn and similar are community directories, with no official affiliation with DeepSeek / High-Flyer.
If menu items do not appear, check: whether the profile’s node_modules is correctly linked, whether cordis.patch.yml is enabled, and whether DSH was restarted; if the client half-crashes the menu silently disappears, so check the DSH logs for slot entry crashed.
Conclusion¶
dsh-session-cleaner fills in DSH’s missing “permanently delete archived sessions” capability, and turns scanning and cleanup of ghost markers, sidebar leftover rows, and orphan subagent sessions into a safe, diagnosable, checkable process with rejection codes. If you are already using DSH desktop, you can get the plugin from the directory page or GitHub, install it per the README, restart, and then try deleting a fake session.