dsh-html-live-preview: Inline HTML rendering in DSH conversations

Preface

When asking models in DeepSeek Harness (DSH) to produce a visualization page, the common approaches are to paste an ```html code block, or to put the preview in a side panel. The former only shows the source code, and the latter easily gets disconnected from the context of the current reply. If you want “the model writes HTML → the rendered result appears directly in the conversation stream, and after the turn ends the preview remains below that reply”, a plugin needs to hook into the Web side to mount the tool and the client-side rendering surface.

Below we introduce the community plugin dsh-html-live-preview (maintainer Weihong-Liu). It provides a render_html tool inside conversations, and renders it with an inline sandboxed iframe that auto-grows with the content and follows the DSH light/dark theme.

What is this

dsh-html-live-preview is a client-side class plugin for DSH: the model calls a tool, and the generated HTML is rendered as a card inside the chat—not as a code block, nor as a standalone side-panel. The npm package name and the repository name are both dsh-html-live-preview, the current published version is 1.0.1, and the license is MIT.

The plugin declares a peer dependency range of ^0.1.7-rc.2 || ^0.2.0-rc.1 on @deepseek-ai/dsh-tools; when the DSH runtime is outside that range it will refuse to load and report a version mismatch instead of crashing only on the first call.

Core features

All of the following capabilities come from the project README and the implementation notes.

Streaming preview. While the model is writing the render_html argument, the client decodes partial HTML from the not-yet-complete JSON, so the preview grows along with the argument stream without waiting for the entire tool call to finish.

Interactivity and scripts. After the call settles, the full markup is injected into the iframe, and each <script> runs once in document order; buttons, animations, charts, canvas, and so on work normally (subject to the sandbox and CSP, see below).

Still visible after the turn ends. DSH collapses tool rows into that turn’s process-disclosure area; the plugin re-renders the preview once at conversation.chat.turnTail, so it stays outside the collapsed area, under the corresponding reply. Each call corresponds to one iframe at a time.

Theme sync. The iframe inherits the host’s --dsw-* / --dsh-* design tokens and readable aliases, and updates in real time as the app switches between light and dark.

Failure visibility. Script errors and sub-resource load failures are shown below the card in a dismissible strip; if a recorded call falls outside the currently loaded session window, the card states this explicitly and cannot rebuild the preview.

Host side (index.js). Validates the call, sets the HTML fragment upper limit to 256 KiB, and returns a very short receipt; the HTML itself is stored in the recorded tool/call arguments, so reopening a session can replay the preview without taking extra storage or context.

Browser side (client.js). A classic script injected as a DSH client-module, with no build step. It renders at two mount points: tool.call.toolview (while the turn is in progress) and turnTail (after the turn ends); the iframe uses a fixed srcdoc to receive the document, and the model’s HTML is injected via postMessage, so streaming updates do not reload the entire page. During the streaming phase it strips scripts and on* attributes; in the final phase it injects the full markup again and waits for external scripts to load. The sandbox is sandbox="allow-scripts" without allow-same-origin; the in-frame CSP forbids fetch/XHR/WebSocket, and allows the specified CDNs (jsdelivr, unpkg, cdnjs, esm.sh) as well as inline scripts, images, and fonts, etc. The default preview height cap is 620px, and the card can be expanded up to 2400px; a ResizeObserver reports the content height (with a 60ms debounce).

Card controls (on hover). View the HTML source, copy, re-run scripts, expand the height.

Environment and requirements

  • Use the DSH web profile, i.e. launch the Web UI via dsh web (the README notes it has been verified on 0.1.7-rc.2 and 0.2.0-rc.1).
  • The plugin targets only the Web client (dsh.client.platform: web) and must be installed on the profile that runs the Web UI.

Installation and enabling

Install from the npm registry into the web profile:

dsh plugin --profile web add dsh-html-live-preview

You can also do the same in the Web UI’s Plugins; the installation will select the bundle, and it will be mounted on the next composition (HMR can hot-apply it).

If you want to link a development build from a local repository directory (you need to prepare the absolute path yourself):

dsh plugin --profile web add link:/absolute/path/to/dsh-html-live-preview

Open a new session after installing. Existing sessions still use the tool catalog from creation time; new tools will only appear in the catalog in the next session.

render_html is registered at the global layer of the tool registry, so every agent under that profile can call it without changing the agent preset.

Typical usage

Just describe the visualization need in natural language; for example, the README has these examples:

  • “Draw a bar chart of this week’s latency”
  • “Mock up a login page and make the button do something”
  • “Animate how quicksort partitions this array”

The model will call:

render_html({ html, title?, height? })

where html is the fragment to render; title and height are optional.

Use cases and limitations

Who it suits. Developers who need to quickly view model-generated static or lightly-interactive HTML inside DSH Web conversations (mock pages, simple charts, algorithm animation demos, etc.), and want the preview inline, themed, and still attached below the reply after the turn ends.

Security and permissions you must know. The plugin is loaded into the current DSH process; before installing you should read the GitHub repository source and the MIT license, and confirm you accept its sandbox policy (no network requests inside the frame; data must be inlined or pulled from the allowed CDNs).

Limitations explicitly listed in the documentation:

  • DSH has no extension point for custom Markdown code-fence rendering, so ```html remains an ordinary code block; you should use this plugin through a tool call.
  • Networking is intentionally disabled inside the iframe (connect-src 'none'); visualizations that depend on live APIs need to inline the data or use only libraries from the allowed CDNs.
  • When conversation-window truncation causes the call to fall outside the loaded range, the preview cannot be rebuilt.
  • After modifying the plugin’s own code you need to restart the DSH process (the client bundle and host module are cached per process); the profile manifest’s HMR does not cover this.

Verification and ecosystem notes

The maintainer has verified it on a real DSH Web instance with real model calls (see the repository’s screenshots/); there is also a standalone page test/harness.html for exercising client.js behavior locally.

The DSH ecosystem emphasizes “everything is a plugin”; the plugin directory site’s entry on SkillHub and the GitHub repository are community-maintained information sources, and have no official affiliation with DeepSeek / High-Flyer. If the peer version does not match the local DSH, you can follow the DSH prompt to use mechanisms such as dsh plugin allow-version, or follow compatibility updates in the repository’s issues.

After the steps above, once you install dsh-html-live-preview on the web profile and open a new session, you can get inline, sandboxed, streaming HTML previews that grow with the argument stream via render_html in conversations, without squeezing visualizations into a code block or a side panel.

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

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

Xiaoye