dsh-tui-session-manager: dsh-TUI Session Management Plugin

Preface

The adapter layer of dsh-TUI 0.11.x has already implemented true deletion capability (channel.deleteSession(id)), including the recursive deletion of log directories, clearing resume markers, and last-used.json. However, the host does not provide a UI entry point. Neither the /resume selector nor the workspace menu contains an entry to invoke the deletion logic, resulting in the need for manual cleanup via the file system.

This plugin does not rewrite the deletion logic; it only adds the UI entry point. It provides a /sessions full-screen scene for browsing, filtering, and truly deleting saved sessions, and handles state remnants not touched by the host’s deletion path.

Installation and Activation

Please ensure Node.js is installed before installation (requires version ^22.19 || >=24).

dsh plugin --profile dsh-tui add ./dsh-tui-session-manager

After installation is complete, enter /sessions in the dsh-TUI conversation to open the manager. To uninstall:

dsh plugin --profile dsh-tui remove dsh-tui-session-manager

Core Features

  • Full-screen Manager: Opens a full-screen panel via /sessions, supporting browsing grouped by workspace and real-time filtering with the / key (matching title, working directory, or id).
  • Tri-state Filtering: Use the e key to cycle through filter modes: Show All → Show Empty Shells Only → Hide Empty Shells.
  • Empty Shell Identification & Annotation: An empty session is defined as one containing only 4 metadata frames, no human messages, and a title that defaults to the directory name. Empty shell rows are annotated with their size (e.g., empty·312B), and the header displays the total count, empty shell count, and current view status.
  • Batch Deletion: Supports a to select all currently visible items; once checked, press d to delete. A y/n confirmation prompt appears before deletion.
  • Residual Cleanup: The deletion operation synchronously cleans up residual state not touched by the host’s deletion path, preventing ghost entries from appearing in the /resume list.
  • Zero Dependencies: No build step, no runtime dependencies; it is a pure ESM module that runs directly when placed in the profile.

Typical Usage

Enter /sessions in the conversation to enter the manager.

Basic Control Keys:

Key Action
↑ ↓ / k j Move cursor
space / x / enter Check or uncheck current session
a Select All / Select None (current visible set only)
d Delete checked items (confirmation required)
/ Enter filter text
e Toggle empty shell filter state
esc Exit filter, cancel confirmation, or close panel

Standard workflow for cleaning up empty sessions:

  1. Enter /sessions in the conversation to open the full-screen manager;
  2. Press e to switch to “Show Empty Shells Only” mode;
  3. Press a to select all items in the current list;
  4. Press d to delete;
  5. Enter y in the confirmation prompt to confirm.

Deletion results are summarized at the bottom in the format deleted N, refused M. The currently active session will be refused by the host (consistent with host semantics); the refused status also covers cases where logs have already been lost.

Security and Notes

  • Irreversible Deletion: The plugin has no recycle bin functionality; deletion operations cannot be undone. Please carefully verify the checked items.
  • Session ID Format: Only IDs conforming to the ^[A-Za-z0-9][A-Za-z0-9_-]*$ rule will be treated as filenames or map keys; others will be skipped and reported.
  • Automatic Backup: Before each sweep, the plugin backs up affected JSON files with a .bak-sweep-<YYYYMMDD-HHMMSS> suffix.
  • Fault Tolerance: Unparseable JSON is preserved as-is without speculative modifications; the sweep process does not throw exceptions—single-step failures are counted in the result line and do not affect other steps.

Compatibility

  • dsh-TUI Version: Compatible with dsh-TUI 0.11.x.
  • Node.js Version: Requires Node.js ^22.19 or >=24.
  • React Dependency: The plugin uses the host-injected props.React and does not bring its own React (the TUI reconciler only recognizes the host’s React 19 elements).

Conclusion

If you need to maintain a clean, residue-free session environment within dsh-TUI, dsh-tui-session-manager provides a lightweight tool with no build dependencies. Reference links for the plugin source code and documentation can be found below.

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

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

Xiaoye