Introduction¶
DSH organizes sessions, tasks, and streaming outputs within the Web interface. However, when developers want to know “how many tokens this session consumed, the estimated cost, and how many cache hits occurred,” they usually have to dig through logs, calculate manually, or integrate an external monitoring system. dsh-session-stats-panel places the usage dashboard directly into the left sidebar as an independent “Session Statistics” page, without popups or changes to settings. It is maintained by Oblivionis7999 (织风裁月), has zero third-party dependencies, and all charts are hand-coded inline SVG/CSS.
The following sections introduce the plugin’s capabilities, installation methods, page metrics, and precautions.
What is this plugin¶
One-sentence positioning: Adds an independent “Session Statistics” page under “Automated Tasks” in the DSH Web left sidebar, replicating the session usage dashboard. The code is split into a host side and a client side: the host side only reads ctx.sessionQuery and registers two read-only HTTP routes; the client side is responsible for rendering the page.
It fills the parts not covered by the official package. The official @deepseek-ai/dsh-session-stats registers a sessionStats projection on the host side (tok/s, wall-clock time), while this plugin aggregates token/cost/cache hit rate per session, and samples the running status of the DSH process itself.
Core Features¶
Page Layout¶
The top consists of a large title + Time range (Last 24h / Last 7d / Last 14d / Last 30d) + Currency (CNY / USD).
The first row contains four equal-width metric cards: Total Token consumption, Estimated cost, Number of sessions, Cache hit rate.
The second row spans the entire width with a “DSH Runtime Status” card: CPU (single core)/Memory (RSS)/Event loop p99/Duration, plus a 5-minute CPU area line chart.
The third row is side-by-side: “Daily Consumption” stacked bar chart colored by model + “Token Composition” donut chart segmented by model.
The fourth row spans the entire width with a “Model Details” card: Model / tokens / percentage bar / cost.
Runtime Status Sampling¶
Samples every 5 seconds: CPU (process %, system %, number of cores), RSS/Heap, Event loop p99/mean, Duration, PID, Node version. The bottom displays a 60-point CPU circular buffer line chart.
Cost Estimation Methodology¶
Only recognizes “Original Manufacturer Official Pricing”: DeepSeek points to DeepSeek, GLM points to Zhipu, Kimi points to Moonshot, Grok points to xAI, GPT points to OpenAI, Claude points to Anthropic, Qwen points to Alibaba Cloud, and so on. Resale/aggregator platform prices (such as OpenCode Zen) and cross-vendor fallback prices are not used.
DeepSeek charges per entry for peak/valley rates, while other vendors use flat unit prices. USD for overseas vendors is converted using usdRate (default 7.1). Models without official pricing are not guessed or charged: response fields include priced:false, costCNY:0, priceLevel:"unpriced", priceKey:null, sourceUrl:null; the cost column for model details shows “Unpriced”, and the bottom of the table displays gray text indicating “N models have no official pricing, not included in amount (tokens x.xxM)”.
The README includes a “Snapshot Date 2026-11-04” original pricing table covering DeepSeek, Zhipu, Alibaba Cloud, MiniMax, StepFun, Xiaomi, Meituan, xAI, OpenAI, etc., along with links to official documentation for each vendor. Model prices may change; determining whether a specific model is currently priced should rely on this table and the plugin’s actual behavior. Cost can only serve as a local estimation and cannot be treated as a bill.
Charts and Color Scheme¶
Chart colors are only taken from modelPalette (10 colors) in the host response, assigned by the order of first appearance in the window; the 11th and subsequent slices go to the neutral gray “Other” slice. The client does not hardcode colors, only reading the color field. The dark theme only adjusts brightness/saturation for color blocks, without maintaining a second hardcoded palette.
The theme follows the host’s light/dark mode, consuming --dsw-alias-* design tokens (with light theme fallbacks). The light theme uses a white background + #e8eaed thin border. The primary color is #12b886 / #0ca678.
Installation and Enablement¶
First, obtain the absolute path of the plugin directory, represented below as <插件目录>. For local development, use link to install without copying files:
dsh plugin --profile web add "link:<插件目录>"
To uninstall, use the package name:
dsh plugin --profile web remove dsh-session-stats-panel
To distribute to others, use the git method:
dsh plugin --profile web add "git+https://github.com/Oblivionis7999/dsh-session-stats-panel.git"
After installation, restart DSH (bundle list changes do not support hot reload) and perform a hard refresh in the browser (Ctrl+Shift+R). After installation, “Session Statistics” will appear under “Automated Tasks” in the left sidebar.
Requirements are sourced from package.json: peerDependency @deepseek-ai/dsh version >=0.2.1-rc.5 (optional), engines.node version >=22.19.0, version 2.2.2, license MIT.
Page Metrics and Caching¶
Pay attention to several definitions when reading the page:
-
“Last 7 Days” refers to “Today and the previous 6 natural days,” aligned to the Beijing Time zone (UTC+8). The bar chart and summary are strictly same-origin; the sum of the bars is always equal to the total of the cards. The default time range is “Last 7 Days”.
-
Currency switching does not trigger a new request. USD is derived from CNY using
usdRate(default 7.1). -
Total Tokens is the sum of four mutually exclusive buckets:
inputTokens(uncached input) +outputTokens+cacheReadTokens+cacheWriteTokens. The denominator for cache hit rate isinputTokens + cacheReadTokens + cacheWriteTokens(recorded as 0 if the denominator is 0). -
The number of sessions is the count of sessions that have at least one usage event within the window. Average = Window Total / Session Count.
-
The host side does not write any session data; it only processes events where
event.type === "assistant/message"anddata.usageexists. It skipsassistant/attempt, non-message events, empty usage, and events with invalid timestamps. It never throws an error. Model/Supplier comes fromdata.message.source; defaults tounknown/unknownif missing.
Caching and Incremental Updates: The overview response cache has a default ttlMs of 60s. Session-level caching determines changes based on the revision from ctx.sessionPersistence.list(). Only sessions with a changed revision are re-read; memory results are reused for the rest. It degrades to “60s TTL per session” if there is no persistence backend. The concurrency limit for a single scan is sessionConcurrency (default 3), the read timeout for a single session is readTimeoutMs (default 10s), and a single session failure only logs, not affecting other sessions.
There is one specific pitfall to note: The id in cordis.patch.yml is the key for the loader table. DSH merges bundle patches by id, with later loading overwriting earlier loading. The official package already occupies id: session-stats. If this plugin also uses the same name, the official sessionStats projection will silently fail to mount, and the streaming timing data will be missing without visible interface errors. Therefore, this plugin’s loader id is fixed to session-stats-panel and is asserted by tools/selfcheck.mjs to prevent regression.
Applicable Scenarios and Precautions¶
Suitable for DSH developers who want to view session usage, cost estimation, and DSH process status directly in the Web interface. When comparing multi-vendor models, the daily consumption and token composition colored by model can save manual splitting.
Precautions:
-
The plugin runs with the permissions of the current dsh process. Check the source code and license (MIT) before installing.
-
This package does not modify profile configuration, does not listen on ports, and does not write user data. The host side only registers two read-only HTTP routes.
-
The price table is a snapshot from the harvested day. Model official prices change; cost is only an estimation.
-
The repository has complete self-check scripts:
npm run selfcheckwill sequentially runtools/selfcheck.mjs(pure core smoke test),tools/selfcheck-host.mjs(fake ctx run routes),tools/selfcheck-client.mjs(fake environment render page), which can be used to verify behavior. -
This is a community-maintained project. GitHub 2 stars, categorized as client. It is safer to read the source code before using.
Conclusion¶
The value of this plugin lies in placing the usage dashboard in the DSH Web sidebar, using original manufacturer official prices for local cost estimation, with zero third-party dependencies and inline charts. The directory page is at https://www.skillhub.cn/plugins/Oblivionis7999/dsh-session-stats-panel, and the repository is at https://github.com/Oblivionis7999/dsh-session-stats-panel. It should be noted that the community directory is an independent site with no official affiliation to DeepSeek/Fangfang, so do not treat it as an official app store.