dsh-generative-ui: Rendering Interactive Generative UI in DSH Dialogue Flows

Preface

When chatting with an agent in DSH, the common practice is for the model to output only Markdown or plain text: things like counters, small forms, simple calculators, etc., either rely on the user copying HTML into a browser themselves to try, or require writing another frontend layer just to click and interact. DeepSeek Harness’s plugin system allows extending the conversation UI in the client; dsh-generative-ui (maintainer ttmouse, GitHub repository ttmouse/dsh-generative-ui) does the following: it allows the agent to write self-contained HTML using an agreed-upon fence in a single reply, and the client extracts these “artifacts” from the message and renders them as interactive cards in a sandboxed iframe below the message. The implementation is purely client-side, with no backend, no additional storage; the artifacts live within the conversation message text.

Below we introduce what it is, how to install it, how the agent should write fences, and the constraints on layout and security.

What Is This

dsh-generative-ui is a client-side plugin for DSH (npm package name @ttmouse/dsh-generative-ui, current version 0.2.2, license MIT). It solves the problem of directly displaying interactive Generative UI within the conversation flow, rather than only showing static descriptions.

Runtime environment requirements (from package.json): DSH >=0.1.5-rc.2.

Architecturally it splits into two halves (README Design section):

  • Host half: Broadcasts the convention of “writing artifacts using generative-ui fences” to each agent via systemPrompt.section.
  • Browser half: Uses the uiConversation.events accumulator to extract artifacts from assistant/message events (a turn-accumulator similar to dsh-taskboard), attaches them to the current message position, and renders the cards via the conversation.chat.turnTail slot.

No separate state storage: artifacts are in the session messages; as long as the conversation exists, they exist; there is no second copy of state to sync.

Core Features

Fence Convention and Rendering

The agent writes a fenced code block in its reply, with the language marker generative-ui, and the content is self-contained HTML (can include inline <script>). The plugin extracts all such blocks from the current turn’s response and renders each as a card below the message.

The minimal example in the documentation (counter):

```generative-ui
<!-- title: Example: counter -->
<button id="plus">+1</button> <span id="n">0</span>
<script>let n=0;plus.onclick=()=>{n++;n.textContent=n}</script>
```

The README screenshot description shows that multiple cards can appear side by side in the same conversation (e.g., a counter and a BMI calculator).

Sandbox iframe

Each card corresponds to a bare iframe document, using:

<iframe sandbox="allow-scripts">

This means scripts are allowed but no same-origin: the artifact is interactive but cannot access the host page, cookies, or localStorage.

Adaptive Height

A bootstrap is injected into each artifact: it reports height to the parent page via ResizeObserver and postMessage; card height is limited to 120–600px, and anything beyond scrolls within the card.

Runtime Design System

Artifacts are bare iframe documents with no default font or spacing resets. The plugin inlines DESIGN_SYSTEM_CSS into the <head> to constrain generated results at runtime, rather than only verbally requesting it in the prompt. Key points include:

  • Use surface levels like --gui-surface-1/2/3 to distinguish regions, rather than relying on borders.
  • Three font sizes: --gui-fs-title(18), --gui-fs-body(14), --gui-fs-caption(12).
  • Spacing and radius tokens: --gui-gap(12), --gui-pad(16), --gui-radius(12), etc.; utility classes like .gui-stack, .gui-card, .gui-chip are provided.
  • Buttons have primary styling, focus rings, ~44px touch height; animations prefer transform/opacity, and consider prefers-reduced-motion.

The same set of rules is provided as text in GENERATIVE_UI_GUIDANCE for the model to reference.

Source Audit (Non-Blocking)

auditArtifactSource(source) can report violations (e.g., border, shadow, gradient, blur, body-spacing, comment, em-dash, buzzword, pure-color, etc.), but will not block rendering because of them.

Installation and Activation

The official README installation steps are as follows. Note that the command uses link:<this-directory>, indicating a link installation to the local plugin directory, not constructing github:owner/repo from the repository name.

dsh plugin --profile desktop add link:<this-directory>

Then add @ttmouse/dsh-generative-ui to dsh.profile.bundles in the profile’s package.json, and restart the Desktop app (the host half registers the system prompt section; client.js reads from disk per request).

Client script changes take effect by refreshing the page; host-half (system prompt text) changes require restarting the app.

If you want to modify the plugin itself, the in-repo development workflow is:

npm install && npm run build       # produces lib/client.js + lib/index.mjs
npm test                           # unit + e2e (headless Chromium)
npm run screenshot                 # regenerates screenshot.png from the real client

Typical Usage

  1. Complete the link installation, bundles configuration, and Desktop restart as described in the previous section.
  2. In the conversation, have the agent output generative-ui fences according to the convention; an optional HTML comment <!-- title: ... --> serves as the card title.
  3. After sending, view the rendered interactive card at the tail of that assistant message and interact within the iframe sandbox.

The fence content should be self-contained HTML (styles and scripts can be inline); complex UIs should preferentially use the design system tokens and utility classes injected by the plugin to reduce conflicts with auditArtifactSource.

Use Cases and Considerations

Who It’s For

  • Developers who need to quickly prototype small tools, forms, or visual prototypes in a DSH conversation without starting a separate frontend project.
  • Those who want the agent to output “clickable and calculable” UI, and accept that state exists only in the current conversation message.

Security and Trust

  • The plugin runs with the permissions of the current DSH process and browser environment; before installing, you should read the GitHub source code and the MIT license to confirm it meets your security policy.
  • The sandbox limits the iframe’s access to the host page; scripts within the fence still execute within the iframe, so do not allow untrusted models to output unreviewed executable content.

Ecosystem Notes

DSH emphasizes “everything is a plugin”; the community catalog dsh-generative-ui page on SkillHub is an independent site with no official affiliation with DeepSeek / High-Flyer.

Conclusion

dsh-generative-ui consolidates Generative UI into a reproducible convention: generative-ui fences + client-side extraction + sandboxed card rendering, purely client-side, zero backend. For categories and introductions, see the catalog page skillhub.cn/plugins/ttmouse/dsh-generative-ui; details and examples are authoritative in the GitHub README.

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

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

Xiaoye