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(chat): add drag and drop image support with animated UX

Louis Beaumont82f90ae485e1
diff --git a/screenpipe-app-tauri/components/global-chat.tsx b/screenpipe-app-tauri/components/global-chat.tsx
index 7c56735da..5a57b94b2 100644
--- a/screenpipe-app-tauri/components/global-chat.tsx
+++ b/screenpipe-app-tauri/components/global-chat.tsx
@@ -10,7 +10,7 @@ import { Button } from "@/components/ui/button";
import { CustomDialogContent } from "@/components/rewind/custom-dialog-content";
import { useSettings } from "@/lib/hooks/use-settings";
import { cn } from "@/lib/utils";
-import { Loader2, Send, Square, User, X, Settings, ExternalLink, Video, Plus } from "lucide-react";
+import { Loader2, Send, Square, User, X, Settings, ExternalLink, Video, Plus, Zap } from "lucide-react";
import { toast } from "@/components/ui/use-toast";
import { parseInt } from "lodash";
import { motion, AnimatePresence } from "framer-motion";
@@ -1926,6 +1926,18 @@ export function GlobalChat() {
>
{message.content}
</MemoizedReactMarkdown>
+ {/* Upgrade button for daily limit errors */}
+ {message.role === "assistant" &&
+ (message.content.includes("used all your free queries") ||
+ message.content.includes("requires an upgrade")) && (
+ <button
+ onClick={() => setShowUpgradeDialog(true)}
+ className="mt-3 inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-foreground text-background text-sm font-medium hover:opacity-90 transition-opacity"
+ >
+ <Zap className="h-4 w-4" />
+ upgrade now
+ </button>
+ )}
</div>
</motion.div>
))}
diff --git a/screenpipe-app-tauri/components/standalone-chat.tsx b/screenpipe-app-tauri/components/standalone-chat.tsx
index 9e322b6f3..61dd9d54e 100644
--- a/screenpipe-app-tauri/components/standalone-chat.tsx
+++ b/screenpipe-app-tauri/components/standalone-chat.tsx
@@ -7,7 +7,7 @@ import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { useSettings } from "@/lib/hooks/use-settings";
import { cn } from "@/lib/utils";
-import { Loader2, Send, Square, User, Settings, ExternalLink, X } from "lucide-react";
+import { Loader2, Send, Square, User, Settings, ExternalLink, X, ImageIcon } from "lucide-react";
import { toast } from "@/components/ui/use-toast";
import { motion, AnimatePresence } from "framer-motion";
import { PipeAIIcon, PipeAIIconLarge } from "@/components/pipe-ai-icon";
@@ -165,6 +165,66 @@ export function StandaloneChat() {
const [prefillContext, setPrefillContext] = useState<string | null>(null);
const [prefillFrameId, setPrefillFrameId] = useState<number | null>(null);
const [pastedImage, setPastedImage] = useState<string | null>(null); // Base64 data URL
+ const [isDragging, setIsDragging] = useState(false);
+ const dragCounterRef = useRef(0);
+
+ // Process an image file to base64
+ const processImageFile = useCallback((file: File) => {
+ if (!file.type.startsWith("image/")) return;
+ const reader = new FileReader();
+ reader.onload = (event) => {
+ const base64 = event.target?.result as string;
+ setPastedImage(base64);
+ };
+ reader.readAsDataURL(file);
+ }, []);
+
+ // Handle drag events for image drop
+ const handleDragEnter = useCallback((e: React.DragEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ dragCounterRef.current++;
+
+ // Check if dragging files that include images
+ const hasFiles = e.dataTransfer.types.includes("Files");
+ if (hasFiles) {
+ setIsDragging(true);
+ }
+ }, []);
+
+ const handleDragLeave = useCallback((e: React.DragEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ dragCounterRef.current--;
+
+ if (dragCounterRef.current === 0) {
+ setIsDragging(false);
+ }
+ }, []);
+
+ const handleDragOver = useCallback((e: React.DragEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ }, []);
+
+ const handleDrop = useCallback((e: React.DragEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ dragCounterRef.current = 0;
+ setIsDragging(false);
+
+ const files = e.dataTransfer.files;
+ if (files && files.length > 0) {
+ // Find first image file
+ for (let i = 0; i < files.length; i++) {
+ const file = files[i];
+ if (file.type.startsWith("image/")) {
+ processImageFile(file);
+ break;
+ }
+ }
+ }
+ }, [processImageFile]);
// Handle paste events to capture images
const handlePaste = useCallback((e: React.ClipboardEvent) => {
@@ -179,12 +239,7 @@ export function StandaloneChat() {
e.preventDefault();
const file = item.getAsFile();
if (file) {
- const reader = new FileReader();
- reader.onload = (event) => {
- const base64 = event.target?.result as string;
- setPastedImage(base64);
- };
- reader.readAsDataURL(file);
+ processImageFile(file);
}
return;
}
@@ -197,17 +252,12 @@ export function StandaloneChat() {
const file = files[i];
if (file.type.startsWith("image/")) {
e.preventDefault();
- const reader = new FileReader();
- reader.onload = (event) => {
- const base64 = event.target?.result as string;
- setPastedImage(base64);
- };
- reader.readAsDataURL(file);
+ processImageFile(file);
return;
}
}
}
- }, []);
+ }, [processImageFile]);
// Listen for chat-prefill events from search modal
useEffect(() => {
@@ -1201,7 +1251,54 @@ export function StandaloneChat() {
</div>
)}
- <form onSubmit={handleSubmit} className="p-3" onPaste={handlePaste}>
+ <form
+ onSubmit={handleSubmit}
+ className="p-3 relative"
+ onPaste={handlePaste}
+ onDragEnter={handleDragEnter}
+ onDragLeave={handleDragLeave}
+ onDragOver={handleDragOver}
+ onDrop={handleDrop}
+ >
+ {/* Drop zone overlay */}
+ <AnimatePresence>
+ {isDragging && (
+ <motion.div
+ initial={{ opacity: 0 }}
+ animate={{ opacity: 1 }}
+ exit={{ opacity: 0 }}
+ transition={{ duration: 0.15 }}
+ className="absolute inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm rounded-lg border-2 border-dashed border-primary m-1"
+ >
+ <motion.div
+ initial={{ scale: 0.9, opacity: 0 }}
+ animate={{ scale: 1, opacity: 1 }}
+ exit={{ scale: 0.9, opacity: 0 }}
+ transition={{ duration: 0.15, delay: 0.05 }}
+ className="flex flex-col items-center gap-3 p-6"
+ >
+ <motion.div
+ animate={{
+ y: [0, -8, 0],
+ }}
+ transition={{
+ duration: 1.5,
+ repeat: Infinity,
+ ease: "easeInOut",
+ }}
+ className="p-4 rounded-2xl bg-primary/10 border border-primary/20"
+ >
+ <ImageIcon className="w-8 h-8 text-primary" />
+ </motion.div>
+ <div className="text-center">
+ <p className="font-semibold text-foreground">Drop your image here</p>
+ <p className="text-xs text-muted-foreground mt-1">PNG, JPG, GIF, or WebP</p>
+ </div>
+ </motion.div>
+ </motion.div>
+ )}
+ </AnimatePresence>
+
<div className="flex gap-2">
<div className="relative flex-1">
<Input
diff --git a/screenpipe-app-tauri/components/upgrade-dialog.tsx b/screenpipe-app-tauri/components/upgrade-dialog.tsx
index 0404b1521..1be403443 100644
--- a/screenpipe-app-tauri/components/upgrade-dialog.tsx
+++ b/screenpipe-app-tauri/components/upgrade-dialog.tsx
@@ -7,9 +7,10 @@ import {
DialogDescription,
} 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 { useSettings } from "@/lib/hooks/use-settings";
-import { Sparkles, Zap, Clock } from "lucide-react";
+import { Sparkles, Zap, Clock, Star } from "lucide-react";
interface UpgradeDialogProps {
open: boolean;
@@ -27,8 +28,10 @@ export function UpgradeDialog({
const { settings } = useSettings();
const isLoggedIn = !!settings.user?.token;
- const handleSubscribe = async () => {
- const baseUrl = "https://buy.stripe.com/5kA6p79qefweacg5kJ";
+ const handleSubscribe = async (isAnnual: boolean) => {
+ const baseUrl = isAnnual
+ ? "https://buy.stripe.com/eVadRzfOCgAi5W0fZu"
+ : "https://buy.stripe.com/5kA6p79qefweacg5kJ";
const params = new URLSearchParams();
if (settings.user?.id) {
params.set("client_reference_id", settings.user.id);
@@ -61,15 +64,17 @@ export function UpgradeDialog({
return (
<Dialog open={open} onOpenChange={onOpenChange}>
- <DialogContent className="w-full max-w-[420px]">
+ <DialogContent className="w-full max-w-[480px]">
<DialogHeader>
- <DialogTitle className="flex items-center gap-2">
- <Sparkles className="h-5 w-5" />
- {reason === "daily_limit"
- ? "you've used all your free queries today"
- : "this model requires an upgrade"}
+ <DialogTitle className="flex items-center gap-2 text-lg">
+ <Sparkles className="h-5 w-5 shrink-0" />
+ <span>
+ {reason === "daily_limit"
+ ? "you've used all your free queries today"
+ : "this model requires an upgrade"}
+ </span>
</DialogTitle>
- <DialogDescription>
+ <DialogDescription className="text-sm">
{reason === "daily_limit"
? `your free queries reset ${formatResetTime()}, or upgrade for unlimited access`
: "upgrade to access smarter models like claude sonnet and gpt-4"}
@@ -77,27 +82,48 @@ export function UpgradeDialog({
</DialogHeader>
<div className="space-y-3 pt-2">
+ {/* Annual - Primary/Preferred Option */}
<Button
- className="w-full justify-start gap-3 h-auto py-3"
- onClick={handleSubscribe}
+ className="w-full justify-start gap-3 h-auto py-4 relative"
+ onClick={() => handleSubscribe(true)}
>
- <Zap className="h-5 w-5" />
- <div className="text-left">
- <div className="font-medium">subscribe for $30/mo</div>
+ <Star className="h-5 w-5 shrink-0" />
+ <div className="text-left flex-1 min-w-0">
+ <div className="font-medium flex items-center gap-2 flex-wrap">
+ <span>$200/year</span>
+ <Badge variant="secondary" className="text-[10px] px-1.5 py-0">
+ save 17%
+ </Badge>
+ </div>
<div className="text-xs opacity-80">
unlimited queries, all models, priority support
</div>
</div>
</Button>
+ {/* Monthly Option */}
+ <Button
+ variant="outline"
+ className="w-full justify-start gap-3 h-auto py-3"
+ onClick={() => handleSubscribe(false)}
+ >
+ <Zap className="h-5 w-5 shrink-0" />
+ <div className="text-left flex-1 min-w-0">
+ <div className="font-medium">$30/mo</div>
+ <div className="text-xs text-muted-foreground">
+ unlimited queries, all models, priority support
+ </div>
+ </div>
+ </Button>
+
{!isLoggedIn && reason === "daily_limit" && (
<Button
variant="outline"
className="w-full justify-start gap-3 h-auto py-3"
onClick={handleLogin}
>
- <Sparkles className="h-5 w-5" />
- <div className="text-left">
+ <Sparkles className="h-5 w-5 shrink-0" />
+ <div className="text-left flex-1 min-w-0">
<div className="font-medium">sign in for more</div>
<div className="text-xs text-muted-foreground">
get 50 queries/day + access to sonnet
@@ -111,8 +137,8 @@ export function UpgradeDialog({
className="w-full justify-start gap-3 h-auto py-3"
onClick={() => onOpenChange(false)}
>
- <Clock className="h-5 w-5" />
- <div className="text-left">
+ <Clock className="h-5 w-5 shrink-0" />
+ <div className="text-left flex-1 min-w-0">
<div className="font-medium">wait until {formatResetTime()}</div>
<div className="text-xs text-muted-foreground">
your free queries will reset automatically