feat(ohos): vibrancy OHOS adaptation — runtime + build-time effects - #63
Conversation
Package Changes Through f1af1ebThere are 11 changes which include tauri with minor, @tauri-apps/api with minor, tauri-build with minor, tauri-macos-sign with patch, tauri-bundler with minor, @tauri-apps/cli with minor, tauri-cli with minor, tauri-runtime with minor, tauri-runtime-wry with minor, tauri-utils with minor, tauri-plugin with minor Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
c1273c3 to
407b4b3
Compare
MingyuChen1
left a comment
There was a problem hiding this comment.
OHOS Code Review — tauri#63
| 🔴 | 🟡 | 🔵 | ℹ️ |
|---|---|---|---|
| 1 | 0 | 1 | 0 |
🔴 F1 — crates/tauri/Cargo.toml: 移除 Windows/macOS 的 window-vibrancy 依赖 → 破坏其他平台编译
本 PR 从 [target.'cfg(target_os = "macos")'.dependencies] 和 [target."cfg(windows)".dependencies] 段都移除了 window-vibrancy = "0.6",仅在 [target.'cfg(target_env = "ohos")'.dependencies] 下新增 window-vibrancy = { path = "../../../window-vibrancy" }。
但 crates/tauri/src/vibrancy/mod.rs 仍保留 #[cfg(target_os = "macos")] mod macos; 与 #[cfg(windows)] mod windows;,这两个模块(本 PR 未修改)直接调用 window_vibrancy::*:
vibrancy/windows.rs:window_vibrancy::apply_blur/apply_acrylic/apply_mica/apply_tabbed/clear_*vibrancy/macos.rs:use window_vibrancy::{NSVisualEffectMaterial, NSVisualEffectState};+window_vibrancy::apply_vibrancy(...)
Rust 2018 edition 要求 use window_vibrancy 的 crate 必须是 tauri 的直接依赖(传递依赖不可直接 use)。根 Cargo.toml 也无 [workspace.dependencies] 的 window-vibrancy 条目。因此在 Windows/macOS 编译 tauri crate 时会因 unresolved import window_vibrancy 失败,违反铁律 2(不影响其他平台原有实现)。
建议:保留 window-vibrancy = "0.6" 于 macOS/Windows 段(或在各平台段用 path dep 覆盖),仅 OHOS 段用本地 path fork。即“非 OHOS 用 crates.io 版,OHOS 用本地 fork”才是正确模式。
🔵 F4 — openspec/window-vibrancy-plan.md 散落在 openspec/ 根
该计划文件位于 openspec/window-vibrancy-plan.md,未归档到 openspec/changes/ 下(同 #62 的 ohos-permissions-plan.md 模式)。按 H3 规范,openspec 文件应归档到 openspec/changes/(本 PR 的变更已正确归档到 openspec/changes/archive/2026-07-04-p1-window-vibrancy/,但顶层 plan 文件例外)。建议移入 changes 目录或专门的 plans 目录。
整体评价:OHOS vibrancy 适配的架构清晰(tauri vibrancy → window-vibrancy → openharmony-ability 调用链与 Windows/macOS 一致),openspec 归档完整,manual_tests.md 已更新(H5✓)。但 F1 依赖移除会直接破坏 Windows/macOS 构建,必须修复。F1 inline comment 见下方 Cargo.toml 标注。
| @@ -151,6 +149,7 @@ rustls = { version = "0.23", default-features = false, features = [ | |||
| ], optional = true } | |||
There was a problem hiding this comment.
🔴 [B/编译] 这里把 window-vibrancy 仅放到 OHOS target 段,但同时从 macOS 段和 Windows 段移除了 window-vibrancy = "0.6"。
crates/tauri/src/vibrancy/windows.rs 和 macos.rs(本 PR 未改)仍直接调用 window_vibrancy::apply_blur / apply_vibrancy 等。Rust 2018 要求该 crate 是 tauri 的直接依赖,传递依赖不可 use。根 Cargo.toml 也无 workspace 级 window-vibrancy。→ Windows/macOS 编译 tauri 会 unresolved import window_vibrancy,违反铁律 2。
建议:macOS/Windows 段保留 window-vibrancy = "0.6"(crates.io 版),仅 OHOS 段用此 path fork 覆盖。
a2fa440 to
596f095
Compare
MingyuChen1
left a comment
There was a problem hiding this comment.
OHOS Code Review — tauri#63 (re-review 2026-07-07)
| 🔴 | 🟡 | 🔵 | ℹ️ |
|---|---|---|---|
| 0 | 0 | 1 | 0 |
✅ F1(上轮 🔴)已解决
上轮指出 Cargo.toml 把 window-vibrancy 从 macOS/Windows target 段移除、仅留 OHOS target,导致 vibrancy/windows.rs/macos.rs 在 Windows/macOS 编译失败。
本轮确认:作者把 window-vibrancy = "0.7" 放入 [dependencies](全平台),配合根 Cargo.toml 的 [patch.crates-io] window-vibrancy = { path = "../window-vibrancy" }(本地 fork 版本 0.7.1,满足 ^0.7)。因此所有平台都解析到本地 fork,Windows/macOS 的 use window_vibrancy::* 可正常编译,OHO 同样拿到 apply_ohos_blur 等专用 API。铁律 2 已满足,Blocker 清除。
🔵 F4(上轮)仍开 — 次要
openspec/window-vibrancy-plan.md 仍散落在 openspec/ 根(未归档到 openspec/changes/)。属次要,已记入 review checklist H8,可在后续整理。
Blocker 已清除,整体可合入(F4 为非阻塞的归档规范项)。
2867212 to
3408fad
Compare
MingyuChen1
left a comment
There was a problem hiding this comment.
OHOS Code Review — tauri#63 (re-review 2026-07-08)
| 🔴 | 🟡 | 🔵 | ℹ️ |
|---|---|---|---|
| 0 | 0 | 0 | 1 |
✅ F1(🔴,上轮已解决)维持
crates/tauri/Cargo.toml 仍把 window-vibrancy = "0.7" 放在 [dependencies](全平台),配合根 Cargo.toml [patch.crates-io] window-vibrancy = { path = "../window-vibrancy" }。Windows/macOS/OHOS 均解析到本地 fork(0.7.1),编译正常。
✅ F4(🔵,本轮已解决)
openspec/window-vibrancy-plan.md 已移到 openspec/changes/window-vibrancy-plan.md,符合 H3/H8 归档规范。
ℹ️ I1 — design.md 内一处旧路径引用未更新
openspec/changes/archive/2026-07-04-p1-window-vibrancy/design.md 中仍写 "详见 openspec/window-vibrancy-plan.md 的架构决策",但文件已移到 openspec/changes/。属极次要的文档交叉引用,可顺手更新。
所有 finding 已清除,可合入。
MingyuChen1
left a comment
There was a problem hiding this comment.
OHOS Code Review — tauri#63 (re-review 2026-07-08)
| 🔴 | 🟡 | 🔵 | ℹ️ |
|---|---|---|---|
| 0 | 0 | 0 | 1 |
✅ F1(🔴,上轮已解决)维持
crates/tauri/Cargo.toml 仍把 window-vibrancy = "0.7" 放在 [dependencies](全平台),配合根 Cargo.toml [patch.crates-io] window-vibrancy = { path = "../window-vibrancy" }。Windows/macOS/OHOS 均解析到本地 fork(0.7.1),编译正常。
✅ F4(🔵,本轮已解决)
openspec/window-vibrancy-plan.md 已移到 openspec/changes/window-vibrancy-plan.md,符合 H3/H8 归档规范。
ℹ️ I1 — design.md 内一处旧路径引用未更新
openspec/changes/archive/2026-07-04-p1-window-vibrancy/design.md 中仍写 "详见 openspec/window-vibrancy-plan.md 的架构决策",但文件已移到 openspec/changes/。属极次要的文档交叉引用,可顺手更新。
所有 finding 已清除,可合入。
496339a to
30677be
Compare
Complete vibrancy adaptation: build-time effects (WindowBuilder::effects) and runtime setEffects/clearEffects both apply visually on OHOS. Key changes: - vibrancy/ohos.rs + mod.rs: OHOS platform impl (direct window_vibrancy call, no tao) - window/mod.rs: Window::set_effects + build-time direct apply use run_on_main_thread (main thread napi Env for set_window_blur; ohos_window_id inline via send_user_message fast-path, no deadlock now that UIAbility singleton conflict is fixed via Float windows) - tauri-runtime: ohos_window_id() trait + WryWindowId message - cmd.rs: create_transparent_window adds effect/radius/color params for build-time effects - examples/api: vibrancy test cases (runtime setEffects + build-time effects) + manual buttons + vibrancy.html; windows use create_transparent_window (Float sub-window) - build-ohos.sh/sign-and-install.sh: ENTRY_DIR by OHOS_DEVICE_TYPE (entry_desktop/entry_mobile) - Cargo.toml: anyhow dep - Docs: openspec plan + ohos-constraints.md (FnArgs, hilog NAPI, BuilderNode.update) Runtime backdropBlur/backgroundColor refresh relies on openharmony-ability BlurModifier (AttributeUpdater) — see openharmony-ability commit. Co-Authored-By: Claude <noreply@anthropic.com>
MingyuChen1
left a comment
There was a problem hiding this comment.
OHOS Code Review — tauri#63 (re-review 2026-07-08)
| 🔴 | 🟡 | 🔵 | ℹ️ |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
✅ 全部 finding 维持已解决
- F1(🔴 Cargo.toml):
window-vibrancy = "0.7"仍在[dependencies]+[patch.crates-io]指向本地 fork。 - F4(🔵 openspec plan):仍在
openspec/changes/window-vibrancy-plan.md。 - I1(ℹ️ design.md 旧路径引用):本轮也已更新——
openspec/window-vibrancy-plan.md旧路径引用已消除。
无新增问题,可合入。
Complete vibrancy adaptation for OHOS: both build-time effects (
WindowBuilder::effects) and runtimesetEffects/clearEffectsnow apply visually.Changes
window_vibrancycall, no tao)Window::set_effects+ build-time direct apply userun_on_main_thread(main thread napi Env forset_window_blur;ohos_window_idinline viasend_user_messagefast-path, no deadlock now that UIAbility singleton conflict is fixed via Float sub-windows)ohos_window_id()trait +WryWindowIdmessagecreate_transparent_windowaddseffect/radius/colorparams for build-time effectsvibrancy.html; windows usecreate_transparent_window(Float sub-window to avoid UIAbility singleton)ENTRY_DIRbyOHOS_DEVICE_TYPE(entry_desktop/entry_mobile)window-vibrancyisolated tocfg(target_env = "ohos")path dep (Windows/macOS keep upstream 0.6);anyhowdepRelies on openharmony-ability PR for
BlurModifier(AttributeUpdater) runtime refresh ofbackdropBlur/backgroundColor.Test results
window.setEffects (Blur/Acrylic/Mica/TabbedDark/TabbedLight) + clearEffects✅,vibrancy build-time effects (WindowBuilder::effects)✅🤖 Generated with Claude Code