DSH GUI Last Session: Automatically Return to the Last Session After Restarting DSH

Preface

When developing Web interfaces or CLIs with DeepSeek Harness (DSH), after an engine restart, the interface often defaults to a blank session or a default page, requiring you to manually navigate through history to find the conversation you were just working on. Modifying the engine source code to remember the “last session” is difficult to maintain and conflicts with DSH’s “everything is a plugin” philosophy. The following is an introduction to the community plugin dsh-gui-last-session (maintainer itchenshi): without touching engine files, it persists a pointer on the host side and records/recovers on the page side, automatically opening the session you were viewing before leaving whenever possible after a restart.

What is this

dsh-gui-last-session is a “memory” class plugin for DSH, currently at version 0.1.9 (MIT). In short: it remembers the ID of the session you were in last and automatically calls open() to return to it once the engine and page are ready. The implementation relies on “host-side file writing + client-side switching listeners,” rather than patching the engine.

Repository: https://github.com/itchenshi/dsh-gui-last-session
Community Directory: https://www.skillhub.cn/plugins/itchenshi/dsh-gui-last-session

Core Features

The capabilities explicitly defined in the documentation are as follows:

  1. Page Recording and Restart Recovery
    The page side updates the pointer when you switch sessions; upon loading, it attempts to reopen the saved session.

  2. Ignores Blank Sessions
    There are two lines of defense to ensure unused blank sessions generated during engine startup are not written to the pointer, avoiding the continuation of an empty conversation.

  3. Waits for Session List to be Ready
    Before recovery, it polls until the target ID appears in the list (approximately every 150ms, for a maximum of about 30 seconds), avoiding failures from calling open() on an unknown ID.

  4. Quietly Gives Up if Target is Deleted
    If the remembered session has been deleted, the plugin does not force an open, preserving the engine’s own startup behavior.

  5. Does Not Record Sub-agent Sessions
    The recording logic skips subagent sessions.

  6. Migration from DSH Ready GUI
    When migrating from DSH Ready GUI, the GUI can hand over an existing pointer to the plugin; if the plugin already has a pointer, it will not be overwritten, allowing the original “previous session” to persist.

  7. Minimal State
    It only saves the session ID and timestamp in <DSH_HOME>/last-session.json, using atomic writes (temp file + rename).

Recording Priority (per README): Prioritizes the session currently displayed in the engine’s main view (retainedBy.mainView); otherwise, takes the most recently asked session.

Installation and Activation

This package has not yet been published to npm (searching registry.npmjs.org yields no results); you must use DSH plugin commands or a Release tarball.

DSH Ready GUI (Recommended)
The plugin is built into the GUI; check or uncheck it in Settings → “Third-party Plugins”. This is a plugin that includes a page side; refresh the page as prompted after installation.

Other Hosts (dsh web / CLI) Choose one:

# Recommended: Install directly from GitHub
dsh plugin --profile web add github:itchenshi/dsh-gui-last-session

# Alternative: Install from Release tarball
dsh plugin --profile web add https://github.com/itchenshi/dsh-gui-last-session/releases/download/v0.1.9/dsh-gui-last-session-0.1.9.tgz

Both commands will install the complete package containing cordis.patch.yml, and it will work without additional configuration after installation.

Typical Usage

After following the installation steps above:

  1. Restart the DSH engine.
  2. Refresh the Web page.
  3. No further action is needed: the page will attempt to return to the saved session upon loading; every time you switch sessions, the pointer will be updated.

To disable or debug logging, see the configuration section below.

Configuration

In cordis.patch.yml, the config under the line with id: gui-last-session is entirely optional:

Key Default Description
enabled true When false, the plugin returns immediately and does not register routes
quiet false When true, the activation process does not log

To override the configuration under a specific profile, add a line with the same id in that profile’s own cordis.patch.yml. Note: This will entirely replace the config; you must write out every key when overriding.

Compatibility and Runtime Environment

  • The manifest declares DSH >= 0.1.5-rc.2 and marks 0.1.5-rc.2 and 0.2.0-rc.2 as compatible.
  • Node >= 20.
  • The plugin itself does not enforce version number gating and relies on public service contracts (such as ctx.sessions); if the contract changes, the engine will report an error rather than failing silently.
  • Tests within the repository do not start a real engine, and end-to-end behavior is not automated in CI.

Use Cases and Notes

Who it is for
DSH users who frequently restart engines or refresh deployments and want the Web interface to immediately return to the previous conversation; especially when using dsh web or non-GUI hosts, it can be enabled separately using the installation commands in the official README.

Security and Permissions
The plugin runs with the permissions of the current DSH process; it is recommended to read the source code and MIT license before installation. The pointer is accessed via the host-provided GET/POST/PUT /gui-last-session and POST /gui-last-session/report, going through the engine’s trust fence (Host whitelist + browser session cookie); bare requests without cookies will get a 401. The documentation states that the plugin has no external network requests.

Troubleshooting
If the original session is not restored after a restart, check the application logs: successful recording will show [gui-last-session] pointer -> session-...; upon startup, there will be [gui-last-session] active (pointer: <DSH_HOME>/last-session.json). If recovery fails, the logs will distinguish between no pointer, target not appearing, or missing session opening interfaces (e.g., reopen: no usable pointer, reopen: FAILED — ..., reopen: giving up ...).

Conclusion

dsh-gui-last-session solves the repetitive labor of “finding the session after a restart” using a plugin approach: state is stored in a single last-session.json, and behavioral boundaries are clearly defined in the README. For details, Issues, or self-building, refer to the GitHub repository; the same plugin entry can be found in community directories like SkillHub (the directory is an independent site and has no official affiliation with DeepSeek / High-Flyer).

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

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

Xiaoye