YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix: timeline
Louis Beaumont9f8fae1d3891
diff --git a/screenpipe-app-tauri/components/pipe-store.tsx b/screenpipe-app-tauri/components/pipe-store.tsxindex 4aeed29e1..069f44008 100644--- a/screenpipe-app-tauri/components/pipe-store.tsx+++ b/screenpipe-app-tauri/components/pipe-store.tsx@@ -39,6 +39,7 @@ import { PublishDialog } from "./publish-dialog";import { invoke } from "@tauri-apps/api/core";import { Progress } from "@/components/ui/progress";import supabase from "@/lib/supabase/client";+import { CreditPurchaseDialog } from "./store/credit-purchase-dialog";export interface Pipe {enabled: boolean;@@ -60,6 +61,15 @@ interface CorePipe {}const corePipes: CorePipe[] = [+ {+ id: "timeline",+ name: "timeline",+ description:+ "visualize your day with a beautiful AI-powered timeline of your activities, perfect for time tracking and productivity analysis",+ url: "https://github.com/mediar-ai/screenpipe/tree/main/pipes/timeline",+ credits: 20,+ paid: true,+ },{id: "pipe-linkedin-ai-assistant",name: "linkedin ai assistant (preview)",@@ -113,7 +123,7 @@ const corePipes: CorePipe[] = [paid: false,},{- id: "pipe-search",+ id: "search",name: "search",description:"search through your screen recordings and audio transcripts with AI",@@ -189,6 +199,11 @@ const getFriendlyName = (id: string, corePipes: CorePipe[]): string => {.join(" ");};+const normalizeId = (id: string): string => {+ // Remove 'pipe-' prefix if it exists and convert to lowercase+ return id.replace(/^pipe-/, "").toLowerCase();+};+const PipeStore: React.FC = () => {const [newRepoUrl, setNewRepoUrl] = useState("");const [selectedPipe, setSelectedPipe] = useState<Pipe | null>(null);@@ -197,7 +212,8 @@ const PipeStore: React.FC = () => {const [showInstalledOnly, setShowInstalledOnly] = useState(false);const { health } = useHealthCheck();const { getDataDir } = useSettings();- const { user } = useUser();+ const { user, refreshUser } = useUser();+ const [showCreditDialog, setShowCreditDialog] = useState(false);useEffect(() => {fetchInstalledPipes();@@ -325,6 +341,13 @@ const PipeStore: React.FC = () => {});await fetchInstalledPipes();++ const freshPipe = pipes.find(+ (p) => normalizeId(p.id) === normalizeId(url)+ );+ if (freshPipe) {+ setSelectedPipe(freshPipe);+ }} catch (error) {console.error("Failed to download pipe:", error);toast({@@ -367,18 +390,17 @@ const PipeStore: React.FC = () => {return;}- // NEW: Check if they already purchased+ // Check if user already purchased this pipeconst hasSubscription = await checkExistingSubscription(pipe.id);if (!hasSubscription) {const userCredits = user.credits?.amount || 0;-- // If not enough credits, redirect to buy moreif (userCredits < corePipe.credits) {- openUrl("https://buy.stripe.com/5kA6p79qefweacg5kJ");+ // Show the dialog instead of redirecting+ setShowCreditDialog(true);return;}- // If they have enough credits, try to purchase+ // If enough credits, proceed with purchaseconst purchaseSuccess = await handlePipePurchase(pipe,corePipe.credits@@ -437,7 +459,6 @@ const PipeStore: React.FC = () => {setSelectedPipe(freshPipe);}-toast({title: `pipe ${endpoint}d`,});@@ -598,7 +619,9 @@ const PipeStore: React.FC = () => {const allPipes = [...pipes,...corePipes- .filter((cp) => !pipes.some((p) => p.id === cp.id))+ .filter(+ (cp) => !pipes.some((p) => normalizeId(p.id) === normalizeId(cp.id))+ ).map((cp) => ({id: cp.id,fullDescription: cp.description,@@ -623,6 +646,17 @@ const PipeStore: React.FC = () => {return (<div className="fixed inset-0 bg-background transform transition-transform duration-200 ease-in-out flex flex-col">+ <CreditPurchaseDialog+ open={showCreditDialog}+ onOpenChange={setShowCreditDialog}+ requiredCredits={+ selectedPipe !== null+ ? corePipes.find((cp) => cp.id === selectedPipe.id)?.credits || 0+ : 0+ }+ currentCredits={user?.credits?.amount || 0}+ onCreditsUpdated={refreshUser}+ /><div className="flex items-center justify-between p-4 border-b bg-muted/30 flex-shrink-0"><div className="flex items-center gap-3"><Buttondiff --git a/screenpipe-app-tauri/components/settings/account-section.tsx b/screenpipe-app-tauri/components/settings/account-section.tsxindex 08df8a5d8..46aa52c73 100644--- a/screenpipe-app-tauri/components/settings/account-section.tsx+++ b/screenpipe-app-tauri/components/settings/account-section.tsx@@ -153,13 +153,20 @@ export function AccountSection() {<Badge variant="secondary" className="px-1.5 text-xs">monthly</Badge>- <span className="text-sm font-mono">15 credits/m, unlimited screenpipe cloud, priority support</span>+ <span className="text-sm font-mono">+ 15 credits/m, unlimited screenpipe cloud, priority+ support+ </span></div><Buttonsize="sm"variant="outline"onClick={() =>- openUrl("https://buy.stripe.com/5kA6p79qefweacg5kJ")+ openUrl(+ `https://buy.stripe.com/5kA6p79qefweacg5kJ?client_reference_id=${user?.id}&customer_email=${encodeURIComponent(+ user?.email ?? ""+ )}`+ )}>$30/mo@@ -181,7 +188,11 @@ export function AccountSection() {size="sm"variant="outline"onClick={() =>- openUrl("https://buy.stripe.com/eVaeVD45UbfYeswcNd")+ openUrl(+ `https://buy.stripe.com/eVaeVD45UbfYeswcNd?client_reference_id=${user?.id}&customer_email=${encodeURIComponent(+ user?.email ?? ""+ )}`+ )}>$50diff --git a/screenpipe-app-tauri/components/store/credit-purchase-dialog.tsx b/screenpipe-app-tauri/components/store/credit-purchase-dialog.tsxnew file mode 100644index 000000000..16d3e5c3b--- /dev/null+++ b/screenpipe-app-tauri/components/store/credit-purchase-dialog.tsx@@ -0,0 +1,124 @@+import React, { useState } from "react";+import {+ Dialog,+ DialogContent,+ DialogHeader,+ DialogTitle,+} from "@/components/ui/dialog";+import { Button } from "@/components/ui/button";+import { Badge } from "@/components/ui/badge";+import { open as openUrl } from "@tauri-apps/plugin-shell";+import { useUser } from "@/lib/hooks/use-user";+import { Loader2 } from "lucide-react";++interface CreditPurchaseDialogProps {+ open: boolean;+ onOpenChange: (open: boolean) => void;+ requiredCredits: number;+ currentCredits: number;+ onCreditsUpdated?: () => void;+}++export function CreditPurchaseDialog({+ open,+ onOpenChange,+ requiredCredits,+ currentCredits,+ onCreditsUpdated,+}: CreditPurchaseDialogProps) {+ const { refreshUser, user } = useUser();+ const [showRefreshHint, setShowRefreshHint] = useState(false);+ const [isLoading, setIsLoading] = useState(false);++ const handlePurchase = async (url: string) => {+ setIsLoading(true);+ await openUrl(url);+ setTimeout(async () => {+ await refreshUser();+ onCreditsUpdated?.();+ setShowRefreshHint(true);+ setIsLoading(false);+ }, 2000);+ };++ return (+ <Dialog open={open} onOpenChange={onOpenChange}>+ <DialogContent className="w-full max-w-[650px]">+ <DialogHeader>+ <DialogTitle>insufficient credits</DialogTitle>+ </DialogHeader>+ <div className="space-y-4">+ <p className="text-sm text-muted-foreground">+ you need {requiredCredits} credits but only have {currentCredits}+ </p>++ <div className="grid grid-cols-1 gap-3">+ <div className="rounded-lg border bg-card text-card-foreground shadow-sm">+ <div className="flex flex-col space-y-1.5 p-3">+ <div className="flex items-center justify-between">+ <div className="flex items-center gap-2">+ <Badge variant="secondary" className="px-1.5 text-xs">+ monthly+ </Badge>+ <span className="text-sm font-mono">+ 15 credits/m, unlimited screenpipe cloud, priority support+ </span>+ </div>+ <Button+ size="sm"+ variant="outline"+ onClick={() =>+ handlePurchase(+ `https://buy.stripe.com/5kA6p79qefweacg5kJ?client_reference_id=${user?.id}&customer_email=${encodeURIComponent(user?.email ?? '')}`+ )+ }+ disabled={isLoading}+ >+ {isLoading ? (+ <Loader2 className="h-4 w-4 animate-spin mr-2" />+ ) : null}+ $30/mo+ </Button>+ </div>+ </div>+ </div>++ <div className="rounded-lg border bg-card text-card-foreground shadow-sm">+ <div className="flex flex-col space-y-1.5 p-3">+ <div className="flex items-center justify-between">+ <div className="flex items-center gap-2">+ <Badge variant="secondary" className="px-1.5 text-xs">+ one-time+ </Badge>+ <span className="text-sm font-mono">50 credits</span>+ </div>+ <Button+ size="sm"+ variant="outline"+ onClick={() =>+ handlePurchase(+ `https://buy.stripe.com/eVaeVD45UbfYeswcNd?client_reference_id=${user?.id}&customer_email=${encodeURIComponent(user?.email ?? '')}`+ )+ }+ disabled={isLoading}+ >+ {isLoading ? (+ <Loader2 className="h-4 w-4 animate-spin mr-2" />+ ) : null}+ $50+ </Button>+ </div>+ </div>+ </div>+ </div>++ {showRefreshHint && (+ <p className="text-xs text-muted-foreground">+ if credits not updating, please refresh page+ </p>+ )}+ </div>+ </DialogContent>+ </Dialog>+ );+}diff --git a/screenpipe-app-tauri/lib/hooks/use-user.ts b/screenpipe-app-tauri/lib/hooks/use-user.tsindex f2535a004..fc0366d60 100644--- a/screenpipe-app-tauri/lib/hooks/use-user.ts+++ b/screenpipe-app-tauri/lib/hooks/use-user.ts@@ -49,7 +49,11 @@ export function useUser() {try {const userData = await verifyUserToken(token);// skip if user data did not change- if (userData.id === user?.id) return;+ if (+ userData.id === user?.id &&+ userData.credits?.amount === user?.credits?.amount+ )+ return;setUser(userData);await updateSettings({ user: userData });} catch (err) {@@ -60,6 +64,13 @@ export function useUser() {}};+ // explicit refresh function+ const refreshUser = async () => {+ if (settings.user?.token) {+ await loadUser(settings.user.token);+ }+ };+// load from settingsuseEffect(() => {if (settings.user?.token) {@@ -73,5 +84,6 @@ export function useUser() {isLoading,error,loadUser,+ refreshUser, // expose the refresh function};}