Skip to content
dsh.fish
Bundle

dsh-plugin-thinking-size

Live reasoning-token badge — Think(5.2K) — on every Think disclosure row of the DSH web UI, ticking while streaming · 在 web 界面 Think 行标题后实时显示思考内容 token 数的 DeepSeek Harness 插件

Source
focksor
stars
1 stars
License
MIT
Updated
Updated 5 days ago

Readme

# dsh-plugin-thinking-size

A live reasoning-token badge for DSH web. It appends a compact `Think(128)` / `Think(5.2K)` marker to the title of every "Think" disclosure row in the conversation — ticking in real time while the model is still thinking, and staying put on history messages afterwards.

English | [中文](README.zh.md)

![platform](https://img.shields.io/badge/platform-web-blue)
![dependencies](https://img.shields.io/badge/dependencies-0-brightgreen)
[![Listed on dsh-plugin.org](https://dsh-plugin.org/badges/listed.svg)](https://dsh-plugin.org/plugins/focksor/dsh-plugin-thinking-size)

## The badge

| Format | Rule |
| --- | --- |
| `Think(128)` | Below 1000 tokens: plain integer |
| `Think(5.2K)` | 1000 – 999 499: 1 decimal + K, fixed digits (`5000 → 5.0K`) |
| `Think(1.2M)` | A million or more: 1 decimal + M (`1000000 → 1.0M`) |

- **Live** — the number ticks up while the reasoning is streaming.
- **Persistent** — every historical Think row keeps its badge too, across expand/collapse and session switches.
- **Subtle** — a 12px caption-colored span in tabular figures, appended inside the row title and marked `aria-hidden`, so the accessible title still reads just "Think".
- **Adjustable precision** — hover the badge to pick **1 or 2 decimal places** (default 1); the choice applies to every badge instantly and is remembered in `localStorage`, surviving reloads and restarts.

## 雷霆大思考, measured

Some LLMs are famous for their 雷霆大思考 — thunder-length thinking that opens with several thousand tokens of pure reasoning. With this plugin you can watch the badge sprint in real time and see, at a glance, just how long each burst of thinking really is. No more wondering what the model was doing up there: the length is right on the row.

## How it works

- **Data** comes from the current session snapshot (`sessions` service → `chat.nodes`): the full text of every `reasoning` block of each `assistant-step` node. The collapsed DOM never carries the full reasoning text, so counting must read the snapshot, not the page.
- **Estimation** follows DeepSeek's official approximation — 1 English character ≈ 0.3 tokens, 1 CJK character ≈ 0.6 tokens, the sum rounded up. Counts are cached per reasoning-block object (its reference is immutable), so a streaming chunk only re-counts the one block that changed.
- **Writing** appends the badge span into each row's title span. Think rows (`data-variant="think"`) are matched to reasoning blocks by conversation anchor key plus in-anchor index. Snapshot subscription and a `MutationObserver` only set a dirty flag; a 100ms throttled sweep does the work — and if a React re-render wipes a badge, the observer flags it and the sweep puts it back.
- **Silent by design** — no host code is touched. If the `sessions` service is missing, the DOM contract changes, or a snapshot looks malformed, the plugin idles or skips rows quietly; it can never break the host.

## Install

```bash
dsh plugin --profile web add dsh-plugin-thinking-size
```

Restart `dsh web` to take effect.

### From source (local development)

```bash
pnpm install
pnpm run build
pnpm test
```

Then add this package to `~/.dsh/profiles/web/package.json` as a `link:` dependency, register it in `dsh.profile.bundles`, and restart `dsh web`.

## Keywords

dsh · deepseek harness · dsh plugin · web plugin · client plugin · chat ui · thinking · deep thinking · reasoning · reasoning tokens · reasoning length · token counter · token estimator · token usage · think badge · badge · streaming · 思考 · 深度思考 · 长思考 · 思考长度 · 思考时长 · 思考过程 · 推理 · 推理 token · 思维链 · token 统计 · token 估算 · 徽标 · 实时显示 · 聊天界面 · 雷霆大思考

Install

dsh plugin --profile web add github:focksor/dsh-plugin-thinking-size

Profile: web

  • This package builds from source on install. pnpm will ask you to allow its build script — that is permission to run the package’s code on your machine, outside the agent sandbox. Only allow sources you trust.
  • This source has no pinned commit, so a later push upstream changes what installs. Prefer pinning a commit.
Source