Skip to content

fix: dsh settings panel follows the live proxy origin instead of freezing on the boot snapshot (#2288) - #2289

Merged
ranxianglei merged 1 commit into
masterfrom
2026-10-07_dsh-settings-follow-live-origin
Oct 7, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-10-07_dsh-settings-follow-live-origin

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #2288

What & why

The dsh settings panel's "Open Web UI" button froze on whatever origin the page captured at boot (globalThis.__BILI__ snapshot): once any value was present, the useEffect guard skipped /bili/origin probing for the rest of the session. The snapshot goes stale by design on the server side — attach-mode presets publish the BILLION_CONTEXT_PROXY env origin at startup (currentOrigin() = register.base ?? env), while the host re-binds register.base at runtime (dead-attach fallback spawn #983/#1130, routed-origin convergence #1365). Result: the button kept pointing at the old/dead port (e.g. 8787 vs live 18798) for the whole session.

Note: the issue's reference to src/mcp.ts DEFAULT_PROXY_ORIGIN (8787) is unrelated to this path — that constant only serves the codex MCP lane. The staleness mechanism above is what reproduces the reported symptom.

Fix

Behavior change (old → new)

Config surface

None — no config/env/CLI changes.

Tests

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-07_dsh-settings-follow-live-origin (da880f0)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.2416-pr.2289.aa128d0

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-pr2289.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 唤醒。这是本账号先前会话已完成的工作(PR #2289,分支 2026-10-07_dsh-settings-follow-live-origin,head da880f0),按协议不重做,现执行核验:拉分支核对代码 → 本地定向测试 → CI 状态确认,结论稍后按七问体例回复。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 PR #2289 核验结论(七问)

已拉取分支(da880f0,基于当前 master tip 9f82bbed,无需 rebase,mergeable=true),逐行审完 diff(3 文件,+147/−39),本地定向验证通过。

  1. 是什么问题:dsh 设置面板「打开 Web UI」按钮冻结在页面启动时捕获的 origin 快照(如 8787),代理实际跑在别的端口(如 18798),点按钮开死链且整会话不自愈。设置面板「打开 Web UI」按钮显示错误的 origin(过时的 __BILI__ 启动快照 / 硬编码默认值 8787)— probeOrigin 被防护逻辑跳过 #2288 的用户定位(防护逻辑挡住探测)在表层正确;本 PR 进一步指出根因层——服务端快照设计上就会过时(attach 预设发布 env origin + host 运行时重绑 [dsh] native proxyEnvOrigin() 把临时 origin 冻结进 BILLION_CONTEXT_PROXY,绕过 ensureProxyRunning() 的 instance 验活;工具调用全部 fetch failed,需重启宿主 #983/native attach 模式无运行时 respawn:共享代理的属主退出后,attach 方全部模型请求永久硬失败 #1130/bug: dsh-native — attach 目标瞬时不可达 → 回退 spawn 第二实例:routed baseURL 下工具/模型通道必然脑裂(工具 404 → preflight 502 → 会话不可自愈) #1365),并正确排除了 issue 里 src/mcp.ts DEFAULT_PROXY_ORIGIN 的干扰项(那只服务 codex MCP 通道)。方向判对:修的是根因机制而非症状,一个「探测跟随整个挂载期」的机制同时覆盖「晚到」(Windows/dsh 宿主重启:代理就绪超出 SPAWN_WAIT_MS(20s) 导致 bootstrap 失败,本进程内无重试 → /bili/origin 恒为 null、设置面板永久"未绑定"、整场会话直连(压缩失效) #2187)和「中途搬走」(设置面板「打开 Web UI」按钮显示错误的 origin(过时的 __BILI__ 启动快照 / 硬编码默认值 8787)— probeOrigin 被防护逻辑跳过 #2288)两种失效。

  2. 什么原因导致的:客户端把「首个已知值」当最终值——effect 防护 if (origin !== undefined) return 让启动快照一旦有值就永久封死唯一的修正通道(/bili/origin 探测)。因果链:服务端重绑 register.base(正常设计)→ 快照过时(必然)→ 客户端停止探测(缺陷)→ 按钮指死链。

  3. 怎么修复的:快照降级为首帧提示,实时路由成为唯一权威源:probeOrigin 用跨轮次持久的 settled 标志(正确地放在 poll() 外),首次解析前快节奏(3s×10)、之后慢节奏(10s)无限跟随到卸载;effect 去防护、deps 改 [] 每挂载只跑一次,直接传 setOrigin(React 对相同值 bail out,无重渲染抖动)。另修了测试 harness 的 react stub(deps 比较 + 重跑前先 cleanup)——旧的每次渲染都跑的 stub 会在防护移除后静默起重复探测而掩盖问题,这个修正必要且正确。

  4. 是否有回归问题:审过的既有行为——给deepseek定制一个跳转到状态的链接 #1590 index-inject 注入逻辑(服务端 dsh-native.ts:761 未动)、dsh web端和桌面端点击bili设置显示未启动 #1809 路由注册/应答语义(未动)、feat(dsh): 设置栏入口迁到插件详情页配置区(plugins.bundle.config) #2125 双槽渲染与降级提示(面板 JSX 未动,无快照+无路由→hint 的路径保留)、Windows/dsh 宿主重启:代理就绪超出 SPAWN_WAIT_MS(20s) 导致 bootstrap 失败,本进程内无重试 → /bili/origin 恒为 null、设置面板永久"未绑定"、整场会话直连(压缩失效) #2187 解析前快慢节奏契约(!settled && attempts < 10 ? 3000 : 10000,未解析时与旧逻辑逐字节等价)、卸载取消 pending timer(cleanup 保留,deps [] → 仅卸载时触发)、首帧从快照出图(新测试钉住)——全部保持。唯一有意变更(PR 正文已按旧→新+原因披露):解析后探测不再永久停止,改为 10s 慢节奏持续到卸载。无无意回归。本地证据:typecheck 干净;PR head 上定向套件 tests/dsh-settings-ui.test.ts + tests/dsh-native.test.ts + tests/issue2187-dsh-spawn-retry.test.ts 53/53 通过(全量交 CI);测试跑的是 esbuild/tsup 真实构建产物进 vm,不是裸 TS 源码。

  5. 是否破坏缓存:不涉及——纯客户端 UI 代码,不触碰压缩、前缀缓存、重试或去重键。代价仅每个挂载槽每 10s 一次 localhost GET,可忽略。

  6. 是否改了设计方向:无架构转向。是 dsh web端和桌面端点击bili设置显示未启动 #1809 原始意图("entry upgrades without a reload")的补全:从「未解析前升级」扩展为「解析后继续跟随」。

  7. 是否引入了新的配置:无(env/config/CLI 均未动)。

测试有效性:两个新回归块都有牙——块一在旧防护下必挂(label 停在 8787),块二若解析后停止轮询会显式 throw,且用手动时钟把每次后续探测的 delay 钉死在 10000ms。非恒真断言,能兜底。

diff 整洁度:单一目的,每一行都与本 PR 相关,无空行/锁文件/生成物噪音;probeOrigin/readOrigin 无其他调用方(grep 确认),不存在依赖旧「解析即停」行为的隐藏耦合。review 中未发现需要顺手修的小问题。

CI 状态:head commit da880f0 上 19/23 绿(build-artifact、kernel-guard、lane-guard、docs-sync、version-guard、registry e2e ubuntu、全部真实客户端 e2e 车道),剩 4 个标准全量矩阵 job(ubuntu/windows × node 22/24)仍在跑,目前零失败。§7.4 自动合并门禁各项均满足(pure fix、单模块、回归测试、无 config/persistence/wire/kernel 触碰、引用 #2288),但合并归人工。

判定:代码与测试就绪,等剩余 4 个 CI 矩阵 job 转绿后即可人工合并。

antclt pushed a commit to antclt/billion-context that referenced this pull request Oct 7, 2026
…ei#2289 to ranxianglei#2281

The launcher -c insertion fix and its tests cited ranxianglei#2289, which does not
exist; the bug is tracked under ranxianglei#2281 (the issue this PR closes). Comment-
and-test-name-only change, no behavior delta.
@github-actions github-actions Bot mentioned this pull request Oct 7, 2026
@ranxianglei
ranxianglei merged commit db7344e into master Oct 7, 2026
23 checks passed
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.100-master.db7344e (rolling master tag).

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

None yet

Projects

None yet

1 participant