Skip to content

feat(web): detailed visual config form over the raw JSON editor (#1748) - #1752

Closed
ranxianglei wants to merge 2 commits into
masterfrom
2026-09-30_web-config-buttons
Closed

ranxianglei wants to merge 2 commits into
masterfrom
2026-09-30_web-config-buttons

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What

#1748 — web 页面配置按钮化。The config page now renders a detailed visual form covering every field of ~/.config/billion-context/config.json, above the raw JSON editor which is kept as-is as the advanced escape hatch (per the issue: "保留原来的json高级配置").

Design

  • One control per known field, grouped: server (port/host/upstream/logFile/sessionHeader/dumpSse/log), compress (all flat CompressSettings fields incl. pct-or-number inputs like modelContextLimit/maxContextLimit, tool lists, and JSON boxes for sub-objects like prompts/absorb/ccr/reasoning), update, behavior (passthrough/debug/modelContextLimit/maskHosts/subagentSplit/forkAdoption/resumeInheritance/chainContentDetection/stableSystemAnchor/imageBilling), advanced (promptCache.routing/mitm/compat/claude.nativePort/native.attachExternal), plus a providers section (add/remove routes; per-route models/proxy/compressProtocol/passthrough/direct/imageBilling/compress/compat) and an other-keys section (any unmodeled top-level key gets its own JSON box).
  • Whole-file save contract: saving deep-clones the current document and applies only the modeled controls, then PUTs {file}. Unmodeled keys at every level survive byte-for-byte (pinned by test). The form never invents values for what it doesn't model.
  • Env-lock visibility: GET /__bili/config now includes read-only envForced (dot-path → env var names) computed from the same resolution order as src/config.ts. Controls whose effective value an env var currently overrides render locked with a badge naming the variable instead of letting a file write silently lose to it.
  • The old passthrough status card is folded into the form (toggle + source note); the raw editor's unsaved-changes guard now also covers the form.

Config surface

No new/renamed/re-semantics'd config fields — the form edits exactly the existing file schema; no new env vars or CLI flags. The only API delta is the additive read-only envForced object in the GET response.

Behavior changes (flagged)

  • GET /__bili/config response gains envForced (additive; old clients ignore unknown keys).
  • UI: the standalone passthrough card (badge + clear button) is replaced by the in-form passthrough toggle with an env/file source note. Clearing via the raw JSON box still works unchanged. Intentional UX consolidation, no semantic change.

Pre-flight

  • npm run typecheck — clean
  • npm test — 3235 pass / 1 fail / 12 skipped; the single failure (issue1452-socket-hardening.test.ts stall-guard timing test) is unrelated to this diff and passes in isolation (full-suite load flake)
  • npm run build — OK
  • New regression suite tests/web-config-form.test.ts: envForced reporting, whole-file PUT preservation of unmodeled keys, client wiring presence, exact-path env lookup semantics

Closes #1748

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-30_web-config-buttons (082064a)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.1704-pr.1752.153b96d

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-pr1752.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] 🏷 收到,开始按 review 规范审查本 PR(原 issue #1748 → 回归审查 → 代码 → 测试有效性 → diff 整洁度)。已拉取 PR 分支到本地,稍后给出完整结论。

…ute ids

Review fixes for the visual config form (review of this PR):

1. Default-on bool controls could not be disabled: collectValue deleted the
   key when a switch was unchecked, but for fields whose config default is ON
   (absent key = on) that leaves the feature on — and the switch rendered
   unchecked while the effective state was on. Mark those 12 fields with
   def: true (log, compress.injectTool/injectNudge/tiers/visibilityMarkers,
   autoUpdate, advisoryCheck, maskHosts, subagentSplit, resumeInheritance,
   chainContentDetection, mitm.enabled), render the switch checked for an
   absent key, and write an explicit false when turned off. Default-off
   fields keep the delete-key semantics.

2. Route control ids were index-based (cf_r_<i>_<f>): addRoute re-sorts and
   removeRoute splices routeKeys before re-rendering, so snapshot/restore by
   id shifted unsaved edits onto the wrong provider rows. Ids are now
   key-stable via routeCtrlId(key, f).

3. Drop the orphaned en-only i18n key toast.passthrough_cleared left behind
   when this PR removed its only consumer (the standalone passthrough card).

Adds regression tests pinning the def-marked field set, the render/collect
semantics, and the key-stable route ids.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Review 完成 — 方向正确,发现并直接修掉了 2 个表单缺陷(已补 commit 082064ac 到分支),CI 重跑中。逐项结论如下:

① 原 issue(#1748)方向:要的是 web 配置页面按钮化、点一点就能改、保留原 JSON 高级编辑。PR 完全对题——每个已知字段一个控件、按 server/compress/update/behavior/advanced/providers/other-keys 分组,raw JSON editor 原样保留作 escape hatch。✅

② 回归审查(diff 触碰路径的既有行为清点):

  • GET /__bili/config:仅新增只读 envForced(additive,旧客户端忽略未知键)。ENV_OVERRIDES 表逐条与 src/config.ts 的解析顺序核对过(30 条全对上);漏掉的 BILI_UPSTREAM_PROXY(_MODE)/BILI_MITM_DOMAINS/BILI_ZCODE_PORT 要么不属于本表单管辖、要么非 override 语义,不算漏报。
  • PUT /__bili/config(whole-file save):未改动——校验、passthrough env-conflict 409、atomic temp+rename 全部保持。
  • passthrough 状态卡并入表单(toggle + source note):作者在 PR 描述里已按规范 flag,属有意 UX 整合,无语义变化;raw JSON box 里 clear 的路径不变。✅
  • wire/消息形态、config schema、持久化格式、acp-kernel pin:均未触碰。whole-file 保存对未建模 key 的逐字节保留有测试钉住。✅

③ 代码审查 — 发现 2 个真实缺陷,已直接在 PR 分支修掉(commit 082064ac):

  1. 默认开启的 bool 开关无法关闭(真 bug):collectValue 对未勾选的 switch 是 删除 key,而 12 个字段在 config 里"缺省 = 开启"(log、compress.injectTool/injectNudge/tiers/visibilityMarkers、autoUpdate、advisoryCheck、maskHosts、subagentSplit、resumeInheritance、chainContentDetection、mitm.enabled,已逐一对照 src/config.ts:909-946 与 kernel defaultConfig 核实)。后果:这些开关在文件缺 key 时显示为 OFF(实际 ON),用户关掉它 → 删 key → 功能仍然 ON,UI 上永远关不掉。修复:这 12 个字段标 def: true;渲染时缺 key 显示为 checked(反映真实生效态);关闭时写显式 false。默认关闭的字段(debug/passthrough/forkAdoption/stableSystemAnchor/stripImages/rules/acknowledgePromptsRisk/attachExternal/route passthrough/direct 等)保持原删 key 语义,不受影响。
  2. provider 行编辑错位(小众但会丢数据):route 控件 id 用行号(cf_r_<i>_<f>),而 addRoute 会重排、removeRoute 会 splice 后整体重渲染,snapshot/restore 按 id 回填 → 增删 provider 后,尚未保存的编辑会落到错误的 provider 行上再保存。修复:id 改为 key-stable(routeCtrlId(key, f))。

另顺手清理:en i18n 残留孤儿键 toast.passthrough_cleared(本 PR 删掉了它唯一的消费者,zh 侧已删、en 侧漏了)。

④ 测试有效性:新增 tests/web-config-form.test.ts 的服务端部分(envForced 报告、未建模 key 保留、exact-path 查找)是真测试,断言有牙。客户端部分是对 WEB_CLIENT 源码的 needle 断言——能钉住"接线存在",但测不到运行时行为(仓库没有 DOM harness,这是既有约束,不阻塞);我补的两个回归测试同样沿此模式,把 def 标记集合、render/collect 语义、key-stable id 都钉死了。

⑤ diff 整洁度:单 commit、6 文件、每行都与 #1748 相关,无跑题内容。✅

行为变更(flagged,均为新表单自身,无存量行为漂移):

  • 上述 12 个默认开启 bool 控件:旧=未勾选→删 key→实际仍开启(bug);新=未勾选→写显式 false(真正关闭)。
  • 首次保存会把文件里缺失的这些字段物化为显式 true(生效态不变,只是文件变啰嗦一点)。
  • 开关显示态:文件缺 key 时从"显示 OFF"改为"显示 ON"(反映真实生效值)。
  • 无 config 字段/env var/CLI 新增或改名。

CI:新 head 082064ac 上 12 项检查已 8 绿(6 lane e2e + registry e2e + version-guard + build-artifact),4 个 test matrix job 运行中(本地全量已过:typecheck clean、3250 tests / 3238 pass / 0 fail / 12 skipped、build OK)。原 head 1b45da14 曾 12/12 全绿。

小观察(不修,留档):envForcedMap 用 !== undefined,空字符串 env 也会标 forced(而 || 风格解析会落到 file,极边缘);upstreamProxy/upstreamProxyMode 同时出现在表单 other-keys 和旧 upstream 卡片里(写同一文件,一致,不冲突)。

一句话中文摘要:审查了 web 可视化配置表单 PR,修了两个缺陷——12 个默认开启的 bool 开关原来关不掉(关=删 key 仍保持开启)、增删 provider 时未保存的编辑会错位到别的行——已在 PR 分支补 commit 并加了回归测试,待 CI 转绿即可合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 补充:新 head 082064ac 的 CI 已全部转绿 —— 12/12 success(含 ubuntu 22/24 + windows 22/24 全量测试矩阵、6 条 real-client lane e2e、hermetic registry e2e、version-guard、build-artifact)。修复 commit 已验证,PR 处于可合并状态(合并操作按惯例由人工执行)。

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.

web页面更改配置,按钮化

1 participant