dsh-subpages: Mounting Independent Dashboards and Unified Portals on the Same DSH Port

Introduction

When running Harness on DSH, it is common to build extra small web apps: todo summaries, usage statistics, or internal tool panels. The usual approach involves spinning up an extra port, configuring a separate domain, or writing another login system. The DSH client itself lacks a bookmarkable, deep-linkable frontend router, making state management prone to loss after a refresh.

dsh-subpages (maintained by SJTUMalPan) is a client-side plugin for DSH. It reuses the prefix routing on the DSH webServer (default /subpages) to provide a gateway and unified portal, mounting subpages developed in independent repositories. Requests pass through DSH’s existing authentication first, eliminating the need to open separate ports or expose new attack surfaces for new pages.

What is this

In one sentence: A DSH Dashboard Host — it turns independently developed small web apps into “dashboards” within DSH, sharing the DSH port and login session, accessible via a unified portal.

Core Capabilities

Gateway and Portal

Accessing /subpages/ on the DSH port (e.g., :3080) in a browser enters the portal shell: navigation bar, iframes, and hash routing. Public frontend assets are located at /subpages/_assets/* (including subpage.css); the mounted list is provided by /subpages/_api/pages. Every /subpages/<id>/* request is forwarded to the dashboard backend or static directory only after passing DSH authentication (connection.requestRejection).

Browser ──> DSH :3080 /subpages/             Portal Shell (Nav + iframe + hash routing)
                   /subpages/_assets/*       Public Frontend Libs (subpage.css)
                   /subpages/_api/pages     Mounted List (used by shell)
                   /subpages/<id>/*   ──►    Dashboard's own http service (127.0.0.1:<port>)

Portal URLs like /subpages/notify-hub/todos are bookmarkable, support deep linking, and retain state across refreshes — this compensates for the limitations of the DSH client’s own routing.

Two Dashboard Forms

  1. Proxy Mode: target in subpage.json is http://…; the host reverse proxies to the local service. Optional health check (default /healthz).
  2. Static Mode: target is a directory path; the host serves files directly and performs realpath boundary checks against ../ and symbolic links.

Style Strategy: style can be inherit (default, host injects common styles into the portal HTML) or standalone (no injection). Static pages can link the stylesheet themselves:

<link rel="stylesheet" href="/subpages/_assets/subpage.css">

The common style is based on Pico 2 classless + dark tokens + sp-* component classes (.sp-page, .sp-card, etc.).

Mounting Methods

Directory Scanning: Place subpage.json under pages/<id>/ inside the plugin package; you can also point to an independent dashboard repository via submodule (git submodule add <dashboard-repo> pages/<id>, with the manifest placed in the dashboard repo’s root. See pages/README.md in the repo for details). Restart dsh web — no host code modification required.

Runtime Registration (for other DSH plugins):

await ctx.subPages.register({ id: 'x', title: 'X', target: 'http://127.0.0.1:9000' })
ctx.subPages.list()
ctx.subPages.unregister('x')
ctx.subPages.mountPath     // '/subpages'

Downstream Authentication (Tokens Not Distributed)

Optional auth: Reads tokens from tokenEnv or tokenFile + tokenPath, and injects them into forwarding via header/scheme or queryParam; browser-side ?token= is stripped before forwarding. The host can also hold downstream session cookies on behalf of the user, so the browser neither sees the token nor obtains downstream cookies. Tokens do not appear in manifest JSON, HTML, or visible URLs (the repo includes corresponding tests).

Bundled Example Dashboards

The two submodules under pages/ demonstrate proxy + standalone and static + independent styling respectively:

Dashboard Repo Form
Todo notify-hub Proxy
Usage dsh-usage-stats Static Single File HTML

Optional: Startup Notice

When startupNotice is configured, DSH can deliver a tokenized access link to notify-hub (which then forwards to Feishu, etc.) at every startup. Explicit enabled: true and publicHost configuration are required; the token is read from the new banner in the startup logs. Delivery is skipped if publicHost is not configured.

Installation and Activation

Installation commands are based on the README:

# Local dev (symlink, changes take effect immediately)
dsh plugin --profile web add "$PWD"     # Run in repo root

# Install from GitHub (can also install directly from plugin market)
dsh plugin --profile web add github:SJTUMalPan/dsh-subpages

# Lock commit (reproducible)
dsh plugin --profile web add "git+https://github.com/SJTUMalPan/dsh-subpages#<sha>"

Restart dsh web after installation. A “Dashboards” button will appear at the bottom of the sidebar.

Uninstall:

dsh plugin --profile web remove dsh-subpages

Typical Usage: Mounting a Proxy Dashboard

Create a directory under pages/ and place a subpage.json (refer to the README table for fields):

{
  "id": "notify-hub",
  "title": "Todo",
  "icon": "inbox",
  "order": 10,
  "target": "http://127.0.0.1:8000",
  "health": "/healthz",
  "style": "standalone",
  "auth": {
    "tokenFile": "~/notify-hub-run/config.yaml",
    "tokenPath": "server.auth_token",
    "queryParam": "token"
  }
}

target is required; if id is omitted, the directory name is used (must be kebab-case). The downstream service must be listening on the corresponding local port and started; otherwise, the portal will display “Dashboard Offline”.

You can modify plugin config in the profile (or cordis.patch.yml):

- id: subpages
  config:
    mountPath: /subpages
    pagesDirs: [/abs/extra]
    requestTimeoutMs: 15000
    probeTimeoutMs: 2000

Use Cases and Notes

Suitable for: Users who already have or plan to maintain small panels in independent repos, wanting to share the DSH Web port and login; requiring real URL deep links; hoping for unified portal and static page styling without an extra design system.

Trust Model (Read before mounting): Mounting a dashboard implies letting its frontend run under the DSH Origin. The portal iframe uses allow-same-origin allow-scripts, meaning dashboard scripts can access DSH Cookies, storage, and HTTP interfaces, and can manipulate the parent window DOM. Only mount dashboards you trust and have audited; third-party code should be deployed on an independent origin and integrated cross-origin. This plugin does not provide cross-origin isolation.

Process and Permissions: The plugin runs with the permissions of the current DSH process; read the source code and MIT license before installing. Understand the semantics of auth, forwarding header whitelists (browser cookie/authorization are not passed to downstream), and “sharing process-level downstream sessions across the same dashboard”.

Troubleshooting Quick Check:
- No “Dashboards” button → Confirm plugin is installed in the profile and dsh web has been restarted.
- “No dashboards mounted yet” → Check pages/ and subpage.json.
- Link jumps to gateway 404 → Downstream service should not use absolute URL redirects.
- 401 → Refresh the DSH page to log in again.

Conclusion

dsh-subpages consolidates “independent small apps” into dashboards within DSH: no new listening ports, manifest and submodules decoupled from host code, gateway enabling frontend deep links, and optional startup link pushing to notify-hub. The DeepSeek Harness ecosystem emphasizes “Everything is a plugin”; the community directory SkillHub is listed alongside the GitHub repo to facilitate search and installation. It has no official affiliation with DeepSeek / High-Flyer.

  • Directory Page: https://www.skillhub.cn/plugins/SJTUMalPan/dsh-subpages
  • GitHub: https://github.com/SJTUMalPan/dsh-subpages
羽毛球分组比赛记分
小程序二维码

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

Xiaoye