Skip to content

feat(ohos): vibrancy OHOS adaptation — runtime + build-time effects - #63

Merged
Eulogizethesun merged 1 commit into
Eulogizethesun:ohdevfrom
hardtohavename:ohdev
Jul 9, 2026
Merged

feat(ohos): vibrancy OHOS adaptation — runtime + build-time effects#63
Eulogizethesun merged 1 commit into
Eulogizethesun:ohdevfrom
hardtohavename:ohdev

Conversation

@hardtohavename

Copy link
Copy Markdown

Complete vibrancy adaptation for OHOS: both build-time effects (WindowBuilder::effects) and runtime setEffects/clearEffects now apply visually.

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 sub-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 to avoid UIAbility singleton)
  • build-ohos.sh/sign-and-install.sh: ENTRY_DIR by OHOS_DEVICE_TYPE (entry_desktop/entry_mobile)
  • Cargo.toml: window-vibrancy isolated to cfg(target_env = "ohos") path dep (Windows/macOS keep upstream 0.6); anyhow dep

Relies on openharmony-ability PR for BlurModifier (AttributeUpdater) runtime refresh of backdropBlur/backgroundColor.

Test results

  • Auto: window.setEffects (Blur/Acrylic/Mica/TabbedDark/TabbedLight) + clearEffects ✅, vibrancy build-time effects (WindowBuilder::effects)
  • Manual: 5 buttons (Blur/Acrylic/TabbedDark/clearEffects/build-time Blur) all verified — blur + tint visible, tints differ by effect
  • 4 failures unrelated to vibrancy (Resumed/clipboard/notification)

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Package Changes Through f1af1eb

There 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 Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
@tauri-apps/api 2.10.1 2.11.0
tauri-utils 2.8.3 2.9.0
tauri-macos-sign 2.3.3 2.3.4
tauri-bundler 2.8.1 2.9.0
tauri-runtime 2.10.1 2.11.0
tauri-runtime-wry 2.10.1 2.11.0
tauri-codegen 2.5.5 2.5.6
tauri-macros 2.5.5 2.5.6
tauri-plugin 2.5.4 2.6.0
tauri-build 2.5.6 2.6.0
tauri 2.10.3 2.11.0
@tauri-apps/cli 2.10.1 2.11.0
tauri-cli 2.10.1 2.11.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@MingyuChen1 MingyuChen1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 标注。

Comment thread crates/tauri/Cargo.toml Outdated
@@ -151,6 +149,7 @@ rustls = { version = "0.23", default-features = false, features = [
], optional = true }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 [B/编译] 这里把 window-vibrancy 仅放到 OHOS target 段,但同时从 macOS 段和 Windows 段移除了 window-vibrancy = "0.6"

crates/tauri/src/vibrancy/windows.rsmacos.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 覆盖。

@hardtohavename
hardtohavename force-pushed the ohdev branch 6 times, most recently from a2fa440 to 596f095 Compare July 7, 2026 08:56

@MingyuChen1 MingyuChen1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OHOS Code Review — tauri#63 (re-review 2026-07-07)

🔴 🟡 🔵 ℹ️
0 0 1 0

✅ F1(上轮 🔴)已解决

上轮指出 Cargo.tomlwindow-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 为非阻塞的归档规范项)。

@hardtohavename
hardtohavename force-pushed the ohdev branch 3 times, most recently from 2867212 to 3408fad Compare July 8, 2026 02:28

@MingyuChen1 MingyuChen1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 MingyuChen1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 已清除,可合入。

@hardtohavename
hardtohavename force-pushed the ohdev branch 2 times, most recently from 496339a to 30677be Compare July 8, 2026 07:16
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 MingyuChen1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 旧路径引用已消除。

无新增问题,可合入。

@Eulogizethesun
Eulogizethesun merged commit 8e94356 into Eulogizethesun:ohdev Jul 9, 2026
2 of 25 checks passed
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.

3 participants