dsh-plugin-open-in-browser: Open Sidebar Files in the System's Default Browser

Preface

When using the sidebar in DSH to preview HTML, PDFs, or images, the built-in preview is often sufficient; however, once a page relies on fetch, ES modules, absolute paths, Service Workers, or a real origin, the sandboxed iframe (srcDoc/blob) often goes blank. Some formats simply cannot be previewed, and the sidebar only displays “Cannot preview this file.” Opening the file in the system’s default browser is the most direct solution for relative path resources and origin-dependent APIs.

Below is an introduction to the community plugin dsh-plugin-open-in-browser (maintainer haoqiya138-source): It allows you to hand the current file to the system default browser with one click from the right-click menu of the sidebar tab chip, or from the “Cannot preview” empty state, rather than getting stuck in the in-app preview.

What is this

dsh-plugin-open-in-browser is a Cordis plugin for the DSH desktop client, with the npm package name dsh-plugin-open-in-browser (refer to npm and the repository’s package.json for the current released version). It does not provide generic entries like “Open with editor / Git GUI”—DSH’s built-in @deepseek-ai/dsh-host-open-in-app already covers “Open in app” for the document preview area. This plugin does exactly one thing: Open workspace files from the sidebar in a browser, and supplements the tab menu entry so that files can still be opened when preview fails.

The plugin is categorized as a Client in the DSH Community Plugin Directory; source code and documentation are available in the GitHub Repository (MIT License).

Core Features

The plugin package registers two UI Seats, corresponding to two types of entries:

Seat Location Info provided by Host
sidebar.right.tab.document.unpreviewable “Cannot preview this file” empty state Host path of the file (absolutePath)
sidebar.right.tab.menu.item Right-click menu of sidebar tab chip Only the tab’s contentId (dsh-resource://file/session/…)

It intentionally does not register sidebar.right.tab.document.actions. When the preview is working normally, the document area title bar already has preview controls; adding an “Open in browser” button next to them yields little benefit, whereas the tab chip right-click menu is available for all tabs and is accessible in one step. More importantly: when a third-party preview returns an error (e.g., HTTP 405), the built-in preview might not be able to read the complete metadata, leaving the document area without an absolutePath. However, the tab menu still holds the dsh-resource://… address, which is sufficient to resolve, validate, and open the file.

In the opening flow, the client sends a request to a fixed route registered by this plugin’s Host half:

POST /dsh-plugin-open-in-browser/open
content-type: application/json

{ "path": "C:\\Users\\me\\project\\preview.html" }
{ "address": "dsh-resource://file/session/<sessionId>/pages/preview.html" }

The address is generated by the tab menu: the Host constructs the relative path based on the Session workspace root directory and performs security validation. On success, it returns { ok: true, mode: "browser" | "association", path }; on failure, it returns { ok: false, code } with a 4xx/5xx status.

The Host resolves the user’s actual default browser (on Windows, via Registry UserChoice → ProgId → command line, supplemented by common installation paths; falling back to system file associations only if necessary). For images, PDFs, etc., the built-in session.openWorkspacePath Remote often relies on system associations (e.g., opening .png with “Photos” on Windows), whereas this plugin explicitly prioritizes using the browser whenever possible. If the Host route is unavailable (old version or Host half not deployed), the client falls back to calling that Remote to avoid the control becoming completely non-functional.

The security layer is shared between the Host and Client sides: absolute path checks, path traversal/UNC/device name rejection, extension whitelists, workspace containment, symlink escape detection, and dsh-resource://file/… address resolution (implementation details can be found in src/security.ts in the repository).

Installation and Enablement

The released package includes pre-built artifacts in dist/. Installation requires no local building, and there are no runtime npm dependencies.

Install from npm (Recommended method in README):

  1. Open DSH → Plugins → Add Plugin.
  2. Enter the package name dsh-plugin-open-in-browser.
  3. Completely exit and reopen DSH to load the new Host half and Client artifacts (the module loader caches client bundles).

Equivalently, you can install it using the plugin tool:

plugin_manager  action=install_bundle  target=dsh-plugin-open-in-browser

If installing from a local checkout directory (which contains dist/):

plugin_manager  action=install_bundle  target=<absolute path to checkout directory>

Environment Requirements: Requires the DSH Desktop App (the Host must be able to launch local programs). In remote / SSH deployments where there is no launchable desktop browser, the control will display a clear prompt instead of silently failing. Node ≥ 20 is only required for building from source; using the npm package for daily usage does not require local Node.

After installation, updates, or local rebuilds, you should also completely exit and reopen DSH.

Typical Usage

  1. Open an HTML tab in the sidebar; if the built-in preview is blank or reports an error, right-click on the tab chip and select the “Open in browser” item provided by the plugin (refer to meta.title in the plugin’s locale/zh.json for the specific text).
  2. If the file type cannot be previewed and the sidebar displays “Cannot preview this file”, use the same capability on the empty state (this utilizes the absolutePath entry).
  3. The system default browser will open the validated workspace file path; complex HTML loads relative resources under a real origin, and the behavior differs from the DSH sandbox preview, which is expected.

When developing the plugin locally, the README recommends running npm run build and npm test first (covering the security layer, browser resolution, Host routing, and client bundle with node:test), and then verifying via install_bundle pointing to the checkout directory.

Scenarios and Notes

Suitable for: Debugging sidebar HTML/static sites in a real browser; scripts or modules that the preview iframe cannot satisfy; PDFs, images, etc., when preview fails or when you prefer to view them uniformly in a browser; scenarios where the tab is open but the document preview seat cannot render due to metadata errors.

Not suitable for or limited: Remote sessions without a desktop environment; when you prefer to open with the system default “Image Viewer” rather than a browser—this plugin prioritizes the browser, which differs in positioning from the built-in open-in-app. You can install the official open-in-app plugin alongside it as needed.

Security and Trust: The plugin’s Host half registers an HTTP route within the DSH Host process and launches an external browser. Paths and addresses undergo whitelist and workspace boundary validation, but access to workspace files is still performed with the current DSH process permissions. Before installing, please review the Source Code and the MIT License to ensure compliance with your security policies. The community directory skillhub.cn has no official affiliation with DeepSeek / Hithink RoyalFlush; the plugin is community-maintained.

Ending

dsh-plugin-open-in-browser utilizes two entries—the tab right-click menu and the “Cannot preview” state—to hand sidebar files to the system default browser with one click. It specifically addresses preview failures, sandbox limitations, and the differences between OS file associations and “Open with browser”. For installation or source code, please visit the Community Directory Page and the GitHub Repository.

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

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

Xiaoye