Preface¶
When developing with or using DeepSeek Harness (DSH) on a daily basis, you frequently need to check account balance and usage entry points. In the Web GUI, this typically requires navigating to Settings › Account & Balance, and the desktop version also requires locating the corresponding button in the sidebar. To reduce navigation steps and increase the frequency of balance checks, it’s useful to have a persistent balance capsule and a detail panel in a fixed position in the sidebar.
What This Is¶
The DSH sidebar balance plugin is a local bundle that permanently displays your DeepSeek account balance in the bottom-left corner of the DSH Web GUI sidebar and provides quick entry points to Query Usage and Top Up. It is installed via DSH’s plugin_manager using a file: symlink and does not depend on npm.
The plugin is maintained by Mr-carp-86 and is a client-side plugin with 0 stars at present.
Core Features¶
- Persistent balance capsule in the bottom-left of the sidebar
- Clicking the capsule opens a detail panel (top-up balance, bonus balance, total, last updated time, refresh button)
- Two actions — Query Usage and Top Up — that automatically fall back through different opening methods based on the runtime environment
Balance Display & Formatting¶
- Capsule position: directly above the Settings row in the sidebar, left-aligned with the avatar; when the sidebar collapses to a 56 px rail, only a 36×36 circular icon is retained
- Panel fields: top-up balance, bonus balance (shown only when non-zero), total, last updated time, refresh button
- Amount formatting mirrors the official account card:
0 → ¥0.000 < v < 0.01 → <¥0.01- Negative numbers prefixed with
-, thousands separators, truncated to two decimal places - Currency follows the wallet (
CNY → ¥,USD → $)
Example panel layout:
┌──────────────────────────┐
│ Account Balance ⟳ │
│ Top-up Balance ¥5.49 │
│ ──────────────────────── │
│ Total ¥5.49 │
│ Updated at 13:19 │
├──────────────────────────┤
│ Query Usage │ Top Up │
└──────────────────────────┘
[ 🪙 ¥5.49 ]
Fallback Order for the Two Actions¶
- Desktop (Electron shell): Uses
window.dshPlatform.open('usage' | 'top-up', bounds)to open the native platform view. This channel is the same as the official Settings › Account & Balance entry and supports per-account persistent partitions, header injection, and bootstrap tokens, so it opens in an already-authenticated state without landing on a login page. The view opens as a full-window overlay; dismiss it via the top Back button orEsc. - Regular browser (no Electron shell): Follows the DSH Settings › General › Default link opening method configuration. If set to In-app sidebar, it opens in the built-in sidebar Browser tab; if set to Default browser, it opens in a regular new tab.
- If neither of the above is available: Falls back to native
<a target="_blank" rel="noreferrer">behavior, so the links are always clickable.
The three tiers use an “automatic fallback on failure” strategy, so a click will never be unresponsive.
Installation¶
Run the following in a DSH session (or invoke it via a plugin management tool):
plugin_manager { action: "install_bundle", target: "<absolute path to this repo>" }
After installation, refresh the page (client bundles do not support HMR). Uninstallation works the same way: remove_bundle. If you want to change the installation directory, you must run remove_bundle first and then install_bundle; the same name and version will be reported as already-installed, and the source path is not compared.
Data Sources & Dependencies¶
All data is fetched through DSH’s client-side remote services — the plugin does not construct HTTP requests on its own:
- Balance: Calls
ctx.remote.account.getBalance({ version, locale, timezoneOffsetSeconds }), returning{ ok: true, value: { status: 'ready', value: [...], bonusWallets: [...] } } - Platform links: Calls
ctx.remote.account.getState(), returning{ links: { usageUrl, topUpUrl } }
version is read from window.__DSH_BOOT__.release.version; if missing, it falls back to unknown. The platform only uses it as a request header.
The wallet is split into value (top-up balance) and bonusWallets (bonus balance). A top-up balance of 0 with a non-zero bonus is a normal account state and is not treated as a failure. The total is accumulated in integer cents to avoid floating-point rounding errors.
The plugin treats the following capabilities as optional dependencies; if any is missing, it degrades gracefully without blocking loading:
| Service / Global | Purpose | Behavior When Missing |
|---|---|---|
slots / locale / remote |
Slot registration, i18n strings, balance fetching | Required (written into inject) |
window.dshPlatform |
Native platform view | Falls back to link settings |
configForms + ui-chat.linkOpening |
Reads “Default link opening method” | Uses default sidebar |
sidebarRight / sidebarRightTabs |
Built-in sidebar Browser tab | Falls back to regular new tab |
The plugin registers the slot sidebar.footer.action (kind list, scope root) with id: 'sidebar-balance' and order: 50.
File Structure¶
| File | Role |
|---|---|
package.json |
Bundle manifest: dsh.bundle.patch + dsh.client{platform:'web', immediately:true} |
cordis.patch.yml |
Inserts the sidebar-balance entry into the host loader |
index.js |
Host half — empty apply(); all logic lives on the client side, and the host half deliberately does not inject any optional services |
client.js |
All logic: balance fetching, capsule, panel, native view, link fallback |
icon.svg |
Plugin icon (wallet, #4D6BFE) |
locale/zh.json, locale/en.json |
Display name and description in plugin management |
Known Limitations¶
- Only the desktop version (Electron shell) can use the native platform view; in a regular browser the balance is still displayed, but the two actions can only be opened via link settings.
- While the native view is open, keyboard focus is inside the
WebContentsView, so shortcuts likeCtrl+Rare sent to the platform page rather than DSH; to refresh DSH, you must first click Back. - The built-in sidebar Browser is an independent webview without the platform’s login session, so the platform page will land on
sign_in; the native channel is therefore preferred. - Theme colors are taken exclusively from the
--dsw-alias-*token set, following the host’s light/dark mode; no custom palette is defined.
Use Cases & Notes¶
Ideal for developers and users who need to quickly check their balance and trigger usage/top-up flows from the DSH sidebar. The plugin runs with the current DSH process privileges, so it is recommended to review the source code and license before installing (this project uses the MIT license).
Closing¶
The DSH sidebar balance plugin reduces the number of navigations to Settings › Account & Balance by providing a persistent capsule and panel in the sidebar, along with a native channel consistent with the official one. Install it with plugin_manager { action: "install_bundle", target: "<absolute path to this repo>" }, then refresh the page to activate.
- Plugin directory: https://www.skillhub.cn/plugins/Mr-carp-86/dsh-plugin-sidebar-balance
- GitHub: https://github.com/Mr-carp-86/dsh-plugin-sidebar-balance