Introduction¶
In a DSH session, once a prompt has been sent, it usually cannot be directly edited afterward. This forces developers to copy the text and regenerate it, which is inefficient. The dsh-undo plugin uses a rewind and forking mechanism to allow developers to return to any historical prompt and re-edit it.
Overview¶
dsh-undo is a plugin that provides an undo button and a side ruler for DSH sessions. It works based on the Cordis reversibility paradigm: the session log is the context, and undoing a prompt means restoring the previous context prefix (Withdrawal) without modifying the original log. It is maintained by tofe98 and released under the MIT license.
Core Features¶
The plugin provides two interaction methods:
-
↶ button in the session header
An undo button is displayed in the session header. Hovering over it shows a dropdown menu that lists the previous prompt trajectory (in reverse chronological order, with one entry per user or guide message). Selecting an entry forks the session before the boundary of that prompt, opens a child session, and pre-fills the prompt text. -
Left side ruler
A ruler is displayed on the left side of the conversation, with one tick corresponding to each user or guide message. Clicking a tick jumps to that message, and right-clicking a tick performs an undo operation (confirmation required).
Installation and Enablement¶
Install via the plugin marketplace or by running the following command directly:
dsh plugin --profile web add github:tofe98/dsh-undo
Typical Usage¶
- Send a few prompts in the session.
- Hover over the ↶ button in the session header and select an earlier prompt.
- The system opens a forked child session, rolls the conversation state back to the point before that prompt, and pre-fills the editor with the prompt text.
- Edit the text and resend it, or directly right-click the corresponding tick on the left side ruler to perform an undo (confirmation required).
Technical Notes¶
- Fork semantics: The original session remains unchanged, and an undo operation essentially creates a child session (Fork). According to the Cordis paradigm, this is called “Withdrawal” (restoration) and does not break the original log.
- Reconstruction mechanism: Child conversations are reconstructed through DSH’s projection machine.
- Side-effect preservation: External side effects from reverted turns (such as file edits or Web calls) are not undone. These side effects are outside the system boundary, and the plugin is only responsible for restoring conversation state.
- Implementation details: Undo calls
sessions.fork({ sessionId, atSeq: boundary })and usesinputActions.setDraftto pre-fill the text.
Conclusion¶
dsh-undo uses a forking mechanism to solve the pain point of being unable to roll back and edit in DSH sessions. It is suitable for developers who need to adjust earlier inputs in long conversations.
- Plugin catalog: https://www.skillhub.cn/plugins/tofe98/dsh-undo
- Source repository: https://github.com/tofe98/dsh-undo