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
refactor: better handling of switch with screenpipe cloud in settings, move auto start to general settings, improve cli command dialog and fix for windows
Louis Beaumont5226f6753d91
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.mdindex f4fac1749..abf6a92da 100644--- a/.github/pull_request_template.md+++ b/.github/pull_request_template.md@@ -8,6 +8,7 @@ assignees: ''---## description+brief description of the changes in this pr.related issue: #diff --git a/pipes/rewind/bun.lockb b/pipes/rewind/bun.lockbindex 2ab027e81..b94ad3522 100755Binary files a/pipes/rewind/bun.lockb and b/pipes/rewind/bun.lockb differdiff --git a/pipes/rewind/package.json b/pipes/rewind/package.jsonindex 893f2e91a..577e60887 100644--- a/pipes/rewind/package.json+++ b/pipes/rewind/package.json@@ -1,6 +1,6 @@{"name": "rewind",- "version": "0.1.7",+ "version": "0.1.8","private": true,"scripts": {"dev": "next dev --turbopack",diff --git a/screenpipe-app-tauri/app/page.tsx b/screenpipe-app-tauri/app/page.tsxindex daaf5dbe6..f8e0d162a 100644--- a/screenpipe-app-tauri/app/page.tsx+++ b/screenpipe-app-tauri/app/page.tsx@@ -2,7 +2,7 @@import { getStore, useSettings } from "@/lib/hooks/use-settings";-import React, { useEffect } from "react";+import React, { useEffect, useState } from "react";import NotificationHandler from "@/components/notification-handler";import Header from "@/components/header";import { useToast } from "@/components/ui/use-toast";@@ -22,6 +22,7 @@ import { relaunch } from "@tauri-apps/plugin-process";import { PipeApi } from "@/lib/api";import localforage from "localforage";import { onOpenUrl } from "@tauri-apps/plugin-deep-link";+import { LoginDialog } from "@/components/login-dialog";export default function Home() {const { settings, updateSettings, loadUser, reloadStore } = useSettings();@@ -32,13 +33,10 @@ export default function Home() {const { open: openStatusDialog } = useStatusDialog();const { setIsOpen: setSettingsOpen } = useSettingsDialog();const isProcessingRef = React.useRef(false);-- // staggered polling with exponential backoff while maintaining responsiveness- // while reducing backend loaduseEffect(() => {- if (settings.user?.token) {- loadUser(settings.user.token);- }+ if (settings.user?.token) {+ loadUser(settings.user.token);+ }}, [settings.user.token]);useEffect(() => {@@ -61,7 +59,7 @@ export default function Home() {updateSettings({ user: { token: apiKey } });toast({title: "logged in!",- description: "your api key has been set",+ description: "you have been logged in",});}}@@ -152,7 +150,7 @@ export default function Home() {const pipeApi = new PipeApi();console.log("audio-devices", devices);await Promise.all(- devices.map((device) => pipeApi.startAudio(device)),+ devices.map((device) => pipeApi.startAudio(device)));toast({title: "audio started",@@ -205,7 +203,7 @@ export default function Home() {useEffect(() => {const checkScreenPermissionRestart = async () => {const restartPending = await localforage.getItem(- "screenPermissionRestartPending",+ "screenPermissionRestartPending");if (restartPending) {setShowOnboarding(true);@@ -228,6 +226,8 @@ export default function Home() {return (<div className="flex flex-col items-center flex-1 max-w-screen-2xl mx-auto relative">+ <LoginDialog />+<NotificationHandler />{showOnboarding ? (<Onboarding />diff --git a/screenpipe-app-tauri/components/cli-command-dialog.tsx b/screenpipe-app-tauri/components/cli-command-dialog.tsxindex 336906e0c..5d726742a 100644--- a/screenpipe-app-tauri/components/cli-command-dialog.tsx+++ b/screenpipe-app-tauri/components/cli-command-dialog.tsx@@ -32,13 +32,41 @@ export function CliCommandDialog({ settings }: CliCommandDialogProps) {setIsWindows(p === "windows");}, []);- const generateCliCommand = () => {+ const generateCliCommand = (+ shell: "cmd" | "powershell" | "bash" = "bash"+ ) => {const cliPath = getCliPath();let envVars = [];let args = [];if (settings.useChineseMirror) {- envVars.push('HF_ENDPOINT="https://hf-mirror.com"');+ envVars.push(+ shell === "cmd"+ ? "SET HF_ENDPOINT=https://hf-mirror.com"+ : 'HF_ENDPOINT="https://hf-mirror.com"'+ );+ }++ // Add AI proxy env vars for screenpipe cloud+ if (+ settings.user.cloud_subscribed &&+ settings.realtimeAudioTranscriptionEngine === "screenpipe-cloud" &&+ settings.userId+ ) {+ const cmdPrefix = shell === "cmd" ? "SET " : "";+ const quoteChar = shell === "cmd" ? "" : '"';+ envVars.push(+ `${cmdPrefix}DEEPGRAM_API_URL=${quoteChar}https://ai-proxy.i-f9f.workers.dev/v1/listen${quoteChar}`+ );+ envVars.push(+ `${cmdPrefix}DEEPGRAM_WEBSOCKET_URL=${quoteChar}wss://ai-proxy.i-f9f.workers.dev${quoteChar}`+ );+ envVars.push(+ `${cmdPrefix}CUSTOM_DEEPGRAM_API_TOKEN=${quoteChar}${settings.userId}${quoteChar}`+ );+ args.push(+ `--deepgram-api-key ${quoteChar}${settings.userId}${quoteChar}`+ );}if (settings.audioTranscriptionEngine !== "default") {@@ -112,8 +140,12 @@ export function CliCommandDialog({ settings }: CliCommandDialogProps) {args.push("--enable-realtime-audio-transcription");}- const envVarsStr = envVars.length > 0 ? `${envVars.join(" ")} ` : "";- return `${envVarsStr}${cliPath} ${args.join(" ")}`;+ const envVarsStr =+ envVars.length > 0+ ? `${envVars.join(shell === "cmd" ? " && " : " ")} `+ : "";+ const cmdPrefix = shell === "cmd" ? "&& " : "";+ return `${envVarsStr}${cmdPrefix}${cliPath} ${args.join(" ")}`;};const handleCopyCliCommand = () => {@@ -147,17 +179,20 @@ export function CliCommandDialog({ settings }: CliCommandDialogProps) {<TabsTrigger value="powershell">powershell</TabsTrigger></TabsList><TabsContent value="cmd">- <CodeBlock language="bash" value={generateCliCommand()} />+ <CodeBlock+ language="bash"+ value={generateCliCommand("cmd")}+ /></TabsContent><TabsContent value="powershell"><CodeBlocklanguage="powershell"- value={generateCliCommand()}+ value={generateCliCommand("powershell")}/></TabsContent></Tabs>) : (- <CodeBlock language="bash" value={generateCliCommand()} />+ <CodeBlock language="bash" value={generateCliCommand("bash")} />)}</div><DialogFooter>diff --git a/screenpipe-app-tauri/components/login-dialog.tsx b/screenpipe-app-tauri/components/login-dialog.tsxindex 767161920..080ccedf1 100644--- a/screenpipe-app-tauri/components/login-dialog.tsx+++ b/screenpipe-app-tauri/components/login-dialog.tsx@@ -1,23 +1,20 @@-import { Button } from '@/components/ui/button';+import { Button } from "@/components/ui/button";import {Dialog,DialogContent,DialogDescription,DialogHeader,DialogTitle,-} from '@/components/ui/dialog';-import { ExternalLinkIcon } from 'lucide-react';-import { open as openUrl } from '@tauri-apps/plugin-shell';-import { useState } from 'react';+} from "@/components/ui/dialog";+import { ExternalLinkIcon } from "lucide-react";+import { open as openUrl } from "@tauri-apps/plugin-shell";+import { create } from "zustand";-interface LoginDialogProps {- open: boolean;- onOpenChange: (open: boolean) => void;-}+export function LoginDialog() {+ const { isOpen, setIsOpen } = useLoginDialog();-export const LoginDialog: React.FC<LoginDialogProps> = ({ open, onOpenChange }) => {return (- <Dialog open={open} onOpenChange={onOpenChange}>+ <Dialog open={isOpen} onOpenChange={setIsOpen}><DialogContent><DialogHeader><DialogTitle>login required</DialogTitle>@@ -25,32 +22,38 @@ export const LoginDialog: React.FC<LoginDialogProps> = ({ open, onOpenChange })please login to continue. you will be redirected to screenpi.pe</DialogDescription></DialogHeader>- <div className='flex justify-end'>+ <div className="flex justify-end"><Button- variant='default'+ variant="default"onClick={() => {- openUrl('https://screenpi.pe/login');- onOpenChange(false);+ openUrl("https://screenpi.pe/login");+ setIsOpen(false);}}>- login <ExternalLinkIcon className='w-4 h-4 ml-2' />+ login <ExternalLinkIcon className="w-4 h-4 ml-2" /></Button></div></DialogContent></Dialog>);-};+}-export const useLoginCheck = () => {- const [showLoginDialog, setShowLoginDialog] = useState(false);+interface LoginDialogState {+ isOpen: boolean;+ setIsOpen: (open: boolean) => void;+ checkLogin: (user: any | null, showDialog?: boolean) => boolean;+}- const checkLogin = (user: any | null, showDialog: boolean = true) => {+export const useLoginDialog = create<LoginDialogState>((set) => ({+ isOpen: false,+ setIsOpen: (open) => set({ isOpen: open }),+ checkLogin: (user, showDialog = true) => {if (!user?.token) {- if (showDialog) setShowLoginDialog(true);+ if (showDialog) {+ set({ isOpen: true });+ }return false;}return true;- };-- return { showLoginDialog, setShowLoginDialog, checkLogin };-};\ No newline at end of file+ },+}));diff --git a/screenpipe-app-tauri/components/onboarding/login.tsx b/screenpipe-app-tauri/components/onboarding/login.tsxindex 1dedf6925..7190b13fa 100644--- a/screenpipe-app-tauri/components/onboarding/login.tsx+++ b/screenpipe-app-tauri/components/onboarding/login.tsx@@ -1,13 +1,9 @@-import React, { useEffect } from "react";-import { ExternalLinkIcon, UserCog, Coins } from "lucide-react";+import React from "react";+import { ExternalLinkIcon, UserCog } from "lucide-react";import { open } from "@tauri-apps/plugin-shell";-import { Input } from "@/components/ui/input";-import { Label } from "@/components/ui/label";import { Button } from "@/components/ui/button";-import { Badge } from "@/components/ui/badge";import { useSettings } from "@/lib/hooks/use-settings";import { toast } from "@/components/ui/use-toast";-import { onOpenUrl } from "@tauri-apps/plugin-deep-link";import OnboardingNavigation from "./navigation";interface OnboardingLoginProps {@@ -21,39 +17,7 @@ const OnboardingLogin: React.FC<OnboardingLoginProps> = ({handlePrevSlide,handleNextSlide,}) => {- const { settings, updateSettings, loadUser } = useSettings();-- useEffect(() => {- const setupDeepLink = async () => {- const unsubscribeDeepLink = await onOpenUrl(async (urls) => {- console.log("urls", urls);- for (const url of urls) {- if (url.includes("api_key=")) {- const apiKey = new URL(url).searchParams.get("api_key");- if (apiKey) {- updateSettings({ user: { token: apiKey } });- await loadUser(apiKey, true);- toast({- title: "logged in!",- description: "your api key has been set",- });- // handleNextSlide();- }- }- }- });- return unsubscribeDeepLink;- };-- let deepLinkUnsubscribe: (() => void) | undefined;- setupDeepLink().then((unsubscribe) => {- deepLinkUnsubscribe = unsubscribe;- });-- return () => {- if (deepLinkUnsubscribe) deepLinkUnsubscribe();- };- }, [settings.user?.token, updateSettings, handleNextSlide]);+ const { settings, updateSettings } = useSettings();return (<div className="w-full h-full flex flex-col items-center justify-center space-y-6 py-4">@@ -67,7 +31,7 @@ const OnboardingLogin: React.FC<OnboardingLoginProps> = ({<div className="p-6 border border-border/50 rounded-lg bg-background/50"><div className="space-y-4">- {settings.user?.email ? (+ {settings.user?.token ? (<p className="text-sm text-muted-foreground flex items-center justify-center gap-2"><span className="inline-flex h-2 w-2 rounded-full bg-green-500" />logged in as {settings.user.email}diff --git a/screenpipe-app-tauri/components/pipe-store.tsx b/screenpipe-app-tauri/components/pipe-store.tsxindex 857f54de4..5f5ef48d6 100644--- a/screenpipe-app-tauri/components/pipe-store.tsx+++ b/screenpipe-app-tauri/components/pipe-store.tsx@@ -5,11 +5,10 @@ import { Switch } from "@/components/ui/switch";import { Loader2, Power, Search, Trash2, RefreshCw } from "lucide-react";import { toast } from "@/components/ui/use-toast";import { useHealthCheck } from "@/lib/hooks/use-health-check";-import { Command } from "@tauri-apps/plugin-shell";import {- PipeApi,- PipeDownloadError,- PurchaseHistoryItem,+ PipeApi,+ PipeDownloadError,+ PurchaseHistoryItem,} from "@/lib/api/store";import { open as openUrl } from "@tauri-apps/plugin-shell";import { listen } from "@tauri-apps/api/event";@@ -21,1096 +20,1096 @@ import { useSettings } from "@/lib/hooks/use-settings";import posthog from "posthog-js";import { Progress } from "./ui/progress";import { open } from "@tauri-apps/plugin-dialog";-import { LoginDialog, useLoginCheck } from "./login-dialog";import { onOpenUrl } from "@tauri-apps/plugin-deep-link";import { useStatusDialog } from "@/lib/hooks/use-status-dialog";import {- Tooltip,- TooltipContent,- TooltipProvider,- TooltipTrigger,+ Tooltip,+ TooltipContent,+ TooltipProvider,+ TooltipTrigger,} from "@/components/ui/tooltip";import localforage from "localforage";+import { useLoginDialog } from "./login-dialog";const corePipes: string[] = ["data-table", "search"];export const PipeStore: React.FC = () => {- const { health } = useHealthCheck();- const [selectedPipe, setSelectedPipe] = useState<PipeWithStatus | null>(null);- const { settings, loadUser } = useSettings();- const [pipes, setPipes] = useState<PipeWithStatus[]>([]);- const [installedPipes, setInstalledPipes] = useState<InstalledPipe[]>([]);- const [searchQuery, setSearchQuery] = useState("");- const [showInstalledOnly, setShowInstalledOnly] = useState(false);- const [purchaseHistory, setPurchaseHistory] = useState<PurchaseHistoryItem[]>(- [],- );- const { showLoginDialog, setShowLoginDialog, checkLogin } = useLoginCheck();- const { open: openStatusDialog } = useStatusDialog();- const [loadingPurchases, setLoadingPurchases] = useState<Set<string>>(- new Set(),- );- const [loadingInstalls, setLoadingInstalls] = useState<Set<string>>(- new Set(),- );-- const filteredPipes = pipes- .filter(- (pipe) =>- pipe.id.toLowerCase().includes(searchQuery.toLowerCase()) &&- (!showInstalledOnly || pipe.is_installed) &&- !pipe.is_installing,- )- .sort((a, b) => Number(b.is_paid) - Number(a.is_paid));-- // Add debounced search tracking- useEffect(() => {- const timeoutId = setTimeout(() => {- if (searchQuery) {- posthog.capture("search_pipes", {- query: searchQuery,- results_count: filteredPipes.length,- });- }- }, 1000); // Debounce for 1 second-- return () => clearTimeout(timeoutId);- }, [searchQuery, filteredPipes.length]);-- useEffect(() => {- const unsubscribePromise = listen("update-all-pipes", async () => {- // not sure this is a good idea ... basically pipes will break in the hand of users when update will happen- if (!checkLogin(settings.user, false)) return;-- for (const pipe of pipes) {- // Then download the new version- await handleUpdatePipe(pipe);- }-- // Refresh the pipe list- await fetchInstalledPipes();- });-- return () => {- unsubscribePromise.then((unsubscribe) => unsubscribe());- };- }, []);-- const fetchStorePlugins = async () => {- try {- const pipeApi = await PipeApi.create(settings.user?.token!);- const plugins = await pipeApi.listStorePlugins();-- // Create PipeWithStatus objects for store plugins- const storePluginsWithStatus = await Promise.all(- plugins.map(async (plugin) => {- const installedPipe = installedPipes.find((p) => {- return p.id?.replace("._temp", "") === plugin.name;- });- return {- ...plugin,- is_installed: !!installedPipe,- installed_config: installedPipe?.config,- has_purchased: purchaseHistory.some(- (p) => p.plugin_id === plugin.id,- ),- is_core_pipe: corePipes.includes(plugin.name),- is_enabled: installedPipe?.config?.enabled ?? false,- has_update: false,- };- }),- );-- const customPipes = installedPipes- .filter(- (p) =>- !plugins.find(- (plugin) => plugin.name === p.id?.replace("._temp", ""),- ),- )- .map((p) => {- const pluginName = p.config?.source?.split("/").pop();- const is_local = p.id.endsWith("_local");- return {- id: p.id || "",- name: pluginName || "",- description: p.desc,- version: p.config?.version || "0.0.0",- is_paid: false,- price: 0,- status: "active",- created_at: new Date().toISOString(),- developer_accounts: { developer_name: "You" },- plugin_analytics: { downloads_count: 0 },- is_installed: true,- installed_config: p.config,- has_purchased: true,- is_core_pipe: false,- is_enabled: p.config?.enabled || false,- source_code: p.config?.source || "",- is_local,- };- });-- setPipes([...storePluginsWithStatus, ...customPipes]);- } catch (error) {- console.warn("Failed to fetch store plugins:", error);- }- };-- const fetchPurchaseHistory = async () => {- if (!settings.user?.token) return;- const pipeApi = await PipeApi.create(settings.user!.token!);- const purchaseHistory = await pipeApi.getUserPurchaseHistory();- setPurchaseHistory(purchaseHistory);- };-- const handlePurchasePipe = async (- pipe: PipeWithStatus,- onComplete?: () => void,- ) => {- try {- if (!checkLogin(settings.user)) return;-- setLoadingPurchases((prev) => new Set(prev).add(pipe.id));-- const pipeApi = await PipeApi.create(settings.user!.token!);- const response = await pipeApi.purchasePipe(pipe.id);-- if (response.data.payment_successful) {- await handleInstallPipe(pipe);- toast({- title: "purchase & install successful",- description: "payment processed with saved card",- });- } else if (response.data.already_purchased) {- await handleInstallPipe(pipe);- toast({- title: "pipe already purchased",- description: "installing pipe...",- });- } else if (response.data.used_credits) {- await handleInstallPipe(pipe);- toast({- title: "purchase & install successful",- description: "your pipe has been purchased and installed",- });- } else if (response.data.checkout_url) {- openUrl(response.data.checkout_url);- toast({- title: "redirecting to checkout",- description: "you'll be able to install the pipe after purchase",- });- }- onComplete?.();- } catch (error) {- console.error("error purchasing pipe:", error);- toast({- title: "error purchasing pipe",- description: "please try again or check the logs",- variant: "destructive",- });- } finally {- setLoadingPurchases((prev) => {- const next = new Set(prev);- next.delete(pipe.id);- return next;- });- }- };-- const handleInstallSideload = async (url: string) => {- posthog.capture("add_own_pipe", {- newRepoUrl: url,- });- try {- const t = toast({- title: "adding custom pipe",- description: (- <div className="space-y-2">- <Progress value={0} className="h-1" />- <p className="text-xs">starting installation...</p>- </div>- ),- duration: 100000,- });- let value = 0;-- const progressInterval = setInterval(() => {- value += 3;- t.update({- id: t.id,- title: "adding custom pipe",- description: (- <div className="space-y-2">- <Progress value={value} className="h-1" />- <p className="text-xs">installing dependencies...</p>- </div>- ),- duration: 100000,- });- }, 500);-- const response = await fetch("http://localhost:3030/pipes/download", {- method: "POST",- headers: {- "Content-Type": "application/json",- },- body: JSON.stringify({ url: url }),- });-- const data = await response.json();-- clearInterval(progressInterval);-- if (!data.success) {- throw new Error(data.error || "Failed to download pipe");- }-- t.update({- id: t.id,- title: "pipe added",- description: (- <div className="space-y-2">- <Progress value={100} className="h-1" />- <p className="text-xs">completed successfully</p>- </div>- ),- duration: 2000,- });-- await fetchInstalledPipes();-- t.dismiss();- } catch (error) {- console.error("failed to add custom pipe:", error);- toast({- title: "error adding custom pipe",- description: "please check the url and try again.",- variant: "destructive",- });- }- };-- const handleInstallPipe = async (- pipe: PipeWithStatus,- onComplete?: () => void,- ) => {- try {- if (!checkLogin(settings.user)) return;-- // Keep the pipe in its current position by updating its status- setPipes((prevPipes) =>- prevPipes.map((p) =>- p.id === pipe.id ? { ...p, is_installing: true } : p,- ),- );-- setLoadingInstalls((prev) => new Set(prev).add(pipe.id));-- const t = toast({- title: "creating pipe",- description: (- <div className="space-y-2">- <Progress value={0} className="h-1" />- <p className="text-xs">creating pipe...</p>- </div>- ),- duration: 10000,- });-- const pipeApi = await PipeApi.create(settings.user!.token!);- const response = await pipeApi.downloadPipe(pipe.id);-- const downloadResponse = await fetch(- "http://localhost:3030/pipes/download-private",- {- method: "POST",- headers: {- "Content-Type": "application/json",- },- body: JSON.stringify({- pipe_name: pipe.name,- pipe_id: pipe.id,- url: response.download_url,- }),- },- );-- const data = await downloadResponse.json();- if (!data.success) {- throw new Error(data.error || "Failed to download pipe");- }-- await fetchInstalledPipes();-- // Update the pipe's status after successful installation- setPipes((prevPipes) =>- prevPipes.map((p) =>- p.id === pipe.id- ? {- ...p,- is_installed: true,- is_installing: false,- }- : p,- ),- );-- onComplete?.();- t.dismiss();- } catch (error) {- // Reset the pipe's status on error- setPipes((prevPipes) =>- prevPipes.map((p) =>- p.id === pipe.id ? { ...p, is_installing: false } : p,- ),- );- if ((error as Error).cause === PipeDownloadError.PURCHASE_REQUIRED) {- return toast({- title: "paid pipe",- description:- "this pipe requires purchase. please visit screenpi.pe to buy credits.",- variant: "destructive",- });- }- toast({- title: "error installing pipe",- description: (error as Error).message,- variant: "destructive",- });- } finally {- setLoadingInstalls((prev) => {- const next = new Set(prev);- next.delete(pipe.id);- return next;- });- }- };-- const fetchInstalledPipes = async () => {- if (!health || health?.status === "error") return;- try {- const response = await fetch("http://localhost:3030/pipes/list");- const data = (await response.json()) as {- data: InstalledPipe[];- success: boolean;- };-- if (!data.success) throw new Error("Failed to fetch installed pipes");-- setInstalledPipes(data.data);- return data.data;- } catch (error) {- console.error("Error fetching installed pipes:", error);- toast({- title: "error fetching installed pipes",- description: "please try again or check the logs",- variant: "destructive",- });- }- };-- const handleResetAllPipes = async () => {- try {- const t = toast({- title: "resetting pipes",- description: (- <div className="space-y-2">- <Progress value={0} className="h-1" />- <p className="text-xs">deleting all pipes...</p>- </div>- ),- duration: 100000,- });-- const response = await fetch(`http://localhost:3030/pipes/purge`, {- method: "POST",- headers: { "Content-Type": "application/json" },- body: JSON.stringify({}),- });- if (!response.ok) {- toast({- title: "failed to purge pipes",- description: "failed to purge pipes, please try again",- variant: "destructive",- });- return;- }- await fetchInstalledPipes();-- t.update({- id: t.id,- title: "pipes reset",- description: (- <div className="space-y-2">- <Progress value={100} className="h-1" />- <p className="text-xs">all pipes have been deleted</p>- </div>- ),- duration: 2000,- });- } catch (error) {- console.error("failed to reset pipes:", error);- toast({- title: "error resetting pipes",- description: "please try again or check the logs",- variant: "destructive",- });- }- };-- const handleUpdateAllPipes = async (delayToast: boolean = false) => {- try {- if (!checkLogin(settings.user)) return;-- let t;- if (!delayToast) {- t = toast({- title: "checking for updates",- description: (- <div className="space-y-2">- <Progress value={0} className="h-1" />- <p className="text-xs">checking installed pipes...</p>- </div>- ),- duration: 100000,- });- }-- // Filter installed pipes that have updates available- const pipesToUpdate = pipes.filter(- (pipe) => pipe.is_installed && pipe.has_update,- );-- if (pipesToUpdate.length === 0) {- if (t) {- t.update({- id: t.id,- title: "no updates available",- description: "all pipes are up to date",- duration: 2000,- });- }- return;- }-- // Update progress message- if (t) {- t.update({- id: t.id,- title: `updating ${pipesToUpdate.length} pipes`,- description: (- <div className="space-y-2">- <Progress value={0} className="h-1" />- <p className="text-xs">starting updates...</p>- </div>- ),- duration: 100000,- });- } else {- t = toast({- title: `updating ${pipesToUpdate.length} pipes`,- description: (- <div className="space-y-2">- <Progress value={0} className="h-1" />- <p className="text-xs">starting updates...</p>- </div>- ),- duration: 100000,- });- }-- // Update each pipe sequentially- for (let i = 0; i < pipesToUpdate.length; i++) {- const pipe = pipesToUpdate[i];- const progress = Math.round((i / pipesToUpdate.length) * 100);-- t.update({- id: t.id,- title: `updating pipes (${i + 1}/${pipesToUpdate.length})`,- description: (- <div className="space-y-2">- <Progress value={progress} className="h-1" />- <p className="text-xs">updating {pipe.name}...</p>- </div>- ),- duration: 100000,- });-- await handleUpdatePipe(pipe);- }-- t.update({- id: t.id,- title: "all pipes updated",- description: (- <div className="space-y-2">- <Progress value={100} className="h-1" />- <p className="text-xs">completed successfully</p>- </div>- ),- duration: 2000,- });- } catch (error) {- console.error("failed to update all pipes:", error);- toast({- title: "error updating pipes",- description: "please try again or check the logs",- variant: "destructive",- });- }- };-- const handleTogglePipe = async (- pipe: PipeWithStatus,- onComplete: () => void,- ) => {- try {- const t = toast({- title: "loading pipe",- description: "please wait...",- action: (- <div className="flex items-center">- <Loader2 className="h-4 w-4 animate-spin" />- </div>- ),- duration: 4000,- });-- const endpoint = pipe.installed_config?.enabled ? "disable" : "enable";- console.log("toggel", pipe, endpoint);-- const id = pipe.is_local ? pipe.id : pipe.name;- const response = await fetch(`http://localhost:3030/pipes/${endpoint}`, {- method: "POST",- headers: {- "Content-Type": "application/json",- },- body: JSON.stringify({ pipe_id: id }),- });-- const data = await response.json();- if (!data.success) {- throw new Error(data.error);- }-- toast({- title: `pipe ${endpoint}d`,- });- const installedPipes = await fetchInstalledPipes();- console.log("installed Pipes", installedPipes);- const pp = installedPipes?.find((p) => p.config.id === pipe.id);- const port = pp?.config.port;-- setSelectedPipe((prev) => {- if (!prev) return prev;- return {- ...prev,- installed_config: {- port,- ...prev.installed_config!,- enabled: !pipe.installed_config?.enabled,- buildStatus: "in_progress",- },- };- });- onComplete();- } catch (error) {- console.error(- `Failed to ${- pipe.installed_config?.enabled ? "disable" : "enable"- } pipe:`,- error,- );- toast({- title: "error toggling pipe",- description: "please try again or check the logs for more information.",- variant: "destructive",- });- }- };-- const handleLoadFromLocalFolder = async (- setNewRepoUrl: (url: string) => void,- ) => {- try {- const selectedFolder = await open({- directory: true,- multiple: false,- });-- if (selectedFolder) {- console.log("loading from local folder", selectedFolder);- // set in the bar- setNewRepoUrl(selectedFolder);- }- } catch (error) {- console.error("failed to load pipe from local folder:", error);- toast({- title: "error loading pipe",- description: "please try again or check the logs for more information.",- variant: "destructive",- });- }- };-- const handleConfigSave = async (config: Record<string, any>) => {- if (selectedPipe) {- try {- const id = selectedPipe.is_local ? selectedPipe.id : selectedPipe.name;- const response = await fetch("http://localhost:3030/pipes/update", {- method: "POST",- headers: {- "Content-Type": "application/json",- },- body: JSON.stringify({- pipe_id: id,- config: config,- }),- });-- const data = await response.json();- if (!data.success) {- throw new Error(data.error || "Failed to update pipe configuration");- }-- toast({- title: "Configuration saved",- description: "The pipe configuration has been updated.",- });-- setSelectedPipe({- ...selectedPipe,- installed_config: {- ...selectedPipe.installed_config!,- ...config,- },- });- } catch (error) {- console.error("Failed to save config:", error);- toast({- title: "error saving configuration",- description:- "please try again or check the logs for more information.",- variant: "destructive",- });- }- }- };- const handleDeletePipe = async (pipe: PipeWithStatus) => {- try {- toast({- title: "deleting pipe",- description: "please wait...",- });- setSelectedPipe(null);-- const id = pipe.is_local ? pipe.id : pipe.name;- const response = await fetch("http://localhost:3030/pipes/delete", {- method: "POST",- headers: {- "Content-Type": "application/json",- },- body: JSON.stringify({ pipe_id: id }),- });-- const data = await response.json();- if (!data.success) {- throw new Error(data.error);- }-- // First unselect the pipe, then fetch the updated list- await fetchInstalledPipes();-- toast({- title: "pipe deleted",- description: "the pipe has been successfully removed",- });-- setSelectedPipe(null);- } catch (error) {- console.error("failed to delete pipe:", error);- toast({- title: "error deleting pipe",- description: "please try again or check the logs for more information.",- variant: "destructive",- });- }- };-- const handleRefreshFromDisk = async (pipe: PipeWithStatus) => {- try {- toast({- title: "refreshing pipe",- description: "please wait...",- });-- const response = await fetch(`http://localhost:3030/pipes/download`, {- method: "POST",- headers: {- "Content-Type": "application/json",- },- body: JSON.stringify({ url: pipe.installed_config?.source }),- });- if (!response.ok) {- throw new Error("failed to refresh pipe");- }-- await fetchInstalledPipes();- toast({- title: "pipe refreshed",- description: "the pipe has been successfully refreshed from disk.",- });- } catch (error) {- console.error("failed to refresh pipe from disk:", error);- toast({- title: "error refreshing pipe",- description: "please try again or check the logs for more information.",- variant: "destructive",- });- } finally {- setSelectedPipe(null);- }- };-- const handleUpdatePipe = async (pipe: PipeWithStatus) => {- try {- if (!checkLogin(settings.user)) return;-- const currentVersion = pipe.installed_config?.version!;- const storeApi = await PipeApi.create(settings.user!.token!);- const update = await storeApi.checkUpdate(pipe.id, currentVersion);- if (!update.has_update) {- toast({- title: "no update available",- description: "the pipe is already up to date",- });- return;- }-- const t = toast({- title: "updating pipe",- description: (- <div className="space-y-2">- <Progress value={25} className="h-1" />- <p className="text-xs">checking for updates...</p>- </div>- ),- duration: 100000,- });-- // Update progress for download start- t.update({- id: t.id,- description: (- <div className="space-y-2">- <Progress value={50} className="h-1" />- <p className="text-xs">downloading update...</p>- </div>- ),- });-- const responseDownload = await storeApi.downloadPipe(pipe.id);-- // Update progress for installation- t.update({- id: t.id,- description: (- <div className="space-y-2">- <Progress value={75} className="h-1" />- <p className="text-xs">installing update...</p>- </div>- ),- });-- const response = await fetch(- `http://localhost:3030/pipes/update-version`,- {- method: "POST",- headers: {- "Content-Type": "application/json",- },- body: JSON.stringify({- pipe_id: pipe.name,- source: responseDownload.download_url,- }),- },- );-- const data = await response.json();- if (!data.success) {- throw new Error(data.error);- }-- // Update progress for completion- t.update({- id: t.id,- title: "pipe updated",- description: (- <div className="space-y-2">- <Progress value={100} className="h-1" />- <p className="text-xs">completed successfully</p>- </div>- ),- duration: 2000,- });-- await fetchInstalledPipes();-- t.dismiss();- } catch (error) {- console.error("failed to update pipe:", error);- toast({- title: "error updating pipe",- description: "please try again or check the logs for more information.",- variant: "destructive",- });- }- };-- useEffect(() => {- fetchStorePlugins();- }, [installedPipes, purchaseHistory]);-- useEffect(() => {- fetchPurchaseHistory();- }, [settings.user.token]);-- useEffect(() => {- fetchInstalledPipes();- }, [health]);-- useEffect(() => {- const interval = setInterval(() => {- fetchInstalledPipes();- }, 3000);- return () => clearInterval(interval);- }, []);-- useEffect(() => {- const checkForUpdates = async () => {- if (!settings.user.token) {- return;- }- // Get last check time from local storage- const lastCheckTime =- await localforage.getItem<number>("lastUpdateCheck");- const now = Date.now();-- // Check if 5 minutes have passed since last check- if (lastCheckTime && now - lastCheckTime < 5 * 60 * 1000) {- return;- }-- // Store current time as last check- await localforage.setItem("lastUpdateCheck", now);-- const installedPipes = pipes.filter((pipe) => pipe.is_installed);-- const storeApi = await PipeApi.create(settings.user.token);- for (const pipe of installedPipes) {- const update = await storeApi.checkUpdate(- pipe.id,- pipe.installed_config?.version!,- );- if (update.has_update) {- await handleUpdatePipe(pipe);- }- }- };-- // Run check immediately- checkForUpdates();-- // Set up interval to check every 10 seconds actual check is done in the function- const interval = setInterval(checkForUpdates, 10 * 1000);-- return () => clearInterval(interval);- }, [settings.user.token]);-- useEffect(() => {- const setupDeepLink = async () => {- const unsubscribeDeepLink = await onOpenUrl(async (urls) => {- console.log("received deep link urls:", urls);- for (const url of urls) {- if (url.includes("purchase-successful")) {- const urlObj = new URL(url);- const pipeId = urlObj.searchParams.get("pipe_id");-- if (!pipeId) {- toast({- title: "purchase successful",- description: "your purchase was successful",- });- return;- }-- await new Promise((resolve) => setTimeout(resolve, 1000));-- // First update purchase history to reflect the new purchase- await fetchPurchaseHistory();-- // Find the pipe in the store- const purchasedPipe = pipes.find((pipe) => pipe.id === pipeId);- if (!purchasedPipe) {- toast({- title: "error installing pipe",- description: "could not find the purchased pipe",- variant: "destructive",- });- return;- }-- // Install the pipe- await handleInstallPipe(purchasedPipe);- }- }- });- return unsubscribeDeepLink;- };-- let deepLinkUnsubscribe: (() => void) | undefined;-- setupDeepLink().then((unsubscribe) => {- deepLinkUnsubscribe = unsubscribe;- });- return () => {- if (deepLinkUnsubscribe) deepLinkUnsubscribe();- };- }, [pipes]);-- if (health?.status === "error") {- return (- <div className="flex flex-col items-center justify-center h-screen p-4 space-y-4">- <div className="text-center space-y-4">- <h3 className="text-lg font-medium">screenpipe is not recording</h3>- <p className="text-sm text-muted-foreground">- please start the screenpipe service to browse and manage pipes- </p>- <Button- variant="outline"- onClick={openStatusDialog}- className="gap-2"- >- <Power className="h-4 w-4" />- check service status- </Button>- </div>- </div>- );- }-- if (selectedPipe) {- return (- <PipeDetails- pipe={selectedPipe}- onClose={() => setSelectedPipe(null)}- onToggle={handleTogglePipe}- onConfigSave={handleConfigSave}- onDelete={handleDeletePipe}- onRefreshFromDisk={handleRefreshFromDisk}- onUpdate={handleUpdatePipe}- />- );- }-- return (- <div className="overflow-hidden flex flex-col space-y-4 min-w-[800px]">- <div className="flex flex-col flex-1 overflow-hidden space-y-4 p-4 min-w-[800px]">- <div className="space-y-4 min-w-[800px]">- <div className="flex flex-col gap-4 w-[50%]">- <div className="flex-1 relative">- <Search className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400" />- <Input- placeholder="search community pipes..."- value={searchQuery}- onChange={(e) => setSearchQuery(e.target.value)}- className="pl-9"- autoCorrect="off"- autoComplete="off"- />- </div>- <div className="flex items-center gap-2">- <span className="text-sm text-gray-600">show installed only</span>- <Switch- checked={showInstalledOnly}- onCheckedChange={setShowInstalledOnly}- />- <TooltipProvider>- <Tooltip>- <TooltipTrigger asChild>- <Button- variant="outline"- size="icon"- onClick={handleResetAllPipes}- className="flex items-center gap-2"- >- <Trash2 className="h-4 w-4" />- </Button>- </TooltipTrigger>- <TooltipContent>- <p>reset all pipes</p>- </TooltipContent>- </Tooltip>- </TooltipProvider>- <TooltipProvider>- <Tooltip>- <TooltipTrigger asChild>- <Button- variant="outline"- size="icon"- onClick={() => handleUpdateAllPipes()}- className="flex items-center gap-2"- disabled={- !pipes.some(- (pipe) => pipe.is_installed && pipe.has_update,- )- }- >- <RefreshCw className="h-4 w-4" />- </Button>- </TooltipTrigger>- <TooltipContent>- <p>update all pipes</p>- </TooltipContent>- </Tooltip>- </TooltipProvider>- </div>- </div>- </div>-- <div className="flex-1 overflow-y-auto">- <div className="grid grid-cols-2 gap-4">- {filteredPipes.map((pipe) => (- <PipeCard- key={pipe.id}- pipe={pipe}- setPipe={(updatedPipe) => {- setPipes((prevPipes) => {- return prevPipes.map((p) =>- p.id === updatedPipe.id ? updatedPipe : p,- );- });- }}- onInstall={handleInstallPipe}- onClick={setSelectedPipe}- onPurchase={handlePurchasePipe}- isLoadingPurchase={loadingPurchases.has(pipe.id)}- isLoadingInstall={loadingInstalls.has(pipe.id)}- onToggle={handleTogglePipe}- />- ))}- </div>- </div>-- <AddPipeForm- onAddPipe={handleInstallSideload}- isHealthy={health?.status !== "error"}- onLoadFromLocalFolder={handleLoadFromLocalFolder}- />- </div>- <LoginDialog open={showLoginDialog} onOpenChange={setShowLoginDialog} />- </div>- );+ const { health } = useHealthCheck();+ const [selectedPipe, setSelectedPipe] = useState<PipeWithStatus | null>(null);+ const { settings, loadUser } = useSettings();+ const [pipes, setPipes] = useState<PipeWithStatus[]>([]);+ const [installedPipes, setInstalledPipes] = useState<InstalledPipe[]>([]);+ const [searchQuery, setSearchQuery] = useState("");+ const [showInstalledOnly, setShowInstalledOnly] = useState(false);+ const [purchaseHistory, setPurchaseHistory] = useState<PurchaseHistoryItem[]>(+ []+ );+ const { checkLogin } = useLoginDialog();+ const { open: openStatusDialog } = useStatusDialog();+ const [loadingPurchases, setLoadingPurchases] = useState<Set<string>>(+ new Set()+ );+ const [loadingInstalls, setLoadingInstalls] = useState<Set<string>>(+ new Set()+ );++ const filteredPipes = pipes+ .filter(+ (pipe) =>+ pipe.id.toLowerCase().includes(searchQuery.toLowerCase()) &&+ (!showInstalledOnly || pipe.is_installed) &&+ !pipe.is_installing+ )+ .sort((a, b) => Number(b.is_paid) - Number(a.is_paid));++ // Add debounced search tracking+ useEffect(() => {+ const timeoutId = setTimeout(() => {+ if (searchQuery) {+ posthog.capture("search_pipes", {+ query: searchQuery,+ results_count: filteredPipes.length,+ });+ }+ }, 1000); // Debounce for 1 second++ return () => clearTimeout(timeoutId);+ }, [searchQuery, filteredPipes.length]);++ useEffect(() => {+ const unsubscribePromise = listen("update-all-pipes", async () => {+ // not sure this is a good idea ... basically pipes will break in the hand of users when update will happen+ if (!checkLogin(settings.user, false)) return;++ for (const pipe of pipes) {+ // Then download the new version+ await handleUpdatePipe(pipe);+ }++ // Refresh the pipe list+ await fetchInstalledPipes();+ });++ return () => {+ unsubscribePromise.then((unsubscribe) => unsubscribe());+ };+ }, []);++ const fetchStorePlugins = async () => {+ try {+ const pipeApi = await PipeApi.create(settings.user?.token!);+ const plugins = await pipeApi.listStorePlugins();++ // Create PipeWithStatus objects for store plugins+ const storePluginsWithStatus = await Promise.all(+ plugins.map(async (plugin) => {+ const installedPipe = installedPipes.find((p) => {+ return p.id?.replace("._temp", "") === plugin.name;+ });+ return {+ ...plugin,+ is_installed: !!installedPipe,+ installed_config: installedPipe?.config,+ has_purchased: purchaseHistory.some(+ (p) => p.plugin_id === plugin.id+ ),+ is_core_pipe: corePipes.includes(plugin.name),+ is_enabled: installedPipe?.config?.enabled ?? false,+ has_update: false,+ };+ })+ );++ const customPipes = installedPipes+ .filter(+ (p) =>+ !plugins.find(+ (plugin) => plugin.name === p.id?.replace("._temp", "")+ )+ )+ .map((p) => {+ const pluginName = p.config?.source?.split("/").pop();+ const is_local = p.id.endsWith("_local");+ return {+ id: p.id || "",+ name: pluginName || "",+ description: p.desc,+ version: p.config?.version || "0.0.0",+ is_paid: false,+ price: 0,+ status: "active",+ created_at: new Date().toISOString(),+ developer_accounts: { developer_name: "You" },+ plugin_analytics: { downloads_count: 0 },+ is_installed: true,+ installed_config: p.config,+ has_purchased: true,+ is_core_pipe: false,+ is_enabled: p.config?.enabled || false,+ source_code: p.config?.source || "",+ is_local,+ };+ });++ setPipes([...storePluginsWithStatus, ...customPipes]);+ } catch (error) {+ console.warn("Failed to fetch store plugins:", error);+ }+ };++ const fetchPurchaseHistory = async () => {+ if (!settings.user?.token) return;+ const pipeApi = await PipeApi.create(settings.user!.token!);+ const purchaseHistory = await pipeApi.getUserPurchaseHistory();+ setPurchaseHistory(purchaseHistory);+ };++ const handlePurchasePipe = async (+ pipe: PipeWithStatus,+ onComplete?: () => void+ ) => {+ try {+ if (!checkLogin(settings.user)) return;++ setLoadingPurchases((prev) => new Set(prev).add(pipe.id));++ const pipeApi = await PipeApi.create(settings.user!.token!);+ const response = await pipeApi.purchasePipe(pipe.id);++ if (response.data.payment_successful) {+ await handleInstallPipe(pipe);+ toast({+ title: "purchase & install successful",+ description: "payment processed with saved card",+ });+ } else if (response.data.already_purchased) {+ await handleInstallPipe(pipe);+ toast({+ title: "pipe already purchased",+ description: "installing pipe...",+ });+ } else if (response.data.used_credits) {+ await handleInstallPipe(pipe);+ toast({+ title: "purchase & install successful",+ description: "your pipe has been purchased and installed",+ });+ } else if (response.data.checkout_url) {+ openUrl(response.data.checkout_url);+ toast({+ title: "redirecting to checkout",+ description: "you'll be able to install the pipe after purchase",+ });+ }+ onComplete?.();+ } catch (error) {+ console.error("error purchasing pipe:", error);+ toast({+ title: "error purchasing pipe",+ description: "please try again or check the logs",+ variant: "destructive",+ });+ } finally {+ setLoadingPurchases((prev) => {+ const next = new Set(prev);+ next.delete(pipe.id);+ return next;+ });+ }+ };++ const handleInstallSideload = async (url: string) => {+ posthog.capture("add_own_pipe", {+ newRepoUrl: url,+ });+ try {+ const t = toast({+ title: "adding custom pipe",+ description: (+ <div className="space-y-2">+ <Progress value={0} className="h-1" />+ <p className="text-xs">starting installation...</p>+ </div>+ ),+ duration: 100000,+ });+ let value = 0;++ const progressInterval = setInterval(() => {+ value += 3;+ t.update({+ id: t.id,+ title: "adding custom pipe",+ description: (+ <div className="space-y-2">+ <Progress value={value} className="h-1" />+ <p className="text-xs">installing dependencies...</p>+ </div>+ ),+ duration: 100000,+ });+ }, 500);++ const response = await fetch("http://localhost:3030/pipes/download", {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ body: JSON.stringify({ url: url }),+ });++ const data = await response.json();++ clearInterval(progressInterval);++ if (!data.success) {+ throw new Error(data.error || "Failed to download pipe");+ }++ t.update({+ id: t.id,+ title: "pipe added",+ description: (+ <div className="space-y-2">+ <Progress value={100} className="h-1" />+ <p className="text-xs">completed successfully</p>+ </div>+ ),+ duration: 2000,+ });++ await fetchInstalledPipes();++ t.dismiss();+ } catch (error) {+ console.error("failed to add custom pipe:", error);+ toast({+ title: "error adding custom pipe",+ description: "please check the url and try again.",+ variant: "destructive",+ });+ }+ };++ const handleInstallPipe = async (+ pipe: PipeWithStatus,+ onComplete?: () => void+ ) => {+ try {+ if (!checkLogin(settings.user)) return;++ // Keep the pipe in its current position by updating its status+ setPipes((prevPipes) =>+ prevPipes.map((p) =>+ p.id === pipe.id ? { ...p, is_installing: true } : p+ )+ );++ setLoadingInstalls((prev) => new Set(prev).add(pipe.id));++ const t = toast({+ title: "creating pipe",+ description: (+ <div className="space-y-2">+ <Progress value={0} className="h-1" />+ <p className="text-xs">creating pipe...</p>+ </div>+ ),+ duration: 10000,+ });++ const pipeApi = await PipeApi.create(settings.user!.token!);+ const response = await pipeApi.downloadPipe(pipe.id);++ const downloadResponse = await fetch(+ "http://localhost:3030/pipes/download-private",+ {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ body: JSON.stringify({+ pipe_name: pipe.name,+ pipe_id: pipe.id,+ url: response.download_url,+ }),+ }+ );++ const data = await downloadResponse.json();+ if (!data.success) {+ throw new Error(data.error || "Failed to download pipe");+ }++ await fetchInstalledPipes();++ // Update the pipe's status after successful installation+ setPipes((prevPipes) =>+ prevPipes.map((p) =>+ p.id === pipe.id+ ? {+ ...p,+ is_installed: true,+ is_installing: false,+ }+ : p+ )+ );++ onComplete?.();+ t.dismiss();+ } catch (error) {+ // Reset the pipe's status on error+ setPipes((prevPipes) =>+ prevPipes.map((p) =>+ p.id === pipe.id ? { ...p, is_installing: false } : p+ )+ );+ if ((error as Error).cause === PipeDownloadError.PURCHASE_REQUIRED) {+ return toast({+ title: "paid pipe",+ description:+ "this pipe requires purchase. please visit screenpi.pe to buy credits.",+ variant: "destructive",+ });+ }+ toast({+ title: "error installing pipe",+ description: (error as Error).message,+ variant: "destructive",+ });+ } finally {+ setLoadingInstalls((prev) => {+ const next = new Set(prev);+ next.delete(pipe.id);+ return next;+ });+ }+ };++ const fetchInstalledPipes = async () => {+ if (!health || health?.status === "error") return;+ try {+ const response = await fetch("http://localhost:3030/pipes/list");+ const data = (await response.json()) as {+ data: InstalledPipe[];+ success: boolean;+ };++ if (!data.success) throw new Error("Failed to fetch installed pipes");++ setInstalledPipes(data.data);+ return data.data;+ } catch (error) {+ console.error("Error fetching installed pipes:", error);+ toast({+ title: "error fetching installed pipes",+ description: "please try again or check the logs",+ variant: "destructive",+ });+ }+ };++ const handleResetAllPipes = async () => {+ try {+ const t = toast({+ title: "resetting pipes",+ description: (+ <div className="space-y-2">+ <Progress value={0} className="h-1" />+ <p className="text-xs">deleting all pipes...</p>+ </div>+ ),+ duration: 100000,+ });++ const response = await fetch(`http://localhost:3030/pipes/purge`, {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({}),+ });+ if (!response.ok) {+ toast({+ title: "failed to purge pipes",+ description: "failed to purge pipes, please try again",+ variant: "destructive",+ });+ return;+ }+ await fetchInstalledPipes();++ t.update({+ id: t.id,+ title: "pipes reset",+ description: (+ <div className="space-y-2">+ <Progress value={100} className="h-1" />+ <p className="text-xs">all pipes have been deleted</p>+ </div>+ ),+ duration: 2000,+ });+ } catch (error) {+ console.error("failed to reset pipes:", error);+ toast({+ title: "error resetting pipes",+ description: "please try again or check the logs",+ variant: "destructive",+ });+ }+ };++ const handleUpdateAllPipes = async (delayToast: boolean = false) => {+ try {+ if (!checkLogin(settings.user)) return;++ let t;+ if (!delayToast) {+ t = toast({+ title: "checking for updates",+ description: (+ <div className="space-y-2">+ <Progress value={0} className="h-1" />+ <p className="text-xs">checking installed pipes...</p>+ </div>+ ),+ duration: 100000,+ });+ }++ // Filter installed pipes that have updates available+ const pipesToUpdate = pipes.filter(+ (pipe) => pipe.is_installed && pipe.has_update+ );++ if (pipesToUpdate.length === 0) {+ if (t) {+ t.update({+ id: t.id,+ title: "no updates available",+ description: "all pipes are up to date",+ duration: 2000,+ });+ }+ return;+ }++ // Update progress message+ if (t) {+ t.update({+ id: t.id,+ title: `updating ${pipesToUpdate.length} pipes`,+ description: (+ <div className="space-y-2">+ <Progress value={0} className="h-1" />+ <p className="text-xs">starting updates...</p>+ </div>+ ),+ duration: 100000,+ });+ } else {+ t = toast({+ title: `updating ${pipesToUpdate.length} pipes`,+ description: (+ <div className="space-y-2">+ <Progress value={0} className="h-1" />+ <p className="text-xs">starting updates...</p>+ </div>+ ),+ duration: 100000,+ });+ }++ // Update each pipe sequentially+ for (let i = 0; i < pipesToUpdate.length; i++) {+ const pipe = pipesToUpdate[i];+ const progress = Math.round((i / pipesToUpdate.length) * 100);++ t.update({+ id: t.id,+ title: `updating pipes (${i + 1}/${pipesToUpdate.length})`,+ description: (+ <div className="space-y-2">+ <Progress value={progress} className="h-1" />+ <p className="text-xs">updating {pipe.name}...</p>+ </div>+ ),+ duration: 100000,+ });++ await handleUpdatePipe(pipe);+ }++ t.update({+ id: t.id,+ title: "all pipes updated",+ description: (+ <div className="space-y-2">+ <Progress value={100} className="h-1" />+ <p className="text-xs">completed successfully</p>+ </div>+ ),+ duration: 2000,+ });+ } catch (error) {+ console.error("failed to update all pipes:", error);+ toast({+ title: "error updating pipes",+ description: "please try again or check the logs",+ variant: "destructive",+ });+ }+ };++ const handleTogglePipe = async (+ pipe: PipeWithStatus,+ onComplete: () => void+ ) => {+ try {+ const t = toast({+ title: "loading pipe",+ description: "please wait...",+ action: (+ <div className="flex items-center">+ <Loader2 className="h-4 w-4 animate-spin" />+ </div>+ ),+ duration: 4000,+ });++ const endpoint = pipe.installed_config?.enabled ? "disable" : "enable";+ console.log("toggel", pipe, endpoint);++ const id = pipe.is_local ? pipe.id : pipe.name;+ const response = await fetch(`http://localhost:3030/pipes/${endpoint}`, {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ body: JSON.stringify({ pipe_id: id }),+ });++ const data = await response.json();+ if (!data.success) {+ throw new Error(data.error);+ }++ toast({+ title: `pipe ${endpoint}d`,+ });+ const installedPipes = await fetchInstalledPipes();+ console.log("installed Pipes", installedPipes);+ const pp = installedPipes?.find((p) => p.config.id === pipe.id);+ const port = pp?.config.port;++ setSelectedPipe((prev) => {+ if (!prev) return prev;+ return {+ ...prev,+ installed_config: {+ port,+ ...prev.installed_config!,+ enabled: !pipe.installed_config?.enabled,+ buildStatus: "in_progress",+ },+ };+ });+ onComplete();+ } catch (error) {+ console.error(+ `Failed to ${+ pipe.installed_config?.enabled ? "disable" : "enable"+ } pipe:`,+ error+ );+ toast({+ title: "error toggling pipe",+ description: "please try again or check the logs for more information.",+ variant: "destructive",+ });+ }+ };++ const handleLoadFromLocalFolder = async (+ setNewRepoUrl: (url: string) => void+ ) => {+ try {+ const selectedFolder = await open({+ directory: true,+ multiple: false,+ });++ if (selectedFolder) {+ console.log("loading from local folder", selectedFolder);+ // set in the bar+ setNewRepoUrl(selectedFolder);+ }+ } catch (error) {+ console.error("failed to load pipe from local folder:", error);+ toast({+ title: "error loading pipe",+ description: "please try again or check the logs for more information.",+ variant: "destructive",+ });+ }+ };++ const handleConfigSave = async (config: Record<string, any>) => {+ if (selectedPipe) {+ try {+ const id = selectedPipe.is_local ? selectedPipe.id : selectedPipe.name;+ const response = await fetch("http://localhost:3030/pipes/update", {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ body: JSON.stringify({+ pipe_id: id,+ config: config,+ }),+ });++ const data = await response.json();+ if (!data.success) {+ throw new Error(data.error || "Failed to update pipe configuration");+ }++ toast({+ title: "Configuration saved",+ description: "The pipe configuration has been updated.",+ });++ setSelectedPipe({+ ...selectedPipe,+ installed_config: {+ ...selectedPipe.installed_config!,+ ...config,+ },+ });+ } catch (error) {+ console.error("Failed to save config:", error);+ toast({+ title: "error saving configuration",+ description:+ "please try again or check the logs for more information.",+ variant: "destructive",+ });+ }+ }+ };+ const handleDeletePipe = async (pipe: PipeWithStatus) => {+ try {+ toast({+ title: "deleting pipe",+ description: "please wait...",+ });+ setSelectedPipe(null);++ const id = pipe.is_local ? pipe.id : pipe.name;+ const response = await fetch("http://localhost:3030/pipes/delete", {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ body: JSON.stringify({ pipe_id: id }),+ });++ const data = await response.json();+ if (!data.success) {+ throw new Error(data.error);+ }++ // First unselect the pipe, then fetch the updated list+ await fetchInstalledPipes();++ toast({+ title: "pipe deleted",+ description: "the pipe has been successfully removed",+ });++ setSelectedPipe(null);+ } catch (error) {+ console.error("failed to delete pipe:", error);+ toast({+ title: "error deleting pipe",+ description: "please try again or check the logs for more information.",+ variant: "destructive",+ });+ }+ };++ const handleRefreshFromDisk = async (pipe: PipeWithStatus) => {+ try {+ toast({+ title: "refreshing pipe",+ description: "please wait...",+ });++ const response = await fetch(`http://localhost:3030/pipes/download`, {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ body: JSON.stringify({ url: pipe.installed_config?.source }),+ });+ if (!response.ok) {+ throw new Error("failed to refresh pipe");+ }++ await fetchInstalledPipes();+ toast({+ title: "pipe refreshed",+ description: "the pipe has been successfully refreshed from disk.",+ });+ } catch (error) {+ console.error("failed to refresh pipe from disk:", error);+ toast({+ title: "error refreshing pipe",+ description: "please try again or check the logs for more information.",+ variant: "destructive",+ });+ } finally {+ setSelectedPipe(null);+ }+ };++ const handleUpdatePipe = async (pipe: PipeWithStatus) => {+ try {+ if (!checkLogin(settings.user)) return;++ const currentVersion = pipe.installed_config?.version!;+ const storeApi = await PipeApi.create(settings.user!.token!);+ const update = await storeApi.checkUpdate(pipe.id, currentVersion);+ if (!update.has_update) {+ toast({+ title: "no update available",+ description: "the pipe is already up to date",+ });+ return;+ }++ const t = toast({+ title: "updating pipe",+ description: (+ <div className="space-y-2">+ <Progress value={25} className="h-1" />+ <p className="text-xs">checking for updates...</p>+ </div>+ ),+ duration: 100000,+ });++ // Update progress for download start+ t.update({+ id: t.id,+ description: (+ <div className="space-y-2">+ <Progress value={50} className="h-1" />+ <p className="text-xs">downloading update...</p>+ </div>+ ),+ });++ const responseDownload = await storeApi.downloadPipe(pipe.id);++ // Update progress for installation+ t.update({+ id: t.id,+ description: (+ <div className="space-y-2">+ <Progress value={75} className="h-1" />+ <p className="text-xs">installing update...</p>+ </div>+ ),+ });++ const response = await fetch(+ `http://localhost:3030/pipes/update-version`,+ {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ body: JSON.stringify({+ pipe_id: pipe.name,+ source: responseDownload.download_url,+ }),+ }+ );++ const data = await response.json();+ if (!data.success) {+ throw new Error(data.error);+ }++ // Update progress for completion+ t.update({+ id: t.id,+ title: "pipe updated",+ description: (+ <div className="space-y-2">+ <Progress value={100} className="h-1" />+ <p className="text-xs">completed successfully</p>+ </div>+ ),+ duration: 2000,+ });++ await fetchInstalledPipes();++ t.dismiss();+ } catch (error) {+ console.error("failed to update pipe:", error);+ toast({+ title: "error updating pipe",+ description: "please try again or check the logs for more information.",+ variant: "destructive",+ });+ }+ };++ useEffect(() => {+ fetchStorePlugins();+ }, [installedPipes, purchaseHistory]);++ useEffect(() => {+ fetchPurchaseHistory();+ }, [settings.user.token]);++ useEffect(() => {+ fetchInstalledPipes();+ }, [health]);++ useEffect(() => {+ const interval = setInterval(() => {+ fetchInstalledPipes();+ }, 3000);+ return () => clearInterval(interval);+ }, []);++ useEffect(() => {+ const checkForUpdates = async () => {+ if (!settings.user.token) {+ return;+ }+ // Get last check time from local storage+ const lastCheckTime = await localforage.getItem<number>(+ "lastUpdateCheck"+ );+ const now = Date.now();++ // Check if 5 minutes have passed since last check+ if (lastCheckTime && now - lastCheckTime < 5 * 60 * 1000) {+ return;+ }++ // Store current time as last check+ await localforage.setItem("lastUpdateCheck", now);++ const installedPipes = pipes.filter((pipe) => pipe.is_installed);++ const storeApi = await PipeApi.create(settings.user.token);+ for (const pipe of installedPipes) {+ const update = await storeApi.checkUpdate(+ pipe.id,+ pipe.installed_config?.version!+ );+ if (update.has_update) {+ await handleUpdatePipe(pipe);+ }+ }+ };++ // Run check immediately+ checkForUpdates();++ // Set up interval to check every 10 seconds actual check is done in the function+ const interval = setInterval(checkForUpdates, 10 * 1000);++ return () => clearInterval(interval);+ }, [settings.user.token]);++ useEffect(() => {+ const setupDeepLink = async () => {+ const unsubscribeDeepLink = await onOpenUrl(async (urls) => {+ console.log("received deep link urls:", urls);+ for (const url of urls) {+ if (url.includes("purchase-successful")) {+ const urlObj = new URL(url);+ const pipeId = urlObj.searchParams.get("pipe_id");++ if (!pipeId) {+ toast({+ title: "purchase successful",+ description: "your purchase was successful",+ });+ return;+ }++ await new Promise((resolve) => setTimeout(resolve, 1000));++ // First update purchase history to reflect the new purchase+ await fetchPurchaseHistory();++ // Find the pipe in the store+ const purchasedPipe = pipes.find((pipe) => pipe.id === pipeId);+ if (!purchasedPipe) {+ toast({+ title: "error installing pipe",+ description: "could not find the purchased pipe",+ variant: "destructive",+ });+ return;+ }++ // Install the pipe+ await handleInstallPipe(purchasedPipe);+ }+ }+ });+ return unsubscribeDeepLink;+ };++ let deepLinkUnsubscribe: (() => void) | undefined;++ setupDeepLink().then((unsubscribe) => {+ deepLinkUnsubscribe = unsubscribe;+ });+ return () => {+ if (deepLinkUnsubscribe) deepLinkUnsubscribe();+ };+ }, [pipes]);++ if (health?.status === "error") {+ return (+ <div className="flex flex-col items-center justify-center h-screen p-4 space-y-4">+ <div className="text-center space-y-4">+ <h3 className="text-lg font-medium">screenpipe is not recording</h3>+ <p className="text-sm text-muted-foreground">+ please start the screenpipe service to browse and manage pipes+ </p>+ <Button+ variant="outline"+ onClick={openStatusDialog}+ className="gap-2"+ >+ <Power className="h-4 w-4" />+ check service status+ </Button>+ </div>+ </div>+ );+ }++ if (selectedPipe) {+ return (+ <PipeDetails+ pipe={selectedPipe}+ onClose={() => setSelectedPipe(null)}+ onToggle={handleTogglePipe}+ onConfigSave={handleConfigSave}+ onDelete={handleDeletePipe}+ onRefreshFromDisk={handleRefreshFromDisk}+ onUpdate={handleUpdatePipe}+ />+ );+ }++ return (+ <div className="overflow-hidden flex flex-col space-y-4 min-w-[800px]">+ <div className="flex flex-col flex-1 overflow-hidden space-y-4 p-4 min-w-[800px]">+ <div className="space-y-4 min-w-[800px]">+ <div className="flex flex-col gap-4 w-[50%]">+ <div className="flex-1 relative">+ <Search className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400" />+ <Input+ placeholder="search community pipes..."+ value={searchQuery}+ onChange={(e) => setSearchQuery(e.target.value)}+ className="pl-9"+ autoCorrect="off"+ autoComplete="off"+ />+ </div>+ <div className="flex items-center gap-2">+ <span className="text-sm text-gray-600">show installed only</span>+ <Switch+ checked={showInstalledOnly}+ onCheckedChange={setShowInstalledOnly}+ />+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <Button+ variant="outline"+ size="icon"+ onClick={handleResetAllPipes}+ className="flex items-center gap-2"+ >+ <Trash2 className="h-4 w-4" />+ </Button>+ </TooltipTrigger>+ <TooltipContent>+ <p>reset all pipes</p>+ </TooltipContent>+ </Tooltip>+ </TooltipProvider>+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <Button+ variant="outline"+ size="icon"+ onClick={() => handleUpdateAllPipes()}+ className="flex items-center gap-2"+ disabled={+ !pipes.some(+ (pipe) => pipe.is_installed && pipe.has_update+ )+ }+ >+ <RefreshCw className="h-4 w-4" />+ </Button>+ </TooltipTrigger>+ <TooltipContent>+ <p>update all pipes</p>+ </TooltipContent>+ </Tooltip>+ </TooltipProvider>+ </div>+ </div>+ </div>++ <div className="flex-1 overflow-y-auto">+ <div className="grid grid-cols-2 gap-4">+ {filteredPipes.map((pipe) => (+ <PipeCard+ key={pipe.id}+ pipe={pipe}+ setPipe={(updatedPipe) => {+ setPipes((prevPipes) => {+ return prevPipes.map((p) =>+ p.id === updatedPipe.id ? updatedPipe : p+ );+ });+ }}+ onInstall={handleInstallPipe}+ onClick={setSelectedPipe}+ onPurchase={handlePurchasePipe}+ isLoadingPurchase={loadingPurchases.has(pipe.id)}+ isLoadingInstall={loadingInstalls.has(pipe.id)}+ onToggle={handleTogglePipe}+ />+ ))}+ </div>+ </div>++ <AddPipeForm+ onAddPipe={handleInstallSideload}+ isHealthy={health?.status !== "error"}+ onLoadFromLocalFolder={handleLoadFromLocalFolder}+ />+ </div>+ </div>+ );};diff --git a/screenpipe-app-tauri/components/settings.tsx b/screenpipe-app-tauri/components/settings.tsxindex 171fa174b..4189a824c 100644--- a/screenpipe-app-tauri/components/settings.tsx+++ b/screenpipe-app-tauri/components/settings.tsx@@ -13,10 +13,10 @@ import {Check,HardDrive,FolderInput,+ Settings as SettingsIcon,} from "lucide-react";import { DialogHeader, DialogTitle } from "./ui/dialog";import { cn } from "@/lib/utils";-import { RecordingSettings } from "./recording-settings";import { AccountSection } from "./settings/account-section";import ShortcutSection from "./settings/shortcut-section";import DiskUsage from "./settings/disk-usage";@@ -37,8 +37,11 @@ import { toast } from "./ui/use-toast";import { DataImportSection } from "./settings/data-import-section";import { Dialog, DialogContent } from "./ui/dialog";import { useSettingsDialog } from "@/lib/hooks/use-settings-dialog";+import { RecordingSettings } from "./settings/recording-settings";+import GeneralSettings from "./settings/general-settings";type SettingsSection =+ | "general"| "ai"| "shortcuts"| "recording"@@ -104,6 +107,8 @@ export function Settings() {const renderSection = () => {switch (activeSection) {+ case "general":+ return <GeneralSettings />;case "ai":return <AISection />;case "account":@@ -220,6 +225,11 @@ export function Settings() {label: "account",icon: <User className="h-4 w-4" />,},+ {+ id: "general",+ label: "general",+ icon: <SettingsIcon className="h-4 w-4" />,+ },{id: "ai",label: "ai settings",diff --git a/screenpipe-app-tauri/components/settings/account-section.tsx b/screenpipe-app-tauri/components/settings/account-section.tsxindex b477965d9..4878be03a 100644--- a/screenpipe-app-tauri/components/settings/account-section.tsx+++ b/screenpipe-app-tauri/components/settings/account-section.tsx@@ -100,19 +100,6 @@ export function AccountSection() {const unsubscribeDeepLink = await onOpenUrl(async (urls) => {console.log("received deep link urls:", urls);for (const url of urls) {- // eg. user flow- if (url.includes("api_key=")) {- const apiKey = new URL(url).searchParams.get("api_key");- if (apiKey) {- updateSettings({ user: { token: apiKey } });- await loadUser(apiKey, true);-- toast({- title: "logged in!",- description: "your api key has been set",- });- }- }// eg stripe / dev flowif (url.includes("stripe-connect")) {console.log("stripe connect url:", url);@@ -289,7 +276,7 @@ export function AccountSection() {<div className="flex items-center justify-between"><div className="space-y-2"><h1 className="text-2xl font-bold">account settings</h1>- {settings.user?.email ? (+ {settings.user?.token ? (<p className="text-sm text-muted-foreground flex items-center gap-2"><span className="inline-flex h-2 w-2 rounded-full bg-green-500" />logged in as {settings.user.email}diff --git a/screenpipe-app-tauri/components/settings/general-settings.tsx b/screenpipe-app-tauri/components/settings/general-settings.tsxnew file mode 100644index 000000000..6b5a3e256--- /dev/null+++ b/screenpipe-app-tauri/components/settings/general-settings.tsx@@ -0,0 +1,37 @@+"use client";++import React from "react";+import { useSettings } from "@/lib/hooks/use-settings";+import { Switch } from "@/components/ui/switch";++export default function GeneralSettings() {+ const { settings, updateSettings } = useSettings();++ const handleSettingsChange = (newSettings: Partial<typeof settings>) => {+ updateSettings(newSettings);+ };++ return (+ <div className="w-full space-y-6 py-4">+ <h1 className="text-2xl font-bold mb-4">general</h1>++ <div className="space-y-8">+ <div className="flex items-center justify-between">+ <div className="space-y-1">+ <h4 className="font-medium">enable autostart</h4>+ <p className="text-sm text-muted-foreground">+ automatically launch screenpipe at startup+ </p>+ </div>+ <Switch+ id="auto-start-toggle"+ checked={settings.autoStartEnabled}+ onCheckedChange={(checked) =>+ handleSettingsChange({ autoStartEnabled: checked })+ }+ />+ </div>+ </div>+ </div>+ );+}diff --git a/screenpipe-app-tauri/components/recording-settings.tsx b/screenpipe-app-tauri/components/settings/recording-settings.tsxsimilarity index 88%rename from screenpipe-app-tauri/components/recording-settings.tsxrename to screenpipe-app-tauri/components/settings/recording-settings.tsxindex 43cb69f1f..374314145 100644--- a/screenpipe-app-tauri/components/recording-settings.tsx+++ b/screenpipe-app-tauri/components/settings/recording-settings.tsx@@ -8,9 +8,13 @@ import {SelectItem,SelectTrigger,SelectValue,-} from "./ui/select";+} from "@/components/ui/select";import { Button } from "@/components/ui/button";-import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover";+import {+ Popover,+ PopoverContent,+ PopoverTrigger,+} from "@/components/ui/popover";import {Check,ChevronsUpDown,@@ -34,7 +38,7 @@ import {CommandEmpty,CommandGroup,CommandItem,-} from "./ui/command";+} from "@/components/ui/command";import {Settings,useSettings,@@ -43,30 +47,30 @@ import {import { useToast } from "@/components/ui/use-toast";import { useHealthCheck } from "@/lib/hooks/use-health-check";import { invoke } from "@tauri-apps/api/core";-import { Badge } from "./ui/badge";+import { Badge } from "@/components/ui/badge";import {Tooltip,TooltipContent,TooltipProvider,TooltipTrigger,-} from "./ui/tooltip";-import { Switch } from "./ui/switch";-import { Input } from "./ui/input";-import { Slider } from "./ui/slider";+} from "@/components/ui/tooltip";+import { Switch } from "@/components/ui/switch";+import { Input } from "@/components/ui/input";+import { Slider } from "@/components/ui/slider";import { platform } from "@tauri-apps/plugin-os";import posthog from "posthog-js";import { Language } from "@/lib/language";import { open } from "@tauri-apps/plugin-dialog";import { exists } from "@tauri-apps/plugin-fs";-import { Command as ShellCommand } from "@tauri-apps/plugin-shell";import { ToastAction } from "@/components/ui/toast";import { open as openUrl } from "@tauri-apps/plugin-shell";-import { Separator } from "./ui/separator";+import { Separator } from "@/components/ui/separator";import { MultiSelect } from "@/components/ui/multi-select";-import { Alert, AlertDescription, AlertTitle } from "./ui/alert";+import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";import { useSqlAutocomplete } from "@/lib/hooks/use-sql-autocomplete";import * as Sentry from "@sentry/react";import { defaultOptions } from "tauri-plugin-sentry-api";+import { useLoginDialog } from "../login-dialog";type PermissionsStatus = {screenRecording: string;@@ -114,14 +118,11 @@ const createWindowOptions = (export function RecordingSettings() {const { settings, updateSettings, getDataDir } = useSettings();const [openAudioDevices, setOpenAudioDevices] = React.useState(false);- const [openMonitors, setOpenMonitors] = React.useState(false);const [openLanguages, setOpenLanguages] = React.useState(false);const [dataDirInputVisible, setDataDirInputVisible] = React.useState(false);const [clickTimeout, setClickTimeout] = useState<ReturnType<typeof setTimeout> | null>(null);- const [windowsForIgnore, setWindowsForIgnore] = useState("");- const [windowsForInclude, setWindowsForInclude] = useState("");const { items: windowItems, isLoading: isWindowItemsLoading } =useSqlAutocomplete("window");@@ -137,9 +138,9 @@ export function RecordingSettings() {const { health } = useHealthCheck();const isDisabled = health?.status_code === 500;const [isMacOS, setIsMacOS] = useState(false);- const [isSetupRunning, setIsSetupRunning] = useState(false);const [showApiKey, setShowApiKey] = useState(false);- const { credits } = settings.user || {};+ const { checkLogin } = useLoginDialog();+// Add new state to track if settings have changedconst [hasUnsavedChanges, setHasUnsavedChanges] = useState(false);@@ -341,19 +342,33 @@ export function RecordingSettings() {}};- const handleAudioTranscriptionModelChange = (value: string) => {- if (value === "screenpipe-cloud" && !settings.user?.cloud_subscribed) {- openUrl("https://buy.stripe.com/7sIdRzbym4RA98c7sX");+ const handleAudioTranscriptionModelChange = (+ value: string,+ realtime = false+ ) => {+ const isLoggedIn = checkLogin(settings.user);+ // If trying to use cloud but not logged in+ if (value === "screenpipe-cloud" && !isLoggedIn) {return;}- if (value === "screenpipe-cloud") {- handleSettingsChange({- audioTranscriptionEngine: value,- });- } else {- handleSettingsChange({ audioTranscriptionEngine: value });+ // If trying to use cloud but not subscribed+ if (value === "screenpipe-cloud" && !settings.user?.cloud_subscribed) {+ const clientRefId = `${+ settings.user?.id+ }&customer_email=${encodeURIComponent(settings.user?.email ?? "")}`;+ openUrl(+ `https://buy.stripe.com/7sIdRzbym4RA98c7sX?client_reference_id=${clientRefId}`+ );+ // Revert back to previous value in the Select component+ return;}++ // Only proceed with the change if all checks pass+ const newSettings = realtime+ ? { realtimeAudioTranscriptionEngine: value }+ : { audioTranscriptionEngine: value };+ handleSettingsChange(newSettings, true);};const handleOcrModelChange = (value: string) => {@@ -431,20 +446,11 @@ export function RecordingSettings() {const handleAnalyticsToggle = (checked: boolean) => {const newValue = checked;- handleSettingsChange({ analyticsEnabled: newValue });+ handleSettingsChange({ analyticsEnabled: newValue }, true);};- const handleAutoStartToggle = async (checked: boolean) => {- const newValue = checked- handleSettingsChange({ autoStartEnabled: newValue});- }-const handleChineseMirrorToggle = async (checked: boolean) => {- handleSettingsChange({ useChineseMirror: checked });- if (checked) {- // Trigger setup when the toggle is turned on- await runSetup();- }+ handleSettingsChange({ useChineseMirror: checked }, true);};const handleDataDirChange = async () => {@@ -474,7 +480,7 @@ export function RecordingSettings() {// TODO: check permission of selected dir for server to write intoif (selected) {- handleSettingsChange({ dataDir: selected });+ handleSettingsChange({ dataDir: selected }, true);} else {console.log("canceled");}@@ -526,62 +532,7 @@ export function RecordingSettings() {duration: 3000,});- handleSettingsChange({ dataDir: settings.dataDir });- };-- const runSetup = async () => {- setIsSetupRunning(true);- try {- const command = ShellCommand.sidecar("screenpipe", ["setup"]);- const child = await command.spawn();-- toast({- title: "Setting up Chinese mirror",- description: "This may take a few minutes...",- });-- const outputPromise = new Promise<string>((resolve, reject) => {- command.on("close", (data) => {- if (data.code !== 0) {- reject(new Error(`Command failed with code ${data.code}`));- }- });- command.on("error", (error) => reject(new Error(error)));- command.stdout.on("data", (line) => {- console.log(line);- if (line.includes("screenpipe setup complete")) {- resolve("ok");- }- });- });-- const timeoutPromise = new Promise(- (_, reject) =>- setTimeout(() => reject(new Error("Setup timed out")), 900000) // 15 minutes- );-- const result = await Promise.race([outputPromise, timeoutPromise]);-- if (result === "ok") {- toast({- title: "Chinese mirror setup complete",- description: "You can now use the Chinese mirror for downloads.",- });- } else {- throw new Error("Setup failed or timed out");- }- } catch (error) {- console.error("Error setting up Chinese mirror:", error);- toast({- title: "Error setting up Chinese mirror",- description: "Please try again or check the logs for more information.",- variant: "destructive",- });- // Revert the toggle if setup fails- handleSettingsChange({ useChineseMirror: false });- } finally {- setIsSetupRunning(false);- }+ handleSettingsChange({ dataDir: settings.dataDir }, true);};const handleFrameCacheToggle = (checked: boolean) => {@@ -617,7 +568,7 @@ export function RecordingSettings() {}// Just update the local setting - the update button will handle the restart- handleSettingsChange({ enableUiMonitoring: checked });+ handleSettingsChange({ enableUiMonitoring: checked }, true);} catch (error) {console.error("failed to toggle ui monitoring:", error);toast({@@ -656,11 +607,14 @@ export function RecordingSettings() {} else if (removedValues.length > 0) {// Handle removing valueconst removedValue = removedValues[0];- handleSettingsChange({- ignoredWindows: settings.ignoredWindows.filter(- (w) => w !== removedValue- ),- });+ handleSettingsChange(+ {+ ignoredWindows: settings.ignoredWindows.filter(+ (w) => w !== removedValue+ ),+ },+ true+ );}};@@ -683,21 +637,27 @@ export function RecordingSettings() {if (addedValues.length > 0) {// Handle adding new valueconst newValue = addedValues[0];- handleSettingsChange({- includedWindows: [...settings.includedWindows, newValue],- // Remove from ignored windows if present- ignoredWindows: settings.ignoredWindows.filter(- (w) => w.toLowerCase() !== newValue.toLowerCase()- ),- });+ handleSettingsChange(+ {+ includedWindows: [...settings.includedWindows, newValue],+ // Remove from ignored windows if present+ ignoredWindows: settings.ignoredWindows.filter(+ (w) => w.toLowerCase() !== newValue.toLowerCase()+ ),+ },+ true+ );} else if (removedValues.length > 0) {// Handle removing valueconst removedValue = removedValues[0];- handleSettingsChange({- includedWindows: settings.includedWindows.filter(- (w) => w !== removedValue- ),- });+ handleSettingsChange(+ {+ includedWindows: settings.includedWindows.filter(+ (w) => w !== removedValue+ ),+ },+ true+ );}};@@ -735,7 +695,7 @@ export function RecordingSettings() {id="disableVision"checked={settings.disableVision}onCheckedChange={(checked) =>- handleSettingsChange({ disableVision: checked })+ handleSettingsChange({ disableVision: checked }, true)}/></div>@@ -780,8 +740,8 @@ export function RecordingSettings() {defaultValue={settings.monitorIds}onValueChange={(values) =>values.length === 0- ? handleSettingsChange({ disableVision: true })- : handleSettingsChange({ monitorIds: values })+ ? handleSettingsChange({ disableVision: true }, true)+ : handleSettingsChange({ monitorIds: values }, true)}placeholder={settings.useAllMonitors@@ -989,9 +949,12 @@ export function RecordingSettings() {id="enableRealtimeAudio"checked={settings.enableRealtimeAudioTranscription}onCheckedChange={(checked) =>- handleSettingsChange({- enableRealtimeAudioTranscription: checked,- })+ handleSettingsChange(+ {+ enableRealtimeAudioTranscription: checked,+ },+ true+ )}/></div>@@ -1008,9 +971,7 @@ export function RecordingSettings() {</Label><SelectonValueChange={(value) =>- handleSettingsChange({- realtimeAudioTranscriptionEngine: value,- })+ handleAudioTranscriptionModelChange(value, true)}value={settings.realtimeAudioTranscriptionEngine}>@@ -1103,9 +1064,12 @@ export function RecordingSettings() {value={settings.deepgramApiKey}onChange={(e) => {const newValue = e.target.value;- handleSettingsChange({- deepgramApiKey: newValue,- });+ handleSettingsChange(+ {+ deepgramApiKey: newValue,+ },+ true+ );}}className="pr-10 w-full"placeholder="enter your Deepgram API key"@@ -1377,49 +1341,6 @@ export function RecordingSettings() {<div className="space-y-8 py-4"><div className="space-y-6">- {/* <div className="flex flex-col space-y-2">- <Label- htmlFor="restartInterval"- className="flex items-center space-x-2"- >- <span>auto restart interval (minutes)</span>- <TooltipProvider>- <Tooltip>- <TooltipTrigger>- <HelpCircle className="h-4 w-4 cursor-default" />- </TooltipTrigger>- <TooltipContent side="right">- <p>- automatically restart screenpipe after the specified- interval.- <br />- 0 means no automatic restart.- <br />- useful if you face memory issues and ensure stable- recording.- </p>- </TooltipContent>- </Tooltip>- </TooltipProvider>- </Label>- <div className="flex items-center space-x-4">- <Slider- id="restartInterval"- min={0}- max={1440}- step={30}- value={[settings.restartInterval || 0]}- onValueChange={(value) =>- handleSettingsChange({ restartInterval: value[0] })- }- className="flex-grow"- />- <span className="w-16 text-right">- {settings.restartInterval || 0} min- </span>- </div>- </div> */}-<div className="flex items-center justify-between"><div className="space-y-1"><h4 className="font-medium">@@ -1484,20 +1405,6 @@ export function RecordingSettings() {/></div>- <div className="flex items-center justify-between">- <div className="space-y-1">- <h4 className="font-medium">enable autostart</h4>- <p className="text-sm text-muted-foreground">- automatically launch Screenpipe at startup- </p>- </div>- <Switch- id="auto-start-toggle"- checked={settings.autoStartEnabled}- onCheckedChange={handleAutoStartToggle}- />- </div>-{isMacOS && (<div className="flex items-center justify-between"><div className="space-y-1">diff --git a/screenpipe-app-tauri/src-tauri/Cargo.lock b/screenpipe-app-tauri/src-tauri/Cargo.lockindex 3057f23a2..49db5ce30 100755--- a/screenpipe-app-tauri/src-tauri/Cargo.lock+++ b/screenpipe-app-tauri/src-tauri/Cargo.lock@@ -5289,7 +5289,7 @@ dependencies = [[[package]]name = "screenpipe-app"-version = "0.35.10"+version = "0.36.3"dependencies = ["anyhow","async-stream",diff --git a/screenpipe-app-tauri/src-tauri/ui_monitor-aarch64-apple-darwin b/screenpipe-app-tauri/src-tauri/ui_monitor-aarch64-apple-darwinindex 9aba920f6..3d76bb9fa 100755Binary files a/screenpipe-app-tauri/src-tauri/ui_monitor-aarch64-apple-darwin and b/screenpipe-app-tauri/src-tauri/ui_monitor-aarch64-apple-darwin differdiff --git a/screenpipe-app-tauri/src-tauri/ui_monitor-x86_64-apple-darwin b/screenpipe-app-tauri/src-tauri/ui_monitor-x86_64-apple-darwinindex 4cab4bf60..4c3ff7c82 100755Binary files a/screenpipe-app-tauri/src-tauri/ui_monitor-x86_64-apple-darwin and b/screenpipe-app-tauri/src-tauri/ui_monitor-x86_64-apple-darwin differ