Skip to content

fix: cover the DSH lane with the #2354 host-title channel (#2604) - #2615

Merged
ranxianglei merged 3 commits into
masterfrom
2026-10-10_dsh-host-title-channel
Oct 10, 2026
Merged

ranxianglei merged 3 commits into
masterfrom
2026-10-10_dsh-host-title-channel

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #2604

是什么问题

面板 GET /__bili/sessions 的会话标题显示优先级是 hostTitle || title || …,但 #2354(v0.1.188)加的 POST /__bili/plugin/session-name 通道只接了 pi 车道——dsh-native.js 里根本没有这个端点的调用。于是所有 DSH 会话都落到「第一条用户消息截断」的兜底标签上,与宿主 session/list 的真实名字 0 条一致。

修复方式(机制层面)

dsh 自己拥有会话名:dsh-session-title 服务在 fallback 创建、LLM 生成接受、用户重命名时都会追加 log-backed 的 session/title 事件(latest-wins)。本 PR 让 dsh-native 插件把这条既有事件流镜像到代理端点,完全复用 pi.ts #2322 的模式:

  1. 事件镜像:订阅 cordis session/event,type === "session/title" 且 title 非空 → fire-and-forget POST {conversationId, name}(5s 超时,失败删除去重键自动重试;去重键按 base\u0000sid 计,代理 respawn/rebind 后新 base = 新键,自动重新学习全部标题)。
  2. boot sweep:通过现有动态 ctx.inject 纪律解析 sessions / sessionTitle 两个服务(缺失则静默降级为 面板会话名与 DSH 实际会话名不一致(hostTitle 通道未覆盖 DSH 车道) #2604 前的无标签行为,不阻塞启动),对已存活会话折叠快照补种——覆盖「标题事件全部早于本进程」的 resume 场景。
  3. 懒重标:headersFor 打戳处对未上报的 sid 做一次 store 查询 + 补种——覆盖代理重启后首个带流量请求。

不新增任何配置/env/端点;服务端零改动(端点 v0.1.188 已存在)。旧版本宿主(无这两个服务)行为与之前完全一致。

验证

  • npm run typecheck 干净。
  • tests/dsh-native.test.ts 51/51(含 5 个新场景:事件推送+去重+重命名、失败重试、boot sweep+懒重标、无服务降级、base 切换重新武装)。
  • 其余引用该模块的定向套件全绿:issue2101-dsh-reactivation / issue2082-dsh-recovery / issue2187-dsh-spawn-retry / dsh-fork-adopt / dsh-settings-ui 共 34/34。全量回归与真实 dsh e2e(ACP_TEST_E2E_DSH_NATIVE=1)交给 CI。

附带问题(面板幽灵行)的处理说明

issue 附带的「标题生成请求 / 压缩检查点被当成独立会话行」不在本 PR 范围内——它是另一个机制域(请求进入 bili 时的身份解析路径),且本机无法复现用户桌面环境。机制分析见 issue 回复:两类候选生产者(toolsReady 窗口内未打戳流量 → 匿名前缀亲和会话;或带工具的形状逃逸 side-lane → persona fork |sub:<fp>),需要 issue 作者提供幽灵行的 sessionId 形态(是否带 |sub: 后缀)来定位是哪条路径。定位后另行立项/修复。

config surface

不涉及:无新 env、无新配置字段、无新 CLI flag,复用既有 __bili/plugin/session-name 端点契约。

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-10_dsh-host-title-channel (5ed065d)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.2891-pr.2615.7a30032

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr2615.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 PR review 完成 — 可合(待 CI 最终绿)。我拉取了分支逐行审了 diff、核对了端点契约与 pi.ts #2322 参照实现、本地跑了定向测试,并顺手补了一个测试 commit(见下)。

结构化八问:

  1. 是什么问题:DSH 车道的会话在面板里全部显示「第一条用户消息截断」的兜底标签 —— feat: follow the host session name in the web UI (#2322, B-channel) #2354(v0.1.188)加的 POST /__bili/plugin/session-name(hostTitle,显示优先级 hostTitle || title)只接了 pi 车道,dsh-native 插件从没有这条通道的调用,面板名字与宿主 session/list 的真实名字 0 条一致。
  2. 什么原因导致的:机制层面是「通道未接线」而非显示 bug——服务端端点早已存在(src/server/admin.ts:412,v0.1.188 起),但 dsh 车道没有任何宿主侧发送方;dsh 自己拥有会话名(dsh-session-title 服务在 fallback 创建/LLM 生成接受/用户重命名时发 log-backed session/title 事件,latest-wins),这条事件流此前无人镜像到代理。
  3. 影响范围与严重程度:仅 DSH native 车道用户在面板/导出里看到的标题字段;压缩、wire、身份绑定全部不受影响。严重度 = 体验瑕疵(功能正常,只是看不到宿主真实名字)。issue 附带的「幽灵行」问题按 PR 说明明确不在本 PR 范围(另一机制域,等用户提供幽灵行 sessionId 形态后另行定位)。
  4. 怎么修复的:完全复用 pi.ts [pi] Web UI 会话标题固定为第一条用户消息,不跟随 /name 会话名 #2322 的既有模式,三层覆盖:①事件镜像——订阅 session/event,type === "session/title" 且非空 → fire-and-forget POST(5s 超时,失败删去重键自动重试);②boot sweep——动态 inject 解析 sessions/sessionTitle 服务后对存活会话折叠快照补种(覆盖标题事件全早于本进程的 resume);③懒重标——headersFor 打戳处对未上报 sid 做一次 store 查询补种(覆盖代理重启后首个带流量请求)。去重键按 ${base}\u0000sid 计,比 pi 的纯 sid 键更完备:代理 respawn/rebind 后新 base = 新键,自动重新学习全部标题。服务缺失时静默降级为 面板会话名与 DSH 实际会话名不一致(hostTitle 通道未覆盖 DSH 车道) #2604 前行为,不阻塞启动。
  5. 是否有回归问题:逐项审过既有行为——(a) 模型请求 wire 字节:ensureDshTitleReported 在 dsh-native.ts:1262 打戳处调用,不改 headers 对象(1269 行全新构造)、内部全部 try/catch + fetch 拒绝已捕获、不可能抛异常,零影响;(b) 两种压缩模式:纯插件侧管理面 POST,不触碰消息重建/tool 注入/acp_summary/nudge;(c) webserver/index-inject 既有行为:仅加显式类型标注,逻辑不变;(d) PluginContext.on 签名放宽为联合类型:该类型文件局部无外部引用,union 向后兼容;(e) 热路径成本:稳态每 stamped 请求一次字符串拼接 + Map.has,可忽略;(f) 旧版本宿主(无这两个服务):行为与之前字节级一致。未发现回归。
  6. 是否破坏缓存:不涉及——不动前缀缓存、会话身份、任何代理侧失效策略;新增的 dedup map 是模块局部结构,与缓存无关。
  7. 是否改了设计方向:不涉及——完全沿用 [pi] Web UI 会话标题固定为第一条用户消息,不跟随 /name 会话名 #2322/feat: follow the host session name in the web UI (#2322, B-channel) #2354 确立的 hostTitle 通道架构,只是把覆盖面从 pi 车道扩到 dsh 车道。
  8. 是否引入了新的配置:不涉及——无新 env/配置字段/CLI flag,复用既有端点契约(PR 的 config surface 声明属实,已核实)。

验证证据(本地定向,全量回归按纪律交给 CI):

  • npm run typecheck 干净;
  • 定向套件本地 85/85 绿:tests/dsh-native.test.ts 51/51(含 5 个新场景)+ issue2101-dsh-reactivation / issue2082-dsh-recovery / issue2187-dsh-spawn-retry / dsh-fork-adopt / dsh-settings-ui 共 34/34;
  • 端点契约核对:src/plugin.ts:787-788 写/删 meta.hostTitle,显示优先级 hostTitle ?? title 在 admin/export/web 四处一致;
  • 新模式 parity:与 src/agent/pi.ts:256-276 逐行对照,结构相同(dedup map、乐观先置位、!ok/catch 删除重武装、5s 超时),dsh 版多出的 base 前缀键是实质性改进。

review 中发现的小问题处置(小问题直接修,不留「仅报告」):

  • ✅ 已修:T3 场景缺懒重标路径的去重负向断言(第二次打戳不会重复 POST 未被钉住)→ 已推 91536833b test: pin the lazy title re-label dedup negative (#2604 review)(独立标注 commit,本地复跑 51/51 绿)。
  • 两处判定为有意 parity、不处理:reportDshSessionName 里 (name === "" && prev === undefined) 分支在所有调用方预过滤空串后不可达,以及 dedup map 无界增长——两者均与 pi.ts [pi] Web UI 会话标题固定为第一条用户消息,不跟随 /name 会话名 #2322 逐字一致(pi.ts:264 / lastReportedNames),保持两个平行实现的一致性优先,不是缺陷。

残余风险(诚实披露):dsh cordis 事件形状(session/title、data.title)在本沙箱无法对真实 dsh 验证——若形状与实际不符,通道静默 no-op(安全降级,只是不出标签,不崩不阻塞)。CI 的 real-dsh headless lane 可部分覆盖;最终确认建议升级 bili + 重启 dsh 桌面后看面板标题是否与 session/list 对齐。

结论:代码方向正确、机制层修复到位、无回归、diff 干净(2 文件每行都与目的相关)。CI 在新 head 91536833b 上运行中(26 个 job 排队中),绿后即可由人合并——我无法代合。附注:原 head 0b0cb8b1d 的 CI 在我审查时已完成项全部 success(kernel-guard/build-artifact/e2e/dsh plugin lane/registry e2e 等),无失败记录。

ework-agent added 2 commits October 10, 2026 15:54
The panel labels conversations from meta.hostTitle when present, but only the pi lane ever pushed one, so every DSH conversation fell back to the truncated first user message. The dsh-native plugin now mirrors dsh's own session/title events (fallback creation, LLM acceptance, user rename) to /__bili/plugin/session-name, seeds resumed sessions from the folded snapshot at boot, and re-labels sids lazily on first stamped traffic after a proxy respawn. Both services are optional; older hosts degrade to the pre-#2604 labelless behavior.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Review 第 2 轮结论(rebase + CI 裁定)

首轮回复后 master 前进(base 059d67c7e → tip 98fb91cc2,含 #2554/#2610/#2616)。按 §7.2「rebase 到当前 master 再下可合结论」执行:

CI 裁定(新 head 24/26):

  • 全绿:ubuntu 矩阵、全部 e2e 车道(含 real-dsh e2e-native-dsh、e2e-dsh-plugin-lane)、kernel/pi-subagents guard、build artifact。
  • 两红 = test (windows-latest, 22) / (windows-latest, 24)——master 既有问题,与本 PR 无关:master tip 98fb91cc2 自己的 CI run 38034641775 挂的正是同样两个 job(前一提交 f3efdca3e 全绿 run 38034523188)。根因已定位:eb0e4d2db(fix: retry MALFORMED_RESPONSE on DSH built-in DeepSeek routes (#2605) #2610)新增 tests/issue2605-dsh-retry-patch.test.ts,对仓库文件 dsh.bundle.patch.yml 做多行精确字面量匹配;.gitattributes 目前只钉了 golden json 的 eol=lf(test: wire-contract anti-regression system — parity fakes, goldens, unified ledger #1305 先例,注释里写的就是这个失败类别),Windows runner 签出转 CRLF → LF 字面量必然失配。overlay lane 用例通过(writeDshAcpPatch 运行期写盘恒 LF)反证了机制。已立项 #2631(带来源标记,含证据链、影响面与修法建议:gitattributes 钉 dsh.bundle.patch.yml text eol=lf + 测试读后归一化双保险)。

结构化八问(本轮增量):

  1. 是什么问题:本 PR 自身无新问题;本轮发现的是 master 既有的 Windows CI 红。
  2. 什么原因导致的:.gitattributes eol=lf 覆盖缺口 × 多行字节级精确字面量断言,由 fix: retry MALFORMED_RESPONSE on DSH built-in DeepSeek routes (#2605) #2610 引入,Windows autocrlf 签出触发。
  3. 影响范围与严重程度:10-10 07:30Z 起每个 PR 的 CI 都带 windows 两腿红,阻塞绿色合并;纯测试门禁,无产品行为影响。
  4. 怎么修复的:不在本 PR 修(超范围、不同机制域)→ 立项 Windows CI 全红:#2610 新增的 bundle-patch 测试对 CRLF 签出的 yml 做字节级精确匹配(.gitattributes 未覆盖) #2631,建议双保险修法。
  5. 是否有回归问题:无。本 PR 仍只触碰 src/agent/dsh-native.ts + 其测试;master 漂移逐项核对零重叠、语义互补或正交。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:无。
  8. 是否引入新配置:无。

判定:可合。 本 PR 验证闭环(方向/回归/代码/测试有效性/diff 整洁均过,head 对当前 master mergeable=true)。仅剩两红为 master 既有问题(#2631):等 #2631 落地后再合可获全绿,或知悉后直接合并(windows 红在 #2631 修复前会一直存在,与是否合并本 PR 无关)。

@ranxianglei
ranxianglei merged commit bc0628b into master Oct 10, 2026
27 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.231-master.bc0628b (rolling master tag).

npm install -g billion-context@0.0.231-master.bc0628b  # 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.

@ranxianglei
ranxianglei deleted the 2026-10-10_dsh-host-title-channel branch October 15, 2026 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

面板会话名与 DSH 实际会话名不一致(hostTitle 通道未覆盖 DSH 车道)

1 participant