Repository navigation
fix: embed face follows the dsh host theme; frame breathing room (#2559 #2560) - #2564
Conversation
#2560) Closes #2559 Closes #2560 Dark readability (#2559): the embed face sits in an iframe whose prefers-color-scheme tracks the OS, not the host app — so a dark dsh panel with an OS-level light preference rendered the light palette onto the host's dark ground and the text went unreadable. The client now samples its own page ground at panel mount (opaque background luminance vote over documentElement/body/main/#root/#app, matchMedia fallback, all failure paths → unpinned) and pins the result on the iframe URL as &theme=light|dark. /__bili/ whitelists the param onto <html data-theme>, which carries the existing dark palette verbatim plus a matching color-scheme declaration; the OS-signal media block narrows to :not([data-theme]) so the two palettes never fight (explicit pin always wins). Live theme toggles piggyback the existing origin probe tick (<=10s lag) — no new timer, no postMessage channel. Frame padding (#2560): .embed main gains 8px/10px/16px padding instead of hugging the frame edge on all four sides.
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2744-pr.2564.baf9f66This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2564.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…n palette sync (#2564 review) Review finding: the :root[data-theme="dark"] block repeated the OS-driven dark list with --red-soft green channel drifted 73 -> 46 (rgba(248,81,46,.12) vs the #f85149-consistent rgba(248,81,73,.12)), contradicting the verbatim-carry intent. Restore 73 and add a bidirectional set-equality guard between the two lists (color-scheme aside) so future drift fails CI.
[bot] 🏷 PR #2564 审查结论(#2559 + #2560) ① 原 issue 方向:两个 issue 都属实、机制分析成立——iframe 是独立文档, ② 回归清点(diff 触碰路径的既有行为逐项过):
③ 代码审查: ④ review 中发现一处真实缺陷,已直接修掉(独立 commit ⑤ 测试有效性:vm 挂载首帧 src 断言(含高 alpha rgba 底色三例)有牙(去掉同步采样或改分类阈值都会红);renderPage data-theme 断言有牙;CSS pin 与仓库惯例一致。非阻塞 gap:mid-session toggle(probe tick 上 ⑥ diff 整洁度:7 个文件全部服务于两个 issue,无跑题改动、无格式噪音,单一线性提交。 验证:typecheck ✔;定向套件(dsh-settings-ui + web-i18n + web-sessions + launcher)330 pass / 0 fail / 1 skip ✔,且在 rebase 到最新 master 后重跑仍绿(rebase 零冲突——merge-base 以来 master 没有提交触碰这 7 个文件)。CI:新 head 结构化八问
判定:可合(等 CI 绿);合并权在你:#2564 相关条目:PR #2561(仅修 #2560 padding)的内容已被本 PR 完全包含(同一行 styles.ts),二者合并顺序会产生冲突——建议本 PR 合并后关闭 #2561(superseded),我没有擅自关闭,由你拍板。 |
…2564 review) Git-for-Windows checks .ts out with \r\n (autocrlf default; .gitattributes pins only tests/golden/** to LF), so the mid-string "\n" literal in the OS-driven-palette assertion fails on every windows-latest CI run. Verified: reproduced locally by converting src/web/styles.ts to CRLF (test red on the exact assertion), green after normalization under both CRLF and LF.
[bot] 🏷 CI 跟进:windows-latest 全红,根因已定位并修掉(commit 现象:新 head 归因:拉了旧 head 根因(平台差异,确定性失败,非 flake):
修复( 验证:本地 A/B——把 状态:新 head |
[bot] 🏷 最终确认:CI 全绿 ✅ 新 head 收工判定:可合。 本分支现在共两笔 review 附加提交,均独立可回溯:
合并权在你:#2564 合并后请顺手关闭 PR #2561(仅含 #2560 padding 一行改动,已被本 PR 完全包含,二者合并顺序会冲突)。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.197-master.ed24c6b # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #2559
Closes #2560
深色跟随(#2559)
嵌入面板在 iframe 里,
prefers-color-scheme只跟操作系统走,跟宿主应用主题无关——dsh 面板切深色但系统偏好仍是浅色时,浅色调色板直接铺到宿主的深色底上,文字不可读(fcab54cd/#2475 的 color-scheme 绑定解决不了:它只把画布颜色交给浏览器,OS 信号本身没变)。修复链:
src/agent/dsh-native-client.ts— panel 挂载时同步采样宿主页面底色(documentElement/body/main/[role=main]/#root/#app 不透明背景做亮度投票,luma≤0.4 → dark;全失败/无信号 → 不 pin,退回 OS 信号),结果通过 iframe URL&theme=light|dark下发。运行时切换寄生在既有 origin probe tick 上(≤10s 延迟,iframe reload 保持 hash),零新增 timer、无 postMessage 通道(Windows/dsh 宿主重启:代理就绪超出 SPAWN_WAIT_MS(20s) 导致 bootstrap 失败,本进程内无重试 → /bili/origin 恒为 null、设置面板永久"未绑定"、整场会话直连(压缩失效) #2187 的 delay-pinning 测试原样通过即证明)。src/server/admin.ts/__bili/—theme参数白名单校验后透传。src/web/page.ts+styles.ts— pin 落在<html data-theme>:新增:root[data-theme="dark"]块逐字携带既有深色变量集 +color-scheme: dark;OS 信号的 media 块收窄为:root:not([data-theme]),两个调色板永不互搏(显式 pin 恒胜)。data-theme="light"只钉color-scheme: light(浅色是基础值)。frame 呼吸空隙(#2560)
.embed mainpadding 由4px 0 12px改为8px 10px 16px,内容不再贴框边(左/右原来为 0)。验证
tests/web-i18n.test.ts10/0、tests/dsh-settings-ui.test.ts(含新增 【ui】dsh 嵌入面板不跟随宿主深色主题——深色底上文字不可读 #2559 CSS-pin 与首帧 pin 场景)、tests/web-sessions.test.ts+launcher.test.ts310/310 ✔。&theme=dark:全深色调板,清晰可读&theme=light:显式 pin 压过 OS 信号config surface:无变更(
?theme=仅为 bili 自家 client↔server 管理路由的内部参数,非用户配置/环境变量)。