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

fix: 3 crash bugs from Sentry

Louis Beaumonteea0c8651226
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/store.rs b/apps/screenpipe-app-tauri/src-tauri/src/store.rs
index 7d6a5ea7d..a842526da 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/store.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/store.rs
@@ -522,7 +522,7 @@ impl Default for SettingsStore {
impl SettingsStore {
pub fn get(app: &AppHandle) -> Result<Option<Self>, String> {
- let store = get_store(app, None).unwrap();
+ let store = get_store(app, None).map_err(|e| format!("Failed to get store: {}", e))?;
match store.is_empty() {
true => Ok(None),
diff --git a/crates/screenpipe-accessibility/src/platform/macos.rs b/crates/screenpipe-accessibility/src/platform/macos.rs
index ee0b10795..394e42784 100644
--- a/crates/screenpipe-accessibility/src/platform/macos.rs
+++ b/crates/screenpipe-accessibility/src/platform/macos.rs
@@ -964,7 +964,12 @@ fn truncate(s: &str, max: usize) -> String {
if s.len() <= max {
s.to_string()
} else {
- format!("{}...", &s[..max - 3])
+ // Find a valid char boundary to avoid panicking on multi-byte UTF-8
+ let mut end = max - 3;
+ while end > 0 && !s.is_char_boundary(end) {
+ end -= 1;
+ }
+ format!("{}...", &s[..end])
}
}
diff --git a/crates/screenpipe-vision/src/browser_utils/windows.rs b/crates/screenpipe-vision/src/browser_utils/windows.rs
index a3cab0bf1..c2992a0ae 100644
--- a/crates/screenpipe-vision/src/browser_utils/windows.rs
+++ b/crates/screenpipe-vision/src/browser_utils/windows.rs
@@ -26,11 +26,13 @@ impl WindowsUrlDetector {
}
fn get_active_url_from_window(pid: i32) -> Result<Option<String>> {
- let automation = UIAutomation::new().unwrap();
- let root_ele = automation.get_root_element().unwrap();
+ let automation = UIAutomation::new()
+ .map_err(|e| anyhow!("Failed to create UIAutomation (COM thread mode conflict?): {}", e))?;
+ let root_ele = automation.get_root_element()
+ .map_err(|e| anyhow!("Failed to get root element: {}", e))?;
let condition = automation
.create_property_condition(ProcessId, Variant::from(pid as i32), None)
- .unwrap();
+ .map_err(|e| anyhow!("Failed to create property condition: {}", e))?;
match root_ele.find_first(TreeScope::Subtree, &condition) {
Ok(ele) => {
@@ -40,7 +42,7 @@ impl WindowsUrlDetector {
Variant::from(ControlType::Edit as i32),
None,
)
- .unwrap();
+ .map_err(|e| anyhow!("Failed to create control condition: {}", e))?;
if let Ok(address_bar) = ele.find_first(TreeScope::Subtree, &control_condition) {
debug!("address bar: {:?}", address_bar);