zhengmz/dsh-auto-fold

dsh-auto-fold

补齐 DSH 在对话显示设为 Compact(紧凑)时无法自动折叠的能力。 Fills in the missing capability for DSH to auto-fold when the conversation display is set to Compact.

Uncategorized

dsh-auto-fold

Fills in the missing capability for DSH to auto-fold when the conversation display is set to Compact. 补齐 DSH 在对话显示设为 Compact(紧凑)时无法自动折叠的能力

中文 · MIT

⚠️ Deprecated / No longer maintained

DSH has shipped a built-in Turn navigation rail (the turn-mark ladder on the right side of the transcript) since 0.1.2-rc.1: every started turn has a mark, and turns not yet paged in are labelled "Load and jump to turn N". Clicking the topmost mark (turn 1) drives the official loadThrough to page in the entire history and lands at the top; once hasMore becomes false, the official native Compact per-turn folding takes over — exactly the same end state this plugin produces.

This plugin is therefore redundant and no longer maintained for 0.1.2-rc.1 and later (the code is kept for reference):

  • New users should not install it: just use the official turn navigation rail (click the top mark → full history loads → official folding engages);
  • The only difference: this plugin backfills automatically on open (zero clicks, and the view stays at the tail); the official rail needs one click and jumps the view to the top;
  • The official path is lighter: this plugin materializes the full history on every open of an old session; the official rail pages on demand (it only loads where you jump to).

It is still worth keeping only if you truly need "zero-click auto-backfill while staying at the tail"; otherwise uninstall:

dsh plugin --profile web remove dsh-auto-fold

What it does

When DeepSeek Harness Web opens an older conversation it only loads the latest 50 messages; older content requires clicking "Load earlier" page by page. The official native per-turn folding only engages once the whole history is loaded (hasMore === false) — each completed turn then collapses into one summary row (N tool calls · Thought for a while) with only the final answer visible. While history is incomplete the official client deliberately keeps everything expanded — that gate exists to guarantee the fold summary's counts and boundaries are authoritative.

This plugin automates the whole path:

Open an older session        →  everything expanded (official gate: data not complete yet)
    ↓  auto session.loadThrough(0), pages 200 messages at a time to the very beginning
History complete (hasMore=false) →  official native per-turn folding takes over, one summary row per turn
  • Zero interaction: runs automatically on session open, no button to press;
  • No extra fold rows: renders no fold bars or summaries of its own — folding is entirely the official native one;
  • No takeover: never touches transcriptView; the official "fold only when data is complete" guarantee stays intact;
  • Always authoritative: fold summaries (counts, boundaries) are computed from complete history, never approximate;
  • Compact mode only: backfill runs only when the official "Turn folding mode" is Compact (the default); when explicitly set to Normal it is skipped to avoid pointless loading.

How it works

Pure browser-side plugin mounted on the official session-scoped slot conversation.composer.dock (renders nothing once loading finishes):

  1. Reads the session snapshot (useSession) and sessionId from the slot's standard props;
  2. Reads transcriptView from the official ui-chat settings namespace via settingsScope; continues only when it is compact (the default);
  3. When openState === 'open' and hasMore === true, calls the official session method session.loadThrough(0);
  4. loadThrough pages backward (200 messages per page) until hasMore === false, with a built-in no-progress guard;
  5. While paging, a single subtle "正在补齐历史…" hint line is shown (not a fold row) and disappears when done;
  6. Once hasMore === false, the official native per-turn folding engages.

loadThrough is idempotent: repeated triggers (streaming appends / in-flight) are safe no-ops. Session switches are followed automatically.

Install

dsh plugin --profile web add github:zhengmz/dsh-auto-fold

Or from a local checkout:

dsh plugin --profile web add /path/to/dsh-auto-fold

Restart DSH (dsh web) and refresh the browser afterwards.

Uninstall

dsh plugin --profile web remove dsh-auto-fold

Fully reversible; no official files are modified.

Optional settings (localStorage, browser console)

KeyValueEffect
dsh-auto-fold.disabled'1'Disable auto-loading without uninstalling
localStorage.setItem('dsh-auto-fold.disabled', '1')   // disable
localStorage.removeItem('dsh-auto-fold.disabled')     // re-enable

Compatibility

⚠️ No longer maintained — see the note at the top: since 0.1.2-rc.1 the official turn navigation rail provides an equivalent capability.

  • Compatible with DeepSeek Harness 0.1.2-rc.1 - 0.1.5-rc.2 (Web profile)
  • Pure client plugin: no host behavior, no telemetry, no network requests
  • Relies on snapshot fields (openState / hasMore / loadingOlder), the conversation.composer.dock slot, and the ui-chat.transcriptView setting, verified against 0.1.2-rc.1 / 0.1.5-rc.2

Known limitations

  • Very long sessions take a moment to backfill on first open (200 messages per page; hasMore is per-session in-memory state, so switching back to a session re-triggers the backfill once);
  • A running/unfinished turn stays expanded (official rule: folding applies only to closed turns); it folds automatically once it closes.