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

feat: add open permission button for macos

Louis Beaumont933be7cd45c8
diff --git a/examples/apps/screenpipe-app-tauri/components/screenpipe-status.tsx b/examples/apps/screenpipe-app-tauri/components/screenpipe-status.tsx
index 75e23fc04..ea048b667 100644
--- a/examples/apps/screenpipe-app-tauri/components/screenpipe-status.tsx
+++ b/examples/apps/screenpipe-app-tauri/components/screenpipe-status.tsx
@@ -26,6 +26,7 @@ import { Separator } from "./ui/separator";
import { Card, CardContent, CardFooter } from "./ui/card";
import { useHealthCheck } from "@/lib/hooks/use-health-check";
import { DevSettings } from "./dev-dialog";
+import { Lock } from "lucide-react";
const getDebuggingCommands = (os: string | null) => {
let cliInstructions = "";
@@ -317,18 +318,44 @@ const DevModeSettings = () => {
);
};
-interface HealthCheckResponse {
- status: string;
- last_frame_timestamp: string | null;
- last_audio_timestamp: string | null;
- frame_status: string;
- audio_status: string;
- message: string;
-}
-
const HealthStatus = ({ className }: { className?: string }) => {
const { health } = useHealthCheck();
const [isDialogOpen, setIsDialogOpen] = useState(false);
+ const [isMac, setIsMac] = useState(false);
+
+ useEffect(() => {
+ setIsMac(platform() === "macos");
+ }, []);
+
+ const handleResetScreenPermissions = async () => {
+ const toastId = toast({
+ title: "opening permissions",
+ description: "please wait...",
+ duration: Infinity,
+ });
+
+ try {
+ await invoke("open_screen_capture_preferences");
+ await new Promise((resolve) => setTimeout(resolve, 2000));
+
+ toastId.update({
+ id: toastId.id,
+ title: "permissions reset",
+ description:
+ "screen capture permissions have been reset. please restart the app.",
+ duration: 5000,
+ });
+ } catch (error) {
+ console.error("failed to reset screen permissions:", error);
+ toastId.update({
+ id: toastId.id,
+ title: "error",
+ description: "failed to reset screen permissions.",
+ variant: "destructive",
+ duration: 3000,
+ });
+ }
+ };
const getStatusColor = (status: string) => {
switch (status) {
@@ -395,8 +422,8 @@ const HealthStatus = ({ className }: { className?: string }) => {
<p className="text-xs mb-1">
last audio: {formatTimestamp(health.last_audio_timestamp)}
</p>
- <div className="text-xs mt-2">
- <p className="font-bold mb-1">troubleshooting Instructions:</p>
+ <div className="text-xs mt-2 relative">
+ <p className="font-bold mb-1">troubleshooting instructions:</p>
<MarkdownWithExternalLinks className="prose prose-sm">
{`if you're experiencing issues, please try the following steps:
1. restart screenpipe
@@ -404,6 +431,28 @@ const HealthStatus = ({ className }: { className?: string }) => {
3. if the problem persists, please contact support at [[email protected]](mailto:[email protected]) or @louis030195 on Discord, X, or LinkedIn
4. last, here are some [FAQ](https://github.com/mediar-ai/screenpipe/blob/main/content/docs/NOTES.md) with visuals to help you troubleshoot`}
</MarkdownWithExternalLinks>
+ {isMac && (
+ <div className="absolute top-[6.5em] right-0">
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={handleResetScreenPermissions}
+ className="flex-shrink-0"
+ >
+ <Lock className="h-4 w-4 mr-2" />
+ open permissions
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <p>open screen capture permissions</p>
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ </div>
+ )}
</div>
<Separator className="my-4" />
<DevModeSettings />
diff --git a/examples/apps/screenpipe-app-tauri/src-tauri/src/commands.rs b/examples/apps/screenpipe-app-tauri/src-tauri/src/commands.rs
new file mode 100644
index 000000000..f367b03f9
--- /dev/null
+++ b/examples/apps/screenpipe-app-tauri/src-tauri/src/commands.rs
@@ -0,0 +1,45 @@
+
+// #[tauri::command]
+// pub fn has_screen_capture_access() -> bool {
+// scap::has_permission()
+// }
+
+#[tauri::command]
+pub fn open_screen_capture_preferences() {
+ #[cfg(target_os = "macos")]
+ std::process::Command::new("open")
+ .arg("x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture")
+ .spawn()
+ .expect("failed to open system preferences");
+}
+
+#[tauri::command]
+pub fn open_mic_preferences() {
+ #[cfg(target_os = "macos")]
+ std::process::Command::new("open")
+ .arg("x-apple.systempreferences:com.apple.preference.security?Privacy_Microphone")
+ .spawn()
+ .expect("failed to open system preferences");
+}
+
+#[tauri::command]
+pub fn reset_screen_permissions() {
+ #[cfg(target_os = "macos")]
+ std::process::Command::new("tccutil")
+ .arg("reset")
+ .arg("ScreenCapture")
+ .arg("so.cap.desktop")
+ .spawn()
+ .expect("failed to reset screen permissions");
+}
+
+#[tauri::command]
+pub fn reset_microphone_permissions() {
+ #[cfg(target_os = "macos")]
+ std::process::Command::new("tccutil")
+ .arg("reset")
+ .arg("Microphone")
+ .arg("so.cap.desktop")
+ .spawn()
+ .expect("failed to reset microphone permissions");
+}
diff --git a/examples/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/examples/apps/screenpipe-app-tauri/src-tauri/src/main.rs
index 919686fb1..7a6b5ba5c 100755
--- a/examples/apps/screenpipe-app-tauri/src-tauri/src/main.rs
+++ b/examples/apps/screenpipe-app-tauri/src-tauri/src/main.rs
@@ -35,6 +35,10 @@ mod analytics;
use crate::analytics::start_analytics;
+mod commands;
+
+pub use commands::reset_screen_permissions;
+pub use commands::open_screen_capture_preferences;
struct SidecarState(Arc<Mutex<Option<CommandChild>>>);
#[tauri::command]
@@ -351,6 +355,8 @@ async fn main() {
.invoke_handler(tauri::generate_handler![
spawn_screenpipe,
kill_all_sreenpipes,
+ reset_screen_permissions,
+ open_screen_capture_preferences,
])
.setup(|app| {
// Logging setup