fix(windows): capsule/qa 透明窗口 Acrylic 兜底#487
Conversation
根因: tauri.conf.json 三个窗口都 transparent: true,但 lib.rs 只对 main 窗口调用 apply_mica。capsule / qa 在 Windows 上是裸 transparent, Webview2 的 backdrop-filter 只能模糊页面内部 DOM 不能模糊 OS 桌面, 导致用户看到的胶囊 / QA 浮窗几乎完全透出桌面壁纸。 macOS 上 NSVisualEffectView (HudWindow vibrancy) 直接由系统合成器 混合桌面,所以 macOS 不需要额外处理。 修复: 1. lib.rs 在 setup 时对 capsule / qa webview 调用 apply_acrylic( color=(30,32,38,140)) — 选 Acrylic 而非 Mica 因为 Acrylic 支持 Win10,更适合小浮窗。失败仅 log::warn 不 panic。 2. global.css 末尾追加 @supports not (backdrop-filter) 和 @media (prefers-reduced-transparency: reduce) 兜底,给 html/body 设实色背景。组件层 inline style 无法被覆盖,这只是二级防护。 Note: Capsule.tsx 和 FloatingShell.tsx 的 inline alpha 保留不动; Acrylic 兜底通常足够。如果 Win10 实测仍偏透(Mica 不支持 Win10), 后续 PR 可考虑给 main 也加 Acrylic 作为 Mica fallback。
PR Reviewer Guide 🔍(Review updated until commit d357d68)Here are some key observations to aid the review process:
|
Local code review flagged that `html, body { background: ... }` applies
to ALL windows including `main`, which would clobber the macOS
NSVisualEffectView vibrancy in `prefers-reduced-transparency: reduce`
mode.
Re-analysis confirms both rules are speculative:
- @supports never fires on modern Webview2 / WKWebView / Chromium
(all support backdrop-filter)
- prefers-reduced-transparency triggers OS-level vibrancy neutralization
on macOS already, but the CSS rule would still wrongly land on main
Acrylic in lib.rs is the canonical fix for the user-reported P0
(capsule/qa 透明遮罩看不清). The CSS layer is dropped to keep the PR
scoped to a single concern and avoid the cross-window collateral.
Refs review of #487
|
Persistent review updated to latest commit d357d68 |
|
@claude 请审核此 PR。如有问题请逐条列出(CRITICAL / HIGH / MEDIUM);如全部通过请明确说 LGTM。 |
|
Claude finished @appergb's task in 1m 59s —— View job PR 审核报告PR #487 — fix(windows): capsule/qa 透明窗口 Acrylic 兜底
结论:LGTM(附 2 条 MEDIUM 说明)未发现 CRITICAL 或 HIGH 级别问题。核心 Rust 改动正确,平台隔离干净,错误处理符合规范。以下两条 MEDIUM 供参考,均不阻塞合并。 MEDIUM — M1:QA 窗口由前端 agent 动态创建时 Acrylic 不生效文件: if let Some(qa) = app.get_webview_window("qa") {
// Acrylic 在这里应用
} else {
log::info!("[qa] qa 窗口未在 tauri.conf.json 中声明,前端 agent 会补上");
}
PR 描述里已明确"前端 agent 负责声明 MEDIUM — M2:
|
| 检查点 | 结论 |
|---|---|
window-vibrancy 依赖已声明 |
Cargo.toml:104 window-vibrancy = "0.7" 在 cfg(any(windows, macos)) 下,正确 |
#[cfg(target_os = "windows")] 平台隔离 |
capsule 和 qa 两处均正确包裹,macOS 路径不受影响 |
| API 签名 | apply_acrylic(&window, Some((r,g,b,a))) 与 window-vibrancy 0.7 签名吻合 |
| 错误处理 | Err(e) 仅 log::warn!,不 panic,不阻塞窗口 hide/show 流程 |
| 调用时机 | apply_acrylic 在 hide() 之前执行;DWM 属性在窗口可见状态变更后仍保留,与 apply_mica 的现有模式一致 |
Acrylic 颜色 (30,32,38,140) |
alpha 140/255 ≈ 55%,在 Win10 Acrylic 建议区间内;深冷灰与胶囊白底叠合可读性合理 |
| Acrylic vs Mica 选型 | Acrylic 支持 Win10 v1803+,Mica 仅 Win11 22H2+;选型正确 |
| main 窗口不受影响 | 仍走 apply_mica,未动 |
| macOS 回归风险 | 为零,两个 #[cfg(windows)] 块在 macOS 编译单元中完全剔除 |
综合:无阻塞性问题,可合并。 M1 是已知配置约束,M2 是无害的空行。两条均建议但不强制在本 PR 修复。
…v 安装
v1.3.4-4 / -5 的 Linux 构建在 "Build fcitx5 plugin" 步骤连挂两次,
错误一致:"E: Unable to locate package fcitx5-dev"。同一 job 前面的
"Install Linux bundle deps" 步骤明明已经 apt-get update + 装好了一堆
universe 包,到 fcitx5 这步突然找不到 —— 表象与 GitHub Actions
ubuntu-22.04 runner 镜像弃用过渡期里 apt 元数据漂移的现象一致。
release-tauri.yml "Build fcitx5 plugin" 步骤增加三层防御:
1) sudo add-apt-repository -y universe(已启用则 no-op)
2) 本步骤内重新 sudo apt-get update,独立于上游 step 缓存
3) 安装失败时打印 apt-cache policy / search / os-release / sources.list.d
便于以后排查
同 commit 同时 bump 五处版本到 1.3.4-6 重发,让 PR #487/#488/#489
三个 Windows P0 修复带上 Linux 包一起进 Beta 通道。
* chore(ci): nudge Actions to index release workflow on fork Co-authored-by: Cursor <cursoragent@cursor.com> * chore(ci): nudge Actions to index release workflow on fork Co-authored-by: Cursor <cursoragent@cursor.com> * chore(ci): nudge Actions to index release workflow on fork Co-authored-by: Cursor <cursoragent@cursor.com> * chore(ci): nudge Actions to index release workflow on fork Co-authored-by: Cursor <cursoragent@cursor.com> * chore: add CapsWriter to .gitignore for local voice inference reference * fix(windows): revert capsule/qa Acrylic to remove dark host rect Reverts the apply_acrylic blocks from #487. Full-window Acrylic tinted the 220×84 capsule hitbox, causing a visible dark rectangle around the pill on light backgrounds. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
问题
Windows Beta 1.3.4-4 上录音胶囊 (capsule) 和 QA 浮窗 (qa) 几乎完全透明,桌面壁纸直接透出,内容看不清。macOS 正常。
根因
tauri.conf.json中 main / capsule / qa 三个窗口都设了transparent: true,但src-tauri/src/lib.rs只对 main 窗口调用了apply_mica。Webview2 的backdrop-filter只能模糊页面内部 DOM,无法模糊 OS 桌面(与 macOS WKWebView + NSVisualEffectView 行为有本质差异)。Capsule.tsx 的rgba(255,255,255,0.85)+backdrop-filter: blur(28px)在 Windows 上等于纯 0.85 alpha 透到桌面壁纸。修复
在
lib.rs的 capsule 和 qa 窗口初始化块里,Windows 下追加 Acrylic:选 Acrylic 而非 Mica 因为 Acrylic 支持 Win10,Mica 仅 Win11 22H2+。颜色
(30, 32, 38, 140)偏冷深灰,alpha 140 在建议范围中段。失败仅log::warn不 panic。macOS 路径完全不动。
关于 CSS 兜底
最初的版本附带了
@supports not (backdrop-filter)和prefers-reduced-transparency两条全局 CSS fallback。本地代码审查指出html, body选择器过宽,在 macOS reduce-transparency 模式下会波及 main 窗口的 Vibrancy。再分析后两条规则其实都是"几乎不会触发"的防御代码:现代 Webview2 / WKWebView / Chromium 都原生支持
backdrop-filter;macOS 系统 reduce-transparency 已经在 OS 层中和了 Vibrancy 不需要 CSS 再补一刀。已在第二个 commit 中删除,PR 现在只保留 Rust 侧 Acrylic 这一处变更,scope 更干净。已知遗留
Capsule.tsx:261仍是rgba(255,255,255,0.85)inline。预期 Acrylic 兜底足够;若实测仍不清需要单独 PR 调 alpha本地审查结论
cargo check无新增 warningTest plan
🤖 Generated with Claude Code