Skip to content

[PR] refactor(web): unified built-in notice registry — one table, one render loop (#5548 P1) - #5554

Closed
ranxianglei wants to merge 3 commits into
masterfrom
2026-11-02_notice-p1
Closed

ranxianglei wants to merge 3 commits into
masterfrom
2026-11-02_notice-p1

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

#5548 分期实施 P1:注册表化(设计见 issue,owner 已批准)。

做什么

内置 web 公告从此只有一张表(src/notices.ts)+ 一个渲染循环。现状是每条公告手抄五个文件——#5079 抄第一遍、#5469 抄第二遍、#5547 抄第三遍被砍掉。P1 把这三遍的重复全部收进注册表:

文件 变化
src/notices.ts(新) NoticeEntry{id,tone,keys,active} 表;visibleNotices() 永不抛错
src/server/admin.ts overview 两个专用字段(pckNotice/wmNotice)→ 统一 notices[];新增 GET /__bili/notices(同一数组)
src/web/client.ts 两个专用 builder + ~60 行重复绑定 → 一个 bili_noticeBanner(s) + 单循环;dismiss 按钮统一 .notice-dismiss,id 取自 data-id
src/web/page.ts 两个静态 banner div → 单个 #notices-banner-region
src/web/i18n.ts 两条 dismissed toast 文案合并为一个 notices.dismissed(zh/en);现有文案一字未改
tests/web-i18n.test.ts 死 key 守卫把 src/notices.ts 纳入扫描范围(注册表字符串算引用)
tests/notice-registry.test.ts(新) 注册表不变量(id 唯一/tone/双 locale key 齐全)、全新安装两条全亮且顺序固定、关一条只灭一条

验收判据达成:再加一条内置公告 = 注册表一行 + 几条 i18n + store allowlist 一个 id,admin/client/page 零改动。

行为

刻意零变化(纯重构):两条公告的触发条件、关闭语义、颜色(warn/ok)、文案全部原样。P2/P3(本地 JSON 公告、远程 GitHub raw + CI 门)另开 PR。

证据

typecheck 干净;build 干净;定向套件 30/30 绿(notice-registry、wm-fastpath-intro-notice、issue5079-pck-default-off(含 live-proxy e2e)、web-i18n、web-update-banner、web-relay-warn)。

…er loop (#5548 P1)

Every built-in web notice now lives as ONE entry in src/notices.ts (id, tone,
i18n key set, server-side active predicate). The web client renders whatever
the overview reports through a single generic loop over
#notices-banner-region; the per-notice builders/banners/wiring added one by
one in #5079, #5469 and the retired #5547 are gone. Adding a 4th notice is a
table row + its i18n keys + its store allowlist id — no admin/client/page
edits.

- new src/notices.ts: NoticeEntry registry + never-throwing visibleNotices()
- admin.ts: overview gains notices[] (replaces the two bespoke payload
  fields); new GET /__bili/notices serves the same array
- client.ts: bili_pckNoticeBanner/bili_wmNoticeBanner collapse into one
  bili_noticeBanner({tone,on,desc,hint,dismiss}); one loop wires
  .notice-dismiss buttons against POST /__bili/notices/dismiss
- page.ts: two static banner divs -> single #notices-banner-region
- i18n: per-notice dismissed toasts merge into one notices.dismissed key
  (zh/en); web-i18n dead-key guard learns to scan src/notices.ts (registry
  strings count as references)
- tests: new tests/notice-registry.test.ts (registry invariants, both
  locales, fresh-install visibility order, dismiss-hides-only-one)

Behavior is deliberately unchanged (P1 of the approved #5548 design: P2 adds
local JSON announcements + full schema, P3 remote GitHub raw + CI gate).
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-02_notice-p1 (1c8981b)

Latest build — install this exact version

npm install -g billion-context@0.0.7904-pr.5554.ed78086

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
1c8981b billion-context@0.0.7904-pr.5554.ed78086 build
ae3e936 billion-context@0.0.7903-pr.5554.5a47ec5 build
0df2e51 billion-context@0.0.7899-pr.5554.f926e2f build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title refactor(web): unified built-in notice registry — one table, one render loop (#5548 P1) [PR] refactor(web): unified built-in notice registry — one table, one render loop (#5548 P1) Nov 2, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

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

CI 的 unused-exports 静态门红了:src/notices.ts 新导出的 NoticeEntry 接口只在模块内部使用,gate 判 INTERNAL_ONLY。已在 ae3e936 去掉 export(接口保持模块内可见,行为零变化);本地复跑该门 + typecheck + notice-registry 测试全绿。

…ns() so the env knob is honored (#5548 P1 review)

The pck entry's active predicate read loadConfigFile().promptCache, while the old overview payload read opts.promptCache (loadOptions: env > file). A user who set the documented ACP_PROMPT_CACHE_ROUTING=auto/enabled env var without touching the config file would see the "self-stamping off" notice even though their effective routing is not disabled — and the /acp status surface (which reads through loadOptions() on purpose) would disagree with the web overview. Read through loadOptions() like every other pck surface; add a registry test pinning the env-aware suppression.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重:不重复 —— 本 PR 是 #5548 P1(注册表化)的唯一实现线,近期 open/closed issue 与 PR 中无并行工作。

标签:bug + scope/ui + p3(PR 审核发现两处真实缺陷——一处 CI 门红、一处 env 配置层回归,均已在分支内修复;属 web 面板面,体验级严重度)。

审核结论:方向对,发现并已修掉一个真回归 + 确认 CI 红已解

① 方向关:与 #5548 P1 设计(owner 已批准)一致——一张表(src/notices.ts)+ 一个渲染循环,验收判据「再加一条公告 = 注册表一行 + i18n + allowlist id」成立。纯重构、刻意零行为变化,目标正确。

② 回归审查(既有行为逐项清点):两条公告的触发条件(effective routing disabled 且未关 / 无 rollout override 且未关)、关闭语义(服务端 POST /__bili/notices/dismiss,allowlist 仍是同一组 id)、颜色(warn/ok 与原静态 div 一致)、文案(i18n 逐字保留,dismissed toast 合并后 zh/en 文本一字未变)、dead-key 守卫扩扫注册表——全部保持。发现唯一偏差(已修):

  • env 配置层回归:pck 条目的 active 判定被收进注册表时从原来的 opts.promptCache(loadOptions,env > file)换成了 loadConfigFile().promptCache(只读文件)。后果:用文档化的 env 变量 ACP_PROMPT_CACHE_ROUTING=auto/enabled 设了路由但没写配置文件的用户,web overview 会错误显示「自盖章已关」公告,而 /acp status 面(acp-status.ts 特意走 loadOptions())同时不显示——两个面互相矛盾。修法:改回经 loadOptions() 读取,与其他所有 pck 面一致,并新增 hermetic 单测钉住该行为(env=auto ⇒ 公告消失)。
  • CI 红确认:unused-exports 门在初版 head 上红(NoticeEntry 导出但无外部消费者),且它卡住了全部 test lane(needs 依赖)。你在 ae3e936 去掉 export 的修复与我独立诊断一致,我未重复修;新 head 上该门已绿(镜像缓存确认)。

③ 代码审查:渲染循环的防御式解析(非对象/缺 id 跳过、dataset 取 id、内容全过 escapeHtml)干净;payload 字段变更(pckNotice/wmNotice → notices[])的消费方只有本仓 web client(grep 全仓确认无其他读者),新增 GET /__bili/notices 返回同一数组,符合 issue 设计。

④ 测试有效性:新 tests/notice-registry.test.ts 断言有牙(id 唯一/tone 合法/双 locale key 齐全非空/全新安装顺序固定/关一条只灭一条),bug 回归时抓得住;我补的 env case 同样可独立复现原缺陷。

⑤ diff 整洁度:干净,7 个文件每一行都服务 P1,无跑题改动。
⑤b 代码整洁:达标(命名达意、无死代码、无魔法值、风格与仓库一致)。

本地证据(新 head 1c8981b)

  • scripts/check-unused-exports.mjs 绿(修复前本地复现过红)
  • npm run typecheck 绿(含 kernel/pi-subagents 构建)
  • 定向套件 31/31 绿:notice-registry(含新增 env case)、wm-fastpath-intro-notice、issue5079-pck-default-off、web-i18n、web-update-banner、web-relay-warn

结构化八问

  1. 是什么问题:P1 把两条内置 web 公告收进统一注册表;审核中发现重构把一个配置读取从「env > file」降级成了「只读文件」,外加一个 CI 门红。
  2. 什么原因导致的:收编 active 判定时只对齐了表面形状、没对齐配置解析层级——loadConfigFile() 不含 env 层,而旧 overview payload 走的是 startup opts(含 env)。CI 红是导出了无外部消费者的接口。
  3. 影响范围与严重程度:仅「用 env 变量设 promptCache.routing 为 auto/enabled 且未写配置文件」的用户,在 web overview 看到一条不该出现的公告(且与 /acp 面矛盾);体验级缺陷,流量/缓存零影响,普通用户路径零感知。修复前 p3~p2 之间,现已消除。
  4. 怎么修复的:判定改回经 loadOptions()(env > file),与启动日志、/acp status 等所有 pck 面同读法;新增单测钉住 env 抑制行为。CI 红由作者侧 ae3e936 解决(去 export),诊断一致不重做。
  5. 是否有回归问题:触发条件/关闭语义/颜色/文案/payload 消费面/dead-key 守卫逐项清点,除上述已修的 env 偏差外无其他回归;高危模式(语义漂移、fail-fast 变吞错、阈值漂移)逐项过——无。
  6. 是否破坏缓存:不涉及——不碰前缀缓存、压缩与会话存储;notice store 文件格式不变。
  7. 是否改了设计方向:否,按 owner 批准的 Unified Announcement Panel Design (Approved): Built-in declarations + local JSON + remote GitHub raw — a single renderer | 公告面统一设计(已批准):内置声明 + 本地 JSON + 远程 GitHub raw,三来源一套渲染器 #5548 设计执行,P2/P3 不在本 PR。
  8. 是否引入了新的配置:无新 config/env/默认值;新增 GET /__bili/notices 端点是 issue 设计内声明的接口面(返回与 overview 相同的数组),非配置面。

判定:可合——两处问题均已修复并在本地验证(门/typecheck/定向 31/31),已推送至 PR 分支(1c8981b1e);等新 head 的 CI 全套转绿后由你合并即可。

@ranxianglei ranxianglei added bug Something isn't working p3 scope/ui labels Nov 2, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

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

Found a same-scope parallel implementation: PR #5557 (opened 16:28Z, ~24 min after this PR) implements the same approved design phase (#5548 P1 — built-in notice registry + single renderer), with the same file set, the same overview payload shape change (pckNotice/wmNotice objects → unified notices[] array), and the same new endpoint GET /__bili/notices. The two PRs are mutually exclusive: both create src/notices.ts with different schemas and both rewrite the same regions of admin.ts/client.ts/page.ts/i18n.ts, so only one can merge — the later one conflicts out.

Mechanism comparison:

Per policy I am not closing either PR — the keep-one decision belongs to the owner (it is raised as a decision request in the #5557 thread, recommendation: keep #5557). Happy to give this PR the same independent review pass before the decision if you want it.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

🔶 需要决策(正式决策请求在 #5557 线程,本线程补独立核查结论) —— 对上面转发的「并行实现」分析,我逐项独立复核过,全部属实,同意其推荐:保留 #5557、退役本 PR(#5554)。补充两个转发评论没覆盖的核查结果:

独立核查证据

  1. 批准设计确实规定 record-carries-copy。Unified Announcement Panel Design (Approved): Built-in declarations + local JSON + remote GitHub raw — a single renderer | 公告面统一设计(已批准):内置声明 + 本地 JSON + 远程 GitHub raw,三来源一套渲染器 #5548 v2(owner 已批准)§四 schema 示例就是记录内嵌多语言 title/desc/hint/ctaLabel 对象;§4.5 模块布局明文「src/web/i18n.ts 只剩动作词(知道了/toast/列表标题),文案本体随 record 走」。[PR] feat: unified announcement surface — built-in registry + single renderer (lane A, #5548 P1) #5557 逐字对齐(含 kind→priority 默认表、tone 推导可覆盖、三模式 dismiss、P2 目标字段先声明保 wire 稳定、registerDynamicNoticeIds 给 B/C 车道留口)。本 PR 的 keys 引用 i18n 目录形状来自任务简报的简化描述,不是批准 schema——若合入本 PR,P2/P3(本地 JSON/远程 raw)落地时外部记录无法引用内置 i18n 目录,注册表要整体返工。
  2. 互斥性确认:两 PR 同建 src/notices.ts(不同 schema)、同改 admin/client/page/i18n 同一批 hunk,只能活一个。
  3. env 回归只存在于本 PR 初版,[PR] feat: unified announcement surface — built-in registry + single renderer (lane A, #5548 P1) #5557 没有。我在审核本 PR 时发现并修掉的「pck 判定从 loadOptions 降级成只读文件」缺陷,在 [PR] feat: unified announcement surface — built-in registry + single renderer (lane A, #5548 P1) #5557 不存在——它的 visibleNoticesPayload(opts) 逐字保留原读法 effectivePromptCacheRouting(opts.promptCache)(env > file)。所以本分支没有任何值得移植到 [PR] feat: unified announcement surface — built-in registry + single renderer (lane A, #5548 P1) #5557 的代码:INTERNAL_ONLY 门两边各自独立修了(对方 commit 1dda83e),env 修复在他们那边不适用。
  4. 文案零漂移抽验通过:两条横幅 12 条正文串(zh/en × title/desc/hint × 2)与 master i18n 目录逐字一致;pck 条用显式 tone: "warn" 覆盖推导值并注释了原因([PR] fix(dsh): carry the thrown error's bounded stack into the gate refusal logs (#5067 option A) #5079 起一直是 .banner.warn,保字节稳定)——这个细节处理得比我这版还周到。
  5. 测试面:[PR] feat: unified announcement surface — built-in registry + single renderer (lane A, #5548 P1) #5557 新增两套(notices-registry 7 例 + web-notices-banner 236 行),比本 PR 的单套更宽。

待决问题与选项

八问(决策支持)

  1. 是什么问题:同一批准设计阶段(Unified Announcement Panel Design (Approved): Built-in declarations + local JSON + remote GitHub raw — a single renderer | 公告面统一设计(已批准):内置声明 + 本地 JSON + 远程 GitHub raw,三来源一套渲染器 #5548 P1)被两个 agent 并行实现了两份互斥 PR,必须留一退一。
  2. 什么原因导致的:两单几乎同时被派发,各自按拿到的简报开工——一份按批准设计原文,一份按简化简报。
  3. 影响范围与严重程度:仅仓库内调度浪费(重复实现 ~1200 行);用户面零影响(未合并任何一份)。
  4. 怎么处置:按批准设计裁决归属——[PR] feat: unified announcement surface — built-in registry + single renderer (lane A, #5548 P1) #5557 匹配已批准 schema,留它;本 PR 退役。无需移植代码。
  5. 是否有回归问题:不涉及(退役的是未合并 PR;[PR] feat: unified announcement surface — built-in registry + single renderer (lane A, #5548 P1) #5557 自身行为保持已由其中披露+我的抽验覆盖)。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:否——恰恰是以批准设计为准绳做的取舍。
  8. 是否引入了新的配置:不涉及。

按政策我不关闭任何 PR(关闭权在你):你拍板后直接关本 PR 即可,我这边不再动作。

@ranxianglei

Copy link
Copy Markdown
Owner Author

(ai: 已并入 #5575 —— 按 owner 裁定不再拆分,本 PR 作废。)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working p3 scope/ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant