Preface¶
In DSH’s multi-conversation scenario, all sessions share the same workspace directory. As the number of conversations grows, temporary files, generated results, and script outputs easily get mixed together, making it difficult to determine file ownership. Archived conversations still occupy directory space. Additionally, if the workspace path contains Chinese characters, older scripts may fail due to encoding or path-handling issues.
dsh-session-folders is a Host-only plugin that automates these operations: it creates a dedicated subfolder for each conversation, names the folder based on the conversation title with a session ID suffix, resolves non-ASCII path compatibility issues through ASCII junctions, and provides cleanup logic for archiving, deletion, and empty-turn scenarios.
Plugin Positioning¶
This plugin belongs to the “Workflow” category and was developed by maintainer qinziang. It extends the session lifecycle through DSH’s plugin mechanism without modifying DSH’s session storage format or injecting into the client UI. The core goal of the plugin is to give each conversation a clear physical boundary within the workspace while keeping the script environment (such as cwd) compatible with ASCII paths.
Core Features¶
1. Conversation Folder Creation and Naming¶
When a new conversation is created, the plugin creates a subfolder in the workspace root directory. The initial name is New-Chat-<session-id>. After DSH generates a title or the user manually renames it, the folder name is synchronously updated to <Conversation-Title>-<session-id>.
The session ID in the folder name is a full UUID, so even if two conversations have identical titles, no folder conflict will occur. Windows-illegal characters in titles are replaced, and titles exceeding 80 characters are truncated. These measures ensure path validity.
2. Title Synchronization¶
The plugin listens to the session/title event. When DSH automatically generates a title or the user manually renames a conversation, it immediately renames the actual folder in place and rebuilds the ASCII junction. The session ID remains unchanged, so the path stays stable.
3. Archiving and Unarchiving¶
When a conversation is archived, the plugin sets the Windows hidden attribute on the actual folder and removes the ASCII junction, so the archived conversation’s files no longer appear in the working directory. When unarchiving, it removes the hidden attribute and rebuilds the junction, allowing the conversation to continue working in its original folder.
4. Deletion Cleanup¶
When a conversation is deleted, the plugin first stops the session’s background tasks and attempts to terminate any processes whose command line or executable references the conversation folder or junction path. It then removes the junction and the actual folder. This only executes after confirming that both the session persistence record and the workspace registration have been removed, to avoid misinterpreting “Host exit” as a deletion.
5. Empty Folder Cleanup¶
If, after a conversation turn ends, the folder contains no files other than the internal marker .dsh-session-folder.json, the plugin deletes the empty folder and junction. On the next message send, the plugin automatically rebuilds the folder and junction before system prompt assembly, model invocation, and tool execution. As long as any file appears in the folder, the empty cleanup will not delete it, and subsequent conversations will continue using it.
6. Non-ASCII Path Compatibility¶
This is the most easily overlooked part of the plugin, yet it is critical for older scripts. The session’s “effective working directory” is set to:
%PUBLIC%\dsh-session-folders\aliases\<session-id>
This is an ASCII junction pointing to the actual conversation folder. The real files are still stored in:
<workspace>\<Conversation-Title>-<session-id>\
Therefore:
- Processes like PowerShell, Node.js, and Python see a
cwdthat contains no Chinese characters (ASCII path only); - Files created via relative paths still end up in the actual Chinese-named folder;
- Legacy scripts that rely on the working directory as a base require no modification.
The plugin preferentially uses %PUBLIC% as the junction root directory, then falls back to %ProgramData%, and finally to %LOCALAPPDATA%, to minimize the chance that Chinese characters in the username are carried into the effective path.
7. Sub-agent Sessions¶
Sub-agents do not create separate folders, avoiding the proliferation of irrelevant directories under a single conversation.
Typical Directory Structure¶
After installing the plugin, a typical workspace directory structure looks like this:
MyProject/
├─ Hello-Greeting-session-f328d195-45bf-431d-960e-9e7c3fa1e0fc/
│ ├─ hello.txt
│ └─ MeetingNotes.md
├─ Fix-Login-Issue-session-a17c2b3d-8c91-4a02-9d77-5e6f70819233
└─ Data-Analysis-session-9e02af...
Installation and Activation¶
It is recommended to install via DSH’s plugin manager:
- Install the
dsh-session-foldersbundle from DSH’s “Plugins” page; - Restart or reload the DSH profile after installation or update to activate the Host-side plugin;
- Create a new conversation, send the first message, and verify that a
<Title>-<session-id>folder appears in the workspace.
Environment Requirements¶
- DSH must use Cordis 4;
- Node.js
^22.15.0 || >=24.0.0; - Windows is recommended (hidden attributes and junction behavior are implemented for Windows); other platforms use directory symbolic links, and the hiding behavior may differ.
How It Works¶
The plugin listens to multiple DSH events to implement the behaviors described above:
- Listens to
agent/created, skips sub-agent sessions; locates the owning workspace based on the session header’scwd. - Creates the actual conversation folder, writes the
.dsh-session-folder.jsonmarker, and creates the ASCII junction. - Silently sets the session’s effective working directory via
session.append('working-directory/change', { cwd: alias }). - Listens to
session/title, renames the actual folder to<New-Title>-<session-id>, and rebuilds the junction. - Listens to
working-directory/access: before the system prompt and tools read the working directory, if the folder has been removed by empty cleanup, it rebuilds the folder and junction first. - Listens to
workspace/session-archivedandworkspace/session-unarchivingto handle hidden attributes and junctions. - Listens to
session/disposed, and after dual confirmation viasessionPersistenceand workspace registration, executes deletion cleanup.
Known Limitations¶
- Only conversations created after installation will have folders created; existing conversations will not be migrated automatically.
- If the model actively writes files using absolute paths outside the workspace, those files will not be forced back into the conversation folder.
- Process cleanup on deletion is best-effort: it matches processes whose command line or executable contains the conversation folder / junction path; if a process obscures the path information, it cannot be guaranteed that the process will be found.
- Archive hiding depends on Windows file attributes; on non-Windows platforms, folders will still be retained, but the hiding effect may differ.
Applicable Scenarios and Notes¶
This plugin is suitable for scenarios where you need to manage files from multiple conversations in a local workspace, where scripts are sensitive to working directory paths, or where workspace paths contain Chinese or other non-ASCII characters. It ensures script environment compatibility through ASCII junctions while keeping physical files in their actual folders.
The plugin runs with the current DSH process permissions. You should review the source code and license (MIT) before installing. The plugin is Host-only; it does not modify DSH’s session storage format or inject into the client UI.
Conclusion¶
With dsh-session-folders, each conversation now has an independent folder boundary within the workspace. Title synchronization, archive hiding, deletion cleanup, and empty folder rebuilding are all handled automatically by the plugin, while non-ASCII path compatibility is resolved through ASCII junctions. DSH’s “everything is a plugin” philosophy is realized here—the plugin extends session lifecycle management without intruding into core logic.
- Plugin directory page: https://www.skillhub.cn/plugins/qinziang/dsh-session-folders
- GitHub repository: https://github.com/qinziang/dsh-session-folders