dsh-session-drag-move: Drag-and-Drop Migration of DSH Left Sidebar Sessions Across Workspaces

In the left sidebar workspace panel of DeepSeek Harness (DSH), official support is limited to drag-and-drop sorting of sessions within the same workspace. When dragging across workspaces, onDrop does not fire, and insertSessionBefore rejects sessions that do not belong to the current workspace. The dsh-session-drag-move plugin fills this interaction gap, implementing true session migration.

Installation and Activation

Install the plugin via the CLI:

dsh plugin --profile desktop add dsh-session-drag-move

For manual installation, place the plugin directory into the profile’s node_modules and register it in cordis.patch.yml.

How It Works

Session ownership in DSH is derived: a workspace contains all sessions whose header cwd matches the workspace path. The sessionIds in workspace.json serve merely as a sequential ledger. To move to a different workspace, the header must be modified.

Session logs are a concatenation of Zstandard frames, with the first frame acting as the header. The plugin achieves migration by rewriting the cwd in the first frame, copying the trailing frames as-is, and then synchronizing the registry cache.

Core Features

  1. Cross-Workspace Drag Logic

    • Dragging to the target workspace header row: The session is assigned to that workspace and appended to the end of the list.
    • Dragging to the upper half of a session row in the target workspace: The session is inserted before the target session.
    • Dragging to the lower half of a session row in the target workspace: The session is inserted after the target session.
    • Dragging within the same workspace: Not intercepted; sorting is still handled by the official logic.
  2. Migration and Safety

    • Background Job Execution: Long migrations are executed as background jobs to prevent UI freezing.
    • Frame Operations: Only the first frame (header) is rewritten; trailing frames are copied as-is, followed by a post-write self-check.
    • Legacy Directory Handling: The old directory is moved out of the sessions root and placed in a backup area (<root>/../session-drag-move-backup).
    • Running Session Check: The plugin checks if the session is currently running before migration; running or active sessions are rejected.
    • Target Conflict: If the target file already exists, the entire operation is rejected to avoid partial writes.
  3. Sidebar Adaptation
    The plugin identifies rows based on runtime DOM contracts rather than source code class names:

    • Primary Contract: [data-row-key="session:<id>"] and [data-row-key="workspace:<id>"]
    • Fallback: *_sessionRow class name suffixes, [draggable="true"], and [role="treeitem"] attributes.
    • When adapting to third-party sidebars (such as dsh-better-workspace), matching by source code class names will inevitably fail. The plugin maintains compatibility by matching suffixes and attributes.

Known Limitations and Dependencies

  • Version Sensitivity: The plugin depends on internal fields of workspaceRegistry (headers / sessionPaths / host.rememberSessionPath). These fields are version-sensitive. The plugin performs feature-probing and returns structured errors if they are not detected.
  • Cache Synchronization: The record.identity.cwd in the projection cache ~/.dsh/stores/session_projcache/sessions/<id>.json is currently not rewritten (this does not affect ownership).
  • Silent Failure: If a sidebar replaces all signals such as data-row-key, the plugin will silently abstain from taking over (without affecting native drag-and-drop). This can be diagnosed via console logs prefixed with [sm].

API Endpoints

Long migrations are executed in the background. Progress can be queried via the following endpoints:

POST /session-drag-move/api/move       # 开始迁移,传 wait: true 可同步等待结果
POST /session-drag-move/api/progress   # 查询进度,返回 state, phase, detail, result, error

The phase values include resolve, scan, index, read, rewrite, write-main, move-extras, backup, ledger, branches, done.

羽毛球分组比赛记分
小程序二维码

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

Xiaoye