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
feat: improve log button share to also share browser logs (eg client side app)
Louis Beaumont98695fb4d258
diff --git a/screenpipe-app-tauri/app/layout.tsx b/screenpipe-app-tauri/app/layout.tsxindex 1927054b0..1dab4e9c7 100644--- a/screenpipe-app-tauri/app/layout.tsx+++ b/screenpipe-app-tauri/app/layout.tsx@@ -3,14 +3,63 @@ import { Inter } from "next/font/google";import "./globals.css";import { Providers } from "./providers";import { Toaster } from "@/components/ui/toaster";+import { useEffect } from "react";const inter = Inter({ subsets: ["latin"] });+// Debounced localStorage writer+const createDebouncer = (wait: number) => {+ let timeout: NodeJS.Timeout;+ return (fn: Function) => {+ clearTimeout(timeout);+ timeout = setTimeout(() => fn(), wait);+ };+};+export default function RootLayout({children,}: {children: React.ReactNode;}) {+ useEffect(() => {+ if (typeof window === "undefined") return;++ const logs: string[] = [];+ const MAX_LOGS = 1000;+ const originalConsole = { ...console };+ const debouncedWrite = createDebouncer(1000);++ ["log", "error", "warn", "info"].forEach((level) => {+ (console[level as keyof Console] as any) = (...args: any[]) => {+ // Call original first for performance+ (originalConsole[level as keyof Console] as Function)(...args);++ // Add to memory buffer+ logs.push(+ `[${level.toUpperCase()}] ${args+ .map((arg) => (typeof arg === "object" ? JSON.stringify(arg) : arg))+ .join(" ")}`+ );++ // Trim buffer if needed+ if (logs.length > MAX_LOGS) {+ logs.splice(0, logs.length - MAX_LOGS);+ }++ // Debounced write to localStorage+ debouncedWrite(() => {+ try {+ localStorage.setItem("console_logs", logs.join("\n"));+ } catch (e) {+ // If localStorage is full, clear half the logs+ logs.splice(0, logs.length / 2);+ localStorage.setItem("console_logs", logs.join("\n"));+ }+ });+ };+ });+ }, []);+return (<html lang="en" suppressHydrationWarning><Providers>diff --git a/screenpipe-app-tauri/components/log-file-button.tsx b/screenpipe-app-tauri/components/log-file-button.tsxindex 84a1bee56..520316f4f 100644--- a/screenpipe-app-tauri/components/log-file-button.tsx+++ b/screenpipe-app-tauri/components/log-file-button.tsx@@ -236,17 +236,25 @@ export const LogFileButton = ({}, []);const sendLogs = async () => {- if (!logContent) return;+ if (!logFiles.length) return;setIsSending(true);try {- // const BASE_URL =- // (await invoke("get_env", { name: "BASE_URL_PRIVATE" })) ??- // "https://screenpi.pe";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 URLconst signedRes = await fetch(`${BASE_URL}/api/logs`, {method: "POST",@@ -258,16 +266,24 @@ export const LogFileButton = ({data: { signedUrl, path },} = await signedRes.json();- // Upload log content+ // 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 contentawait fetch(signedUrl, {method: "PUT",- body: logContent,+ body: combinedLogs,headers: { "Content-Type": "text/plain" },});const os = osPlatform();const os_version = osVersion();- const app_version = await getVersion();+ const app_version = getVersion();// Confirm uploadconst confirmRes = await fetch(`${BASE_URL}/api/logs/confirm`, {