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
Pipe update fix (#1547)
Matthew Diakonov96588dce5196
diff --git a/screenpipe-app-tauri/components/pipe-store.tsx b/screenpipe-app-tauri/components/pipe-store.tsxindex 0a3d829e4..1c083c371 100644--- a/screenpipe-app-tauri/components/pipe-store.tsx+++ b/screenpipe-app-tauri/components/pipe-store.tsx@@ -948,6 +948,7 @@ export const PipeStore: React.FC = () => {useEffect(() => {const checkForUpdates = async () => {if (!settings.user.token) {+ console.log("[pipe-update] Update check skipped: No user token");return;}// Get last check time from local storage@@ -958,45 +959,62 @@ export const PipeStore: React.FC = () => {// Check if 5 minutes have passed since last checkif (lastCheckTime && now - lastCheckTime < 5 * 60 * 1000) {+ console.log("[pipe-update] Skipping check - last check was less than 5 minutes ago");return;}// Store current time as last checkawait localforage.setItem("lastUpdateCheck", now);+ console.log("[pipe-update] Checking for updates...");const installedPipes = pipes.filter((pipe) => pipe.is_installed && pipe.installed_config?.version);// Skip if no pipes to check- if (installedPipes.length === 0) return;-- // Format pipes for batch update check- const pluginsToCheck = installedPipes.map((pipe) => ({- pipe_id: pipe.id,- version: pipe.installed_config!.version!,- }));-- const storeApi = await PipeApi.create(settings.user.token);- const updates = await storeApi.checkUpdates(pluginsToCheck);-- // Process updates and install them- for (const pipe of installedPipes) {- const update = updates.results.find((u) => u.pipe_id === pipe.id);- if (update && "has_update" in update && update.has_update) {- await handleUpdatePipe(pipe);+ if (installedPipes.length === 0) {+ console.log("[pipe-update] No installed pipes to check");+ return;+ }++ try {+ // Format pipes for batch update check+ const pluginsToCheck = installedPipes.map((pipe) => ({+ pipe_id: pipe.id,+ version: pipe.installed_config!.version!,+ }));++ console.log("[pipe-update] Sending update check request:", pluginsToCheck);++ const storeApi = await PipeApi.create(settings.user.token);+ const updates = await storeApi.checkUpdates(pluginsToCheck);++ console.log("[pipe-update] Update check response:", updates);++ // Process updates+ for (const pipe of installedPipes) {+ const update = updates.results.find((u) => u.pipe_id === pipe.id);+ console.log(`[pipe-update] Update check for ${pipe.name}:`, update);+ if (update && "has_update" in update && update.has_update) {+ console.log(`[pipe-update] Update available for ${pipe.name}`);+ await handleUpdatePipe(pipe);+ } else {+ console.log(`[pipe-update] No update needed for ${pipe.name}`);+ }}+ } catch (error) {+ console.error("[pipe-update] Error checking for updates:", error);}};// Run check immediatelycheckForUpdates();- // Set up interval to check every 10 seconds actual check is done in the function+ // Set up interval to check every 10 seconds actual check is done in the functionconst interval = setInterval(checkForUpdates, 10 * 1000);return () => clearInterval(interval);- }, [settings.user.token]);+ }, [settings.user.token, pipes]);useEffect(() => {const setupDeepLink = async () => {diff --git a/screenpipe-app-tauri/lib/api/store/index.ts b/screenpipe-app-tauri/lib/api/store/index.tsindex beb7dc13a..f1b04db63 100644--- a/screenpipe-app-tauri/lib/api/store/index.ts+++ b/screenpipe-app-tauri/lib/api/store/index.ts@@ -279,29 +279,68 @@ export class PipeApi {async checkUpdates(plugins: Array<{ pipe_id: string; version: string }>): Promise<CheckUpdatesResponse> {- // Create a cache key based on all plugin IDs and versions- const cacheKey = `updates_${plugins+ // Filter out local plugins+ const localPlugins = plugins.filter(p => p.pipe_id.includes('_local'));+ const remotePlugins = plugins.filter(p => !p.pipe_id.includes('_local'));++ if (localPlugins.length > 0) {+ console.log(`[pipe-update] filtered out ${localPlugins.length} local plugins:`, localPlugins);+ }+++ // If no remote plugins, return empty result+ if (remotePlugins.length === 0) {+ console.log("[pipe-update] no remote plugins to check for updates");+ return {+ results: []+ };+ }++ // Create a cache key based on remote plugin IDs and versions+ const cacheKey = `updates_${remotePlugins.map((p) => `${p.pipe_id}_${p.version}`).join("_")}`;const cached = await this.getCached<CheckUpdatesResponse>(cacheKey);- if (cached) return cached;+ if (cached) {+ console.log("[pipe-update] returning cached update results");+ return cached;+ }try {+ console.log(`[pipe-update] sending update check request to server for ${remotePlugins.length} plugins`);const response = await fetch(`${this.baseUrl}/api/plugins/check-updates`, {method: "POST",headers: {"Content-Type": "application/json",Authorization: `Bearer ${this.authToken}`,},- body: JSON.stringify({ plugins }),+ body: JSON.stringify({ plugins: remotePlugins }),});if (!response.ok) {- const { error } = await response.json();- throw new Error(`failed to check for updates: ${error}`);+ const errorData = await response.json();+ console.error(`[pipe-update] server returned ${response.status}: ${JSON.stringify(errorData)}`);+ throw new Error(`failed to check for updates: ${errorData.error}`);}const data = await response.json();+ console.log("[pipe-update] received update check response:", data);++ // Add back information about local plugins+ if (localPlugins.length > 0) {+ console.log("[pipe-update] adding local plugin info to response");+ const localResults = localPlugins.map(p => ({+ pipe_id: p.pipe_id,+ error: "Local plugin cannot be checked for updates",+ status: 404+ }));++ // If data.results exists, add local results to it+ if (data.results) {+ data.results = [...data.results, ...localResults];+ }+ }+await this.setCache(cacheKey, data);return data;} catch (error) {