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: make sure backend properly start when non dev mode at app boot
Louis Beaumonte78e652e79d6
diff --git a/screenpipe-app-tauri/components/dev-mode-settings.tsx b/screenpipe-app-tauri/components/dev-mode-settings.tsxindex fc3fe194c..23eef3948 100644--- a/screenpipe-app-tauri/components/dev-mode-settings.tsx+++ b/screenpipe-app-tauri/components/dev-mode-settings.tsx@@ -207,7 +207,7 @@ export const DevModeSettings = () => {<><div className="w-full my-4"><div className="flex justify-around">- <Card className="p-4 relative">+ <Card className="p-8 relative"><CardContent><div className="flex flex-col space-y-2"><div className="flex items-center justify-between">@@ -234,10 +234,10 @@ export const DevModeSettings = () => {</Card><div className="relative">- <Badge className="text-xs absolute -top-3 left-1/2 transform -translate-x-1/2 z-10">+ <Badge className="bg-white text-gray-800 hover:bg-white/80 text-xs absolute -top-3 left-1/2 transform -translate-x-1/2 z-10">expert only</Badge>- <Card className="p-4">+ <Card className="p-8"><CardContent><div className="flex items-center space-x-2"><div className="flex flex-col items-center w-full">diff --git a/screenpipe-app-tauri/components/log-file-button.tsx b/screenpipe-app-tauri/components/log-file-button.tsxindex 049e8feea..f8972a02e 100644--- a/screenpipe-app-tauri/components/log-file-button.tsx+++ b/screenpipe-app-tauri/components/log-file-button.tsx@@ -8,22 +8,30 @@ import {TooltipTrigger,} from "./ui/tooltip";import { Button } from "./ui/button";-import { FileText } from "lucide-react";+import { FileText, Copy } from "lucide-react";import { open } from "@tauri-apps/plugin-shell";+import { readTextFile } from "@tauri-apps/plugin-fs";+import { useCopyToClipboard } from "@/lib/hooks/use-copy-to-clipboard";+import { cn } from "@/lib/utils";export const LogFileButton = ({ className }: { className?: string }) => {const { toast } = useToast();+ const { copyToClipboard } = useCopyToClipboard({ timeout: 3000 });++ const getLogFilePath = async () => {+ const homeDirPath = await homeDir();+ return platform() === "windows"+ ? `${homeDirPath}\\.screenpipe\\screenpipe.${+ new Date().toISOString().split("T")[0]+ }.log`+ : `${homeDirPath}/.screenpipe/screenpipe.${+ new Date().toISOString().split("T")[0]+ }.log`;+ };+const handleOpenLogFile = async () => {try {- const homeDirPath = await homeDir();- const logPath =- platform() === "windows"- ? `${homeDirPath}\\.screenpipe\\screenpipe.${- new Date().toISOString().split("T")[0]- }.log`- : `${homeDirPath}/.screenpipe/screenpipe.${- new Date().toISOString().split("T")[0]- }.log`;+ const logPath = await getLogFilePath();await open(logPath);} catch (error) {console.error("failed to open log file:", error);@@ -35,23 +43,59 @@ export const LogFileButton = ({ className }: { className?: string }) => {});}};++ const handleCopyLogs = async () => {+ try {+ const logPath = await getLogFilePath();+ const logContent = await readTextFile(logPath);+ copyToClipboard(logContent);+ toast({+ title: "success",+ description: "logs copied to clipboard.",+ duration: 3000,+ });+ } catch (error) {+ console.error("failed to copy logs:", error);+ toast({+ title: "error",+ description: "failed to copy logs.",+ variant: "destructive",+ duration: 3000,+ });+ }+ };+return (- <TooltipProvider>- <Tooltip>- <TooltipTrigger asChild>- <Button- variant="outline"- size="sm"- onClick={handleOpenLogFile}- className="ml-2"- >- <FileText className="h-4 w-4" />- </Button>- </TooltipTrigger>- <TooltipContent>- <p>open log file</p>- </TooltipContent>- </Tooltip>- </TooltipProvider>+ <div className={cn("flex", className)}>+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <Button+ variant="outline"+ size="sm"+ onClick={handleOpenLogFile}+ className="mr-2"+ >+ <FileText className="h-4 w-4" />+ </Button>+ </TooltipTrigger>+ <TooltipContent>+ <p>open log file</p>+ </TooltipContent>+ </Tooltip>+ </TooltipProvider>+ {/* <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <Button variant="outline" size="sm" onClick={handleCopyLogs}>+ <Copy className="h-4 w-4" />+ </Button>+ </TooltipTrigger>+ <TooltipContent>+ <p>copy logs to clipboard</p>+ </TooltipContent>+ </Tooltip>+ </TooltipProvider> */}+ </div>);};diff --git a/screenpipe-app-tauri/components/onboarding.tsx b/screenpipe-app-tauri/components/onboarding.tsxindex eda81f0c8..9f8994a37 100644--- a/screenpipe-app-tauri/components/onboarding.tsx+++ b/screenpipe-app-tauri/components/onboarding.tsx@@ -12,6 +12,7 @@ import OnboardingDevConfig from "@/components/onboarding/dev-configuration";import OnboardingSelection from "@/components/onboarding/usecases-selection";import OnboardingInstructions from "@/components/onboarding/explain-instructions";import { useOnboarding } from "@/lib/hooks/use-onboarding";+import { useSettings } from "@/lib/hooks/use-settings";const setFirstTimeUserFlag = async () => {await localforage.setItem("isFirstTimeUser", false);@@ -139,6 +140,7 @@ const Onboarding: React.FC = () => {const [error, setError] = useState<string | null>(null);const [isVisible, setIsVisible] = useState(false);const { showOnboarding, setShowOnboarding } = useOnboarding();+ const { updateSettings } = useSettings();useEffect(() => {setIsVisible(true);@@ -156,8 +158,6 @@ const Onboarding: React.FC = () => {}}, [showOnboarding]);--useEffect(() => {if (error) {toast({@@ -233,6 +233,9 @@ const Onboarding: React.FC = () => {const handleEnd = async () => {setShowOnboarding(false);await setFirstTimeUserFlag();+ updateSettings({+ isFirstTimeUser: false,+ });};return (diff --git a/screenpipe-app-tauri/components/screenpipe-status.tsx b/screenpipe-app-tauri/components/screenpipe-status.tsxindex 0eb09f713..4e954c61d 100644--- a/screenpipe-app-tauri/components/screenpipe-status.tsx+++ b/screenpipe-app-tauri/components/screenpipe-status.tsx@@ -5,6 +5,7 @@ import {DialogContent,DialogHeader,DialogTitle,+ DialogTrigger,} from "@/components/ui/dialog";import { CodeBlock } from "@/components/ui/codeblock";import { platform } from "@tauri-apps/plugin-os";@@ -25,7 +26,16 @@ 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 { Lock, Folder, FileText, Activity, Wrench } from "lucide-react";+import {+ Lock,+ Folder,+ FileText,+ Activity,+ Wrench,+ RefreshCw,+ HardDrive,+ HelpCircle,+} from "lucide-react";import { open } from "@tauri-apps/plugin-shell";import { homeDir } from "@tauri-apps/api/path";import LogViewer from "./log-viewer-v2";@@ -38,6 +48,8 @@ import { Command } from "@tauri-apps/plugin-shell";import { CliCommandDialog } from "./cli-command-dialog";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";const HealthStatus = ({ className }: { className?: string }) => {const { health } = useHealthCheck();@@ -46,6 +58,8 @@ const HealthStatus = ({ className }: { className?: string }) => {const { settings } = useSettings();const [isLogOpen, setIsLogOpen] = useState(false);const [isFixingSetup, setIsFixingSetup] = useState(false);+ const [isTroubleshootOpen, setIsTroubleshootOpen] = useState(false);+ const [currentStep, setCurrentStep] = useState(0);useEffect(() => {setIsMac(platform() === "macos");@@ -188,6 +202,106 @@ const HealthStatus = ({ className }: { className?: string }) => {}};+ const troubleshootingSteps = [+ {+ title: "try fixing setup",+ description: "attempt to automatically fix common setup issues",+ action: (+ <Button+ variant="outline"+ onClick={handleFixSetup}+ disabled={isFixingSetup}+ >+ <Wrench className="mr-2 h-4 w-4" />+ {isFixingSetup ? "fixing..." : "fix setup"}+ </Button>+ ),+ },+ {+ title: "restart screenpipe recording",+ description: "click stop and start again",+ action: (+ <Button+ variant="outline"+ onClick={async () => {+ const toastId = toast({+ title: "stopping screenpipe",+ description: "please wait...",+ duration: Infinity,+ });+ try {+ await invoke("kill_all_sreenpipes");+ await new Promise((resolve) => setTimeout(resolve, 2000));+ toastId.update({+ id: toastId.id,+ title: "screenpipe stopped",+ description: "screenpipe is now stopped.",+ duration: 3000,+ });+ } catch (error) {+ console.error("failed to stop screenpipe:", error);+ toastId.update({+ id: toastId.id,+ title: "error",+ description: "failed to stop screenpipe.",+ variant: "destructive",+ duration: 3000,+ });+ } finally {+ toastId.dismiss();+ }+ }}+ >+ <RefreshCw className="mr-2 h-4 w-4" />+ restart recording+ </Button>+ ),+ },+ {+ title: "check permissions",+ description: "ensure screen and audio recording permissions are granted",+ action: isMac ? (+ <Button variant="outline" onClick={openScreenPermissions}>+ <Lock className="mr-2 h-4 w-4" />+ open screen permissions+ </Button>+ ) : null,+ },+ {+ title: "contact support",+ description: "if the issue persists, reach out to our support team",+ action: (+ <div className="flex flex-col space-y-2 ">+ <div className="flex items-center space-x-2 justify-center">+ <p className="text-sm">please share your logs with support:</p>+ <LogFileButton />+ </div>+ <Button+ variant="outline"+ onClick={() => open("mailto:[email protected]")}+ >+ <FileText className="mr-2 h-4 w-4" />+ email founders+ </Button>+ <Button+ variant="outline"+ onClick={() => open("https://cal.com/louis030195/screenpipe")}+ >+ <Activity className="mr-2 h-4 w-4" />+ book a call w founders+ </Button>+ <Button+ variant="outline"+ onClick={() => open("https://discord.gg/dU9EBuw7Uq")}+ >+ <HelpCircle className="mr-2 h-4 w-4" />+ join our discord+ </Button>+ </div>+ ),+ },+ ];+if (!health) {return (<Badge@@ -235,47 +349,12 @@ const HealthStatus = ({ className }: { className?: string }) => {</Badge><Dialog open={isDialogOpen} onOpenChange={setIsDialogOpen}><DialogContent- className="max-w-3xl max-h-[80vh] flex flex-col p-8"+ className="max-w-4xl max-h-[100vh] flex flex-col p-8"aria-describedby="status-dialog-description"><DialogHeader className="flex flex-row items-center justify-between"><DialogTitle>screenpipe status</DialogTitle><div className="flex space-x-2">- <TooltipProvider>- <Tooltip>- <TooltipTrigger asChild>- <Button- variant="outline"- size="icon"- onClick={handleFixSetup}- disabled={isFixingSetup}- >- <Wrench className="h-4 w-4" />- </Button>- </TooltipTrigger>- <TooltipContent>- <p>try fixing setup</p>- </TooltipContent>- </Tooltip>- </TooltipProvider>- {isMac && (- <TooltipProvider>- <Tooltip>- <TooltipTrigger asChild>- <Button- variant="outline"- size="icon"- onClick={openScreenPermissions}- >- <Lock className="h-4 w-4" />- </Button>- </TooltipTrigger>- <TooltipContent>- <p>open screen permissions</p>- </TooltipContent>- </Tooltip>- </TooltipProvider>- )}<Buttonvariant="outline"onClick={handleOpenDataDir}@@ -284,6 +363,13 @@ const HealthStatus = ({ className }: { className?: string }) => {<Folder className="h-4 w-4 mr-2" />view saved data</Button>+ <Button+ variant="outline"+ onClick={() => setIsTroubleshootOpen(true)}+ >+ <Wrench className="h-4 w-4 mr-2" />+ troubleshoot+ </Button></div></DialogHeader><div className="flex-grow overflow-auto">@@ -305,40 +391,8 @@ const HealthStatus = ({ className }: { className?: string }) => {: formatTimestamp(health.last_audio_timestamp)}</p></div>- <div className="text-sm mt-4">- <p className="font-semibold mb-2">- if you're having issues:- </p>- <ol className="list-decimal list-inside space-y-1">- <li>try restarting screenpipe</li>- <li>- check your computer's screen and audio recording- permissions- </li>- <li>- if problems continue, contact support at{" "}- <a- href="mailto:[email protected]"- className="hover:underline"- >- </a>- </li>- <li>- view our{" "}- <a- href="https://github.com/mediar-ai/screenpipe/blob/main/content/docs/NOTES.md"- target="_blank"- rel="noopener noreferrer"- className="hover:underline"- >- FAQ page- </a>{" "}- for more help- </li>- </ol>- </div>- <Separator className="my-4" />++ <Separator className="my-12" /><DevModeSettings /><Collapsible@@ -360,6 +414,55 @@ const HealthStatus = ({ className }: { className?: string }) => {</div></DialogContent></Dialog>++ <Dialog open={isTroubleshootOpen} onOpenChange={setIsTroubleshootOpen}>+ <DialogContent className="max-w-2xl">+ <DialogHeader>+ <DialogTitle className="text-center">+ troubleshooting guide+ </DialogTitle>+ </DialogHeader>+ <div className="mt-6">+ <div className="mb-16">+ <h3 className="text-2xl font-bold mb-4 text-center">+ {troubleshootingSteps[currentStep].title}+ </h3>+ <p className="text-xl text-center mb-4">+ {troubleshootingSteps[currentStep].description}+ </p>+ {troubleshootingSteps[currentStep].action && (+ <div className="flex justify-center">+ {troubleshootingSteps[currentStep].action}+ </div>+ )}+ </div>+ <div className="flex justify-between items-center">+ <Button+ variant="outline"+ onClick={() => setCurrentStep((prev) => Math.max(0, prev - 1))}+ disabled={currentStep === 0}+ >+ <ChevronLeft className="mr-2 h-4 w-4" />+ previous+ </Button>+ <span className="text-sm text-gray-500">+ {currentStep + 1} / {troubleshootingSteps.length}+ </span>+ <Button+ onClick={() =>+ setCurrentStep((prev) =>+ Math.min(troubleshootingSteps.length - 1, prev + 1)+ )+ }+ disabled={currentStep === troubleshootingSteps.length - 1}+ >+ next+ <ChevronRight className="ml-2 h-4 w-4" />+ </Button>+ </div>+ </div>+ </DialogContent>+ </Dialog></>);};diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.tomlindex c936c4e1a..26cdec909 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.6.5"+version = "0.6.6"description = ""authors = ["you"]license = ""diff --git a/screenpipe-app-tauri/src-tauri/src/main.rs b/screenpipe-app-tauri/src-tauri/src/main.rsindex 11966ab4d..33220920c 100755--- a/screenpipe-app-tauri/src-tauri/src/main.rs+++ b/screenpipe-app-tauri/src-tauri/src/main.rs@@ -70,9 +70,9 @@ async fn main() {let _ = window.set_always_on_top(false);let _ = window.set_visible_on_all_workspaces(false);#[cfg(target_os = "macos")]- let _ = window- .app_handle()- .set_activation_policy(tauri::ActivationPolicy::Regular);+ let _ = window+ .app_handle()+ .set_activation_policy(tauri::ActivationPolicy::Regular);window.hide().unwrap();api.prevent_close();}@@ -312,14 +312,23 @@ async fn main() {.unwrap_or(true);// double-check if they have any files in the data dir- let data_dir =- get_base_dir(&app_handle, None).expect("Failed to ensure local data directory");- let has_files = fs::read_dir(data_dir.join("data"))+ let data_dir = app+ .path()+ .home_dir()+ .expect("Failed to ensure local data directory");++ info!("data_dir: {}", data_dir.display());+ let has_files = fs::read_dir(data_dir.join(".screenpipe").join("data")).map(|mut entries| entries.next().is_some()).unwrap_or(false);+ info!("has_files: {}", has_files);+if has_files {is_first_time_user = false;+ // Update the store with the new value+ store.set("isFirstTimeUser".to_string(), Value::Bool(false));+ store.save().unwrap();}let sidecar_manager = Arc::new(Mutex::new(SidecarManager::new()));@@ -327,6 +336,11 @@ async fn main() {let app_handle = app.handle().clone();+ info!(+ "will start sidecar: {}",+ !use_dev_mode && !is_first_time_user+ );+if !use_dev_mode && !is_first_time_user {tauri::async_runtime::spawn(async move {let mut manager = sidecar_manager.lock().await;