Skip to content

feat: add native macOS controller support - #298

Merged
MistEO merged 3 commits into
MistEO:mainfrom
Windsland52:issue-242-native-macos-controller
Jul 29, 2026
Merged

feat: add native macOS controller support#298
MistEO merged 3 commits into
MistEO:mainfrom
Windsland52:issue-242-native-macos-controller

Conversation

@Windsland52

@Windsland52 Windsland52 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Closes #242

Summary

  • add ProjectInterface V2 MacOS support with the correct macos.title_regex contract
  • support native MaaFramework window discovery and controller creation across manual, historical, and automatic connection flows
  • require macOS 14+ and MaaFramework v5.10.0-beta.1+ before calling native macOS APIs
  • request Screen Recording permission for discovery and Accessibility permission only when input is enabled
  • localize permission, platform, system-version, and MaaFramework-version errors in all supported locales
  • map pipeline hotkeys to native CGKeyCode values while preserving Command/Meta semantics

Relation to #271

This supersedes #271 by reimplementing its approach on the current main branch and addressing the remaining protocol, compatibility, permission, and hotkey gaps.

Validation

  • pnpm build
  • cargo check --locked
  • cargo test --locked --lib (6 passed)
  • Rustfmt check
  • git diff --check

QA note

Runtime verification on macOS 14+ hardware is still recommended for the first-run TCC permission flow, GlobalEvent/PostToPid input behavior, and non-US keyboard layouts.

Implement ProjectInterface V2 MacOS discovery and connection flows, add runtime and permission guards, and map pipeline hotkeys to native CGKeyCode values.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - 我在这里给出了一些整体层面的反馈:

  • 前端中的 macOS 错误处理(localizeControllerError)目前依赖对错误消息内容的子字符串匹配;可以考虑改用后端提供的结构化错误码或专用错误类型,这样可以让本地化和分支逻辑在未来错误消息发生变更时更稳健。
  • macos_system_version_supported 对任何无法解析的版本字符串都会静默返回 false;如果 sysctl 返回了意料之外的格式,你可能需要记录日志或以更明确的诊断信息形式暴露出来,以便区分系统信息格式异常和确实不受支持的系统版本。
用于 AI Agents 的提示词
Please address the comments from this code review:

## Overall Comments
- The macOS error handling on the frontend (localizeControllerError) depends on substring matches in error messages; consider using structured error codes or dedicated error types from the backend to make localization and branching more robust to future message changes.
- macos_system_version_supported silently returns false for any unparsable version string; if sysctl returns unexpected formats, you may want to log or surface a more explicit diagnostic to distinguish malformed system info from genuinely unsupported versions.

Sourcery 对开源项目是免费的——如果你觉得我们的代码审查有帮助,请考虑分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的代码审查。
Original comment in English

Hey - I've left some high level feedback:

  • The macOS error handling on the frontend (localizeControllerError) depends on substring matches in error messages; consider using structured error codes or dedicated error types from the backend to make localization and branching more robust to future message changes.
  • macos_system_version_supported silently returns false for any unparsable version string; if sysctl returns unexpected formats, you may want to log or surface a more explicit diagnostic to distinguish malformed system info from genuinely unsupported versions.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The macOS error handling on the frontend (localizeControllerError) depends on substring matches in error messages; consider using structured error codes or dedicated error types from the backend to make localization and branching more robust to future message changes.
- macos_system_version_supported silently returns false for any unparsable version string; if sysctl returns unexpected formats, you may want to log or surface a more explicit diagnostic to distinguish malformed system info from genuinely unsupported versions.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Return an explicit diagnostic when kern.osproductversion cannot be parsed, log the raw value, and localize the new error across supported languages.
@Windsland52

Copy link
Copy Markdown
Contributor Author

Addressed the system-version parsing feedback in b4a5a0a:

  • macos_system_version_supported now returns Result<bool, String>
  • malformed or empty kern.osproductversion values are logged with the raw value
  • malformed values return the dedicated MACOS_VERSION_DETECTION_FAILED diagnostic instead of being reported as an unsupported OS
  • the new diagnostic is localized in every supported locale
  • unit tests now cover unsupported, supported, empty, and malformed versions

Regarding structured errors: the current project command boundary consistently uses Result<T, String>. The uppercase MACOS_* tokens are stable sentinel codes, and the frontend substring lookup intentionally finds them in both raw Tauri errors and HTTP errors wrapped by backendApi. A proper structured error type would need an end-to-end transport change across Rust/Tauri serialization, Axum JSON responses, and frontend HTTP parsing. I kept that broader refactor out of this controller-focused PR rather than introduce a macOS-only error model.

@MistEO

MistEO commented Jul 28, 2026

Copy link
Copy Markdown
Owner

冲突了,康康

@MistEO
MistEO merged commit 5e3d3a6 into MistEO:main Jul 29, 2026
9 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.

对原生mac控制器的支持

2 participants