dsh-workspace-archiver: Workspace-Level Archiving and Recovery

Introduction

In DSH, you can archive a single session or remove a workspace registration. However, after removal, all sessions belonging to that workspace become “ungrouped” and cannot be restored to their original order. This plugin fills the gap by providing workspace-level “archive and hide”: before hiding, it archives all sessions in the workspace and records the workspace path, title, ordering, and session IDs; afterwards, the workspace and its sessions can be restored together.

Plugin Overview

  • Name: dsh-workspace-archiver
  • Maintainer: PandaBoby
  • Category: Client
  • Description: DSH sidebar action: archives all sessions in a workspace and hides the row, then allows restoring the workspace along with its sessions.

Core Features

  • Workspace row entry point: appears in the right-click menu / … menu of the workspace row, ordered between the official “Rename” (100) and “Delete” (300) entries (200).
  • Archive and hide: upon click, the Host archives all unarchived sessions in the workspace one by one; once all succeed, it saves the hidden record and removes the workspace registration, causing the sidebar row to disappear.
  • Fail-fast: if any session fails to archive (still running, insufficient permissions, etc.), the registration is not removed and no hidden record is written; a notification reports the number of blocked sessions, and the console logs the per-session reason.
  • Restorable: via the “Restore Archived Workspaces” submenu in any workspace menu, or by using the /workspace-archiver command, you can rebuild the workspace, reattach the old sessions in their original order, and unarchive them.
  • All-hidden fallback: when all workspaces are hidden and no rows are available to click, use /workspace-archiver to list them and /workspace-archiver restore <id|index> to restore.
  • Directory and logs preserved: only the workspace registration is removed; directories, session logs, and the archive collection are all retained.
  • Duplicate-click guard: repeated clicks on the same workspace / same hidden record are ignored if the previous round has not yet finished.

Installation & Enablement

The plugin is provided as a DSH bundle; after installation, simply refresh the page to activate it.

Install from a local checkout:

dsh plugin --profile <profile> add /absolute/path/to/dsh-workspace-archiver

Install from npm:

dsh plugin --profile <profile> add dsh-workspace-archiver

On desktop, you can also navigate to “Settings → Plugins → Add Plugin → Install Local Plugin Directory” and select this repository.

Typical Usage

  1. In the sidebar, locate the target workspace row (the folder row, not the session rows beneath it).
  2. Right-click, or hover and click ….
  3. Select Archive and Hide This Workspace (N sessions); if the workspace has no unarchived sessions, the menu item reads Hide This Workspace.
  4. On success, the row disappears and a notification indicates the number of archived sessions; the directory and session logs are preserved.

To restore:

  • In a workspace row’s … menu, select Restore Archived Workspaces, then pick the target workspace; or
  • Use the command:
/workspace-archiver                         List archived workspaces
/workspace-archiver restore <id|index>      Restore a specific workspace

Restore results:

  • The workspace row reappears, with title and path taken from the hidden record;
  • Old sessions are reattached to the workspace in their original order, and sessions archived during this run are unarchived;
  • If a session’s original cwd no longer exists or cannot be resolved, attachSession will reject it; the notification / command result reports the number of sessions not reattached, and the session remains in the archive collection—no logs are lost;
  • Sessions that were individually archived before this operation are reattached to the workspace but remain archived; only sessions archived during this run are unarchived;
  • If a workspace at the same path has already been manually re-added, the restore reuses that workspace instead of creating a duplicate.

Hidden Record

The Host writes the hidden record to:

$DSH_HOME/workspace-archiver/hidden.json

By default this is ~/.dsh/workspace-archiver/hidden.json; the file is created with 0600 permissions and the directory with 0700. The content contains only the workspace path, title, ordering anchor, session IDs, and timestamps—no credentials.

  • This file is the sole source for restoring workspace membership. Deleting it does not remove directories or session logs, but the hidden workspace can no longer be restored via the plugin.
  • Records are written to disk serially via a write queue within the Host process; a write failure causes the archive action to abort before the registration is removed.
  • When upgrading or migrating profiles, retain this file if you wish to preserve the restore capability.

Known Limitations

  • Restore depends on the original directory still existing. workspaceRegistry.create performs a realpath check and requires the directory to be valid; if the directory has been deleted or moved, restore will fail and the hidden record is preserved.
  • Individual sessions may fail to reattach. attachSession re-resolves the cwd from the session header; if the cwd no longer exists or is not a directory, that session is skipped, remains archived, and the result reports the number of sessions not reattached.
  • If a workspace at the same path already exists, a merge occurs. If the directory was manually re-added before restore, the restore reuses that workspace and prepends the old sessions; it does not rename or rebuild.
  • A running session blocks the entire archive. If even one candidate session fails to archive, the workspace is left untouched; stop or wait for those sessions first, or use the official single-session archive “Stop and Archive” confirmation flow.

Technical Details

The plugin requires DSH >= 0.2.2-rc.1; interfaces were verified against 0.2.2-rc.5. The Node.js version requirement is >= 20, needed only for the test suite; the plugin itself runs in the DSH Host and Web/Desktop pages. Current test results: 32/32 passing.

The plugin contributes its menu item via ctx.contextMenus.register({ target: 'workspace' }); the Host handles archive/restore logic while the Client handles menu rendering and command registration. All UI strings go through ctx.locale, supporting both Chinese and English with no build step required.

Use Cases & Notes

  • Ideal for scenarios requiring “hide a workspace while preserving session relationships,” such as temporarily unused project groups or workspace-organized test case collections.
  • The plugin runs with the current dsh process permissions. Review the source code and license (MIT) before installing.

Closing

dsh-workspace-archiver extends DSH’s official capabilities with workspace-level restorable archiving, suiting workflows that manage session lifecycles on a per-workspace basis. See the directory page and source code via the links below.

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

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

Xiaoye