fix(cua): wait for the settings window before showing permission guidance

This commit is contained in:
creatixchu committed 2026-10-30 11:47:56 +08:00
1 parent 4ef8177d69
commit 8752b64b35
7 files changed
+13 -8

No files matched your search

@@ -12,8 +12,8 @@
en: 4549f02fc53854a5
zh: 6f74f1130b6623a8
/deepseek-ai-dsh-experimental-cua-macos/table-of-contents:
en: 5554884176bc5852
zh: 341b79487eae467f
en: 34dd3fa8857d798e
zh: 14c105e3e317f0ce
/deepseek-ai-dsh-experimental-cua-macos/use-this-package:
en: 7ff2d4f06916ff82
zh: d9e92b49c16868af
+1 -1
View File
@@ -24,7 +24,7 @@ The helper supplies bounded 64-pixel PNG application icons for permission prompt
The helper runs through LaunchServices as the independent application `DSH Computer Use.app`. Accessibility and Screen Recording permissions belong to this application. Permission guidance uses the responsible application’s bundle URL, identifier, filename, and system icon captured at startup; unavailable system attribution falls back to the independent helper’s own bundle. Dragging and Finder selection validate the bundle identifier and executable. Existing connections retain their running application generation when another build updates `current.json`.
Permission requests open the selected privacy pane and a native floating guide. The guide selects the largest settings window once and follows that window by ID. It uses the normal window level, ordered immediately above the selected window so authentication dialogs remain above it. Placement reads window bounds without requesting Accessibility access; unavailable initial bounds place it near the screen bottom. A material alpha mask gives the panel and its shadow rounded corners. The latest request replaces the shared guide, and only its owning connection can close it during cleanup. A rejected settings-open request reports `SETTINGS_UNAVAILABLE`; missing or replaced application targets report `APPLICATION_UNAVAILABLE`. System Settings owns drag acceptance and any relaunch requirement. macOS 14 is the minimum supported version; settings navigation, dragging, and permission refresh require qualification on each supported release.
Permission requests open the selected privacy pane and a native floating guide. The guide selects the largest settings window once and follows that window by ID. It uses the normal window level, ordered immediately above the selected window so authentication dialogs remain above it. Placement reads window bounds without requesting Accessibility access. The guide stays hidden until the settings window is identified; a failed settings-open request displays manual navigation instructions independently. A material alpha mask gives the panel and its shadow rounded corners. The latest request replaces the shared guide, and only its owning connection can close it during cleanup. A rejected settings-open request reports `SETTINGS_UNAVAILABLE`; missing or replaced application targets report `APPLICATION_UNAVAILABLE`. System Settings owns drag acceptance and any relaunch requirement. macOS 14 is the minimum supported version; settings navigation, dragging, and permission refresh require qualification on each supported release.
-----
+1 -1
View File
@@ -24,7 +24,7 @@ helper 为授权提示和已授权应用列表提供 64 像素 PNG 图标。读
helper 通过 LaunchServices 作为独立应用 `DSH Computer Use.app` 运行。辅助功能和屏幕录制权限属于此应用。授权引导使用启动时记录的责任应用 bundle URL、标识、文件名和系统图标;系统归属信息不可用时使用独立 helper 自身的 bundle。拖动和 Finder 选择会验证 bundle 标识及可执行文件。其他构建更新 `current.json` 后,已有连接仍指向正在运行的应用版本。
权限请求打开对应隐私设置页和原生悬浮引导框。引导框首次选择面积最大的设置窗口,随后按窗口 ID 跟随。它使用普通窗口层级,紧邻所选窗口上方排列,使认证弹窗保持在其上方。定位读取窗口边界,不申请辅助功能权限;初次无法获取边界时放在屏幕底部附近。材质的透明度遮罩为面板和阴影提供圆角。最新请求替换共享引导,连接清理只关闭自身创建的引导。系统拒绝打开设置时报告 `SETTINGS_UNAVAILABLE`;应用目标缺失或被替换时报告 `APPLICATION_UNAVAILABLE`。系统设置决定是否接收拖入的应用,以及是否要求重新启动。最低支持 macOS 14;设置导航、拖动和权限刷新需要在各支持版本验收。
权限请求打开对应隐私设置页和原生悬浮引导框。引导框首次选择面积最大的设置窗口,随后按窗口 ID 跟随。它使用普通窗口层级,紧邻所选窗口上方排列,使认证弹窗保持在其上方。定位读取窗口边界,不申请辅助功能权限。引导框等到识别出设置窗口后才显示;打开设置失败时独立显示手动导航说明。材质的透明度遮罩为面板和阴影提供圆角。最新请求替换共享引导,连接清理只关闭自身创建的引导。系统拒绝打开设置时报告 `SETTINGS_UNAVAILABLE`;应用目标缺失或被替换时报告 `APPLICATION_UNAVAILABLE`。系统设置决定是否接收拖入的应用,以及是否要求重新启动。最低支持 macOS 14;设置导航、拖动和权限刷新需要在各支持版本验收。
-----
@@ -74,6 +74,7 @@ enum PermissionGuidePlacement {
private var text: PermissionGuideText?
private var settingsWindowID: CGWindowID?
private var dragging = false
private var settingsOpenFailed = false
func show(application: PermissionGuideApplication, text: PermissionGuideText, owner: UUID,
interval: TimeInterval, granted: @escaping @MainActor () -> Bool) throws {
@@ -86,6 +87,7 @@ enum PermissionGuidePlacement {
returnApplication = previousApplication?.bundleIdentifier == "com.apple.systempreferences" ? nil : previousApplication
settingsWindowID = nil
dragging = false
settingsOpenFailed = false
let panel = PermissionGuidePanel(contentRect: NSRect(x: 0, y: 0, width: 620, height: 128),
styleMask: [.borderless, .nonactivatingPanel], backing: .buffered, defer: false)
@@ -190,6 +192,7 @@ enum PermissionGuidePlacement {
}
func reportSettingsFailure() {
settingsOpenFailed = true
if let text { showFailure(text.settingsMessage) }
}
@@ -219,6 +222,7 @@ enum PermissionGuidePlacement {
text = nil
settingsWindowID = nil
dragging = false
settingsOpenFailed = false
window?.close()
if activatePrevious, let previous, !previous.isTerminated { _ = previous.activate(options: []) }
}
@@ -241,6 +245,7 @@ enum PermissionGuidePlacement {
let target = PermissionGuidePlacement.target(in: snapshot.targets, pinned: settingsWindowID)
if let target { settingsWindowID = target.id }
else if settingsWindowID != nil { dismiss(activatePrevious: false); return }
else if !settingsOpenFailed { return }
let settings = target?.frame
let screen = NSScreen.screens.max { left, right in
let target = settings ?? primary.frame
+2 -2
View File
@@ -18,8 +18,8 @@
en: ed736a45140a6d56
zh: 8dc89373a0a88fcc
/deepseek-ai-dsh-cua/use-this-package/permission-controls:
en: fec13651aeab9a8d
zh: 09e9dd82bd767ec8
en: 35fe4f9842f7c152
zh: cbbb8ab4af00d88b
/deepseek-ai-dsh-cua/understand-the-implementation:
en: 90e8fcb6ebe271d1
zh: f0c90834bec8c73a
+1 -1
View File
@@ -45,7 +45,7 @@ Actions return `dispatched:true, verified:false`; read fresh state to verify the
On the Computer Use detail page, permission cards, component rows, and source facts use l3 borders, with 32px gaps between sections. Application badges retain their l1 borders.
The [Computer Use bundle](../cua-bundle/README.md) mounts this page with its native provider. **Authorize computer use** groups the new-session default, PTC execution mode, Accessibility, and Screen Recording inside one border. Each permission row shows the responsible application’s name and icon. **Request permission** opens the selected System Settings pane and a native guide over its lower margin. Drag the application row from this guide into the permission list, then enable its switch; enable the existing entry when already listed. The guide hides during dragging, closes when a drop is accepted, and returns after a canceled or rejected drag. The back button closes the guide and returns to the previous application. Right-click the application row or focus it and press Return or Space to reveal the same bundle in Finder. An outlined **Allowed** button opens settings for revocation; unknown status uses **Unknown**. Application grants remain in a separate group.
The [Computer Use bundle](../cua-bundle/README.md) mounts this page with its native provider. **Authorize computer use** groups the new-session default, PTC execution mode, Accessibility, and Screen Recording inside one border. Each permission row shows the responsible application’s name and icon. **Request permission** opens the selected System Settings pane; the native guide appears over its lower margin once the window is identified. Drag the application row from this guide into the permission list, then enable its switch; enable the existing entry when already listed. The guide hides during dragging, closes when a drop is accepted, and returns after a canceled or rejected drag. The back button closes the guide and returns to the previous application. Right-click the application row or focus it and press Return or Space to reveal the same bundle in Finder. An outlined **Allowed** button opens settings for revocation; unknown status uses **Unknown**. Application grants remain in a separate group.
The page refreshes on entry, window focus, and completed actions. Query failures retain the last observation as unknown and offer **Retry**. While open, the native guide checks permission and window position every `permissionPollIntervalMs` (default 1000 ms), and closes after a confirmed grant, dismissal, disappearance of the settings window, or its owning connection’s cleanup. Opening settings or dragging the application does not establish consent. Settings-open failures retain manual navigation instructions. Follow any macOS quit-and-reopen prompt; the shared helper is not automatically terminated.
+1 -1
View File
@@ -45,7 +45,7 @@ kind: "package-reference"
Computer Use 详情页的权限卡片、组件列表和来源信息使用 l3 边框,区块间距为 32px。应用名称徽标保留 l1 边框。
[Computer Use 组合](../cua-bundle/README.zh.md)将本页与原生 provider 一起挂载。“给 Computer Use 授权”把新会话默认模式、PTC 执行方式、辅助功能和屏幕录制放在同一个边框内。每条权限要求显示责任应用的名称和图标。“申请权限”打开对应系统设置页,并在其底部显示原生引导框。将引导框内的应用拖入权限列表,再开启开关;已有此应用时直接开启现有条目。拖动时隐藏引导框,放置被接收后关闭,拖动取消或被拒绝后恢复。返回按钮关闭引导框并返回之前的应用。右键点击应用行,或聚焦后按 Return、空格,可在 Finder 中选中同一应用。“已允许”描边按钮打开设置以撤销权限;未知状态使用“未确认”。应用访问授权保持独立分组。
[Computer Use 组合](../cua-bundle/README.zh.md)将本页与原生 provider 一起挂载。“给 Computer Use 授权”把新会话默认模式、PTC 执行方式、辅助功能和屏幕录制放在同一个边框内。每条权限要求显示责任应用的名称和图标。“申请权限”打开对应系统设置页;识别到设置窗口后,原生引导框才在其底部显示。将引导框内的应用拖入权限列表,再开启开关;已有此应用时直接开启现有条目。拖动时隐藏引导框,放置被接收后关闭,拖动取消或被拒绝后恢复。返回按钮关闭引导框并返回之前的应用。右键点击应用行,或聚焦后按 Return、空格,可在 Finder 中选中同一应用。“已允许”描边按钮打开设置以撤销权限;未知状态使用“未确认”。应用访问授权保持独立分组。
进入页面、返回窗口和操作结束后会刷新状态。查询失败保留上次观测但标为未确认,并提供“重试”。原生引导打开期间,每隔 `permissionPollIntervalMs` 检查权限和窗口位置,默认 1000 毫秒;在确认授权、用户关闭、系统设置窗口消失或所属连接清理时关闭。打开设置或拖动应用不代表授权完成。设置打开失败时保留手动导航说明。若 macOS 提示退出并重新打开应用,请按提示操作;系统不会自动终止共享 helper。