A per-turn token usage strip in each reply's icon row: a grey/yellow/green segmented bar plus a legend giving that turn's uncached-input, cache-read and output split and each one's share.
Install
# from npm (prebuilt)
dsh plugin --profile web add dsh-token-bar
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:LobotomyCorporation/dsh-token-bar
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
A per-turn token usage strip for the DeepSeek Harness Web UI. It rides each reply's own icon row — the line that carries copy / branch / usage / timestamp — and draws that turn's cache structure as a grey / yellow / green segmented bar, with a written legend beside it. By the time a reply settles, you have already seen how the turn spent its tokens.

The whole thing is presentation-layer: no network, no storage, no host routes, no session-log writes, and no patching of any official package. Zero dependencies — one hand-written bundle that only borrows the platform-provided React.
English | 中文
Why it exists
Mid-run, the questions you actually want answered are per-turn ones: was this turn served almost entirely from cache? Did a fat uncached prefix suddenly appear — usually a sign the prefix got invalidated and this turn is going to cost noticeably more? Is the output share behaving?
DSH already has the answer somewhere: open the usage bubble at the end of a reply and the exact per-turn figures are there. The problem was never that the numbers are missing — it is that numbers have to be read. Three or four figures are fine once; across a long conversation your eyes glaze, and proportions have to be assembled in your head.
So this plugin draws them instead. Three figures become one three-slice strip: a near-total cache hit reads as an almost solid yellow bar; an invalidated prefix makes the grey slice bulge at a glance; an unusually long answer eats visibly into the green. A written legend sits beside it — dot, name, percentage, always on screen. No hovering, no memorising what colour means what; glance and move on.
Exact numbers remain the popover's job: both read the same source. The strip is the shape, the popover is the detail; neither competes with the other.
What it looks like, and why
Three slices, one fixed order: grey (uncached input) → yellow (cache read) → green (output). Strip and legend share the same order, left to right in the direction of input to output.
132px of track is a compromise: narrower and three minimum-width slices start crowding each other; wider and it demands attention that belongs to the reply itself.
A 6px floor per slice: any non-zero bucket draws at least six pixels. A 0.1% output still shows — the legend says 0.1%, and the corresponding sliver is right there on the track. The legend never promises a slice the bar fails to draw.
The legend is always visible. Hover is for extras, not for essentials; colour meanings are essentials.
Type sits one notch below body copy — calc(var(--dsh-content-font-size-secondary, 13px) - 1px) — and tracks the shell's font setting. Every colour comes from a --dsw-* theme token, so light and dark follow the shell with nothing hard-coded. The whole strip centres vertically on the icon row without stretching it.
Hovering shows the full breakdown: cache hit rate plus every bucket's exact token count and share. Glance normally; hover when you want to be precise.
Cache write has no slice: this route reports a constant 0 for it, and a permanently empty slice would only be noise.
Where the numbers come from
The strip reads tokenUsage from this turn's turn-tail location data — this turn's accounting, the same source the shipped per-turn popover prints, never the session-wide projection. The session total answers “how much have I spent?”; the per-turn figure answers “what just happened?” — and only the second one tells you which turn invalidated your prefix.
The lookup path is worth a paragraph. The conversation.chat.assistant-actions slot hands the component a message id and nothing else, so the component walks back through useChat: every completed Turn publishes a turn-tail entry carrying its own tokenUsage. Once found, the index registers every reply of that turn — the conversation nodes name all its assistant messages.
That “every” is deliberate, and new. Drop a steering message mid-run (“wait — try a different approach”) and the turn does not end; it takes your new instruction and keeps going, which leaves several replies inside one turn. The old index pinned the accounting to the closing reply only, so the pre-steering reply had nothing to show; now every reply of the turn carries the same per-turn strip, and the figure matches the shipped popover wherever you look.
useChat ships on the session standard kit (SessionStandardProps in dsh-client-ui-chat's slots.d.ts), so nothing extra has to be injected.
Credit to dsh-token-counter for the implementation reference.
Install
Published to npm: dsh-token-bar
# from npm (recommended)
dsh plugin --profile web add dsh-token-bar
# or install it into your project with npm
npm i dsh-token-bar
Point it at a local directory while developing:
dsh plugin --profile web add /path/to/dsh-token-bar
Restart dsh web afterwards for it to take effect. Uninstall with dsh plugin --profile web remove dsh-token-bar.
Compatibility
| Component | Supported |
|---|---|
| DSH | >=0.2.0-rc.1 <0.3.0-0, verified on 0.2.0-rc.2 |
| Node.js | >=20 |
| UI | DSH Web (needs the conversation.chat.assistant-actions slot) |
| OS | macOS / Linux / Windows (pure JavaScript) |
Development
npm run check # syntax
npm test # pure helpers + render
npm test verifies the source client.js by default. To verify the build the browser actually receives, snapshot it from a running dsh web and run again:
node scripts/snapshot-bundle.mjs "http://127.0.0.1:3080/?token=<token printed at startup>"
npm test # with verify-module.js present, tests the served bundle instead
Pushing when github.com is unreachable
If github.com:443 refuses connections from your network but api.github.com works, push through the REST API:
node scripts/push-via-api.mjs <owner>/<repo> --dry-run # see what would go
node scripts/push-via-api.mjs <owner>/<repo> # actually push
It replays local history as blobs → trees → commits, then points the branch at the remotely created commit — API-created SHAs differ from local ones, so a mismatched git log is expected.
Restyling
No settings UI; the knobs live at the top of client.js:
| Constant | Role |
|---|---|
BUCKETS |
slice definitions (order, names, colours) |
MIN_SEGMENT_PX |
minimum slice width, default 6 |
TRACK_PX |
track width, default 132 |
FONT_SIZE |
type size, default one notch below body copy |
Known limits
- Completed (
turn/end) turns only; the turn currently streaming gets its strip when it finishes. Every reply of a completed turn — including the one before a mid-turn steering message — carries the same per-turn strip; a turn aborted without a durable closing message id (a fallback assembled from stream chunks) can still render none. - The icon row stays visible. Upstream keeps only the newest reply's row on screen and fades older ones in on hover — the strip would fade with them. To keep it steady, the plugin pins the assistant row visible, scoped to the row carrying
data-clock="end"and leaving the user bubble alone. The cost: every reply's icon row is permanently on. - Position follows the official layout, not preference. The row is hard-coded as copy → plugin actions → branch → usage → timestamp, and the one plugin slot sits between copy and branch. The strip therefore lands left of the usage pill, not “between usage and timestamp” — there is no slot there.
- It relies on the official
turn-taillocation-data shape; a change there needs a matching update here. - No settings UI — restyling means editing the source (all knobs live at the top of the file).
License
MIT
Links
More in this category
bowenliang123/dsh-context★ 5616
DeepSeek Harness officially recommended - a context insight plugin for context composition, evolution and Multi-Agent collaboration. It provides a cross-session Insights page (tokens, cost, cache hit, activity heatmap, skill and tool loads), a per-session Context tab (composition, token and timing stats, timeline, browser, events, file activity, command executions), a Fleet tab for the agent family (the current agent, its parents and every subagent), and a /context command.
Han-1413141/dsh-cost-meter★ 787
Per-session and daily API cost, budget with usage %, official balance, history dashboard, and one-click official price sync with peak/off-peak pricing.
wssfk12138/dsh-damage-pulse★ 292
Tracks DeepSeek token usage, per-call and session costs, and account balance with cache-aware charge animations in the DSH Web UI.
zh667/TokenLedger★ 206
Sidebar usage panel that attributes tokens to the relay site that served each request, read from your existing provider config: today/month/all-time totals, per-site and per-model breakdowns, a year activity heatmap, and New API / Sub2API / DeepSeek balances.
Ychris12138/dsh-usage-stats★ 195
Multi-provider usage dashboard with provider/model token breakdowns, calendar drill-downs, account balances, and OpenCode Go / Z.ai subscription quota tracking.
PolinniZhong/dsh-personal-center★ 114
Personal center for DeepSeek Harness: cross-session usage statistics with per-provider and per-model breakdown (auto-discovers configured models), per-model cost estimation, global custom instructions, a data-driven desktop pet with bitmap & vector skins, and a conversation status overview, all local and offline.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.