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: ui app
Louis Beaumont9c90a2d52826
diff --git a/screenpipe-app-tauri/components/screenpipe-status.tsx b/screenpipe-app-tauri/components/screenpipe-status.tsxindex 1f2103683..d90303b24 100644--- a/screenpipe-app-tauri/components/screenpipe-status.tsx+++ b/screenpipe-app-tauri/components/screenpipe-status.tsx@@ -50,22 +50,42 @@ import { LogFileButton } from "./log-file-button";import { DevModeSettings } from "./dev-mode-settings";import { ChevronLeft, ChevronRight } from "lucide-react";import { useCopyToClipboard } from "@/lib/hooks/use-copy-to-clipboard";+import { Loader2 } from "lucide-react";+import { cn } from "@/lib/utils";const HealthStatus = ({ className }: { className?: string }) => {- const { health } = useHealthCheck();+ const {+ health,+ isServerDown,+ isLoading: healthCheckLoading,+ debouncedFetchHealth,+ } = useHealthCheck();const [isDialogOpen, setIsDialogOpen] = useState(false);const [isMac, setIsMac] = useState(false);const { settings, getDataDir } = useSettings();- const [localDataDir, setLocalDataDir] = useState('');+ const [localDataDir, setLocalDataDir] = useState("");const [isLogOpen, setIsLogOpen] = useState(false);const [isFixingSetup, setIsFixingSetup] = useState(false);const [isTroubleshootOpen, setIsTroubleshootOpen] = useState(false);const [currentStep, setCurrentStep] = useState(0);+ const [isDialogLoading, setIsDialogLoading] = useState(false);useEffect(() => {setIsMac(platform() === "macos");}, []);+ useEffect(() => {+ const handleSettingsUpdate = () => {+ debouncedFetchHealth();+ };++ window.addEventListener("settings-updated", handleSettingsUpdate);++ return () => {+ window.removeEventListener("settings-updated", handleSettingsUpdate);+ };+ }, [debouncedFetchHealth]);+const openScreenPermissions = async () => {const toastId = toast({title: "opening permissions",@@ -89,7 +109,7 @@ const HealthStatus = ({ className }: { className?: string }) => {const handleOpenDataDir = async () => {try {- const dataDir = await getDataDir()+ const dataDir = await getDataDir();await open(dataDir);} catch (error) {console.error("failed to open data directory:", error);@@ -112,8 +132,10 @@ const HealthStatus = ({ className }: { className?: string }) => {) => {if (status === "loading") return "bg-yellow-500";const isVisionOk = frameStatus === "ok" || frameStatus === "disabled";- const isAudioOk = audioStatus === "ok" || audioStatus === "disabled" || audioDisabled;- const isUiOk = uiStatus === "ok" || uiStatus === "disabled" || !uiMonitoringEnabled;+ const isAudioOk =+ audioStatus === "ok" || audioStatus === "disabled" || audioDisabled;+ const isUiOk =+ uiStatus === "ok" || uiStatus === "disabled" || !uiMonitoringEnabled;return isVisionOk && isAudioOk && isUiOk ? "bg-green-500" : "bg-red-500";};@@ -380,22 +402,46 @@ const HealthStatus = ({ className }: { className?: string }) => {);const handleOpenStatusDialog = async () => {- setLocalDataDir(await getDataDir())- setIsDialogOpen(true)- }+ if (isDialogLoading) return; // Prevent multiple clicks while loading++ try {+ setIsDialogLoading(true);+ const dir = await getDataDir();+ setLocalDataDir(dir);+ setIsDialogOpen(true);+ } catch (error) {+ console.error("Failed to open status dialog:", error);+ toast({+ title: "Error",+ description: "Failed to open status dialog. Please try again.",+ variant: "destructive",+ duration: 3000,+ });+ } finally {+ setIsDialogLoading(false);+ }+ };return (<><Badgevariant="outline"- className="cursor-pointer bg-transparent text-foreground hover:bg-accent hover:text-accent-foreground"+ className={cn(+ "cursor-pointer bg-transparent text-foreground hover:bg-accent hover:text-accent-foreground",+ isDialogLoading && "opacity-50 pointer-events-none"+ )}onClick={handleOpenStatusDialog}>- <Activity className="mr-2 h-4 w-4" />+ {isDialogLoading ? (+ <Loader2 className="mr-2 h-4 w-4 animate-spin" />+ ) : (+ <Activity className="mr-2 h-4 w-4" />+ )}status{" "}<span- className={`ml-1 w-2 h-2 rounded-full ${statusColor} inline-block ${statusColor === "bg-red-500" ? "animate-pulse" : ""- }`}+ className={`ml-1 w-2 h-2 rounded-full ${statusColor} inline-block ${+ statusColor === "bg-red-500" ? "animate-pulse" : ""+ }`}/></Badge><Dialog open={isDialogOpen} onOpenChange={setIsDialogOpen}>@@ -428,27 +474,59 @@ const HealthStatus = ({ className }: { className?: string }) => {<div className="space-y-2 text-xs mb-4">{/* Screen Recording Status */}<div className="flex items-center">- <div className={`w-2 h-2 rounded-full ${health.frame_status === "ok" ? "bg-green-500" : "bg-red-500"} mr-2`} />+ <div+ className={`w-2 h-2 rounded-full ${+ health.frame_status === "ok" ? "bg-green-500" : "bg-red-500"+ } mr-2`}+ /><span>screen recording</span>- <span className="text-muted-foreground ml-2">status: {health.frame_status},</span>- <span className="text-muted-foreground ml-2">last update: {formatTimestamp(health.last_frame_timestamp)}</span>+ <span className="text-muted-foreground ml-2">+ status: {health.frame_status},+ </span>+ <span className="text-muted-foreground ml-2">+ last update: {formatTimestamp(health.last_frame_timestamp)}+ </span></div>{/* Audio Recording Status */}<div className="flex items-center">- <div className={`w-2 h-2 rounded-full ${settings.disableAudio ? "bg-gray-400" : health.audio_status === "ok" ? "bg-green-500" : "bg-red-500"} mr-2`} />+ <div+ className={`w-2 h-2 rounded-full ${+ settings.disableAudio+ ? "bg-gray-400"+ : health.audio_status === "ok"+ ? "bg-green-500"+ : "bg-red-500"+ } mr-2`}+ /><span>audio recording</span>- <span className="text-muted-foreground ml-2">status: {settings.disableAudio ? "turned off" : health.audio_status},</span>- <span className="text-muted-foreground ml-2">last update: {settings.disableAudio ? "n/a" : formatTimestamp(health.last_audio_timestamp)}</span>+ <span className="text-muted-foreground ml-2">+ status:{" "}+ {settings.disableAudio ? "turned off" : health.audio_status},+ </span>+ <span className="text-muted-foreground ml-2">+ last update:{" "}+ {settings.disableAudio+ ? "n/a"+ : formatTimestamp(health.last_audio_timestamp)}+ </span></div>{/* UI Monitoring Status - Only show if enabled */}{settings.enableUiMonitoring && (<div className="flex items-center">- <div className={`w-2 h-2 rounded-full ${health.ui_status === "ok" ? "bg-green-500" : "bg-red-500"} mr-2`} />+ <div+ className={`w-2 h-2 rounded-full ${+ health.ui_status === "ok" ? "bg-green-500" : "bg-red-500"+ } mr-2`}+ /><span>ui monitoring</span>- <span className="text-muted-foreground ml-2">status: {health.ui_status},</span>- <span className="text-muted-foreground ml-2">last update: {formatTimestamp(health.last_ui_timestamp)}</span>+ <span className="text-muted-foreground ml-2">+ status: {health.ui_status},+ </span>+ <span className="text-muted-foreground ml-2">+ last update: {formatTimestamp(health.last_ui_timestamp)}+ </span></div>)}</div>@@ -456,28 +534,22 @@ const HealthStatus = ({ className }: { className?: string }) => {<Separator className="my-12" /><DevModeSettings localDataDir={localDataDir} />- {isMac ? (- <Collapsible- open={isLogOpen}- onOpenChange={setIsLogOpen}- className="w-full mt-4"- >- <div className="flex items-center justify-between w-full">- <CollapsibleTrigger className="flex items-center justify-between p-2 flex-grow border-b border-gray-200">- recorder logs- <span>{isLogOpen ? "▲" : "▼"}</span>- </CollapsibleTrigger>- <LogFileButton />- </div>- <CollapsibleContent>- <LogViewer className="mt-2" />- </CollapsibleContent>- </Collapsible>- ) : (- <div className="flex justify-end mt-4">+ <Collapsible+ open={isLogOpen}+ onOpenChange={setIsLogOpen}+ className="w-full mt-4"+ >+ <div className="flex items-center justify-between w-full">+ <CollapsibleTrigger className="flex items-center justify-between p-2 flex-grow border-b border-gray-200">+ recorder logs+ <span>{isLogOpen ? "▲" : "▼"}</span>+ </CollapsibleTrigger><LogFileButton /></div>- )}+ <CollapsibleContent>+ <LogViewer className="mt-2" />+ </CollapsibleContent>+ </Collapsible></div></DialogContent></Dialog>diff --git a/screenpipe-app-tauri/components/settings.tsx b/screenpipe-app-tauri/components/settings.tsxindex 13e21fff0..9bc73ac89 100644--- a/screenpipe-app-tauri/components/settings.tsx+++ b/screenpipe-app-tauri/components/settings.tsx@@ -21,9 +21,9 @@ import {import { Separator } from "@/components/ui/separator";import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";import { Textarea } from "./ui/textarea";-import { Slider } from "@/components/ui/slider";-import { Badge } from "@/components/ui/badge";-import { parseKeyboardShortcut } from "@/lib/utils";+import { Slider } from "@/components/ui/slider"; // Add this import+import { Badge } from "@/components/ui/badge"; // Add this import+import { parseKeyboardShortcut } from "@/lib/utils"; // Add this importimport {Eye,@@ -55,10 +55,11 @@ import {SelectValue,} from "@/components/ui/select";import { useInterval } from "@/lib/hooks/use-interval";-import { AuthButton } from "./auth";+import { useHealthCheck } from "@/lib/hooks/use-health-check";export function Settings({ className }: { className?: string }) {const { settings, updateSettings, resetSetting } = useSettings();+ const { debouncedFetchHealth } = useHealthCheck();const [localSettings, setLocalSettings] = React.useState(settings);const [showApiKey, setShowApiKey] = React.useState(false);const [ollamaStatus, setOllamaStatus] = useState<@@ -474,12 +475,30 @@ export function Settings({ className }: { className?: string }) {// Use the useInterval hook to periodically check the statususeInterval(checkEmbeddedAIStatus, 10000); // Check every 10 seconds+ useEffect(() => {+ const handleSettingsUpdate = () => {+ debouncedFetchHealth();+ };++ window.addEventListener('settings-updated', handleSettingsUpdate);++ return () => {+ window.removeEventListener('settings-updated', handleSettingsUpdate);+ };+ }, [debouncedFetchHealth]);+return (<DialogonOpenChange={(open) => {if (!open) {- // hack bcs something does not update settings for some reason- window.location.reload(); // TODO: event trigger+ // Use a more reliable state update mechanism+ const event = new CustomEvent('settings-updated');+ window.dispatchEvent(event);++ // Add a small delay before refetching health+ setTimeout(() => {+ debouncedFetchHealth();+ }, 500);}}}>@@ -491,20 +510,16 @@ export function Settings({ className }: { className?: string }) {</DialogTrigger><DialogContent className="max-w-[80vw] w-full max-h-[80vh] h-full overflow-y-auto"><DialogHeader>- <div className="flex flex-col items-end space-y-2">- <div className="w-full flex justify-between items-center">- <DialogTitle>settings</DialogTitle>- <Badge className="mr-4">$200 cloud credits</Badge>- </div>- <div className="flex items-center space-x-2">- <AuthButton />- </div>- </div>+ <DialogTitle>settings</DialogTitle>+ <DialogDescription>+ choose your AI provider, enter necessary credentials, and more.+ </DialogDescription></DialogHeader><div className="mt-8 space-y-6"><RecordingSettingslocalSettings={localSettings}- setLocalSettings={setLocalSettings} />+ setLocalSettings={setLocalSettings}+ /><Separator />@@ -988,4 +1003,4 @@ export function Settings({ className }: { className?: string }) {</DialogContent></Dialog>);-}+}\ No newline at end of filediff --git a/screenpipe-app-tauri/lib/hooks/use-health-check.tsx b/screenpipe-app-tauri/lib/hooks/use-health-check.tsxindex 725928958..88af1334f 100644--- a/screenpipe-app-tauri/lib/hooks/use-health-check.tsx+++ b/screenpipe-app-tauri/lib/hooks/use-health-check.tsx@@ -1,4 +1,5 @@import { useState, useEffect, useCallback, useRef } from "react";+import { debounce } from "lodash";interface HealthCheckResponse {status: string;@@ -30,28 +31,57 @@ function isHealthChanged();}+interface HealthCheckHook {+ health: HealthCheckResponse | null;+ isServerDown: boolean;+ isLoading: boolean;+ fetchHealth: () => Promise<void>;+ debouncedFetchHealth: () => Promise<void>;+}+export function useHealthCheck() {const [health, setHealth] = useState<HealthCheckResponse | null>(null);const [isServerDown, setIsServerDown] = useState(false);- const pollInterval = 1000; // 1 second+ const [isLoading, setIsLoading] = useState(false);+ const abortControllerRef = useRef<AbortController | null>(null);const healthRef = useRef(health);const fetchHealth = useCallback(async () => {+ if (abortControllerRef.current) {+ abortControllerRef.current.abort();+ }++ abortControllerRef.current = new AbortController();+try {+ setIsLoading(true);const response = await fetch("http://localhost:3030/health", {cache: "no-store",+ signal: abortControllerRef.current.signal,+ headers: {+ "Cache-Control": "no-cache",+ Pragma: "no-cache",+ },});+if (!response.ok) {- throw new Error(`http error! status: ${response.status}`);+ throw new Error(`HTTP error! status: ${response.status}`);}+const data: HealthCheckResponse = await response.json();+if (isHealthChanged(healthRef.current, data)) {setHealth(data);healthRef.current = data;}+setIsServerDown(false);} catch (error) {- console.error("health check error:", error);+ if (error instanceof Error && error.name === "AbortError") {+ return;+ }++ console.error("Health check error:", error);if (!isServerDown) {setIsServerDown(true);const errorHealth: HealthCheckResponse = {@@ -63,20 +93,37 @@ export function useHealthCheck() {ui_status: "error",status: "error",status_code: 500,- message: "failed to fetch health status. server might be down.",+ message: "Failed to fetch health status. Server might be down.",};setHealth(errorHealth);healthRef.current = errorHealth;}+ } finally {+ setIsLoading(false);}- }, [isServerDown]);+ }, [isServerDown, setIsLoading]);++ const debouncedFetchHealth = useCallback(debounce(fetchHealth, 200), [+ fetchHealth,+ ]);useEffect(() => {fetchHealth();- const interval = setInterval(fetchHealth, pollInterval);+ const interval = setInterval(fetchHealth, 1000);- return () => clearInterval(interval);+ return () => {+ clearInterval(interval);+ if (abortControllerRef.current) {+ abortControllerRef.current.abort();+ }+ };}, [fetchHealth]);- return { health, isServerDown, refetchHealth: fetchHealth };+ return {+ health,+ isServerDown,+ isLoading,+ fetchHealth,+ debouncedFetchHealth,+ } as HealthCheckHook;}diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.tomlindex 2f72d37fd..f3ff34bb2 100644--- a/screenpipe-app-tauri/src-tauri/Cargo.toml+++ b/screenpipe-app-tauri/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "screenpipe-app"-version = "0.14.12"+version = "0.14.13"description = ""authors = ["you"]license = ""