Introduction¶
In the DeepSeek Harness (DSH) Web chat input box, copying long logs, stack traces, or API responses can turn the input area into a hard-to-read wall of text. The dsh-paste-code-block plugin addresses this visual clutter by converting pasted content into structured “chip” cards. It leverages DSH’s hidden reference mechanism to keep the content editable and recoverable while maintaining a clean input interface.
Plugin Overview¶
Name: dsh-paste-code-block
Author: cjm-m
Category: Fun Skins
License: MIT
This plugin is a port of a Cherry Studio-style paste feature, tailored for the DSH Web environment. It automatically folds pasted text or code into bordered, collapsible cards with language labels. When sending a message, the original content is automatically restored as a fenced code block; in the conversation history, these code blocks remain collapsed and are displayed only as expandable cards.
Core Features¶
-
Automatic Block Detection
The plugin detects text that contains line breaks, is longer than 96 characters, has densely packed curly braces, or includes fenced markers (``` ). If any condition is met, the text is treated as a code block; otherwise, ordinary short text passes through directly. -
Language Labels and Smart Numbering
It automatically recognizes languages such as Python, JS, JSON, YAML, SQL, bash, HTML/XML, C++, Go, and Ruby (including shebangs). Pure text blocks are labeled astext. Code blocks and text blocks are counted separately, and numbers are automatically recycled from unused IDs. -
Editing and Removal Inside Cards
Clicking a chip expands the card, supporting inline editing, copying, and collapsing/expanding. A×button in the upper-right corner of the card removes that block with one click and releases its number. -
Sending and Restoring
After clicking Send, the content is sent as a complete fenced code block. If sending fails, the input box automatically restores the original content. -
Collapsed Display in Conversations
Sent messages remain collapsed in the conversation stream and are displayed as cards similar topython · 128 lines. Click the header to expand and read it; click again to collapse it. -
Localization Support
Card names follow the DSH interface language (Chinese/English), for example代码块 1orCode #1. When the language is changed in settings, existing card names are updated in real time.
Installation and Enablement¶
The plugin is published via npm. Use the following command to install it:
dsh plugin --profile web add dsh-paste-code-block
After installation, restart the dsh web process to load the plugin.
Usage Steps¶
- Copy: Copy any code or multiline text from anywhere.
- Paste: Paste it into the DSH input box. The content is automatically folded into a chip (for example,
代码块 1). - Manage cards: Click a chip to open the card. You can read it, edit it inline, or click
×to delete it. Deleting immediately recycles the number. - Send: Send the message. The original content is sent as a fenced code block.
- View history: In the conversation history, code blocks are displayed as collapsed cards. Click the header to expand them.
Notes¶
- Draft safety: Blocks are appended to the end of the draft and use DSH’s hidden reference mechanism, which keeps cursor positioning and undo operations stable. Creating a block does not leave extra spaces before or after it.
- Plain text handling: Pure text blocks are wrapped in
textfences when sending, preventing the text from being squeezed into a single line. - Deletion mechanism: Deleting by clicking
×or pressing Backspace releases the number. Deletion is a normal editing operation and supportsCtrl+Zundo. - Display and storage: Post-send collapsing is only a display style and does not modify stored message content. Draft restoration depends on a
localStoragemirror (if the browser disallows local storage, only same-tab switching is supported).