Provides the ability to select conversation text and ask questions in the right panel for DSH Web client: creates an independent follow-up session in the same workspace without interrupting the main conversation, supporting nesting, context strategy switching, and follow-up record tree.
- Language
- TypeScript
- License
- MIT
- Branch
- main
Install
$ dsh plugin --profile web add dsh-sidebar-qaRun the command above in your terminal to install this plugin via the dsh CLI. You can switch Profile in the top-right corner. New to dsh? Read the beginner tutorial
Install via your agent
Install the DeepSeek Harness plugin ChenRuoT/dsh-sidebar-qa for me: review the repository at https://github.com/ChenRuoT/dsh-sidebar-qa first, then run the install command and verify the plugin loads successfully.
Paste this instruction to the DSH Web GUI assistant — it will install and verify for you.
One-Line Description
In any DSH Web chat, select any text segment, click the floating "Ask" button, and you'll get a complete Q&A in the right panel—the main conversation remains uninterrupted, and all follow-up questions run in automatically created independent DSH sessions within the same workspace, which can be continued, archived, or nested.
Core Features
- After selecting text in a conversation, a floating "Ask" button appears; clicking it opens a follow-up tab in the right panel and automatically expands the sidebar (even if the panel is collapsed)
- Each question automatically creates an independent DSH sub-session in the same workspace (
❓追问·<topic>), without touching the main conversation's agent, message stream, or queue - Three context strategies selectable in sequence: Full Inheritance (fork sub-session hits DeepSeek prefix cache, zero compression loss) / Compression (fast model compresses old history + keep recent raw text, default) / Mechanical Trim (take last N messages as-is, zero LLM cost)
- Follow-up questions support arbitrary depth nesting—selecting text in a follow-up session to ask creates a sub-follow-up
- Follow-up records tab displays a tree layered by root (main) session, scoped to current workspace, collapsible with recent access time shown; archived/deleted nodes are grayed out with status标注, removable with one click
- The answer/summary model provider and model in the config panel have been changed to dropdown selection (from runtime-configured providers); switching provider automatically links the model; summary provider can choose to "Inherit from questioned session"
Technical Implementation
- Language: TypeScript (ESM); Frontend React 18 + Backend Node 20+, bundled for both host and client halves
- Key Dependencies:
dsh-better-sidebar(hard peer dependency, providesctx.betterSidebarregistry service);@deepseek-ai/dsh-client-ui-primitives(icons);cordis(plugin mounting framework);schemastery(settings schema validation) - Architecture Pattern: Dual-half plugin. Host half (
src/index.ts) registers/sidebarqa/apiprefix route, exposes six JSON methods:config/catalog/config.get/config.update/context/title, and registers a settings panel with optimistic revision guard undersidebarqanamespace viactx.inject(['settings'], ...); Client half (src/client/index.tsx) registers two tabs (Follow-up / Follow-up Records) viactx.betterSidebar.registerTaband mounts a floating "Ask" button ondocument.body; all cross-half communication goes through standardwebServer+sessionQuery+llmservice facade - Entry Files: host
src/index.ts(exportsapply+inject = ['webServer','sessionQuery','llm','loader']), clientsrc/client/index.tsx(exportsapply+inject = ['betterSidebar','sessions','connection','workspaces']), mounting declared viacordis.patch.yml+package.json#dsh.bundle.patchfor both host/client halves
Use Cases
When collaborating with long conversation agents on DSH Web, you often need to follow up for details on a specific answer—without disrupting the main thread, or losing context by copying/pasting to a new session. This plugin makes "select text → right panel Q&A" a one-click operation: each follow-up is an independent DSH session in the same workspace, can be continued, archived, or nested; context can be switched between "Full Inheritance / Compression / Mechanical Trim" strategies as needed, putting token cost and answer fidelity in your hands.
Prerequisites & Compatibility
| Dependency | Minimum Version | Notes |
|---|---|---|
| DSH | 0.1.0-rc.8 | Below this version cannot resolve react / cordis / dsh-better-sidebar peer dependencies; rc.7 and earlier please upgrade DSH first |
| dsh-better-sidebar | 0.14.0+ | Hard peer dependency; when not installed, this plugin remains inactive (no UI, no behavior, no session creation) |
| Node | >=20 | Declared by package.json#engines.node |
| @deepseek-ai/dsh-client-ui-primitives | ^0.1.0-rc.8 | Client UI icons and primitives |
| cordis | ^4.0.0-rc.8 | Plugin runtime framework |
| Platform | Cross-platform | Pure Web browser plugin, requires DSH Web to run, no native modules |
Installation
dsh plugin --profile web add github:ChenRuoT/dsh-sidebar-qa
Configuration Options
All config is served under DSH settings service sidebarqa namespace, writes go through /sidebarqa/api/config.update with revision optimistic lock (prompts retry on multi-window conflicts). Web entry is in "DSH Settings → Sidebar Cards → Follow-up Card top-right gear → Feature Config" popup; the table below lists only 8 common settings exposed by the panel; other internal tuning keys (summarizeBudgetTokens, recentWindowMessages, backgroundWindowMessages, titleBudgetTokens) can be configured directly in settings.yaml under the sidebarqa namespace.
| Config | Type | Description | Default |
|---|---|---|---|
historyStrategy | Enum | Default context strategy for new follow-up: inherit Full Inheritance (fork + cache hit) / compressed Compression / trim Mechanical Trim; can be switched sequentially in panel | compressed |
trimWindowMessages | Number (1-256) | Number of recent messages to keep in mechanical trim mode | 10 |
summarizeProvider | String | Summary fast model provider; empty = inherit from questioned session's provider | '' |
summarizeModel | String | Summary fast no-thinking model | deepseek-v4-flash |
summarizeReasoningEffort | Enum | Summary thinking mode off / high / max | off |
answerProvider | String | Sub-conversation answer model provider | deepseek-official |
answerModel | String | Sub-conversation answer model | deepseek-v4-flash |
answerReasoningEffort | Enum | Sub-conversation thinking mode off / high / max | off |
FAQ
Q: Must I install dsh-better-sidebar first?
A: Yes, required. dsh-better-sidebar is a hard peer dependency; when not installed, the client-side inject = ['betterSidebar', ...] cannot obtain the service, and this plugin remains inactive—no UI, no behavior, no session creation. First run dsh plugin --profile web add dsh-better-sidebar@latest, and require version 0.14.0+.
Q: After selecting text and clicking "Ask", will the main conversation be interrupted?
A: No. The host side only reads the main session's current model surface (ctx.sessionQuery.readSurface, does not enqueue for sending), and the client side creates an independent DSH sub-session for Q&A; the main conversation's agent, message stream, and queue are completely untouched.
Q: How should I choose among the three context strategies?
A: "Full Inheritance" forks from the main session's latest completed turn, inheriting complete history as seed, can hit DeepSeek prefix cache but must use the main session's model; "Compression" uses a fast no-thinking model to compress old history + keep recent raw text (default, saves tokens); "Mechanical Trim" directly takes the last N messages as-is, zero LLM cost. When starting a new follow-up, switch strategies sequentially via the strategy chip on the panel's left side. Full Inheritance automatically degrades to Compression when the main conversation is mid-response (no completed turn yet).
Q: Why does the follow-up session title start as a placeholder and only update after answering?
A: This is two-phase naming: creation uses the first line of the quoted text as a placeholder title (❓追问·<first line>), and after the first answer completes, the host side uses a fast no-thinking model to extract a final title ≤15 characters from "question + answer" and renames over it. If extraction fails, the placeholder is kept and no retry will occur.
Q: What are the grayed-out "Archived / Deleted" entries in follow-up records? Does clicking "Remove" delete the DSH session?
A: Sessions you archived or deleted on the DSH side are not automatically cleaned from this plugin's localStorage parent→child mapping; the records tab grays them out with status labels. Clicking "Remove" only cleans up this plugin's mapping and derived state (titled / collapsed), without touching the real session on the DSH side.
Q: After closing the browser and returning, are follow-up records still there?
A: Yes. Parent→child mapping, titled markers, and follow-up records tree collapse state are all persisted in localStorage keys dsh-sidebar-qa:map / :titled / :collapsed. The actual sessions on the DSH side are independently retained by DSH's own session storage.
Q: After modifying the backend, must I restart dsh web?
A: Host half changes (/sidebarqa/api summary, title, settings namespace) require restarting dsh web; client half changes (selection floating layer, follow-up/follow-up records tabs, model dropdown, config panel) only require a hard browser refresh, no service restart needed.
Q: If the selection spans multiple messages or includes text currently streaming, can I select and ask?
A: No. The selection is identified as invalid: it must fall within a single [data-chat-anchor-key] node, and that node must not be in data-streaming state—selection is only possible after the streaming output collapses back to a single message. Single selection text length limit is 2000 characters. These validations are done in captureSelection in src/client/selection.ts.
Learning Curve
Beginner—just install dsh-better-sidebar, select text and click "Ask"; advanced parts (strategy switching, model dropdown, follow-up records tree) can be explored as needed, no source code reading required.
Known Issues & Limitations
- DSH upstream limitation:
sessions.selectModelunconditionally persists the selected model as the global default model. Therefore, when compression/trim follow-up sets the model for sub-sessions, it still changes "the starting model for new sessions"; a session that has never sent a request will also resolve its current model from this global default, which may appear to change. The plugin side has no API to avoid this (selectModelhas no opt-out, doesn't write session logs,sessions.modelscan only pull), see CHANGELOG 0.3.2. - Selection has 4 hard thresholds: must fall within a single message
[data-chat-anchor-key]node, target message not streaming, selection non-empty and ≤2000 characters; if any is not met, the floating layer won't appear (src/client/selection.ts:9-63). - Selection scope is limited to browser native
window.getSelection(), cannot select across iframes / Shadow DOM; text in these areas won't trigger the floating layer. - Full Inheritance strategy automatically degrades to Compression when the main conversation is "mid-response, no completed turn yet", panel will prompt; other fork failures (e.g., network) also degrade to Compression, won't block questioning.
- Parent→child mapping, titled markers, and collapse state are all stored in localStorage: clearing browser site data will lose this metadata, but the actual follow-up sessions on the DSH side are unaffected.
- The floating layer only listens to
selectionchange/mouseup/keyupondocument; when DSH Web renders conversation content in non-standard ways (e.g., custom containers withoutdata-chat-anchor-key/data-chat-flow-kindmarkers), selections won't be recognized as valid conversation text.
划选提问 上下文摘要 嵌套追问 追问记录 零打断DeepSeek Harness(DSH)Web 插件:在对话里划选任意文本 → 点击「提问」→ 右侧面板问答——
自动创建同工作区的独立 DSH 会话,主对话零打断。实现类 codex 侧边提问 / Claude Code `/btw` 功能。
✨ 功能一览
- 📝 划选提问:对话中划选任意文本 → 浮层「提问」→ 右侧面板内嵌问答,全程不跳转大窗口;侧边栏面板收起时也会自动展开,「提问」永远有可见反馈
- 🧠 智能摘要:快速无思考模型把主对话上下文压缩成小摘要,与划选引文一起注入首条消息
- 🔀 三种上下文策略:每次提问可在「全量继承(fork+缓存命中)/ 压缩 / 机械裁切」间切换,面板内选择器 + 配置默认值双入口
- 🔗 独立会话:自动创建同工作区独立 DSH 会话(
❓追问·<主题>),可继续、可归档,主对话零打断 - 🪆 嵌套追问:在追问对话里再划选提问,生成子追问,层层嵌套
- 🗂️ 追问记录:按根(主)会话分层树展示;限定当前工作区;节点可折叠、显示最近访问时间;点击跳转后追问记录 tab 保持开启;已归档/已删除的追问置灰标记状态,可一键从记录中移除(连同整棵子树清理映射,不影响 DSH 侧会话)
- 🏷️ 两段式命名:划选首行占位命名 → 首次回答完成后基于「问题 + 回答」自动提炼 ≤15 字最终标题
- ⚙️ 可配置:摘要/回答模型渠道、思考模式、上下文窗口与预算全部可调(设置页齿轮弹窗)
🔌 基于 dsh-better-sidebar 开发的第三方拓展 Tab,通过
ctx.betterSidebar.registerTab注册;能力对等内置 tab,安装即用。
前置依赖(必装)
dsh-better-sidebar 必须安装(未安装时本插件不激活,无任何 UI/行为,也不创建会话),且需 0.14.0+(对应 DSH 0.1.0-rc.8;rc.7 及更早的 DSH 环境无法解析本插件的 peer 依赖,请先升级 DSH)。
dsh plugin --profile web add dsh-better-sidebar@latest
安装
# 通过 npm(推荐)
dsh plugin --profile web add dsh-sidebar-qa
# 或本地路径
dsh plugin --profile web add <本仓库路径>
重启 dsh web(host 半改动需要重启;client 改动浏览器硬刷新即可)。
使用
- 在任意对话(主对话或追问对话)中划选一段文本,点击浮层「提问」。即使右侧面板处于收起状态也会自动展开(对应 issue #6),「追问」tab 直接可见——包括"先手动收起面板、再点提问"的重复场景。
- 右侧「追问」面板变成一条内嵌对话:引文/问题在侧边栏内流式回答,输入框固定在下方面板底部,不会跳转到子对话大窗口。
- 回答过程中可在输入框继续追问(Enter 发送、Shift+Enter 换行),所有问答都在侧边栏内完成。面板底部的输入框复用 DSH 主对话的输入栏外观(同一套设计 token 的圆角胶囊卡片):发起新追问时左侧是上下文策略 chip,右侧的模型选择(与主对话同一份
session.models/selectModel数据,切换互通)与 context 占用环(复用contextPressure投影)始终可见——新追问时它们绑定被追问的父会话(context 环即父会话占用,可据此判断用全量还是裁切;在面板切换模型会立即改父会话模型,全量继承的子会话天然沿用它,压缩/裁切子会话则使用你选的模型),继续已有追问时绑定该追问会话;最右侧为上箭头发送键。 - 每个追问仍是同工作区的独立会话(
❓追问·<主题>),主对话零打断;追问可以嵌套(在追问对话里再划选提问会生成新的子追问)。发起新追问时,输入框左侧的上下文策略 chip 可选择策略(默认取配置historyStrategy):- 全量继承:
sessions.fork从主会话最近的已完成 turn 分叉子会话,完整历史随种子继承,首条请求复用主会话消息前缀 → DeepSeek 自动前缀缓存命中、零压缩损失;子会话沿用主会话模型。主对话正在回答(无已完成 turn)时 fork 自动降级为「压缩」并提示。追问 tab 中,继承的父对话历史显示在分割条上方,默认视图锚定在本追问自己的「引用 + 提问」处,向上滚动分页加载父对话历史(与主对话「加载更早」体验一致)。 - 压缩:快速模型压缩较早窗口 + 近期原文保留(默认,省 token)。
- 机械裁切:最后
trimWindowMessages条消息原文直取,零 LLM 成本、确定性输出。
- 全量继承:
- 侧边栏「追问记录」tab 按根(主)会话分组,以分层树列出当前工作区内的所有(嵌套)追问(归属判定:当前会话所在工作区,见
src/client/history-scope.ts),点击跳转。有子追问的节点右侧有折叠按钮(箭头随折叠状态旋转)收纳子树,其左侧显示该对话组最近访问时间(相对标签,复用 DSH 左侧面板的样式与数据源sessions.list.updatedAt)。跳转后目标会话的追问记录 tab 保持开启(定向openTab(seed, scope),已打开则聚焦、未打开则新建)。被归档或删除的追问(用户自行管理会话时)会置灰并标注「已归档 / 已删除」,不可再点击跳转,行尾的「移除」按钮将其从记录中清除(连同整棵子树清理 localStorage 映射,DSH 侧会话本身不受影响)。
配置
配置走 DSH 设置服务 sidebarqa 命名空间(settings.yaml 或设置页)。Web 界面入口:DSH 设置 → 侧边卡片 → 「追问」卡片右上角的齿轮「功能配置」弹窗(由 dsh-better-sidebar v0.12+ 的 settings.render 提供),可逐项编辑下表字段——文本行 blur/Enter 提交,数字行按区间钳制,写入经 /sidebarqa/api/config.update 带 revision 乐观锁(多窗口冲突时提示重试)。回答/摘要的模型渠道与模型为下拉框,选项来自运行时已配置的渠道。
| 键 | 默认 | 说明 |
|---|---|---|
historyStrategy | compressed | 默认上下文策略:inherit 全量继承(fork+缓存命中)/ compressed 压缩 / trim 机械裁切(面板内可逐次切换) |
trimWindowMessages | 10 | 机械裁切模式保留的最近消息条数(1–256) |
summarizeProvider | '' | 摘要快速模型渠道;空 = 继承被追问会话的 provider |
summarizeModel | deepseek-v4-flash | 摘要快速无思考模型 |
summarizeReasoningEffort | off | 摘要思考模式(off/high/max 三档下拉) |
answerProvider | deepseek-official | 子对话回答模型渠道 |
answerModel | deepseek-v4-flash | 子对话回答模型 |
answerReasoningEffort | off | 子对话思考模式(off/high/max 三档下拉) |
面板只展示上述 8 项常用设置;压缩/标题的内部调参键(
summarizeBudgetTokens、recentWindowMessages、backgroundWindowMessages、titleBudgetTokens)不在面板暴露,仍可在settings.yaml的sidebarqa命名空间里配置。
压缩模式的下上文注入刻意保持轻量:旧背景压成最多 3 句话(目标 / 当前进度 / 未决事项),近期只保留最近 2 条且每段强截断(≤400 字符);模型侧从新到旧提交,让当前进度落在注意力最强位置。摘要失败/无渠道时自动降级为「仅近期对话 + 引文 + 问题」,问答不中断;全量继承失败(主对话正在回答)时自动降级为压缩模式。
架构
dsh-sidebar-qa (bundle: dsh.bundle + package.json#dsh.client)
├── src/index.ts host:/sidebarqa/api 摘要 + 标题服务 + sidebarqa 设置命名空间
├── src/summarize.ts 表面文本抽取 + 流组装(纯函数,可测)
├── src/title.ts 标题提示词 + 规范化 + Q+A 输入框定(纯函数,可测)
├── src/config.ts 设置 schema + 默认值
├── src/context-types.ts 结构化 cordis 服务面 + Context 增补
└── src/client/ 浏览器:选区捕获、浮层、问答面板、会话编排、追问记录
├── index.tsx apply:注册 2 个 better-sidebar tab + 浮层
├── selection.ts 选区捕获与校验(单消息/非流式/≤2000 字符)
├── SelectionPopover.tsx 划选浮层「提问」按钮
├── AskPanel.tsx 追问 tab(内嵌对话:流式 transcript + DSH 风格输入卡片 + 追问切换)
├── HistoryPanel.tsx 追问记录 tab(分层树:折叠按钮 + 最近访问时间 + 工作区限定 + 归档/删除置灰与移除)
├── history-scope.ts 工作区归属解析 + 树过滤 + 子树最近访问时间 + 会话状态判定(live/archived/gone)与子树移除(纯函数,可测)
├── history-time.ts 相对时间分桶 + 中文标签(纯函数,可测,复用左侧面板样式)
├── StrategySelect.tsx 上下文策略 chip(PermissionSelect 同款触发器 + Menu)
├── ModelSelect.tsx 模型选择(session.models/selectModel 驱动的双层菜单,与主对话互通)
├── model-menu.ts 模型目录扁平化/选中解析(纯函数,可测)
├── ContextMeter.tsx context 占用环(contextPressure 投影 + breakdown 面板)
├── context-meter.ts 占用百分比/紧凑 token 格式化(纯函数,可测)
├── ensure-panel.ts 面板收起自愈:展开判定 + 经 SidebarStore 展开(纯函数,可测)
├── tab-activation.ts onActivate 激活桥:收起后重新激活 tab 时再次自愈(issue #6)
├── orchestrate.ts create → 占位 rename → selectModel(默认 flash/关思考) → prompt + 继续追问 + 回答后重命名
├── ConfigPanel.tsx 功能配置面板(设置齿轮弹窗:编辑 sidebarqa 命名空间,回答/摘要模型渠道与模型下拉)
├── config-fields.ts 配置面板行声明 + 数字钳制 + catalog 选项解析(纯函数,可测)
├── store.ts 父→子 映射(localStorage 持久化,支持嵌套)+ 待提问引文 + 已命名标记
├── injection.ts XML 转义/消毒 + 注入格式 + 占位主题生成
├── answer.ts 历史流 → 回答文本折叠
└── api.ts /sidebarqa/api fetch 封装 + 当前模型读取
跨插件 seam(meta.quote)
外部插件可以打开追问 tab 并预填引文(不经本插件的划选浮层):通过 better-sidebar 的 openTab seed 携带 meta:
ctx.betterSidebar.openTab(
{ type: 'dsh-sidebar-qa:ask', meta: { quote: { text: '选中的内容', role: 'user' } } },
)
面板优先显示 meta.quote(形状校验:text 为非空字符串;可选透传 role / messageId),回退到本插件浮层的 pending 引文;用户输入问题发送后引文即被消费(updateTab 清除),刷新/再次聚焦不会复现旧引文。<quoted_context> 的 source 标签沿用 agent-history。
关键数据流
划选文本 ─▶ 浮层[提问] ─▶ 右侧面板(引文 + 底部输入框)
回车 ─▶ ① host 摘要:sessionQuery.readSurface(被追问会话) → llm 快速无思考模型压缩
② client 创建会话 sessions.create(workspaceId)
③ rename → "❓追问·<划选文本首行占位>"
④ selectModel(默认 deepseek-v4-flash, 思考关闭)
⑤ prompt(摘要块 + <quoted_context> + 问题)
─▶ 面板轮询 sessions.history 流式渲染 transcript(不跳转大窗口)
─▶ 首次 turn/end 后 ⑥ host 标题:Q+A 截断 → llm 快速无思考模型提炼 ≤15 字主题
→ rename 覆盖为 "❓追问·<最终主题>"(仅一次,失败保留占位)
─▶ 底部输入框继续追问;主对话零影响;追问可嵌套
上下文注入格式(首条消息)
<统领性指令:这是「侧边栏追问」,只围绕划选文本主题直接回答……>
【主对话上下文】
【背景】<模型压缩的旧历史,最多 3 句话>
【近期对话】<最近 2 条近原文,每条 ≤400 字符>
<quoted_context source="agent-history" label="Agent 回复"
message_id="<id>" role="assistant" turn="<n>">
<引文原文>
</quoted_context>
问题:<用户输入>
统领性指令置于输入最前,利用注意力机制让模型先定调「聚焦划选文本」再读上下文;用户问题虽然在输入末尾,但划选文本(quoted_context)与指令共同锚定了回答范围。追问会话内的后续消息默认不带主对话上下文(只有首条携带)。
构建与测试
pnpm install
pnpm build # tsc 声明 + tsdown(lib/index.js + lib/client.js + lib/client-registry.js)
pnpm test # vitest 单测(injection / summarize / answer / store / title / meta-quote / history-scope / history-time / model-menu / context-meter / config / ensure-panel / tab-activation)
pnpm typecheck
License
MIT
Read the usage guide →
Install steps, key points, FAQ and compatibility for this plugin — auto-derived from indexed fields.
Listing badge
[](https://deepseek-plugin.org/plugins/ChenRuoT/dsh-sidebar-qa)Paste this markdown into your GitHub README to link back to this listing. The badge only states the listing — not a security endorsement.