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
feat: add feature to always record all monitors
Louis Beaumonte3df9b71111c
diff --git a/screenpipe-app-tauri/components/recording-settings.tsx b/screenpipe-app-tauri/components/recording-settings.tsxindex cba0f11f0..0c7c30b6e 100644--- a/screenpipe-app-tauri/components/recording-settings.tsx+++ b/screenpipe-app-tauri/components/recording-settings.tsx@@ -202,10 +202,7 @@ export function RecordingSettings() {try {// Fetch monitorsconst monitorsResponse = await fetch(- "http://localhost:3030/vision/list",- {- method: "POST",- }+ "http://localhost:3030/vision/list");if (!monitorsResponse.ok) {throw new Error("Failed to fetch monitors");@@ -344,52 +341,6 @@ export function RecordingSettings() {}};- const handleAddIgnoredWindow = (value: string) => {- const lowerCaseValue = value.toLowerCase();- if (- value &&- !settings.ignoredWindows- .map((w) => w.toLowerCase())- .includes(lowerCaseValue)- ) {- handleSettingsChange({- ignoredWindows: [...settings.ignoredWindows, value],- includedWindows: settings.includedWindows.filter(- (w) => w.toLowerCase() !== lowerCaseValue- ),- });- }- };-- const handleRemoveIgnoredWindow = (value: string) => {- handleSettingsChange({- ignoredWindows: settings.ignoredWindows.filter((w) => w !== value),- });- };-- const handleAddIncludedWindow = (value: string) => {- const lowerCaseValue = value.toLowerCase();- if (- value &&- !settings.includedWindows- .map((w) => w.toLowerCase())- .includes(lowerCaseValue)- ) {- handleSettingsChange({- includedWindows: [...settings.includedWindows, value],- ignoredWindows: settings.ignoredWindows.filter(- (w) => w.toLowerCase() !== lowerCaseValue- ),- });- }- };-- const handleRemoveIncludedWindow = (value: string) => {- handleSettingsChange({- includedWindows: settings.includedWindows.filter((w) => w !== value),- });- };-const handleAudioTranscriptionModelChange = (value: string) => {if (value === "screenpipe-cloud" && !settings.user?.cloud_subscribed) {openUrl("https://buy.stripe.com/7sIdRzbym4RA98c7sX");@@ -786,6 +737,23 @@ export function RecordingSettings() {{!settings.disableVision && (<>+ <div className="flex items-center justify-between mb-4">+ <div className="space-y-1">+ <h4 className="font-medium">use all monitors</h4>+ <p className="text-sm text-muted-foreground">+ automatically detect and record all monitors, including+ newly connected ones+ </p>+ </div>+ <Switch+ id="useAllMonitors"+ checked={settings.useAllMonitors}+ onCheckedChange={(checked) =>+ handleSettingsChange({ useAllMonitors: checked })+ }+ />+ </div>+<div className="flex flex-col space-y-6"><div className="flex flex-col space-y-2"><Label@@ -796,22 +764,29 @@ export function RecordingSettings() {<span>monitors</span></Label><MultiSelect- options={- availableMonitors.map((monitor) => ({- value: monitor.id.toString(),- label: `${monitor.id}. ${monitor.name} - ${monitor.width}x${monitor.height} ${monitor.is_default ? "(default)" : ""}`,- }))- }+ options={availableMonitors.map((monitor) => ({+ value: monitor.id.toString(),+ label: `${monitor.id}. ${monitor.name} - ${+ monitor.width+ }x${monitor.height} ${+ monitor.is_default ? "(default)" : ""+ }`,+ }))}defaultValue={settings.monitorIds}onValueChange={(values) =>values.length === 0? handleSettingsChange({ disableVision: true }): handleSettingsChange({ monitorIds: values })}- placeholder="select monitors"+ placeholder={+ settings.useAllMonitors+ ? "all monitors will be used"+ : "select monitors"+ }variant="default"modalPopover={true}animation={2}+ disabled={settings.useAllMonitors}/></div>diff --git a/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/screenpipe-app-tauri/lib/hooks/use-settings.tsxindex bb9b31774..e37a8f4eb 100644--- a/screenpipe-app-tauri/lib/hooks/use-settings.tsx+++ b/screenpipe-app-tauri/lib/hooks/use-settings.tsx@@ -103,6 +103,7 @@ export type Settings = {enableRealtimeAudioTranscription: boolean;realtimeAudioTranscriptionEngine: string;disableVision: boolean;+ useAllMonitors: boolean;};const DEFAULT_SETTINGS: Settings = {@@ -161,6 +162,7 @@ const DEFAULT_SETTINGS: Settings = {enableRealtimeAudioTranscription: false,realtimeAudioTranscriptionEngine: "whisper-large-v3-turbo",disableVision: false,+ useAllMonitors: false,};const DEFAULT_IGNORED_WINDOWS_IN_ALL_OS = [diff --git a/screenpipe-app-tauri/src-tauri/Cargo.lock b/screenpipe-app-tauri/src-tauri/Cargo.lockindex f2aceeb79..56d18fba9 100755--- a/screenpipe-app-tauri/src-tauri/Cargo.lock+++ b/screenpipe-app-tauri/src-tauri/Cargo.lock@@ -775,14 +775,16 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"[[package]]name = "chrono"-version = "0.4.38"+version = "0.4.39"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"+checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825"dependencies = ["android-tzdata","iana-time-zone",+ "js-sys","num-traits","serde",+ "wasm-bindgen","windows-targets 0.52.6",]@@ -5273,12 +5275,13 @@ dependencies = [[[package]]name = "screenpipe-app"-version = "0.29.0"+version = "0.29.6"dependencies = ["anyhow","async-stream","axum","base64 0.22.1",+ "chrono","cocoa 0.26.0","core-foundation 0.9.4","dirs 5.0.1",diff --git a/screenpipe-app-tauri/src-tauri/src/sidecar.rs b/screenpipe-app-tauri/src-tauri/src/sidecar.rsindex c1cc4e50d..5369281fa 100644--- a/screenpipe-app-tauri/src-tauri/src/sidecar.rs+++ b/screenpipe-app-tauri/src-tauri/src/sidecar.rs@@ -255,6 +255,11 @@ fn spawn_sidecar(app: &tauri::AppHandle) -> Result<CommandChild, String> {.and_then(|v| v.as_bool()).unwrap_or(false);+ let use_all_monitors = store+ .get("useAllMonitors")+ .and_then(|v| v.as_bool())+ .unwrap_or(false);+let user = User::from_store(&store);println!("user: {:?}", user);@@ -376,6 +381,10 @@ fn spawn_sidecar(app: &tauri::AppHandle) -> Result<CommandChild, String> {args.push("--enable-realtime-audio-transcription");}+ if use_all_monitors {+ args.push("--use-all-monitors");+ }+let disable_vision = store.get("disableVision").and_then(|v| v.as_bool())diff --git a/screenpipe-server/src/bin/screenpipe-server.rs b/screenpipe-server/src/bin/screenpipe-server.rsindex f649ab89c..10ba0cb33 100644--- a/screenpipe-server/src/bin/screenpipe-server.rs+++ b/screenpipe-server/src/bin/screenpipe-server.rs@@ -15,6 +15,7 @@ use screenpipe_core::AudioDevice;use screenpipe_core::DeviceControl;use screenpipe_core::DeviceType;use screenpipe_server::core::DeviceManager;+use screenpipe_server::VisionDeviceControlRequest;use screenpipe_server::{cli::{Cli, CliAudioTranscriptionEngine, CliOcrEngine, Command, OutputFormat, PipeCommand},core::{AudioConfig, RealtimeConfig, RecordingConfig, VisionConfig},@@ -27,8 +28,14 @@ use screenpipe_vision::monitor::list_monitors;use screenpipe_vision::run_ui;use serde_json::{json, Value};use std::{- collections::HashMap, env, fs, io::Write, net::SocketAddr, ops::Deref, path::PathBuf,- sync::Arc, time::Duration,+ collections::{HashMap, HashSet},+ env, fs,+ io::Write,+ net::SocketAddr,+ ops::Deref,+ path::PathBuf,+ sync::Arc,+ time::Duration,};use tokio::{runtime::Runtime, signal, sync::broadcast};use tracing::{debug, error, info, warn};@@ -1114,6 +1121,76 @@ async fn main() -> anyhow::Result<()> {});}+ if cli.use_all_monitors && !cli.disable_vision {+ let client = reqwest::Client::new();+ let port = cli.port;+ let mut shutdown_rx = shutdown_tx.subscribe();++ tokio::spawn(async move {+ // Start all available monitors immediately+ let initial_monitors: HashSet<u32> =+ list_monitors().await.into_iter().map(|m| m.id()).collect();++ for monitor_id in &initial_monitors {+ info!("starting monitor: {}", monitor_id);+ let _ = client+ .post(format!("http://127.0.0.1:{}/vision/start", port))+ .json(&VisionDeviceControlRequest::new(*monitor_id))+ .send()+ .await+ .map_err(|e| error!("failed to start monitor {}: {}", monitor_id, e));+ }++ let mut previous_monitors = initial_monitors;++ loop {+ tokio::select! {+ _ = shutdown_rx.recv() => {+ info!("stopping monitor polling due to shutdown signal");+ break;+ }+ _ = tokio::time::sleep(Duration::from_secs(5)) => {+ let current_monitors: HashSet<u32> = list_monitors()+ .await+ .into_iter()+ .map(|m| m.id())+ .collect();++ // Handle new monitors+ for monitor_id in current_monitors.difference(&previous_monitors) {+ info!("new monitor detected: {}", monitor_id);++ // Start recording the new monitor using the API+ let _ = client+ .post(format!("http://127.0.0.1:{}/vision/start", port))+ .json(&VisionDeviceControlRequest::new(*monitor_id))+ .send()+ .await+ .map_err(|e| error!("failed to start new monitor {}: {}", monitor_id, e));+ }++ // Handle removed monitors+ for monitor_id in previous_monitors.difference(¤t_monitors) {+ info!("monitor removed: {}", monitor_id);++ // Stop recording the removed monitor using the API+ let _ = client+ .post(format!("http://127.0.0.1:{}/vision/stop", port))+ .json(&VisionDeviceControlRequest::new(*monitor_id))+ .send()+ .await+ .map_err(|e| {+ error!("failed to stop removed monitor {}: {}", monitor_id, e)+ });+ }++ previous_monitors = current_monitors;+ }+ }+ }+ });+ }+tokio::select! {_ = handle => info!("recording completed"),result = &mut server_future => {diff --git a/screenpipe-server/src/cli.rs b/screenpipe-server/src/cli.rsindex 7dbf57ab3..23523547d 100644--- a/screenpipe-server/src/cli.rs+++ b/screenpipe-server/src/cli.rs@@ -264,6 +264,10 @@ pub struct Cli {#[arg(long, default_value_t = false)]pub capture_unfocused_windows: bool,+ /// Automatically detect and use all monitors, including newly connected ones+ #[arg(long, default_value_t = false)]+ pub use_all_monitors: bool,+#[command(subcommand)]pub command: Option<Command>,diff --git a/screenpipe-server/src/lib.rs b/screenpipe-server/src/lib.rsindex ef51ff969..0a77b0b7e 100644--- a/screenpipe-server/src/lib.rs+++ b/screenpipe-server/src/lib.rs@@ -31,4 +31,5 @@ pub use server::ContentItem;pub use server::HealthCheckResponse;pub use server::PaginatedResponse;pub use server::Server;+pub use server::VisionDeviceControlRequest;pub use video::VideoCapture;diff --git a/screenpipe-server/src/server.rs b/screenpipe-server/src/server.rsindex 66894443f..57721b9af 100644--- a/screenpipe-server/src/server.rs+++ b/screenpipe-server/src/server.rs@@ -1849,11 +1849,17 @@ async fn semantic_search_handler(}}-#[derive(Deserialize)]+#[derive(Serialize, Deserialize)]pub struct VisionDeviceControlRequest {device_id: u32,}+impl VisionDeviceControlRequest {+ pub fn new(device_id: u32) -> Self {+ Self { device_id }+ }+}+#[derive(Serialize)]pub struct VisionDeviceControlResponse {success: bool,