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

Feedback refactor (#1323)

neo7737e40cd0a7b88
diff --git a/screenpipe-app-tauri/components/header.tsx b/screenpipe-app-tauri/components/header.tsx
index 25fe01499..e327a8f3c 100644
--- a/screenpipe-app-tauri/components/header.tsx
+++ b/screenpipe-app-tauri/components/header.tsx
@@ -22,6 +22,8 @@ import {
Book,
User,
Settings2,
+ Upload,
+ Mail,
} from "lucide-react";
import { open } from "@tauri-apps/plugin-shell";
import {
@@ -35,6 +37,8 @@ import { listen } from "@tauri-apps/api/event";
import localforage from "localforage";
import { useChangelogDialog } from "@/lib/hooks/use-changelog-dialog";
import { useSettingsDialog } from "@/lib/hooks/use-settings-dialog";
+import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover";
+import { ShareLogsButton } from "./share-logs-button";
export default function Header() {
const [showInbox, setShowInbox] = useState(false);
@@ -42,9 +46,8 @@ export default function Header() {
useEffect(() => {
const loadMessages = async () => {
- const savedMessages = await localforage.getItem<Message[]>(
- "inboxMessages"
- );
+ const savedMessages =
+ await localforage.getItem<Message[]>("inboxMessages");
if (savedMessages) {
setMessages(savedMessages);
}
@@ -104,6 +107,7 @@ export default function Header() {
const { setShowOnboarding } = useOnboarding();
const { setShowChangelogDialog } = useChangelogDialog();
const { setIsOpen: setSettingsOpen } = useSettingsDialog();
+ const [isFeedbackOpen, setIsFeedbackOpen] = useState(false);
return (
<div>
@@ -113,6 +117,17 @@ export default function Header() {
</div>
</div>
<div className="flex space-x-4 absolute top-4 right-4">
+ <Popover open={isFeedbackOpen} onOpenChange={setIsFeedbackOpen}>
+ <PopoverTrigger asChild>
+ <Button variant="outline">
+ <Mail className="h-3.5 w-3.5 mr-2" />
+ feedback
+ </Button>
+ </PopoverTrigger>
+ <PopoverContent className="w-100 rounded-2xl" >
+ <ShareLogsButton showShareLink={false} onComplete={() => setIsFeedbackOpen(false)} />
+ </PopoverContent>
+ </Popover>
<HealthStatus className="mt-3 cursor-pointer" />
<Settings />
@@ -160,17 +175,6 @@ export default function Header() {
<Book className="mr-2 h-4 w-4" />
<span>check docs</span>
</DropdownMenuItem>
- <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={() =>
diff --git a/screenpipe-app-tauri/components/log-file-button.tsx b/screenpipe-app-tauri/components/log-file-button.tsx
index 57e64cf8f..e885204d5 100644
--- a/screenpipe-app-tauri/components/log-file-button.tsx
+++ b/screenpipe-app-tauri/components/log-file-button.tsx
@@ -30,6 +30,8 @@ import {
version as osVersion,
platform as osPlatform,
} from "@tauri-apps/plugin-os";
+import { ShareLogsButton } from './share-logs-button'
+import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover";
const LogContent = ({
content,
@@ -86,75 +88,6 @@ const LogContent = ({
};
LogContent.displayName = "LogContent";
-const ShareLogButton = ({
- onShare,
- isSending,
-}: {
- onShare: () => void;
- isSending: boolean;
-}) => {
- return (
- <Button
- variant="secondary"
- size="sm"
- onClick={onShare}
- disabled={isSending}
- className="gap-2 group relative"
- >
- {isSending ? (
- <>
- <Loader className="h-3.5 w-3.5 animate-spin" />
- <span>sharing...</span>
- </>
- ) : (
- <>
- <Upload className="h-3.5 w-3.5 transition-transform group-hover:-translate-y-0.5" />
- <span>share logs</span>
- </>
- )}
- </Button>
- );
-};
-
-const ShareLinkDisplay = ({
- shareLink,
- onCopy,
- onClose,
-}: {
- shareLink: string;
- onCopy: () => void;
- onClose: () => void;
-}) => {
- return (
- <div className="flex items-center gap-2 bg-secondary/30 px-3 py-2 rounded-lg border border-secondary animate-in fade-in slide-in-from-top-4">
- <div className="flex items-center gap-2 flex-1">
- <div className="h-2 w-2 bg-green-500 rounded-full animate-pulse" />
- <span className="text-sm font-mono">{shareLink}</span>
- </div>
- <div className="flex items-center gap-1.5">
- <Button
- variant="ghost"
- size="icon"
- className="h-7 w-7 hover:bg-secondary/50 transition-colors"
- onClick={onCopy}
- title="Copy share link"
- >
- <Copy className="h-3.5 w-3.5" />
- </Button>
- <Button
- variant="ghost"
- size="icon"
- className="h-7 w-7 hover:bg-secondary/50 transition-colors text-muted-foreground"
- onClick={onClose}
- title="Dismiss"
- >
- <X className="h-3.5 w-3.5" />
- </Button>
- </div>
- </div>
- );
-};
-
export const LogFileButton = ({
className,
isAppLog = false,
@@ -172,9 +105,6 @@ export const LogFileButton = ({
const [logPath, setLogPath] = useState("");
const [logContent, setLogContent] = useState("");
const [logFiles, setLogFiles] = useState<LogFile[]>([]);
- const [isSending, setIsSending] = useState(false);
- const [shareLink, setShareLink] = useState("");
- const [machineId, setMachineId] = useState("");
interface LogFile {
name: string;
@@ -223,98 +153,6 @@ export const LogFileButton = ({
setIsOpen(true);
};
- useEffect(() => {
- const loadMachineId = async () => {
- let id = localStorage.getItem("machineId");
- if (!id) {
- id = crypto.randomUUID();
- localStorage.setItem("machineId", id);
- }
- setMachineId(id);
- };
- loadMachineId();
- }, []);
-
- const sendLogs = async () => {
- if (!logFiles.length) return;
-
- setIsSending(true);
- try {
- const BASE_URL = "https://screenpi.pe";
- const identifier = settings.user?.id || machineId;
- const type = settings.user?.id ? "user" : "machine";
-
- // Get all log contents
- const logContents = await Promise.all(
- logFiles.map(async (file) => ({
- name: file.name,
- content: await readTextFile(file.path),
- }))
- );
-
- // Also get console logs from browser
- const consoleLog = localStorage.getItem("console_logs") || ""; // You'll need to implement console log capturing
-
- // Get signed URL
- const signedRes = await fetch(`${BASE_URL}/api/logs`, {
- method: "POST",
- headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ identifier, type }),
- });
-
- const {
- data: { signedUrl, path },
- } = await signedRes.json();
-
- // Combine all logs with clear separators
- const combinedLogs =
- logContents
- .map((log) => `\n=== ${log.name} ===\n${log.content}`)
- .join("\n\n") +
- "\n\n=== Browser Console Logs ===\n" +
- consoleLog;
-
- // Upload combined log content
- await fetch(signedUrl, {
- method: "PUT",
- body: combinedLogs,
- headers: { "Content-Type": "text/plain" },
- });
-
- const os = osPlatform();
- const os_version = osVersion();
- const app_version = await getVersion();
-
- // Confirm upload
- const confirmRes = await fetch(`${BASE_URL}/api/logs/confirm`, {
- method: "POST",
- headers: { "Content-Type": "application/json" },
- body: JSON.stringify({
- path,
- identifier,
- type,
- os,
- os_version,
- app_version,
- }),
- });
-
- const {
- data: { id },
- } = await confirmRes.json();
- setShareLink(`${BASE_URL}/logs/${id}`);
- } catch (err) {
- console.error("log sharing failed:", err);
- toast({
- title: "sharing failed",
- description: "could not upload logs",
- variant: "destructive",
- });
- } finally {
- setIsSending(false);
- }
- };
-
return (
<>
<TooltipProvider>
@@ -358,18 +196,19 @@ export const LogFileButton = ({
</DialogDescription>
</div>
<div className="flex mr-8">
- {!shareLink && (
- <ShareLogButton onShare={sendLogs} isSending={isSending} />
- )}
+ <Popover>
+ <PopoverTrigger asChild>
+ <Button>
+ <Upload className="h-3.5 w-3.5 mr-2" />
+ send logs
+ </Button>
+ </PopoverTrigger>
+ <PopoverContent className="w-100 rounded-2xl">
+ <ShareLogsButton />
+ </PopoverContent>
+ </Popover>
</div>
</div>
- {shareLink && (
- <ShareLinkDisplay
- shareLink={shareLink}
- onCopy={() => copyToClipboard(shareLink)}
- onClose={() => setShareLink("")}
- />
- )}
</DialogHeader>
{logFiles.length === 0 ? (
diff --git a/screenpipe-app-tauri/components/share-logs-button.tsx b/screenpipe-app-tauri/components/share-logs-button.tsx
new file mode 100644
index 000000000..f928ae253
--- /dev/null
+++ b/screenpipe-app-tauri/components/share-logs-button.tsx
@@ -0,0 +1,430 @@
+import { Button } from "./ui/button";
+import { useToast } from "./ui/use-toast";
+import { Upload, Loader, Copy, X, Camera, Video } from "lucide-react";
+import { readTextFile } from "@tauri-apps/plugin-fs";
+import { invoke } from "@tauri-apps/api/core";
+import { useState, useEffect } from "react";
+import { useCopyToClipboard } from "@/lib/hooks/use-copy-to-clipboard";
+import { useSettings } from "@/lib/hooks/use-settings";
+import { getVersion } from "@tauri-apps/api/app";
+import {
+ version as osVersion,
+ platform as osPlatform,
+} from "@tauri-apps/plugin-os";
+import { Textarea } from "./ui/textarea";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+ TooltipProvider,
+} from "./ui/tooltip";
+
+interface LogFile {
+ name: string;
+ path: string;
+ modified_at: number;
+}
+
+interface VideoChunk {
+ device_name: string;
+ file_path: string;
+ id: number;
+}
+
+const ShareLinkDisplay = ({
+ shareLink,
+ onCopy,
+ onClose,
+}: {
+ shareLink: string;
+ onCopy: () => void;
+ onClose: () => void;
+}) => {
+ return (
+ <div className="flex items-center gap-2 bg-secondary/30 px-3 py-2 rounded-lg border border-secondary animate-in fade-in slide-in-from-top-4">
+ <div className="flex items-center gap-2 flex-1">
+ <div className="h-2 w-2 bg-green-500 rounded-full animate-pulse" />
+ <span className="text-sm font-mono">{shareLink}</span>
+ </div>
+ <div className="flex items-center gap-1.5">
+ <Button
+ variant="ghost"
+ size="icon"
+ className="h-7 w-7 hover:bg-secondary/50 transition-colors"
+ onClick={onCopy}
+ title="Copy share link"
+ >
+ <Copy className="h-3.5 w-3.5" />
+ </Button>
+ <Button
+ variant="ghost"
+ size="icon"
+ className="h-7 w-7 hover:bg-secondary/50 transition-colors text-muted-foreground"
+ onClick={onClose}
+ title="Dismiss"
+ >
+ <X className="h-3.5 w-3.5" />
+ </Button>
+ </div>
+ </div>
+ );
+};
+
+export const ShareLogsButton = ({
+ showShareLink = true,
+ onComplete,
+}: {
+ showShareLink?: boolean;
+ onComplete?: () => void;
+}) => {
+ const { toast } = useToast();
+ const { copyToClipboard } = useCopyToClipboard({ timeout: 3000 });
+ const { settings } = useSettings();
+ const [isSending, setIsSending] = useState(false);
+ const [shareLink, setShareLink] = useState("");
+ const [machineId, setMachineId] = useState("");
+ const [feedbackText, setFeedbackText] = useState("");
+ const [isLoadingVideo, setIsLoadingVideo] = useState(false);
+ const [screenshot, setScreenshot] = useState<string | null>(null);
+ const [mergedVideoPath, setMergedVideoPath] = useState<string | null>(null);
+
+ useEffect(() => {
+ const loadMachineId = async () => {
+ let id = localStorage.getItem("machineId");
+ if (!id) {
+ id = crypto.randomUUID();
+ localStorage.setItem("machineId", id);
+ }
+ setMachineId(id);
+ };
+ loadMachineId();
+ }, []);
+
+ const getLogFiles = async () => {
+ try {
+ const logFiles = await invoke("get_log_files");
+ return logFiles as LogFile[];
+ } catch (error) {
+ console.error("failed to get log files:", error);
+ return [];
+ }
+ };
+
+ const captureLastFiveMinutes = async () => {
+ setIsLoadingVideo(true);
+ try {
+ // Fetch last video chunks
+ const response = await fetch("http://localhost:3030/raw_sql", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ query: `
+ SELECT * FROM video_chunks
+ ORDER BY id DESC
+ LIMIT 7
+ `,
+ }),
+ });
+
+ if (!response.ok) throw new Error("failed to fetch video chunks");
+ const chunks = (await response.json()) as VideoChunk[];
+
+ // Merge frames
+ const mergeResponse = await fetch(
+ "http://localhost:3030/experimental/frames/merge",
+ {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ video_paths: chunks.map((c) => c.file_path),
+ }),
+ }
+ );
+
+ if (!mergeResponse.ok) throw new Error("failed to merge video chunks");
+ const { video_path } = await mergeResponse.json();
+ setMergedVideoPath(video_path);
+ } catch (err) {
+ console.error("failed to capture video:", err);
+ toast({
+ title: "video capture failed",
+ description: "could not record last 5 minutes",
+ variant: "destructive",
+ });
+ } finally {
+ setIsLoadingVideo(false);
+ }
+ };
+
+ const handleScreenshotUpload = async (
+ e: React.ChangeEvent<HTMLInputElement>
+ ) => {
+ try {
+ const file = e.target.files?.[0];
+ if (!file) return;
+
+ // Convert to data URL for preview
+ const reader = new FileReader();
+ reader.onload = (e) => {
+ setScreenshot(e.target?.result as string);
+ };
+ reader.readAsDataURL(file);
+ } catch (err) {
+ console.error("Failed to select screenshot:", err);
+ }
+ };
+
+ const sendLogs = async () => {
+ const logFiles = await getLogFiles();
+ if (!logFiles.length) return;
+
+ setIsSending(true);
+ try {
+ const BASE_URL = 'https://screenpi.pe'
+ const identifier = settings.user?.id || machineId;
+ const type = settings.user?.id ? "user" : "machine";
+
+ // Get all log contents
+ const logContents = await Promise.all(
+ logFiles.map(async (file) => ({
+ name: file.name,
+ content: await readTextFile(file.path),
+ }))
+ );
+
+ const consoleLog = localStorage.getItem("console_logs") || "";
+
+ const signedRes = await fetch(`${BASE_URL}/api/logs`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ identifier,
+ type,
+ }),
+ });
+
+ const {
+ data: {
+ signedUrl,
+ path,
+ signedUrlScreenshot,
+ signedUrlVideo,
+ screenshotPath,
+ videoPath,
+ },
+ } = await signedRes.json();
+
+ const combinedLogs =
+ logContents
+ .map((log) => `\n=== ${log.name} ===\n${log.content}`)
+ .join("\n\n") +
+ "\n\n=== Browser Console Logs ===\n" +
+ consoleLog;
+
+ await fetch(signedUrl, {
+ method: "PUT",
+ body: combinedLogs,
+ headers: { "Content-Type": "text/plain" },
+ });
+
+ // Upload screenshot if exists
+ if (screenshot && signedUrlScreenshot) {
+ // Convert base64 to blob
+ const response = await fetch(screenshot);
+ const blob = await response.blob();
+
+ // Upload directly using fetch
+ await fetch(signedUrlScreenshot, {
+ method: "PUT",
+ body: blob,
+ headers: { "Content-Type": blob.type },
+ });
+ }
+
+ // Upload video if exists
+ if (mergedVideoPath && signedUrlVideo) {
+ console.log({
+ filePath: mergedVideoPath,
+ signedUrl: signedUrlVideo,
+ });
+
+ const videoUploaded = await invoke("upload_file_to_s3", {
+ filePath: mergedVideoPath,
+ signedUrl: signedUrlVideo,
+ });
+ if (!videoUploaded) throw new Error("Failed to upload video");
+ }
+
+ const os = osPlatform();
+ const os_version = osVersion();
+ const app_version = await getVersion();
+
+ const confirmRes = await fetch(`${BASE_URL}/api/logs/confirm`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ path,
+ identifier,
+ type,
+ os,
+ os_version,
+ app_version,
+ feedback_text: feedbackText,
+ screenshot_url: screenshotPath,
+ video_url: videoPath,
+ }),
+ });
+
+ const {
+ data: { id },
+ } = await confirmRes.json();
+ setShareLink(`${BASE_URL}/logs/${id}`);
+ } catch (err) {
+ console.error("log sharing failed:", err);
+ toast({
+ title: "sharing failed",
+ description: String(err),
+ variant: "destructive",
+ });
+ } finally {
+ if (!showShareLink) {
+ toast({
+ title: "feedback sent",
+ description: "thanks for your feedback!",
+ });
+ }
+ if (onComplete) onComplete();
+ setIsSending(false);
+ }
+ };
+ return (
+ <TooltipProvider>
+ <div className="flex flex-col gap-6 w-full max-w-2xl">
+ {!shareLink ? (
+ <>
+ <Textarea
+ placeholder="describe your feedback or issue..."
+ value={feedbackText}
+ onChange={(e) => setFeedbackText(e.target.value)}
+ className="min-h-[120px] resize-none rounded-xl bg-secondary/5 placeholder:text-muted-foreground/50 focus:border-secondary/30 focus:ring-0 transition-colors"
+ />
+
+ <div className="flex flex-wrap items-center gap-3">
+ <label className="cursor-pointer flex-none">
+ <input
+ type="file"
+ accept="image/*"
+ className="hidden"
+ onChange={handleScreenshotUpload}
+ disabled={!!screenshot}
+ />
+ <Button
+ variant={screenshot ? "secondary" : "outline"}
+ size="sm"
+ className={`gap-2 h-9 px-4 rounded-full transition-all ${
+ screenshot
+ ? "bg-emerald-500/10 text-emerald-500 border-emerald-500/30 hover:bg-emerald-500/20"
+ : ""
+ }`}
+ disabled={!!screenshot}
+ asChild
+ >
+ <span>
+ <Camera className="h-3.5 w-3.5" />
+ <span>screenshot</span>
+ </span>
+ </Button>
+ </label>
+
+ <Tooltip delayDuration={200}>
+ <TooltipTrigger asChild>
+ <Button
+ variant={mergedVideoPath ? "secondary" : "outline"}
+ size="sm"
+ onClick={captureLastFiveMinutes}
+ className={`gap-2 h-9 px-4 rounded-full transition-all ${
+ mergedVideoPath
+ ? "bg-emerald-500/10 text-emerald-500 border-emerald-500/30 hover:bg-emerald-500/20"
+ : ""
+ }`}
+ disabled={isLoadingVideo}
+ >
+ {isLoadingVideo ? (
+ <Loader className="h-3.5 w-3.5 animate-spin" />
+ ) : (
+ <Video className="h-3.5 w-3.5" />
+ )}
+ <span>recording</span>
+ <span className="ml-1 text-xs text-muted-foreground/70">
+ 5m
+ </span>
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent
+ side="bottom"
+ className="text-xs bg-secondary/80 backdrop-blur-sm border-secondary/30"
+ >
+ Attach last 5 minutes of screen recording
+ </TooltipContent>
+ </Tooltip>
+ </div>
+
+ {screenshot && (
+ <div className="relative w-48 aspect-video rounded-xl overflow-hidden bg-secondary/10 border border-secondary/20">
+ {/* eslint-disable-next-line @next/next/no-img-element */}
+ <img
+ src={screenshot}
+ alt="Screenshot preview"
+ className="object-cover w-full h-full"
+ />
+ <Button
+ variant="ghost"
+ size="icon"
+ className="absolute top-2 right-2 h-7 w-7 rounded-full bg-background/80 hover:bg-background/95 backdrop-blur-sm"
+ onClick={() => setScreenshot(null)}
+ >
+ <X className="h-3.5 w-3.5" />
+ </Button>
+ </div>
+ )}
+
+ <Button
+ variant="default"
+ size="sm"
+ onClick={sendLogs}
+ disabled={isSending || !feedbackText.trim()}
+ className="gap-2 group relative h-10 px-5 rounded-full"
+ >
+ {isSending ? (
+ <>
+ <Loader className="h-3.5 w-3.5 animate-spin" />
+ <span>sending feedback...</span>
+ </>
+ ) : (
+ <>
+ <Upload className="h-3.5 w-3.5 transition-transform group-hover:-translate-y-0.5" />
+ <span>send feedback</span>
+ </>
+ )}
+ </Button>
+ </>
+ ) : (
+ <>
+ {showShareLink && (
+ <ShareLinkDisplay
+ shareLink={shareLink}
+ onCopy={() => copyToClipboard(shareLink)}
+ onClose={() => {
+ setShareLink("");
+ setFeedbackText("");
+ setScreenshot(null);
+ setMergedVideoPath(null);
+ }}
+ />
+ )}
+ </>
+ )}
+ </div>
+ </TooltipProvider>
+ );
+};
diff --git a/screenpipe-app-tauri/src-tauri/src/main.rs b/screenpipe-app-tauri/src-tauri/src/main.rs
index efa8f7fdc..1e80024ba 100755
--- a/screenpipe-app-tauri/src-tauri/src/main.rs
+++ b/screenpipe-app-tauri/src-tauri/src/main.rs
@@ -446,6 +446,37 @@ fn get_data_dir(app: &tauri::AppHandle) -> anyhow::Result<PathBuf> {
}
}
+#[tauri::command]
+async fn upload_file_to_s3(file_path: &str, signed_url: &str) -> Result<bool, String> {
+ // Read file contents
+ let file_contents = match tokio::fs::read(file_path).await {
+ Ok(contents) => contents,
+ Err(e) => return Err(e.to_string())
+ };
+
+ // Create client and send PUT request
+ let client = reqwest::Client::new();
+ let response = match client
+ .put(signed_url)
+ .body(file_contents)
+ .send()
+ .await {
+ Ok(r) => r,
+ Err(e) => return Err(e.to_string())
+ };
+
+ if !response.status().is_success() {
+ return Err(format!(
+ "Failed to upload file: {}",
+ response.status()
+ ));
+ }
+
+ Ok(true)
+}
+
+
+
// Helper function to parse shortcut string
fn parse_shortcut(shortcut_str: &str) -> Result<Shortcut, String> {
let parts: Vec<&str> = shortcut_str.split('+').collect();
@@ -630,8 +661,9 @@ async fn main() {
commands::get_disk_usage,
commands::open_pipe_window,
get_log_files,
+ upload_file_to_s3,
update_global_shortcuts,
- get_env
+ get_env,
])
.setup(|app| {
//deep link register_all