Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(computer-use): distinguish app and backend accessibility trust

vastsa7dd5cbb47fc3
diff --git a/apps/desktop/electron/main/computer-use/permission.ts b/apps/desktop/electron/main/computer-use/permission.ts
index d40d3f96a..b7b1df09e 100644
--- a/apps/desktop/electron/main/computer-use/permission.ts
+++ b/apps/desktop/electron/main/computer-use/permission.ts
@@ -1,10 +1,21 @@
-import { shell } from "electron";
+import { shell, systemPreferences } from "electron";
import { needsAccessibilityRequest, type ComputerCapabilities } from "@pi-desktop/shared";
/** Fixed OS pane only; neither renderer nor model can supply an external URL. */
export const ACCESSIBILITY_SETTINGS_URL =
"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility";
+/** The app and its Rust child can have different TCC identities. Do not conflate them. */
+export function applicationAccessibility(
+ capabilities: ComputerCapabilities,
+ prompt = false,
+): ComputerCapabilities {
+ if (capabilities.platform !== "darwin" || capabilities.backend !== "macos-ax") return capabilities;
+ const granted = systemPreferences.isTrustedAccessibilityClient(false)
+ || (prompt && systemPreferences.isTrustedAccessibilityClient(true));
+ return { ...capabilities, applicationAccessibility: granted ? "granted" : "not-requested" };
+}
+
/** TCC may not show another prompt, so expose the switch in System Settings. */
export async function openAccessibilitySettings(
capabilities: ComputerCapabilities,
diff --git a/apps/desktop/electron/main/ipc/computer-ipc.ts b/apps/desktop/electron/main/ipc/computer-ipc.ts
index 0bdfb6ba6..098ac5712 100644
--- a/apps/desktop/electron/main/ipc/computer-ipc.ts
+++ b/apps/desktop/electron/main/ipc/computer-ipc.ts
@@ -10,7 +10,7 @@
*/
import { IPC, type ComputerCapabilities, type ComputerGrantView } from "@pi-desktop/shared";
import { capturePermissionState } from "../computer-use/capture";
-import { openAccessibilitySettings } from "../computer-use/permission";
+import { applicationAccessibility, openAccessibilitySettings } from "../computer-use/permission";
import type { HostProcess } from "../host-process";
import type { IpcRegistrar } from "./types";
@@ -32,22 +32,23 @@ export function registerComputerIpc({ registrar, getHost, publishGrant }: Comput
if (!host) hostUnavailable();
const capabilities = await host.call<ComputerCapabilities>("computer.capabilities", {});
// host-core cannot answer for the capture path: that one is Chromium's.
- return { ...capabilities, capture: capturePermissionState() };
+ return { ...applicationAccessibility(capabilities), capture: capturePermissionState() };
});
- // The user's click: the host asks macOS for Accessibility, and when the
- // answer is still "no" main opens the pane that holds the switch. The reply
- // is the same capability object the row already renders, so the badge updates
- // without a second round trip.
+ // Request trust for the app visible in System Settings. The Rust child's
+ // trust remains a separate, authoritative check before native input.
registrar.handleWithEvent(IPC.invoke.computerRequestPermission, async (event) => {
registrar.assertMainWindowSender(event);
const host = getHost();
if (!host) hostUnavailable();
const capabilities = await host.call<ComputerCapabilities>(
- "computer.requestPermission",
+ "computer.capabilities",
{},
);
- const view = { ...capabilities, capture: capturePermissionState() };
+ const requested = capabilities.platform === "darwin" && capabilities.backend === "macos-ax"
+ ? applicationAccessibility(capabilities, true)
+ : await host.call<ComputerCapabilities>("computer.requestPermission", {});
+ const view = { ...requested, capture: capturePermissionState() };
await openAccessibilitySettings(view);
return view;
});
diff --git a/apps/desktop/src/features/computer-use/use-computer-permission.ts b/apps/desktop/src/features/computer-use/use-computer-permission.ts
index 7098cbbca..ddd8e6dec 100644
--- a/apps/desktop/src/features/computer-use/use-computer-permission.ts
+++ b/apps/desktop/src/features/computer-use/use-computer-permission.ts
@@ -56,6 +56,19 @@ export function useComputerPermission() {
};
}, [refresh]);
+ useEffect(() => {
+ if (!waiting) return;
+ let polling = false;
+ let attempts = 0;
+ // TCC can settle after focus returns. Poll briefly without prompting again.
+ const timer = window.setInterval(() => {
+ if (++attempts >= 60) window.clearInterval(timer);
+ if (document.hidden || polling || pending.current) return;
+ polling = true;
+ void refresh().finally(() => { polling = false; });
+ }, 1_000);
+ return () => window.clearInterval(timer);
+ }, [waiting, refresh]);
const requestPermission = useCallback(async () => {
if (!mounted.current || pending.current || !capabilities || !needsAccessibilityRequest(capabilities)) return;
pending.current = true;
diff --git a/apps/desktop/src/features/settings/computer-use/ComputerUseSettings.tsx b/apps/desktop/src/features/settings/computer-use/ComputerUseSettings.tsx
index 8524f2b2a..3eb4e0a00 100644
--- a/apps/desktop/src/features/settings/computer-use/ComputerUseSettings.tsx
+++ b/apps/desktop/src/features/settings/computer-use/ComputerUseSettings.tsx
@@ -64,6 +64,9 @@ export function ComputerUseSettings({
const selectedModel = value.model ? `${value.model.providerId}\u0000${value.model.modelId}` : "";
const unsupported = capabilities?.backend === "unsupported";
+ const accessibility = capabilities?.applicationAccessibility ?? capabilities?.accessibility;
+ const backendPermissionMissing = capabilities?.applicationAccessibility === "granted"
+ && capabilities.accessibility !== "granted";
const patch = (next: Partial<ComputerUseSettingsValue>) =>
void saveSettings({ computerUse: { ...value, ...next } });
@@ -96,11 +99,11 @@ export function ComputerUseSettings({
aria-busy={requesting}
onClick={() => { void requestPermission(); }}
>
- {requesting ? t("computerUse.requestingPermission") : t(`computerUse.permission.${capabilities.accessibility}`)}
+ {requesting ? t("computerUse.requestingPermission") : t(`computerUse.permission.${accessibility}`)}
</Button>
) : (
- <Badge tone={capabilities.accessibility === "granted" ? "neutral" : "warning"}>
- {t(`computerUse.permission.${capabilities.accessibility}`)}
+ <Badge tone={accessibility === "granted" ? "neutral" : "warning"}>
+ {t(`computerUse.permission.${accessibility}`)}
</Badge>
)}
</>
@@ -116,6 +119,11 @@ export function ComputerUseSettings({
: t("computerUse.permissionPending")}
</p>
)}
+ {backendPermissionMissing && (
+ <p className="computer-use-picker-error" role="status">
+ {t("computerUse.backendPermissionMissing")}
+ </p>
+ )}
{value.enabled && (
<>
diff --git a/apps/desktop/test/computer-use-permission-ipc.test.mjs b/apps/desktop/test/computer-use-permission-ipc.test.mjs
index 86f8392b4..41042b5b4 100644
--- a/apps/desktop/test/computer-use-permission-ipc.test.mjs
+++ b/apps/desktop/test/computer-use-permission-ipc.test.mjs
@@ -20,7 +20,13 @@ export const shell = { openExternal: async (url) => {
if (globalThis.computerPermissionFixture.openError) throw new Error("Fixture pane unavailable");
} };
export const desktopCapturer = { getSources: async () => { throw new Error("Permission requests must not capture"); } };
-export const systemPreferences = { getMediaAccessStatus: () => "granted" };
+export const systemPreferences = {
+ getMediaAccessStatus: () => "granted",
+ isTrustedAccessibilityClient: (prompt) => {
+ globalThis.computerPermissionFixture.prompts.push(prompt);
+ return globalThis.computerPermissionFixture.appTrusted;
+ },
+};
`);
const outfile = join(temp, "ipc.mjs");
await build({
@@ -32,7 +38,7 @@ export { IPC } from "@pi-desktop/shared";
alias: { electron: stub, "@pi-desktop/shared": join(root, "packages/shared/src") },
});
const { registerComputerIpc, IPC } = await import(pathToFileURL(outfile).href);
- const fixture = { urls: [], openError: false };
+ const fixture = { urls: [], openError: false, appTrusted: false, prompts: [] };
globalThis.computerPermissionFixture = fixture;
t.after(() => { delete globalThis.computerPermissionFixture; });
const callbacks = new Map();
@@ -71,15 +77,17 @@ export { IPC } from "@pi-desktop/shared";
const result = await request({ trusted: true }, { url: "https://not-accepted.invalid", targetId: "not-accepted" });
assert.equal(result.accessibility, "not-requested");
assert.equal(result.capture, "granted");
- assert.deepEqual(calls, [{ method: "computer.requestPermission", params: {} }]);
+ assert.deepEqual(calls, [{ method: "computer.capabilities", params: {} }]);
assert.deepEqual(fixture.urls, ["x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"]);
fixture.urls.length = 0;
capabilities.accessibility = "granted";
+ fixture.appTrusted = true;
assert.equal((await request({ trusted: true })).accessibility, "granted");
assert.deepEqual(fixture.urls, []);
capabilities.accessibility = "denied";
+ fixture.appTrusted = false;
await request({ trusted: true });
assert.equal(fixture.urls.length, 1);
fixture.openError = true;
@@ -87,6 +95,17 @@ export { IPC } from "@pi-desktop/shared";
fixture.openError = false;
fixture.urls.length = 0;
+ fixture.appTrusted = true;
+ const read = callbacks.get(IPC.invoke.computerCapabilities);
+ const appGranted = await read({ trusted: true });
+ assert.equal(appGranted.applicationAccessibility, "granted",
+ "Settings must read the app's own TCC grant even when its child reports denied");
+ assert.equal(appGranted.accessibility, "denied", "backend refusal must remain authoritative");
+ await request({ trusted: true });
+ assert.deepEqual(fixture.urls, [], "already-authorized app must not reopen System Settings");
+ assert.equal(fixture.prompts.at(-1), false, "an authorized app must not be prompted again");
+ fixture.appTrusted = false;
+
hostError = Object.assign(new Error("Platform unsupported"), { errorCode: "COMPUTER_PLATFORM_UNSUPPORTED" });
await assert.rejects(request({ trusted: true }), { errorCode: "COMPUTER_PLATFORM_UNSUPPORTED" });
assert.deepEqual(fixture.urls, []);
diff --git a/apps/desktop/test/computer-use-permission-user-path.test.mjs b/apps/desktop/test/computer-use-permission-user-path.test.mjs
index 81d1eb64d..65a2cb34d 100644
--- a/apps/desktop/test/computer-use-permission-user-path.test.mjs
+++ b/apps/desktop/test/computer-use-permission-user-path.test.mjs
@@ -29,6 +29,20 @@ let reads = [];
let requests = [];
let requestCount = 0;
let readCount = 0;
+const permissionTimers = new Map();
+const nativeSetInterval = window.setInterval.bind(window);
+const nativeClearInterval = window.clearInterval.bind(window);
+let timerId = -1;
+window.setInterval = (callback, delay, ...args) => {
+ if (delay !== 1000) return nativeSetInterval(callback, delay, ...args);
+ const id = timerId--;
+ permissionTimers.set(id, callback);
+ return id;
+};
+window.clearInterval = (id) => {
+ if (!permissionTimers.delete(id)) nativeClearInterval(id);
+};
+Object.defineProperty(document, "hidden", { configurable: true, value: false });
window.piDesktop = {
on() { return () => {}; },
async invoke(channel) {
@@ -80,12 +94,18 @@ window.computerPermissionProbe = async () => {
reply();
await until(() => !!button() && !button().disabled, "request button did not recover");
check(message()?.textContent.includes("System Settings"), "still-missing permission has no manual-grant guidance");
+ await until(() => permissionTimers.size === 1, "permission follow-up timer missing");
+ capabilities.applicationAccessibility = "granted";
+ const beforePoll = readCount;
+ [...permissionTimers.values()][0]();
+ await until(() => document.body.textContent.includes("Accessibility granted"), "app grant did not update without a focus event");
+ check(readCount > beforePoll && !button(), "authorized app remained actionable");
+ check(message()?.textContent.includes("backend"), "backend denial was hidden behind the app grant");
+ await until(() => permissionTimers.size === 0, "granted app kept polling");
capabilities.accessibility = "granted";
- const beforeFocus = readCount;
window.dispatchEvent(new Event("focus"));
- await until(() => document.body.textContent.includes("Accessibility granted"), "returning from System Settings did not refresh permission");
- check(readCount > beforeFocus && !button(), "granted permission remained actionable");
- check(!message(), "waiting guidance remained after granting permission");
+ await until(() => !message(), "backend recovery did not clear the diagnostic");
+ delete capabilities.applicationAccessibility;
capabilities.accessibility = "denied";
window.dispatchEvent(new Event("focus"));
@@ -133,10 +153,19 @@ window.computerPermissionProbe = async () => {
window.dispatchEvent(new Event("focus"));
await until(() => !!button(), "unmount reset missing");
flushSync(() => button().click());
+ reply();
+ await until(() => permissionTimers.size === 1, "bounded polling did not start");
+ for (let tick = 0; tick < 60; tick += 1) {
+ [...permissionTimers.values()][0]();
+ await settle();
+ }
+ check(permissionTimers.size === 0, "polling did not expire after 60 ticks");
+ flushSync(() => button().click());
flushSync(() => rootNode.unmount());
const afterUnmount = readCount;
window.dispatchEvent(new Event("focus"));
reply();
+ check(permissionTimers.size === 0, "unmounted settings retained a poll timer");
await settle();
check(readCount === afterUnmount, "unmounted settings retained focus listeners");
return { passed: true, requestCount };
@@ -195,6 +224,6 @@ app.whenReady().then(async () => {
assert.equal(code, 0, output.slice(-6000));
const line = output.split(/\r?\n/).find((item) => item.startsWith("COMPUTER_PERMISSION_PROBE "));
assert.ok(line, output.slice(-6000));
- assert.deepEqual(JSON.parse(line.slice("COMPUTER_PERMISSION_PROBE ".length)), { passed: true, requestCount: 6 });
+ assert.deepEqual(JSON.parse(line.slice("COMPUTER_PERMISSION_PROBE ".length)), { passed: true, requestCount: 7 });
} finally { await rm(temp, { recursive: true, force: true }); }
});
diff --git a/docs/adr/0342-os-computer-use-capability.md b/docs/adr/0342-os-computer-use-capability.md
index 64b44b5c6..9b5bde181 100644
--- a/docs/adr/0342-os-computer-use-capability.md
+++ b/docs/adr/0342-os-computer-use-capability.md
@@ -208,6 +208,13 @@ user: it can approve dialogs, including this application's own permission cards.
- The product acquires OS permission prompts it never had. A doctor view has to
report Screen Recording and Accessibility state per platform, because a denied
TCC grant is indistinguishable from a broken feature from the user's side.
+ The desktop app and its child can have different TCC attribution, especially
+ in adhoc builds. Settings queries and requests the app's trust in Electron
+ main; the optional `applicationAccessibility` field is display-only. Native
+ trust remains host-core's `accessibility` reading and all input refusals stay
+ there. A disagreement must be shown explicitly, not resolved by copying an
+ app-level grant into native authority. This retains the ownership decision
+ above and adds no input path or sidecar proxy permission.
- Screenshots of the user's desktop can now enter a session transcript and
therefore SQLite. That is a real privacy change; `a11y-only` grants exist so a
user can take the capability without it.
diff --git a/docs/spec/03-runtime/computer-use.md b/docs/spec/03-runtime/computer-use.md
index 74a686f6e..1efea6506 100644
--- a/docs/spec/03-runtime/computer-use.md
+++ b/docs/spec/03-runtime/computer-use.md
@@ -255,8 +255,11 @@ never a no-op reported as success.
presented as a broken feature.
- On macOS, missing Accessibility is a keyboard-accessible button in Settings,
available even while Computer Use is off. Only clicking it invokes
- `pi-desktop/computer/permission/request` → `computer.requestPermission` →
- `AXIsProcessTrustedWithOptions` with the OS prompt option. If still untrusted,
+ `pi-desktop/computer/permission/request`. Main checks and prompts the app's
+ own TCC identity using `systemPreferences.isTrustedAccessibilityClient`.
+ The host's `computer.requestPermission` remains a backend-only API; desktop
+ settings does not prompt through the differently-attributed Rust process.
+ If still untrusted,
main opens the fixed Accessibility pane in System Settings; the user must
enable the switch. This never grants trust automatically or hands over a
target. macOS cannot distinguish an unrequested grant from a denied grant
@@ -268,6 +271,19 @@ never a no-op reported as success.
unmount removes listeners and discards pending results. Granted and unsupported
permission states remain labels, not request buttons. The request IPC rejects
non-main-window senders, and no `host.proxy` allowlist entry is added.
+- Desktop capabilities add optional `applicationAccessibility`, queried afresh in
+ main. `accessibility` retains its existing meaning: the backend's OS trust.
+ Settings uses the app state when present, falling back to the backend field for
+ older hosts. If the app is granted but the backend is not, show the granted
+ badge with an explicit backend-permission diagnostic. The main-process reading
+ is display-only: it is never sent to host-core as authority and cannot bypass
+ its inspection, grant, or input checks. Adhoc builds can have distinct app and
+ executable-path identities in TCC; a checked app entry is not evidence that
+ the backend can act.
+- After a request remains ungranted, poll capabilities once per second for up
+ to 60 ticks while the page is visible. Never prompt from a poll. Stop the
+ timer on app authorization or unmount. Focus/visibility rechecks remain active
+ after polling expires, and pending requests are never duplicated.
- The target picker is host-driven and shows the display list only while it is
open. It is the only way to choose a target.
- The grant indicator is visible for the whole life of a grant, names the
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index eae188a62..95349d7b6 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -19679,13 +19679,18 @@ The permission-request UI below has isolated fixture automation.
retry, a stale capabilities read, focus during a pending request, unsupported
platform, and unmount during a request.
- **Expected**: Opening Settings or toggling the feature never requests OS
- permission. Explicit click alone sends `computer.requestPermission`; while
- pending, the button is busy/disabled and duplicate clicks are ignored. Missing
- trust opens only the fixed macOS Accessibility pane and explains that the user
- must enable it. Errors are visible and retryable. Focus/visibility refreshes
- without prompting; stale results and unmounted listeners cannot update UI.
- Granted/unsupported states are labels. Non-main senders are rejected before
- OS calls; opening failure propagates; no grant, capture, or input is dispatched.
+ permission. Explicit click alone requests the app's own TCC trust in main;
+ while pending, the button is busy/disabled and duplicate clicks are ignored.
+ Missing app trust opens only the fixed macOS Accessibility pane and explains
+ that the user must enable it. Errors are visible and retryable. Focus and
+ visibility refreshes never prompt. Controlled one-second polling after a
+ request detects authorization without a focus event, stops on authorization
+ or unmount, and expires after 60 ticks. Stale reads cannot replace newer state.
+ An app-level grant updates the badge even when the Rust child still reports
+ denied: show a backend-permission diagnostic instead of another request.
+ Backend recovery clears the diagnostic without granting any authority from UI.
+ Granted/unsupported states are labels. Non-main senders are rejected before OS
+ calls; opening failure propagates; no grant, capture, or input is dispatched.
- **Automation**: `node --test apps/desktop/test/computer-use-permission-user-path.test.mjs
apps/desktop/test/computer-use-permission-ipc.test.mjs`; shared capability
selection tests and host-core unsupported-backend tests cover platform gating.
diff --git a/docs/zh-CN/spec/03-runtime/computer-use.md b/docs/zh-CN/spec/03-runtime/computer-use.md
index afa8f7d40..701e4f67e 100644
--- a/docs/zh-CN/spec/03-runtime/computer-use.md
+++ b/docs/zh-CN/spec/03-runtime/computer-use.md
@@ -144,8 +144,10 @@ Agent 以一条自然语言 `instruction` 加可选 `maxSteps` 调用它;`obse
- 电脑操作默认关闭。打开开关不会创建授权、申请操作系统权限、截取画面或枚举窗口。
- 模型绑定是显式的。设置里提供用户已配置的 Provider 行;功能已开启但没有绑定是一个可见的未配置状态,而不是静默回退到对话模型。
- 体检视图按平台报告操作系统权限状态(无障碍、截取、无障碍总线、会话类型),并区分"未申请"、"已拒绝"与"本平台不支持"。被拒绝的 TCC 授权不得呈现为功能损坏。
-- macOS 上,缺少辅助功能权限时,设置中的状态是可用键盘访问的申请按钮,功能关闭时也可点击。仅点击才调用 `pi-desktop/computer/permission/request` → `computer.requestPermission` → 带系统提示选项的 `AXIsProcessTrustedWithOptions`。仍未授权时,Main 打开固定的系统设置辅助功能页面,由用户手动开启开关;不会自动获得权限或交接目标。macOS 的可信查询无法区分未申请与已拒绝,两者均在获准前显示 `not-requested`。
+- macOS 上,缺少辅助功能权限时,设置中的状态是可用键盘访问的申请按钮,功能关闭时也可点击。点击 `pi-desktop/computer/permission/request` 后,由 Main 的 `systemPreferences.isTrustedAccessibilityClient` 查询并申请主应用自己的 TCC 权限,不再让身份可能不同的 Rust 子进程代为申请。宿主的 `computer.requestPermission` 保留为后端 API。仍未授权时,Main 打开固定的系统设置辅助功能页面,由用户手动开启开关;不会自动获得权限或交接目标。macOS 的可信查询无法区分未申请与已拒绝,两者均在获准前显示 `not-requested`。
- 请求期间显示忙碌并禁用按钮,重复点击不会重复申请。申请失败或系统设置打开失败会显示错误码并允许重试。返回应用或页面再次可见时仅重新查询能力,不再次弹授权提示。过期查询不得覆盖申请结果;卸载页面清理监听并丢弃未完成结果。已授权与不支持状态仅显示标签。申请 IPC 拒绝非主窗口来源,不新增 `host.proxy` 白名单入口。
+- 桌面能力信息新增可选 `applicationAccessibility`,由 Main 实时查询;原 `accessibility` 继续表示操作后端的系统权限。设置优先显示主应用权限,旧宿主无新增字段时仍回退到原字段。如果主应用已授权而后端未授权,显示已授权标签并单独提示后端权限异常。主应用查询结果仅用于显示,不传给 host-core 作为放行依据,检查、窗口交接和输入仍由后端核验。adhoc 构建的应用与可执行路径可能有不同 TCC 身份,系统设置中的应用勾选不代表后端已能操作。
+- 申请后仍未授权时,在页面可见期间每秒查询一次能力,最多持续 60 次计时。轮询不弹权限提示,主应用获准或页面卸载时停止;轮询结束后,焦点与可见性恢复仍会重新查询。等待中的请求不重复执行。
- 目标挑选器由宿主驱动,仅在打开期间展示列表。它是选择目标的唯一方式。
- 授权指示器在授权存续期间始终可见,标明目标、剩余预算与截取模式,并带有"停止"。应用退到后台时它仍然可见。
- 授权卡片在批准之前说明正在批准哪种截取模式,并说明 `a11y-and-pixels` 意味着目标的截图可能进入会话转录。
diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
index 86d716c2e..0de2324b6 100644
--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
@@ -10170,7 +10170,7 @@ PluginPack 产物的解包目录,仅用于开发验证。验收 #1711 前需
- **前置条件**:隔离 Electron profile;在 IPC 与 Electron 边界模拟系统调用;功能关闭,不调用 Provider 或真实系统权限提示。
- **步骤**:打开设置,键盘聚焦并连续点击未授权状态;完成申请但保持未授权。在外部开启权限后返回应用。覆盖权限拒绝、申请失败及重试、过期查询、申请中返回焦点、不支持平台与申请中卸载页面。
-- **预期**:打开设置或开启功能不会申请系统权限。只有显式点击发送 `computer.requestPermission`;等待中禁用按钮并显示忙碌,重复点击不重复申请。未授权时仅打开固定的 macOS 辅助功能设置页,并提示用户开启权限。错误可见且可重试。焦点/可见性恢复只刷新状态,不再次提示;过期结果和卸载后的监听不得更新界面。已授权或不支持状态仅显示标签。非主窗口来源在系统调用前被拒绝,系统设置打开失败传回;不会交接窗口、截屏或派发输入。
+- **预期**:打开设置或开启功能不会申请系统权限。只有显式点击才在 Main 申请主应用 TCC 权限,后端 API 保持独立。等待中禁用按钮并显示忙碌,重复点击不重复申请。未授权时仅打开固定的 macOS 辅助功能设置页,并提示用户开启权限。错误可见且可重试。焦点/可见性恢复刷新状态;申请后每秒轮询一次,最多 60 次计时,不再次提示。主应用授权后停止轮询并显示已授权;即使子进程仍未授权,也不会继续要求重复授权,而是单独说明后端权限异常。后端恢复后清除异常。过期结果和卸载后的监听、计时器不得更新界面。已授权或不支持状态仅显示标签。非主窗口来源在系统调用前被拒绝,系统设置打开失败传回;不会交接窗口、截屏或派发输入。
- **自动化**:`node --test apps/desktop/test/computer-use-permission-user-path.test.mjs apps/desktop/test/computer-use-permission-ipc.test.mjs`;shared 能力筛选测试与 host-core 不支持后端测试覆盖平台门禁。
- **规格**:[Computer Use](/zh-CN/spec/03-runtime/computer-use) 的设置与 UX 界面。
- **状态**:fixture 自动化 PASS;真实 macOS TCC 提示/开关 NOT RUN。系统权限仍由用户手动确认。
diff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.ts
index eb8ee16db..4fd4a79d5 100644
--- a/packages/i18n/src/locales/de/index.ts
+++ b/packages/i18n/src/locales/de/index.ts
@@ -2922,6 +2922,7 @@ sklm: {
requestPermission: "Zugriff auf Bedienungshilfen anfordern",
requestingPermission: "Zugriff wird angefordert…",
permissionPending: "Aktiviere PI-Desktop unter Bedienungshilfen in den Systemeinstellungen. Kehre dann zurück, um den Status zu aktualisieren.",
+ backendPermissionMissing: "PI-Desktop ist autorisiert, das native Steuerungs-Backend jedoch nicht. Prüfe App-Signatur und Backend-Berechtigungen; die Computersteuerung bleibt gesperrt.",
permissionRequestFailed: "Bedienungshilfen konnten nicht angefordert oder Systemeinstellungen nicht geöffnet werden. Versuche es erneut. ({{code}})",
permission: {
granted: "Accessibility granted",
diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.ts
index 739c2d695..3cd6def8d 100644
--- a/packages/i18n/src/locales/en/index.ts
+++ b/packages/i18n/src/locales/en/index.ts
@@ -2970,6 +2970,7 @@ importConfirm: "Imported extensions run inside the agent process with the same a
requestPermission: "Request Accessibility permission",
requestingPermission: "Requesting Accessibility…",
permissionPending: "Enable Accessibility for PI-Desktop in System Settings, then return here to refresh the status.",
+ backendPermissionMissing: "PI-Desktop is authorized, but its native-control backend is not. Check the installed app’s signature and backend permissions; computer control remains blocked.",
permissionRequestFailed: "Could not request Accessibility or open System Settings. Try again. ({{code}})",
permission: {
granted: "Accessibility granted",
diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.ts
index 3f13ecabe..10312a8b8 100644
--- a/packages/i18n/src/locales/es/index.ts
+++ b/packages/i18n/src/locales/es/index.ts
@@ -2922,6 +2922,7 @@ sklm: {
requestPermission: "Solicitar permiso de accesibilidad",
requestingPermission: "Solicitando accesibilidad…",
permissionPending: "Activa la accesibilidad para PI-Desktop en Ajustes del Sistema y vuelve aquí para actualizar el estado.",
+ backendPermissionMissing: "PI-Desktop está autorizado, pero su backend de control nativo no. Revisa la firma de la aplicación y los permisos del backend; el control sigue bloqueado.",
permissionRequestFailed: "No se pudo solicitar accesibilidad o abrir Ajustes del Sistema. Inténtalo de nuevo. ({{code}})",
permission: {
granted: "Accessibility granted",
diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.ts
index 5194a7fc3..6220363b2 100644
--- a/packages/i18n/src/locales/fr/index.ts
+++ b/packages/i18n/src/locales/fr/index.ts
@@ -2922,6 +2922,7 @@ sklm: {
requestPermission: "Demander l’autorisation d’accessibilité",
requestingPermission: "Demande d’accessibilité en cours…",
permissionPending: "Activez l’accessibilité pour PI-Desktop dans Réglages Système, puis revenez ici pour actualiser l’état.",
+ backendPermissionMissing: "PI-Desktop est autorisé, mais pas son moteur de contrôle natif. Vérifiez la signature de l’application et les autorisations du moteur ; le contrôle reste bloqué.",
permissionRequestFailed: "Impossible de demander l’accessibilité ou d’ouvrir Réglages Système. Réessayez. ({{code}})",
permission: {
granted: "Accessibility granted",
diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.ts
index ec1a0ae23..50740dd8e 100644
--- a/packages/i18n/src/locales/ko/index.ts
+++ b/packages/i18n/src/locales/ko/index.ts
@@ -2961,6 +2961,7 @@ importConfirm: "가져온 확장은 에이전트 프로세스 안에서 에이
requestPermission: "손쉬운 사용 권한 요청",
requestingPermission: "손쉬운 사용 권한 요청 중…",
permissionPending: "시스템 설정에서 PI-Desktop의 손쉬운 사용 권한을 켠 다음 돌아오면 상태가 갱신됩니다.",
+ backendPermissionMissing: "PI-Desktop은 승인되었지만 기본 제어 백엔드에는 권한이 없습니다. 설치된 앱의 서명과 백엔드 권한을 확인하세요. 컴퓨터 제어는 계속 차단됩니다.",
permissionRequestFailed: "손쉬운 사용 권한을 요청하거나 시스템 설정을 열 수 없습니다. 다시 시도하세요. ({{code}})",
permission: {
granted: "Accessibility granted",
diff --git a/packages/i18n/src/locales/pt-BR/index.ts b/packages/i18n/src/locales/pt-BR/index.ts
index a1303207e..9e943c10d 100644
--- a/packages/i18n/src/locales/pt-BR/index.ts
+++ b/packages/i18n/src/locales/pt-BR/index.ts
@@ -2892,6 +2892,7 @@ export const ptBR = {
requestPermission: "Solicitar permissão de acessibilidade",
requestingPermission: "Solicitando acessibilidade…",
permissionPending: "Ative a acessibilidade para o PI-Desktop nos Ajustes do Sistema e volte aqui para atualizar o status.",
+ backendPermissionMissing: "O PI-Desktop está autorizado, mas seu backend de controle nativo não. Verifique a assinatura do aplicativo e as permissões do backend; o controle continua bloqueado.",
permissionRequestFailed: "Não foi possível solicitar acessibilidade ou abrir os Ajustes do Sistema. Tente novamente. ({{code}})",
permission: {
granted: "Accessibility granted",
diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.ts
index 7824e7071..fd119d044 100644
--- a/packages/i18n/src/locales/tr/index.ts
+++ b/packages/i18n/src/locales/tr/index.ts
@@ -2954,6 +2954,7 @@ importConfirm: "İçe aktarılan uzantılar ajan sürecinde, ajanın kendi araç
requestPermission: "Erişilebilirlik izni iste",
requestingPermission: "Erişilebilirlik izni isteniyor…",
permissionPending: "Sistem Ayarları’nda PI-Desktop için erişilebilirliği etkinleştirin, ardından durumu yenilemek için buraya dönün.",
+ backendPermissionMissing: "PI-Desktop yetkilendirildi ancak yerel kontrol arka ucu yetkilendirilmedi. Uygulama imzasını ve arka uç izinlerini kontrol edin; bilgisayar kontrolü engellenmeye devam eder.",
permissionRequestFailed: "Erişilebilirlik izni istenemedi veya Sistem Ayarları açılamadı. Tekrar deneyin. ({{code}})",
permission: {
granted: "Accessibility granted",
diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.ts
index c2772df8f..df24f3ca3 100644
--- a/packages/i18n/src/locales/zh-CN/index.ts
+++ b/packages/i18n/src/locales/zh-CN/index.ts
@@ -2919,6 +2919,7 @@ sklm: {
requestPermission: "申请辅助功能权限",
requestingPermission: "正在申请辅助功能权限……",
permissionPending: "请在系统设置中开启 PI-Desktop 的辅助功能权限,返回此处后会自动刷新状态。",
+ backendPermissionMissing: "PI-Desktop 已获授权,但原生操作后端尚未获得权限。请检查安装版本的签名与后端权限;电脑操作仍被阻止。",
permissionRequestFailed: "申请辅助功能权限或打开系统设置失败,请重试。({{code}})",
permission: {
granted: "已获得辅助功能权限",
diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.ts
index 65430f2db..1716f2021 100644
--- a/packages/i18n/src/locales/zh-TW/index.ts
+++ b/packages/i18n/src/locales/zh-TW/index.ts
@@ -2917,6 +2917,7 @@ sklm: {
requestPermission: "申請輔助使用權限",
requestingPermission: "正在申請輔助使用權限……",
permissionPending: "請在系統設定中開啟 PI-Desktop 的輔助使用權限,返回此處後會自動更新狀態。",
+ backendPermissionMissing: "PI-Desktop 已獲授權,但原生操作後端尚未取得權限。請檢查安裝版本的簽章與後端權限;電腦操作仍被阻擋。",
permissionRequestFailed: "申請輔助使用權限或開啟系統設定失敗,請重試。({{code}})",
permission: {
granted: "已取得輔助使用權限",
diff --git a/packages/shared/src/computer-use.test.ts b/packages/shared/src/computer-use.test.ts
index 2770cd0e8..d3e0f71b8 100644
--- a/packages/shared/src/computer-use.test.ts
+++ b/packages/shared/src/computer-use.test.ts
@@ -91,6 +91,8 @@ it("OS permission requests are offered only for missing macOS Accessibility", ()
expect(needsAccessibilityRequest({ ...capabilities, accessibility: "denied" })).toBe(true);
expect(needsAccessibilityRequest({ ...capabilities, accessibility: "granted" })).toBe(false);
expect(needsAccessibilityRequest({ ...capabilities, accessibility: "unsupported" })).toBe(false);
+ expect(needsAccessibilityRequest({ ...capabilities, applicationAccessibility: "granted" })).toBe(false);
+ expect(needsAccessibilityRequest({ ...capabilities, accessibility: "granted", applicationAccessibility: "not-requested" })).toBe(true);
for (const platform of ["linux", "win32", "other"] as const) {
expect(needsAccessibilityRequest({ ...capabilities, platform, backend: "unsupported" })).toBe(false);
}
diff --git a/packages/shared/src/computer-use.ts b/packages/shared/src/computer-use.ts
index 2d4dcdf3c..2d1ae11b4 100644
--- a/packages/shared/src/computer-use.ts
+++ b/packages/shared/src/computer-use.ts
@@ -175,6 +175,8 @@ export type ComputerCapabilities = {
fidelity: ComputerFidelity;
/** Native inspection/synthesis permission (macOS Accessibility, AT-SPI bus). */
accessibility: ComputerPermissionState;
+ /** Desktop app's own TCC grant, for display only; never authorizes native input. */
+ applicationAccessibility?: ComputerPermissionState;
/** Window capture permission, as far as the host can tell before trying. */
capture: ComputerPermissionState;
/** `wayland` refuses input by contract; `x11` is best effort. */
@@ -185,9 +187,10 @@ export type ComputerCapabilities = {
/** Only the macOS backend currently implements an explicit OS trust request. */
export function needsAccessibilityRequest(capabilities: ComputerCapabilities): boolean {
+ const permission = capabilities.applicationAccessibility ?? capabilities.accessibility;
return capabilities.platform === "darwin"
&& capabilities.backend === "macos-ax"
- && (capabilities.accessibility === "not-requested" || capabilities.accessibility === "denied");
+ && (permission === "not-requested" || permission === "denied");
}
export type ComputerGrantView = {