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: windows settings SSE

tribhuwan1af520951b0a
diff --git a/screenpipe-app-tauri/src-tauri/src/main.rs b/screenpipe-app-tauri/src-tauri/src/main.rs
index b2bb4d19a..3f69763aa 100755
--- a/screenpipe-app-tauri/src-tauri/src/main.rs
+++ b/screenpipe-app-tauri/src-tauri/src/main.rs
@@ -368,7 +368,8 @@ async fn list_pipes() -> anyhow::Result<Value> {
Ok(response)
}
-fn get_base_dir(app: &tauri::AppHandle, custom_path: Option<String>) -> anyhow::Result<PathBuf> {
+
+pub fn get_base_dir(app: &tauri::AppHandle, custom_path: Option<String>) -> anyhow::Result<PathBuf> {
let default_path = app.path().local_data_dir().unwrap().join("screenpipe");
let local_data_dir = custom_path.map(PathBuf::from).unwrap_or(default_path);
diff --git a/screenpipe-app-tauri/src-tauri/src/server.rs b/screenpipe-app-tauri/src-tauri/src/server.rs
index 120d3f823..5ac818728 100644
--- a/screenpipe-app-tauri/src-tauri/src/server.rs
+++ b/screenpipe-app-tauri/src-tauri/src/server.rs
@@ -1,4 +1,4 @@
-use crate::{get_store, icons::AppIcon};
+use crate::{get_store, get_base_dir, icons::AppIcon};
use axum::response::sse::{Event, Sse};
use axum::{
extract::{Query, State},
@@ -91,7 +91,6 @@ struct WindowSizePayload {
height: f64,
}
-#[cfg(not(target_os = "windows"))]
async fn settings_stream(
State(state): State<ServerState>,
) -> Sse<impl Stream<Item = Result<Event, Infallible>>> {
@@ -114,46 +113,30 @@ async fn settings_stream(
)
}
-#[cfg(target_os = "windows")]
-async fn settings_stream(
- State(_): State<ServerState>,
-) -> (StatusCode, String) {
- (StatusCode::NOT_IMPLEMENTED, "SSE not supported on Windows".to_string())
-}
-
pub async fn run_server(app_handle: tauri::AppHandle, port: u16) {
let (settings_tx, _) = broadcast::channel(100);
-
- #[cfg(not(target_os = "windows"))]
let settings_tx_clone = settings_tx.clone();
-
let app_handle_clone = app_handle.clone();
-
- #[cfg(not(target_os = "windows"))]
- {
- let store_path = app_handle
- .path()
- .local_data_dir()
- .unwrap()
- .join("store.bin");
-
- let mut watcher = notify::recommended_watcher(move |res: notify::Result<notify::Event>| {
- if let Ok(event) = res {
- if event.kind.is_modify() {
- if let Ok(store) = get_store(&app_handle_clone, None) {
- if let Ok(settings) = serde_json::to_string(&store.entries()) {
- let _ = settings_tx_clone.send(settings);
- }
+ let base_dir =
+ get_base_dir(&app_handle, None).expect("Failed to ensure local data directory");
+ let store_path = base_dir.join("store.bin");
+
+ let mut watcher = notify::recommended_watcher(move |res: notify::Result<notify::Event>| {
+ if let Ok(event) = res {
+ if event.kind.is_modify() {
+ if let Ok(store) = get_store(&app_handle_clone, None) {
+ if let Ok(settings) = serde_json::to_string(&store.entries()) {
+ let _ = settings_tx_clone.send(settings);
}
}
}
- })
- .unwrap();
+ }
+ })
+ .unwrap();
- watcher
- .watch(&store_path, RecursiveMode::NonRecursive)
- .unwrap();
- }
+ watcher
+ .watch(&store_path, RecursiveMode::NonRecursive)
+ .unwrap();
let state = ServerState {
app_handle,