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
release-app add endpoint to get settings
Louis Beaumont130174491bfb
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.tomlindex aeaae64bd..7a4e1ec52 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.26.6"+version = "0.26.7"description = ""authors = ["you"]license = ""diff --git a/screenpipe-app-tauri/src-tauri/src/server.rs b/screenpipe-app-tauri/src-tauri/src/server.rsindex b55bb1947..c66d1e4da 100644--- a/screenpipe-app-tauri/src-tauri/src/server.rs+++ b/screenpipe-app-tauri/src-tauri/src/server.rs@@ -15,6 +15,13 @@ use tower_http::cors::{Any, CorsLayer};use tower_http::trace::{DefaultMakeSpan, TraceLayer};use tracing::{error, info};use tauri::Manager;+use notify::{RecommendedWatcher, RecursiveMode, Watcher};+use tokio::sync::broadcast;+use axum::response::sse::{Event, Sse};+use futures::stream::Stream;+use std::pin::Pin;+use std::convert::Infallible;+#[derive(Clone, serde::Serialize, serde::Deserialize)]struct LogEntry {pipe_id: String,@@ -26,6 +33,7 @@ struct LogEntry {#[derive(Clone)]pub struct ServerState {app_handle: tauri::AppHandle,+ settings_tx: broadcast::Sender<String>,}#[derive(Serialize, Deserialize, Debug)]@@ -84,8 +92,51 @@ struct WindowSizePayload {height: f64,}+async fn settings_stream(+ State(state): State<ServerState>,+) -> Sse<impl Stream<Item = Result<Event, Infallible>>> {+ let mut rx = state.settings_tx.subscribe();++ let stream = async_stream::stream! {+ let store = get_store(&state.app_handle, None).unwrap();+ let settings = serde_json::to_string(&store.clone()).unwrap();+ yield Ok(Event::default().data(settings));++ while let Ok(settings) = rx.recv().await {+ yield Ok(Event::default().data(settings));+ }+ };++ Sse::new(stream).keep_alive(+ axum::response::sse::KeepAlive::new()+ .interval(std::time::Duration::from_secs(1))+ .text("keep-alive-text")+ )+}+pub async fn run_server(app_handle: tauri::AppHandle, port: u16) {- let state = ServerState { app_handle };+ let (settings_tx, _) = broadcast::channel(100);+ let settings_tx_clone = settings_tx.clone();++ let store_path = app_handle.path().app_config_dir().unwrap().join("store.bin");+ let mut watcher = notify::recommended_watcher(move |res| {+ if let Ok(event) = res {+ if event.kind.is_modify() {+ if let Ok(store) = get_store(&app_handle, None) {+ if let Ok(settings) = serde_json::to_string(&store) {+ let _ = settings_tx_clone.send(settings);+ }+ }+ }+ }+ }).unwrap();++ watcher.watch(&store_path, RecursiveMode::NonRecursive).unwrap();++ let state = ServerState {+ app_handle,+ settings_tx,+ };let cors = CorsLayer::new().allow_origin("*".parse::<HeaderValue>().unwrap())@@ -100,6 +151,7 @@ pub async fn run_server(app_handle: tauri::AppHandle, port: u16) {.route("/auth", axum::routing::post(handle_auth)).route("/app-icon", axum::routing::get(get_app_icon_handler)).route("/window-size", axum::routing::post(set_window_size))+ .route("/sse/settings", axum::routing::get(settings_stream)).layer(cors).layer(TraceLayer::new_for_http()diff --git a/screenpipe-js/browser-sdk/package.json b/screenpipe-js/browser-sdk/package.jsonindex 30a8cd2c1..9993926c9 100644--- a/screenpipe-js/browser-sdk/package.json+++ b/screenpipe-js/browser-sdk/package.json@@ -1,6 +1,6 @@{"name": "@screenpipe/browser",- "version": "0.1.21",+ "version": "0.1.22","type": "module","main": "./dist/index.cjs","module": "./dist/index.js",diff --git a/screenpipe-js/browser-sdk/src/index.ts b/screenpipe-js/browser-sdk/src/index.tsindex fa3c564eb..5eb3e396b 100644--- a/screenpipe-js/browser-sdk/src/index.ts+++ b/screenpipe-js/browser-sdk/src/index.ts@@ -74,14 +74,45 @@ class BrowserPipeImpl implements BrowserPipe {if (this.analyticsInitialized || !this.userId) return;try {- const settings = { analyticsEnabled: false }; // TODO: impl settings browser side somehow ...+ // Connect to settings SSE stream+ const settingsStream = new EventSource(+ "http://localhost:11435/sse/settings"+ );++ // Get initial settings+ const settings = await new Promise<{ analyticsEnabled: boolean }>(+ (resolve, reject) => {+ const timeout = setTimeout(() => {+ settingsStream.close();+ reject(new Error("settings stream timeout"));+ }, 5000);++ settingsStream.onmessage = (event) => {+ clearTimeout(timeout);+ settingsStream.close();+ resolve(JSON.parse(event.data));+ };++ settingsStream.onerror = (error) => {+ clearTimeout(timeout);+ settingsStream.close();+ reject(error);+ };+ }+ );+this.analyticsEnabled = settings.analyticsEnabled;- if (settings.analyticsEnabled) {- await identifyUser(this.userId, this.userProperties);- this.analyticsInitialized = true;- }} catch (error) {- console.error("failed to fetch settings:", error);+ console.error(+ "failed to fetch settings, defaulting to analytics enabled:",+ error+ );+ this.analyticsEnabled = false; // Default to false if fetch fails+ }++ if (this.analyticsEnabled) {+ await identifyUser(this.userId, this.userProperties);+ this.analyticsInitialized = true;}}diff --git a/screenpipe-js/create-pipe/index.ts b/screenpipe-js/create-pipe/index.tsindex 7ab77f1ba..59eb45890 100644--- a/screenpipe-js/create-pipe/index.ts+++ b/screenpipe-js/create-pipe/index.ts@@ -1,4 +1,7 @@#!/usr/bin/env node+// Add this at the very top to suppress the Buffer deprecation warning+process.removeAllListeners("warning");+import fs from "fs-extra";import path from "path";import { select, input } from "@inquirer/prompts";@@ -150,8 +153,12 @@ async function main() {console.log("\nto get started:");console.log(chalk.cyan(`cd ${directory}`));- console.log(chalk.cyan("bun install # or use: npm install, pnpm install, yarn"));- console.log(chalk.cyan("bun dev # or use: npm run dev, pnpm dev, yarn dev"));+ console.log(+ chalk.cyan("bun install # or use: npm install, pnpm install, yarn")+ );+ console.log(+ chalk.cyan("bun dev # or use: npm run dev, pnpm dev, yarn dev")+ );console.log("\nwhen you're ready, you can ship your pipe to the app by adding it to the pipe store using the UI and then send a PR to the main repo.\n"diff --git a/screenpipe-js/create-pipe/package.json b/screenpipe-js/create-pipe/package.jsonindex e493ea693..1f25b65b8 100644--- a/screenpipe-js/create-pipe/package.json+++ b/screenpipe-js/create-pipe/package.json@@ -1,6 +1,6 @@{"name": "@screenpipe/create-pipe",- "version": "0.0.10",+ "version": "0.0.11","description": "create a new screenpipe pipe with nextjs","type": "module","bin": {