Introduction

When developing agents in DSH, a common problem arises: a single instruction triggers multiple rounds of modifications, and the workspace code moves forward together with the session context. If the result of a step does not meet expectations, it is quite troublesome to manually organize git history and then handle the session branch separately.

dsh-rollback-withdraw provides a path for this point: recording rollback points at the boundaries of completed rounds. After clicking the undo icon next to a message, it simultaneously restores the workspace code and forks the session to before that boundary.

The following introduces its positioning, capabilities, installation, and the boundaries that need attention.

What is it

dsh-rollback-withdraw is a DSH web-profile plugin maintained by dyhyfjn, licensed under MIT. It provides a Trae-style withdraw experience: providing a rollback button under the user bubble and under the last assistant message of each completed round, used to restore workspace code and rollback the session to the last completed round.

It is suitable for users who are already using the DSH web-profile and want to perform “code rollback + session fork” as a single-step operation. Runtime requirements: Node >= 20. Currently prioritized for Windows, using robocopy and PowerShell 5.1+; other platforms are planned.

Core Features

Undo Entry for Every Message

  • A rollback button is provided under the user bubble.
  • A rollback button is also provided under the last assistant message of each completed round.

Automatic Selection of Two Recovery Backends

The plugin will select from available backends:

  • Git Mode: When the workspace is a git repository, a commit is made at the end of each round with the message rollback checkpoint <seq>; rollback uses git reset --hard and git clean, preserving ignored directories.
  • File Snapshot Mode: A hard-link snapshot is created at the end of each round; unchanged files share a single copy between snapshots.

The meanings of Git mode related commands are as follows:

git reset --hard
git clean

Workspace-level Git Auto-commit Switch

The default configuration item is:

{
  "gitAutoCommit": true
}

When the workspace is a git repository, the plugin uses git commits as rollback points. The switch is persisted at:

.dsh-rollback/config.json

Auto-loading and Two-step Confirmation

  • The plugin loads automatically as a web-profile bundle; it takes effect when the client starts and does not need reactivation after restart.
  • Rollback uses two-step confirmation: the first click enters the arm state, and the second click executes the rollback.

Installation and Enablement

Installation command:

dsh plugin --profile web add dsh-rollback-withdraw

This command adds the plugin to DSH’s web profile. After changes to the plugin collection or plugin settings, the web app needs to be restarted for the plugin settings to take effect; since it loads as a web-profile bundle, it takes effect automatically after the client starts.

Requirements here:

Node >= 20

The current plugin prioritizes the Windows platform, with dependencies:

robocopy
PowerShell 5.1+

Typical Usage

  1. Conduct a normal session with the agent. After each completed round, the plugin automatically records a rollback point.
  2. Hover over a message and click the undo icon. The first click enters confirm/arm mode, and the second click executes.
  3. After the workspace is restored, the UI switches to the forked and rolled-back session, from which you can continue.
  4. If you want to toggle the Git auto-commit switch, modify the workspace-level settings and restart the web app for the changes to take effect.

Applicable Scenarios and Notes

Applicable Scenarios

  • Using the DSH web-profile on Windows.
  • The workspace can be a git repository or a non-git directory.
  • Need to quickly rollback code and session when used locally and by a single person.

Rollback Boundaries

  • Forks can only be cut at round boundaries; rolling back an assistant response will also rollback the preceding user questions.
  • The first message in the session cannot be rolled back.
  • Messages before the plugin installation do not have snapshots.
  • The source session is retained in the sidebar as a branch and is not automatically archived.

File Deletion and Ignored Paths

Git mode executes the following for the entire repository:

git reset --hard
git clean

Ignored directories are preserved; untracked and non-ignored files will be deleted during rollback.

The following paths will not be snapshotted, committed, or deleted:

node_modules
.git
dist
build

Security Boundaries

The plugin’s client and host communicate via the following route:

/rollback/rpc

This route is a localhost same-origin, unauthenticated route, assuming personal local use. Do not expose the DSH harness port to untrusted networks.

The plugin executes repository-level git commands and reads/writes workspace files, so it runs with the permissions of the current dsh process. It is recommended to check the source code, license, and actual workspace content before installation.

Links

  • Community Directory Page: https://www.skillhub.cn/plugins/dyhyfjn/dsh-rollback-withdraw
  • GitHub: https://github.com/dyhyfjn/dsh-rollback-withdraw