dsh-image-preview: Inline Preview of Local Images and Videos in DSH Web Chat

Introduction

When collaborating with the assistant in DeepSeek Harness (dsh), absolute paths to local images or videos often appear in the replies. By default, these paths are just a line of text: they cannot be previewed and are inconvenient to open with system default applications. Manually copying the path to the file manager or player involves many steps and interrupts the train of thought. dsh-image-preview addresses this scenario: automatically converting real local media paths in the Web conversation body into inline images or playable videos, while retaining a clickable local address line below the media. Below is an introduction to the plugin’s positioning, capability boundaries, installation method, and working principle.

What is this

dsh-image-preview is published by community maintainer DSH43, classified as a client plugin (containing both host-side routes and Web client scripts). Repository address: https://github.com/DSH43/dsh-image-preview; Community directory page: https://www.skillhub.cn/plugins/DSH43/dsh-image-preview. It is installed as a regular profile dependency and does not enter the dsh bundles layer.

One-sentence positioning: Wraps llm/stream, scans for local media absolute paths in the assistant’s reply, and rewrites them into same-origin loopback URLs; registers three routes for reading images, reading videos (supporting HTTP Range), and opening locally; the client is responsible for the <video> player, styles, and click interception.

Core Features

Images

Supported extensions: png, jpg, jpeg, webp, gif, svg, avif, bmp, ico. Single file limit 20MB, or consistent with the attachment service’s maxImageBytes. Paths in the conversation will be displayed as large images, with a small local path line below; clicking the address line opens it with the system default application (macOS open, Windows start, Linux xdg-open), and the client intercepts the link to prevent opening a new browser tab.

Videos

Supported containers: mp4, m4v, webm, mov, ogv (native encodings playable by browsers; mkv, avi, etc., are not within the scope of inline preview, but the address line click can still open them with a system player). Single file limit 512MB. Paths in the assistant’s reply will be replaced by a <video> player with controls, allowing progress bar dragging; the host side /video route parses the Range header and returns a 206 partial content response.

Persistent Token & Fallback

Media access tokens are persisted in $DSH_HOME/plugins/dsh-image-preview.token (file permissions 600), and inline links remain valid across dsh restarts. When there is no client module: images might display the original image in a new tab, and videos might play directly in a new tab; when there is client.js, clicking /open only triggers a local open.

Design Boundaries (Must Read)

  • Only handles streamed text of the assistant’s reply (llm/stream); paths inside tool result cards are not rewritten.
  • Only handles real existing local absolute paths (POSIX /..., Windows drive letters, UNC); http(s), data:, file:, and relative paths are not rewritten.
  • The placeholder text for links rewritten by the host is in English; when the player fails to load and falls back to a link, the client displays “Play video / Play video” based on the ctx.locale imagePreview namespace.

Installation & Enablement

Install as a regular dependency in the dsh web profile directory:

cd ~/.dsh/profiles/web
pnpm add github:DSH43/dsh-image-preview

Append the loader entry in the user patch layer ~/.dsh/profiles/web/cordis.patch.yml:

- insert:
    - id: dsh-image-preview
      name: dsh-image-preview

After restarting dsh web, refresh the browser page. To uninstall, run pnpm remove dsh-image-preview in the same profile and delete the corresponding insert block in cordis.patch.yml.

Other machines can be installed by tag, e.g., pnpm add github:DSH43/dsh-image-preview#vX.Y.Z; for an already installed environment, use pnpm update dsh-image-preview to pull the latest code from the default branch, then restart and refresh the page.

Typical Usage

No additional configuration items are needed. When the assistant outputs an absolute path to an image or video that already exists locally in the reply, it will be automatically rewritten when the streamed text block ends. For example, if the assistant outputs:

/home/user/screenshots/demo.png

The user side will see an inline image, and a clickable /home/user/screenshots/demo.png line below it. The same applies to video paths: the host writes them as “▶ Play video” links first, and the client then replaces them with inline players.

Working Principle Summary

  1. Rewrite: When the llm/stream text block ends, scan for paths, validate file existence, and rewrite them into image, video, or open query parameter links under http://127.0.0.1:<port>/plugins/dsh-image-preview/ (containing token and encoded path).
  2. Read Image / Read Video / Open: After validating the token, read bytes via ctx.fs; videos support Range; /open spawns the system default application and redirects (302) to the corresponding media route.
  3. Boot Shell: index.js dynamically loads host.js as a sub-plugin to avoid the entire plugin tree boot failure due to host loading failure; host.js carries the rewriting and routing logic, while client.js is responsible for styles, players, and click interception.

Changes take effect: index.js / host.js require restarting dsh web; client.js only requires refreshing the page.

Use Cases & Notes

Who is it for: Developers running dsh web locally who want to directly preview screenshots, screen recordings, or generated image paths mentioned by the assistant in the conversation; scenarios where only local absolute paths matter and remote URL inlining is not a concern.

Security & Permissions: The three routes are authenticated solely by a local token; any local process capable of reading $DSH_HOME/plugins/dsh-image-preview.token can access the media routes; it is designed for local loopback use only—do not expose dsh to the public internet. The plugin reads files and executes open/start/xdg-open with the current dsh process permissions; please review the repository source code and the MIT license before installing.

Known Limitations: Markdown links may break if the path contains characters like (, ), [, ]; Windows/Linux open commands have been implemented, but the maintainer’s documentation indicates that testing is primarily done on macOS. Special characters or very large files in paths may require manual judgment.

Conclusion

dsh-image-preview turns “local media paths output by the assistant” into images viewable directly in the conversation and videos draggable, while retaining a one-click path line to open with system applications. Changes are focused on the assistant’s streamed body and do not touch tool cards. Current package version is 0.2.2, license MIT. Directory page: https://www.skillhub.cn/plugins/DSH43/dsh-image-preview; Source code and full documentation: https://github.com/DSH43/dsh-image-preview.

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

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

Xiaoye