Skip to content

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

fix: gracefully handle missing macOS 26 SDK in apple-intelligence build

Louis Beaumont2206f16805b2
diff --git a/apps/screenpipe-app-tauri/app/permission-recovery/page.tsx b/apps/screenpipe-app-tauri/app/permission-recovery/page.tsx
index 83ec4897e..f2e121dd8 100644
--- a/apps/screenpipe-app-tauri/app/permission-recovery/page.tsx
+++ b/apps/screenpipe-app-tauri/app/permission-recovery/page.tsx
@@ -9,16 +9,17 @@ import { usePlatform } from "@/lib/hooks/use-platform";
import posthog from "posthog-js";
-interface PermissionRowProps {
+interface PermissionRowFullProps {
icon: React.ReactNode;
label: string;
description: string;
status: "granted" | "denied" | "checking";
- onFix: () => void;
- isAnyFixing: boolean;
+ onResetAndFix: () => void;
+ onOpenSettings: () => void;
+ isFixing: boolean;
}
-function PermissionRow({ icon, label, description, status, onFix, isAnyFixing }: Omit<PermissionRowProps, 'onReset' | 'isFixing'>) {
+function PermissionRow({ icon, label, description, status, onResetAndFix, onOpenSettings, isFixing }: PermissionRowFullProps) {
return (
<div className="flex items-center justify-between p-4 border border-border rounded-lg bg-card">
<div className="flex items-center space-x-3">
@@ -37,16 +38,32 @@ function PermissionRow({ icon, label, description, status, onFix, isAnyFixing }:
<span className="font-mono text-xs">ok</span>
</div>
) : (
- <Button
- variant="outline"
- size="sm"
- onClick={onFix}
- disabled={isAnyFixing}
- className="font-mono text-xs"
- >
- <ExternalLink className="w-3 h-3 mr-1" />
- open settings
- </Button>
+ <>
+ <Button
+ variant="default"
+ size="sm"
+ onClick={onResetAndFix}
+ disabled={isFixing}
+ className="font-mono text-xs"
+ >
+ {isFixing ? (
+ <RefreshCw className="w-3 h-3 mr-1 animate-spin" />
+ ) : (
+ <RefreshCw className="w-3 h-3 mr-1" />
+ )}
+ reset & fix
+ </Button>
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={onOpenSettings}
+ disabled={isFixing}
+ className="font-mono text-xs"
+ >
+ <ExternalLink className="w-3 h-3 mr-1" />
+ open settings
+ </Button>
+ </>
)}
</div>
</div>
@@ -55,6 +72,7 @@ function PermissionRow({ icon, label, description, status, onFix, isAnyFixing }:
export default function PermissionRecoveryPage() {
const [permissions, setPermissions] = useState<Record<string, string> | null>(null);
+ const [fixingPermission, setFixingPermission] = useState<string | null>(null);
const { isMac: isMacOS } = usePlatform();
@@ -113,6 +131,27 @@ export default function PermissionRecoveryPage() {
}
}, [permissions]);
+ // Reset TCC entry and re-request permission (shows native dialog if possible)
+ const resetAndFix = async (permission: OSPermission) => {
+ posthog.capture("permission_recovery_reset_and_fix", { permission });
+ setFixingPermission(permission);
+ try {
+ const result = await commands.resetAndRequestPermission(permission);
+ if (result.status === "error") {
+ console.error("Reset and request failed:", result.error);
+ // Fallback: open settings directly
+ await commands.openPermissionSettings(permission);
+ }
+ } catch (error) {
+ console.error("Failed to reset and request permission:", error);
+ // Fallback: open settings directly
+ await commands.openPermissionSettings(permission);
+ } finally {
+ // Clear fixing state after a short delay to let the dialog appear
+ setTimeout(() => setFixingPermission(null), 2000);
+ }
+ };
+
// Open system settings for a permission
const openSettings = async (permission: OSPermission) => {
posthog.capture("permission_recovery_manual_fix", { permission });
@@ -203,8 +242,9 @@ export default function PermissionRecoveryPage() {
label="screen recording"
description="capture what's on screen"
status={screenStatus}
- onFix={() => openSettings("screenRecording")}
- isAnyFixing={false}
+ onResetAndFix={() => resetAndFix("screenRecording")}
+ onOpenSettings={() => openSettings("screenRecording")}
+ isFixing={fixingPermission === "screenRecording"}
/>
<PermissionRow
@@ -212,8 +252,9 @@ export default function PermissionRecoveryPage() {
label="microphone"
description="transcribe speech"
status={micStatus}
- onFix={() => openSettings("microphone")}
- isAnyFixing={false}
+ onResetAndFix={() => resetAndFix("microphone")}
+ onOpenSettings={() => openSettings("microphone")}
+ isFixing={fixingPermission === "microphone"}
/>
{isMacOS && (
@@ -222,15 +263,18 @@ export default function PermissionRecoveryPage() {
label="accessibility"
description="keyboard shortcuts"
status={accessibilityStatus}
- onFix={() => openSettings("accessibility")}
- isAnyFixing={false}
+ onResetAndFix={() => resetAndFix("accessibility")}
+ onOpenSettings={() => openSettings("accessibility")}
+ isFixing={fixingPermission === "accessibility"}
/>
)}
</div>
<div className="text-center space-y-3">
<p className="font-mono text-xs text-muted-foreground">
- click &quot;open settings&quot; to toggle the permission on in system settings.
+ click &quot;reset &amp; fix&quot; to trigger the permission dialog.
+ <br />
+ if that doesn&apos;t work, use &quot;open settings&quot; to toggle it manually.
<br />
this window will close automatically once permissions are fixed.
</p>
diff --git a/apps/screenpipe-app-tauri/components/status/permission-banner.tsx b/apps/screenpipe-app-tauri/components/status/permission-banner.tsx
index f86e78cc5..c5b9550d2 100644
--- a/apps/screenpipe-app-tauri/components/status/permission-banner.tsx
+++ b/apps/screenpipe-app-tauri/components/status/permission-banner.tsx
@@ -83,17 +83,18 @@ export function PermissionBanner() {
size="sm"
className="h-8 px-4 text-sm font-medium"
onClick={async () => {
- // Open System Settings directly for the first missing permission.
- // macOS can't programmatically grant permissions — user must toggle in Settings.
+ // Try requestPermission first — this shows the native macOS dialog
+ // (e.g. mic prompt, accessibility prompt). If the permission was already
+ // denied, it falls back to opening System Settings internally.
try {
- if (!permissions.screenOk) await commands.openPermissionSettings("screenRecording");
- else if (!permissions.micOk) await commands.openPermissionSettings("microphone");
- else if (!permissions.accessibilityOk) await commands.openPermissionSettings("accessibility");
- } catch {
- // fallback
if (!permissions.screenOk) await commands.requestPermission("screenRecording");
else if (!permissions.micOk) await commands.requestPermission("microphone");
else if (!permissions.accessibilityOk) await commands.requestPermission("accessibility");
+ } catch {
+ // fallback to opening settings directly
+ if (!permissions.screenOk) await commands.openPermissionSettings("screenRecording");
+ else if (!permissions.micOk) await commands.openPermissionSettings("microphone");
+ else if (!permissions.accessibilityOk) await commands.openPermissionSettings("accessibility");
}
}}
>
diff --git a/apps/screenpipe-app-tauri/lib/utils/tauri.ts b/apps/screenpipe-app-tauri/lib/utils/tauri.ts
index 7a92e9b2e..8b9e1b621 100644
--- a/apps/screenpipe-app-tauri/lib/utils/tauri.ts
+++ b/apps/screenpipe-app-tauri/lib/utils/tauri.ts
@@ -28,6 +28,19 @@ async checkMicrophonePermission() : Promise<OSPermissionStatus> {
async checkAccessibilityPermissionCmd() : Promise<OSPermissionStatus> {
return await TAURI_INVOKE("check_accessibility_permission_cmd");
},
+/**
+ * Reset a permission using tccutil and re-request it
+ * This removes the app from the TCC database and triggers a fresh permission request
+ */
+async resetAndRequestPermission(permission: OSPermission) : Promise<Result<null, string>> {
+ try {
+ await TAURI_INVOKE("reset_and_request_permission", { permission });
+ return { status: "ok", data: null };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
async getEnv(name: string) : Promise<string> {
return await TAURI_INVOKE("get_env", { name });
},
diff --git a/crates/screenpipe-apple-intelligence/build.rs b/crates/screenpipe-apple-intelligence/build.rs
index 4922198ba..55fee6a69 100644
--- a/crates/screenpipe-apple-intelligence/build.rs
+++ b/crates/screenpipe-apple-intelligence/build.rs
@@ -24,6 +24,95 @@ fn main() {
.trim()
.to_string();
+ // Check if the SDK supports macOS 26+ (FoundationModels.framework)
+ // by looking at the SDK version. SDKs < 26 don't have FoundationModels.
+ let sdk_settings_path = format!("{}/SDKSettings.json", sdk_path);
+ let has_macos26_sdk = if let Ok(contents) = std::fs::read_to_string(&sdk_settings_path) {
+ // Look for "Version" : "26.x" or higher
+ contents.contains("\"26.") || contents.contains("\"27.") || contents.contains("\"28.")
+ } else {
+ // Fallback: check if FoundationModels.framework exists in the SDK
+ std::path::Path::new(&format!(
+ "{}/System/Library/Frameworks/FoundationModels.framework",
+ sdk_path
+ ))
+ .exists()
+ };
+
+ if !has_macos26_sdk {
+ println!("cargo:warning=macOS SDK does not include FoundationModels.framework (need macOS 26+ SDK), building stub");
+ // Create a minimal stub library so linking doesn't fail.
+ // All functions return error codes indicating unavailability.
+ let stub_src = out_dir.join("stub.c");
+ std::fs::write(
+ &stub_src,
+ r#"// Stub: FoundationModels not available on this SDK
+#include <stdlib.h>
+#include <string.h>
+
+static char* make_string(const char* s) {
+ char* p = malloc(strlen(s) + 1);
+ if (p) strcpy(p, s);
+ return p;
+}
+
+int fm_check_availability(char** out_reason) {
+ if (out_reason) *out_reason = make_string("FoundationModels SDK not available at build time");
+ return 4; // unknown/unavailable
+}
+
+void fm_free_string(char* ptr) { if (ptr) free(ptr); }
+
+int fm_generate_text(const char* inst, const char* prompt, char** out_text, char** out_error,
+ double* time_ms, unsigned long long* mem_before, unsigned long long* mem_after) {
+ if (out_error) *out_error = make_string("Apple Intelligence not available (built without macOS 26 SDK)");
+ if (out_text) *out_text = 0;
+ if (time_ms) *time_ms = 0;
+ if (mem_before) *mem_before = 0;
+ if (mem_after) *mem_after = 0;
+ return -1;
+}
+
+int fm_generate_json(const char* inst, const char* prompt, const char* schema,
+ char** out_text, char** out_error,
+ double* time_ms, unsigned long long* mem_before, unsigned long long* mem_after) {
+ if (out_error) *out_error = make_string("Apple Intelligence not available (built without macOS 26 SDK)");
+ if (out_text) *out_text = 0;
+ if (time_ms) *time_ms = 0;
+ if (mem_before) *mem_before = 0;
+ if (mem_after) *mem_after = 0;
+ return -1;
+}
+
+int fm_prewarm(void) { return -1; }
+
+char* fm_supported_languages(void) { return make_string("[]"); }
+"#,
+ )
+ .expect("failed to write stub");
+
+ let status = Command::new("cc")
+ .args(["-c", "-o"])
+ .arg(out_dir.join("stub.o").to_str().unwrap())
+ .arg(stub_src.to_str().unwrap())
+ .status()
+ .expect("failed to compile stub");
+ assert!(status.success(), "stub compilation failed");
+
+ let status = Command::new("ar")
+ .args(["rcs"])
+ .arg(&lib_path)
+ .arg(out_dir.join("stub.o").to_str().unwrap())
+ .status()
+ .expect("failed to create stub archive");
+ assert!(status.success(), "stub archive failed");
+
+ println!("cargo:rustc-link-search=native={}", out_dir.display());
+ println!("cargo:rustc-link-lib=static=foundation_models_bridge");
+ println!("cargo:rerun-if-changed=swift/bridge.swift");
+ return;
+ }
+
// Compile Swift to static library
let status = Command::new("swiftc")
.args([