wisyh/dsh-session-compaction ↗★ 1

@wisyh/dsh-session-compaction

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

パッケージ
@wisyh/dsh-session-compaction
互換性
未検証
バージョン
1.0.0
ライセンス
MIT
最終更新
2026/11/16

インストール

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:wisyh/dsh-session-compaction

ドキュメント

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:

KeyValue
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.

FilePurpose
package.jsonbundle manifest, dsh.bundle, dsh.client
cordis.patch.ymlinserts the Loader row
index.jsHost half: empty apply()
client.jsthe whole Web UI and trigger logic
locale/*.jsonPlugin Manager title and description
icon.svgplugin artwork
test/render-smoke.mjsbehavioral test suite
docs/preview.pngthe screenshot above

License

MIT © W.