ui-theme-quota-show
A DeepSeek Harness web UI plugin that adds a DeepSeek API balance card directly above the Settings trigger in the sidebar. It reads the official GET /user/balance endpoint, shows the remaining balance plus its top-up/granted breakdown, and refreshes automatically every 60s.

Features
- Live remaining balance (
total_balance), big number, with a low-balance red warning (lowBalanceThreshold, default5). - Breakdown of top-up (
topped_up_balance) and granted (granted_balance) balance. - Update time and period usage (the balance delta since the card loaded — the same key's total across all clients).
- 60s auto-refresh + a manual refresh button; a failed refresh keeps the last good value (stale-while-error).
- Collapsed-sidebar (rail) mode collapses to a 32px round button —
¥normally,!when balance is low — and clicking it expands the sidebar. - No new secret: the API key is reused from the existing
DEEPSEEK_API_KEYcredential (written by Settings → Models, stored in~/.dsh/.credentials.yaml), resolved on the host and never sent to the browser.
Quick start
One-click script (recommended)
Clone and run the installer — it checks that dsh is on your PATH, links the plugin into your web profile with link:, and prompts you to restart:
git clone https://github.com/wwxiaoqi/ui-theme-quota-show.git
cd ui-theme-quota-show
# Windows (PowerShell)
.\scripts\install.ps1
# macOS / Linux
bash ./scripts/install.shThen restart dsh web (the client module system only picks up a new plugin on restart).
Developer iteration (link mode)
No build step, no npm dependencies — just link your checkout:
cd ui-theme-quota-show
# macOS / Linux
dsh plugin --profile web add "link:$PWD"
# Windows (PowerShell) — forward slashes; link: is required cross-drive
dsh plugin --profile web add "link:D:/path/to/ui-theme-quota-show"Update / reinstall
dsh plugin --profile web remove ui-theme-quota-show
dsh plugin --profile web add "link:D:/path/to/ui-theme-quota-show"Configuration
The base config lives in cordis.patch.yml under config.
| Field | Type | Default | Meaning |
|---|---|---|---|
baseUrl | string | https://api.deepseek.com | Balance endpoint base; /user/balance is appended. |
lowBalanceThreshold | number | 5 | Main number turns red when total_balance falls to or below this amount (account currency). |
> The DEEPSEEK_API_KEY credential is resolved per request through the credentials seam (the Models page writes it), falling back to the process environment when that seam is absent. A changed key reaches the next request without a restart.
Field semantics
DeepSeek's balance API is a prepaid-credit model — there is no "total quota" or "used" field. The card maps it faithfully:
| Shown | Source |
|---|---|
| Remaining balance | total_balance (total available credit) |
| Total composition | topped_up_balance (top-up) + granted_balance (granted) |
| Period usage | balance delta since the card loaded (approximation) |
| Update time | time of the last successful fetch |
How it works
- Host registers the route
/ui-theme-quota-show/balance. Each request resolvesDEEPSEEK_API_KEYthroughctx.credentials(orprocess.env), callsGET https://api.deepseek.com/user/balancewith Nodefetch, and returns only normalized numbers — the key never reaches the browser. - Client registers into
sidebar.footer.action(the row the sidebar shell renders directly above the Settings trigger), receives thewidecolumn state, and renders the card (wide) or the 32px rail button (collapsed). It polls the host route every 60s withcache: no-store, keeping the last good snapshot on failure. - The rail button expands the collapsed sidebar through
layout.toggleSidebar().
File layout
| File | Role |
|---|---|
index.js | Host half: balance route + credential resolution + upstream proxy |
client.js | Client half: card + rail button + 60s refresh + state machine |
cordis.patch.yml | Bundle patch: inserts the row with base config |
package.json | Declares dsh.bundle.patch and dsh.client |
> client.js is hand-authored in the exact window.__ModuleLoader__.load format that the tsdown client-bundle preset emits (packages/client/tsdown.client.ts in the harness). If you migrate to a TypeScript/tsdown build, move it to src/client/index.ts plus a tsdown.config.ts.
License
[MIT](./LICENSE)