DSH Knowledge Base Quick Reference Panel: Right Sidebar Quick Lookup & Reader Plugin

Introduction

When doing knowledge base retrieval in DSH Web, you often need to click a document from the list, scroll to the matching passage, then go back to the list to find the next one. This back-and-forth disrupts your reading flow, which is especially noticeable during tasks like memorization or textbook review that require continuous reading.

The DSH right-panel “Knowledge Base” quick-reference sidebar (dsh-kb-sidebar) is designed for exactly this: it provides a “Knowledge Base” tab in the DSH right sidebar, reads the upstream plugin’s /kb-api, and handles search, hit positioning, table-of-contents navigation, tag and collection filtering, focus reading, resume-from-last-position, and sequential reading across documents.

Below is a guide on how to install and use it.

What Is This

  • Name: dsh-kb-sidebar
  • Maintainer: ymf2317-tech
  • Category: Memory
  • Repository: https://github.com/ymf2317-tech/dsh-kb-sidebar
  • Positioning: DSH Web right-panel “Knowledge Base” quick-reference sidebar; a pure front-end display and reading plugin + minimal host shell. It does not ship its own knowledge base storage or vector engine; all data is read from the same-origin /kb-api.
  • Core value: Perform knowledge base retrieval and reading directly in the DSH right sidebar, reducing the need to jump back and forth between the list and the article body.

Prerequisites

