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

feat(onboarding): simplify to 2-step flow with auto-start

Louis Beaumont1d80a5a7a445
diff --git a/screenpipe-app-tauri/app/onboarding/page.tsx b/screenpipe-app-tauri/app/onboarding/page.tsx
index 9fa74a575..214917684 100644
--- a/screenpipe-app-tauri/app/onboarding/page.tsx
+++ b/screenpipe-app-tauri/app/onboarding/page.tsx
@@ -4,47 +4,25 @@ import React, { useState, useEffect } from "react";
import { useToast } from "@/components/ui/use-toast";
import OnboardingStatus from "@/components/onboarding/status";
import OnboardingIntro from "@/components/onboarding/introduction";
-import OnboardingAPISetup from "@/components/onboarding/api-setup";
-import OnboardingInstructions from "@/components/onboarding/explain-instructions";
-import OnboardingLogin from "@/components/onboarding/login";
-import OnboardingShortcuts from "@/components/onboarding/shortcuts";
import { useOnboarding } from "@/lib/hooks/use-onboarding";
import posthog from "posthog-js";
import { commands } from "@/lib/utils/tauri";
-type SlideKey =
- | "intro"
- | "status"
- | "login"
- | "apiSetup"
- | "shortcuts"
- | "instructions";
+type SlideKey = "intro" | "status";
// Window size configurations for each slide
const SLIDE_WINDOW_SIZES: Record<SlideKey, { width: number; height: number }> = {
- intro: { width: 1100, height: 850 }, // Increased for demo content
- status: { width: 1100, height: 850 }, // Good for status checks
- login: { width: 1100, height: 680 }, // Compact for login form
- apiSetup: { width: 1100, height: 1000 }, // Taller for AI presets configuration
- shortcuts: { width: 1100, height: 850 }, // Good size for shortcuts display
- instructions: { width: 1100, height: 1050 }, // Largest for the final comprehensive instructions
+ intro: { width: 800, height: 750 },
+ status: { width: 800, height: 500 },
};
-// Simplified flow - linear progression
+// Simple 2-step flow: intro → status → done
const getNextSlide = (currentSlide: SlideKey): SlideKey | null => {
switch (currentSlide) {
case "intro":
return "status";
case "status":
- return "login";
- case "login":
- return "apiSetup";
- case "apiSetup":
- return "shortcuts";
- case "shortcuts":
- return "instructions";
- case "instructions":
- return null;
+ return null; // Complete onboarding
default:
return null;
}
@@ -56,14 +34,6 @@ const getPrevSlide = (currentSlide: SlideKey): SlideKey | null => {
return null;
case "status":
return "intro";
- case "login":
- return "status";
- case "apiSetup":
- return "login";
- case "shortcuts":
- return "apiSetup";
- case "instructions":
- return "shortcuts";
default:
return null;
}
@@ -270,8 +240,8 @@ export default function OnboardingPage() {
return (
<div className="flex items-center justify-center min-h-screen bg-background">
<div className="text-center">
- <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"></div>
- <p className="text-muted-foreground">Loading onboarding...</p>
+ <div className="w-6 h-6 border border-foreground border-t-transparent animate-spin mx-auto mb-4"></div>
+ <p className="font-mono text-xs text-muted-foreground">loading...</p>
</div>
</div>
);
@@ -279,28 +249,22 @@ export default function OnboardingPage() {
return (
<div className="flex flex-col w-full h-screen overflow-hidden bg-background">
- {/* Progress indicator with drag region */}
- <div className="w-full bg-secondary p-4 border-b border-border" data-tauri-drag-region>
- <div className="flex items-center justify-between max-w-4xl mx-auto">
- <div className="flex items-center space-x-2">
- <span className="text-sm font-medium text-text-primary">Progress:</span>
- <div className="text-sm text-text-secondary">
- Step {["intro", "status", "login", "apiSetup", "shortcuts", "instructions"].indexOf(currentSlide) + 1} of 6
- </div>
- </div>
+ {/* Minimal header with drag region */}
+ <div className="w-full bg-background p-4" data-tauri-drag-region>
+ <div className="flex items-center justify-end max-w-4xl mx-auto">
<button
onClick={handleSkip}
disabled={isTransitioning}
- className="text-sm text-text-secondary hover:text-text-primary disabled:opacity-50 transition-colors"
+ className="font-mono text-xs text-muted-foreground hover:text-foreground disabled:opacity-50 transition-colors"
>
- Skip onboarding
+ skip
</button>
</div>
</div>
- {/* Main content container - centered and properly sized */}
+ {/* Main content container */}
<div className="flex-1 flex items-center justify-center p-6 overflow-auto">
- <div className="w-full max-w-4xl mx-auto h-full flex items-center justify-center">
+ <div className="w-full max-w-2xl mx-auto">
{currentSlide === "intro" && (
<OnboardingIntro
className={`transition-opacity duration-300 w-full
@@ -313,39 +277,7 @@ export default function OnboardingPage() {
className={`transition-opacity duration-300 w-full
${isVisible ? "opacity-100 ease-out" : "opacity-0 ease-in"}`}
handlePrevSlide={handlePrevSlide}
- handleNextSlide={handleNextSlide}
- />
- )}
- {currentSlide === "login" && (
- <OnboardingLogin
- className={`transition-opacity duration-300 w-full
- ${isVisible ? "opacity-100 ease-out" : "opacity-0 ease-in"}`}
- handleNextSlide={handleNextSlide}
- handlePrevSlide={handlePrevSlide}
- />
- )}
- {currentSlide === "apiSetup" && (
- <OnboardingAPISetup
- className={`transition-opacity duration-300 ease-in-out w-full
- ${isVisible ? "opacity-100 ease-out" : "opacity-0 ease-in"}`}
- handleNextSlide={handleNextSlide}
- handlePrevSlide={handlePrevSlide}
- />
- )}
- {currentSlide === "shortcuts" && (
- <OnboardingShortcuts
- className={`transition-opacity duration-300 ease-in-out w-full
- ${isVisible ? "opacity-100 ease-out" : "opacity-0 ease-in"}`}
- handleNextSlide={handleNextSlide}
- handlePrevSlide={handlePrevSlide}
- />
- )}
- {currentSlide === "instructions" && (
- <OnboardingInstructions
- className={`transition-opacity duration-300 ease-in-out w-full
- ${isVisible ? "opacity-100 ease-out" : "opacity-0 ease-in"}`}
handleNextSlide={handleEnd}
- handlePrevSlide={handlePrevSlide}
/>
)}
</div>
diff --git a/screenpipe-app-tauri/components/onboarding/introduction.tsx b/screenpipe-app-tauri/components/onboarding/introduction.tsx
index 82800106f..f43c9063b 100644
--- a/screenpipe-app-tauri/components/onboarding/introduction.tsx
+++ b/screenpipe-app-tauri/components/onboarding/introduction.tsx
@@ -1,12 +1,7 @@
-import React, { useState } from "react";
+import React from "react";
import { Button } from "@/components/ui/button";
-import { RainbowButton } from "../ui/rainbow-button";
-import { ArrowRight, Video, Mic, Brain, Clock, Play } from "lucide-react";
-import { useSettings } from "@/lib/hooks/use-settings";
-import posthog from "posthog-js";
-import { useOnboarding } from "@/lib/hooks/use-onboarding";
+import { ArrowRight, Video, Mic, Brain, Clock } from "lucide-react";
import { motion } from "framer-motion";
-import { commands } from "@/lib/utils/tauri";
interface OnboardingIntroProps {
className?: string;
@@ -17,63 +12,31 @@ const OnboardingIntro: React.FC<OnboardingIntroProps> = ({
className = "",
handleNextSlide,
}) => {
- const { completeOnboarding } = useOnboarding();
- const [currentStep, setCurrentStep] = useState(0);
- const [showDemo, setShowDemo] = useState(false);
-
- const handleSkip = async () => {
- try {
- await completeOnboarding();
- posthog.capture("onboarding_skipped");
-
- // Show main window and close onboarding window
- await commands.showWindow("Main");
-
- // Close the onboarding window
- if (typeof window !== 'undefined' && 'close' in window) {
- window.close();
- }
- } catch (error) {
- console.error("Error skipping onboarding:", error);
- }
- };
-
const features = [
{
icon: Video,
- title: "Records Your Screen",
- description: "Captures everything you see and do on your computer",
- color: "text-blue-500"
+ title: "records your screen",
+ description: "captures everything you see and do on your computer",
},
{
icon: Mic,
- title: "Captures Audio",
- description: "Records conversations, meetings, and all audio interactions",
- color: "text-green-500"
+ title: "captures audio",
+ description: "records conversations, meetings, and all audio interactions",
},
{
icon: Clock,
- title: "Creates a Timeline",
- description: "Organizes everything into an easy-to-navigate visual timeline",
- color: "text-purple-500"
+ title: "creates a timeline",
+ description: "organizes everything into an easy-to-navigate visual timeline",
},
{
icon: Brain,
- title: "AI-Powered Search",
- description: "Ask questions about your recorded data using AI",
- color: "text-orange-500"
+ title: "ai-powered search",
+ description: "ask questions about your recorded data using AI",
}
];
- const demoSteps = [
- "🖥️ screenpipe quietly records your screen activity",
- "🎙️ Captures audio from meetings and conversations",
- "📅 Creates a beautiful timeline of your day",
- "🤖 AI helps you find anything: 'What did I discuss in my 2pm meeting?'"
- ];
-
return (
- <div className={`flex justify-center items-center flex-col space-y-6 ${className}`}>
+ <div className={`flex justify-center items-center flex-col space-y-8 ${className}`}>
<div className="flex flex-col px-2 justify-center items-center">
<motion.img
className="w-24 h-24 justify-center"
@@ -83,129 +46,57 @@ const OnboardingIntro: React.FC<OnboardingIntroProps> = ({
animate={{ scale: 1, opacity: 1 }}
transition={{ duration: 0.5 }}
/>
- <h1 className="text-center text-3xl font-bold bg-gradient-to-r from-blue-600 to-purple-600 bg-clip-text text-transparent">
- Welcome to screenpipe
+ <h1 className="text-center text-3xl font-mono font-bold text-foreground mt-4">
+ screenpipe
</h1>
- <p className="text-center text-lg text-text-secondary mt-2">
- Your AI-powered digital memory assistant
+ <p className="text-center text-sm font-mono text-muted-foreground mt-2">
+ memory infrastructure for your computer
</p>
</div>
- {!showDemo ? (
- <>
- <div className="grid grid-cols-2 gap-4 max-w-2xl">
- {features.map((feature, index) => (
- <motion.div
- key={index}
- className="bg-card border border-border rounded-xl p-4 hover:shadow-lg transition-all duration-300"
- initial={{ opacity: 0, y: 20 }}
- animate={{ opacity: 1, y: 0 }}
- transition={{ delay: index * 0.1 }}
- >
- <feature.icon className={`w-8 h-8 ${feature.color} mb-3`} />
- <h3 className="font-semibold text-sm mb-1 text-text-primary">{feature.title}</h3>
- <p className="text-xs text-text-secondary">{feature.description}</p>
- </motion.div>
- ))}
- </div>
-
- <div className="bg-gradient-to-r from-blue-50 to-purple-50 dark:from-blue-950/20 dark:to-purple-950/20 rounded-xl p-6 max-w-2xl">
- <h3 className="text-lg font-semibold text-center mb-3 text-text-primary">How it works</h3>
- <div className="flex items-center justify-center space-x-3 text-sm">
- <div className="flex items-center space-x-1">
- <Video className="w-4 h-4 text-blue-500" />
- <span className="text-text-primary">Record</span>
- </div>
- <ArrowRight className="w-4 h-4 text-text-secondary" />
- <div className="flex items-center space-x-1">
- <Clock className="w-4 h-4 text-purple-500" />
- <span className="text-text-primary">Timeline</span>
- </div>
- <ArrowRight className="w-4 h-4 text-text-secondary" />
- <div className="flex items-center space-x-1">
- <Brain className="w-4 h-4 text-orange-500" />
- <span className="text-text-primary">AI Search</span>
- </div>
- </div>
- </div>
+ <div className="grid grid-cols-2 gap-4 max-w-2xl">
+ {features.map((feature, index) => (
+ <motion.div
+ key={index}
+ className="bg-card border border-border p-5 hover:bg-foreground hover:text-background transition-all duration-150 group"
+ initial={{ opacity: 0, y: 20 }}
+ animate={{ opacity: 1, y: 0 }}
+ transition={{ delay: index * 0.1 }}
+ >
+ <feature.icon className="w-6 h-6 text-foreground group-hover:text-background mb-3" strokeWidth={1.5} />
+ <h3 className="font-mono text-sm mb-1 text-foreground group-hover:text-background">{feature.title}</h3>
+ <p className="font-mono text-xs text-muted-foreground group-hover:text-background/70">{feature.description}</p>
+ </motion.div>
+ ))}
+ </div>
- <div className="flex gap-4 mt-6">
- <Button
- variant="ghost"
- onClick={() => setShowDemo(true)}
- className="text-text-secondary hover:text-text-primary"
- >
- <Play className="w-4 h-4 mr-2" />
- See Demo
- </Button>
- <Button
- variant="ghost"
- onClick={handleSkip}
- className="text-text-secondary hover:text-text-primary"
- >
- Skip Setup
- </Button>
- <RainbowButton onClick={handleNextSlide}>
- Get Started
- <ArrowRight className="w-4 w-4 ml-2" />
- </RainbowButton>
+ <div className="border border-border p-6 max-w-md">
+ <h3 className="font-mono text-sm text-center mb-4 text-foreground">how it works</h3>
+ <div className="flex items-center justify-center space-x-4 font-mono text-xs">
+ <div className="flex items-center space-x-2">
+ <Video className="w-4 h-4 text-foreground" strokeWidth={1.5} />
+ <span className="text-foreground">record</span>
</div>
- </>
- ) : (
- <div className="max-w-2xl">
- <div className="bg-surface rounded-xl overflow-hidden shadow-2xl border border-border">
- <div className="bg-surface-secondary px-4 py-2 flex items-center space-x-2">
- <div className="w-3 h-3 bg-red-500 rounded-full"></div>
- <div className="w-3 h-3 bg-yellow-500 rounded-full"></div>
- <div className="w-3 h-3 bg-green-500 rounded-full"></div>
- <span className="text-text-secondary text-sm ml-2">screenpipe Demo</span>
- </div>
- <div className="p-6 h-64 bg-gradient-to-br from-surface to-surface-tertiary relative overflow-hidden">
- <motion.div
- className="absolute inset-0 flex items-center justify-center"
- initial={{ opacity: 0 }}
- animate={{ opacity: 1 }}
- transition={{ duration: 0.5 }}
- >
- <div className="text-center text-text-primary space-y-4">
- {demoSteps.map((step, index) => (
- <motion.p
- key={index}
- className="text-lg"
- initial={{ opacity: 0, x: -20 }}
- animate={{ opacity: 1, x: 0 }}
- transition={{ delay: index * 0.8, duration: 0.5 }}
- >
- {step}
- </motion.p>
- ))}
- </div>
- </motion.div>
- </div>
+ <span className="text-muted-foreground">→</span>
+ <div className="flex items-center space-x-2">
+ <Clock className="w-4 h-4 text-foreground" strokeWidth={1.5} />
+ <span className="text-foreground">timeline</span>
</div>
-
- <div className="flex gap-4 mt-6 justify-center">
- <Button
- variant="ghost"
- onClick={() => setShowDemo(false)}
- className="text-text-secondary hover:text-text-primary"
- >
- Back
- </Button>
- <Button
- variant="ghost"
- onClick={handleSkip}
- className="text-text-secondary hover:text-text-primary"
- >
- Skip Setup
- </Button>
- <RainbowButton onClick={handleNextSlide}>
- Get Started
- <ArrowRight className="w-4 h-4 ml-2" />
- </RainbowButton>
+ <span className="text-muted-foreground">→</span>
+ <div className="flex items-center space-x-2">
+ <Brain className="w-4 h-4 text-foreground" strokeWidth={1.5} />
+ <span className="text-foreground">search</span>
</div>
</div>
- )}
+ </div>
+
+ <Button
+ onClick={handleNextSlide}
+ size="lg"
+ >
+ get started
+ <ArrowRight className="w-4 h-4 ml-2" strokeWidth={1.5} />
+ </Button>
</div>
);
};
diff --git a/screenpipe-app-tauri/components/onboarding/status.tsx b/screenpipe-app-tauri/components/onboarding/status.tsx
index 3e2f45d48..27efde919 100644
--- a/screenpipe-app-tauri/components/onboarding/status.tsx
+++ b/screenpipe-app-tauri/components/onboarding/status.tsx
@@ -1,27 +1,12 @@
import React, { useState, useEffect, useRef } from "react";
-import { Check, HelpCircle, Video, ChevronDown } from "lucide-react";
-import OnboardingNavigation from "@/components/onboarding/navigation";
+import { Check, Monitor, Mic } from "lucide-react";
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";
-import { LogFileButton } from "../log-file-button";
-import { Separator } from "../ui/separator";
import { invoke } from "@tauri-apps/api/core";
import posthog from "posthog-js";
-import { toast } from "@/components/ui/use-toast";
-import { PermissionButtons } from "../status/permission-buttons";
import { usePlatform } from "@/lib/hooks/use-platform";
-import { pipe } from "@screenpipe/browser";
-import { VisionEvent } from "@screenpipe/browser";
-import Image from "next/image";
import { commands, OSPermissionsCheck } from "@/lib/utils/tauri";
+import { motion } from "framer-motion";
+import { useSettings, DEFAULT_PROMPT } from "@/lib/hooks/use-settings";
interface OnboardingStatusProps {
className?: string;
@@ -29,474 +14,250 @@ interface OnboardingStatusProps {
handleNextSlide: () => void;
}
+type SetupState = "checking" | "needs-permissions" | "ready" | "starting" | "recording";
+
const OnboardingStatus: React.FC<OnboardingStatusProps> = ({
className = "",
- handlePrevSlide,
handleNextSlide,
}) => {
- const [status, setStatus] = useState<string | null>(null);
- const [isLoading, setIsLoading] = useState(false);
- const [useChineseMirror, setUseChineseMirror] = useState(false);
- const { updateSettings, settings } = useSettings();
- const { isMac: isMacOS } = usePlatform();
- const [stats, setStats] = useState<{
- screenshots: number;
- audioSeconds: number;
- } | null>(null);
- const [visionEvent, setVisionEvent] = useState<VisionEvent | null>(null);
- const [showScrollButton, setShowScrollButton] = useState(false);
- const containerRef = useRef<HTMLDivElement>(null);
+ const [setupState, setSetupState] = useState<SetupState>("checking");
const [permissions, setPermissions] = useState<OSPermissionsCheck | null>(null);
+ const { isMac: isMacOS } = usePlatform();
+ const { settings, updateSettings } = useSettings();
+ const hasStartedRef = useRef(false);
+
+ // Create default screenpipe-cloud preset if none exists
+ const ensureDefaultPreset = async () => {
+ if (settings.aiPresets.length === 0) {
+ const defaultPreset = {
+ id: crypto.randomUUID(),
+ provider: "screenpipe-cloud" as const,
+ url: "https://ai-proxy.i-f9f.workers.dev/v1",
+ model: "gpt-4o-mini",
+ maxContextChars: 512000,
+ defaultPreset: true,
+ prompt: DEFAULT_PROMPT,
+ };
+ await updateSettings({ aiPresets: [defaultPreset] });
+ }
+ };
- // Check permissions on macOS
- useEffect(() => {
- const checkPermissions = async () => {
- if (isMacOS) {
- try {
- const perms = await commands.doPermissionsCheck(true);
- setPermissions(perms);
- } catch (error) {
- console.error("Failed to check permissions:", error);
- }
- }
- };
-
- // Poll permissions every 2 seconds
- const intervalId = setInterval(() => {
- checkPermissions();
- }, 2000);
-
- // Initial check
- checkPermissions();
-
- // Cleanup interval on unmount
- return () => clearInterval(intervalId);
- }, [isMacOS]);
+ const handleComplete = async () => {
+ await ensureDefaultPreset();
+ handleNextSlide();
+ };
+ // Check permissions
useEffect(() => {
- const fetchStats = async () => {
- try {
- const screenshotsResponse = await fetch(
- "http://localhost:3030/raw_sql",
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- query: `SELECT COUNT(*) as count FROM frames`,
- }),
- }
- );
- const screenshotsResult = await screenshotsResponse.json();
-
- const audioResponse = await fetch("http://localhost:3030/raw_sql", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- query: `
- SELECT
- ROUND(SUM((end_time - start_time)), 2) as total_seconds
- FROM audio_transcriptions
- WHERE start_time IS NOT NULL
- AND end_time IS NOT NULL
- `,
- }),
- });
- const audioResult = await audioResponse.json();
+ const checkPermissions = async () => {
+ // Don't check if already starting or recording
+ if (hasStartedRef.current) return;
- setStats({
- screenshots: screenshotsResult[0].count,
- audioSeconds: audioResult[0].total_seconds || 0,
- });
- } catch (error) {
- console.error("failed to fetch stats:", error);
+ if (!isMacOS) {
+ setSetupState("ready");
+ return;
}
- };
- // initial fetch
- fetchStats();
-
- // set up interval for periodic updates
- const interval = setInterval(fetchStats, 1000); // refresh every second
-
- // cleanup interval on unmount
- return () => clearInterval(interval);
- }, []);
-
- // Add effect for streaming screenshots when recording starts
- useEffect(() => {
- let isActive = false;
-
- const streamVision = async () => {
- if (status !== "ok" || isActive) return;
-
- isActive = true;
try {
- console.log("starting vision stream");
- for await (const event of pipe.streamVision(true)) {
- setVisionEvent(event.data);
- console.log("vision event received");
+ const perms = await commands.doPermissionsCheck(true);
+ setPermissions(perms);
- // Scroll to bottom when new vision event is received
- setTimeout(() => {
- if (containerRef.current) {
- // Only auto-scroll if already near the bottom
- const { scrollTop, scrollHeight, clientHeight } =
- containerRef.current;
- const isNearBottom =
- scrollHeight - scrollTop - clientHeight < 150;
+ const screenOk = perms.screenRecording === "granted" || perms.screenRecording === "notNeeded";
+ const audioOk = perms.microphone === "granted" || perms.microphone === "notNeeded";
- if (isNearBottom) {
- containerRef.current.scrollTo({
- top: containerRef.current.scrollHeight,
- behavior: "smooth",
- });
- } else if (!showScrollButton) {
- setShowScrollButton(true);
- }
- }
- }, 100);
+ if (screenOk && audioOk && !hasStartedRef.current) {
+ setSetupState("ready");
+ } else if (!hasStartedRef.current) {
+ setSetupState("needs-permissions");
}
} catch (error) {
- console.error("vision stream error:", error);
- } finally {
- isActive = false;
+ console.error("Failed to check permissions:", error);
+ if (!hasStartedRef.current) {
+ setSetupState("ready");
+ }
}
};
- streamVision();
-
- return () => {
- pipe.disconnect();
- };
- }, [status, showScrollButton]);
-
- // Add effect to scroll to bottom when status changes to "ok"
- useEffect(() => {
- if (status === "ok" && containerRef.current) {
- setTimeout(() => {
- if (containerRef.current) {
- containerRef.current.scrollTo({
- top: containerRef.current.scrollHeight,
- behavior: "smooth",
- });
- }
- }, 500); // Give time for the UI to render
- }
- }, [status]);
+ checkPermissions();
+ const interval = setInterval(checkPermissions, 2000);
+ return () => clearInterval(interval);
+ }, [isMacOS]);
- // Add scroll event listener to show/hide scroll button
+ // Auto-start when ready (only once)
useEffect(() => {
- const container = containerRef.current;
- if (!container) return;
-
- const handleScroll = () => {
- const { scrollTop, scrollHeight, clientHeight } = container;
- // Show button if not at bottom (with some threshold)
- const isAtBottom = scrollHeight - scrollTop - clientHeight < 50;
- setShowScrollButton(!isAtBottom);
- };
-
- container.addEventListener("scroll", handleScroll);
- return () => container.removeEventListener("scroll", handleScroll);
- }, []);
-
- const scrollToBottom = () => {
- if (containerRef.current) {
- containerRef.current.scrollTo({
- top: containerRef.current.scrollHeight,
- behavior: "smooth",
- });
+ if (setupState === "ready" && !hasStartedRef.current) {
+ hasStartedRef.current = true;
+ handleStartRecording();
}
- };
+ }, [setupState]);
- const handleStartScreenpipe = async () => {
+ const handleStartRecording = async () => {
posthog.capture("screenpipe_setup_start");
- setIsLoading(true);
- const toastId = toast({
- title: "starting screenpipe",
- description:
- "please wait as we download AI models and start recording\nplease check logs if this is taking longer than expected (30s)",
- duration: Infinity,
- });
+ setSetupState("starting");
+
try {
await invoke("stop_screenpipe");
- await new Promise((resolve) => setTimeout(resolve, 1_000));
-
- await invoke("spawn_screenpipe", {
- overrideArgs: ["--enable-realtime-vision"],
- });
- await new Promise((resolve) => setTimeout(resolve, 5_000));
- toastId.update({
- id: toastId.id,
- title: "screenpipe started",
- description: "screenpipe is now running.",
- duration: 3000,
- });
- setStatus("ok");
+ await new Promise((resolve) => setTimeout(resolve, 1000));
+ await invoke("spawn_screenpipe");
+ await new Promise((resolve) => setTimeout(resolve, 3000));
+ setSetupState("recording");
} catch (error) {
- console.error("failed to start screenpipe:", error);
- toastId.update({
- id: toastId.id,
- title: "error",
- description: "failed to start screenpipe.",
- variant: "destructive",
- duration: 3000,
- });
- } finally {
- toastId.dismiss();
- setIsLoading(false);
- }
- };
-
- const handleNext = () => {
- setStatus(null);
- handleNextSlide();
- };
-
- const handlePrev = () => {
- setStatus(null);
- handlePrevSlide();
- };
-
- const handleChineseMirrorToggle = async (checked: boolean) => {
- setUseChineseMirror(checked);
- updateSettings({ useChineseMirror: checked });
- };
-
- // Helper function to check if screen recording permission is granted
- const isScreenRecordingPermissionGranted = () => {
- if (!isMacOS) {
- // On non-macOS platforms, assume permission is granted
- return true;
+ console.error("Failed to start screenpipe:", error);
+ setSetupState("ready");
}
-
- const screenPermission = permissions?.screenRecording;
- return screenPermission === "granted" || screenPermission === "notNeeded";
};
- // Helper function to check if audio permission is granted (when audio is enabled)
- const isAudioPermissionGranted = () => {
- if (!isMacOS || settings.disableAudio) {
- // On non-macOS platforms or when audio is disabled, assume permission is granted
- return true;
+ const openSystemPreferences = async (type: "screen" | "audio") => {
+ try {
+ if (type === "screen") {
+ await commands.openScreenRecordingPreferences();
+ } else {
+ await commands.openMicrophonePreferences();
+ }
+ } catch (error) {
+ console.error("Failed to open preferences:", error);
}
-
- const audioPermission = permissions?.microphone;
- return audioPermission === "granted" || audioPermission === "notNeeded";
- };
-
- // Helper function to check if all required permissions are granted
- const areRequiredPermissionsGranted = () => {
- return isScreenRecordingPermissionGranted() && isAudioPermissionGranted();
};
- // Check if next button should be disabled
- const isNextDisabled = isLoading || (isMacOS && !areRequiredPermissionsGranted());
+ const screenGranted = permissions?.screenRecording === "granted" || permissions?.screenRecording === "notNeeded";
+ const audioGranted = permissions?.microphone === "granted" || permissions?.microphone === "notNeeded";
return (
- <div
- ref={containerRef}
- className={`${className} w-full flex flex-col items-center relative max-h-full`}
- >
- <div className="flex flex-col items-center justify-start w-full overflow-y-auto py-4">
- <div className="w-32 h-32 flex items-center justify-center">
- <img className="w-32 h-32" src="/128x128.png" alt="screenpipe-logo" />
- </div>
- <h1 className="text-center text-2xl text-text-primary">
- setting up screenpipe
- </h1>
- <p className="text-sm text-text-secondary pt-2">
- 100% local-first • your data never leaves your device
- </p>
-
- {isMacOS && (
- <div className="mt-6 pt-4 border-t border-border w-full flex flex-col items-center">
- <h4 className="text-sm font-medium mb-3 text-text-primary">check permissions</h4>
- <div className="space-y-2">
- <PermissionButtons type="screen" />
- <PermissionButtons type="audio" />
- </div>
- {!areRequiredPermissionsGranted() && (
- <p className="text-xs text-amber-600 dark:text-amber-400 mt-2 text-center">
- {!isScreenRecordingPermissionGranted() && !isAudioPermissionGranted()
- ? "screen recording and audio permissions are required to continue"
- : !isScreenRecordingPermissionGranted()
- ? "screen recording permission is required to continue"
- : "audio permission is required to continue"}
- </p>
- )}
- </div>
+ <div className={`${className} w-full flex flex-col items-center justify-center min-h-[400px]`}>
+
+ {/* Checking state */}
+ {setupState === "checking" && (
+ <motion.div
+ className="flex flex-col items-center space-y-4"
+ initial={{ opacity: 0 }}
+ animate={{ opacity: 1 }}
+ >
+ <div className="w-6 h-6 border border-foreground border-t-transparent animate-spin" />
+ <p className="font-mono text-sm text-muted-foreground">checking permissions...</p>
+ </motion.div>
)}
- <Separator className="w-full my-2 bg-border" />
-
- <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"
+ {/* Needs permissions */}
+ {setupState === "needs-permissions" && (
+ <motion.div
+ className="flex flex-col items-center space-y-8 max-w-md"
+ initial={{ opacity: 0, y: 20 }}
+ animate={{ opacity: 1, y: 0 }}
>
- <span>i am currently in mainland china</span>
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger>
- <HelpCircle className="h-4 w-4 cursor-default" />
- </TooltipTrigger>
- <TooltipContent side="right">
- <p>
- enable this option to use a chinese cloud for
- <br />
- downloading AI models
- <br />
- which are blocked in mainland china.
- </p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </Label>
- </div>
- <div className="w-full flex flex-col items-center justify-center gap-2 my-1">
- {status === null ? (
- <Button
- onClick={handleStartScreenpipe}
- 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 text-text-secondary 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>
- ) : (
- <Video className="h-4 w-4 mr-2" />
- )}
- {isLoading ? "starting..." : "start recording"}
- </Button>
- ) : status === "ok" ? (
- <div className="flex flex-col items-center mt-4">
- <Check className="size-5 text-success" />
- <p className="text-sm text-text-secondary mt-2 text-center">
- screenpipe setup complete. <br />
- AI models downloaded.
+ <div className="text-center space-y-2">
+ <h2 className="font-mono text-xl text-foreground">grant access</h2>
+ <p className="font-mono text-xs text-muted-foreground">
+ screenpipe needs permission to capture your screen and audio
</p>
</div>
- ) : (
- <p className="text-center mt-4 text-text-primary">{status}</p>
- )}
- <LogFileButton />
- </div>
+ <div className="space-y-3 w-full">
+ <button
+ onClick={() => openSystemPreferences("screen")}
+ className="w-full flex items-center justify-between p-4 border border-border hover:bg-foreground hover:text-background transition-all group"
+ >
+ <div className="flex items-center space-x-3">
+ <Monitor className="w-5 h-5" strokeWidth={1.5} />
+ <span className="font-mono text-sm">screen recording</span>
+ </div>
+ {screenGranted ? (
+ <Check className="w-5 h-5 text-foreground group-hover:text-background" strokeWidth={1.5} />
+ ) : (
+ <span className="font-mono text-xs text-muted-foreground group-hover:text-background/70">click to enable</span>
+ )}
+ </button>
+
+ <button
+ onClick={() => openSystemPreferences("audio")}
+ className="w-full flex items-center justify-between p-4 border border-border hover:bg-foreground hover:text-background transition-all group"
+ >
+ <div className="flex items-center space-x-3">
+ <Mic className="w-5 h-5" strokeWidth={1.5} />
+ <span className="font-mono text-sm">microphone</span>
+ </div>
+ {audioGranted ? (
+ <Check className="w-5 h-5 text-foreground group-hover:text-background" strokeWidth={1.5} />
+ ) : (
+ <span className="font-mono text-xs text-muted-foreground group-hover:text-background/70">click to enable</span>
+ )}
+ </button>
+ </div>
+
+ <p className="font-mono text-xs text-muted-foreground text-center">
+ toggle permissions in system settings, then return here
+ </p>
+ </motion.div>
+ )}
- {/* Screenshot stream display */}
- {status === "ok" && (
- <div
- className="w-full mt-4 p-4 space-y-3 rounded-lg border bg-card text-card-foreground shadow-sm"
- id="screenshot-preview"
+ {/* Starting state */}
+ {setupState === "starting" && (
+ <motion.div
+ className="flex flex-col items-center space-y-6"
+ initial={{ opacity: 0 }}
+ animate={{ opacity: 1 }}
>
- <div className="flex items-center justify-between">
- <h3 className="text-sm font-medium text-text-primary">live preview</h3>
- <span className="text-xs text-text-secondary">
- {visionEvent ? "streaming..." : "waiting for stream..."}
- </span>
+ <div className="w-6 h-6 border border-foreground border-t-transparent animate-spin" />
+ <div className="text-center space-y-2">
+ <p className="font-mono text-sm text-foreground">starting screenpipe...</p>
+ <p className="font-mono text-xs text-muted-foreground">downloading AI models</p>
</div>
-
- {visionEvent?.image ? (
- <div className="space-y-3">
- <div className="relative w-full h-[250px] overflow-hidden rounded-md">
- <Image
- src={`data:image/jpeg;base64,${visionEvent.image}`}
- alt="screen capture"
- fill
- style={{ objectFit: "contain" }}
- className="rounded-md"
- priority
- />
- </div>
- <div className="grid grid-cols-2 gap-2 text-xs text-text-secondary">
- <div>
- <span className="font-medium">app:</span>{" "}
- {visionEvent.app_name || "unknown"}
- </div>
- <div>
- <span className="font-medium">window:</span>{" "}
- {visionEvent.window_name || "unknown"}
- </div>
- <div>
- <span className="font-medium">time:</span>{" "}
- {new Date(visionEvent.timestamp).toLocaleTimeString()}
- </div>
- {visionEvent.browser_url && (
- <div className="col-span-2 truncate">
- <span className="font-medium">url:</span>{" "}
- {visionEvent.browser_url}
- </div>
- )}
- </div>
- </div>
- ) : (
- <div className="animate-pulse bg-muted rounded-md w-full h-[250px]" />
- )}
- </div>
+ </motion.div>
)}
- {/* Stats display */}
- {stats && (
- <div className="w-full p-4 space-y-3 rounded-lg border bg-card text-card-foreground shadow-sm">
- <div className="flex items-center justify-between">
- <div className="flex items-center gap-2">
- <Video className="h-4 w-4 text-muted-foreground" />
- <span className="text-sm text-muted-foreground">screenshots</span>
- </div>
- <span className="font-mono text-sm">
- {stats.screenshots.toLocaleString()}
- </span>
+ {/* Recording state */}
+ {setupState === "recording" && (
+ <motion.div
+ className="flex flex-col items-center space-y-8"
+ initial={{ opacity: 0, scale: 0.95 }}
+ animate={{ opacity: 1, scale: 1 }}
+ transition={{ duration: 0.3 }}
+ >
+ <div className="flex items-center space-x-3">
+ <div className="w-3 h-3 bg-foreground animate-pulse" />
+ <span className="font-mono text-lg text-foreground">recording</span>
+ </div>
+
+ <div className="text-center space-y-2">
+ <p className="font-mono text-sm text-muted-foreground">
+ screenpipe is now capturing your screen and audio
+ </p>
+ <p className="font-mono text-xs text-muted-foreground">
+ find it in your menu bar anytime
+ </p>
</div>
- <div className="flex items-center justify-between">
- <div className="flex items-center gap-2">
- <Video className="h-4 w-4 text-muted-foreground" />
- <span className="text-sm text-muted-foreground">audio</span>
+
+ <div className="flex items-center space-x-4 text-xs font-mono text-muted-foreground">
+ <div className="flex items-center space-x-2">
+ <Check className="w-4 h-4" strokeWidth={1.5} />
+ <span>screen</span>
+ </div>
+ <div className="flex items-center space-x-2">
+ <Check className="w-4 h-4" strokeWidth={1.5} />
+ <span>audio</span>
+ </div>
+ <div className="flex items-center space-x-2">
+ <Check className="w-4 h-4" strokeWidth={1.5} />
+ <span>local</span>
</div>
- <span className="font-mono text-sm">
- {Math.round(stats.audioSeconds / 60)}m
- </span>
</div>
- </div>
+
+ <Button onClick={handleComplete} size="lg">
+ continue
+ </Button>
+ </motion.div>
)}
- {/* Scroll to bottom button */}
- {showScrollButton && status === "ok" && visionEvent && (
- <button
- onClick={scrollToBottom}
- className="fixed bottom-16 right-4 bg-primary text-primary-foreground rounded-full p-2 shadow-md hover:bg-primary/90 transition-opacity z-20"
- aria-label="Scroll to bottom"
+ {/* Ready but not auto-started (fallback) */}
+ {setupState === "ready" && (
+ <motion.div
+ className="flex flex-col items-center space-y-6"
+ initial={{ opacity: 0 }}
+ animate={{ opacity: 1 }}
>
- <ChevronDown className="h-4 w-4" />
- </button>
+ <div className="w-6 h-6 border border-foreground border-t-transparent animate-spin" />
+ <p className="font-mono text-sm text-muted-foreground">preparing...</p>
+ </motion.div>
)}
- </div>
- <OnboardingNavigation
- handlePrevSlide={handlePrev}
- handleNextSlide={handleNext}
- prevBtnText="previous"
- nextBtnText="next"
- isLoading={isNextDisabled}
- />
</div>
);
};