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
fix: app icons not showing on Windows timeline
Louis Beaumontfcae1349ea74
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/icons.rs b/apps/screenpipe-app-tauri/src-tauri/src/icons.rsindex c256c03fe..6d8aee9a9 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/icons.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/icons.rs@@ -244,12 +244,64 @@ async fn get_exe_from_potential_path(app_name: &str) -> Option<String> {const CREATE_NO_WINDOW: u32 = 0x08000000;let app_name = app_name.strip_suffix(".exe").unwrap_or(&app_name);- // Try direct path in Program Files first (fast, no PowerShell)+ let app_lower = app_name.to_lowercase();++ // Try %LOCALAPPDATA% first — Electron apps (Slack, Discord, etc.) install here+ if let Ok(local_app_data) = std::env::var("LOCALAPPDATA") {+ let local_dir = std::path::Path::new(&local_app_data);+ if let Ok(entries) = std::fs::read_dir(local_dir) {+ for entry in entries.flatten() {+ let folder_name = entry.file_name().to_string_lossy().to_lowercase();+ if folder_name.contains(&app_lower) || app_lower.contains(&folder_name) {+ let entry_path = entry.path();+ // Electron pattern: %LOCALAPPDATA%\<app>\app-*\<app>.exe+ if let Ok(sub_entries) = std::fs::read_dir(&entry_path) {+ for sub in sub_entries.flatten() {+ let sub_name = sub.file_name().to_string_lossy().to_lowercase();+ // Check versioned "app-X.Y.Z" subdirs (Electron/Squirrel)+ if sub_name.starts_with("app-") && sub.path().is_dir() {+ if let Ok(app_entries) = std::fs::read_dir(sub.path()) {+ for app_entry in app_entries.flatten() {+ let fname = app_entry.file_name().to_string_lossy().to_lowercase();+ if fname.ends_with(".exe") && fname.contains(&app_lower) {+ return Some(app_entry.path().to_string_lossy().to_string());+ }+ }+ }+ }+ // Direct exe in app folder+ if sub_name.ends_with(".exe") && sub_name.contains(&app_lower) {+ return Some(sub.path().to_string_lossy().to_string());+ }+ }+ }+ }+ }+ }+ // Also check %LOCALAPPDATA%\Programs (e.g. cursor, VS Code user installs)+ let programs_dir = local_dir.join("Programs");+ if let Ok(entries) = std::fs::read_dir(&programs_dir) {+ for entry in entries.flatten() {+ let folder_name = entry.file_name().to_string_lossy().to_lowercase();+ if folder_name.contains(&app_lower) || app_lower.contains(&folder_name) {+ if let Ok(sub_entries) = std::fs::read_dir(entry.path()) {+ for sub in sub_entries.flatten() {+ let fname = sub.file_name().to_string_lossy().to_lowercase();+ if fname.ends_with(".exe") && (fname.contains(&app_lower) || fname.contains("gui")) {+ return Some(sub.path().to_string_lossy().to_string());+ }+ }+ }+ }+ }+ }+ }++ // Try direct path in Program Files (fast, no PowerShell)let program_dirs = [r"C:\Program Files",r"C:\Program Files (x86)",];- let app_lower = app_name.to_lowercase();for dir in &program_dirs {let base = std::path::Path::new(dir);if let Ok(entries) = std::fs::read_dir(base) {diff --git a/apps/screenpipe-app-tauri/src-tauri/src/server.rs b/apps/screenpipe-app-tauri/src-tauri/src/server.rsindex 860eb07a5..e36a2e874 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/server.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/server.rs@@ -458,36 +458,33 @@ async fn get_app_icon_handler(Query(app_name): Query<AppIconQuery>,) -> impl IntoResponse {use once_cell::sync::Lazy;- use std::collections::HashSet;+ use std::collections::HashMap;use std::sync::Mutex;+ use std::time::Instant;- // Cache of app names we already know have no icon, to avoid repeated expensive lookups- static NOT_FOUND_CACHE: Lazy<Mutex<HashSet<String>>> =- Lazy::new(|| Mutex::new(HashSet::new()));+ // Cache of app names we already know have no icon, with expiry time.+ // Entries expire after 5 minutes so new installations are picked up.+ static NOT_FOUND_CACHE: Lazy<Mutex<HashMap<String, Instant>>> =+ Lazy::new(|| Mutex::new(HashMap::new()));- // 1x1 transparent PNG placeholder- static PLACEHOLDER_PNG: &[u8] = &[- 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48,- 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x06, 0x00, 0x00,- 0x00, 0x1F, 0x15, 0xC4, 0x89, 0x00, 0x00, 0x00, 0x0A, 0x49, 0x44, 0x41, 0x54, 0x78,- 0x9C, 0x62, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0xE5, 0x27, 0xDE, 0xFC, 0x00, 0x00,- 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82,- ];+ const NOT_FOUND_TTL: std::time::Duration = std::time::Duration::from_secs(300);info!("received app icon request: {:?}", app_name);// Check not-found cache first to skip expensive lookupslet cache_key = format!("{}:{}", app_name.name, app_name.path.as_deref().unwrap_or(""));if let Ok(cache) = NOT_FOUND_CACHE.lock() {- if cache.contains(&cache_key) {- let headers = [- (CONTENT_TYPE, HeaderValue::from_static("image/png")),- (- http::header::CACHE_CONTROL,- HeaderValue::from_static("public, max-age=604800"),- ),- ];- return (StatusCode::OK, headers, Bytes::from_static(PLACEHOLDER_PNG));+ if let Some(inserted_at) = cache.get(&cache_key) {+ if inserted_at.elapsed() < NOT_FOUND_TTL {+ let headers = [+ (CONTENT_TYPE, HeaderValue::from_static("image/png")),+ (+ http::header::CACHE_CONTROL,+ HeaderValue::from_static("public, max-age=60"),+ ),+ ];+ return (StatusCode::NOT_FOUND, headers, Bytes::new());+ }}}@@ -505,18 +502,22 @@ async fn get_app_icon_handler((StatusCode::OK, headers, Bytes::from(icon.data))}Ok(None) | Err(_) => {- // Cache the miss to avoid repeated expensive lookups+ // Cache the miss with timestamp for expiryif let Ok(mut cache) = NOT_FOUND_CACHE.lock() {- cache.insert(cache_key);+ cache.insert(cache_key, Instant::now());+ // Evict expired entries periodically+ if cache.len() > 100 {+ cache.retain(|_, t| t.elapsed() < NOT_FOUND_TTL);+ }}let headers = [(CONTENT_TYPE, HeaderValue::from_static("image/png")),(http::header::CACHE_CONTROL,- HeaderValue::from_static("public, max-age=604800"),+ HeaderValue::from_static("public, max-age=60"),),];- (StatusCode::OK, headers, Bytes::from_static(PLACEHOLDER_PNG))+ (StatusCode::NOT_FOUND, headers, Bytes::new())}}}@@ -527,10 +528,10 @@ async fn get_app_icon_handler((CONTENT_TYPE, HeaderValue::from_static("image/png")),(http::header::CACHE_CONTROL,- HeaderValue::from_static("public, max-age=604800"),+ HeaderValue::from_static("public, max-age=60"),),];- (StatusCode::OK, headers, Bytes::from_static(PLACEHOLDER_PNG))+ (StatusCode::NOT_FOUND, headers, Bytes::new())}}