返回目录
模型与 MCP 插件

dsh-session-compaction

wisyh/dsh-session-compaction

Context-pressure ball for DeepSeek Harness: live occupancy, heat colouring, and a user-set threshold that compacts between turns instead of interrupting them.

Stars
1
Forks
0
Issues
0
更新
7 天前

PROJECT TOPICS

项目标签

INSTALL REFERENCE

安装参考

未验证
dsh plugin --profile web add github:wisyh/dsh-session-compaction

该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。

PROJECT README

README

dsh-session-compaction

A floating ball for the DeepSeek Harness Web UI that shows how full the current context is, and compacts the conversation early — at a threshold you set — without interrupting a running turn.

Compaction ball states and settings panel

Why

Harness already compacts on its own: compaction-basic runs between steps once context pressure reaches thresholdRatio (0.8 by default). That is a safety fence, not a control. By the time it fires, the conversation is already at the edge, and there is no way to see the pressure coming or to decide where the line should be.

This plugin moves that line earlier and makes it visible:

  • the ball turns from blue to amber to red as the context fills, so pressure is visible while you work;
  • the trigger threshold is yours (30%–80%), not the provider's default;
  • a running turn is never cut off — the trigger waits for the turn to end and then compacts.

How it works

Reading pressure. Occupancy comes from the Harness token meter, not from an estimate:

sessions.binding(sessionId)
  .session.projections.faceOf("contextPressure")
  .getSnapshot() // { projectedTokens, pressureTokens, contextWindow }

That projection is wire.summary: false, so it is read per session rather than from the session list. The widget subscribes to both the session face and the projection, so every token sample repaints the ball. Occupancy is projectedTokens / contextWindow, clamped to 0–1.

Triggering compaction. No compaction logic is reimplemented. The widget calls the same seam the composer's slash command uses:

ctx.remote.commands.execute(sessionId, "/compact", [])

So the compaction lock, the command/run and command/done journal entries, and the summary itself all belong to @deepseek-ai/dsh-compaction-basic.

Not interrupting a turn. /compact refuses to run while the agent is busy, so the widget never sends it then. Above the threshold with a turn in flight, the trigger is armed — a pulsing dot on the ball — and the command is dispatched on the first render where the session is idle. A "not idle yet" answer right after a turn retries in 8 seconds; a successful compaction holds a 45-second cooldown so a still-high reading cannot chain into repeated model calls.

Install

The package is not published on npm yet; install it from a checkout.

git clone https://github.com/wisyh/dsh-session-compaction.git

Then either use the dsh CLI:

dsh plugin add ./dsh-session-compaction

or the in-app Plugin Manager (install_bundle) pointing at the same directory. The bundle inserts one Loader row, wisyh-session-compaction; the Host half is an intentionally empty apply(), because every behavior lives in the Client half.

After installation, reload the page (Ctrl+Shift+R) so the browser picks up client.js.

The ball

  • The outer ring is a progress arc: its sweep is the occupancy.
  • Colour bands: below 45% brand color, 45–70% amber, above 70% red.
  • A running compaction spins a second arc around the ball.
  • Above the threshold with a turn in flight, an amber dot appears at the lower right: queued.
  • Drag it anywhere; releasing near an edge snaps to it. The position is remembered.

The panel

Clicking the ball opens a small panel anchored to it — the panel follows while you drag the ball, flips below the ball near the top edge, and scrolls its body instead of overflowing the viewport. Only four blocks, no explanatory copy:

  1. occupancy: large percentage, the progress bar (the white tick is your threshold), and 152k / 200k;
  2. the auto-compaction switch, with the threshold slider directly beneath it;
  3. Compact now, disabled while a turn is running;
  4. recent compactions — time, auto/manual, and the result.

Press ×, Esc, or click outside to close.

Settings

Stored in localStorage, per browser:

Key Value
dsh-session-compact.settings.v1 { auto: boolean, threshold: number }
dsh-session-compact.ball.v1 { left, top }

The 80% ceiling on the slider is deliberate: it is where compaction-basic already compacts, so a higher user threshold could never fire first.

Compatibility

  • Verified against the Harness build shipped in DeepSeek Desktop, November 2026.
  • Colors go through --dsw-alias-* theme tokens only, so light and dark themes follow the host.
  • The DOM carries data-dsh-plugin, data-dsh-surface and data-dsh-part semantic attributes.
  • dsh-plugin.naming.json declares the community coordinate wisyh/session-compaction; it is an advisory declaration, not an official manifest.

Communication with the Harness goes through two documented seams only — the contextPressure projection and remote.commands — so a future rename of either surfaces as a visible error in the panel rather than silent breakage.

Development

node test/render-smoke.mjs   # 52 behavioral assertions, no dependencies

The test drives the real Client half through a small React runtime written for the purpose (hooks, synchronous re-render, effect commit), so it covers interactions rather than string snapshots: the panel opening, the threshold round-tripping to localStorage, a manual compaction sending exactly one command, the six result texts, a queued trigger firing once at turn end, the cooldown, the anchor flipping, and drag persistence.

File Purpose
package.json bundle manifest, dsh.bundle, dsh.client
cordis.patch.yml inserts the Loader row
index.js Host half: empty apply()
client.js the whole Web UI and trigger logic
locale/*.json Plugin Manager title and description
icon.svg plugin artwork
test/render-smoke.mjs behavioral test suite
docs/preview.png the screenshot above

License

MIT © W.

CLASSIFICATION EVIDENCE

分类依据

项目类型插件
功能分类模型与 MCP
规则置信度中

系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。