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
louis030195798299f8e20f
diff --cc screenpipe-app-tauri/src-tauri/src/main.rsindex bead2ad1d,7e7e6934c..415ee3add--- a/screenpipe-app-tauri/src-tauri/src/main.rs+++ b/screenpipe-app-tauri/src-tauri/src/main.rs@@@ -54,9 -58,152 +58,153 @@@ use crate::commands::hide_main_windowpub use permissions::do_permissions_check;pub use permissions::open_permission_settings;pub use permissions::request_permission;++ use tauri::AppHandle;+ use tauri_plugin_deep_link::DeepLinkExt;+ use tauri_plugin_global_shortcut::GlobalShortcutExt;+ use tauri_plugin_global_shortcut::{Code, Modifiers, Shortcut};pub struct SidecarState(Arc<tokio::sync::Mutex<Option<SidecarManager>>>);+ // New struct to hold shortcut configuration+ #[derive(Debug, Default)]+ struct ShortcutConfig {+ show: String,+ start: String,+ stop: String,+ disabled: Vec<String>,+ }++ impl ShortcutConfig {+ async fn from_store(app: &AppHandle) -> Result<Self, String> {+ let base_dir = get_base_dir(app, None).map_err(|e| e.to_string())?;+ let path = base_dir.join("store.bin");+ let store = StoreBuilder::new(app, path)+ .build()+ .map_err(|e| e.to_string())?;++ Ok(Self {+ show: store+ .get("showScreenpipeShortcut")+ .and_then(|v| v.as_str().map(String::from))+ .unwrap_or_else(|| "Alt+Space".to_string()),+ start: store+ .get("startRecordingShortcut")+ .and_then(|v| v.as_str().map(String::from))+ .unwrap_or_else(|| "Alt+Shift+R".to_string()),+ stop: store+ .get("stopRecordingShortcut")+ .and_then(|v| v.as_str().map(String::from))+ .unwrap_or_else(|| "Alt+Shift+S".to_string()),+ disabled: store+ .get("disabledShortcuts")+ .and_then(|v| serde_json::from_value(v.clone()).ok())+ .unwrap_or_default(),+ })+ }++ fn is_disabled(&self, shortcut_type: &str) -> bool {+ self.disabled.contains(&shortcut_type.to_string())+ }+ }++ // Helper to register a single shortcut+ async fn register_shortcut(+ app: &AppHandle,+ shortcut_str: &str,+ is_disabled: bool,+ handler: impl Fn(&AppHandle) + Send + Sync + 'static,+ ) -> Result<(), String> {+ if shortcut_str.is_empty() || is_disabled {+ return Ok(());+ }++ let shortcut = parse_shortcut(shortcut_str)?;++ let global_shortcut = app.global_shortcut();++ global_shortcut+ .on_shortcut(shortcut, move |app, _shortcut, event| {+ // Only trigger on key press, not release+ if matches!(event.state, ShortcutState::Pressed) {+ handler(&app);+ }+ })+ .map_err(|e| e.to_string())+ }++ #[tauri::command]+ async fn update_global_shortcuts(+ app: AppHandle,+ show_shortcut: String,+ start_shortcut: String,+ stop_shortcut: String,+ ) -> Result<(), String> {+ let config = ShortcutConfig {+ show: show_shortcut,+ start: start_shortcut,+ stop: stop_shortcut,+ disabled: ShortcutConfig::from_store(&app).await?.disabled,+ };+ apply_shortcuts(&app, &config).await+ }++ async fn initialize_global_shortcuts(app: &AppHandle) -> Result<(), String> {+ let config = ShortcutConfig::from_store(app).await?;+ apply_shortcuts(app, &config).await+ }++ async fn apply_shortcuts(app: &AppHandle, config: &ShortcutConfig) -> Result<(), String> {+ let global_shortcut = app.global_shortcut();+ // Unregister all existing shortcuts first+ global_shortcut.unregister_all().unwrap();++ // Register show shortcut+ register_shortcut(app, &config.show, config.is_disabled("show"), |app| {+ info!("show shortcut triggered");+ if let Some(window) = app.get_webview_window("main") {+ match window.is_visible() {+ Ok(true) => {+ info!("window is visible, hiding main window");+ hide_main_window(app)+ }+ Ok(false) | Err(_) => {+ info!(+ "window is not visible or error checking visibility, showing main window"+ );+ show_main_window(app, false)+ }+ }+ } else {+ debug!("main window not found");+ }+ })+ .await?;++ // Register start shortcut+ register_shortcut(+ app,+ &config.start,+ config.is_disabled("start_recording"),+ |app| {+ let _ = app.emit("shortcut-start-recording", ());+ },+ )+ .await?;++ // Register stop shortcut+ register_shortcut(+ app,+ &config.stop,+ config.is_disabled("stop_recording"),+ |app| {+ let _ = app.emit("shortcut-stop-recording", ());+ },+ )+ .await?;++ Ok(())+ }+async fn get_pipe_port(pipe_id: &str) -> anyhow::Result<u16> {// Fetch pipe config from APIlet client = reqwest::Client::new();@@@ -494,6 -818,29 +819,32 @@@ async fn main()});}++<<<<<<< HEAD++=======+ #[cfg(any(target_os = "linux", all(debug_assertions, windows)))]+ app.deep_link().register_all()?;++ app.deep_link().on_open_url(move |event| {+ let urls: Vec<_> = event.urls().into_iter().collect();+ info!("deep link URLs: {:?}", urls);+ });+ // Register URL scheme on Windows/Linux+ #[cfg(any(windows, target_os = "linux"))]+ {+ if let Err(err) = app.handle().deep_link().register("screenpipe") {+ error!("Failed to register deep link protocol: {}", err);+ }+ }++ // Initialize global shortcuts+ let app_handle = app.handle().clone();+ tauri::async_runtime::spawn(async move {+ if let Err(e) = initialize_global_shortcuts(&app_handle).await {+ error!("Failed to initialize global shortcuts: {}", e);+ }+ });+++>>>>>>> 7da94cbf3cd799baef60e49976f63cf5a5a91b47Ok(())}).build(tauri::generate_context!())