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: send desktop notifications through pipes
Louis Beaumont82ad9fb40a31
diff --git a/examples/apps/screenpipe-app-tauri/components/notification-handler.tsx b/examples/apps/screenpipe-app-tauri/components/notification-handler.tsxindex cc6f075be..9e54f82d2 100644--- a/examples/apps/screenpipe-app-tauri/components/notification-handler.tsx+++ b/examples/apps/screenpipe-app-tauri/components/notification-handler.tsx@@ -6,6 +6,13 @@ import {sendNotification,} from "@tauri-apps/plugin-notification";+import { listen } from "@tauri-apps/api/event";++type NotificationRequested = {+ title: string;+ body: string;+};+const NotificationHandler: React.FC = () => {useEffect(() => {const checkAndRequestPermission = async () => {@@ -34,6 +41,16 @@ const NotificationHandler: React.FC = () => {localStorage.setItem("lastNotificationTime", currentTime.toString());}}++ listen<NotificationRequested>("notification-requested", (event) => {+ console.log(+ `notification requested ${event.payload.title} ${event.payload.body}`+ );+ sendNotification({+ title: event.payload.title,+ body: event.payload.body,+ });+ });};checkAndRequestPermission();diff --git a/examples/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/examples/apps/screenpipe-app-tauri/src-tauri/Cargo.tomlindex d1113ef12..247b698b3 100644--- a/examples/apps/screenpipe-app-tauri/src-tauri/Cargo.toml+++ b/examples/apps/screenpipe-app-tauri/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "screenpipe-app"-version = "0.1.84"+version = "0.1.85"description = ""authors = ["you"]license = ""@@ -55,6 +55,11 @@ sysinfo = "0.29.0"# hakcfix-path-env = { git = "https://github.com/tauri-apps/fix-path-env-rs" }+# server+axum = "0.6"+serde = "1.0.160"++tauri-plugin-fs = "2.0.0-beta"tauri-plugin-notification = "2.0.0-alpha.3"tauri-plugin-updater = "2.0.0-alpha.2"diff --git a/examples/apps/screenpipe-app-tauri/src-tauri/capabilities/main.json b/examples/apps/screenpipe-app-tauri/src-tauri/capabilities/main.jsonindex 2d2edfc52..8f72529fb 100644--- a/examples/apps/screenpipe-app-tauri/src-tauri/capabilities/main.json+++ b/examples/apps/screenpipe-app-tauri/src-tauri/capabilities/main.json@@ -6,6 +6,8 @@"main"],"permissions": [+ "core:event:allow-listen",+ "core:event:default","process:allow-restart","process:allow-exit","notification:default",diff --git a/examples/apps/screenpipe-app-tauri/src-tauri/gen/schemas/capabilities.json b/examples/apps/screenpipe-app-tauri/src-tauri/gen/schemas/capabilities.jsonindex 4904c3cf3..e0e65c78b 100644--- a/examples/apps/screenpipe-app-tauri/src-tauri/gen/schemas/capabilities.json+++ b/examples/apps/screenpipe-app-tauri/src-tauri/gen/schemas/capabilities.json@@ -1 +1 @@-{"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["process:allow-restart","process:allow-exit","notification:default","core:resources:default","core:menu:default","core:tray:default","shell:default","store:allow-get","store:allow-set","store:allow-save","store:allow-load","shell:allow-open","fs:allow-watch","fs:default","fs:allow-read-file","fs:allow-read-dir","fs:allow-read","fs:allow-write-file","fs:read-dirs","fs:allow-copy-file","fs:allow-exists","fs:allow-read-text-file","fs:allow-create","fs:allow-mkdir",{"identifier":"fs:scope","allow":[{"path":"$XDG_DATA_HOME","requireLiteralLeadingDot":false},{"path":"$XDG_DATA_HOME/**","requireLiteralLeadingDot":false},{"path":"$LOCALAPPDATA/*","requireLiteralLeadingDot":false},{"path":"$LOCALAPPDATA/**","requireLiteralLeadingDot":false},{"path":"$APPLOCALDATA/*","requireLiteralLeadingDot":false},{"path":"$APPLOCALDATA/**","requireLiteralLeadingDot":false},{"path":"$APPDATA/*","requireLiteralLeadingDot":false},{"path":"$APPDATA/**","requireLiteralLeadingDot":false},{"path":"$APPCONFIG/*","requireLiteralLeadingDot":false},{"path":"$RESOURCE/*","requireLiteralLeadingDot":false},{"path":"$RESOURCE/.screenpipe/*","requireLiteralLeadingDot":false},{"path":"$HOME/*","requireLiteralLeadingDot":false},{"path":"$HOME/.screenpipe/*","requireLiteralLeadingDot":false},{"path":"$APP/*","requireLiteralLeadingDot":false},{"path":"$HOME/.screenpipe/data/**","requireLiteralLeadingDot":false}]},{"identifier":"shell:allow-execute","allow":[{"args":["-c",{"validator":"\\S+"}],"cmd":"sh","name":"exec-sh","sidecar":false}]},"cli:default","shell:default","dialog:default","updater:default","os:default","os:allow-arch","os:allow-hostname","os:allow-os-type","core:path:default","process:default"]}}\ No newline at end of file+{"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["core:event:allow-listen","core:event:default","process:allow-restart","process:allow-exit","notification:default","core:resources:default","core:menu:default","core:tray:default","shell:default","store:allow-get","store:allow-set","store:allow-save","store:allow-load","shell:allow-open","fs:allow-watch","fs:default","fs:allow-read-file","fs:allow-read-dir","fs:allow-read","fs:allow-write-file","fs:read-dirs","fs:allow-copy-file","fs:allow-exists","fs:allow-read-text-file","fs:allow-create","fs:allow-mkdir",{"identifier":"fs:scope","allow":[{"path":"$XDG_DATA_HOME","requireLiteralLeadingDot":false},{"path":"$XDG_DATA_HOME/**","requireLiteralLeadingDot":false},{"path":"$LOCALAPPDATA/*","requireLiteralLeadingDot":false},{"path":"$LOCALAPPDATA/**","requireLiteralLeadingDot":false},{"path":"$APPLOCALDATA/*","requireLiteralLeadingDot":false},{"path":"$APPLOCALDATA/**","requireLiteralLeadingDot":false},{"path":"$APPDATA/*","requireLiteralLeadingDot":false},{"path":"$APPDATA/**","requireLiteralLeadingDot":false},{"path":"$APPCONFIG/*","requireLiteralLeadingDot":false},{"path":"$RESOURCE/*","requireLiteralLeadingDot":false},{"path":"$RESOURCE/.screenpipe/*","requireLiteralLeadingDot":false},{"path":"$HOME/*","requireLiteralLeadingDot":false},{"path":"$HOME/.screenpipe/*","requireLiteralLeadingDot":false},{"path":"$APP/*","requireLiteralLeadingDot":false},{"path":"$HOME/.screenpipe/data/**","requireLiteralLeadingDot":false}]},{"identifier":"shell:allow-execute","allow":[{"args":["-c",{"validator":"\\S+"}],"cmd":"sh","name":"exec-sh","sidecar":false}]},"cli:default","shell:default","dialog:default","updater:default","os:default","os:allow-arch","os:allow-hostname","os:allow-os-type","core:path:default","process:default"]}}\ No newline at end of filediff --git a/examples/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/examples/apps/screenpipe-app-tauri/src-tauri/src/main.rsindex 6def1507c..ef8fc6a48 100755--- a/examples/apps/screenpipe-app-tauri/src-tauri/src/main.rs+++ b/examples/apps/screenpipe-app-tauri/src-tauri/src/main.rs@@ -3,7 +3,7 @@use sidecar::SidecarManager;use tauri::Config;-+use tokio::sync::mpsc;use serde_json::Value;use std::env;use std::fs;@@ -16,6 +16,7 @@ use tauri::{menu::{MenuBuilder, MenuItemBuilder},tray::{MouseButton, MouseButtonState},};+use tauri_plugin_notification::NotificationExt;use tauri_plugin_autostart::MacosLauncher;use tauri_plugin_autostart::ManagerExt;#[allow(unused_imports)]@@ -33,10 +34,13 @@ use crate::analytics::start_analytics;mod commands;mod sidecar;+mod server;pub use commands::open_screen_capture_preferences;pub use commands::reset_screen_permissions;pub use sidecar::kill_all_sreenpipes;pub use sidecar::spawn_screenpipe;+pub use server::spawn_server;+pub struct SidecarState(Arc<tokio::sync::Mutex<Option<SidecarManager>>>);fn get_base_dir(app: &tauri::AppHandle, custom_path: Option<String>) -> anyhow::Result<PathBuf> {@@ -133,8 +137,6 @@ async fn main() {autostart_manager.is_enabled().unwrap());- let port = 3030;- app.manage(port);info!("Local data directory: {}", base_dir.display());@@ -258,6 +260,12 @@ async fn main() {debug!("Dev mode enabled, skipping sidecar spawn and restart");}+ // Inside the main function, after the `app.manage(port);` line, add:+ let server_shutdown_tx = spawn_server(app.handle().clone(), 11435);+ app.manage(server_shutdown_tx);+++Ok(())}).build(tauri::generate_context!())@@ -293,6 +301,10 @@ async fn main() {}});}+ // Add this to shut down the server+ if let Some(server_shutdown_tx) = app_handle.try_state::<mpsc::Sender<()>>() {+ let _ = server_shutdown_tx.send(());+ }}_ => {}});diff --git a/examples/apps/screenpipe-app-tauri/src-tauri/src/server.rs b/examples/apps/screenpipe-app-tauri/src-tauri/src/server.rsnew file mode 100644index 000000000..df198ac2b--- /dev/null+++ b/examples/apps/screenpipe-app-tauri/src-tauri/src/server.rs@@ -0,0 +1,98 @@+use axum::{extract::State, http::StatusCode, routing::post, Json, Router};+use serde::{Deserialize, Serialize};+use std::net::SocketAddr;+use tauri::Emitter;+use tauri_plugin_notification::NotificationExt;+use tokio::sync::mpsc;+use tracing::{error, info};++#[derive(Clone)]+pub struct ServerState {+ app_handle: tauri::AppHandle,+}++#[derive(Serialize, Deserialize)]+struct NotificationPayload {+ title: String,+ body: String,+}++#[derive(Serialize)]+struct ApiResponse {+ success: bool,+ message: String,+}++pub async fn run_server(app_handle: tauri::AppHandle, port: u16) {+ let state = ServerState { app_handle };++ let app = Router::new()+ .route("/notify", post(send_notification))+ .with_state(state);++ let addr = SocketAddr::from(([127, 0, 0, 1], port));+ info!("Server listening on {}", addr);++ axum::Server::bind(&addr)+ .serve(app.into_make_service())+ .await+ .unwrap();+}++async fn send_notification(+ State(state): State<ServerState>,+ Json(payload): Json<NotificationPayload>,+) -> Result<Json<ApiResponse>, (StatusCode, String)> {+ match state.app_handle.emit("notification-requested", &payload) {+ Ok(e) => {+ info!("Notification sent: {:?}", e);+ Ok(Json(ApiResponse {+ success: true,+ message: "Notification sent successfully".to_string(),+ }))+ }+ Err(e) => {+ error!("Failed to send notification: {}", e);+ Err((+ StatusCode::INTERNAL_SERVER_ERROR,+ format!("Failed to send notification: {}", e),+ ))+ }+ }+}++pub fn spawn_server(app_handle: tauri::AppHandle, port: u16) -> mpsc::Sender<()> {+ let (tx, mut rx) = mpsc::channel(1);++ tokio::spawn(async move {+ tokio::select! {+ _ = run_server(app_handle, port) => {},+ _ = rx.recv() => {+ info!("Received shutdown signal for server");+ }+ }+ });++ tx+}++/*+++curl -X POST http://localhost:11435/notify \+ -H "Content-Type: application/json" \+ -d '{"title": "Test Notification", "body": "This is a test notification body"}'++ curl -X POST http://localhost:11435/notify \+ -H "Content-Type: application/json" \+ -d '{"title": "Special Characters: !@#$%^&*()", "body": "Testing with émojis 😀🎉"}'++ curl -X POST http://localhost:11435/notify \+ -H "Content-Type: application/json" \+ -d '{"title": "Long Notification", "body": "This is a much longer notification body to test how the system handles larger amounts of text. It might wrap or be truncated depending on the system'\''s limitations."}'++ curl -X POST http://localhost:11435/notify \+ -H "Content-Type: application/json" \+ -d '{"title": "Malformed JSON", "body": "This JSON is malformed}'++*/diff --git a/screenpipe-audio/src/stt.rs b/screenpipe-audio/src/stt.rsindex a28567d11..00eedf3b8 100644--- a/screenpipe-audio/src/stt.rs+++ b/screenpipe-audio/src/stt.rs@@ -538,7 +538,7 @@ pub fn stt(// Initialize VADdebug!("VAD: Initializing VAD");let mut vad = Vad::new();- vad.set_mode(VadMode::Quality); // Set mode to very aggressive+ vad.set_mode(VadMode::VeryAggressive); // Set mode to very aggressive// Filter out non-speech segmentsdebug!("VAD: Filtering out non-speech segments");