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: implement status component
Louis Beaumont8a58a7c7ca10
diff --git a/examples/apps/screenpipe-app-tauri/app/layout.tsx b/examples/apps/screenpipe-app-tauri/app/layout.tsxindex 3314e4780..197bc8693 100644--- a/examples/apps/screenpipe-app-tauri/app/layout.tsx+++ b/examples/apps/screenpipe-app-tauri/app/layout.tsx@@ -1,6 +1,7 @@import type { Metadata } from "next";import { Inter } from "next/font/google";import "./globals.css";+import HealthStatus from "@/components/screenpipe-status";const inter = Inter({ subsets: ["latin"] });@@ -16,7 +17,9 @@ export default function RootLayout({}>) {return (<html lang="en">- <body className={inter.className}>{children}</body>+ <body className={inter.className}>+ {children}+ </body></html>);}diff --git a/examples/apps/screenpipe-app-tauri/app/page.tsx b/examples/apps/screenpipe-app-tauri/app/page.tsxindex fb9bc3aad..39c92758c 100644--- a/examples/apps/screenpipe-app-tauri/app/page.tsx+++ b/examples/apps/screenpipe-app-tauri/app/page.tsx@@ -18,8 +18,8 @@ function IconNewChat() {<pathd="M12.1464 1.14645C12.3417 0.951184 12.6583 0.951184 12.8535 1.14645L14.8535 3.14645C15.0488 3.34171 15.0488 3.65829 14.8535 3.85355L10.9109 7.79618C10.8349 7.87218 10.7471 7.93543 10.651 7.9835L6.72359 9.94721C6.53109 10.0435 6.29861 10.0057 6.14643 9.85355C5.99425 9.70137 5.95652 9.46889 6.05277 9.27639L8.01648 5.34897C8.06455 5.25283 8.1278 5.16507 8.2038 5.08907L12.1464 1.14645ZM12.5 2.20711L8.91091 5.79618L7.87266 7.87267L8.12731 8.12732L10.2038 7.08907L13.7929 3.5L12.5 2.20711ZM9.99998 2L8.99998 3H4.9C4.47171 3 4.18056 3.00039 3.95552 3.01877C3.73631 3.03668 3.62421 3.06915 3.54601 3.10899C3.35785 3.20487 3.20487 3.35785 3.10899 3.54601C3.06915 3.62421 3.03669 3.73631 3.01878 3.95552C3.00039 4.18056 3 4.47171 3 4.9V11.1C3 11.5283 3.00039 11.8194 3.01878 12.0445C3.03669 12.2637 3.06915 12.3758 3.10899 12.454C3.20487 12.6422 3.35785 12.7951 3.54601 12.891C3.62421 12.9309 3.73631 12.9633 3.95552 12.9812C4.18056 12.9996 4.47171 13 4.9 13H11.1C11.5283 13 11.8194 12.9996 12.0445 12.9812C12.2637 12.9633 12.3758 12.9309 12.454 12.891C12.6422 12.7951 12.7951 12.6422 12.891 12.454C12.9309 12.3758 12.9633 12.2637 12.9812 12.0445C12.9996 11.8194 13 11.5283 13 11.1V6.99998L14 5.99998V11.1V11.1207C14 11.5231 14 11.8553 13.9779 12.1259C13.9549 12.407 13.9057 12.6653 13.782 12.908C13.5903 13.2843 13.2843 13.5903 12.908 13.782C12.6653 13.9057 12.407 13.9549 12.1259 13.9779C11.8553 14 11.5231 14 11.1207 14H11.1H4.9H4.87934C4.47686 14 4.14468 14 3.87409 13.9779C3.59304 13.9549 3.33469 13.9057 3.09202 13.782C2.7157 13.5903 2.40973 13.2843 2.21799 12.908C2.09434 12.6653 2.04506 12.407 2.0221 12.1259C1.99999 11.8553 1.99999 11.5231 2 11.1207V11.1206V11.1V4.9V4.87935V4.87932V4.87931C1.99999 4.47685 1.99999 4.14468 2.0221 3.87409C2.04506 3.59304 2.09434 3.33469 2.21799 3.09202C2.40973 2.71569 2.7157 2.40973 3.09202 2.21799C3.33469 2.09434 3.59304 2.04506 3.87409 2.0221C4.14468 1.99999 4.47685 1.99999 4.87932 2H4.87935H4.9H9.99998Z"fill="currentColor"- fill-rule="evenodd"- clip-rule="evenodd"+ fillRule="evenodd"+ clipRule="evenodd"></path></svg>);@@ -72,6 +72,7 @@ function Header({ onKeyChange }: { onKeyChange: (key: string) => void }) {<div className="mt-4 flex space-x-4 absolute top-4 right-4">{" "}{/* Added margin-top for spacing */}+ <HealthStatus className="mt-3" /><Settings onKeyChange={onKeyChange} />{/* <LogViewer /> */}<PrettyLink href="https://github.com/louis030195/screen-pipe/tree/main/examples/ts">@@ -130,6 +131,7 @@ import { LogViewer } from "@/components/log-viewer";import { Skeleton } from "@/components/ui/skeleton";import { PrettyLink } from "@/components/pretty-link";+import HealthStatus from "@/components/screenpipe-status";export default function Home() {const [openAiKey, setOpenAiKey] = useState<string | null>(null);diff --git a/examples/apps/screenpipe-app-tauri/components/screenpipe-status.tsx b/examples/apps/screenpipe-app-tauri/components/screenpipe-status.tsxnew file mode 100644index 000000000..f93436a3b--- /dev/null+++ b/examples/apps/screenpipe-app-tauri/components/screenpipe-status.tsx@@ -0,0 +1,147 @@+"use client";+import React, { useState, useEffect } from "react";+import {+ Tooltip,+ TooltipContent,+ TooltipProvider,+ TooltipTrigger,+} from "@/components/ui/tooltip";+import { Button } from "@/components/ui/button";+import {+ Dialog,+ DialogContent,+ DialogHeader,+ DialogTitle,+ DialogTrigger,+} from "@/components/ui/dialog";+import { CodeBlock } from "@/components/ui/codeblock";++interface HealthCheckResponse {+ status: string;+ last_frame_timestamp: string | null;+ last_audio_timestamp: string | null;+ frame_status: string;+ audio_status: string;+ message: string;+ verbose_instructions: string | null;+}++const HealthStatus = ({ className }: { className?: string }) => {+ const [health, setHealth] = useState<HealthCheckResponse | null>(null);+ const [isBlinking, setIsBlinking] = useState(false);+ const [isDialogOpen, setIsDialogOpen] = useState(false);++ useEffect(() => {+ const fetchHealth = async () => {+ try {+ const response = await fetch("http://localhost:3030/health");+ const data: HealthCheckResponse = await response.json();+ if (health && data.status !== health.status) {+ setIsBlinking(true);+ setTimeout(() => setIsBlinking(false), 5000); // Blink for 5 seconds on status change+ }+ setHealth(data);+ } catch (error) {+ console.error("Failed to fetch health status:", error);+ }+ };++ fetchHealth();+ const interval = setInterval(fetchHealth, 1000); // Poll every 1 seconds++ return () => clearInterval(interval);+ }, []);++ if (!health) return null;++ const getStatusColor = (status: string) => {+ switch (status) {+ case "Healthy":+ return "bg-green-500";+ case "Loading":+ return "bg-yellow-500";+ case "Unhealthy":+ return "bg-red-500";+ default:+ return "bg-gray-500";+ }+ };++ const formatTimestamp = (timestamp: string | null) => {+ return timestamp ? new Date(timestamp).toLocaleString() : "N/A";+ };++ const blinkingClass =+ isBlinking || health.status === "Unhealthy" ? "animate-pulse" : "";++ const logCommands = `# Stream the log:+tail -f $HOME/.screenpipe/screenpipe.log++# Scroll the logs:+less $HOME/.screenpipe/screenpipe.log`;++ return (+ <>+ <style jsx>{`+ @keyframes pulse-custom {+ 0%,+ 100% {+ opacity: 1;+ }+ 50% {+ opacity: 0.5;+ }+ }+ .animate-pulse-custom {+ animation: pulse-custom 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;+ }+ `}</style>+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <div+ className={`w-4 h-4 rounded-full ${getStatusColor(+ health.status+ )} ${blinkingClass} animate-pulse-custom shadow-lg flex items-center justify-center text-white font-bold ${className}`}+ />+ </TooltipTrigger>+ <TooltipContent className="w-64 p-2">+ <h3 className="font-bold mb-2">{health.status}</h3>+ <p className="text-sm mb-2">{health.message}</p>+ <p className="text-xs mb-1">Frame: {health.frame_status}</p>+ <p className="text-xs mb-1">Audio: {health.audio_status}</p>+ <p className="text-xs mb-1">+ Last Frame: {formatTimestamp(health.last_frame_timestamp)}+ </p>+ <p className="text-xs mb-1">+ Last Audio: {formatTimestamp(health.last_audio_timestamp)}+ </p>+ {health.verbose_instructions && (+ <p className="text-xs mt-2 text-red-500">+ {health.verbose_instructions}+ </p>+ )}+ <Button+ variant="outline"+ size="sm"+ className="mt-2 w-full"+ onClick={() => setIsDialogOpen(true)}+ >+ View Log Commands+ </Button>+ </TooltipContent>+ </Tooltip>+ </TooltipProvider>+ <Dialog open={isDialogOpen} onOpenChange={setIsDialogOpen}>+ <DialogContent>+ <DialogHeader>+ <DialogTitle>Log Commands</DialogTitle>+ </DialogHeader>+ <CodeBlock language="bash" value={logCommands} />+ </DialogContent>+ </Dialog>+ </>+ );+};++export default HealthStatus;diff --git a/examples/apps/screenpipe-app-tauri/src-tauri/src/find_screenpipe.rs b/examples/apps/screenpipe-app-tauri/src-tauri/src/find_screenpipe.rsdeleted file mode 100644index ee85b7942..000000000--- a/examples/apps/screenpipe-app-tauri/src-tauri/src/find_screenpipe.rs+++ /dev/null@@ -1,98 +0,0 @@-use log::{debug, error};-use std::path::PathBuf;-use which::which;--#[cfg(windows)]-use std::os::windows::process::CommandExt;--#[cfg(not(windows))]-const EXECUTABLE_NAME: &str = "screenpipe";--#[cfg(windows)]-const EXECUTABLE_NAME: &str = "screenpipe.exe";--#[cfg(windows)]-const CREATE_NO_WINDOW: u32 = 0x08000000;--pub fn find_screenpipe_path() -> Option<PathBuf> {- debug!("Starting search for screenpipe executable");-- // Check if `ffmpeg` is in the PATH environment variable- if let Ok(path) = which(EXECUTABLE_NAME) {- debug!("Found screenpipe in PATH: {:?}", path);- return Some(path);- }- debug!("screenpipe not found in PATH");-- // Check in current working directory- if let Ok(cwd) = std::env::current_dir() {- debug!("Current working directory: {:?}", cwd);- let screenpipe_in_cwd = cwd.join(EXECUTABLE_NAME);- if screenpipe_in_cwd.is_file() && screenpipe_in_cwd.exists() {- debug!(- "Found screenpipe in current working directory: {:?}",- screenpipe_in_cwd- );- return Some(screenpipe_in_cwd);- }- debug!("screenpipe not found in current working directory");- }-- // Check in the same folder as the executable- if let Ok(exe_path) = std::env::current_exe() {- if let Some(exe_folder) = exe_path.parent() {- debug!("Executable folder: {:?}", exe_folder);- let screenpipe_in_exe_folder = exe_folder.join(EXECUTABLE_NAME);- if screenpipe_in_exe_folder.exists() {- debug!(- "Found screenpipe in executable folder: {:?}",- screenpipe_in_exe_folder- );- return Some(screenpipe_in_exe_folder);- }- debug!("screenpipe not found in executable folder");-- // Platform-specific checks- #[cfg(target_os = "macos")]- {- let resources_folder = exe_folder.join("../Resources");- debug!("Resources folder: {:?}", resources_folder);- let screenpipe_in_resources = resources_folder.join(EXECUTABLE_NAME);- if screenpipe_in_resources.exists() {- debug!(- "Found screenpipe in Resources folder: {:?}",- screenpipe_in_resources- );- return Some(screenpipe_in_resources);- }- debug!("screenpipe not found in Resources folder");- }-- #[cfg(target_os = "linux")]- {- let lib_folder = exe_folder.join("lib");- debug!("Lib folder: {:?}", lib_folder);- let screenpipe_in_lib = lib_folder.join(EXECUTABLE_NAME);- if screenpipe_in_lib.exists() {- debug!("Found screenpipe in lib folder: {:?}", screenpipe_in_lib);- return Some(screenpipe_in_lib);- }- debug!("screenpipe not found in lib folder");- }- }- }-- // check in $HOME/.local/bin- let home = dirs::home_dir().unwrap();- let screenpipe_in_home = PathBuf::from(home).join(".local/bin").join(EXECUTABLE_NAME);- if screenpipe_in_home.exists() {- debug!(- "Found screenpipe in $HOME/.local/bin: {:?}",- screenpipe_in_home- );- return Some(screenpipe_in_home);- }-- error!("screenpipe not found");- None // Return None if screenpipe is not found-}diff --git a/examples/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/examples/apps/screenpipe-app-tauri/src-tauri/src/main.rsindex 945912b4c..27bca0db8 100755--- a/examples/apps/screenpipe-app-tauri/src-tauri/src/main.rs+++ b/examples/apps/screenpipe-app-tauri/src-tauri/src/main.rs@@ -4,6 +4,7 @@use dirs::home_dir;use log::{debug, error, info, LevelFilter};use logs::MultiWriter;+use tauri_plugin_shell::ShellExt;use serde_json::Value;use std::fs::File;@@ -22,7 +23,6 @@ use tauri_plugin_autostart::ManagerExt;mod analytics;use crate::analytics::start_analytics;-mod find_screenpipe;mod logs;fn get_base_dir(custom_path: Option<String>) -> anyhow::Result<PathBuf> {@@ -144,6 +144,12 @@ async fn main() {.spawn().expect("Failed to spawn sidecar");+ // .args(if cfg!(target_os = "macos") { // ! hack?+ // vec!["--port", "3030", "--debug", "--data-dir", "/Applications/screenpipe.app/Contents/Resources"]+ // } else {+ // vec!["--port", "3030", "--debug"] // "--disable-audio"+ // })+tauri::async_runtime::spawn(async move {while let Some(event) = rx.recv().await {match event {@@ -189,113 +195,3 @@ async fn main() {_ => {}});}--use std::sync::Arc;-use tokio::io::{AsyncBufReadExt, BufReader};-use tokio::time::{interval, Duration};--async fn start_server() -> anyhow::Result<()> {- let restart_interval = Duration::from_secs(2 * 60); // Restart every 2 minutes ! HACK- let server_handle: Arc<tokio::sync::Mutex<Option<tokio::task::JoinHandle<()>>>> =- Arc::new(tokio::sync::Mutex::new(None));- let server_handle_clone = Arc::clone(&server_handle);-- // tokio::spawn(async move {- // let mut interval = interval(restart_interval);-- // loop {- // interval.tick().await;- // debug!("Restarting screenpipe sidecar...");-- // // Stop the current server- // if let Some(handle) = server_handle_clone.lock().await.take() {- // handle.abort();- // }-- // // Start a new server- // *server_handle_clone.lock().await = Some(start_screenpipe_server());- // }- // });-- // Initial server start- *server_handle.lock().await = Some(start_screenpipe_server());-- Ok(())-}-use tauri_plugin_shell::ShellExt;--fn start_screenpipe_server_new(app: tauri::AppHandle) -> tauri::Result<()> {- let sidecar = app.shell().sidecar("screenpipe").unwrap();- let (mut rx, _child) = sidecar- .args(vec!["--port", "3030", "--debug"])- // .args(if cfg!(target_os = "macos") { // ! hack?- // vec!["--port", "3030", "--debug", "--data-dir", "/Applications/screenpipe.app/Contents/Resources"]- // } else {- // vec!["--port", "3030", "--debug"] // "--disable-audio"- // })- .spawn()- .expect("Failed to spawn sidecar");-- tauri::async_runtime::spawn(async move {- while let Some(event) = rx.recv().await {- match event {- tauri_plugin_shell::process::CommandEvent::Stdout(line) => {- debug!("{:?}", line);- }- tauri_plugin_shell::process::CommandEvent::Stderr(line) => {- debug!("{:?}", line);- }- _ => {}- }- }- });-- Ok(())-}--fn start_screenpipe_server() -> tokio::task::JoinHandle<()> {- tokio::spawn(async move {- debug!("Starting screenpipe server");-- // Kill any existing process on port 3030- let _ = tokio::process::Command::new("pkill")- .arg("-f")- .arg("screenpipe")- .output()- .await;-- let mut cmd =- tokio::process::Command::new(find_screenpipe::find_screenpipe_path().unwrap());- cmd.arg("--port").arg("3030");- cmd.arg("--debug");- cmd.arg("--disable-audio");- cmd.stdout(std::process::Stdio::piped());- cmd.stderr(std::process::Stdio::piped());-- let mut child = cmd.spawn().expect("Failed to spawn command");-- let stdout = child.stdout.take().expect("Failed to capture stdout");- let stderr = child.stderr.take().expect("Failed to capture stderr");-- let mut stdout_reader = BufReader::new(stdout).lines();- let mut stderr_reader = BufReader::new(stderr).lines();-- tokio::spawn(async move {- while let Ok(Some(line)) = stdout_reader.next_line().await {- debug!("{}", line);- }- });-- tokio::spawn(async move {- while let Ok(Some(line)) = stderr_reader.next_line().await {- debug!("{}", line);- }- });-- let output = child- .wait_with_output()- .await- .expect("Failed to wait for child process");- debug!("Child process exited with output: {:?}", output);- })-}diff --git a/examples/apps/screenpipe-app-tauri/tailwind.config.ts b/examples/apps/screenpipe-app-tauri/tailwind.config.tsindex 3e48b4270..a7b2f0a07 100644--- a/examples/apps/screenpipe-app-tauri/tailwind.config.ts+++ b/examples/apps/screenpipe-app-tauri/tailwind.config.ts@@ -70,10 +70,15 @@ module.exports = {from: { height: "var(--radix-accordion-content-height)" },to: { height: "0" },},+ "pulse": {+ '0%, 100%': { opacity: 1 },+ '50%': { opacity: .5 },+ }},animation: {"accordion-down": "accordion-down 0.2s ease-out","accordion-up": "accordion-up 0.2s ease-out",+ "pulse": "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",},},},diff --git a/screenpipe-core/src/llm.rs b/screenpipe-core/src/llm.rsindex 95279a356..90e866304 100755--- a/screenpipe-core/src/llm.rs+++ b/screenpipe-core/src/llm.rs@@ -77,7 +77,6 @@ wherecandle_transformers::generation::LogitsProcessor::new(42, Some(temperature), None);let mut tokens = tokenizer.encode(prompt, true).map_err(anyhow::Error::msg)?;- let mut generated_tokens = 0;let eos_token = tokenizer.token_to_id("</s>");let bos_token = tokenizer.token_to_id("<s>");@@ -120,7 +119,6 @@ where.map_err(anyhow::Error::msg)?;callback(text)?;- generated_tokens += 1;}Ok(())