Skip to content

[PR] fix(dsh): hide the host composer seat while the Context tab is open (#4406) / 打开上下文标签页时隐藏宿主 composer 座位 - #5837

Merged
ranxianglei merged 1 commit into
ranxianglei:masterfrom
TLEWA:2026-11-07_context-tab-hide-composer
Nov 8, 2026
Merged

ranxianglei merged 1 commit into
ranxianglei:masterfrom
TLEWA:2026-11-07_context-tab-hide-composer

Conversation

@TLEWA

@TLEWA TLEWA commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

中文

问题

「上下文」(Context)标签页接管整个会话区后,宿主(dsh)的 composer 座位仍然钉在它下面:输入框、任务条(todo dock)、目标框都还显示着,任务条会浮在上下文面板下方,输入框还会被窗口底边裁掉。

根因

conversation.view 注册项会拿走整块会话视图,但宿主没有提供任何「隐藏 composer 座位」的注册开关。dsh 自带的上下文面板(dsh-context)是自己给滚动容器打上 data-lc-surface 标记、再自带一条 CSS 把座位隐藏掉的;本插件的 Context 标签页没有做这一步,于是座位照常渲染。

改动

  • src/agent/dsh-native-client.ts:Context 标签页在挂载后用 useLayoutEffect 找到自己所在的 [data-conversation-scroll] 容器,打上 data-bili-surface 标记,卸载时移除;同时按需注入唯一一条样式规则,把该容器下的 [data-composer-seat] 隐藏。规则沿用宿主同款写法,但作用域是自己的属性,不会和 dsh-context 抢同一个节点。
  • 规则带 :not(:has([data-approval-key],[data-question-key],[data-plan-review-key])):审批 / 提问 / 计划评审这类接管面板出现时座位保持可见,待处理的提示不会被藏到标签页背后。
  • src/agent/dsh-native-client-react-shim.d.ts:补上 useLayoutEffect / useRef 声明(客户端包不装 react,靠运行时注入)。
  • 客户端包的 typecheck 不带 DOM lib,因此样式注入走一个很窄的 globalThis.document 类型面,而不是裸 document。

验证

  • npm run typecheck:通过。
  • npm run build:通过(dist-import-annotations: OK、dist-external: OK)。
  • node --import tsx --test tests/dsh-settings-ui.test.ts:27/27 通过,含新增用例(标记只注入一次、滚动容器被打上标记、规则含 approval/question/plan-review 例外、卸载后标记被移除)。
  • 真机验证:本机 dsh web(1258×802)上打开 Context 标签页,composer 座位 display:none、任务条高度归零、会话区铺满;切回「对话」标签页后座位恢复、任务条重新出现。

测试夹具

新增用例需要 effect 在 ref 挂载之后运行(React 语义)。原来的 runEffect 在 render 内联执行,此时 ref 还是 null,因此改为把 effect 排到本次 render 结束、树构建完之后统一 flush;resetHooks 一并清空队列。

Fixes #4406


English

Problem

Once the Context tab takes over the conversation surface, the host composer seat stays pinned underneath it: the input, the todo dock and the goal box keep rendering, so the task bar floats under the context panel and the composer gets clipped by the window edge.

Root cause

A conversation.view entry owns the whole conversation surface, but the host exposes no registration switch to hide its composer seat. dsh's own context pane (dsh-context) marks its scroll container with data-lc-surface and ships the CSS that hides the seat itself; this plugin's Context tab never did that, so the seat kept rendering.

Changes

  • src/agent/dsh-native-client.ts: after mount, the Context tab uses useLayoutEffect to find the enclosing [data-conversation-scroll] container, marks it with data-bili-surface, and drops the marker on unmount; it also injects one style rule on demand that hides [data-composer-seat] under that container. Same shape as the host's own rule, but scoped to our attribute so the two can never fight over one node.
  • The rule carries :not(:has([data-approval-key],[data-question-key],[data-plan-review-key])): approval / question / plan-review takeovers keep the seat visible, so a pending prompt is never hidden behind the tab.
  • src/agent/dsh-native-client-react-shim.d.ts: declares useLayoutEffect / useRef (the client bundle installs no react; it arrives at runtime).
  • The client bundle typechecks without a DOM lib, so the style injection goes through a narrow globalThis.document surface instead of a bare document.

Verification

  • npm run typecheck: passes.
  • npm run build: passes (dist-import-annotations: OK, dist-external: OK).
  • node --import tsx --test tests/dsh-settings-ui.test.ts: 27/27 pass, including a new case (style injected once, scroll container marked, rule keeps the approval/question/plan-review exception, marker removed on unmount).
  • Live check on a local dsh web host (1258×802): with the Context tab open the composer seat computes display:none, the todo dock collapses to zero height and the conversation area fills the pane; switching back to the chat tab restores the seat and the task bar.

Test harness

The new case needs effects to run after refs are attached (React semantics). The old runEffect ran inline during render, where the ref is still null, so effects are now queued and flushed once the tree for that render is built; resetHooks clears the queue too.

Fixes #4406

…anglei#4406)

conversation.view entries own the whole conversation surface, but the host
keeps its composer seat (input, todo dock, goal box) pinned under them and
offers no registration switch to turn it off. The tab now marks its own
scroll container with data-bili-surface and carries a single scoped rule
that hides the seat, the same shape dsh's own context pane uses with
data-lc-surface. Approval, question and plan-review takeovers keep the
seat visible, so a pending prompt is never hidden behind the tab.

The client bundle has no DOM lib in its typecheck, so the style injection
goes through a narrow globalThis document surface, and the react shim
gains useLayoutEffect/useRef for the post-commit marking.

tests: the settings harness now defers effects to the end of a render pass
(React commits refs before effects run), which the new case relies on.
@ranxianglei ranxianglei changed the title fix(dsh): hide the host composer seat while the Context tab is open (#4406) / 打开上下文标签页时隐藏宿主 composer 座位 [PR] fix(dsh): hide the host composer seat while the Context tab is open (#4406) / 打开上下文标签页时隐藏宿主 composer 座位 Nov 6, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重:不重复。 #5837 是引用 #4406 的唯一 PR,无已合并或并行的同类修复(#4406 仍 open)。

标签: dsh / scope/ui / p3 —— dsh 车道的客户端 UI 展示面改动;纯外观/体验瑕疵、不阻塞使用,按「功能请求不算 bug」不打 bug,定 p3。(保留原有 pr。)

结论先行

方向正确、实现干净、失败模式优雅降级(即便宿主选择器对不上,最坏也只是「座位照旧显示」= 现状,无崩溃 / 无数据丢失 / 无线上协议影响),测试有牙。CI 静态门禁(typecheck + build + dist 标注/外部检查)ubuntu/windows 已绿;11 个 test(...) 分片在途、failed=0。可合(mergeable-with-caveats),前提 = CI test 分片转绿 + owner 认可宿主选择器契约(见第 5 问残留风险)。

结构化八问

  1. 是什么问题:Context(上下文)标签页接管整块会话区后,宿主 dsh 的 composer 座位(输入框 / todo 任务条 / goal 框 / queue dock)仍钉在只读报告页下方——任务条浮在面板底下、输入框被窗口底边裁掉。
  2. 什么原因导致:conversation.view 注册项拿走整块会话视图,但宿主没有「隐藏 composer 座位」的声明式开关;本插件的 Context 标签页没像宿主自带的 dsh-context 面板那样给滚动容器打标记 + 自带一条隐藏 CSS,于是座位照常渲染。
  3. 影响范围与严重程度:仅 dsh web/desktop 且打开 Context 标签页时可见的外观问题。报告本身可读、该 tab 本就只读(不在此对话),属体验瑕疵(p3),非功能损坏、非阻塞。触发条件 = 装了 bili dsh 插件并点开 Context tab。
  4. 怎么修复的:Context 标签页挂载后用 useLayoutEffect 找到自身所在的 [data-conversation-scroll] 容器打上 data-bili-surface 标记、卸载时移除;同时幂等注入唯一一条 scoped CSS,把该容器下作为直接子节点的 [data-composer-seat]:not(:has(审批/提问/计划评审)) 置为 display:none。规则作用域绑自己的属性,与宿主 data-lc-surface 互不抢同一节点;:not(:has(...)) 例外保证审批 / 提问 / 计划评审这类仍需交互的接管面板出现时座位保持可见。这正是 issue [Feature][dsh] The "Compression Agent" tab should not render the host composer (input field / task list / goal box) | [Feature][dsh] 「压缩代理」标签页不应渲染宿主 composer(输入框 / 任务列表 / goal 框) #4406 自己给出的 bili 侧短期方案(建议fix: address all code review findings (condense, routing, session-id, dead code) #2);长期正解(宿主给 conversation.view 加 composer:"hide" chrome 开关,建议fix: keep system prompt byte-stable for prefix cache #1)属 dsh 宿主仓库,不在本 PR 范围。
  5. 是否有回归问题:审过的既有行为——contextPanel 渲染输出不变(根 div 仅多一个 ref,DOM 不可见);新增副作用只影响匹配 [data-bili-surface] 的元素(bili 私有属性,宿主不认识,无跨交互);注入样式仅在「已标记 && 座位是直接子节点 && 无审批/提问/评审」三者齐备时命中,爆炸半径极小;卸载即移除标记,样式标签全局至多一个、失配时匹配不到任何元素、无害。高危模式逐项过:无语义漂移 / 无 fail-fast 变吞错 / 无阈值·时序·输出格式漂移 / 无缓存·重试·去重键变化。
    • 残留风险(诚实边界):CSS 命中的那批宿主属性(data-composer-seat / data-conversation-scroll / data-approval-key / data-question-key / data-plan-review-key)在本仓内零引用,属宿主契约、仓内无法验证正确性;单测只对 mock DOM 验逻辑、不验证真实宿主匹配;且用直接子组合子 > 假定座位是滚动容器的直接子节点。作者声称真机(dsh web 1258×802)实测 display:none、切回对话 tab 座位恢复。因失败模式优雅(选错→座位照旧显示=现状),此项是健壮性关注而非 blocker;建议 owner/dsh 维护者确认这些属性跨 dsh 版本稳定。
  6. 是否破坏缓存:不涉及。纯客户端 UI chrome 操作,不触碰压缩 / 前缀缓存 / 会话线。
  7. 是否改了设计方向:不涉及架构转向。沿用 issue 既定的 bili 侧 CSS 兜底路线,且与同文件既有宿主 DOM 访问风格一致(窄 globalThis.document cast + guard-wrapped 早退,参考 detectHostTheme / probeForms)。未引入新配置面、未引入新依赖。
  8. 是否引入新配置:不涉及。无新 env / config / 默认值。

代码整洁(外部提交从严,逐项过)

命名达意(BILI_SURFACE_ATTR/BILI_SURFACE_CSS/biliSurfaceDoc/ensureBiliSurfaceStyle)· 无死代码 · 无重复到需抽公共 · 错误处理完整(doc === undefined / scroll === null 均早退,无空 catch 无吞错)· 无魔法串(均为具名常量)· 注释讲 why · 风格跟仓库既有 · 零新增依赖 · 函数短小 · 测试有真断言(一次性注入 / 标记落位 / 含例外 / 卸载移除 / 重渲不重复注入——任一回归都能咬住)。达标,无需重构对齐。

CI 状态(mirror sha 204f79f)

static-gates(typecheck+build+dist 标注/外部)ubuntu/windows 均 success;mysql-contract / pi-subagents-guard / test-import-graph / lock-sync 均 success;11 个 test(...) 分片 in_progress、failed=0;e2e/real-lane 各 lane skipped(gated,符合预期)。本地未全量复跑:工作区无 node_modules,static 门已在 CI 绿、test 分片即权威判定,为避免挤占共享资源不另起全量安装。

判定

可合(待 CI test 分片转绿即由 owner 合并)。无小问题需顺手修,无需要 owner 拍板的决策点(方向与 issue 自提方案一致)。若要更稳,可在合并说明里补一句:宿主选择器以作者真机实测为准;若后续某 dsh 版本座位未被隐藏,则按 issue #4406 建议#1 走宿主侧 composer:"hide" 开关根治。

@ranxianglei
ranxianglei merged commit f1a4af4 into ranxianglei:master Nov 8, 2026
88 of 129 checks passed
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.1093-master.f1a4af4 (rolling master tag).

npm install -g billion-context@0.0.1093-master.f1a4af4  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants