Skip to content

[PR] fix(dsh): make dsh.contextTab work on DSH Desktop — always emit the __BILI__ boot-snapshot row - #4848

Merged
ranxianglei merged 1 commit into
masterfrom
2026-10-26_dsh-contexttab-boot-snapshot
Oct 26, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-10-26_dsh-contexttab-boot-snapshot

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What

On DSH Desktop (Electron shell), dsh.contextTab: false (and BILI_DSH_CONTEXT_TAB=0) has no effect — the "Context" top-bar tab still registers on every cold start. Browser / Web GUI are unaffected.

Root cause

DSH Desktop collects the web index-injection table once at Host ready and serves that same snapshot to every page boot (DESKTOP_IPC.boot) — it never re-collects. bili's webserver/index-inject handler dropped the entire __BILI__ row whenever the proxy origin was not yet bound:

const origin = currentOrigin();
if (origin === undefined) return;   // spawn mode: register.base binds only after bootstrap
table.push({ kind: "global", name: "__BILI__", value: withCtxTabFace(...) });

In spawn mode the Host ready precedes the origin binding, so the row never lands in the one-shot snapshot. The client's readCtxTabFace() then fails open (snap !== undefined && snap.contextTab === false ⇒ missing snapshot ⇒ tab shown). Because desktop never re-collects, this is a permanent failure, not the transient "refresh fixes it" boundary the browser path has.

Fix

Emit the __BILI__ row unconditionally, using a null origin placeholder, mirroring the existing /bili/origin route expression exactly (so snapshot ≡ route at any instant):

const origin = currentOrigin();
table.push({ kind: "global", name: "__BILI__", value: withCtxTabFace(origin !== undefined && adminRelayEnabled() ? { origin: null, relay: true } : { origin: origin ?? null }) });

This decouples the Context-tab face flags (contextTab / contextTabLabel, read live from config) from origin readiness. The client's readOrigin() already treats a non-string origin as unresolved and keeps polling /bili/origin; readCtxTabFace() only needs contextTab/contextTabLabel. Page functionality is unchanged.

Behavior change (disclosed)

  • Before: when the origin was unbound, the __BILI__ snapshot row was absent ⇒ the client failed open and showed the Context tab regardless of dsh.contextTab.
  • After: the row is always present with origin: null + the live face flags ⇒ dsh.contextTab: false now hides the tab even before the origin binds.

Only observable effect: on hosts that snapshot before the origin binds (DSH Desktop; the first paint of a browser page), dsh.contextTab: false now takes effect immediately instead of being ignored until a refresh/restart. Default (contextTab: true) behavior is byte-identical (tab shown either way). No LLM-wire, config-schema, persistence, or kernel change.

I deliberately did not also flip the client gate to fail-closed (reporter's option 2): that would change the fail-open contract globally (browser + legacy hosts without the field) and is a product decision left to you. The host-side change alone closes this bug.

Tests

  • Flipped #1590: index-inject stays silent when no origin is known yet → now asserts the row lands as { origin: null, contextTab: true }.
  • Added #4846: config contextTab: false + origin unbound ⇒ snapshot row carries contextTab: false, and the /bili/origin route agrees (snapshot ≡ route).

Local: targeted suite green (26/26) + typecheck clean. Full-suite verdict from CI.

Closes #4846

….contextTab works on Desktop

The webserver/index-inject handler dropped the whole __BILI__ row when the
proxy origin was not yet bound (spawn mode binds register.base only after
bootstrap). DSH Desktop captures that table ONCE per app launch (a one-shot
boot snapshot) and never re-collects, so a dropped row is gone for the whole
session — unlike browser/web which re-renders the index per request. The
client readCtxTabFace() then fails open (missing snapshot => tab shown),
making dsh.contextTab=false / BILI_DSH_CONTEXT_TAB=0 a no-op on Desktop.

Emit the row unconditionally with a null origin placeholder, mirroring the
/bili/origin route expression so snapshot == route at any instant. readOrigin()
already treats a non-string origin as unresolved and keeps polling;
readCtxTabFace() only needs contextTab/contextTabLabel, so page semantics are
unchanged and fail-open shifts from "row absent" to "origin pending".

Flips the #1590 "stays silent when no origin" test to assert the row now lands,
and adds a desktop-boot regression test (config hide + origin unbound => row
carries contextTab:false).

Fixes #4846
@ranxianglei ranxianglei changed the title fix(dsh): make dsh.contextTab work on DSH Desktop — always emit the __BILI__ boot-snapshot row [PR] fix(dsh): make dsh.contextTab work on DSH Desktop — always emit the __BILI__ boot-snapshot row Oct 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-26_dsh-contexttab-boot-snapshot (f6b537b)

Latest build — install this exact version

npm install -g billion-context@0.0.6256-pr.4848.4abd46e

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

Recent builds (commit → version)

commit version build
f6b537b billion-context@0.0.6256-pr.4848.4abd46e build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr4848.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

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

查重:不重复。 本 PR 是 #4846(DSH Desktop dsh.contextTab:false 失效)的修复,与 #4846 一一对应;open 列表里同家族的只有 #4686(session fork 到 |sub: 车道后 Context tab 冻结在旧裸行)——症状相关但机制不同(#4686 是 fork 后行内容陈旧,本 PR 是 boot 快照整行缺失),非重复。近期无其他触碰 index-inject/contextTab 的在途 PR。

标签:bug / dsh / scope/wiring / p2(配置开关在桌面端稳定失效,功能缺陷但有绕行;浏览器端正常)

开始独立审核:核对分支代码、既有行为回归面、测试有效性,并查 CI 状态。结论稍后按结构化八问回复。

@ranxianglei ranxianglei added bug Something isn't working dsh p2 scope/wiring labels Oct 26, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

独立审核完成(分支 f6b537bd7,base = master 341e76c28,零落后;未照抄 issue 侧结论,以下全部为本人重读代码后的判定)。

结构化八问

1. 是什么问题:DSH Desktop 上 dsh.contextTab:false 完全失效——冷启动后 Context 顶栏标签永远注册。浏览器/Web 端不受影响。

2. 什么原因导致的:因果链分三层,已逐层验证——

  • 桌面壳在 Host ready 时一次性收集 index-inject 表并永久复用(从不重收集);
  • bili 的 index-inject handler 在 proxy origin 未绑定时 if (origin === undefined) return; 整行丢弃 __BILI__(spawn 模式下 register.base 在 bootstrap 后才绑定,ready 必然早于它);
  • 客户端 readCtxTabFace()(src/agent/dsh-native-client.ts:552-558)对「快照缺失」fail-open(snap !== undefined && snap.contextTab === false),于是标签常显。
    缺陷生产者 = 那个 early-return:它把「face flags(从配置实时读)」与「origin 就绪」耦合在一起;在一拍快照型宿主上这个耦合变成永久性丢失。修法在源头解除耦合,不是拦截症状。

3. 影响范围与严重程度:仅显式设置 dsh.contextTab:false(或 BILI_DSH_CONTEXT_TAB=0)的 DSH Desktop 用户;触发条件 = 每次冷启动,无绕行(桌面端刷新不存在)。程度 = 体验瑕疵(多一个不想要的标签页;压缩本身、账本可达性均不受影响)。默认值(true)用户零可观测量变化。

4. 怎么修复的:行无条件发出,origin 用 null 占位,表达式与 /bili/origin 路由逐字相同(已核对 src/agent/dsh-native.ts:1765 与 :1802 —— 同一表达式字符串),因此「snapshot ≡ route」在任意时刻成立,包括 relay+未绑定角落(两处都发 {origin:null} 不带 relay 标记——不存在不一致)。客户端零改动且自洽:readOrigin()(:535-544)把非字符串 origin 判为未解析,轮询走同源相对路径(probeForms :645-656 不需要绝对 origin);readCtxTabFace() 只需两个 face 字段。门禁决策点(client apply :1116-1122)未动。

5. 是否有回归问题:触碰路径的既有行为逐项清点——

既有行为 结论
attach 模式(origin 已知)行形状 保持(#1590 attach 测试钉住)
spawn/浏览器首帧(未绑定) readOrigin() 前后都返回 undefined(null≠string)→ 客户端行为字节级一致;唯一差异是显式 false 时标签从首帧起隐藏 = 披露的有意变更
relay 模式 + origin 已知 前后同为 {origin:null, relay:true}(现有 relay 测试 :833/:1560 钉住)
relay 模式 + origin 未绑定 前行缺失 → 现 {origin:null} 无 relay 标记——与该状态下路由早已返回的值一致(路由本身未改),客户端继续同源轮询,无新状态
TUI/headless profile(无 webServer) index-inject 根本不收集,不变
旧版宿主客户端 只读 origin/relay,多余字段被忽略
LLM wire / 配置 schema / 持久化 / kernel 均未触碰

高危模式逐项过:无 fail-fast 变吞错、无阈值/时序漂移、无输出格式变化(除披露的行存在性变化)。未发现回归。

6. 是否破坏缓存:不涉及(无缓存/重试/游标/去重路径触碰;wire 零改动,前缀缓存不受影响)。

7. 是否改了设计方向:无架构转向。一处有意的契约细化:__BILI__ 快照行从「仅 origin 已知时存在」变为「恒存在」——行成为 face flags 的载体,与 origin 就绪解耦;origin 语义不变(null = 未解析,走路由轮询)。PR 有意不做客户端 fail-closed 翻转(那会全局改变 fail-open 契约)——判断正确,留给 owner 决策。

8. 是否引入了新的配置:无。

行为变更披露(旧→新)

  • 旧:origin 未绑定时 __BILI__ 快照行缺失 ⇒ 客户端 fail-open,dsh.contextTab:false 被忽略(桌面端永久、浏览器端至刷新为止)。
  • 新:行恒存在,origin:null + 实时 face flags ⇒ 显式 false 在 origin 绑定前即生效。
  • 原因:一拍快照宿主上「行缺失」不可恢复,face flags 必须独立于 origin 就绪送达。默认值路径字节级一致。

测试有效性与 CI

Diff 整洁度与自动合并门槛

2 文件 43+/7-,每一行都与本 PR 目的相关;注释解释的是「为什么」(#4846 机制),非复述代码。无无关改动、无版本 bump、无 kernel 触碰。§7.4 自动合并门槛逐条满足(单模块 fix、有回归钉、rebased head 绿、纯 fix:、引用 #4846、不碰承重基建)。

结论:可合并。 建议 owner 直接 merge:#4848

@ranxianglei
ranxianglei merged commit 42529ea into master Oct 26, 2026
90 of 129 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.862-master.42529ea (rolling master tag).

npm install -g billion-context@0.0.862-master.42529ea  # 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

Labels

bug Something isn't working dsh p2 scope/wiring

Projects

None yet

1 participant