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
Bump app to v2.0.199
Louis Beaumontfcb89002c164
diff --git a/screenpipe-accessibility/src/platform/macos.rs b/screenpipe-accessibility/src/platform/macos.rsindex ae7842cdd..981918518 100644--- a/screenpipe-accessibility/src/platform/macos.rs+++ b/screenpipe-accessibility/src/platform/macos.rs@@ -1,7 +1,8 @@//! macOS UI event capture using CGEventTap and Accessibility APIs//!-//! Based on bigbrother's implementation with screenpipe-specific enhancements.+//! Uses native macOS APIs - no rdev dependency.+use crate::activity_feed::{ActivityFeed, ActivityKind};use crate::config::UiCaptureConfig;use crate::events::{ElementContext, EventData, Modifiers, UiEvent};use anyhow::Result;@@ -109,8 +110,44 @@ impl UiRecorder {}}- /// Start capturing events+ /// Start capturing events (without activity feed)pub fn start(&self) -> Result<RecordingHandle> {+ let (handle, _) = self.start_internal(None)?;+ Ok(handle)+ }++ /// Start capturing with activity feed for adaptive FPS+ pub fn start_with_activity_feed(&self) -> Result<(RecordingHandle, ActivityFeed)> {+ let activity_feed = ActivityFeed::new();+ let (handle, _) = self.start_internal(Some(activity_feed.clone()))?;+ Ok((handle, activity_feed))+ }++ /// Start activity feed only (minimal hooks, no full event capture)+ pub fn start_activity_only(&self) -> Result<ActivityFeed> {+ let perms = self.check_permissions();+ if !perms.input_monitoring {+ anyhow::bail!("Missing input monitoring permission");+ }++ let activity_feed = ActivityFeed::new();+ let stop = Arc::new(AtomicBool::new(false));++ let feed_clone = activity_feed.clone();+ let stop_clone = stop.clone();++ // Spawn minimal event tap thread (activity only)+ thread::spawn(move || {+ run_activity_only_tap(feed_clone, stop_clone);+ });++ Ok(activity_feed)+ }++ fn start_internal(+ &self,+ activity_feed: Option<ActivityFeed>,+ ) -> Result<(RecordingHandle, Option<ActivityFeed>)> {let perms = self.check_permissions();if !perms.all_granted() {anyhow::bail!(@@ -136,8 +173,9 @@ impl UiRecorder {let config1 = self.config.clone();let app1 = current_app.clone();let window1 = current_window.clone();+ let feed1 = activity_feed.clone();threads.push(thread::spawn(move || {- run_event_tap(tx1, stop1, start_time, config1, app1, window1);+ run_event_tap(tx1, stop1, start_time, config1, app1, window1, feed1);}));// Thread 2: App/window observer@@ -150,11 +188,14 @@ impl UiRecorder {run_app_observer(tx2, stop2, start_time, config2, app2, window2);}));- Ok(RecordingHandle {- stop,- events_rx: rx,- threads,- })+ Ok((+ RecordingHandle {+ stop,+ events_rx: rx,+ threads,+ },+ activity_feed,+ ))}}@@ -170,6 +211,7 @@ struct TapState {text_buf: Mutex<TextBuffer>,current_app: Arc<Mutex<Option<String>>>,current_window: Arc<Mutex<Option<String>>>,+ activity_feed: Option<ActivityFeed>,}struct TextBuffer {@@ -220,16 +262,18 @@ fn run_event_tap(config: UiCaptureConfig,current_app: Arc<Mutex<Option<String>>>,current_window: Arc<Mutex<Option<String>>>,+ activity_feed: Option<ActivityFeed>,) {- // Build event mask+ // Build event mask - always include KEY_UP for activity trackinglet mut mask = cg::EventType::LEFT_MOUSE_DOWN.mask()| cg::EventType::LEFT_MOUSE_UP.mask()| cg::EventType::RIGHT_MOUSE_DOWN.mask()| cg::EventType::RIGHT_MOUSE_UP.mask()| cg::EventType::KEY_DOWN.mask()+ | cg::EventType::KEY_UP.mask()| cg::EventType::SCROLL_WHEEL.mask();- if config.capture_mouse_move {+ if config.capture_mouse_move || activity_feed.is_some() {mask |= cg::EventType::MOUSE_MOVED.mask()| cg::EventType::LEFT_MOUSE_DRAGGED.mask()| cg::EventType::RIGHT_MOUSE_DRAGGED.mask();@@ -243,6 +287,7 @@ fn run_event_tap(text_buf: Mutex::new(TextBuffer::new(config.text_timeout_ms)),current_app,current_window,+ activity_feed,}));let tap = cg::EventTap::new(@@ -324,6 +369,11 @@ extern "C" fn tap_callback(match event_type {cg::EventType::LEFT_MOUSE_DOWN | cg::EventType::RIGHT_MOUSE_DOWN => {+ // Record activity+ if let Some(ref feed) = state.activity_feed {+ feed.record(ActivityKind::MouseClick);+ }+if !state.config.capture_clicks {return Some(event);}@@ -388,36 +438,45 @@ extern "C" fn tap_callback(cg::EventType::MOUSE_MOVED| cg::EventType::LEFT_MOUSE_DRAGGED| cg::EventType::RIGHT_MOUSE_DRAGGED => {- if !state.config.capture_mouse_move {- return Some(event);- }-let mut last = state.last_mouse.lock();let dx = loc.x - last.0;let dy = loc.y - last.1;let dist = (dx * dx + dy * dy).sqrt();if dist >= state.config.mouse_move_threshold {+ // Record activity (throttled by distance)+ if let Some(ref feed) = state.activity_feed {+ feed.record(ActivityKind::MouseMove);+ }+*last = (loc.x, loc.y);- let ui_event = UiEvent {- id: None,- timestamp,- relative_ms: t,- data: EventData::Move {- x: loc.x as i32,- y: loc.y as i32,- },- app_name,- window_title,- browser_url: None,- element: None,- frame_id: None,- };- let _ = state.tx.try_send(ui_event);++ if state.config.capture_mouse_move {+ let ui_event = UiEvent {+ id: None,+ timestamp,+ relative_ms: t,+ data: EventData::Move {+ x: loc.x as i32,+ y: loc.y as i32,+ },+ app_name,+ window_title,+ browser_url: None,+ element: None,+ frame_id: None,+ };+ let _ = state.tx.try_send(ui_event);+ }}}cg::EventType::SCROLL_WHEEL => {+ // Record activity+ if let Some(ref feed) = state.activity_feed {+ feed.record(ActivityKind::Scroll);+ }+let dy = event.field_i64(cg::EventField::SCROLL_WHEEL_EVENT_DELTA_AXIS1) as i16;let dx = event.field_i64(cg::EventField::SCROLL_WHEEL_EVENT_DELTA_AXIS2) as i16;if dx != 0 || dy != 0 {@@ -441,7 +500,18 @@ extern "C" fn tap_callback(}}+ cg::EventType::KEY_UP => {+ // Record key release activity+ if let Some(ref feed) = state.activity_feed {+ feed.record(ActivityKind::KeyRelease);+ }+ }+cg::EventType::KEY_DOWN => {+ // Record key press activity+ if let Some(ref feed) = state.activity_feed {+ feed.record(ActivityKind::KeyPress);+ }let keycode = event.field_i64(cg::EventField::KEYBOARD_EVENT_KEYCODE) as u16;// Check for clipboard operations (Cmd+C, Cmd+X, Cmd+V)@@ -978,6 +1048,99 @@ fn keycode_to_char(keycode: u16, mods: Modifiers) -> Option<char> {}}+// ============================================================================+// Activity-Only Event Tap (minimal, for adaptive FPS without full event capture)+// ============================================================================++fn run_activity_only_tap(activity_feed: ActivityFeed, stop: Arc<AtomicBool>) {+ debug!("Starting activity-only event tap");++ // Minimal event mask for activity detection+ let mask = cg::EventType::KEY_DOWN.mask()+ | cg::EventType::KEY_UP.mask()+ | cg::EventType::LEFT_MOUSE_DOWN.mask()+ | cg::EventType::RIGHT_MOUSE_DOWN.mask()+ | cg::EventType::MOUSE_MOVED.mask()+ | cg::EventType::SCROLL_WHEEL.mask();++ // Store activity feed in a box for the callback+ let feed_ptr = Box::into_raw(Box::new(activity_feed));++ let tap = cg::EventTap::new(+ cg::EventTapLocation::Session,+ cg::EventTapPlacement::TailAppend,+ cg::EventTapOpts::LISTEN_ONLY,+ mask,+ activity_only_callback,+ feed_ptr as *mut ActivityFeed,+ );++ let Some(tap) = tap else {+ error!("Failed to create activity-only CGEventTap");+ // Clean up the leaked box+ unsafe {+ let _ = Box::from_raw(feed_ptr);+ }+ return;+ };++ let Some(src) = cf::MachPort::run_loop_src(&tap, 0) else {+ error!("Failed to create run loop source");+ unsafe {+ let _ = Box::from_raw(feed_ptr);+ }+ return;+ };++ let rl = cf::RunLoop::current();+ rl.add_src(&src, cf::RunLoopMode::default());++ debug!("Activity-only event tap started");++ while !stop.load(Ordering::Relaxed) {+ cf::RunLoop::run_in_mode(cf::RunLoopMode::default(), 0.05, true);+ }++ rl.remove_src(&src, cf::RunLoopMode::default());++ // Clean up+ unsafe {+ let _ = Box::from_raw(feed_ptr);+ }++ debug!("Activity-only event tap stopped");+}++extern "C" fn activity_only_callback(+ _proxy: *mut cg::EventTapProxy,+ event_type: cg::EventType,+ event: &mut cg::Event,+ user_info: *mut ActivityFeed,+) -> Option<&cg::Event> {+ let feed = unsafe { &*user_info };++ match event_type {+ cg::EventType::KEY_DOWN => {+ feed.record(ActivityKind::KeyPress);+ }+ cg::EventType::KEY_UP => {+ feed.record(ActivityKind::KeyRelease);+ }+ cg::EventType::LEFT_MOUSE_DOWN | cg::EventType::RIGHT_MOUSE_DOWN => {+ feed.record(ActivityKind::MouseClick);+ }+ cg::EventType::MOUSE_MOVED => {+ feed.record(ActivityKind::MouseMove);+ }+ cg::EventType::SCROLL_WHEEL => {+ feed.record(ActivityKind::Scroll);+ }+ _ => {}+ }++ Some(event)+}+#[cfg(test)]mod tests {use super::*;diff --git a/screenpipe-accessibility/src/platform/mod.rs b/screenpipe-accessibility/src/platform/mod.rsindex 7e5dfb4dc..c75ef95aa 100644--- a/screenpipe-accessibility/src/platform/mod.rs+++ b/screenpipe-accessibility/src/platform/mod.rs@@ -13,9 +13,10 @@ pub use macos::{PermissionStatus, RecordingHandle, UiRecorder};#[cfg(target_os = "windows")]pub use windows::{PermissionStatus, RecordingHandle, UiRecorder};-// Stub for unsupported platforms+// Stub for unsupported platforms (Linux, etc.)#[cfg(not(any(target_os = "macos", target_os = "windows")))]pub mod stub {+ use crate::activity_feed::ActivityFeed;use crate::config::UiCaptureConfig;use crate::events::UiEvent;use anyhow::Result;@@ -83,6 +84,14 @@ pub mod stub {pub fn start(&self) -> Result<RecordingHandle> {anyhow::bail!("UI event capture not supported on this platform")}++ pub fn start_with_activity_feed(&self) -> Result<(RecordingHandle, ActivityFeed)> {+ anyhow::bail!("UI event capture not supported on this platform")+ }++ pub fn start_activity_only(&self) -> Result<ActivityFeed> {+ anyhow::bail!("Activity feed not supported on this platform")+ }}}diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.tomlindex b5ba1c926..2b630e27e 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 = "2.0.198"+version = "2.0.199"description = "24/7 memory for your desktop. 100% local."authors = ["you"]license = ""diff --git a/screenpipe-server/src/bin/screenpipe-server.rs b/screenpipe-server/src/bin/screenpipe-server.rsindex 42fef0bff..73908f194 100644--- a/screenpipe-server/src/bin/screenpipe-server.rs+++ b/screenpipe-server/src/bin/screenpipe-server.rs@@ -779,6 +779,28 @@ async fn main() -> anyhow::Result<()> {let vision_manager: Option<Arc<VisionManager>> = if cli.use_all_monitors && !cli.disable_vision{info!("Using dynamic monitor detection (--use-all-monitors)");++ // Create activity feed for adaptive FPS if enabled+ #[cfg(feature = "adaptive-fps")]+ let activity_feed: screenpipe_vision::ActivityFeedOption = if cli.adaptive_fps {+ info!("Starting activity feed for adaptive FPS");+ match screenpipe_accessibility::UiRecorder::with_defaults().start_activity_only() {+ Ok(feed) => {+ info!("Activity feed started successfully");+ Some(feed)+ }+ Err(e) => {+ warn!("Failed to start activity feed: {:?}. Adaptive FPS will be disabled.", e);+ None+ }+ }+ } else {+ None+ };++ #[cfg(not(feature = "adaptive-fps"))]+ let activity_feed: screenpipe_vision::ActivityFeedOption = None;+let config = VisionManagerConfig {output_path: output_path_clone.to_string(),fps,@@ -791,7 +813,7 @@ async fn main() -> anyhow::Result<()> {languages: languages_clone.clone(),capture_unfocused_windows: cli.capture_unfocused_windows,realtime_vision: cli.enable_realtime_audio_transcription,- adaptive_fps: cli.adaptive_fps,+ activity_feed: activity_feed.clone(),};Some(Arc::new(VisionManager::new(config,@@ -832,6 +854,27 @@ async fn main() -> anyhow::Result<()> {}})} else {+ // Create activity feed for adaptive FPS if enabled (for non-VisionManager path)+ #[cfg(feature = "adaptive-fps")]+ let activity_feed_legacy: screenpipe_vision::ActivityFeedOption = if cli.adaptive_fps {+ info!("Starting activity feed for adaptive FPS (legacy path)");+ match screenpipe_accessibility::UiRecorder::with_defaults().start_activity_only() {+ Ok(feed) => {+ info!("Activity feed started successfully");+ Some(feed)+ }+ Err(e) => {+ warn!("Failed to start activity feed: {:?}. Adaptive FPS will be disabled.", e);+ None+ }+ }+ } else {+ None+ };++ #[cfg(not(feature = "adaptive-fps"))]+ let activity_feed_legacy: screenpipe_vision::ActivityFeedOption = None;+// Use traditional start_continuous_recordinglet runtime = &tokio::runtime::Handle::current();runtime.spawn(async move {@@ -853,7 +896,7 @@ async fn main() -> anyhow::Result<()> {languages_clone.clone(),cli.capture_unfocused_windows,cli.enable_realtime_audio_transcription,- cli.adaptive_fps,+ activity_feed_legacy.clone(),);let result = tokio::select! {diff --git a/screenpipe-server/src/core.rs b/screenpipe-server/src/core.rsindex c62ad6ece..5689587aa 100644--- a/screenpipe-server/src/core.rs+++ b/screenpipe-server/src/core.rs@@ -29,7 +29,7 @@ pub async fn start_continuous_recording(languages: Vec<Language>,capture_unfocused_windows: bool,realtime_vision: bool,- adaptive_fps: bool,+ activity_feed: screenpipe_vision::ActivityFeedOption,) -> Result<()> {debug!("Starting video recording for monitors {:?}", monitor_ids);let video_tasks = if !vision_disabled {@@ -44,6 +44,7 @@ pub async fn start_continuous_recording(let ignored_urls_video = ignored_urls.to_vec();let languages = languages.clone();+ let activity_feed = activity_feed.clone();debug!("Starting video recording for monitor {}", monitor_id);vision_handle.spawn(async move {@@ -64,7 +65,7 @@ pub async fn start_continuous_recording(languages.clone(),capture_unfocused_windows,realtime_vision,- adaptive_fps,+ activity_feed.clone(),).await{@@ -130,7 +131,7 @@ pub async fn record_video(languages: Vec<Language>,capture_unfocused_windows: bool,realtime_vision: bool,- adaptive_fps: bool,+ activity_feed: screenpipe_vision::ActivityFeedOption,) -> Result<()> {debug!("record_video: Starting for monitor {}", monitor_id);let device_name = Arc::new(format!("monitor_{}", monitor_id));@@ -178,7 +179,7 @@ pub async fn record_video(ignored_urls,languages,capture_unfocused_windows,- adaptive_fps,+ activity_feed,);info!(diff --git a/screenpipe-server/src/video.rs b/screenpipe-server/src/video.rsindex eca2bb5e5..6b9c46ad2 100644--- a/screenpipe-server/src/video.rs+++ b/screenpipe-server/src/video.rs@@ -127,7 +127,7 @@ impl VideoCapture {ignored_urls: &[String],languages: Vec<Language>,capture_unfocused_windows: bool,- adaptive_fps: bool,+ activity_feed: screenpipe_vision::ActivityFeedOption,) -> Self {let fps = if fps.is_finite() && fps > 0.0 {fps@@ -162,7 +162,7 @@ impl VideoCapture {let capture_result_sender = result_sender.clone();let capture_interval = interval;let capture_unfocused = capture_unfocused_windows;- let capture_adaptive_fps = adaptive_fps;+ let capture_activity_feed = activity_feed;// Store task handles for health monitoringlet capture_thread = tokio::spawn(async move {@@ -192,7 +192,7 @@ impl VideoCapture {capture_window_filters.clone(),capture_languages.clone(),capture_unfocused,- capture_adaptive_fps,+ capture_activity_feed.clone(),).await{diff --git a/screenpipe-server/src/vision_manager/manager.rs b/screenpipe-server/src/vision_manager/manager.rsindex 51d973f15..6c0b6c932 100644--- a/screenpipe-server/src/vision_manager/manager.rs+++ b/screenpipe-server/src/vision_manager/manager.rs@@ -29,7 +29,7 @@ pub struct VisionManagerConfig {pub languages: Vec<Language>,pub capture_unfocused_windows: bool,pub realtime_vision: bool,- pub adaptive_fps: bool,+ pub activity_feed: screenpipe_vision::ActivityFeedOption,}/// Status of the VisionManager@@ -164,7 +164,7 @@ impl VisionManager {let languages = self.config.languages.clone();let capture_unfocused_windows = self.config.capture_unfocused_windows;let realtime_vision = self.config.realtime_vision;- let adaptive_fps = self.config.adaptive_fps;+ let activity_feed = self.config.activity_feed.clone();// Spawn the recording task using the existing record_video functionlet handle = self.vision_handle.spawn(async move {@@ -183,7 +183,7 @@ impl VisionManager {languages.clone(),capture_unfocused_windows,realtime_vision,- adaptive_fps,+ activity_feed.clone(),).await{diff --git a/screenpipe-vision/Cargo.toml b/screenpipe-vision/Cargo.tomlindex 45634368c..6fd6fd005 100644--- a/screenpipe-vision/Cargo.toml+++ b/screenpipe-vision/Cargo.toml@@ -12,11 +12,13 @@ edition = { workspace = true }[features]default = []-adaptive-fps = ["rdev"]+# Adaptive FPS based on input activity (requires screenpipe-accessibility)+# Only supported on macOS and Windows+adaptive-fps = ["screenpipe-accessibility"][dependencies]-# Input activity monitoring for adaptive FPS (optional)-rdev = { version = "0.5", optional = true }+# Activity feed for adaptive FPS (optional, macOS/Windows only)+screenpipe-accessibility = { path = "../screenpipe-accessibility", optional = true }serde_json = "1.0"chrono = { version = "0.4.31", features = ["serde"] }diff --git a/screenpipe-vision/src/activity.rs b/screenpipe-vision/src/activity.rsdeleted file mode 100644index cdbc37700..000000000--- a/screenpipe-vision/src/activity.rs+++ /dev/null@@ -1,141 +0,0 @@-//! Activity monitoring for adaptive FPS capture.-//!-//! This module provides input activity detection using rdev to dynamically-//! adjust capture rates based on user activity (mouse/keyboard events).--use std::sync::atomic::{AtomicU64, Ordering};-use std::sync::Arc;-use std::time::Duration;-use tracing::{debug, error, info};--/// Tracks input activity to determine optimal capture rate.-///-/// Spawns a background thread that listens for mouse/keyboard events-/// and updates an atomic timestamp. The capture loop can query this-/// to determine if the user is active and adjust FPS accordingly.-pub struct ActivityMonitor {- last_activity: Arc<AtomicU64>,- base_interval: Duration,-}--impl ActivityMonitor {- /// Create a new ActivityMonitor and start listening for input events.- ///- /// # Arguments- /// * `base_interval` - The default capture interval when user is idle- pub fn new(base_interval: Duration) -> Self {- let last_activity = Arc::new(AtomicU64::new(current_time_ms()));- let activity_clone = last_activity.clone();-- // Spawn listener thread (rdev::listen blocks, so needs its own thread)- std::thread::Builder::new()- .name("activity-monitor".to_string())- .spawn(move || {- info!("Starting input activity monitor");-- let callback = move |event: rdev::Event| {- match event.event_type {- // Key events - always update- rdev::EventType::KeyPress(_) | rdev::EventType::KeyRelease(_) => {- activity_clone.store(current_time_ms(), Ordering::Relaxed);- }- // Mouse button events - always update- rdev::EventType::ButtonPress(_) | rdev::EventType::ButtonRelease(_) => {- activity_clone.store(current_time_ms(), Ordering::Relaxed);- }- // Scroll events - always update- rdev::EventType::Wheel { .. } => {- activity_clone.store(current_time_ms(), Ordering::Relaxed);- }- // Mouse move - throttle to reduce overhead- rdev::EventType::MouseMove { .. } => {- let now = current_time_ms();- let last = activity_clone.load(Ordering::Relaxed);- // Only update if more than 100ms since last activity- if now.saturating_sub(last) > 100 {- activity_clone.store(now, Ordering::Relaxed);- }- }- }- };-- if let Err(e) = rdev::listen(callback) {- error!("Input activity listener error: {:?}", e);- }- })- .expect("Failed to spawn activity monitor thread");-- Self {- last_activity,- base_interval,- }- }-- /// Returns the optimal capture interval based on recent activity.- ///- /// Activity tiers:- /// - < 500ms since activity: 200ms interval (5 FPS) - active- /// - < 2000ms: 500ms interval (2 FPS) - cooling down- /// - < 5000ms: 1000ms interval (1 FPS) - idle- /// - > 5000ms: base_interval - deep idle- pub fn get_interval(&self) -> Duration {- let now = current_time_ms();- let last = self.last_activity.load(Ordering::Relaxed);- let idle_ms = now.saturating_sub(last);-- let interval = if idle_ms < 500 {- // Active - capture at 5 FPS- Duration::from_millis(200)- } else if idle_ms < 2000 {- // Cooling down - 2 FPS- Duration::from_millis(500)- } else if idle_ms < 5000 {- // Idle - 1 FPS- Duration::from_millis(1000)- } else {- // Deep idle - use base interval- self.base_interval- };-- debug!(- "Activity monitor: idle_ms={}, interval={}ms",- idle_ms,- interval.as_millis()- );-- interval- }-- /// Returns milliseconds since last detected activity.- pub fn idle_time_ms(&self) -> u64 {- let now = current_time_ms();- let last = self.last_activity.load(Ordering::Relaxed);- now.saturating_sub(last)- }-- /// Returns true if user was active in the last N milliseconds.- pub fn is_active(&self, threshold_ms: u64) -> bool {- self.idle_time_ms() < threshold_ms- }-}--/// Get current time in milliseconds since UNIX epoch.-fn current_time_ms() -> u64 {- std::time::SystemTime::now()- .duration_since(std::time::UNIX_EPOCH)- .unwrap_or_default()- .as_millis() as u64-}--#[cfg(test)]-mod tests {- use super::*;-- #[test]- fn test_current_time_ms() {- let t1 = current_time_ms();- std::thread::sleep(Duration::from_millis(10));- let t2 = current_time_ms();- assert!(t2 > t1);- }-}diff --git a/screenpipe-vision/src/core.rs b/screenpipe-vision/src/core.rsindex 4f131c7ff..2d44145e2 100644--- a/screenpipe-vision/src/core.rs+++ b/screenpipe-vision/src/core.rs@@ -144,6 +144,13 @@ impl std::fmt::Display for ContinuousCaptureError {}}+/// Activity feed for adaptive FPS (optional, from screenpipe-accessibility)+#[cfg(feature = "adaptive-fps")]+pub type ActivityFeedOption = Option<screenpipe_accessibility::ActivityFeed>;++#[cfg(not(feature = "adaptive-fps"))]+pub type ActivityFeedOption = Option<()>;+pub async fn continuous_capture(result_tx: Sender<CaptureResult>,interval: Duration,@@ -152,23 +159,15 @@ pub async fn continuous_capture(window_filters: Arc<WindowFilters>,languages: Vec<Language>,capture_unfocused_windows: bool,- adaptive_fps: bool,+ activity_feed: ActivityFeedOption,) -> Result<(), ContinuousCaptureError> {let mut frame_counter: u64 = 0;let mut previous_image: Option<DynamicImage> = None;let mut max_average: Option<MaxAverageFrame> = None;let mut max_avg_value = 0.0;- // Initialize activity monitor for adaptive FPS if enabled- #[cfg(feature = "adaptive-fps")]- let activity_monitor = if adaptive_fps {- Some(crate::activity::ActivityMonitor::new(interval))- } else {- None- };-#[cfg(feature = "adaptive-fps")]- if adaptive_fps {+ if activity_feed.is_some() {debug!("Adaptive FPS enabled - will adjust capture rate based on input activity");}@@ -194,7 +193,7 @@ pub async fn continuous_capture(// Suppress unused variable warning when feature is disabled#[cfg(not(feature = "adaptive-fps"))]- let _ = adaptive_fps;+ let _ = activity_feed;loop {// 3. Capture screenshot and wall-clock time atomically@@ -230,9 +229,9 @@ pub async fn continuous_capture(frame_counter += 1;// Use adaptive interval if enabled, otherwise use base interval#[cfg(feature = "adaptive-fps")]- let sleep_interval = activity_monitor+ let sleep_interval = activity_feed.as_ref()- .map(|m| m.get_interval())+ .map(|f| f.get_capture_params().interval).unwrap_or(interval);#[cfg(not(feature = "adaptive-fps"))]let sleep_interval = interval;@@ -261,9 +260,9 @@ pub async fn continuous_capture(frame_counter += 1;// Use adaptive interval if enabled, otherwise use base interval#[cfg(feature = "adaptive-fps")]- let sleep_interval = activity_monitor+ let sleep_interval = activity_feed.as_ref()- .map(|m| m.get_interval())+ .map(|f| f.get_capture_params().interval).unwrap_or(interval);#[cfg(not(feature = "adaptive-fps"))]let sleep_interval = interval;diff --git a/screenpipe-vision/src/lib.rs b/screenpipe-vision/src/lib.rsindex b683ce033..26cf36a81 100644--- a/screenpipe-vision/src/lib.rs+++ b/screenpipe-vision/src/lib.rs@@ -1,5 +1,7 @@+// Re-export activity feed types when adaptive-fps is enabled#[cfg(feature = "adaptive-fps")]-pub mod activity;+pub use screenpipe_accessibility::{ActivityFeed, ActivityKind, CaptureParams};+#[cfg(target_os = "macos")]pub mod apple;pub mod core;