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
feat: show update download progress in UI and tray menu
Louis Beaumont2df7e8185034
diff --git a/apps/screenpipe-app-tauri/components/update-banner.tsx b/apps/screenpipe-app-tauri/components/update-banner.tsxindex f1881c07e..996d74ab6 100644--- a/apps/screenpipe-app-tauri/components/update-banner.tsx+++ b/apps/screenpipe-app-tauri/components/update-banner.tsx@@ -17,14 +17,25 @@ interface UpdateInfo {body: string;}+interface DownloadProgress {+ version: string;+ downloaded: number;+ total: number | null;+ percent: number;+}+interface UpdateBannerState {isVisible: boolean;updateInfo: UpdateInfo | null;isInstalling: boolean;+ isDownloading: boolean;+ downloadProgress: DownloadProgress | null;pendingUpdate: Update | null;setIsVisible: (visible: boolean) => void;setUpdateInfo: (info: UpdateInfo | null) => void;setIsInstalling: (installing: boolean) => void;+ setIsDownloading: (downloading: boolean) => void;+ setDownloadProgress: (progress: DownloadProgress | null) => void;setPendingUpdate: (update: Update | null) => void;}@@ -32,10 +43,14 @@ export const useUpdateBanner = create<UpdateBannerState>((set) => ({isVisible: false,updateInfo: null,isInstalling: false,+ isDownloading: false,+ downloadProgress: null,pendingUpdate: null,setIsVisible: (visible) => set({ isVisible: visible }),setUpdateInfo: (info) => set({ updateInfo: info }),setIsInstalling: (installing) => set({ isInstalling: installing }),+ setIsDownloading: (downloading) => set({ isDownloading: downloading }),+ setDownloadProgress: (progress) => set({ downloadProgress: progress }),setPendingUpdate: (update) => set({ pendingUpdate: update }),}));@@ -45,7 +60,7 @@ interface UpdateBannerProps {}export function UpdateBanner({ className, compact = false }: UpdateBannerProps) {- const { isVisible, updateInfo, isInstalling, setIsVisible, setIsInstalling, pendingUpdate } = useUpdateBanner();+ const { isVisible, updateInfo, isInstalling, isDownloading, downloadProgress, setIsVisible, setIsInstalling, pendingUpdate } = useUpdateBanner();const { toast } = useToast();const handleUpdate = async () => {@@ -116,6 +131,34 @@ export function UpdateBanner({ className, compact = false }: UpdateBannerProps)}};+ // Show downloading state even before updateInfo is set+ if (isDownloading && !updateInfo) {+ const pct = downloadProgress?.percent ?? 0;+ 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 animate-pulse" />+ <span>downloading update... {pct}%</span>+ </div>+ );+ }+ return (+ <div className={cn("flex items-center gap-3 px-3 py-2 bg-muted/50 border-b text-sm", className)}>+ <Sparkles className="h-4 w-4 text-primary animate-pulse" />+ <div className="flex items-center gap-2 flex-1">+ <span>downloading update{downloadProgress?.version ? ` v${downloadProgress.version}` : ""}...</span>+ <div className="flex-1 max-w-[200px] h-1.5 bg-muted rounded-full overflow-hidden">+ <div+ className="h-full bg-primary rounded-full transition-all duration-300"+ style={{ width: `${pct}%` }}+ />+ </div>+ <span className="text-xs text-muted-foreground">{pct}%</span>+ </div>+ </div>+ );+ }+if (!isVisible || !updateInfo) return null;if (compact) {@@ -125,16 +168,24 @@ export function UpdateBanner({ className, compact = false }: UpdateBannerProps)className)}><Sparkles className="h-3 w-3 text-primary" />- <span>v{updateInfo.version} available</span>- <Button- variant="ghost"- size="sm"- className="h-5 px-2 text-xs"- onClick={handleUpdate}- disabled={isInstalling}- >- {isInstalling ? "downloading..." : "update"}- </Button>+ {isDownloading ? (+ <>+ <span>downloading v{updateInfo.version}... {downloadProgress?.percent ?? 0}%</span>+ </>+ ) : (+ <>+ <span>v{updateInfo.version} ready</span>+ <Button+ variant="ghost"+ size="sm"+ className="h-5 px-2 text-xs"+ onClick={handleUpdate}+ disabled={isInstalling}+ >+ {isInstalling ? "restarting..." : "restart to update"}+ </Button>+ </>+ )}</div>);}@@ -144,46 +195,77 @@ export function UpdateBanner({ className, compact = false }: UpdateBannerProps)"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">+ <div className="flex items-center gap-2 flex-1"><Sparkles className="h-4 w-4 text-primary" />- <span>- screenpipe <span className="font-medium">v{updateInfo.version}</span> is available- </span>- </div>- <div className="flex items-center gap-2">- <Button- variant="default"- size="sm"- className="h-7 px-3 text-xs"- onClick={handleUpdate}- disabled={isInstalling}- >- {isInstalling ? "installing..." : "update now"}- </Button>- <Button- variant="ghost"- size="sm"- className="h-7 w-7 p-0"- onClick={() => setIsVisible(false)}- >- <X className="h-4 w-4" />- </Button>+ {isDownloading ? (+ <div className="flex items-center gap-2 flex-1">+ <span>downloading <span className="font-medium">v{updateInfo.version}</span></span>+ <div className="flex-1 max-w-[200px] h-1.5 bg-muted rounded-full overflow-hidden">+ <div+ className="h-full bg-primary rounded-full transition-all duration-300"+ style={{ width: `${downloadProgress?.percent ?? 0}%` }}+ />+ </div>+ <span className="text-xs text-muted-foreground">{downloadProgress?.percent ?? 0}%</span>+ </div>+ ) : (+ <span>+ screenpipe <span className="font-medium">v{updateInfo.version}</span> is ready+ </span>+ )}</div>+ {!isDownloading && (+ <div className="flex items-center gap-2">+ <Button+ variant="default"+ size="sm"+ className="h-7 px-3 text-xs"+ onClick={handleUpdate}+ disabled={isInstalling}+ >+ {isInstalling ? "restarting..." : "restart to update"}+ </Button>+ <Button+ variant="ghost"+ size="sm"+ className="h-7 w-7 p-0"+ onClick={() => setIsVisible(false)}+ >+ <X className="h-4 w-4" />+ </Button>+ </div>+ )}</div>);}// Hook to listen for update events from Rustexport function useUpdateListener() {- const { setIsVisible, setUpdateInfo } = useUpdateBanner();+ const { setIsVisible, setUpdateInfo, setIsDownloading, setDownloadProgress } = useUpdateBanner();useEffect(() => {let unlistenAvailable: (() => void) | undefined;let unlistenClick: (() => void) | undefined;+ let unlistenDownloading: (() => void) | undefined;+ let unlistenProgress: (() => void) | undefined;const setupListeners = async () => {- // Listen for update available event+ // Listen for download starting (shows banner immediately)+ unlistenDownloading = await listen<{ version: string; body: string }>("update-downloading", (event) => {+ setIsDownloading(true);+ setDownloadProgress({ version: event.payload.version, downloaded: 0, total: null, percent: 0 });+ setIsVisible(true);+ });++ // Listen for download progress+ unlistenProgress = await listen<DownloadProgress>("update-download-progress", (event) => {+ setDownloadProgress(event.payload);+ });++ // Listen for update ready (download complete)unlistenAvailable = await listen<UpdateInfo>("update-available", (event) => {+ setIsDownloading(false);+ setDownloadProgress(null);setUpdateInfo(event.payload);setIsVisible(true);});@@ -199,6 +281,8 @@ export function useUpdateListener() {return () => {unlistenAvailable?.();unlistenClick?.();+ unlistenDownloading?.();+ unlistenProgress?.();};- }, [setIsVisible, setUpdateInfo]);+ }, [setIsVisible, setUpdateInfo, setIsDownloading, setDownloadProgress]);}diff --git a/apps/screenpipe-app-tauri/components/updater.tsx b/apps/screenpipe-app-tauri/components/updater.tsxindex b5c89fce6..bf641ee6f 100644--- a/apps/screenpipe-app-tauri/components/updater.tsx+++ b/apps/screenpipe-app-tauri/components/updater.tsx@@ -28,6 +28,13 @@ export async function checkForAppUpdates({const os = platform();const cpuArch = arch();+ // Show immediate feedback — user clicked "check for updates"+ const checkingToastId = toast({+ title: "checking for updates...",+ description: `checking ${channel} channel`,+ duration: Infinity,+ });+// Build endpoint URLs for the selected channel (proxy primary, CN fallback)const baseEndpoints = UPDATE_ENDPOINTS[channel];const target = os === "macos" ? "darwin" : os;@@ -35,63 +42,103 @@ export async function checkForAppUpdates({(base) => `${base}/${target}-${cpuArch}/{{current_version}}`);- // @ts-ignore - endpoints option may not be in type definitions but is supported- const update = await check({- endpoints,- } as any);+ let update;+ try {+ // @ts-ignore - endpoints option may not be in type definitions but is supported+ update = await check({+ endpoints,+ } as any);+ } catch (error) {+ toast({+ id: checkingToastId,+ title: "update check failed",+ description: String(error),+ variant: "destructive",+ duration: 5000,+ });+ return null;+ }++ if (!update?.available) {+ toast({+ id: checkingToastId,+ title: "you're up to date",+ description: "no new updates available",+ duration: 3000,+ });+ return update;+ }++ // Dismiss checking toast+ toast({+ id: checkingToastId,+ title: `update v${update.version} found`,+ description: "preparing to download...",+ duration: 2000,+ });- if (update?.available) {- const channelLabel = channel === "beta" ? " (Beta)" : "";- const yes = await ask(- `+ const channelLabel = channel === "beta" ? " (Beta)" : "";+ const yes = await ask(+ `Update to ${update.version}${channelLabel} is available!Release notes: ${update.body}- `,- {- title: "Update Now!",- kind: "info",- okLabel: "Update",- cancelLabel: "Cancel",- }- );+ `,+ {+ title: "Update Now!",+ kind: "info",+ okLabel: "Update",+ cancelLabel: "Cancel",+ }+ );- if (yes) {- // on windows only - TODO shouldnt be necessary- if (os === "windows") {- await invoke("stop_screenpipe");- }+ if (yes) {+ // on windows only - TODO shouldnt be necessary+ if (os === "windows") {+ await invoke("stop_screenpipe");+ }- const toastId = toast({- title: "Updating...",- description: `Downloading and installing ${channel} update`,- duration: Infinity,- });+ const toastId = toast({+ title: "downloading update...",+ description: `downloading v${update.version}`,+ duration: Infinity,+ });+ try {+ // Back up current app bundle before replacing it (for rollback)try {- // Back up current app bundle before replacing it (for rollback)- try {- await invoke("backup_current_app");- } catch (_) {- // Non-fatal — proceed with update even if backup fails- console.warn("rollback backup failed, continuing with update");- }- await update.downloadAndInstall();- toast({- id: toastId,- title: "Update complete",- description: "Relaunching application",- duration: 3000,- });- await relaunch();- } catch (error) {- toast({- id: toastId,- title: "Update failed",- description: "An error occurred during the update",- variant: "destructive",- duration: 5000,- });+ await invoke("backup_current_app");+ } catch (_) {+ // Non-fatal — proceed with update even if backup fails+ console.warn("rollback backup failed, continuing with update");}+ await update.downloadAndInstall((event: any) => {+ if (event?.event === "progress") {+ const pct = event.data?.contentLength+ ? Math.round((event.data.chunkLength / event.data.contentLength) * 100)+ : 0;+ toast({+ id: toastId,+ title: "downloading update...",+ description: `${pct}% downloaded`,+ duration: Infinity,+ });+ }+ });+ toast({+ id: toastId,+ title: "update complete",+ description: "relaunching application",+ duration: 3000,+ });+ await relaunch();+ } catch (error) {+ toast({+ id: toastId,+ title: "update failed",+ description: "an error occurred during the update",+ variant: "destructive",+ duration: 5000,+ });}}diff --git a/apps/screenpipe-app-tauri/src-tauri/src/updates.rs b/apps/screenpipe-app-tauri/src-tauri/src/updates.rsindex 8c8c0beb8..49d4f5f26 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/updates.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/updates.rs@@ -422,6 +422,14 @@ impl UpdatesManager {if let Some(update) = check_result? {*self.update_available.lock().await = true;+ // Emit "update-downloading" immediately so user sees feedback+ let download_info = serde_json::json!({+ "version": update.version,+ "body": update.body.clone().unwrap_or_default(),+ "stage": "downloading",+ });+ let _ = self.app.emit("update-downloading", download_info);+#[cfg(target_os = "windows")]{self.update_menu_item.set_enabled(true)?;@@ -458,10 +466,38 @@ impl UpdatesManager {{// Back up current app bundle before replacing itbackup_current_app();- update.download_and_install(|_, _| {}, || {}).await?;+ let app_handle = self.app.clone();+ let update_version = update.version.clone();+ let menu_item = self.update_menu_item.clone();+ let mut downloaded: u64 = 0;+ let mut last_pct: u8 = 0;+ update.download_and_install(+ move |chunk_len, content_len| {+ downloaded += chunk_len as u64;+ let pct = content_len+ .map(|total| ((downloaded as f64 / total as f64) * 100.0) as u8)+ .unwrap_or(0);+ // Only emit every 5% to avoid flooding+ if pct >= last_pct + 5 || pct == 100 {+ last_pct = pct;+ let progress = serde_json::json!({+ "version": update_version,+ "downloaded": downloaded,+ "total": content_len,+ "percent": pct,+ });+ let _ = app_handle.emit("update-download-progress", progress);+ info!("update download: {}%", pct);+ }+ let _ = menu_item.set_text(+ &format!("downloading update... {}%", pct)+ );+ },+ || {},+ ).await?;*self.update_installed.lock().await = true;self.update_menu_item.set_enabled(true)?;- self.update_menu_item.set_text("update now")?;+ self.update_menu_item.set_text("restart to update")?;}// Emit event to frontend for in-app banner (visible if window is open)@@ -550,11 +586,28 @@ impl UpdatesManager {// Back up current app before replacing itbackup_current_app();- update.download_and_install(|_, _| {}, || {}).await?;+ let menu_item_win = self.update_menu_item.clone();+ let mut dl: u64 = 0;+ let mut lp: u8 = 0;+ update.download_and_install(+ move |chunk_len, content_len| {+ dl += chunk_len as u64;+ let pct = content_len+ .map(|t| ((dl as f64 / t as f64) * 100.0) as u8)+ .unwrap_or(0);+ if pct >= lp + 5 || pct == 100 {+ lp = pct;+ let _ = menu_item_win.set_text(+ &format!("downloading update... {}%", pct)+ );+ }+ },+ || {},+ ).await?;*self.update_installed.lock().await = true;self.update_menu_item.set_enabled(true)?;- self.update_menu_item.set_text("update now")?;+ self.update_menu_item.set_text("restart to update")?;}// Proceed with the update