dsh-session-hygiene
Manifest validDelete sessions into a recoverable trash, clean up sessions orphaned by deleted workspaces, and group workspaces into categories. A DSH plugin.
dsh-session-hygiene
English | 中文
Three gaps in the shipped DSH sidebar, closed by one plugin:
- A session can be archived but never deleted. Delete session (to trash) moves the log out of the session store into a recycle bin instead of unlinking it, so it can be restored.
- Deleting a workspace leaves its sessions behind. They stay on disk with a
cwdthat matches nothing, so the sidebar has nowhere to list them. Settings → Session cleanup finds those orphans and lets you archive or trash them. - Workspaces cannot be grouped. Settings → Workspace categories adds categories, sidebar headers, drag-to-assign and collapse.
Everything is additive: no shipped row is replaced or hidden, and no DOM outside these components is rewritten.
Where it shows up
| Surface | What you get |
|---|---|
Session row ... menu | Delete session (to trash) |
| Sidebar workspace list | Category headers, and drag-to-assign |
| Settings → Session cleanup | Orphan scan, trash, restore, permanent delete |
| Settings → Workspace categories | Categories, assignment, ordering, header toggle |
Install
From the npm registry, either from DSH's Plugins page or through the agent:
plugin_manager install_bundle dsh-session-hygiene
To install a local checkout instead, pass its absolute path:
plugin_manager install_bundle <path to this checkout>
Host-side JavaScript does not hot-reload: restart the host once after install.
Delete a session
- In the sidebar, point at a session and open its
...menu. - Choose Delete session (to trash).
- The row leaves the list immediately; the data is moved, not deleted.
Under the hood, in order: running work is stopped and the row is hidden, the id
is detached from every workspace and unpinned, <home>/sessions/<group>/<id>/
is renamed into the trash, a preview is recorded, and api-session/removed
lets open pages drop the row without a reload. The projection cache stays, so a
restored session keeps its title and opening prompt.
If the move fails with "the session data is still in use", another view still holds the directory open: switch to a different conversation and retry. When the move fails the archive is rolled back, so the session keeps showing as before.
Clean up sessions from deleted workspaces
Open Settings → Session cleanup. The page scans as it opens; Rescan repeats it.
Orphaned sessions are stored sessions whose header.cwd matches no
registered workspace. Each row shows its title, opening preview, the workspace it
used to belong to, the directory name, and its size.
- Per row: Move to trash.
- Bulk: Archive N — hides them in the shell's archive, skipping subagent sessions, which are usually owned by a parent session.
- Bulk: Move all to trash — includes subagents, and asks for confirmation.
Detached sessions are a separate case: their cwd matches a workspace that
does not list them, so the sidebar files them under Ungrouped even though the
workspace exists. They appear as a strip above the tabs with Attach all,
which is cheaper and safer than trashing a healthy session.
The trash: restore or delete permanently
The Trash tab lists what has been moved.
- Restore renames the directory back to its recorded path and re-attaches the
session to the workspace that owns that
cwd. It refuses (409) when something already occupies the original path — move or delete that first. If the original workspace no longer exists, the session comes back ungrouped, because nothing owns itscwdany more. - Delete permanently unlinks the directory and drops its projection-cache entry. This is the only irreversible action, and it always names exactly what it removes; a second click confirms it.
Group workspaces into categories
Open Settings → Workspace categories.
- Add category, rename inline, reorder with ↑/↓, Delete (its workspaces fall back to unclassified).
- Assign a workspace from its dropdown, or drag a workspace row onto a category header in the sidebar.
- Save and regroup writes the assignment and reorders the workspace registry so each category's rows are contiguous; unclassified workspaces sort last. The shipped drag-to-reorder keeps working — this only reorders on save.
- Clear assignments sends every workspace back to unclassified without deleting the categories themselves.
- Click a header to collapse or expand a category; the collapsed state persists. Show category headers in the sidebar hides the bands without losing the assignments.
A category only gets a header while its rows form one contiguous block. A split category shows no header rather than a header over rows that belong elsewhere. The bands are nodes this plugin adds and removes itself, so removing the plugin restores the sidebar exactly as the shell rendered it.
Where your data goes
<home>/storages/session-hygiene/
categories.json
trash/<sessionId>__<stamp>/
entry.json
session.v4.jsonl.zstd ...
entry.json records sessionId, cwd, from (the original directory),
title, preview, createdAt, sizeBytes and deletedAt. It is the only file
this plugin authors, and it is what makes a restore possible.
Delete that directory tree to empty the trash by hand. The projection cache is deliberately kept on trash (a derived artifact, so a restored session still shows its title) and removed on purge.
Remove
Remove the bundle from DSH's Plugins page. The sidebar loses its category bands immediately, and no shipped row is left in a modified state.
Empty or restore the trash first. Removing the plugin leaves
<home>/storages/session-hygiene/ on disk, but sessions already in the trash
no longer have any UI that can restore them — you would have to rename each
directory back by hand, following its entry.json.
Known limits
- Orphan detection compares a session's
header.cwdagainst the workspace registry's recorded directory. A session whosecwdwas renamed on disk reads as orphaned even though its workspace still exists. - Deleting a workspace still does not warn about its sessions at delete time;
this plugin surfaces them afterwards, in Settings. Intercepting the shipped
delete flow would mean taking over
sidebar.workspaces, which is asingleslot owned by the shell. - Subagent sessions are listed and marked separately, excluded from Archive all, and included in bulk trash.
- Category headers require contiguity; dropping a row between two rows derives its category from the header above, which is a guess when a category holds a single row.
- Host-side JavaScript does not hot-reload: restart the host after install or update.
Development
node tests/host-smoke.mjs
The smoke test drives the real route handler through scan → trash → restore →
purge against a throwaway DSH_HOME, so it never touches a live profile. It is
excluded from the published package by files.
For maintainers, the surfaces are registered as:
| Slot | Id | Purpose |
|---|---|---|
sidebar.workspaces.session.menu.item | session-hygiene-trash | Delete row, ordered directly above Archive |
settings.section | session-hygiene | Session cleanup page |
settings.section | workspace-categories | Categories page |
settings.section.icon | session-hygiene, workspace-categories | Nav glyphs |
sidebar.footer.action | session-hygiene-labels | Renders nothing; mounts the DOM watcher that draws category bands |
Comments
Loading…
Similar plugins
by OliYogSothoth
Delete DeepSeek Harness sessions for good — via a recycle bin: move, restore, then the next start wipes the log, projection cache, spill files and workspace accounting.
★ 1
MIT
JavaScript
Nov 4, 2026
dsh plugin --profile web add dsh-plugin-session-purgeby LucasCaleb-ggg
Batch session cleanup for DeepSeek Harness — pick a workspace, see which sessions are archived, and permanently delete logs, projection caches and workspace records.
★ 0
MIT
JavaScript
Oct 31, 2026
dsh plugin --profile web add dsh-session-cleanupby WindFromKadath
DSH plugin: archive the sessions of a workspace whose folder disappears, and bring them back (grouping included) when the folder returns.
★ 0
MIT
JavaScript
Nov 3, 2026
dsh plugin --profile web add dsh-plugin-workspace-archiveby nlflora
Recreate deleted workspace folders and import session context as a summary
★ 1
MIT
JavaScript
Oct 24, 2026
dsh plugin --profile web add dsh-workspace-healby gcggcg
DeepSeek Harness sidebar plugin: permanently delete sessions (including opened ones) and show/hide archived sessions per workspace.
★ 3
↓ 811/wk
MIT
JavaScript
Oct 29, 2026
dsh plugin --profile web add @estelle-ge/dsh-plugin-session-cleanerby jingmei2
Physically delete DeepSeek Harness Sessions through an undoable recycle bin: trash, restore, or purge for good.
★ 1
MIT
JavaScript
Nov 2, 2026
dsh plugin --profile web add @jingmei2/dsh-session-bin