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: skip auto-update install for non-admin macOS users
AI Agentc250f080e382
diff --git a/apps/screenpipe-app-tauri/components/update-banner.tsx b/apps/screenpipe-app-tauri/components/update-banner.tsxindex 760dc296d..662538f90 100644--- a/apps/screenpipe-app-tauri/components/update-banner.tsx+++ b/apps/screenpipe-app-tauri/components/update-banner.tsx@@ -30,6 +30,10 @@ interface AuthRequiredInfo {message: string;}+interface NeedsAdminInfo {+ version: string;+}+interface UpdateBannerState {isVisible: boolean;updateInfo: UpdateInfo | null;@@ -38,6 +42,7 @@ interface UpdateBannerState {downloadProgress: DownloadProgress | null;pendingUpdate: Update | null;authRequired: AuthRequiredInfo | null;+ needsAdmin: NeedsAdminInfo | null;setIsVisible: (visible: boolean) => void;setUpdateInfo: (info: UpdateInfo | null) => void;setIsInstalling: (installing: boolean) => void;@@ -45,6 +50,7 @@ interface UpdateBannerState {setDownloadProgress: (progress: DownloadProgress | null) => void;setPendingUpdate: (update: Update | null) => void;setAuthRequired: (info: AuthRequiredInfo | null) => void;+ setNeedsAdmin: (info: NeedsAdminInfo | null) => void;}export const useUpdateBanner = create<UpdateBannerState>((set) => ({@@ -55,6 +61,7 @@ export const useUpdateBanner = create<UpdateBannerState>((set) => ({downloadProgress: null,pendingUpdate: null,authRequired: null,+ needsAdmin: null,setIsVisible: (visible) => set({ isVisible: visible }),setUpdateInfo: (info) => set({ updateInfo: info }),setIsInstalling: (installing) => set({ isInstalling: installing }),@@ -62,6 +69,7 @@ export const useUpdateBanner = create<UpdateBannerState>((set) => ({setDownloadProgress: (progress) => set({ downloadProgress: progress }),setPendingUpdate: (update) => set({ pendingUpdate: update }),setAuthRequired: (info) => set({ authRequired: info }),+ setNeedsAdmin: (info) => set({ needsAdmin: info }),}));interface UpdateBannerProps {@@ -71,7 +79,7 @@ interface UpdateBannerProps {export function UpdateBanner({ className, compact = false }: UpdateBannerProps) {const isEnterprise = useIsEnterpriseBuild();- const { isVisible, updateInfo, isInstalling, isDownloading, downloadProgress, setIsVisible, setIsInstalling, pendingUpdate, authRequired, setAuthRequired } = useUpdateBanner();+ const { isVisible, updateInfo, isInstalling, isDownloading, downloadProgress, setIsVisible, setIsInstalling, pendingUpdate, authRequired, setAuthRequired, needsAdmin, setNeedsAdmin } = useUpdateBanner();const { toast } = useToast();if (isEnterprise) return null;@@ -189,6 +197,41 @@ export function UpdateBanner({ className, compact = false }: UpdateBannerProps));}+ // Show needs-admin state — macOS non-admin users need admin to install+ if (needsAdmin) {+ if (compact) {+ return (+ <div className={cn("flex items-center gap-2 text-xs text-muted-foreground", className)}>+ <Sparkles className="h-3 w-3 text-primary" />+ <span>v{needsAdmin.version} available (admin needed)</span>+ </div>+ );+ }+ return (+ <div className={cn(+ "flex items-center justify-between gap-3 px-3 py-2 bg-muted/50 border-b text-sm",+ className+ )}>+ <div className="flex items-center gap-2 flex-1">+ <Sparkles className="h-4 w-4 text-primary" />+ <span>+ screenpipe <span className="font-medium">v{needsAdmin.version}</span> is available — ask your admin to install it+ </span>+ </div>+ <div className="flex items-center gap-2">+ <Button+ variant="ghost"+ size="sm"+ className="h-7 w-7 p-0"+ onClick={() => setNeedsAdmin(null)}+ >+ <X className="h-4 w-4" />+ </Button>+ </div>+ </div>+ );+ }+// Show downloading state even before updateInfo is setif (isDownloading && !updateInfo) {const pct = downloadProgress?.percent ?? 0;@@ -299,7 +342,7 @@ export function UpdateBanner({ className, compact = false }: UpdateBannerProps)// Hook to listen for update events from Rustexport function useUpdateListener() {- const { setIsVisible, setUpdateInfo, setIsDownloading, setDownloadProgress, setAuthRequired } = useUpdateBanner();+ const { setIsVisible, setUpdateInfo, setIsDownloading, setDownloadProgress, setAuthRequired, setNeedsAdmin } = useUpdateBanner();useEffect(() => {let unlistenAvailable: (() => void) | undefined;@@ -307,6 +350,7 @@ export function useUpdateListener() {let unlistenDownloading: (() => void) | undefined;let unlistenProgress: (() => void) | undefined;let unlistenAuth: (() => void) | undefined;+ let unlistenNeedsAdmin: (() => void) | undefined;const setupListeners = async () => {// Listen for download starting (shows banner immediately)@@ -340,6 +384,12 @@ export function useUpdateListener() {setIsDownloading(false);setDownloadProgress(null);});++ unlistenNeedsAdmin = await listen<NeedsAdminInfo>("update-needs-admin", (event) => {+ setNeedsAdmin(event.payload);+ setIsDownloading(false);+ setDownloadProgress(null);+ });};setupListeners();@@ -350,6 +400,7 @@ export function useUpdateListener() {unlistenDownloading?.();unlistenProgress?.();unlistenAuth?.();+ unlistenNeedsAdmin?.();};- }, [setIsVisible, setUpdateInfo, setIsDownloading, setDownloadProgress, setAuthRequired]);+ }, [setIsVisible, setUpdateInfo, setIsDownloading, setDownloadProgress, setAuthRequired, setNeedsAdmin]);}diff --git a/apps/screenpipe-app-tauri/src-tauri/src/updates.rs b/apps/screenpipe-app-tauri/src-tauri/src/updates.rsindex 82d404613..b55022983 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/updates.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/updates.rs@@ -24,6 +24,40 @@ use tokio::sync::oneshot;use tokio::sync::Mutex;use tokio::time::interval;+use std::sync::OnceLock;++static IS_MACOS_ADMIN: OnceLock<bool> = OnceLock::new();++pub fn is_macos_admin() -> bool {+ *IS_MACOS_ADMIN.get_or_init(|| {+ #[cfg(target_os = "macos")]+ {+ if let Ok(output) = std::process::Command::new("id").arg("-Gn").output() {+ if let Ok(groups) = String::from_utf8(output.stdout) {+ return groups.split_whitespace().any(|g| g == "admin");+ }+ }+ false+ }+ #[cfg(not(target_os = "macos"))]+ {+ true+ }+ })+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn test_is_macos_admin_executes() {+ // Just verify it doesn't panic+ let is_admin = is_macos_admin();+ println!("is_macos_admin: {}", is_admin);+ }+}+// ---------------------------------------------------------------------------// Rollback: download a specific older version from R2 via the website API// ---------------------------------------------------------------------------@@ -69,6 +103,10 @@ pub async fn install_specific_version(app: &tauri::AppHandle, version: &str) ->info!("rollback: downloading v{}", version);+ if !is_macos_admin() {+ return Err("rollback requires admin privileges on macOS. please run screenpipe as admin to rollback.".to_string());+ }+update.download_and_install(|_, _| {}, || {}).await@@ -248,6 +286,34 @@ impl UpdatesManager {if let Some(update) = check_result? {*self.update_available.lock().await = true;+ if !is_macos_admin() {+ warn!("skipping auto-update: user is not a macOS admin");+ let _ = self.app.emit(+ "update-needs-admin",+ serde_json::json!({+ "version": update.version+ }),+ );++ let app_notif = self.app.clone();+ let version_str = update.version.clone();+ let _ = std::thread::spawn(move || {+ let _ = app_notif+ .notification()+ .builder()+ .title("screenpipe update available")+ .body(format!("update v{} available — ask your admin to install it", version_str))+ .show();+ });++ if let Some(ref item) = self.update_menu_item {+ item.set_enabled(false)?;+ item.set_text(&format!("ask admin to update v{}", update.version))?;+ }++ return Ok(false);+ }+// Emit "update-downloading" immediately so user sees feedbacklet download_info = serde_json::json!({"version": update.version,