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(updates): silent background download — banner only when ready
Louis Beaumont882d2d19a1d4
diff --git a/apps/screenpipe-app-tauri/components/update-banner.tsx b/apps/screenpipe-app-tauri/components/update-banner.tsxindex 9f9edd021..75039bcf0 100644--- a/apps/screenpipe-app-tauri/components/update-banner.tsx+++ b/apps/screenpipe-app-tauri/components/update-banner.tsx@@ -17,13 +17,6 @@ interface UpdateInfo {body: string;}-interface DownloadProgress {- version: string;- downloaded: number;- total: number | null;- percent: number;-}-interface AuthRequiredInfo {version: string;message: string;@@ -33,15 +26,11 @@ interface UpdateBannerState {isVisible: boolean;updateInfo: UpdateInfo | null;isInstalling: boolean;- isDownloading: boolean;- downloadProgress: DownloadProgress | null;pendingUpdate: Update | null;authRequired: AuthRequiredInfo | 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;setAuthRequired: (info: AuthRequiredInfo | null) => void;}@@ -50,15 +39,11 @@ export const useUpdateBanner = create<UpdateBannerState>((set) => ({isVisible: false,updateInfo: null,isInstalling: false,- isDownloading: false,- downloadProgress: null,pendingUpdate: null,authRequired: 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 }),setAuthRequired: (info) => set({ authRequired: info }),}));@@ -71,7 +56,7 @@ interface UpdateBannerProps {}export function UpdateBanner({ className, compact = false, variant = "default" }: UpdateBannerProps) {- const { isVisible, updateInfo, isInstalling, isDownloading, downloadProgress, setIsVisible, setIsInstalling, pendingUpdate, authRequired, setAuthRequired } = useUpdateBanner();+ const { isVisible, updateInfo, isInstalling, setIsVisible, setIsInstalling, pendingUpdate, authRequired, setAuthRequired } = useUpdateBanner();const { toast } = useToast();const handleUpdate = async () => {@@ -187,57 +172,9 @@ export function UpdateBanner({ className, compact = false, variant = "default" });}- // 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 (variant === "sidebar") {- if (isDownloading) {- const pct = downloadProgress?.percent ?? 0;- return (- <div className={cn(- "rounded-lg border border-border bg-card/50 px-2.5 py-2 text-xs",- className,- )}>- <div className="flex items-center gap-2 mb-1.5">- <Sparkles className="h-3.5 w-3.5 text-primary animate-pulse shrink-0" />- <span className="text-muted-foreground truncate">Downloading v{updateInfo.version}…</span>- </div>- <div className="h-1 bg-muted rounded-full overflow-hidden">- <div- className="h-full bg-primary rounded-full transition-all duration-300"- style={{ width: `${pct}%` }}- />- </div>- </div>- );- }return (<buttontype="button"@@ -266,24 +203,16 @@ export function UpdateBanner({ className, compact = false, variant = "default" }className)}><Sparkles className="h-3 w-3 text-primary" />- {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>- </>- )}+ <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>);}@@ -295,76 +224,46 @@ export function UpdateBanner({ className, compact = false, variant = "default" })}><div className="flex items-center gap-2 flex-1"><Sparkles className="h-4 w-4 text-primary" />- {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>- )}+ <span>+ screenpipe <span className="font-medium">v{updateInfo.version}</span> is ready+ </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 ? "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>- {!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, setIsDownloading, setDownloadProgress, setAuthRequired } = useUpdateBanner();+ const { setIsVisible, setUpdateInfo, setAuthRequired } = useUpdateBanner();useEffect(() => {let unlistenAvailable: (() => void) | undefined;let unlistenClick: (() => void) | undefined;- let unlistenDownloading: (() => void) | undefined;- let unlistenProgress: (() => void) | undefined;let unlistenAuth: (() => void) | undefined;const setupListeners = async () => {- // 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)+ // Download happens silently in the background. Banner only appears+ // when the download is complete and the app is ready to restart.unlistenAvailable = await listen<UpdateInfo>("update-available", (event) => {- setIsDownloading(false);- setDownloadProgress(null);setUpdateInfo(event.payload);setIsVisible(true);});@@ -377,8 +276,6 @@ export function useUpdateListener() {// Listen for auth-required (user needs to sign in to download update)unlistenAuth = await listen<AuthRequiredInfo>("update-auth-required", (event) => {setAuthRequired(event.payload);- setIsDownloading(false);- setDownloadProgress(null);});};@@ -387,9 +284,7 @@ export function useUpdateListener() {return () => {unlistenAvailable?.();unlistenClick?.();- unlistenDownloading?.();- unlistenProgress?.();unlistenAuth?.();};- }, [setIsVisible, setUpdateInfo, setIsDownloading, setDownloadProgress, setAuthRequired]);+ }, [setIsVisible, setUpdateInfo, setAuthRequired]);}