Repository navigation
[PR] dsh Context tab: bind the embedded frame to THIS conversation (#4117) - #4118
Conversation
The per-session Context tab polled /__bili/plugin/status?conversationId=dsh&fallback=latest. The conversations map is keyed by the host's REAL session id (the value the dsh lane stamps on x-bili-plugin-conversation), so the literal "dsh" exact lookup never hits and every read fell through to fallback=latest = most-recently-active session across the WHOLE proxy process. While an acp_delegate sub-agent (its own pi process, its own conversation id) is active, its session wins that pool: the iframe re-navigates to the child's page and flips back when the main agent resumes — the reported flicker. Fix (client-only; server byte-for-byte unchanged): - The host names this conversation to every conversation.view entry (props.sessionId — the same identity dsh-cost-meter reads from the slot props and from [data-conversation-session]); poll for THAT exact id. fallback=latest stays only so the pre-first-request panel still resolves before our own first request. - Ownership gate at render: a row resolved via the fallback pool whose conversationId is not ours (or carries none) is refused instead of framed — the not-yet hint stands. Exact hits are trusted unconditionally. - Hosts passing no props keep the historical behaviour bit-for-bit (legacy literal path + render unchanged). Tests: the embed pin now mounts with the host conversation identity, pins the exact-id status URL, and adds the refusal case (foreign via-fallback session ⇒ no iframe, not-yet hint); subMount cases stay prop-less and pin the legacy path.
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4915-pr.4118.fa0b08eThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr4118.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复。 全仓 open+closed issue/PR 检索(plugin/status fallback latest、conversationId、dsh Context tab、viaFallback/embedded frame 等失败签名)均无同症状同机制条目;本 PR 是 #4117 的首个修复,#4086 只是触发复现的装机版本,不是独立缺陷。 先报一个 阻断性发现(正在修 + 定向验证,随后给完整八问结论): PR 把「渲染时所有权门」列为核心机制之一,但客户端读的是响应字段
两者对不上 ⇒ 客户端 影响分层:
修法明确、无需决策:客户端 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.715-master.357c694 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #4117
症状
#4086(0.1.204-ctxembed.1)装机后用户复现:有
acp_delegate子 agent 运行时,dsh 客户端「上下文」页签的内嵌帧反复切换成子 agent 的会话页,主 agent 恢复活动又切回,来回闪烁。根因
页签轮询
/__bili/plugin/status?conversationId=dsh&fallback=latest。服务端conversationsmap 的 key 是宿主真实 session id(dsh lane 打进x-bili-plugin-conversation的initiator.session.id,src/agent/dsh-native.ts:2024/1428),字面量"dsh"精确查几乎永不命中 ⇒ 每次读都落fallback=latest= 全代理进程最近活跃会话(src/plugin.ts:1552,L1567)。子 agent 是独立 pi 进程、带自己的会话 id 打流量 ⇒ 其 lastSeen 变最新 ⇒ 页签被劫持;主 agent 恢复又切回 = 闪烁。同一 fallback 歧义还波及
/acp命令(fetchStatusLatest)与 MCP 重试 lane——本 PR 只修用户可见的页签面,二者留档为后续(见"已知余留")。修复(纯客户端,server 零改动)
dsh core 给每个 conversation.view 条目传 props——同 slot 的 dsh-cost-meter 直接读
props.sessionId(并与 DOM[data-conversation-session]比对),与 lane stamp 的 sid 是同一条身份链。于是:props.sessionId⇒ 按它精确查询(conversationId=<id>&fallback=latest;保留 fallback 只为让 pre-first-request 面板在首个请求前仍可解析)。viaFallback===true && conversationId !== 本会话id(或无 conversationId 字段可证)的行拒绝出帧,落「暂无上下文数据」诚实提示;精确命中无条件信任;旧响应体缺这两个字段 ⇒viaFallback=false,历史行为不变。验证
tsc --noEmit0 错;npm run buildrc=0(含 dist-import-annotations / dist-external 门)。tests/dsh-settings-ui.test.ts #3862重写扩展:主用例改以宿主身份挂载,钉住 exact-id status URL + iframe src/title/polling(10s)/refresh/unmount;新增劫持拒绝子例(外来 via-fallback 会话 ⇒ 无 iframe + not-yet 提示);既有降级态子例保持无 props 钉 legacy 路径。全绿。issue3862-context-view.test.ts+dsh-panel-embed-cors.test.ts合跑 7/7 绿。tools/gen-config-docs.mjs generate零 diff、scripts/check-unused-exports.mjsrc=0。tests/dsh-native.test.ts不加载客户端 bundle(grep 确认仅 mock/__bili/plugin/status服务端侧),失败集与 master 基线一致(此前电池已钉 IDENTICAL FAILURE SETS)。已知余留(后续 issue 候选)
/acp命令与 MCP 重试 lane 仍用 latest fallback:CommandsService handler 签名无参拿不到宿主会话 id("Host's command API passes no arguments"),需另找通路。sessionId(理论上 dsh-cost-meter 已在用,风险极低),页签自动退化为老行为——失败模式安全(无闪烁,最坏显示 waiting/hint 而非错帧)。