This plugin depends on the upstream plugin dsh-knowledge-base-local, which handles Markdown storage, chunk-based retrieval, and the /kb-api/* routes. You must install and enable that upstream plugin before installing this one.

Core Features

Hybrid Retrieval and Hit Positioning

  • Search endpoint: /kb-api/search
  • Retrieval method: BM25 + vector hybrid, using the same scoring as the Agent’s kb_search.
  • Debounce: 280 ms; pressing Enter triggers immediately.
  • Hit positioning: The matching passage in a search result (heading / snippet) is automatically anchored after the document opens — the passage is highlighted and scrolled to the center of the viewport, eliminating the need to scroll manually.

Document Table of Contents and Navigation

  • Documents are rendered by “section.” The plugin automatically extracts headings-like or entry-like lines (e.g., 1. …, Chapter 3 …, I. …, •) to build a table of contents. Clicking an entry scrolls to that section.

Tag and Collection Filtering

  • Tags are aggregated from the document list and sorted by distinctiveness.
  • The tag-chip filtering threshold is 95% as of version 0.3.1 (previously 75%), preventing textbook-style content from being mistakenly treated as a “universal tag.”
  • Tag chips and collection filters can be combined.

Font Size Adjustment

  • A- / A+ adjusts the range from 13–21 px.
  • Font size preference is stored in localStorage.kbs-font-size; default is 16 px.
  • The input box is fixed at ≥16 px to prevent iOS from zooming the page on focus.

Focus Reading Mode

  • The “Focus” button in the top-right of the article body enters Focus mode.
  • Upon entering, the entire panel header (title / document count / refresh) and the subtitle row are hidden. Only a slim top bar remains: ← Title A- A+ TOC Exit.
  • The article body occupies the full panel height.
  • The focus toggle is stored in localStorage.kbs-focus, so the next time you open it, Focus mode is entered automatically.

Resume Reading and Sequential Reading

  • Resume reading: While scrolling, the position (“which section you’ve read to”) is recorded with a 400 ms throttle (localStorage['kbs-pos:'+id]). Next time the document is opened in plain reading mode (no word lookup, no search hit), it automatically scrolls back to that section. The list page top shows “Continue from last position · Title” (localStorage.kbs-last).
  • The plugin records the section index rather than scrollTop, so it works correctly after changing font size or screen width.
  • Sequential reading: At the end of the article body, ‹ Prev / Next › links appear. The order follows the current list (search results take priority, then the document list). During memorization, you can page through from Chapter 1 onward without returning to the list.

Hit Navigation

  • When a search result has multiple hits, the reading view title shows ‹ 2/24 › on the right. Clicking the arrows cycles to the previous/next search result (automatically fetching that result’s document and positioning to its own hit).
  • Within a single document, the “Hits k/n” button in the title bar cycles through the hit passages in the current article. After jumping, the scroll aligns to the first highlighted word in the section (.kbs-mark).

Formula and Markdown Rendering

  • Formulas: $…$ / $$…$$ are converted via latexToText() into readable symbols rather than raw source — for example, $\gamma$-Fe→γ-Fe, $300^{\circ}\mathrm{C}$→300°C, M_n=\sum N_i M_i→Mₙ=Σ Nᵢ Mᵢ, 10^{-3}\ \mathrm{s}^{-1}→10⁻³ s⁻¹, \mathrm{Fe_3C}→Fe₃C, \textcircled{2}→②.
  • Fractions use a/b; deeply nested formulas can only be approximated.
  • Lightweight Markdown: **bold**→<strong>, `code`→<code>, and the # prefix on heading lines is stripped.
  • Hit highlighting: Word lookups mark occurrences in the article body with <mark class="kbs-mark"> (yellow background).

Fallback and Fault Tolerance

  • If /kb-api is unreachable, the panel shows a single prompt line and does not throw exceptions; read failures are logged to window.__KB_SIDEBAR_ERR.
  • If the upstream vector service (e.g., a local Ollama embedding) is unresponsive or hung, /v1/embeddings may hang for an extended period:
  • Panel side: Search has a 15-second timeout. On timeout, it automatically falls back to mode=lexical pure-text retrieval, and the UI displays “Vector service unresponsive; falling back to text search.”
  • Render fallback: Error messages are written to window.__KB_SIDEBAR_ERR and shown in the UI, preventing a blank screen.

Installation and Enablement

After ensuring dsh-knowledge-base-local is installed and enabled, run the following in your profile directory (e.g., ~/.dsh/profiles/web):

dsh plugin --profile web add github:ymf2317-tech/dsh-kb-sidebar

After installation, refresh the page and add the “Knowledge Base” tab via the “+” button in the right sidebar.

Typical Usage

  1. Open the “Knowledge Base” tab in the DSH Web right sidebar.
  2. Type a keyword in the search box and press Enter to trigger hybrid retrieval.
  3. Review the highlighted matching passage; click the result to open the document — the system automatically scrolls to the hit section.
  4. Click a table-of-contents entry within the document to jump to that section.
  5. Use tag chips or collection filters to further narrow down documents.
  6. Click “Focus” in the top-right to enter Focus mode and read at full panel height.
  7. The current section is recorded automatically while scrolling; the next time you open the same document, it returns to your last position.
  8. Click “Prev” / “Next” at the bottom of the document to continue sequential reading.

Use Cases and Notes

  • Ideal for scenarios requiring frequent switching between retrieval and reading, or continuous reading sessions (e.g., memorization, textbook review).
  • This plugin does not modify the source code of dsh-knowledge-base-local, nor does it directly read/write vault files. All data flows through the read-only / same-origin /kb-api.
  • If the upstream vector service malfunctions, the plugin automatically falls back to pure-text retrieval without causing DSH to crash or show a blank screen.

In Short

The DSH right-panel “Knowledge Base” quick-reference sidebar provides a lightweight entry point for knowledge base retrieval and reading within DSH Web: hybrid retrieval, hit positioning, TOC navigation, tag and collection filtering, focus reading, resume-from-last-position, and sequential reading across documents. After installation, simply refresh the page and add the “Knowledge Base” tab via the “+” button in the right sidebar to start using it.

  • Plugin directory page: https://www.skillhub.cn/plugins/ymf2317-tech/dsh-kb-sidebar
  • GitHub: https://github.com/ymf2317-tech/dsh-kb-sidebar
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye