Skip to content

feat: add native macOS foreground desktop support - #93

Open
Silhouette-my wants to merge 27 commits into
ok-oldking:masterfrom
Silhouette-my:feature/macos-foreground-mvp
Open

Silhouette-my wants to merge 27 commits into
ok-oldking:masterfrom
Silhouette-my:feature/macos-foreground-mvp

Conversation

@Silhouette-my

@Silhouette-my Silhouette-my commented Sep 7, 2026

Copy link
Copy Markdown

概要

为 ok-script 增加可复用的原生 macOS 前台桌面 provider,同时保持现有 Windows/ADB 行为。该实现由 OK-WW 的 macOS 移植实际使用并完成交叉平台回归。

主要内容:

  • 平台中立 DesktopWindowTarget,macOS 窗口发现、绑定、重绑、前台观察与权限服务
  • 持久 ScreenCaptureKit SCStream 单窗口捕获,bounded latest-frame、BGR uint8、Retina/geometry generation 与 stale-frame rejection
  • Quartz 前台键盘/鼠标输入、ForegroundGuardHeldInputState、幂等 release_all() 与 2 秒 capture heartbeat gate
  • DeviceCapabilities、任务执行前 capability gate、Mac 任务/UI 状态支持
  • Cursor/path 等平台服务,以及 Darwin/Windows 平台安全 import / dependency 边界
  • 收口 macOS capture preparation 生命周期:provider/capture readiness 与最终 input arm 分离

安全边界

  • 仅支持 foreground-only;游戏失焦、窗口/进程丢失、权限失效、capture fatal/stale、任务停止时 fail closed 并释放 held input
  • 不使用 CGEvent.postToPid 后台输入、BetterDisplay/虚拟显示、private API、进程注入、hook 或 TCC 绕过
  • 不做自动循环抢焦点
  • relative_mouse 继续作为独立 capability,当前不作为基础前台 MVP 的统一阻断项

验证

当前 framework PR HEAD:f306651c1f292056d65fa8febaa477401d319846

本地:

  • runtime 质量修复后的 full pytest: 744 passed, 12 skipped, 4 subtests passed
  • pip check 通过
  • Darwin import isolation / Windows regression contracts 通过

GitHub Actions / quality gate:

391aa7b 之后仅调整开发期 CI/source-guardrail,不再改变 capture/input/window runtime。当前 OK-WW PR 已固定测试本 PR HEAD 的 immutable framework SHA。真实硬件侧已经完成官方《鸣潮》Mac 客户端窗口发现、persistent capture、Retina/16:9/16:10 几何、基础键鼠及失焦释放等验证;详细 consumer/package 证据在配套 OK-WW PR 中记录。

兼容性说明

ok-script 的通用 public-API host gate 保留 macOS 13+;当前 OK-WW packaged MVP 因其 Python/PySide6 等 consumer 二进制依赖明确收窄为 macOS 15+,不把 consumer 的二进制限制错误上推到 framework。

配套 PR

…eground-mvp

# Conflicts:
#	ok/notification/manager.py
#	ok/util/windows_schedule.py
#	tests/test_notifications.py
Comment thread .github/workflows/macos-port-stage2-macos.yml Fixed
python -m pip install "pip==26.2.1"
# Development-only branch guardrail: the editable project is this exact checkout;
# release dependency locking is handled by the normal release workflow.
python -m pip install -e ".[default,web,qt,adb,ocr,dev]" "opencv-python==5.0.0.93" "pytest-subtests==0.15.0" # NOSONAR
@sonarqubecloud

sonarqubecloud Bot commented Sep 7, 2026

Copy link
Copy Markdown

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.

2 participants