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

release-app

Louis Beaumont07f372b2c19b
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.lock b/screenpipe-app-tauri/src-tauri/Cargo.lock
index fbfbf4a6c..e7de40542 100755
--- a/screenpipe-app-tauri/src-tauri/Cargo.lock
+++ b/screenpipe-app-tauri/src-tauri/Cargo.lock
@@ -4966,7 +4966,7 @@ dependencies = [
[[package]]
name = "screenpipe-app"
-version = "0.22.5"
+version = "0.22.6"
dependencies = [
"anyhow",
"axum",
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.toml
index a401d0763..3cbe5106a 100644
--- a/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "screenpipe-app"
-version = "0.22.6"
+version = "0.22.7"
description = ""
authors = ["you"]
license = ""
@@ -78,6 +78,8 @@ dirs = "5.0.1"
url = "2.4.0"
tauri-plugin-deep-link = "2"
+once_cell = "1.20.0"
+
[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
tauri-plugin-cli = "2.0.0"
diff --git a/screenpipe-app-tauri/src-tauri/src/health.rs b/screenpipe-app-tauri/src-tauri/src/health.rs
new file mode 100644
index 000000000..9c289d4d1
--- /dev/null
+++ b/screenpipe-app-tauri/src-tauri/src/health.rs
@@ -0,0 +1,93 @@
+use anyhow::Result;
+use serde::Deserialize;
+use tokio::time::{interval, Duration};
+use tracing::info;
+
+#[derive(Debug, Deserialize)]
+#[allow(dead_code)]
+struct HealthCheckResponse {
+ status: String,
+ #[serde(rename = "last_frame_timestamp")]
+ last_frame_timestamp: Option<String>,
+ #[serde(rename = "last_audio_timestamp")]
+ last_audio_timestamp: Option<String>,
+ #[serde(rename = "last_ui_timestamp")]
+ last_ui_timestamp: Option<String>,
+ frame_status: String,
+ audio_status: String,
+ ui_status: String,
+ message: String,
+ #[serde(rename = "verbose_instructions")]
+ verbose_instructions: Option<String>,
+}
+
+pub async fn start_health_check(app: tauri::AppHandle) -> Result<()> {
+ let mut interval = interval(Duration::from_secs(1));
+ let client = reqwest::Client::new();
+ let mut last_status = String::new();
+
+ tokio::spawn(async move {
+ loop {
+ interval.tick().await;
+
+ match check_health(&client).await {
+ Ok(health) => {
+ let current_status = if health.status == "unhealthy" || health.status == "error"
+ {
+ "unhealthy"
+ } else {
+ "healthy"
+ };
+
+ if current_status != last_status {
+ last_status = current_status.to_string();
+ if let Some(main_tray) = app.tray_by_id("screenpipe_main") {
+ let icon_path = if current_status == "unhealthy" {
+ "icons/screenpipe-logo-tray-failed.png"
+ } else {
+ "icons/screenpipe-logo-tray-black.png"
+ };
+ let _ = main_tray
+ .set_icon(Some(tauri::image::Image::from_path(icon_path).unwrap()))
+ .and_then(|_| main_tray.set_icon_as_template(true));
+ }
+ }
+ }
+ Err(e) => {
+ if last_status != "error" {
+ println!("health check failed: {}", e);
+ last_status = "error".to_string();
+ if let Some(main_tray) = app.tray_by_id("screenpipe_main") {
+ let _ = main_tray
+ .set_icon(Some(
+ tauri::image::Image::from_path(
+ "icons/screenpipe-logo-tray-failed.png",
+ )
+ .unwrap(),
+ ))
+ .and_then(|_| main_tray.set_icon_as_template(true));
+ }
+ }
+ }
+ }
+ }
+ });
+
+ Ok(())
+}
+
+async fn check_health(client: &reqwest::Client) -> Result<HealthCheckResponse> {
+ let response = client
+ .get("http://localhost:3030/health")
+ .header("Cache-Control", "no-cache")
+ .header("Pragma", "no-cache")
+ .send()
+ .await?;
+
+ if !response.status().is_success() {
+ anyhow::bail!("health check failed with status: {}", response.status());
+ }
+
+ let health = response.json::<HealthCheckResponse>().await?;
+ Ok(health)
+}
diff --git a/screenpipe-app-tauri/src-tauri/src/main.rs b/screenpipe-app-tauri/src-tauri/src/main.rs
index e329dbbf5..580bf75dc 100755
--- a/screenpipe-app-tauri/src-tauri/src/main.rs
+++ b/screenpipe-app-tauri/src-tauri/src/main.rs
@@ -39,35 +39,35 @@ mod analytics;
mod icons;
use crate::analytics::start_analytics;
use crate::llm_sidecar::LLMSidecar;
-use crate::commands::open_pipe_window;
mod commands;
mod llm_sidecar;
mod permissions;
mod server;
mod sidecar;
+mod store;
mod tray;
mod updates;
-mod store;
pub use commands::reset_all_pipes;
pub use commands::set_tray_health_icon;
pub use commands::set_tray_unhealth_icon;
pub use server::spawn_server;
pub use sidecar::kill_all_sreenpipes;
pub use sidecar::spawn_screenpipe;
-pub use store::get_store;
pub use store::get_profiles_store;
+pub use store::get_store;
use crate::commands::hide_main_window;
pub use permissions::do_permissions_check;
pub use permissions::open_permission_settings;
pub use permissions::request_permission;
+use std::collections::HashMap;
use tauri::AppHandle;
use tauri_plugin_global_shortcut::GlobalShortcutExt;
use tauri_plugin_global_shortcut::{Code, Modifiers, Shortcut};
-use std::collections::HashMap;
-
+mod health;
+use health::start_health_check;
pub struct SidecarState(Arc<tokio::sync::Mutex<Option<SidecarManager>>>);
// New struct to hold shortcut configuration
@@ -91,16 +91,18 @@ impl ShortcutConfig {
.get("profiles")
.and_then(|v| serde_json::from_value::<Vec<String>>(v.clone()).ok())
.unwrap_or_default();
-
- profiles.into_iter()
+
+ profiles
+ .into_iter()
.filter_map(|profile| {
- profiles_store.get(&format!("shortcuts.{}", profile))
+ profiles_store
+ .get(&format!("shortcuts.{}", profile))
.and_then(|v| v.as_str().map(String::from))
.map(|shortcut| (profile, shortcut))
})
.collect()
- },
- Err(_) => HashMap::new()
+ }
+ Err(_) => HashMap::new(),
};
let pipe_shortcuts = store
@@ -108,9 +110,15 @@ impl ShortcutConfig {
.into_iter()
.filter_map(|key| {
if key.starts_with("pipeShortcuts.") {
- store.get(key.clone())
- .and_then(|v| v.as_str().map(String::from))
- .map(|v| (key.trim_start_matches("pipeShortcuts.").to_string(), v.to_string()))
+ store
+ .get(key.clone())
+ .and_then(|v| v.as_str().map(String::from))
+ .map(|v| {
+ (
+ key.trim_start_matches("pipeShortcuts.").to_string(),
+ v.to_string(),
+ )
+ })
} else {
None
}
@@ -266,10 +274,15 @@ async fn apply_shortcuts(app: &AppHandle, config: &ShortcutConfig) -> Result<(),
shortcut_id,
config.is_disabled(&shortcut_id)
);
- register_shortcut(app, shortcut, config.is_disabled(&shortcut_id), move |app| {
- info!("pipe shortcut triggered for pipe: {}", pipe_id);
- let _ = app.emit("open-pipe", pipe_id.clone());
- })
+ register_shortcut(
+ app,
+ shortcut,
+ config.is_disabled(&shortcut_id),
+ move |app| {
+ info!("pipe shortcut triggered for pipe: {}", pipe_id);
+ let _ = app.emit("open-pipe", pipe_id.clone());
+ },
+ )
.await?;
}
}
@@ -868,6 +881,14 @@ async fn main() {
let server_shutdown_tx = spawn_server(app.handle().clone(), 11435);
app.manage(server_shutdown_tx);
+ // Start health check service
+ let app_handle = app.handle().clone();
+ tauri::async_runtime::spawn(async move {
+ if let Err(e) = start_health_check(app_handle).await {
+ error!("Failed to start health check service: {}", e);
+ }
+ });
+
#[cfg(target_os = "macos")]
app.set_activation_policy(tauri::ActivationPolicy::Regular);
diff --git a/screenpipe-app-tauri/src-tauri/src/sidecar.rs b/screenpipe-app-tauri/src-tauri/src/sidecar.rs
index 9996f6dcc..c7d20ed03 100644
--- a/screenpipe-app-tauri/src-tauri/src/sidecar.rs
+++ b/screenpipe-app-tauri/src-tauri/src/sidecar.rs
@@ -1,5 +1,5 @@
-use crate::{get_base_dir, SidecarState};
use crate::get_store;
+use crate::SidecarState;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::sync::Arc;
@@ -10,7 +10,6 @@ use tauri::{Manager, State};
use tauri_plugin_shell::process::{CommandChild, CommandEvent};
use tauri_plugin_shell::ShellExt;
use tauri_plugin_store::Store;
-use tauri_plugin_store::StoreBuilder;
use tokio::sync::Mutex;
use tokio::time::sleep;
use tracing::{debug, error, info};
@@ -365,13 +364,8 @@ fn spawn_sidecar(app: &tauri::AppHandle) -> Result<CommandChild, String> {
// args.push("--debug");
-
-
if cfg!(windows) {
- let mut c = app
- .shell()
- .sidecar("screenpipe")
- .unwrap();
+ let mut c = app.shell().sidecar("screenpipe").unwrap();
if use_chinese_mirror {
c = c.env("HF_ENDPOINT", "https://hf-mirror.com");
}
diff --git a/screenpipe-app-tauri/src-tauri/src/tray.rs b/screenpipe-app-tauri/src-tauri/src/tray.rs
index ef29efa31..9feebaa9e 100644
--- a/screenpipe-app-tauri/src-tauri/src/tray.rs
+++ b/screenpipe-app-tauri/src-tauri/src/tray.rs
@@ -10,6 +10,9 @@ pub async fn update_tray_menu(
app: &AppHandle,
update_item: &tauri::menu::MenuItem<Wry>,
) -> Result<()> {
+ // Cache the current menu state to compare
+ let mut current_menu_state = String::new();
+
// Fetch enabled pipes from API
let client = reqwest::Client::new();
let response = client
@@ -19,6 +22,36 @@ pub async fn update_tray_menu(
.json::<Value>()
.await?;
+ // Create menu state string for comparison
+ if let Some(pipes) = response["data"].as_array() {
+ current_menu_state = pipes
+ .iter()
+ .filter(|p| p["enabled"].as_bool().unwrap_or(false))
+ .map(|p| p["id"].as_str().unwrap_or_default())
+ .collect::<Vec<_>>()
+ .join(",");
+ }
+
+ // Store last menu state in static/thread-safe way
+ use once_cell::sync::Lazy;
+ use std::sync::Mutex;
+ static LAST_MENU_STATE: Lazy<Mutex<String>> = Lazy::new(|| Mutex::new(String::new()));
+
+ // Only update if menu state changed
+ let should_update = {
+ let mut last_state = LAST_MENU_STATE.lock().unwrap();
+ if *last_state != current_menu_state {
+ *last_state = current_menu_state.clone();
+ true
+ } else {
+ false
+ }
+ };
+
+ if !should_update {
+ return Ok(());
+ }
+
// Create all owned menu items first
let mut menu_pipes = Vec::new();
diff --git a/screenpipe-server/src/auto_destruct.rs b/screenpipe-server/src/auto_destruct.rs
index 256b7f2f5..f2e55df8a 100644
--- a/screenpipe-server/src/auto_destruct.rs
+++ b/screenpipe-server/src/auto_destruct.rs
@@ -2,6 +2,7 @@ use std::process::Command;
use std::time::Duration;
use tokio::time::sleep;
+use tracing::info;
#[cfg(target_os = "windows")]
use windows::Win32::Foundation::{CloseHandle, HANDLE};
#[cfg(target_os = "windows")]
@@ -20,7 +21,7 @@ fn is_process_alive(pid: u32) -> bool {
}
pub async fn watch_pid(pid: u32) -> bool {
- println!("starting to watch for app termination (pid: {})", pid);
+ info!("starting to watch for app termination (pid: {})", pid);
loop {
#[cfg(target_os = "windows")]