@xsj/dsh-rewind: DSH Session Rewind to Arbitrary User Messages

Preface

In a DSH session, after a user message is sent, subsequent content continues along that message thread. If you want to reorganize input from a particular user message without breaking the existing session log, and without losing the rollback state after a process restart, you need a plugin that performs rollback at the session level.

@xsj/dsh-rewind provides this capability: select any user message, truncate that message and everything after it from both the chat view and the model context; the message text returns to the input box, where it can be edited or cancelled; once sent, the model only sees the truncated history and the new message.

Plugin Positioning

@xsj/dsh-rewind is a DSH session rollback plugin, maintained by XSJUSTC, licensed under MIT.

It is provided as a permanent bundle plugin, containing both a host half and a web client half, with no npm dependencies. Repository address:

https://github.com/XSJUSTC/dsh-rewind

Core Capabilities

This plugin provides a rollback entry point in DSH’s Web client session, with the following primary capabilities:

  1. A rollback icon appears in the action row of each user message.
  2. If the model is thinking or streaming, clicking rollback immediately interrupts the current turn.
  3. The selected message and all content after it are hidden in the chat view.
  4. The text of the selected message is automatically filled into the input box, unsent and editable.
  5. While the rollback is pending, a prompt banner appears above the input box.
  6. A “Cancel Rollback” entry appears to the left of the send button; clicking it restores the hidden messages, keeps the draft unchanged, and sends nothing.
  7. After sending, the rollback takes effect, and the hidden messages no longer appear in the chat view or the model context.
  8. Only user messages can be rolled back; DSH assistant messages have no rollback entry.
  9. The session log remains an append-only event stream and never deletes original messages.
  10. After a process restart, opening the session causes the Host half to replay rollback records and rebuild the hidden range.

Installation and Activation

The plugin requires a Node.js environment satisfying:

engines.node >=20

The Client half obtains the following modules from the shell’s frozen module table via window.__ModuleLoader__:

react
@deepseek-ai/dsh-client-ui-primitives
@deepseek-ai/dsh-client-ui-attachment

To install, first clone the repository locally, then run the following command in any directory:

dsh plugin --profile web add <absolute path to this repository>

Here, <absolute path to this repository> is a placeholder that needs to be replaced with the cloned location of this repository on your local disk.

After installation, restart the DSH process and refresh the browser page.

Usage Flow

  1. Open a session in DSH’s Web client.
  2. Locate any user message and click the rollback icon in its action row.
  3. If the model is thinking or streaming, clicking rollback immediately interrupts the current turn.
  4. The selected message and all content after it are hidden from the chat view.
  5. The text of the selected message is filled into the input box; it has not been sent yet and can be further edited.
  6. If you decide to abandon the rollback, click “Cancel Rollback” to the left of the send button; the hidden messages are restored, the draft remains unchanged, and nothing is sent.
  7. If you confirm the rollback, simply send the current message in the input box.
  8. After sending, the hidden messages no longer appear in the chat view and will not enter the model context again.

Logging and Restart

This plugin does not delete original messages from the session log. The session log remains an append-only event stream.

Each state change appends a hook/invoked event, with a payload containing:

source: 'xsj.rewind'
phase: 'mark' | 'cancel' | 'commit'
targetSeq
hiddenFrom?
hiddenTo?
preview?

This hook/invoked event type belongs to the known reserved terms for this build, has no read/write side, and is safe for reloading.

After a process restart, opening the session causes the Host half to replay these records and rebuild the hidden range, keeping the hidden state consistent across restarts between the model side and the UI side.

Uninstallation

Run:

dsh plugin --profile web remove @xsj/dsh-rewind

Then restart DSH to complete the uninstallation.

After uninstallation, existing rewind records in the session log are harmlessly retained.

Usage Notes

  1. Only user messages can be rolled back; DSH assistant messages have no rollback entry.
  2. This plugin intervenes in the DSH session’s chat view and model context; it is recommended to review the source code, dependencies, and MIT license before installation.
  3. The plugin runs with the current DSH process privileges; its runtime environment and repository source should be verified as trustworthy.
  4. The path in the installation command must point to the local repository clone location; writing only the repository name is not sufficient.
  5. Rollback can be cancelled at any time while pending; cancellation does not send any content.

Summary

The value of @xsj/dsh-rewind lies in providing recoverable rollback capability for user messages in DSH sessions: you can re-enter input from any user message, cancel before sending, and have the truncation take effect after sending, while preserving the append-only session log and restoring the hidden range after process restarts.

Repository address:

https://github.com/XSJUSTC/dsh-rewind
羽毛球分组比赛记分
小程序二维码

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

Xiaoye