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: preserve member's enabled/disabled state when syncing team pipes
Louis Beaumontff6bcf9ee57a
diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-team-sync.ts b/apps/screenpipe-app-tauri/lib/hooks/use-team-sync.tsindex 3529b0841..99e31d9cf 100644--- a/apps/screenpipe-app-tauri/lib/hooks/use-team-sync.ts+++ b/apps/screenpipe-app-tauri/lib/hooks/use-team-sync.ts@@ -6,11 +6,9 @@ import { useEffect, useRef } from "react";import { useSettings } from "./use-settings";import { AIPreset } from "@/lib/utils/tauri";import { TeamConfig } from "./use-team";-import { mkdir, writeTextFile } from "@tauri-apps/plugin-fs";+import { exists, mkdir, readTextFile, writeTextFile } from "@tauri-apps/plugin-fs";import { homeDir, join } from "@tauri-apps/api/path";-const API_BASE = "http://localhost:3030";-/*** Auto-syncs team configs (window_filter, url_filter, ai_provider, pipe) into local settings.* Call inside a component that already has useTeam() mounted.@@ -95,26 +93,56 @@ export function useTeamSync(configs: TeamConfig[], hasTeam: boolean) {}}- // Sync team-shared pipes to local pipe storage+ // Sync team-shared pipes to local pipe storage.+ // Preserves member's local enabled/disabled override — only updates pipe content+ // when admin pushes a new version (checked via updated_at).const pipeConfigs = configs.filter((c) => c.config_type === "pipe" && c.scope === "team" && c.value);for (const c of pipeConfigs) {const pipeKey = `${c.key}:${c.updated_at}`;if (syncedPipes.current.has(pipeKey)) continue;- const val = c.value as { name?: string; raw_content?: string };+ const val = c.value as { name?: string; raw_content?: string; config?: { enabled?: boolean } };if (!val.name || !val.raw_content) continue;- // Write pipe.md directly to ~/.screenpipe/pipes/<name>/(async () => {try {const home = await homeDir();const pipeDir = await join(home, ".screenpipe", "pipes", val.name!);- await mkdir(pipeDir, { recursive: true });const pipeMd = await join(pipeDir, "pipe.md");- await writeTextFile(pipeMd, val.raw_content!);++ // Check if pipe already exists locally+ const pipeExists = await exists(pipeMd);+ let localEnabled: boolean | null = null;++ if (pipeExists) {+ // Preserve member's local enabled state+ try {+ const localContent = await readTextFile(pipeMd);+ const enabledMatch = localContent.match(/^enabled:\s*(true|false)/m);+ if (enabledMatch) {+ localEnabled = enabledMatch[1] === "true";+ }+ } catch {+ // can't read — will overwrite+ }+ }++ await mkdir(pipeDir, { recursive: true });++ // Write team content but preserve local enabled state+ let content = val.raw_content!;+ if (localEnabled !== null) {+ // Replace the enabled field in the team content with the local value+ content = content.replace(+ /^enabled:\s*(true|false)/m,+ `enabled: ${localEnabled}`+ );+ }++ await writeTextFile(pipeMd, content);syncedPipes.current.add(pipeKey);} catch {- // non-fatal — pipe may already exist or fs error+ // non-fatal}})();}