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: permission pop-up

shaik-zeeshandc5d207df4eb
diff --git a/openrewind/app/page.tsx b/openrewind/app/page.tsx
index 98866efce..a6d1401b3 100644
--- a/openrewind/app/page.tsx
+++ b/openrewind/app/page.tsx
@@ -210,7 +210,7 @@ export default function Home() {
<Button
onClick={handleRestartServer}
disabled={isRestarting}
- className="flex items-center gap-2 bg-muted"
+ className="flex items-center gap-2"
>
<RefreshCw className={`h-4 w-4 ${isRestarting ? 'animate-spin' : ''}`} />
{isRestarting ? "Starting..." : "Start Server"}
diff --git a/openrewind/components/onboarding/status.tsx b/openrewind/components/onboarding/status.tsx
index 584580955..3e2f45d48 100644
--- a/openrewind/components/onboarding/status.tsx
+++ b/openrewind/components/onboarding/status.tsx
@@ -21,6 +21,7 @@ import { usePlatform } from "@/lib/hooks/use-platform";
import { pipe } from "@screenpipe/browser";
import { VisionEvent } from "@screenpipe/browser";
import Image from "next/image";
+import { commands, OSPermissionsCheck } from "@/lib/utils/tauri";
interface OnboardingStatusProps {
className?: string;
@@ -36,7 +37,7 @@ const OnboardingStatus: React.FC<OnboardingStatusProps> = ({
const [status, setStatus] = useState<string | null>(null);
const [isLoading, setIsLoading] = useState(false);
const [useChineseMirror, setUseChineseMirror] = useState(false);
- const { updateSettings } = useSettings();
+ const { updateSettings, settings } = useSettings();
const { isMac: isMacOS } = usePlatform();
const [stats, setStats] = useState<{
screenshots: number;
@@ -45,6 +46,32 @@ const OnboardingStatus: React.FC<OnboardingStatusProps> = ({
const [visionEvent, setVisionEvent] = useState<VisionEvent | null>(null);
const [showScrollButton, setShowScrollButton] = useState(false);
const containerRef = useRef<HTMLDivElement>(null);
+ const [permissions, setPermissions] = useState<OSPermissionsCheck | null>(null);
+
+ // Check permissions on macOS
+ useEffect(() => {
+ const checkPermissions = async () => {
+ if (isMacOS) {
+ try {
+ const perms = await commands.doPermissionsCheck(true);
+ setPermissions(perms);
+ } catch (error) {
+ console.error("Failed to check permissions:", error);
+ }
+ }
+ };
+
+ // Poll permissions every 2 seconds
+ const intervalId = setInterval(() => {
+ checkPermissions();
+ }, 2000);
+
+ // Initial check
+ checkPermissions();
+
+ // Cleanup interval on unmount
+ return () => clearInterval(intervalId);
+ }, [isMacOS]);
useEffect(() => {
const fetchStats = async () => {
@@ -240,6 +267,36 @@ const OnboardingStatus: React.FC<OnboardingStatusProps> = ({
updateSettings({ useChineseMirror: checked });
};
+ // Helper function to check if screen recording permission is granted
+ const isScreenRecordingPermissionGranted = () => {
+ if (!isMacOS) {
+ // On non-macOS platforms, assume permission is granted
+ return true;
+ }
+
+ const screenPermission = permissions?.screenRecording;
+ return screenPermission === "granted" || screenPermission === "notNeeded";
+ };
+
+ // Helper function to check if audio permission is granted (when audio is enabled)
+ const isAudioPermissionGranted = () => {
+ if (!isMacOS || settings.disableAudio) {
+ // On non-macOS platforms or when audio is disabled, assume permission is granted
+ return true;
+ }
+
+ const audioPermission = permissions?.microphone;
+ return audioPermission === "granted" || audioPermission === "notNeeded";
+ };
+
+ // Helper function to check if all required permissions are granted
+ const areRequiredPermissionsGranted = () => {
+ return isScreenRecordingPermissionGranted() && isAudioPermissionGranted();
+ };
+
+ // Check if next button should be disabled
+ const isNextDisabled = isLoading || (isMacOS && !areRequiredPermissionsGranted());
+
return (
<div
ref={containerRef}
@@ -263,6 +320,15 @@ const OnboardingStatus: React.FC<OnboardingStatusProps> = ({
<PermissionButtons type="screen" />
<PermissionButtons type="audio" />
</div>
+ {!areRequiredPermissionsGranted() && (
+ <p className="text-xs text-amber-600 dark:text-amber-400 mt-2 text-center">
+ {!isScreenRecordingPermissionGranted() && !isAudioPermissionGranted()
+ ? "screen recording and audio permissions are required to continue"
+ : !isScreenRecordingPermissionGranted()
+ ? "screen recording permission is required to continue"
+ : "audio permission is required to continue"}
+ </p>
+ )}
</div>
)}
@@ -429,6 +495,7 @@ const OnboardingStatus: React.FC<OnboardingStatusProps> = ({
handleNextSlide={handleNext}
prevBtnText="previous"
nextBtnText="next"
+ isLoading={isNextDisabled}
/>
</div>
);
diff --git a/openrewind/src-tauri/src/main.rs b/openrewind/src-tauri/src/main.rs
index 97f4bf917..78ab4a8a0 100755
--- a/openrewind/src-tauri/src/main.rs
+++ b/openrewind/src-tauri/src/main.rs
@@ -833,6 +833,26 @@ async fn main() {
if server_running.await.unwrap_or(false) {
return;
}
+
+ // Check permissions before spawning sidecar
+ let permissions_check = permissions::do_permissions_check(false);
+ let disable_audio = store.disable_audio;
+
+ // Always check screen recording permission - this is required and needs restart
+ if !permissions_check.screen_recording.permitted() {
+ warn!("Screen recording permission not granted: {:?}. Sidecar will not start until permission is granted.", permissions_check.screen_recording);
+ // Don't start the sidecar if screen recording permission isn't granted
+ // User will need to grant permission through the onboarding/settings UI and restart
+ return;
+ }
+
+ // Check microphone permission if audio recording is enabled - but don't block startup
+ if !disable_audio && !permissions_check.microphone.permitted() {
+ warn!("Microphone permission not granted and audio recording is enabled: {:?}. Audio recording will not work until permission is granted, but sidecar will still start.", permissions_check.microphone);
+ // Continue with sidecar startup - microphone permission can be granted at runtime
+ }
+
+ info!("Screen recording permission granted, spawning screenpipe sidecar. Audio disabled: {}, microphone permission: {:?}", disable_audio, permissions_check.microphone);
if let Err(e) = manager.spawn(&app_handle_clone, None).await {
error!("Failed to spawn initial sidecar: {}", e);
}
diff --git a/openrewind/src-tauri/src/sidecar.rs b/openrewind/src-tauri/src/sidecar.rs
index 95894e9a5..477496c6d 100644
--- a/openrewind/src-tauri/src/sidecar.rs
+++ b/openrewind/src-tauri/src/sidecar.rs
@@ -1,5 +1,6 @@
use crate::get_store;
-use crate::store::{Credits, SettingsStore};
+use crate::store::SettingsStore;
+use crate::permissions::do_permissions_check;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::sync::Arc;
@@ -7,9 +8,8 @@ use tauri::Emitter;
use tauri::{Manager, State};
use tauri_plugin_shell::process::{CommandChild, CommandEvent};
use tauri_plugin_shell::ShellExt;
-use tauri_plugin_store::Store;
use tokio::sync::Mutex;
-use tracing::{debug, error, info};
+use tracing::{debug, error, info, warn};
pub struct SidecarState(pub Arc<tokio::sync::Mutex<Option<SidecarManager>>>);
@@ -217,6 +217,25 @@ pub async fn spawn_screenpipe(
app: tauri::AppHandle,
override_args: Option<Vec<String>>,
) -> Result<(), String> {
+ // Check permissions before spawning
+ let permissions_check = do_permissions_check(false);
+ let store = app.state::<SettingsStore>();
+ let disable_audio = store.disable_audio;
+
+ // Always check screen recording permission - this is required and needs restart
+ if !permissions_check.screen_recording.permitted() {
+ warn!("Screen recording permission not granted: {:?}. Cannot spawn screenpipe.", permissions_check.screen_recording);
+ return Err("Screen recording permission required. Please grant permission through settings and restart the app.".to_string());
+ }
+
+ // Check microphone permission if audio recording is enabled - but don't block startup
+ if !disable_audio && !permissions_check.microphone.permitted() {
+ warn!("Microphone permission not granted and audio recording is enabled: {:?}. Audio recording will not work until permission is granted.", permissions_check.microphone);
+ // Continue with spawn - microphone permission can be granted at runtime
+ }
+
+ info!("Screen recording permission granted for manual spawn. Audio disabled: {}, microphone permission: {:?}", disable_audio, permissions_check.microphone);
+
let mut manager = state.0.lock().await;
if manager.is_none() {
*manager = Some(SidecarManager::new());
@@ -571,8 +590,28 @@ impl SidecarManager {
pub async fn spawn(&mut self, app: &tauri::AppHandle, override_args: Option<Vec<String>>) -> Result<(), String> {
info!("Spawning sidecar with override args: {:?}", override_args);
- // Update settings from store
+
+ // Update settings from store first to get audio settings
self.update_settings(app).await?;
+
+ // Check permissions before spawning
+ let permissions_check = do_permissions_check(false);
+ let store = app.state::<SettingsStore>();
+ let disable_audio = store.disable_audio;
+
+ // Always check screen recording permission - this is required and needs restart
+ if !permissions_check.screen_recording.permitted() {
+ warn!("Screen recording permission not granted: {:?}. Cannot spawn sidecar.", permissions_check.screen_recording);
+ return Err("Screen recording permission required. Please grant permission through settings and restart the app.".to_string());
+ }
+
+ // Check microphone permission if audio recording is enabled - but don't block startup
+ if !disable_audio && !permissions_check.microphone.permitted() {
+ warn!("Microphone permission not granted and audio recording is enabled: {:?}. Audio recording will not work until permission is granted.", permissions_check.microphone);
+ // Continue with spawn - microphone permission can be granted at runtime
+ }
+
+ info!("Screen recording permission granted, proceeding with sidecar spawn. Audio disabled: {}, microphone permission: {:?}", disable_audio, permissions_check.microphone);
// Spawn the sidecar
let child = spawn_sidecar(app, override_args).await?;