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
release-app fix settings not saving
Louis Beaumont648c89abeb77
diff --git a/screenpipe-app-tauri/components/dev-mode-settings.tsx b/screenpipe-app-tauri/components/dev-mode-settings.tsxindex a1c1a4617..876867154 100644--- a/screenpipe-app-tauri/components/dev-mode-settings.tsx+++ b/screenpipe-app-tauri/components/dev-mode-settings.tsx@@ -114,8 +114,8 @@ const getDebuggingCommands = (os: string | null, dataDir: string) => {};export const DevModeSettings = ({ localDataDir }: { localDataDir: string }) => {- const { settings, updateSettings } = useSettings();- const [localSettings, setLocalSettings] = useState(settings);+ const { settings, updateSettings, localSettings, setLocalSettings } =+ useSettings();const handleDevModeToggle = async (checked: boolean) => {try {await updateSettings({ devMode: checked });@@ -129,16 +129,10 @@ export const DevModeSettings = ({ localDataDir }: { localDataDir: string }) => {});}};- console.log("settings:", settings);- console.log("localSettings:", localSettings);const [isLoading, setIsLoading] = useState(false);const { toast } = useToast();- useEffect(() => {- setLocalSettings(settings);- }, [settings]);-const handleStartScreenpipe = async () => {setIsLoading(true);const toastId = toast({diff --git a/screenpipe-app-tauri/components/recording-settings.tsx b/screenpipe-app-tauri/components/recording-settings.tsxindex b247633d0..4c9abf087 100644--- a/screenpipe-app-tauri/components/recording-settings.tsx+++ b/screenpipe-app-tauri/components/recording-settings.tsx@@ -52,17 +52,6 @@ import {import { Switch } from "./ui/switch";import { Input } from "./ui/input";import { Slider } from "./ui/slider";-import { IconCode } from "./ui/icons";-import {- Dialog,- DialogContent,- DialogDescription,- DialogFooter,- DialogHeader,- DialogTitle,-} from "./ui/dialog";-import { CodeBlock } from "./ui/codeblock";-import { useCopyToClipboard } from "@/lib/hooks/use-copy-to-clipboard";import { platform } from "@tauri-apps/plugin-os";import posthog from "posthog-js";import { trace } from "@opentelemetry/api";@@ -120,7 +109,7 @@ export function RecordingSettings({useEffect(() => {const checkPlatform = async () => {- const currentPlatform = await platform();+ const currentPlatform = platform();setIsMacOS(currentPlatform === "macos");};checkPlatform();@@ -223,7 +212,6 @@ export function RecordingSettings({monitorIds: localSettings.monitorIds,audioDevices: localSettings.audioDevices,usePiiRemoval: localSettings.usePiiRemoval,- restartInterval: localSettings.restartInterval,disableAudio: localSettings.disableAudio,ignoredWindows: localSettings.ignoredWindows,includedWindows: localSettings.includedWindows,@@ -372,10 +360,6 @@ export function RecordingSettings({setLocalSettings({ ...localSettings, usePiiRemoval: checked });};- const handleRestartIntervalChange = (value: number[]) => {- setLocalSettings({ ...localSettings, restartInterval: value[0] });- };-const handleDisableAudioChange = (checked: boolean) => {setLocalSettings({ ...localSettings, disableAudio: checked });};@@ -413,12 +397,6 @@ export function RecordingSettings({const currentPlatform = platform();return (<>- {/* <SelectItem value="unstructured">- <div className="flex items-center justify-between w-full space-x-2">- <span>unstructured</span>- <Badge variant="secondary">cloud</Badge>- </div>- </SelectItem> */}{currentPlatform === "linux" && (<SelectItem value="tesseract">tesseract</SelectItem>)}@@ -1000,48 +978,6 @@ export function RecordingSettings({</Label></div></div>- <div className="flex flex-col space-y-2">- <Label- htmlFor="restartInterval"- className="flex items-center space-x-2"- >- <span>restart interval (minutes)</span>- <Badge variant="outline" className="ml-2">- experimental- </Badge>- <TooltipProvider>- <Tooltip>- <TooltipTrigger>- <HelpCircle className="h-4 w-4 cursor-default" />- </TooltipTrigger>- <TooltipContent>- <p>- (not recommended) set how often the recording process- should restart.- <br />- 30 minutes is the minimum interval.- <br />- this can help mitigate potential issues.- </p>- </TooltipContent>- </Tooltip>- </TooltipProvider>- </Label>- <div className="flex items-center space-x-4">- <Slider- id="restartInterval"- min={0}- max={1440} // 24 hours- step={30}- value={[localSettings.restartInterval]}- onValueChange={handleRestartIntervalChange}- className="flex-grow"- />- <span className="w-16 text-right">- {localSettings.restartInterval} min- </span>- </div>- </div><div className="flex flex-col space-y-2"><div className="flex items-center space-x-2">diff --git a/screenpipe-app-tauri/components/screenpipe-status.tsx b/screenpipe-app-tauri/components/screenpipe-status.tsxindex b65a63732..2139d2540 100644--- a/screenpipe-app-tauri/components/screenpipe-status.tsx+++ b/screenpipe-app-tauri/components/screenpipe-status.tsx@@ -67,8 +67,6 @@ const HealthStatus = ({ className }: { className?: string }) => {const { settings, getDataDir } = useSettings();const [localDataDir, setLocalDataDir] = useState("");const [isLogOpen, setIsLogOpen] = useState(false);- const [isFixingSetup, setIsFixingSetup] = useState(false);- const [currentStep, setCurrentStep] = useState(0);const [isDialogLoading, setIsDialogLoading] = useState(false);const [permissions, setPermissions] = useState<PermissionsStatus | null>(null@@ -78,18 +76,6 @@ const HealthStatus = ({ className }: { className?: string }) => {setIsMac(platform() === "macos");}, []);- useEffect(() => {- const handleSettingsUpdate = () => {- debouncedFetchHealth();- };-- window.addEventListener("settings-updated", handleSettingsUpdate);-- return () => {- window.removeEventListener("settings-updated", handleSettingsUpdate);- };- }, [debouncedFetchHealth]);-useEffect(() => {const checkPermissions = async () => {try {diff --git a/screenpipe-app-tauri/components/settings.tsx b/screenpipe-app-tauri/components/settings.tsxindex 625e02a88..701bb62b0 100644--- a/screenpipe-app-tauri/components/settings.tsx+++ b/screenpipe-app-tauri/components/settings.tsx@@ -48,9 +48,7 @@ import {} from "lucide-react";import { RecordingSettings } from "./recording-settings";import { Switch } from "./ui/switch";-import { Command } from "@tauri-apps/plugin-shell";import { LogFileButton } from "./log-file-button";-import { platform } from "@tauri-apps/plugin-os";import { toast } from "@/components/ui/use-toast";import { invoke } from "@tauri-apps/api/core";@@ -66,19 +64,22 @@ import {} from "@/components/ui/select";import { useInterval } from "@/lib/hooks/use-interval";import { useHealthCheck } from "@/lib/hooks/use-health-check";-import { AuthButton } from "./auth";import { DropdownMenuItem } from "./ui/dropdown-menu";export function Settings({ className }: { className?: string }) {- const { settings, updateSettings, resetSetting, resetSettings } =- useSettings();+ const {+ settings,+ updateSettings,+ resetSetting,+ resetSettings,+ localSettings,+ setLocalSettings,+ } = useSettings();const { debouncedFetchHealth } = useHealthCheck();- const [localSettings, setLocalSettings] = React.useState(settings);const [showApiKey, setShowApiKey] = React.useState(false);const [ollamaStatus, setOllamaStatus] = useState<"idle" | "running" | "error">("idle");- const [currentPlatform, setCurrentPlatform] = useState("unknown");const [selectedModifiers, setSelectedModifiers] = useState<string[]>([]);const [nonModifierKey, setNonModifierKey] = useState<string>("");@@ -154,10 +155,6 @@ export function Settings({ className }: { className?: string }) {const newShortcut = [...selectedModifiers, nonModifierKey].join("+");const isShortcutChanged = newShortcut !== currentShortcut;- useEffect(() => {- setCurrentPlatform(platform());- }, []);-const handleApiKeyChange = (e: React.ChangeEvent<HTMLInputElement>) => {const newValue = e.target.value;setLocalSettings({ ...localSettings, openaiApiKey: newValue });@@ -232,10 +229,6 @@ export function Settings({ className }: { className?: string }) {updateSettings({ embeddedLLM: newValue });};- React.useEffect(() => {- setLocalSettings(settings);- }, [settings]);-const startOllamaSidecar = async () => {setOllamaStatus("running");toast({@@ -459,13 +452,6 @@ export function Settings({ className }: { className?: string }) {}};- const isCustomUrl = ![- "https://api.openai.com/v1",- "http://localhost:11434/v1",- "https://ai-proxy.i-f9f.workers.dev/v1",- "embedded",- ].includes(localSettings.aiUrl);-// Add this function to check the embedded AI statusconst checkEmbeddedAIStatus = useCallback(async () => {if (localSettings.embeddedLLM.enabled) {@@ -518,18 +504,6 @@ export function Settings({ className }: { className?: string }) {});};- useEffect(() => {- const handleSettingsUpdate = () => {- debouncedFetchHealth();- };-- window.addEventListener("settings-updated", handleSettingsUpdate);-- return () => {- window.removeEventListener("settings-updated", handleSettingsUpdate);- };- }, [debouncedFetchHealth]);-const handleResetSettings = async () => {try {await resetSettings();diff --git a/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/screenpipe-app-tauri/lib/hooks/use-settings.tsxindex e5482080f..945dea6e8 100644--- a/screenpipe-app-tauri/lib/hooks/use-settings.tsx+++ b/screenpipe-app-tauri/lib/hooks/use-settings.tsx@@ -25,7 +25,7 @@ export enum Shortcut {SHOW_SCREENPIPE = "show_screenpipe",}-export type Settings= {+export type Settings = {openaiApiKey: string;deepgramApiKey: string;isLoading: boolean;@@ -62,7 +62,7 @@ export type Settings= {enableUiMonitoring: boolean; // Add this lineplatform: string; // Add this linedisabledShortcuts: Shortcut[];-}+};const DEFAULT_SETTINGS: Settings = {openaiApiKey: "",@@ -141,33 +141,30 @@ const DEFAULT_IGNORED_WINDOWS_PER_OS: Record<string, string[]> = {"DeepL","Control Center",],- windows: [- "Nvidia",- "Control Panel",- "System Properties",- ],- linux: [- "Info center",- "Discover",- "Parted"- ]-}+ windows: ["Nvidia", "Control Panel", "System Properties"],+ linux: ["Info center", "Discover", "Parted"],+};let store: Awaited<ReturnType<typeof createStore>> | null = null;export function useSettings() {const [settings, setSettings] = useState<Settings>(DEFAULT_SETTINGS);+ const [localSettings, setLocalSettings] = useState<Settings>(settings);useEffect(() => {posthog.identify(settings.userId);}, [settings.userId]);+ useEffect(() => {+ setLocalSettings(settings);+ }, [settings]);+const resetSetting = async (key: keyof Settings) => {if (!store) {await initStore();}- const defaultSettings = createDefaultSettingsObject(platform())+ const defaultSettings = createDefaultSettingsObject(platform());try {const updatedSettings = { ...settings, [key]: defaultSettings[key] };@@ -182,12 +179,10 @@ export function useSettings() {};const resetSettings = async () => {- const userSettings = createDefaultSettingsObject(- platform()- )+ const userSettings = createDefaultSettingsObject(platform());- updateSettings(userSettings)- }+ updateSettings(userSettings);+ };const loadSettings = async () => {if (!store) {@@ -196,15 +191,12 @@ export function useSettings() {try {const currentPlatform = platform();- const userSettings = await createUserSettings(- store!,- currentPlatform- )+ const userSettings = await createUserSettings(store!, currentPlatform);- setSettings({...userSettings, isLoading: false});+ setSettings({ ...userSettings, isLoading: false });} catch (error) {console.error("failed to load settings:", error);- setSettings((prevSettings) => ({ ...prevSettings, isLoading: false }));+ setSettings((prevSettings) => ({ ...prevSettings, isLoading: false }));}};@@ -218,22 +210,26 @@ export function useSettings() {}try {+ // Create complete updated settings objectconst updatedSettings = { ...settings, ...newSettings };- setSettings(updatedSettings);- // Update all changed fields regardless of their values- for (const key in newSettings) {- if (Object.prototype.hasOwnProperty.call(newSettings, key)) {- console.log(- `Setting ${key}:`,- updatedSettings[key as keyof Settings]- );- await store!.set(key, updatedSettings[key as keyof Settings]);- }+ // Save each setting individually to the store+ for (const [key, value] of Object.entries(updatedSettings)) {+ await store!.set(key, value);}++ // Update local state+ setLocalSettings(updatedSettings);+ setSettings(updatedSettings);++ // Force save to disk+ await store!.save();++ console.log("settings saved successfully:", updatedSettings);} catch (error) {console.error("failed to update settings:", error);setSettings(settings);+ throw error;}};@@ -252,7 +248,15 @@ export function useSettings() {: `${homeDirPath}\\.screenpipe`;};- return { settings, updateSettings, resetSetting, getDataDir, resetSettings };+ return {+ settings,+ updateSettings,+ resetSetting,+ getDataDir,+ resetSettings,+ localSettings,+ setLocalSettings,+ };}async function initStore() {@@ -261,8 +265,8 @@ async function initStore() {store = await createStore(storePath);}-function createDefaultSettingsObject(currentPlatform: string){- let defaultSettings = DEFAULT_SETTINGS+function createDefaultSettingsObject(currentPlatform: string) {+ let defaultSettings = DEFAULT_SETTINGS;const ocrModel =currentPlatform === "macos"@@ -271,29 +275,30 @@ function createDefaultSettingsObject(currentPlatform: string){? "windows-native": "tesseract";- defaultSettings.ocrEngine = ocrModel- defaultSettings.fps = currentPlatform === "macos" ? 0.2 : 1+ defaultSettings.ocrEngine = ocrModel;+ defaultSettings.fps = currentPlatform === "macos" ? 0.2 : 1;defaultSettings.ignoredWindows = [...DEFAULT_IGNORED_WINDOWS_IN_ALL_OS,- ...(DEFAULT_IGNORED_WINDOWS_PER_OS[currentPlatform] ?? [])- ]+ ...(DEFAULT_IGNORED_WINDOWS_PER_OS[currentPlatform] ?? []),+ ];- return defaultSettings+ return defaultSettings;}async function createUserSettings(store: Store,currentPlatform: string): Promise<Settings> {- let defaultSettingsObject = createDefaultSettingsObject(currentPlatform)-- let userSettingsObject: Record<string,any> = {}+ let defaultSettingsObject = createDefaultSettingsObject(currentPlatform);+ let userSettingsObject: Record<string, any> = {};for (const key of Object.keys(defaultSettingsObject)) {- userSettingsObject[key] =- await store.get(key) || defaultSettingsObject[key as keyof Settings]+ const storedValue = await store.get(key);+ userSettingsObject[key] = storedValue === null || storedValue === undefined+ ? defaultSettingsObject[key as keyof Settings]+ : storedValue;}- return userSettingsObject as Settings-}\ No newline at end of file+ return userSettingsObject as Settings;+}diff --git a/screenpipe-app-tauri/src-tauri/Cargo.lock b/screenpipe-app-tauri/src-tauri/Cargo.lockindex 7c11506f2..ca0c8e5b8 100755--- a/screenpipe-app-tauri/src-tauri/Cargo.lock+++ b/screenpipe-app-tauri/src-tauri/Cargo.lock@@ -4713,7 +4713,7 @@ dependencies = [[[package]]name = "screenpipe-app"-version = "0.15.2"+version = "0.15.5"dependencies = ["anyhow","axum",diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.tomlindex 4d887b473..63a32d9d3 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.15.4"+version = "0.15.5"description = ""authors = ["you"]license = ""diff --git a/screenpipe-app-tauri/src-tauri/src/analytics.rs b/screenpipe-app-tauri/src-tauri/src/analytics.rsindex e3a61c92d..d9597fcae 100755--- a/screenpipe-app-tauri/src-tauri/src/analytics.rs+++ b/screenpipe-app-tauri/src-tauri/src/analytics.rs@@ -147,7 +147,6 @@ pub fn start_analytics(if let Err(e) = analytics_manager.send_event("app_started", None).await {error!("Failed to send initial PostHog event: {}", e);}- info!("Analytics started");}});