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
chore: add check for shortuts to avoid crashing app and fallback to defualt
Louis Beaumontcf2b374a6525
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.tomlindex 874ba577f..332e23932 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.7.5"+version = "0.7.6"description = ""authors = ["you"]license = ""diff --git a/screenpipe-app-tauri/src-tauri/src/commands.rs b/screenpipe-app-tauri/src-tauri/src/commands.rsindex 5b76d10c4..4ba753c18 100644--- a/screenpipe-app-tauri/src-tauri/src/commands.rs+++ b/screenpipe-app-tauri/src-tauri/src/commands.rs@@ -112,7 +112,6 @@ pub fn show_main_window(app_handle: &tauri::AppHandle<tauri::Wry>, overlay: boollet _ = window.set_always_on_top(overlay);let _ = window.show();-if !overlay {let _ = window.set_focus();}@@ -127,6 +126,8 @@ pub fn show_main_window(app_handle: &tauri::AppHandle<tauri::Wry>, overlay: bool}}+const DEFAULT_SHORTCUT: &str = "Super+Alt+S";+#[tauri::command(rename_all = "snake_case")]pub fn update_show_screenpipe_shortcut(app_handle: tauri::AppHandle<tauri::Wry>,@@ -134,22 +135,53 @@ pub fn update_show_screenpipe_shortcut() -> Result<(), String> {use tauri_plugin_global_shortcut::{GlobalShortcutExt, Shortcut};- app_handle- .global_shortcut()- .unregister_all()- .map_err(|e| e.to_string())?;+ // Unregister all existing shortcuts+ if let Err(e) = app_handle.global_shortcut().unregister_all() {+ info!("failed to unregister shortcuts: {}", e);+ // Continue execution to try setting the default shortcut+ }- let show_window_shortcut = new_shortcut.parse::<Shortcut>().unwrap();+ // Try to parse the new shortcut, fall back to default if it fails+ let shortcut_str = match new_shortcut.parse::<Shortcut>() {+ Ok(s) => new_shortcut,+ Err(e) => {+ info!(+ "invalid shortcut '{}': {}, falling back to default",+ new_shortcut, e+ );+ DEFAULT_SHORTCUT.to_string()+ }+ };- app_handle- .global_shortcut()- .on_shortcut(- show_window_shortcut,- move |app_handle, _event, _shortcut| {- show_main_window(app_handle, true);- },- )- .map_err(|e| e.to_string())?;+ // Parse the shortcut string (will be either new_shortcut or default)+ let show_window_shortcut = match shortcut_str.parse::<Shortcut>() {+ Ok(s) => s,+ Err(e) => {+ return Err(format!("failed to parse shortcut: {}", e));+ }+ };++ // Register the new shortcut+ if let Err(e) = app_handle.global_shortcut().on_shortcut(+ show_window_shortcut,+ move |app_handle, _event, _shortcut| {+ show_main_window(app_handle, true);+ },+ ) {+ info!("failed to register shortcut: {}", e);++ // Try to register the default shortcut as fallback+ if let Ok(default_shortcut) = DEFAULT_SHORTCUT.parse::<Shortcut>() {+ let _ = app_handle.global_shortcut().on_shortcut(+ default_shortcut,+ move |app_handle, _event, _shortcut| {+ show_main_window(app_handle, true);+ },+ );+ }++ return Err("failed to set shortcut, reverted to default".to_string());+ }Ok(())}