Skip to content

feat(platform): add macOS platform implementation and E2E coverage - #87

Open
alan22333 wants to merge 8 commits into
ghost-him:mainfrom
alan22333:main
Open

feat(platform): add macOS platform implementation and E2E coverage#87
alan22333 wants to merge 8 commits into
ghost-him:mainfrom
alan22333:main

Conversation

@alan22333

Copy link
Copy Markdown

adapt for mac

Copilot AI lite review requested due to automatic review settings September 2, 2026 18:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

There is at least one verified cross-platform build-breaker (Windows theme provider construction) plus a portability issue in the macOS E2E script that should be addressed before merging.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR introduces a macOS platform implementation and wires it into the Tauri host via compile-time platform selection, alongside adding a macOS E2E script entrypoint.

Changes:

  • Add zerolaunch-platform-macos crate implementing the platform-neutral zerolaunch-plugin-api traits for macOS.
  • Introduce src-tauri/src/platform.rs to select Windows vs macOS implementations at compile time and refactor host bootstrap to use injected Platform* types.
  • Add a macOS E2E verification script and a corresponding package.json script.
File summaries
File Description
zerolaunch-cli/src/client.rs Adjust data-dir resolution for macOS vs other OSes.
src-tauri/src/window/mod.rs Gate Windows-only fullscreen foreground check.
src-tauri/src/utils/mod.rs Gate utils::windows module behind Windows cfg.
src-tauri/src/utils/locale.rs Add macOS locale detection; gate Windows-only imports.
src-tauri/src/platform.rs New compile-time platform re-export/injection module.
src-tauri/src/lib.rs Refactor HostApi builder to use platform-injected types; soften deep-link registration failure.
src-tauri/src/bootstrap.rs Switch bootstrap wiring to Platform* injected implementations.
src-tauri/Cargo.toml Move Windows-only deps behind Windows target cfg; add macOS platform dependency.
scripts/e2e-macos.sh New macOS E2E smoke script (CLI + bearer auth ping).
package.json Add test:e2e:macos script.
crates/platform-macos/Cargo.toml New macOS platform crate manifest.
crates/platform-macos/src/lib.rs macOS platform crate module exports.
crates/platform-macos/src/app_enumerator.rs Enumerate .app bundles and extract metadata/icons.
crates/platform-macos/src/app_launcher.rs Launch apps via open (bundle id or path).
crates/platform-macos/src/autostart.rs Manage LaunchAgent plist for login startup.
crates/platform-macos/src/capabilities.rs Advertise macOS platform capabilities.
crates/platform-macos/src/clipboard.rs Clipboard write implementation via arboard.
crates/platform-macos/src/focus_monitor.rs Focus-loss reporting based on Tauri window events.
crates/platform-macos/src/hotkey.rs Global shortcut registration via tauri-plugin-global-shortcut.
crates/platform-macos/src/icon.rs Extract/convert app icons (icns → png via sips; favicon via HTTP).
crates/platform-macos/src/installation_monitor.rs Monitor application directories for changes via notify.
crates/platform-macos/src/lnk_resolver.rs Stub .lnk resolver (unsupported on macOS).
crates/platform-macos/src/parameter_providers.rs macOS parameter providers for clipboard/window handle/selection.
crates/platform-macos/src/path_resolver.rs Resolve macOS-known paths (Application Support, Logs, etc.).
crates/platform-macos/src/resource_loader.rs Stub localized resource loader (empty map).
crates/platform-macos/src/shell.rs Shell open/execute via open and /bin/sh.
crates/platform-macos/src/theme.rs Theme provider + polling-based theme monitor.
crates/platform-macos/src/window.rs Window activation via AppleScript (osascript).
crates/platform-macos/src/window_positioner.rs Compute window position across monitors.
Cargo.toml Add macOS platform crate to workspace and workspace dependencies.
Cargo.lock Add lock entries for new macOS platform crate and dependencies.
Review details
  • Files reviewed: 30/31 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src-tauri/src/lib.rs
.theme_provider(Arc::new(WindowsThemeProvider))
.clipboard_manager(Arc::new(PlatformClipboardManager::new()))
.window_positioner(Arc::new(PlatformWindowPositioner::new()))
.theme_provider(Arc::new(PlatformThemeProvider::new()))
Comment thread scripts/e2e-macos.sh
Comment on lines +20 to +23
if [[ ! -x "${cli_bin}" ]]; then
rust_toolchain="1.90.0-aarch64-apple-darwin"
rustup run "${rust_toolchain}" cargo build -p zerolaunch-cli --manifest-path "${repo_root}/Cargo.toml"
fi
Comment thread src-tauri/src/platform.rs
MacosShellExecutor as PlatformShellExecutor, MacosThemeProvider as PlatformThemeProvider,
MacosWindowHandleProvider as PlatformWindowHandleProvider,
MacosWindowManager as PlatformWindowManager, MacosWindowPositioner as PlatformWindowPositioner,
};
Comment on lines 104 to 105
/// 解析 ZeroLaunch 应用数据目录($HOME/.ZeroLaunch-rs)。
fn dirs_data() -> Result<std::path::PathBuf> {
ghost-him and others added 5 commits September 3, 2026 20:53
**🤔 背景与动机 (Why)**
- pr-87 macOS 平台实现的 code review 确认多项真实缺陷:双击 Ctrl 开关恒失败、快捷键键面不全、URL 图标提取违反 PNG 契约、自启动 launchctl 结果被吞。
- macOS 下搜索栏唤醒缺少全屏门控,与 Windows 行为不一致且注释误导。
- 系统区域检测依赖手工 cfg 分支,macOS GUI 下读环境变量会误判英文。

**✨ 解决方案与影响 (What & Impact)**
- 补齐 macOS 快捷键键面、对齐 URL 图标提取与自启动错误处理,修正双击 Ctrl 与主题/焦点监控告警、安装监控线程竞态。
- 新增 macOS 前台全屏检测并在唤醒链路接入门控,全屏时不唤出搜索栏。
- 系统区域检测收敛为平台无关调用,消除重复实现与文档失真。
- 更新平台能力与注释语言规则,覆盖新增 OS 平台 crate 路径与宿主别名约束。
**🤔 背景与动机 (Why)**
- 宿主内平台差异散落多处:全屏门控、版本检测、COM 初始化、宿主侧 Windows 工具模块各自携带条件编译。
- 宿主 utils 与平台 crate 存在重复实现(环境变量展开等逐字相同),且宿主保留大量已无代码引用的 Windows 系依赖。
- 平台差异实现哲学不统一:同是全屏检测,Windows 实现在宿主内、macOS 在平台 crate。

**✨ 解决方案与影响 (What & Impact)**
- 将全屏检测、系统版本、平台就绪初始化下沉为两平台 crate 的同名函数,经平台别名层统一注入,宿主调用点不再出现条件编译。
- 删除宿主侧重复的 Windows 工具模块与无人引用的平台依赖,同步对称化平台 crate 的模块结构。
- 宿主条件编译收敛至唯一平台别名文件,后续新增平台只需在该处登记并实现同名函数。
@ghost-him ghost-him self-assigned this Sep 4, 2026
@ghost-him ghost-him added the enhancement New feature or request label Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants