Skip to content

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

fix: settings shouldn't be usable until loading finished

Louis Beaumont4f418af75fa5
diff --git a/screenpipe-app-tauri/components/example-search-cards.tsx b/screenpipe-app-tauri/components/example-search-cards.tsx
index a20886715..588be3870 100644
--- a/screenpipe-app-tauri/components/example-search-cards.tsx
+++ b/screenpipe-app-tauri/components/example-search-cards.tsx
@@ -1,7 +1,14 @@
import React from "react";
import { Card, CardContent } from "@/components/ui/card";
-import { Search, Mail, Clock } from "lucide-react";
+import { Search, Mail, Clock, AlertCircle } from "lucide-react";
import { Badge } from "./ui/badge";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipProvider,
+ TooltipTrigger,
+} from "./ui/tooltip";
+import { useHealthCheck } from "@/lib/hooks/use-health-check";
export interface ExampleSearch {
title: string;
@@ -43,6 +50,7 @@ const exampleSearches: ExampleSearch[] = [
];
export function ExampleSearchCards({ onSelect }: ExampleSearchCardsProps) {
+ const { health } = useHealthCheck();
const getIcon = (title: string) => {
switch (title) {
case "summarize last hour meeting":
@@ -56,37 +64,63 @@ export function ExampleSearchCards({ onSelect }: ExampleSearchCardsProps) {
}
};
+ const isHealthError = health?.status === "error";
+
return (
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 mt-4">
{exampleSearches.map((example, index) => (
- <div key={index} className="relative group h-[150px]">
- <div className="absolute inset-0 rounded-lg transition-all duration-300 ease-out group-hover:before:opacity-100 group-hover:before:scale-100 before:absolute before:inset-0 before:rounded-lg before:border-2 before:border-black dark:before:border-white before:opacity-0 before:scale-95 group-hover:before:opacity-100 group-hover:before:scale-100 before:transition-all before:duration-300 before:ease-out" />
- <Card
- className="cursor-pointer relative bg-white dark:bg-gray-800 z-10 h-full transition-transform duration-300 ease-out group-hover:scale-[0.98]"
- onClick={() => onSelect(example)}
- >
- <CardContent className="p-3 flex flex-col h-full">
- <div className="flex items-center mb-1">
- {getIcon(example.title)}
- <h3 className="text-sm font-semibold">{example.title}</h3>
- </div>
- <div className="flex flex-wrap gap-2 mt-2">
- {example.contentType && <Badge>{example.contentType}</Badge>}
- {example.windowName && (
- <Badge>window: {example.windowName}</Badge>
- )}
- {example.appName && <Badge>app: {example.appName}</Badge>}
- {example.limit && <Badge>limit: {example.limit}</Badge>}
- {example.minLength && (
- <Badge>min: {example.minLength}</Badge>
- )}
- {example.startDate && (
- <Badge>start: {example.startDate.toLocaleString()}</Badge>
- )}
+ <TooltipProvider key={index}>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <div
+ className={`relative group h-[150px] ${
+ isHealthError ? "opacity-50 cursor-not-allowed" : ""
+ }`}
+ >
+ <div className="absolute inset-0 rounded-lg transition-all duration-300 ease-out group-hover:before:opacity-100 group-hover:before:scale-100 before:absolute before:inset-0 before:rounded-lg before:border-2 before:border-black dark:before:border-white before:opacity-0 before:scale-95 group-hover:before:opacity-100 group-hover:before:scale-100 before:transition-all before:duration-300 before:ease-out" />
+ <Card
+ className={`cursor-pointer relative bg-white dark:bg-gray-800 z-10 h-full transition-transform duration-300 ease-out ${
+ isHealthError ? "" : "group-hover:scale-[0.98]"
+ }`}
+ onClick={() => !isHealthError && onSelect(example)}
+ >
+ <CardContent className="p-3 flex flex-col h-full">
+ <div className="flex items-center mb-1">
+ {getIcon(example.title)}
+ <h3 className="text-sm font-semibold">{example.title}</h3>
+ </div>
+ <div className="flex flex-wrap gap-2 mt-2">
+ {example.contentType && (
+ <Badge>{example.contentType}</Badge>
+ )}
+ {example.windowName && (
+ <Badge>window: {example.windowName}</Badge>
+ )}
+ {example.appName && <Badge>app: {example.appName}</Badge>}
+ {example.limit && <Badge>limit: {example.limit}</Badge>}
+ {example.minLength && (
+ <Badge>min: {example.minLength}</Badge>
+ )}
+ {example.startDate && (
+ <Badge>
+ start: {example.startDate.toLocaleString()}
+ </Badge>
+ )}
+ </div>
+ </CardContent>
+ </Card>
</div>
- </CardContent>
- </Card>
- </div>
+ </TooltipTrigger>
+ {isHealthError && (
+ <TooltipContent>
+ <div className="flex items-center">
+ <AlertCircle className="mr-2 h-4 w-4 text-red-500" />
+ <p>screenpipe is not running. examples are disabled.</p>
+ </div>
+ </TooltipContent>
+ )}
+ </Tooltip>
+ </TooltipProvider>
))}
</div>
);
diff --git a/screenpipe-app-tauri/components/header.tsx b/screenpipe-app-tauri/components/header.tsx
index e8fb5ef7b..c60d3c03d 100644
--- a/screenpipe-app-tauri/components/header.tsx
+++ b/screenpipe-app-tauri/components/header.tsx
@@ -27,6 +27,8 @@ import Onboarding from "@/components/onboarding";
import { useOnboarding } from "@/lib/hooks/use-onboarding";
import { listen } from "@tauri-apps/api/event";
import localforage from "localforage";
+import { useHealthCheck } from "@/lib/hooks/use-health-check";
+import { Skeleton } from "@/components/ui/skeleton";
function IconNewChat() {
return (
@@ -46,13 +48,19 @@ function IconNewChat() {
</svg>
);
}
+
export default function Header() {
const [showInbox, setShowInbox] = useState(false);
const [messages, setMessages] = useState<Message[]>([]);
+ const { health } = useHealthCheck();
+
+ const isLoading = !health;
useEffect(() => {
const loadMessages = async () => {
- const savedMessages = await localforage.getItem<Message[]>("inboxMessages");
+ const savedMessages = await localforage.getItem<Message[]>(
+ "inboxMessages"
+ );
if (savedMessages) {
setMessages(savedMessages);
}
@@ -60,21 +68,24 @@ export default function Header() {
loadMessages();
- const unlisten = listen<Message>("inbox-message-received", async (event) => {
- console.log("inbox-message-received", event);
- const newMessage: Message = {
- id: Date.now().toString(),
- title: event.payload.title,
- body: event.payload.body,
- date: new Date().toISOString(),
- read: false,
- };
- setMessages((prevMessages) => {
- const updatedMessages = [newMessage, ...prevMessages];
- localforage.setItem("inboxMessages", updatedMessages);
- return updatedMessages;
- });
- });
+ const unlisten = listen<Message>(
+ "inbox-message-received",
+ async (event) => {
+ console.log("inbox-message-received", event);
+ const newMessage: Message = {
+ id: Date.now().toString(),
+ title: event.payload.title,
+ body: event.payload.body,
+ date: new Date().toISOString(),
+ read: false,
+ };
+ setMessages((prevMessages) => {
+ const updatedMessages = [newMessage, ...prevMessages];
+ localforage.setItem("inboxMessages", updatedMessages);
+ return updatedMessages;
+ });
+ }
+ );
return () => {
unlisten.then((unlistenFn) => unlistenFn());
@@ -103,107 +114,123 @@ export default function Header() {
return (
<div>
+ {isLoading ? (
+ <HeaderSkeleton />
+ ) : (
+ <>
+ <div className="absolute left-8 top-4">
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="secondary"
+ className="cursor-pointer"
+ onClick={() => {
+ location.reload();
+ }}
+ >
+ <IconNewChat />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <p>New chat</p>
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ </div>
+ <div className="relative z-[-1] flex flex-col items-center">
+ <div className="relative flex flex-col items-center before:absolute before:h-[300px] before:w-full before:-translate-x-1/2 before:rounded-full before:bg-gradient-radial before:from-white before:to-transparent before:blur-2xl before:content-[''] after:absolute after:-z-20 after:h-[180px] after:w-full after:translate-x-1/3 after:bg-gradient-conic after:from-sky-200 after:via-blue-200 after:blur-2xl after:content-[''] before:dark:bg-gradient-to-br before:dark:from-transparent before:dark:to-blue-700 before:dark:opacity-10 after:dark:from-sky-900 after:dark:via-[#0141ff] after:dark:opacity-40 sm:before:w-[480px] sm:after:w-[240px] before:lg:h-[360px] gap-4">
+ <div className="w-[180px] h-[50px]" />
+ </div>
+ </div>
+ <div className="flex space-x-4 absolute top-4 right-4">
+ <HealthStatus className="mt-3 cursor-pointer" />
+ <MeetingHistory />
+ <PipeDialog />
+ <Settings />
+
+ <Button
+ variant="ghost"
+ size="icon"
+ className="cursor-pointer"
+ onClick={() => setShowInbox(!showInbox)}
+ >
+ <Bell className="h-[1.2rem] w-[1.2rem]" />
+ <span className="sr-only">notifications</span>
+ </Button>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="ghost" size="icon" className="cursor-pointer">
+ <Menu className="h-[1.2rem] w-[1.2rem]" />
+ <span className="sr-only">menu</span>
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent className="mr-4" align="end">
+ <DropdownMenuItem
+ className="cursor-pointer"
+ onClick={() =>
+ open(
+ "mailto:[email protected]?subject=Screenpipe%20Feedback&body=Please%20enter%20your%20feedback%20here...%0A%0A...%20or%20let's%20chat?%0Ahttps://cal.com/louis030195/screenpipe"
+ )
+ }
+ >
+ <MessageSquare className="mr-2 h-4 w-4" />
+ <span>send feedback</span>
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ className="cursor-pointer"
+ onClick={() =>
+ open(
+ "https://twitter.com/intent/tweet?text=here's%20how%20i%20use%20@screen_pipe%20...%20%5Bscreenshot%5D%20an%20awesome%20tool%20for%20..."
+ )
+ }
+ >
+ <Heart className="mr-2 h-4 w-4" />
+ <span>support us</span>
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ className="cursor-pointer"
+ onClick={() => setShowOnboarding(true)}
+ >
+ <Play className="mr-2 h-4 w-4" />
+ <span>show onboarding</span>
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ {showInbox && (
+ <div className="absolute right-4 top-16 z-50 bg-white shadow-lg rounded-lg">
+ <InboxMessages
+ messages={messages}
+ onMessageRead={handleMessageRead}
+ onMessageDelete={handleMessageDelete}
+ onClose={() => setShowInbox(false)}
+ />
+ </div>
+ )}
+ </>
+ )}
+ </div>
+ );
+}
+
+function HeaderSkeleton() {
+ return (
+ <div className="w-full">
<div className="absolute left-8 top-4">
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- variant="secondary"
- className="cursor-pointer"
- onClick={() => {
- location.reload();
- }}
- >
- <IconNewChat />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>New chat</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
+ <Skeleton className="w-10 h-10 rounded-md" />
</div>
- <div className="relative z-[-1] flex flex-col items-center">
- <div className="relative flex flex-col items-center before:absolute before:h-[300px] before:w-full before:-translate-x-1/2 before:rounded-full before:bg-gradient-radial before:from-white before:to-transparent before:blur-2xl before:content-[''] after:absolute after:-z-20 after:h-[180px] after:w-full after:translate-x-1/3 after:bg-gradient-conic after:from-sky-200 after:via-blue-200 after:blur-2xl after:content-[''] before:dark:bg-gradient-to-br before:dark:from-transparent before:dark:to-blue-700 before:dark:opacity-10 after:dark:from-sky-900 after:dark:via-[#0141ff] after:dark:opacity-40 sm:before:w-[480px] sm:after:w-[240px] before:lg:h-[360px] gap-4">
- {/* <Image
- className="relative dark:drop-shadow-[0_0_0.3rem_#ffffff70] dark:invert"
- src="/screenpipe.svg"
- alt="Screenpipe Logo"
- width={180}
- height={37}
- priority
- /> */}
- <div className="w-[180px] h-[50px]" />
- {/* <p className="absolute left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-auto lg:rounded-xl lg:border lg:bg-gray-200 lg:p-4 lg:dark:bg-zinc-800/30">
- Personalized AI powered by what you have seen, said, or heard.
- </p> */}
- </div>
+ <div className="flex justify-center">
+ <Skeleton className="w-[180px] h-[50px] mt-4" />
</div>
<div className="flex space-x-4 absolute top-4 right-4">
- <HealthStatus className="mt-3 cursor-pointer" />
- <MeetingHistory />
- <PipeDialog />
- <Settings />
-
- <Button
- variant="ghost"
- size="icon"
- className="cursor-pointer"
- onClick={() => setShowInbox(!showInbox)}
- >
- <Bell className="h-[1.2rem] w-[1.2rem]" />
- <span className="sr-only">notifications</span>
- </Button>
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="ghost" size="icon" className="cursor-pointer">
- <Menu className="h-[1.2rem] w-[1.2rem]" />
- <span className="sr-only">menu</span>
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent className="mr-4" align="end">
- <DropdownMenuItem
- className="cursor-pointer"
- onClick={() =>
- open(
- "mailto:[email protected]?subject=Screenpipe%20Feedback&body=Please%20enter%20your%20feedback%20here...%0A%0A...%20or%20let's%20chat?%0Ahttps://cal.com/louis030195/screenpipe"
- )
- }
- >
- <MessageSquare className="mr-2 h-4 w-4" />
- <span>send feedback</span>
- </DropdownMenuItem>
- <DropdownMenuItem
- className="cursor-pointer"
- onClick={() =>
- open(
- "https://twitter.com/intent/tweet?text=here's%20how%20i%20use%20@screen_pipe%20...%20%5Bscreenshot%5D%20an%20awesome%20tool%20for%20..."
- )
- }
- >
- <Heart className="mr-2 h-4 w-4" />
- <span>support us</span>
- </DropdownMenuItem>
- <DropdownMenuItem
- className="cursor-pointer"
- onClick={() => setShowOnboarding(true)}
- >
- <Play className="mr-2 h-4 w-4" />
- <span>show onboarding</span>
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
+ <Skeleton className="w-8 h-8 rounded-full" />
+ <Skeleton className="w-8 h-8 rounded-full" />
+ <Skeleton className="w-8 h-8 rounded-full" />
+ <Skeleton className="w-8 h-8 rounded-full" />
+ <Skeleton className="w-8 h-8 rounded-full" />
+ <Skeleton className="w-8 h-8 rounded-full" />
</div>
- {showInbox && (
- <div className="absolute right-4 top-16 z-50 bg-white shadow-lg rounded-lg">
- <InboxMessages
- messages={messages}
- onMessageRead={handleMessageRead}
- onMessageDelete={handleMessageDelete}
- onClose={() => setShowInbox(false)}
- />
- </div>
- )}
</div>
);
}
diff --git a/screenpipe-app-tauri/components/onboarding.tsx b/screenpipe-app-tauri/components/onboarding.tsx
index 13f2c30ab..db4e00b73 100644
--- a/screenpipe-app-tauri/components/onboarding.tsx
+++ b/screenpipe-app-tauri/components/onboarding.tsx
@@ -70,7 +70,7 @@ const slideFlow: Record<
selectedOptions?.includes("personalUse") &&
selectedPersonalization === "withoutAI"
)
- return "devOrNonDev";
+ return "instructions";
return "instructions";
},
prev: () => "selection",
@@ -320,7 +320,7 @@ const Onboarding: React.FC = () => {
<OnboardingInstructions
className={`transition-opacity duration-300 ease-in-out
${isVisible ? "opacity-100 ease-out" : "opacity-0 ease-in"}`}
- handleNextSlide={handleNextSlide}
+ handleNextSlide={handleEnd}
handlePrevSlide={handlePrevSlide}
/>
)}
diff --git a/screenpipe-app-tauri/components/onboarding/api-setup.tsx b/screenpipe-app-tauri/components/onboarding/api-setup.tsx
index 12295b88f..ed7070d30 100644
--- a/screenpipe-app-tauri/components/onboarding/api-setup.tsx
+++ b/screenpipe-app-tauri/components/onboarding/api-setup.tsx
@@ -15,6 +15,13 @@ import {
TooltipTrigger,
} from "@/components/ui/tooltip";
import OnboardingNavigation from "@/components/onboarding/navigation";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/components/ui/select";
interface OnboardingAPISetupProps {
className?: string;
@@ -35,22 +42,14 @@ const OnboardingAPISetup: React.FC<OnboardingAPISetupProps> = ({
const [errors, setErrors] = React.useState<{ [key: string]: string }>({});
const [isValidating, setIsValidating] = React.useState(false);
- const handleApiUrlChange = (e: React.ChangeEvent<HTMLInputElement>) => {
- const newValue = e.target.value;
- setLocalSettings({ ...localSettings, aiUrl: newValue });
- updateSettings({ aiUrl: newValue });
- };
-
const handleApiKeyChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const newValue = e.target.value;
- setLocalSettings({ ...localSettings, openaiApiKey: newValue });
- updateSettings({ openaiApiKey: newValue });
+ setLocalSettings((prev) => ({ ...prev, openaiApiKey: newValue }));
};
const handleModelChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const newValue = e.target.value;
- setLocalSettings({ ...localSettings, aiModel: newValue });
- updateSettings({ aiModel: newValue });
+ setLocalSettings((prev) => ({ ...prev, aiModel: newValue }));
};
useEffect(() => {
@@ -64,54 +63,48 @@ const OnboardingAPISetup: React.FC<OnboardingAPISetupProps> = ({
const { aiUrl, openaiApiKey, aiModel } = localSettings;
const newErrors: { [key: string]: string } = {};
try {
- new URL(aiUrl);
- const apiKeyValidationResponse = await fetch(`${aiUrl}/models`, {
- method: "GET",
+ const response = await fetch(`${aiUrl}/chat/completions`, {
+ method: "POST",
headers: {
+ "Content-Type": "application/json",
Authorization: `Bearer ${openaiApiKey}`,
},
- });
- if (apiKeyValidationResponse.ok) {
- try {
- const modelValidationResponse = await fetch(
- `${aiUrl}/models/${aiModel}`,
+ body: JSON.stringify({
+ model: aiModel,
+ messages: [
{
- method: "GET",
- headers: {
- Authorization: `Bearer ${openaiApiKey}`,
- },
- }
- );
- if (!modelValidationResponse.ok) {
- const contentType =
- modelValidationResponse.headers.get("content-type");
- let errorMessage = "unknown error";
- if (contentType && contentType.includes("application/json")) {
- const errorJson = await modelValidationResponse.json();
- errorMessage =
- errorJson.error?.message || JSON.stringify(errorJson);
- } else {
- errorMessage = await modelValidationResponse.text();
- }
- newErrors.aiModel = `invalid ai model: ${errorMessage.toLowerCase()}`;
- }
- } catch (error: any) {
- errors.aiModel = `failed to validate ai model, please make sure ai url & api key is correct: ${error.message.toLowerCase()}`;
- }
+ role: "system",
+ content: "You are a helpful assistant that tells short jokes.",
+ },
+ {
+ role: "user",
+ content:
+ "Tell me a short joke (1-2 sentences) about screen recording, answer in lower case only.",
+ },
+ ],
+ max_tokens: 60,
+ stream: false,
+ }),
+ });
+
+ if (response.ok) {
+ const data = await response.json();
+ const joke = data.choices[0].message.content.trim();
+
+ console.log("ai is ready!", joke);
+ toast({
+ title: "ai is ready!",
+ description: `here's a joke: ${joke}`,
+ duration: 5000,
+ });
} else {
- const contentType =
- apiKeyValidationResponse.headers.get("content-type");
- let errorMessage = "unknown error";
- if (contentType && contentType.includes("application/json")) {
- const errorJson = await apiKeyValidationResponse.json();
- errorMessage = errorJson.error?.message || JSON.stringify(errorJson);
- } else {
- errorMessage = await apiKeyValidationResponse.text();
- }
- newErrors.openaiApiKey = `invalid api key: ${errorMessage.toLowerCase()}`;
+ const errorData = await response.json();
+ newErrors.openaiApiKey = `invalid api key or model: ${
+ errorData.error?.message.toLowerCase() || "unknown error"
+ }`;
}
} catch (error: any) {
- newErrors.openaiApiKey = `failed to validate api key, please make sure ai url is correct: ${error.message.toLowerCase()}`;
+ newErrors.openaiApiKey = `failed to validate api key: ${error.message.toLowerCase()}`;
}
setErrors(newErrors);
@@ -127,14 +120,16 @@ const OnboardingAPISetup: React.FC<OnboardingAPISetupProps> = ({
const handleValidationMoveNextSlide = async () => {
setIsValidating(true);
+ // Update settings here, before validation
+ updateSettings(localSettings);
const isValid = await validateInputs();
setIsValidating(false);
if (isValid) {
- toast({
- title: "success",
- description: "ai setup completed successfully",
- variant: "default",
- });
+ // toast({
+ // title: "success",
+ // description: "ai setup completed successfully",
+ // variant: "default",
+ // });
handleNextSlide();
}
};
@@ -143,6 +138,139 @@ const OnboardingAPISetup: React.FC<OnboardingAPISetupProps> = ({
setLocalSettings(settings);
}, [settings]);
+ const handleAiUrlChange = (newValue: string) => {
+ if (newValue === "custom") {
+ setLocalSettings((prev) => ({ ...prev, aiUrl: "" }));
+ } else {
+ setLocalSettings((prev) => ({ ...prev, aiUrl: newValue }));
+ }
+ };
+
+ const handleCustomUrlChange = (e: React.ChangeEvent<HTMLInputElement>) => {
+ const newValue = e.target.value;
+ setLocalSettings((prev) => ({ ...prev, aiUrl: newValue }));
+ };
+
+ const isApiKeyRequired =
+ localSettings.aiUrl !== "https://ai-proxy.i-f9f.workers.dev/v1" &&
+ localSettings.aiUrl !== "http://localhost:11434/v1";
+
+ const getProviderTooltipContent = () => {
+ switch (localSettings.aiUrl) {
+ case "https://ai-proxy.i-f9f.workers.dev/v1":
+ return (
+ <p>
+ screenpipe cloud doesn&apos;t require an API key.
+ <br />
+ we offer free credits.
+ <br />
+ note: using this option may involve sending data to our servers.
+ <br />
+ please review our data privacy policy for more information at:
+ <br />
+ <a
+ href="https://screenpi.pe/privacy"
+ target="_blank"
+ className="text-primary hover:underline"
+ >
+ screenpipe privacy policy
+ </a>
+ </p>
+ );
+ case "https://api.openai.com/v1":
+ return (
+ <p>
+ openai requires an API key.
+ <br />
+ note: using this option may involve sending data to openai servers.
+ <br />
+ please review openai&apos;s data privacy policy for more
+ information.
+ <br />
+ find openai key here:{" "}
+ <a
+ href="https://platform.openai.com/account/api-keys"
+ target="_blank"
+ className="text-primary hover:underline"
+ >
+ openai
+ </a>
+ </p>
+ );
+ case "http://localhost:11434/v1":
+ return (
+ <p>
+ choose your ai provider. for local providers like ollama, make sure
+ it&apos;s running on your machine.
+ <br />
+ note: on windows, you may need to run ollama with:
+ <pre className="bg-gray-100 p-1 rounded-md">
+ OLLAMA_ORIGINS=* ollama run llama2
+ </pre>
+ </p>
+ );
+ default:
+ return (
+ <p>
+ choose your ai provider. for local providers like ollama, make sure
+ it&apos;s running on your machine.
+ <br />
+ note: on windows, you may need to run ollama with:
+ <pre className="bg-gray-100 p-1 rounded-md">
+ OLLAMA_ORIGINS=* ollama run llama2
+ </pre>
+ </p>
+ );
+ }
+ };
+
+ const getModelTooltipContent = () => {
+ switch (localSettings.aiUrl) {
+ case "https://api.openai.com/v1":
+ case "https://ai-proxy.i-f9f.workers.dev/v1":
+ return (
+ <p>
+ suggested models:
+ <br />- gpt-4o
+ </p>
+ );
+ case "http://localhost:11434/v1":
+ return (
+ <p>
+ suggested models:
+ <br />
+ - llama3.2:3b-instruct-q4_K_M
+ <br />
+ - mistral models
+ <br />
+ or find more models at:
+ <a
+ href="https://ollama.com/library"
+ target="_blank"
+ className="text-primary hover:underline"
+ >
+ ollama models
+ </a>
+ </p>
+ );
+ default:
+ return (
+ <p>enter the model name appropriate for your custom AI provider.</p>
+ );
+ }
+ };
+
+ const isCustomUrl = ![
+ "https://api.openai.com/v1",
+ "http://localhost:11434/v1",
+ "https://ai-proxy.i-f9f.workers.dev/v1",
+ ].includes(localSettings.aiUrl);
+
+ const getSelectValue = () => {
+ if (isCustomUrl) return "custom";
+ return localSettings.aiUrl;
+ };
+
return (
<div className={`flex h-[80%] flex-col ${className}`}>
<DialogHeader className="flex flex-col px-2 justify-center items-center">
@@ -160,97 +288,134 @@ const OnboardingAPISetup: React.FC<OnboardingAPISetupProps> = ({
<CardTitle className="text-center">setup api key</CardTitle>
</CardHeader>
<CardContent className="flex flex-col items-center space-y-4">
- <div className="w-full">
+ <div className="w-full max-w-md">
<div className="flex items-center gap-2 mb-2">
- <Label htmlFor="aiUrl" className="min-w-[80px] text-right">
- ai url
+ <Label htmlFor="aiUrl" className="min-w-[100px] text-right">
+ ai provider
</Label>
<div className="flex-grow flex items-center">
+ <Select
+ onValueChange={handleAiUrlChange}
+ value={getSelectValue()}
+ >
+ <SelectTrigger className="w-full">
+ <SelectValue placeholder="Select AI provider" />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="https://api.openai.com/v1">
+ openai
+ </SelectItem>
+ <SelectItem value="http://localhost:11434/v1">
+ ollama (local)
+ </SelectItem>
+ <SelectItem value="https://ai-proxy.i-f9f.workers.dev/v1">
+ screenpipe cloud
+ </SelectItem>
+ <SelectItem value="custom">custom</SelectItem>
+ </SelectContent>
+ </Select>
+ </div>
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <HelpCircle className="ml-2 h-4 w-4 cursor-default" />
+ </TooltipTrigger>
+ <TooltipContent side="left">
+ {getProviderTooltipContent()}
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ </div>
+ </div>
+ {isCustomUrl && (
+ <div className="w-full max-w-md">
+ <div className="flex items-center gap-2 mb-2">
+ <Label
+ htmlFor="customAiUrl"
+ className="min-w-[100px] text-right"
+ >
+ custom url
+ </Label>
<Input
- id="aiUrl"
+ id="customAiUrl"
value={localSettings.aiUrl}
- onChange={handleApiUrlChange}
+ onChange={handleCustomUrlChange}
className="flex-grow"
- placeholder="enter ai urL"
- type="url"
+ placeholder="enter custom ai url"
+ autoCorrect="off"
+ autoCapitalize="off"
+ autoComplete="off"
+ type="text" // Explicitly set type to "text" to allow any characters
/>
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <HelpCircle className="ml-2 h-4 w-4 cursor-default" />
- </TooltipTrigger>
- <TooltipContent side="left">
- <p>
- the url of your ai provider&apos;s api endpoint. for
- openai:{" "}
- <pre className="bg-gray-100 p-1 rounded-md">
- https://api.openai.com/v1
- </pre>
- <br />
- for local providers like ollama usually it&apos;s
- <pre className="bg-gray-100 p-1 rounded-md">
- http://localhost:11434/v1
- </pre>
- <br />
- note: on windows, you may need to run ollama with:
- <pre className="bg-gray-100 p-1 rounded-md">
- OLLAMA_ORIGINS=* ollama run llama3.2
- </pre>
- </p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
</div>
</div>
- </div>
- <div className="w-full">
+ )}
+ {isApiKeyRequired && (
+ <div className="w-full max-w-md">
+ <div className="flex items-center gap-2 mb-2">
+ <Label htmlFor="aiApiKey" className="min-w-[100px] text-right">
+ api key
+ </Label>
+ <div className="flex-grow relative">
+ <Input
+ id="aiApiKey"
+ type={showApiKey ? "text" : "password"}
+ value={localSettings.openaiApiKey}
+ onChange={handleApiKeyChange}
+ className="pr-10"
+ placeholder="enter your ai api key"
+ autoCorrect="off"
+ autoCapitalize="off"
+ autoComplete="off"
+ />
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon"
+ className="absolute right-0 top-0 h-full"
+ onClick={() => setShowApiKey(!showApiKey)}
+ >
+ {showApiKey ? (
+ <EyeOff className="h-4 w-4" />
+ ) : (
+ <Eye className="h-4 w-4" />
+ )}
+ </Button>
+ </div>
+ </div>
+ </div>
+ )}
+ <div className="w-full max-w-md">
<div className="flex items-center gap-2 mb-2">
- <Label htmlFor="aiApiKey" className="min-w-[80px] text-right">
- api key
+ <Label htmlFor="aiModel" className="min-w-[100px] text-right">
+ ai model
</Label>
<div className="flex-grow relative">
<Input
- id="aiApiKey"
- type={showApiKey ? "text" : "password"}
- value={localSettings.openaiApiKey}
- onChange={handleApiKeyChange}
- className="pr-10"
- placeholder="enter your ai api key"
+ id="aiModel"
+ value={localSettings.aiModel}
+ onChange={handleModelChange}
+ className="flex-grow"
+ placeholder={
+ localSettings.aiUrl === "http://localhost:11434/v1"
+ ? "e.g., llama2:7b-chat"
+ : "e.g., gpt-4"
+ }
autoCorrect="off"
autoCapitalize="off"
autoComplete="off"
/>
- <Button
- type="button"
- variant="ghost"
- size="icon"
- className="absolute right-0 top-0 h-full"
- onClick={() => setShowApiKey(!showApiKey)}
- >
- {showApiKey ? (
- <EyeOff className="h-4 w-4" />
- ) : (
- <Eye className="h-4 w-4" />
- )}
- </Button>
</div>
- </div>
- </div>
- <div className="w-full">
- <div className="flex items-center gap-4 mb-4">
- <Label htmlFor="aiModel" className="min-w-[80px] text-right">
- ai model
- </Label>
- <Input
- id="aiModel"
- value={localSettings.aiModel}
- onChange={handleModelChange}
- className="flex-grow"
- placeholder="enter ai model (e.g., gpt-4)"
- autoCorrect="off"
- autoCapitalize="off"
- autoComplete="off"
- />
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <HelpCircle className="ml-2 h-4 w-4 cursor-default" />
+ </TooltipTrigger>
+ <TooltipContent side="right">
+ {getModelTooltipContent()}
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
</div>
</div>
</CardContent>
@@ -270,7 +435,12 @@ const OnboardingAPISetup: React.FC<OnboardingAPISetupProps> = ({
isLoading={isValidating}
handlePrevSlide={handlePrevSlide}
handleNextSlide={
- areAllInputsFilled ? handleValidationMoveNextSlide : handleNextSlide
+ areAllInputsFilled
+ ? handleValidationMoveNextSlide
+ : () => {
+ updateSettings(localSettings);
+ handleNextSlide();
+ }
}
prevBtnText="previous"
nextBtnText={areAllInputsFilled ? "setup" : "i'll setup later"}
diff --git a/screenpipe-app-tauri/components/onboarding/status.tsx b/screenpipe-app-tauri/components/onboarding/status.tsx
index 416023eff..4e3cbf74b 100644
--- a/screenpipe-app-tauri/components/onboarding/status.tsx
+++ b/screenpipe-app-tauri/components/onboarding/status.tsx
@@ -2,13 +2,21 @@
/*TODO: setup screenpipe status <10-10-24, @tribhuwan-kumar>*/
}
-import React, { useState, useEffect } from "react";
-import { ArrowUpRight, Check } from "lucide-react";
+import React, { useState } from "react";
+import { ArrowUpRight, Check, HelpCircle } from "lucide-react";
import { DialogHeader, DialogTitle } from "@/components/ui/dialog";
import OnboardingNavigation from "@/components/onboarding/navigation";
-import { spinner } from "@/components/spinner";
import { Command } from "@tauri-apps/plugin-shell";
-import { Separator } from "../ui/separator";
+import { Button } from "../ui/button";
+import { Switch } from "../ui/switch";
+import {
+ TooltipProvider,
+ Tooltip,
+ TooltipTrigger,
+ TooltipContent,
+} from "../ui/tooltip";
+import { useSettings } from "@/lib/hooks/use-settings";
+import { Label } from "../ui/label";
interface OnboardingStatusProps {
className?: string;
@@ -22,69 +30,54 @@ const OnboardingStatus: React.FC<OnboardingStatusProps> = ({
handleNextSlide,
}) => {
const [status, setStatus] = useState<string | null>(null);
+ const [isLoading, setIsLoading] = useState(false);
+ const [useChineseMirror, setUseChineseMirror] = useState(false);
+ const { updateSettings } = useSettings();
- useEffect(() => {
- let isMounted = true;
- let child: Awaited<ReturnType<Command<any>["spawn"]>> | null = null;
+ const startSetup = async () => {
+ setIsLoading(true);
+ setStatus(null);
- const checkStatus = async () => {
- try {
- const command = Command.sidecar("screenpipe", ["setup"]);
-
- const timeoutPromise = new Promise(
- (_, reject) =>
- setTimeout(
- () => reject(new Error("Status check timed out")),
- 900000
- ) // 15 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");
- }
- });
- });
+ try {
+ const command = Command.sidecar("screenpipe", ["setup"]);
- child = await command.spawn();
+ const timeoutPromise = new Promise(
+ (_, reject) =>
+ setTimeout(() => reject(new Error("status check timed out")), 900000) // 15 minutes
+ );
- try {
- await new Promise((resolve) => setTimeout(resolve, 2000)); // add 2s delay for fast connections
- const result = await Promise.race([outputPromise, timeoutPromise]);
- if (isMounted) {
- setStatus(result as string);
+ const outputPromise = new Promise<string>((resolve, reject) => {
+ command.on("close", (data) => {
+ if (data.code !== 0) {
+ reject(new Error(`command failed with code ${data.code}`));
}
- } catch (error) {
- console.error("Error or timeout:", error);
- if (isMounted) {
- setStatus("error");
+ });
+ command.on("error", (error) => reject(new Error(error)));
+ command.stdout.on("data", (line) => {
+ console.log(line);
+ if (line.includes("screenpipe setup complete")) {
+ resolve("ok");
}
- }
- } catch (error) {
- console.error("Error checking status:", error);
- if (isMounted) {
- setStatus("error");
- }
- }
- };
+ });
+ });
- checkStatus();
+ const child = await command.spawn();
- return () => {
- isMounted = false;
- if (child) {
- child.kill().catch(console.error);
+ try {
+ const result = await Promise.race([outputPromise, timeoutPromise]);
+ setStatus(result as string);
+ } catch (error) {
+ console.error("error or timeout:", error);
+ setStatus("error");
+ } finally {
+ setIsLoading(false);
}
- };
- }, []);
+ } catch (error) {
+ console.error("error checking status:", error);
+ setStatus("error");
+ setIsLoading(false);
+ }
+ };
const handleNext = () => {
setStatus(null);
@@ -96,6 +89,56 @@ const OnboardingStatus: React.FC<OnboardingStatusProps> = ({
handlePrevSlide();
};
+ const handleChineseMirrorToggle = async (checked: boolean) => {
+ setUseChineseMirror(checked);
+ updateSettings({ useChineseMirror: checked });
+ };
+
+ const runSetup = async () => {
+ setIsLoading(true);
+ setStatus(null);
+
+ try {
+ const command = Command.sidecar("screenpipe", ["setup"]);
+
+ const timeoutPromise = new Promise(
+ (_, reject) =>
+ setTimeout(() => reject(new Error("setup timed out")), 900000) // 15 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 child = await command.spawn();
+
+ try {
+ const result = await Promise.race([outputPromise, timeoutPromise]);
+ setStatus(result as string);
+ } catch (error) {
+ console.error("error or timeout:", error);
+ setStatus("error");
+ } finally {
+ setIsLoading(false);
+ }
+ } catch (error) {
+ console.error("error checking status:", error);
+ setStatus("error");
+ setIsLoading(false);
+ }
+ };
+
return (
<div
className={`${className} w-full flex justify-between flex-col items-center`}
@@ -115,7 +158,6 @@ const OnboardingStatus: React.FC<OnboardingStatusProps> = ({
this may take a few minutes depending on your internet connection
</h2>
</DialogHeader>
- <div className="my-8" />
<div className="mt-4 text-sm text-zinc-600 mx-auto">
<p className="mb-2 text-center">how screenpipe works:</p>
<ul className="list-disc list-inside text-left">
@@ -132,19 +174,55 @@ const OnboardingStatus: React.FC<OnboardingStatusProps> = ({
if encountering any issues, you can proceed to the next step and it will
setup screenpipe when starting the recording process
</p>
- {status === null ? (
- <svg
- fill="none"
- stroke="currentColor"
- strokeWidth="1.5"
- viewBox="0 0 24 24"
- strokeLinecap="round"
- strokeLinejoin="round"
- xmlns="http://www.w3.org/2000/svg"
- className="size-5 animate-spin stroke-zinc-400 mx-auto mt-4"
+ <div className="flex items-center space-x-2 mt-4">
+ <Switch
+ id="chinese-mirror-toggle"
+ checked={useChineseMirror}
+ onCheckedChange={handleChineseMirrorToggle}
+ />
+ <Label
+ htmlFor="chinese-mirror-toggle"
+ className="flex items-center space-x-2"
>
- <path d="M12 3v3m6.366-.366-2.12 2.12M21 12h-3m.366 6.366-2.12-2.12M12 21v-3m-6.366.366 2.12-2.12M3 12h3m-.366-6.366 2.12 2.12"></path>
- </svg>
+ <span>use chinese mirror for model downloads</span>
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger>
+ <HelpCircle className="h-4 w-4 cursor-default" />
+ </TooltipTrigger>
+ <TooltipContent side="right">
+ <p>
+ enable this option to use a chinese mirror for
+ <br />
+ downloading hugging face models
+ <br />
+ (e.g. whisper, embedded llama, etc.)
+ <br />
+ which are blocked in mainland china.
+ </p>
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ </Label>
+ </div>
+ {status === null ? (
+ <Button onClick={startSetup} disabled={isLoading} className="mt-4">
+ {isLoading ? (
+ <svg
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="1.5"
+ viewBox="0 0 24 24"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ xmlns="http://www.w3.org/2000/svg"
+ className="size-5 animate-spin stroke-zinc-400 mr-2"
+ >
+ <path d="M12 3v3m6.366-.366-2.12 2.12M21 12h-3m.366 6.366-2.12-2.12M12 21v-3m-6.366.366 2.12-2.12M3 12h3m-.366-6.366 2.12 2.12"></path>
+ </svg>
+ ) : null}
+ {isLoading ? "setting up..." : "start setup"}
+ </Button>
) : status === "ok" ? (
<div className="flex flex-col items-center mt-4">
<Check className="size-5 stroke-zinc-400" />
diff --git a/screenpipe-app-tauri/components/recording-settings.tsx b/screenpipe-app-tauri/components/recording-settings.tsx
index d76f2e766..ea057f570 100644
--- a/screenpipe-app-tauri/components/recording-settings.tsx
+++ b/screenpipe-app-tauri/components/recording-settings.tsx
@@ -65,6 +65,7 @@ import posthog from "posthog-js";
import { trace } from "@opentelemetry/api";
import { initOpenTelemetry } from "@/lib/opentelemetry";
import { Language } from "@/lib/language";
+import { Command as ShellCommand } from "@tauri-apps/plugin-shell";
interface AudioDevice {
name: string;
@@ -104,6 +105,7 @@ export function RecordingSettings({
const [isCopyDialogOpen, setIsCopyDialogOpen] = useState(false);
const { copyToClipboard } = useCopyToClipboard({ timeout: 2000 });
const [isMacOS, setIsMacOS] = useState(false);
+ const [isSetupRunning, setIsSetupRunning] = useState(false);
useEffect(() => {
const checkPlatform = async () => {
@@ -338,11 +340,8 @@ export function RecordingSettings({
setLocalSettings({ ...localSettings, usePiiRemoval: checked });
};
- const handleRestartIntervalChange = (
- e: React.ChangeEvent<HTMLInputElement>
- ) => {
- const newValue = parseInt(e.target.value, 10);
- setLocalSettings({ ...localSettings, restartInterval: newValue });
+ const handleRestartIntervalChange = (value: number[]) => {
+ setLocalSettings({ ...localSettings, restartInterval: value[0] });
};
const handleDisableAudioChange = (checked: boolean) => {
@@ -486,12 +485,124 @@ export function RecordingSettings({
setLocalSettings({ ...localSettings, analyticsEnabled: newValue });
};
- const handleChineseMirrorToggle = (checked: boolean) => {
+ const handleChineseMirrorToggle = async (checked: boolean) => {
setLocalSettings({ ...localSettings, useChineseMirror: checked });
+ if (checked) {
+ // Trigger setup when the toggle is turned on
+ await runSetup();
+ }
+ };
+
+ 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
+ setLocalSettings({ ...localSettings, useChineseMirror: false });
+ } finally {
+ setIsSetupRunning(false);
+ }
};
- const handleEnableBetaToggle = (checked: boolean) => {
+ const handleEnableBetaToggle = async (checked: boolean) => {
setLocalSettings({ ...localSettings, enableBeta: checked });
+
+ if (checked) {
+ try {
+ const command = ShellCommand.sidecar("screenpipe", ["setup"]);
+ const child = await command.spawn();
+
+ toast({
+ title: "setting up beta features",
+ 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: "beta features setup complete",
+ description: "you can now use the beta features.",
+ });
+ } else {
+ throw new Error("setup failed or timed out");
+ }
+ } catch (error) {
+ console.error("error setting up beta features:", error);
+ toast({
+ title: "error setting up beta features",
+ description:
+ "please try again or check the logs for more information.",
+ variant: "destructive",
+ });
+ // Revert the toggle if setup fails
+ setLocalSettings({ ...localSettings, enableBeta: false });
+ }
+ }
};
return (
@@ -840,26 +951,31 @@ export function RecordingSettings({
</TooltipTrigger>
<TooltipContent>
<p>
- set how often the recording process should restart.
+ (not recommended) set how often the recording process
+ should restart.
<br />
- 0 means no automatic restart.
+ 30 minutes is the minimum interval.
<br />
- this can help mitigate potential memory leaks or other
- issues.
+ this can help mitigate potential issues.
</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</Label>
- <Input
- id="restartInterval"
- type="number"
- min="0"
- value={localSettings.restartInterval}
- onChange={handleRestartIntervalChange}
- className="w-full"
- placeholder="Enter restart interval in minutes (0 to disable)"
- />
+ <div className="flex items-center space-x-4">
+ <Slider
+ id="restartInterval"
+ min={30}
+ 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">
@@ -1203,7 +1319,7 @@ export function RecordingSettings({
htmlFor="chinese-mirror-toggle"
className="flex items-center space-x-2"
>
- <span>use chinese mirror for model downloads</span>
+ <span>Use Chinese mirror for model downloads</span>
<TooltipProvider>
<Tooltip>
<TooltipTrigger>
@@ -1211,7 +1327,7 @@ export function RecordingSettings({
</TooltipTrigger>
<TooltipContent side="right">
<p>
- enable this option to use a chinese mirror for
+ Enable this option to use a Chinese mirror for
<br />
downloading Hugging Face models
<br />
diff --git a/screenpipe-app-tauri/components/screenpipe-status.tsx b/screenpipe-app-tauri/components/screenpipe-status.tsx
index 950dbf92d..b4088fac4 100644
--- a/screenpipe-app-tauri/components/screenpipe-status.tsx
+++ b/screenpipe-app-tauri/components/screenpipe-status.tsx
@@ -25,7 +25,7 @@ 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 } from "lucide-react";
+import { Lock, Folder, FileText, Activity, Wrench } from "lucide-react";
import { open } from "@tauri-apps/plugin-shell";
import { homeDir } from "@tauri-apps/api/path";
import LogViewer from "./log-viewer-v2";
@@ -34,6 +34,7 @@ import {
CollapsibleContent,
CollapsibleTrigger,
} from "@/components/ui/collapsible";
+import { Command } from "@tauri-apps/plugin-shell";
const getDebuggingCommands = (os: string | null) => {
let cliInstructions = "";
@@ -339,6 +340,7 @@ const HealthStatus = ({ className }: { className?: string }) => {
const [isMac, setIsMac] = useState(false);
const { settings } = useSettings();
const [isLogOpen, setIsLogOpen] = useState(false);
+ const [isFixingSetup, setIsFixingSetup] = useState(false);
useEffect(() => {
setIsMac(platform() === "macos");
@@ -385,29 +387,6 @@ const HealthStatus = ({ className }: { className?: string }) => {
}
};
- 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`;
- await open(logPath);
- } catch (error) {
- console.error("failed to open log file:", error);
- toast({
- title: "error",
- description: "failed to open log file.",
- variant: "destructive",
- duration: 3000,
- });
- }
- };
-
const getStatusColor = (
status: string,
frameStatus: string,
@@ -424,6 +403,70 @@ const HealthStatus = ({ className }: { className?: string }) => {
return "bg-red-500";
};
+ const handleFixSetup = async () => {
+ setIsFixingSetup(true);
+ const toastId = toast({
+ title: "fixing setup permissions",
+ description: "this may take a few minutes...",
+ duration: Infinity,
+ });
+
+ try {
+ const args = ["setup"];
+ if (settings.enableBeta) {
+ args.push("--enable-beta");
+ }
+ console.log("args", args);
+ const command = Command.sidecar("screenpipe", args);
+ const child = await command.spawn();
+
+ 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") {
+ toastId.update({
+ id: toastId.id,
+ title: "setup fixed",
+ description: "screenpipe setup permissions have been fixed.",
+ duration: 5000,
+ });
+ } else {
+ throw new Error("setup failed or timed out");
+ }
+ } catch (error) {
+ console.error("error fixing setup:", error);
+ toastId.update({
+ id: toastId.id,
+ title: "error",
+ description: "please try again or check the logs for more info.",
+ variant: "destructive",
+ duration: 3000,
+ });
+ } finally {
+ setIsFixingSetup(false);
+ toastId.dismiss();
+ }
+ };
+
if (!health) {
return (
<Badge
@@ -537,8 +580,8 @@ const HealthStatus = ({ className }: { className?: string }) => {
3. if the problem persists, please contact support at [[email protected]](mailto:[email protected]) or @louis030195 on Discord, X, or LinkedIn
4. last, here are some [FAQ](https://github.com/mediar-ai/screenpipe/blob/main/content/docs/NOTES.md) with visuals to help you troubleshoot`}
</MarkdownWithExternalLinks>
- {isMac && (
- <div className="absolute top-[6.5em] right-0">
+ <div className="absolute top-[6.5em] right-0 flex flex-col space-y-2">
+ {isMac && (
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
@@ -556,8 +599,29 @@ const HealthStatus = ({ className }: { className?: string }) => {
</TooltipContent>
</Tooltip>
</TooltipProvider>
- </div>
- )}
+ )}
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="outline"
+ onClick={handleFixSetup}
+ className="flex-shrink-0"
+ disabled={isFixingSetup}
+ >
+ <Wrench className="h-4 w-4 mr-2" />
+ {isFixingSetup ? "fixing..." : "screenpipe autofix"}
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <p>
+ this will try to request permissions, download models,
+ etc.
+ </p>
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ </div>
</div>
<Separator className="my-4" />
<DevModeSettings />
diff --git a/screenpipe-app-tauri/components/search-chat.tsx b/screenpipe-app-tauri/components/search-chat.tsx
index cd51ed725..8e1a183c2 100644
--- a/screenpipe-app-tauri/components/search-chat.tsx
+++ b/screenpipe-app-tauri/components/search-chat.tsx
@@ -78,9 +78,11 @@ import { encode, removeDuplicateSelections } from "@/lib/utils";
import { ExampleSearch, ExampleSearchCards } from "./example-search-cards";
import { useDebounce } from "@/lib/hooks/use-debounce";
import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover";
+import { useHealthCheck } from "@/lib/hooks/use-health-check";
export function SearchChat() {
// Search state
+ const { health } = useHealthCheck();
const [query, setQuery] = useState("");
const [results, setResults] = useState<ContentItem[]>([]);
const [isLoading, setIsLoading] = useState(false);
@@ -748,28 +750,70 @@ export function SearchChat() {
value={windowName}
onChange={setWindowName}
placeholder="filter by window name"
- className="w-full"
+ className="w-3/4"
/>
<Button
variant="outline"
size="icon"
onClick={() => setIsQueryParamsDialogOpen(true)}
>
- <Settings className="h-4 w-4" />
- </Button>
- <Button onClick={() => handleSearch(0)} disabled={isLoading}>
- {isLoading ? (
- <>
- <Loader2 className="mr-2 h-4 w-4 animate-spin" />
- searching...
- </>
- ) : (
- <>
- <Search className="mr-2 h-4 w-4" />
- search
- </>
- )}
+ <Settings className="h-4 w-12" />
</Button>
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span>
+ <Button
+ onClick={() => handleSearch(0)}
+ disabled={
+ isLoading || !health || health?.status === "error"
+ }
+ >
+ {isLoading ? (
+ <>
+ <Loader2 className="mr-2 h-4 w-4 animate-spin" />
+ searching...
+ </>
+ ) : (
+ <>
+ <Search className="mr-2 h-4 w-4" />
+ search
+ </>
+ )}
+ </Button>
+ </span>
+ </TooltipTrigger>
+ {health?.status === "error" && (
+ <TooltipContent>
+ <p>screenpipe is not running...</p>
+ </TooltipContent>
+ )}
+ </Tooltip>
+ </TooltipProvider>
+ <Dialog open={isCurlDialogOpen} onOpenChange={setIsCurlDialogOpen}>
+ <DialogTrigger asChild>
+ <Button variant="outline" size="icon">
+ <IconCode className="h-4 w-12" />
+ </Button>
+ </DialogTrigger>
+ <DialogContent className="max-w-2xl">
+ <DialogHeader>
+ <DialogTitle>curl command</DialogTitle>
+ <DialogDescription>
+ you can use this curl command to make the same search request
+ from the command line.
+ <br />
+ <br />
+ <span className="text-xs text-gray-500">
+ note: you need to have `jq` installed to use the command.
+ </span>{" "}
+ </DialogDescription>
+ </DialogHeader>
+ <div className="overflow-x-auto">
+ <CodeBlock language="bash" value={generateCurlCommand()} />
+ </div>
+ </DialogContent>
+ </Dialog>
</div>
</div>
@@ -1237,4 +1281,4 @@ export function SearchChat() {
{results.length > 0 && <div className="h-24" />}
</div>
);
-}
+}
\ No newline at end of file
diff --git a/screenpipe-app-tauri/components/settings.tsx b/screenpipe-app-tauri/components/settings.tsx
index fb4985651..281b0bd42 100644
--- a/screenpipe-app-tauri/components/settings.tsx
+++ b/screenpipe-app-tauri/components/settings.tsx
@@ -64,12 +64,6 @@ export function Settings({ className }: { className?: string }) {
setCurrentPlatform(platform());
}, []);
- const handleApiUrlChange = (e: React.ChangeEvent<HTMLInputElement>) => {
- const newValue = e.target.value;
- setLocalSettings({ ...localSettings, aiUrl: newValue });
- updateSettings({ aiUrl: newValue });
- };
-
const handleApiKeyChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const newValue = e.target.value;
setLocalSettings({ ...localSettings, openaiApiKey: newValue });
@@ -198,10 +192,140 @@ export function Settings({ className }: { className?: string }) {
};
const handleAiUrlChange = (newValue: string) => {
+ if (newValue === "custom") {
+ setLocalSettings({ ...localSettings, aiUrl: "" });
+ } else {
+ setLocalSettings({ ...localSettings, aiUrl: newValue });
+ }
+ updateSettings({ aiUrl: newValue });
+ };
+
+ const handleCustomUrlChange = (e: React.ChangeEvent<HTMLInputElement>) => {
+ const newValue = e.target.value;
setLocalSettings({ ...localSettings, aiUrl: newValue });
updateSettings({ aiUrl: newValue });
};
+ const isApiKeyRequired =
+ localSettings.aiUrl !== "https://ai-proxy.i-f9f.workers.dev/v1" &&
+ localSettings.aiUrl !== "http://localhost:11434/v1";
+
+ const getProviderTooltipContent = () => {
+ switch (localSettings.aiUrl) {
+ case "https://ai-proxy.i-f9f.workers.dev/v1":
+ return (
+ <p>
+ screenpipe cloud doesn&apos;t require an API key.
+ <br />
+ we offer free credits.
+ <br />
+ note: using this option may involve sending data to our servers.
+ <br />
+ please review our data privacy policy for more information at:
+ <br />
+ <a
+ href="https://screenpi.pe/privacy"
+ target="_blank"
+ className="text-primary hover:underline"
+ >
+ screenpipe privacy policy
+ </a>
+ </p>
+ );
+ case "https://api.openai.com/v1":
+ return (
+ <p>
+ openai requires an API key.
+ <br />
+ note: using this option may involve sending data to openai servers.
+ <br />
+ please review openai&apos;s data privacy policy for more
+ information.
+ <br />
+ find openai key here:{" "}
+ <a
+ href="https://platform.openai.com/account/api-keys"
+ target="_blank"
+ className="text-primary hover:underline"
+ >
+ openai
+ </a>
+ </p>
+ );
+ case "http://localhost:11434/v1":
+ return (
+ <p>
+ choose your ai provider. for local providers like ollama, make sure
+ it&apos;s running on your machine.
+ <br />
+ note: on windows, you may need to run ollama with:
+ <pre className="bg-gray-100 p-1 rounded-md">
+ OLLAMA_ORIGINS=* ollama run llama2
+ </pre>
+ </p>
+ );
+ default:
+ return (
+ <p>
+ choose your ai provider. for local providers like ollama, make sure
+ it&apos;s running on your machine.
+ <br />
+ note: on windows, you may need to run ollama with:
+ <pre className="bg-gray-100 p-1 rounded-md">
+ OLLAMA_ORIGINS=* ollama run llama2
+ </pre>
+ </p>
+ );
+ }
+ };
+
+ const getModelTooltipContent = () => {
+ switch (localSettings.aiUrl) {
+ case "https://api.openai.com/v1":
+ case "https://ai-proxy.i-f9f.workers.dev/v1":
+ return (
+ <p>
+ suggested models:
+ <br />- gpt-4o
+ </p>
+ );
+ case "http://localhost:11434/v1":
+ return (
+ <p>
+ suggested models:
+ <br />
+ - llama3.2:3b-instruct-q4_K_M
+ <br />
+ - mistral models
+ <br />
+ or find more models at:
+ <a
+ href="https://ollama.com/library"
+ target="_blank"
+ className="text-primary hover:underline"
+ >
+ ollama models
+ </a>
+ </p>
+ );
+ default:
+ return (
+ <p>enter the model name appropriate for your custom AI provider.</p>
+ );
+ }
+ };
+
+ const isCustomUrl = ![
+ "https://api.openai.com/v1",
+ "http://localhost:11434/v1",
+ "https://ai-proxy.i-f9f.workers.dev/v1",
+ ].includes(localSettings.aiUrl);
+
+ const getSelectValue = () => {
+ if (isCustomUrl) return "custom";
+ return localSettings.aiUrl;
+ };
+
return (
<Dialog
onOpenChange={(open) => {
@@ -245,7 +369,7 @@ export function Settings({ className }: { className?: string }) {
<div className="flex-grow flex items-center">
<Select
onValueChange={handleAiUrlChange}
- value={localSettings.aiUrl}
+ value={getSelectValue()}
>
<SelectTrigger className="w-full">
<SelectValue placeholder="Select AI provider" />
@@ -264,108 +388,110 @@ export function Settings({ className }: { className?: string }) {
</SelectContent>
</Select>
</div>
- {localSettings.aiUrl === "custom" && (
- <div className="flex items-center gap-4 mb-4 mt-2">
- <Label
- htmlFor="customAiUrl"
- className="min-w-[80px] text-right"
- >
- custom url
- </Label>
- <Input
- id="customAiUrl"
- value={localSettings.aiUrl}
- onChange={(e) => handleAiUrlChange(e.target.value)}
- className="flex-grow"
- placeholder="Enter custom AI URL"
- type="url"
- />
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <HelpCircle className="ml-2 h-4 w-4 cursor-default" />
- </TooltipTrigger>
- <TooltipContent side="left">
- <p>
- choose your ai provider. for local providers like
- ollama, make sure it&apos;s running on your
- machine.
- <br />
- note: on windows, you may need to run ollama with:
- <pre className="bg-gray-100 p-1 rounded-md">
- OLLAMA_ORIGINS=* ollama run llama3.2
- </pre>
- </p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>
- )}
- {localSettings.aiUrl ===
- "https://ai-proxy.i-f9f.workers.dev/v1" && (
- <p className="mt-2 text-sm text-muted-foreground">
- screenpipe cloud doesn&apos;t require an API key.
- <br />
- note: using this option may involve sending data to our
- servers.
- <br />
- please review our{" "}
- <a href="#" className="text-primary hover:underline">
- data privacy policy
- </a>{" "}
- for more information.
- </p>
- )}
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <HelpCircle className="ml-2 h-4 w-4 cursor-default" />
+ </TooltipTrigger>
+ <TooltipContent side="left">
+ {getProviderTooltipContent()}
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
</div>
</div>
- <div className="w-full">
- <div className="flex items-center gap-4 mb-4">
- <Label htmlFor="aiApiKey" className="min-w-[80px] text-right">
- api key
- </Label>
- <div className="flex-grow relative">
+ {isCustomUrl && (
+ <div className="w-full">
+ <div className="flex items-center gap-4 mb-4">
+ <Label
+ htmlFor="customAiUrl"
+ className="min-w-[80px] text-right"
+ >
+ custom url
+ </Label>
<Input
- id="aiApiKey"
- type={showApiKey ? "text" : "password"}
- value={localSettings.openaiApiKey}
- onChange={handleApiKeyChange}
- className="pr-10"
- placeholder="enter your ai api key"
+ id="customAiUrl"
+ value={localSettings.aiUrl}
+ onChange={handleCustomUrlChange}
+ className="flex-grow"
+ placeholder="enter custom ai url"
autoCorrect="off"
autoCapitalize="off"
autoComplete="off"
+ type="text"
/>
- <Button
- type="button"
- variant="ghost"
- size="icon"
- className="absolute right-0 top-0 h-full"
- onClick={() => setShowApiKey(!showApiKey)}
+ </div>
+ </div>
+ )}
+ {isApiKeyRequired && (
+ <div className="w-full">
+ <div className="flex items-center gap-4 mb-4">
+ <Label
+ htmlFor="aiApiKey"
+ className="min-w-[80px] text-right"
>
- {showApiKey ? (
- <EyeOff className="h-4 w-4" />
- ) : (
- <Eye className="h-4 w-4" />
- )}
- </Button>
+ api key
+ </Label>
+ <div className="flex-grow relative">
+ <Input
+ id="aiApiKey"
+ type={showApiKey ? "text" : "password"}
+ value={localSettings.openaiApiKey}
+ onChange={handleApiKeyChange}
+ className="pr-10"
+ placeholder="enter your ai api key"
+ autoCorrect="off"
+ autoCapitalize="off"
+ autoComplete="off"
+ />
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon"
+ className="absolute right-0 top-0 h-full"
+ onClick={() => setShowApiKey(!showApiKey)}
+ >
+ {showApiKey ? (
+ <EyeOff className="h-4 w-4" />
+ ) : (
+ <Eye className="h-4 w-4" />
+ )}
+ </Button>
+ </div>
</div>
</div>
- </div>
+ )}
<div className="w-full">
<div className="flex items-center gap-4 mb-4">
<Label htmlFor="aiModel" className="min-w-[80px] text-right">
ai model
</Label>
- <Input
- id="aiModel"
- value={localSettings.aiModel}
- onChange={handleModelChange}
- className="flex-grow"
- placeholder="enter ai model (e.g., gpt-4)"
- autoCorrect="off"
- autoCapitalize="off"
- autoComplete="off"
- />
+ <div className="flex-grow relative">
+ <Input
+ id="aiModel"
+ value={localSettings.aiModel}
+ onChange={handleModelChange}
+ className="flex-grow"
+ placeholder={
+ localSettings.aiUrl === "http://localhost:11434/v1"
+ ? "e.g., llama2:7b-chat"
+ : "e.g., gpt-4"
+ }
+ autoCorrect="off"
+ autoCapitalize="off"
+ autoComplete="off"
+ />
+ </div>
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <HelpCircle className="ml-2 h-4 w-4 cursor-default" />
+ </TooltipTrigger>
+ <TooltipContent side="left">
+ {getModelTooltipContent()}
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
</div>
</div>
diff --git a/screenpipe-app-tauri/lib/hooks/use-health-check.tsx b/screenpipe-app-tauri/lib/hooks/use-health-check.tsx
index 78cf5d7f3..e5115216d 100644
--- a/screenpipe-app-tauri/lib/hooks/use-health-check.tsx
+++ b/screenpipe-app-tauri/lib/hooks/use-health-check.tsx
@@ -12,46 +12,53 @@ interface HealthCheckResponse {
export function useHealthCheck() {
const [health, setHealth] = useState<HealthCheckResponse | null>(null);
+ const [isServerDown, setIsServerDown] = useState(false);
+ const baseCheckInterval = 5000; // 5 seconds
+ const maxCheckInterval = 60000; // 1 minute
const fetchHealth = async () => {
try {
const response = await fetch("http://localhost:3030/health");
if (!response.ok) {
- const text = await response.text();
- throw new Error(`HTTP error! status: ${response.status} ${text}`);
+ throw new Error(`http error! status: ${response.status}`);
}
const data: HealthCheckResponse = await response.json();
if (
- (health !== null && health.status === data.status) ||
- // did not change
- (health != null &&
- health.status_code === data.status_code &&
- health.message === data.message)
+ !health ||
+ health.status !== data.status ||
+ health.status_code !== data.status_code ||
+ health.message !== data.message
) {
- return;
+ setHealth(data);
}
- // console.log("setting health", data);
- setHealth(data);
+ setIsServerDown(false);
} catch (error) {
- // console.error("Failed to fetch health status:", error);
- setHealth({
- last_frame_timestamp: null,
- last_audio_timestamp: null,
- frame_status: "error",
- audio_status: "error",
- status: "error",
- status_code: 500,
- message: "failed to fetch health status. server might be down.",
- });
+ if (!isServerDown) {
+ setIsServerDown(true);
+ setHealth({
+ last_frame_timestamp: null,
+ last_audio_timestamp: null,
+ frame_status: "error",
+ audio_status: "error",
+ status: "error",
+ status_code: 500,
+ message: "failed to fetch health status. server might be down.",
+ });
+ }
}
};
useEffect(() => {
fetchHealth();
- const interval = setInterval(fetchHealth, 1000); // Poll every 1 second
+ const interval = setInterval(
+ () => {
+ fetchHealth();
+ },
+ isServerDown ? maxCheckInterval : baseCheckInterval
+ );
return () => clearInterval(interval);
- }, []);
+ }, [isServerDown]);
- return { health };
+ return { health, isServerDown };
}
diff --git a/screenpipe-app-tauri/package.json b/screenpipe-app-tauri/package.json
index b324e8877..dceeb3017 100644
--- a/screenpipe-app-tauri/package.json
+++ b/screenpipe-app-tauri/package.json
@@ -6,7 +6,7 @@
"start": "next start",
"lint": "next lint",
"build": "next build",
- "tauri": "tauri",
+ "tauri": "echo '\u001b[33mWarning: did you run bun scripts/pre_build.js and ALL other instructions carefully listed in https://docs.screenpi.pe/docs/getting-started ?\u001b[0m' && tauri",
"clean": "rm -rf out && cargo clean && rm -rf src-tauri/{screenpipe-*,tesseract-*,ffmpeg} node_modules"
},
"dependencies": {
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.toml
index 9354239d3..190e87cc9 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.5.6"
+version = "0.5.7"
description = ""
authors = ["you"]
license = ""
diff --git a/screenpipe-app-tauri/src-tauri/src/main.rs b/screenpipe-app-tauri/src-tauri/src/main.rs
index cd830884a..aa9ea01b3 100755
--- a/screenpipe-app-tauri/src-tauri/src/main.rs
+++ b/screenpipe-app-tauri/src-tauri/src/main.rs
@@ -307,12 +307,29 @@ async fn main() {
.and_then(|v| v.as_bool())
.unwrap_or(false);
+ // if first time user do t start sidecar yet
+ let mut is_first_time_user = store
+ .get("isFirstTimeUser")
+ .and_then(|v| v.as_bool())
+ .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"))
+ .map(|mut entries| entries.next().is_some())
+ .unwrap_or(false);
+
+ if has_files {
+ is_first_time_user = false;
+ }
+
let sidecar_manager = Arc::new(Mutex::new(SidecarManager::new()));
app.manage(sidecar_manager.clone());
let app_handle = app.handle().clone();
- if !use_dev_mode {
+ if !use_dev_mode && !is_first_time_user {
tauri::async_runtime::spawn(async move {
let mut manager = sidecar_manager.lock().await;
if let Err(e) = manager.spawn(&app_handle).await {
diff --git a/screenpipe-app-tauri/src-tauri/src/sidecar.rs b/screenpipe-app-tauri/src-tauri/src/sidecar.rs
index 9ce643846..017c9a01e 100644
--- a/screenpipe-app-tauri/src-tauri/src/sidecar.rs
+++ b/screenpipe-app-tauri/src-tauri/src/sidecar.rs
@@ -310,7 +310,9 @@ fn spawn_sidecar(app: &tauri::AppHandle) -> Result<CommandChild, String> {
c = c.env("HF_ENDPOINT", "https://hf-mirror.com");
}
- c = c.env("PATH", path_to_sidecars);
+ let current_path = env::var("PATH").unwrap_or_default();
+ let new_path = format!("{};{}", path_to_sidecars, current_path);
+ c = c.env("PATH", new_path);
let c = c.args(&args);
@@ -330,8 +332,9 @@ fn spawn_sidecar(app: &tauri::AppHandle) -> Result<CommandChild, String> {
command = command.env("HF_ENDPOINT", "https://hf-mirror.com");
}
- // pass the sidecars PATH to the screenpipe process
- command = command.env("PATH", path_to_sidecars);
+ let current_path = env::var("PATH").unwrap_or_default();
+ let new_path = format!("{}:{}", path_to_sidecars, current_path);
+ command = command.env("PATH", new_path);
let command = command.args(&args);
diff --git a/screenpipe-server/src/bin/screenpipe-server.rs b/screenpipe-server/src/bin/screenpipe-server.rs
index 6a542ee0c..94ff44d7a 100644
--- a/screenpipe-server/src/bin/screenpipe-server.rs
+++ b/screenpipe-server/src/bin/screenpipe-server.rs
@@ -9,14 +9,13 @@ use crossbeam::queue::SegQueue;
use dirs::home_dir;
use futures::{pin_mut, stream::FuturesUnordered, StreamExt};
use screenpipe_audio::{
- default_input_device, default_output_device, list_audio_devices, parse_audio_device, trigger_audio_permission, vad_engine::SileroVad, whisper::WhisperModel, AudioDevice, DeviceControl
+ default_input_device, default_output_device, list_audio_devices, parse_audio_device, AudioDevice, DeviceControl
};
use screenpipe_core::find_ffmpeg_path;
use screenpipe_server::{
cli::{Cli, CliAudioTranscriptionEngine, CliOcrEngine, Command, PipeCommand}, start_continuous_recording, watch_pid, DatabaseManager, PipeManager, ResourceMonitor, Server
};
use screenpipe_vision::monitor::list_monitors;
-use screenpipe_vision::core::trigger_screen_capture_permission;
use serde_json::{json, Value};
use tokio::{runtime::Runtime, signal, sync::broadcast};
use tracing_subscriber::prelude::__tracing_subscriber_SubscriberExt;
@@ -137,6 +136,9 @@ async fn main() -> anyhow::Result<()> {
info!("Keyboard permission requested. Please grant permission if prompted.");
}
}
+ use screenpipe_audio::{trigger_audio_permission, vad_engine::SileroVad, whisper::WhisperModel};
+ use screenpipe_vision::core::trigger_screen_capture_permission;
+
// Trigger audio permission request
if let Err(e) = trigger_audio_permission() {
error!("Failed to trigger audio permission: {:?}", e);
@@ -654,6 +656,8 @@ async fn main() -> anyhow::Result<()> {
info!("watching pid {} for auto-destruction", pid);
let shutdown_tx_clone = shutdown_tx.clone();
tokio::spawn(async move {
+ // sleep for 5 seconds
+ tokio::time::sleep(std::time::Duration::from_secs(5)).await;
if watch_pid(pid).await {
info!("watched pid {} has stopped, initiating shutdown", pid);
let _ = shutdown_tx_clone.send(());