YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix(onboarding): keep accessibility polling silent until the user requests the grant
Ezra Ellette66a698524237
diff --git a/apps/screenpipe-app-tauri/components/onboarding/permissions-step.test.tsx b/apps/screenpipe-app-tauri/components/onboarding/permissions-step.test.tsxindex f5f724873..916efcecd 100644--- a/apps/screenpipe-app-tauri/components/onboarding/permissions-step.test.tsx+++ b/apps/screenpipe-app-tauri/components/onboarding/permissions-step.test.tsx@@ -8,6 +8,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";const mocks = vi.hoisted(() => ({checkMicrophonePermission: vi.fn(async () => "denied"),checkAccessibilityPermissionCmd: vi.fn(async () => "denied"),+ checkAccessibilityPermissionLiveCmd: vi.fn(async () => "denied"),checkScreenRecordingPermission: vi.fn(async () => "denied"),getBrowsersAutomationStatus: vi.fn(async (): Promise<{ name: string; status: string; running: boolean }[]> =>@@ -28,6 +29,8 @@ vi.mock("@/lib/utils/tauri", () => ({commands: {checkMicrophonePermission: mocks.checkMicrophonePermission,checkAccessibilityPermissionCmd: mocks.checkAccessibilityPermissionCmd,+ checkAccessibilityPermissionLiveCmd:+ mocks.checkAccessibilityPermissionLiveCmd,checkScreenRecordingPermission: mocks.checkScreenRecordingPermission,getBrowsersAutomationStatus: mocks.getBrowsersAutomationStatus,requestPermission: mocks.requestPermission,@@ -65,6 +68,7 @@ describe("onboarding permission wheel", () => {vi.clearAllMocks();mocks.checkMicrophonePermission.mockResolvedValue("denied");mocks.checkAccessibilityPermissionCmd.mockResolvedValue("denied");+ mocks.checkAccessibilityPermissionLiveCmd.mockResolvedValue("denied");mocks.checkScreenRecordingPermission.mockResolvedValue("denied");mocks.getBrowsersAutomationStatus.mockResolvedValue([]);});@@ -153,6 +157,26 @@ describe("onboarding permission wheel", () => {);});+ it("polls accessibility silently until requested, then live", async () => {+ mocks.checkMicrophonePermission.mockResolvedValue("granted");++ render(<PermissionsStep handleNextSlide={vi.fn()} />);++ // Before the user asks for it, only the silent (non-prompting) check runs —+ // the live tccd probe would enroll the app / surface the prompt on mount.+ await waitFor(() => expect(accessibilityRow()).toBeEnabled());+ expect(mocks.checkAccessibilityPermissionCmd).toHaveBeenCalled();+ expect(mocks.checkAccessibilityPermissionLiveCmd).not.toHaveBeenCalled();++ fireEvent.click(accessibilityRow());++ // Once requested, the row switches to the live probe so a grant made in+ // Settings is seen without an app relaunch.+ await waitFor(() =>+ expect(mocks.checkAccessibilityPermissionLiveCmd).toHaveBeenCalled()+ );+ });+it("only requests screen recording after its grant button is clicked", async () => {mocks.checkMicrophonePermission.mockResolvedValue("granted");mocks.checkAccessibilityPermissionCmd.mockResolvedValue("granted");diff --git a/apps/screenpipe-app-tauri/components/onboarding/permissions-step.tsx b/apps/screenpipe-app-tauri/components/onboarding/permissions-step.tsxindex 97790d4a5..7d64ae6ee 100644--- a/apps/screenpipe-app-tauri/components/onboarding/permissions-step.tsx+++ b/apps/screenpipe-app-tauri/components/onboarding/permissions-step.tsx@@ -154,6 +154,11 @@ export default function PermissionsStep({const statusesRef = useRef<Record<string, boolean>>({});const pollInFlightRef = useRef(false);const pollAgainRef = useRef(false);+ // Accessibility is polled silently (AXIsProcessTrusted) until the user+ // actively requests it. Only then do we switch to the live tccd probe,+ // which enrolls the app in the Accessibility list / can surface the system+ // prompt — acceptable once the user is granting, not on step mount.+ const accessibilityRequestedRef = useRef(false);// Wheel order: the user is walked through these strictly in sequence.const permissions: PermissionDef[] = [@@ -203,8 +208,16 @@ export default function PermissionsStep({icon: <Keyboard className="w-3.5 h-3.5" strokeWidth={1.5} />,title: "Read on-screen text",subtitle: "Lets Screenpipe understand app content without OCR",- check: () => commands.checkAccessibilityPermissionCmd(),- request: () => requestPermissionWithFlow("accessibility"),+ // Silent poll until the user asks for it, then the live tccd probe so a+ // grant made in Settings is seen without an app relaunch.+ check: () =>+ accessibilityRequestedRef.current+ ? commands.checkAccessibilityPermissionLiveCmd()+ : commands.checkAccessibilityPermissionCmd(),+ request: () => {+ accessibilityRequestedRef.current = true;+ return requestPermissionWithFlow("accessibility");+ },macOnly: true,},{diff --git a/apps/screenpipe-app-tauri/lib/utils/tauri.ts b/apps/screenpipe-app-tauri/lib/utils/tauri.tsindex 7885475ba..958135fd4 100644--- a/apps/screenpipe-app-tauri/lib/utils/tauri.ts+++ b/apps/screenpipe-app-tauri/lib/utils/tauri.ts@@ -166,12 +166,26 @@ async chatgptOauthStatus() : Promise<Result<ChatGptOAuthStatus, string>> {}},/**- * Check only accessibility permission- * Use this for polling to check if user has granted accessibility permission+ * Check only accessibility permission (silent, side-effect free).+ * Use this for passive polling before the user has chosen to grant — it never+ * enrolls the app in the Accessibility list or surfaces the system prompt.+ * It will not see a grant made *after* the process started (AXIsProcessTrusted+ * caches stale-denied); once the user actively requests the permission, switch+ * to `check_accessibility_permission_live_cmd` to catch that transition.*/async checkAccessibilityPermissionCmd() : Promise<OSPermissionStatus> {return await TAURI_INVOKE("check_accessibility_permission_cmd");},+/**+ * Live accessibility check for polling *after* the user has actively started+ * the grant flow. Probes tccd via an active event tap so a grant made while+ * the app is running is seen without a relaunch. The probe enrolls the app in+ * the Accessibility list (and can surface the system prompt), which is+ * expected once the user is being asked — do NOT use it for passive polling.+ */+async checkAccessibilityPermissionLiveCmd() : Promise<OSPermissionStatus> {+ return await TAURI_INVOKE("check_accessibility_permission_live_cmd");+},/*** Check if Automation permission for Arc is already granted.* In production (.app bundle): uses direct FFI check (correct identity, no Terminal).diff --git a/apps/screenpipe-app-tauri/src-tauri/src/permissions.rs b/apps/screenpipe-app-tauri/src-tauri/src/permissions.rsindex 819062a26..412c0c8e5 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/permissions.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/permissions.rs@@ -401,14 +401,29 @@ pub fn check_screen_recording_permission() -> OSPermissionStatus {}}-/// Check only accessibility permission-/// Use this for polling to check if user has granted accessibility permission+/// Check only accessibility permission (silent, side-effect free).+/// Use this for passive polling before the user has chosen to grant — it never+/// enrolls the app in the Accessibility list or surfaces the system prompt.+/// It will not see a grant made *after* the process started (AXIsProcessTrusted+/// caches stale-denied); once the user actively requests the permission, switch+/// to `check_accessibility_permission_live_cmd` to catch that transition.#[tauri::command(async)]#[specta::specta]pub fn check_accessibility_permission_cmd() -> OSPermissionStatus {core_to_os_status(screenpipe_core::permissions::check_accessibility())}+/// Live accessibility check for polling *after* the user has actively started+/// the grant flow. Probes tccd via an active event tap so a grant made while+/// the app is running is seen without a relaunch. The probe enrolls the app in+/// the Accessibility list (and can surface the system prompt), which is+/// expected once the user is being asked — do NOT use it for passive polling.+#[tauri::command(async)]+#[specta::specta]+pub fn check_accessibility_permission_live_cmd() -> OSPermissionStatus {+ core_to_os_status(screenpipe_core::permissions::check_accessibility_live())+}+/// Check Input Monitoring permission (macOS only).////// Input Monitoring is a TCC category separate from Accessibility. Withoutdiff --git a/crates/screenpipe-core/src/permissions.rs b/crates/screenpipe-core/src/permissions.rsindex caa76cbc0..c5df63ca8 100644--- a/crates/screenpipe-core/src/permissions.rs+++ b/crates/screenpipe-core/src/permissions.rs@@ -247,24 +247,55 @@ pub fn check_screen_recording_tauri() -> PermissionStatus {PermissionStatus::NotNeeded}+/// Silent, side-effect-free accessibility check.+///+/// Uses only `AXIsProcessTrusted()`, which never prompts and never enrolls the+/// app in the Accessibility list. Safe for launch-time capability gates and+/// passive snapshots. On a cold process this returns the true current value;+/// its only weakness is not seeing a grant made *after* the process started+/// (the in-process cache never refreshes). Use [`check_accessibility_live`]+/// where detecting an in-flight grant matters.#[cfg(target_os = "macos")]pub fn check_accessibility() -> PermissionStatus {#[link(name = "ApplicationServices", kind = "framework")]extern "C" {fn AXIsProcessTrusted() -> bool;}- // AXIsProcessTrusted caches its answer in-process (macOS 13+), so a grant- // made while the app is running keeps reading as denied until relaunch.- // The event-tap probe asks tccd live; keep AXIsProcessTrusted as a cheap- // first-line check and to cover the tap probe's own false negatives- // (LSBackgroundOnly helpers, dev-build signature churn).- if unsafe { AXIsProcessTrusted() } || macos_accessibility::event_tap_probe() {+ if unsafe { AXIsProcessTrusted() } {+ PermissionStatus::Granted+ } else {+ PermissionStatus::Denied+ }+}++/// Live accessibility check for the onboarding/settings poll loop.+///+/// `AXIsProcessTrusted()` caches its answer in-process (macOS 13+), so a grant+/// made while the app is running keeps reading as denied until relaunch. The+/// event-tap probe asks tccd at call time and catches that transition;+/// `AXIsProcessTrusted()` stays as the cheap first-line check and covers the+/// probe's own false negatives (LSBackgroundOnly helpers, dev-build signature+/// churn).+///+/// NOT side-effect-free: creating an active event tap while denied enrolls the+/// app in the Accessibility pane and can surface the system prompt. Only call+/// this from a context where the user is actively being asked for the+/// permission (the onboarding/settings grant flow) — never from a passive+/// launch-time gate.+#[cfg(target_os = "macos")]+pub fn check_accessibility_live() -> PermissionStatus {+ if check_accessibility().is_granted() || macos_accessibility::event_tap_probe() {PermissionStatus::Granted} else {PermissionStatus::Denied}}+#[cfg(not(target_os = "macos"))]+pub fn check_accessibility_live() -> PermissionStatus {+ PermissionStatus::NotNeeded+}+#[cfg(target_os = "macos")]mod macos_accessibility {use std::ffi::c_void;