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: settings update issue
Louis Beaumont40dc63313857
diff --git a/screenpipe-app-tauri/components/dev-dialog.tsx b/screenpipe-app-tauri/components/dev-dialog.tsxdeleted file mode 100644index f818c47d9..000000000--- a/screenpipe-app-tauri/components/dev-dialog.tsx+++ /dev/null@@ -1,149 +0,0 @@-import React, { useEffect, useState } from "react";-import { Button } from "@/components/ui/button";-import {- Dialog,- DialogContent,- DialogHeader,- DialogTitle,- DialogTrigger,-} from "@/components/ui/dialog";-import { Input } from "@/components/ui/input";-import { Label } from "@/components/ui/label";-import { Switch } from "@/components/ui/switch";-import { Textarea } from "@/components/ui/textarea";-import { useSettings } from "@/lib/hooks/use-settings";-import { useToast } from "@/components/ui/use-toast";--export function DevSettings() {- const { settings, updateSettings } = useSettings();- const [localSettings, setLocalSettings] = React.useState(settings);- const [isSaving, setIsSaving] = useState(false);- const { toast } = useToast();-- React.useEffect(() => {- setLocalSettings(settings);- }, [settings]);-- const handleChange = (key: keyof typeof settings, value: any) => {- setLocalSettings((prev) => ({ ...prev, [key]: value }));- };-- const handleSave = async () => {- setIsSaving(true);- toast({- title: "updating dev settings",- description: "this may take a few moments...",- });-- try {- // Create an object to store only the changed settings- const changedSettings = Object.entries(localSettings).reduce(- (acc, [key, value]) => {- if (value !== settings[key as keyof typeof settings]) {- acc[key as keyof typeof settings] = value;- }- return acc;- },- {} as Partial<typeof settings>- );-- // Only update if there are changes- if (Object.keys(changedSettings).length > 0) {- await updateSettings(changedSettings);- await new Promise((resolve) => setTimeout(resolve, 1000));-- toast({- title: "dev settings updated successfully",- description: "your changes have been saved.",- });- } else {- toast({- title: "no changes detected",- description: "no settings were updated.",- });- }- } catch (error) {- console.error("failed to update dev settings:", error);- toast({- title: "error updating dev settings",- description: "please try again or check the logs for more information.",- variant: "destructive",- });- } finally {- setIsSaving(false);- }- };-- return (- <Dialog>- <DialogTrigger asChild>- <Button variant="outline">dev settings</Button>- </DialogTrigger>- <DialogContent className="max-w-[80vw] w-full max-h-[80vh] overflow-y-auto">- <DialogHeader>- <DialogTitle>dev settings</DialogTitle>- </DialogHeader>- <div className="space-y-4">- {Object.entries(localSettings).map(([key, value]) => (- <div key={key} className="flex flex-col space-y-2">- <Label htmlFor={key}>{key}</Label>- {typeof value === "boolean" ? (- <Switch- id={key}- checked={value}- onCheckedChange={(checked) =>- handleChange(key as any, checked)- }- />- ) : typeof value === "string" ? (- key === "customPrompt" ? (- <Textarea- id={key}- value={value}- onChange={(e) => handleChange(key as any, e.target.value)}- rows={4}- />- ) : (- <Input- id={key}- value={value}- onChange={(e) => handleChange(key as any, e.target.value)}- />- )- ) : typeof value === "number" ? (- <Input- id={key}- type="number"- value={value}- onChange={(e) =>- handleChange(key as any, Number(e.target.value))- }- />- ) : Array.isArray(value) ? (- <Textarea- id={key}- value={JSON.stringify(value)}- onChange={(e) =>- handleChange(key as any, JSON.parse(e.target.value))- }- rows={4}- />- ) : (- <Input- id={key}- value={JSON.stringify(value)}- onChange={(e) =>- handleChange(key as any, JSON.parse(e.target.value))- }- />- )}- </div>- ))}- </div>- <Button onClick={handleSave} className="mt-4" disabled={isSaving}>- {isSaving ? "saving..." : "save changes"}- </Button>- </DialogContent>- </Dialog>- );-}diff --git a/screenpipe-app-tauri/components/pipe-store.tsx b/screenpipe-app-tauri/components/pipe-store.tsxindex 3c3e317e0..7e9bd8a22 100644--- a/screenpipe-app-tauri/components/pipe-store.tsx+++ b/screenpipe-app-tauri/components/pipe-store.tsx@@ -15,8 +15,6 @@ import { MemoizedReactMarkdown } from "@/components/markdown";import { CodeBlock } from "@/components/ui/codeblock";import remarkGfm from "remark-gfm";import remarkMath from "remark-math";-import { useSettings } from "@/lib/hooks/use-settings";-import { invoke } from "@tauri-apps/api/core";import { toast } from "./ui/use-toast";import { Input } from "./ui/input";import {diff --git a/screenpipe-app-tauri/components/recording-settings.tsx b/screenpipe-app-tauri/components/recording-settings.tsxindex e925eb929..d28cfba9b 100644--- a/screenpipe-app-tauri/components/recording-settings.tsx+++ b/screenpipe-app-tauri/components/recording-settings.tsx@@ -59,6 +59,7 @@ import {} from "./ui/dialog";import { CodeBlock } from "./ui/codeblock";import { useCopyToClipboard } from "@/lib/hooks/use-copy-to-clipboard";+import { platform } from "@tauri-apps/plugin-os";interface AudioDevice {name: string;@@ -76,11 +77,9 @@ interface MonitorDevice {export function RecordingSettings({localSettings,setLocalSettings,- currentPlatform,}: {localSettings: Settings;setLocalSettings: (settings: Settings) => void;- currentPlatform: string;}) {const { settings, updateSettings } = useSettings();const [openAudioDevices, setOpenAudioDevices] = React.useState(false);@@ -98,9 +97,7 @@ export function RecordingSettings({const isDisabled = health?.status_code === 500;const [isCopyDialogOpen, setIsCopyDialogOpen] = useState(false);const { copyToClipboard } = useCopyToClipboard({ timeout: 2000 });- console.log("localSettings", localSettings);- console.log("settings", settings);- console.log("availableMonitors", availableMonitors);+useEffect(() => {const loadDevices = async () => {try {@@ -180,7 +177,7 @@ export function RecordingSettings({};loadDevices();- }, [localSettings, setLocalSettings]);+ }, [settings]);const handleUpdate = async () => {setIsUpdating(true);@@ -393,6 +390,29 @@ export function RecordingSettings({});};+ const renderOcrEngineOptions = () => {+ 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>+ )}+ {currentPlatform === "windows" && (+ <SelectItem value="windows-native">windows native</SelectItem>+ )}+ {currentPlatform === "macos" && (+ <SelectItem value="apple-native">apple native</SelectItem>+ )}+ </>+ );+ };+return (<><div className="relative">@@ -460,25 +480,7 @@ export function RecordingSettings({<SelectTrigger><SelectValue placeholder="select ocr engine" /></SelectTrigger>- <SelectContent>- <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 !== "macos" && (- <SelectItem value="tesseract">tesseract</SelectItem>- )}- {currentPlatform === "windows" && (- <SelectItem value="windows-native">- windows native- </SelectItem>- )}- {currentPlatform === "macos" && (- <SelectItem value="apple-native">apple native</SelectItem>- )}- </SelectContent>+ <SelectContent>{renderOcrEngineOptions()}</SelectContent></Select></div>diff --git a/screenpipe-app-tauri/components/screenpipe-status.tsx b/screenpipe-app-tauri/components/screenpipe-status.tsxindex 9e5e7c821..3778c3610 100644--- a/screenpipe-app-tauri/components/screenpipe-status.tsx+++ b/screenpipe-app-tauri/components/screenpipe-status.tsx@@ -25,7 +25,6 @@ import { Button } from "./ui/button";import { Separator } from "./ui/separator";import { Card, CardContent, CardFooter } from "./ui/card";import { useHealthCheck } from "@/lib/hooks/use-health-check";-import { DevSettings } from "./dev-dialog";import { Lock, Folder, FileText, Activity } from "lucide-react";import { open } from "@tauri-apps/plugin-shell";import { homeDir } from "@tauri-apps/api/path";@@ -122,8 +121,7 @@ const DevModeSettings = () => {const handleDevModeToggle = async (checked: boolean) => {try {await updateSettings({ devMode: checked });- setLocalSettings((prev) => ({ ...prev, devMode: checked }));- // ... rest of the function ...+ setLocalSettings({ ...localSettings, devMode: checked });} catch (error) {console.error("Failed to update dev mode:", error);// Add error handling, e.g., show a toast notificationdiff --git a/screenpipe-app-tauri/components/settings.tsx b/screenpipe-app-tauri/components/settings.tsxindex 89225685c..7be6f0aea 100644--- a/screenpipe-app-tauri/components/settings.tsx+++ b/screenpipe-app-tauri/components/settings.tsx@@ -23,25 +23,23 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";import { Textarea } from "./ui/textarea";import { Slider } from "@/components/ui/slider"; // Add this import-import { platform } from "@tauri-apps/plugin-os";import { Eye, EyeOff, HelpCircle, RefreshCw, Settings2 } from "lucide-react";import { RecordingSettings } from "./recording-settings";export function Settings({ className }: { className?: string }) {const { settings, updateSettings, resetSetting } = useSettings();const [localSettings, setLocalSettings] = React.useState(settings);- const [currentPlatform, setCurrentPlatform] = React.useState<string>("");const [showApiKey, setShowApiKey] = React.useState(false);const handleApiUrlChange = (e: React.ChangeEvent<HTMLInputElement>) => {const newValue = e.target.value;- setLocalSettings((prev) => ({ ...prev, aiUrl: newValue }));+ setLocalSettings({ ...localSettings, aiUrl: newValue });updateSettings({ aiUrl: newValue });};const handleApiKeyChange = (e: React.ChangeEvent<HTMLInputElement>) => {const newValue = e.target.value;- setLocalSettings((prev) => ({ ...prev, openaiApiKey: newValue }));+ setLocalSettings({ ...localSettings, openaiApiKey: newValue });updateSettings({ openaiApiKey: newValue });};@@ -49,13 +47,13 @@ export function Settings({ className }: { className?: string }) {e: React.ChangeEvent<HTMLInputElement>) => {const newValue = e.target.value;- setLocalSettings((prev) => ({ ...prev, deepgramApiKey: newValue }));+ setLocalSettings({ ...localSettings, deepgramApiKey: newValue });updateSettings({ deepgramApiKey: newValue });};const handleModelChange = (e: React.ChangeEvent<HTMLInputElement>) => {const newValue = e.target.value;- setLocalSettings((prev) => ({ ...prev, aiModel: newValue }));+ setLocalSettings({ ...localSettings, aiModel: newValue });updateSettings({ aiModel: newValue });};@@ -63,7 +61,7 @@ export function Settings({ className }: { className?: string }) {e: React.ChangeEvent<HTMLTextAreaElement>) => {const newValue = e.target.value;- setLocalSettings((prev) => ({ ...prev, customPrompt: newValue }));+ setLocalSettings({ ...localSettings, customPrompt: newValue });updateSettings({ customPrompt: newValue });};@@ -73,22 +71,21 @@ export function Settings({ className }: { className?: string }) {const handleMaxContextCharsChange = (value: number[]) => {const newValue = value[0];- setLocalSettings((prev) => ({ ...prev, aiMaxContextChars: newValue }));+ setLocalSettings({ ...localSettings, aiMaxContextChars: newValue });updateSettings({ aiMaxContextChars: newValue });};React.useEffect(() => {setLocalSettings(settings);- setCurrentPlatform(platform());}, [settings]);return (<Dialog- onOpenChange={(open) => {- if (!open) {- location.reload(); // ! HACK to properly refresh stuff (tood beter)- }- }}+ // onOpenChange={(open) => {+ // if (!open) {+ // location.reload(); // ! HACK to properly refresh stuff (tood beter)+ // }+ // }}><DialogTrigger asChild><Button variant="ghost" className={className}>@@ -107,7 +104,6 @@ export function Settings({ className }: { className?: string }) {<RecordingSettingslocalSettings={localSettings}setLocalSettings={setLocalSettings}- currentPlatform={currentPlatform}/><Separator />diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.tomlindex 0b92a6e31..02947f21d 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.2.79"+version = "0.2.80"description = ""authors = ["you"]license = ""@@ -114,4 +114,4 @@ custom-protocol = [ "tauri/custom-protocol" ][package.metadata.cargo-machete]-ignored = ["tauri-utils"]\ No newline at end of file+ignored = ["tauri-utils"]