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

remove dead code and revert to xcap 0.3.3

Louis Beaumontec9281343999
diff --git a/screenpipe-server/src/bin/screenpipe-server.rs b/screenpipe-server/src/bin/screenpipe-server.rs
index c298267a6..cf984d6a8 100644
--- a/screenpipe-server/src/bin/screenpipe-server.rs
+++ b/screenpipe-server/src/bin/screenpipe-server.rs
@@ -787,15 +787,9 @@ async fn main() -> anyhow::Result<()> {
#[cfg(feature = "llm")]
debug!("LLM initialized");
- let api_plugin = |req: &axum::http::Request<axum::body::Body>| {
- if req.uri().path() == "/search" {
- // Track search requests
- }
- };
let (audio_devices_tx, _) = broadcast::channel(100);
- // TODO: Add SSE stream for realtime audio transcription
let server = SCServer::new(
db_server,
SocketAddr::from(([127, 0, 0, 1], cli.port)),
@@ -1133,7 +1127,7 @@ async fn main() -> anyhow::Result<()> {
}
}
- let server_future = server.start(api_plugin, cli.enable_frame_cache);
+ let server_future = server.start(cli.enable_frame_cache);
pin_mut!(server_future);
// Add auto-destruct watcher
diff --git a/screenpipe-server/src/lib.rs b/screenpipe-server/src/lib.rs
index 7bf0d5428..389032440 100644
--- a/screenpipe-server/src/lib.rs
+++ b/screenpipe-server/src/lib.rs
@@ -9,7 +9,6 @@ pub mod embedding;
pub mod filtering;
pub mod migration_worker;
pub mod pipe_manager;
-mod plugin;
mod resource_monitor;
mod server;
pub mod text_embeds;
diff --git a/screenpipe-server/src/plugin.rs b/screenpipe-server/src/plugin.rs
deleted file mode 100644
index 8d0012e6b..000000000
--- a/screenpipe-server/src/plugin.rs
+++ /dev/null
@@ -1,60 +0,0 @@
-use futures::future::BoxFuture;
-use std::task::{Context, Poll};
-use tower::{Layer, Service};
-
-#[derive(Clone)]
-pub struct ApiPluginLayer<F> {
- plugin: F,
-}
-
-impl<F> ApiPluginLayer<F>
-where
- F: Clone,
-{
- pub fn new(plugin: F) -> Self {
- Self { plugin }
- }
-}
-
-impl<S, F> Layer<S> for ApiPluginLayer<F>
-where
- F: Clone + Send + Sync + 'static,
-{
- type Service = ApiPluginService<S, F>;
-
- fn layer(&self, service: S) -> <Self as Layer<S>>::Service {
- ApiPluginService {
- inner: service,
- plugin: self.plugin.clone(),
- }
- }
-}
-
-#[derive(Clone)]
-pub struct ApiPluginService<S, F> {
- inner: S,
- plugin: F,
-}
-
-impl<S, F, R> Service<R> for ApiPluginService<S, F>
-where
- S: Service<R> + Clone + Send + 'static,
- F: Fn(&R) + Clone + Send + Sync + 'static,
- R: Send + 'static,
- S::Future: Send,
-{
- type Response = S::Response;
- type Error = S::Error;
- type Future = BoxFuture<'static, Result<Self::Response, Self::Error>>;
-
- fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
- self.inner.poll_ready(cx)
- }
-
- fn call(&mut self, request: R) -> Self::Future {
- let plugin = self.plugin.clone();
- let mut inner = self.inner.clone();
- plugin(&request);
- Box::pin(async move { inner.call(request).await })
- }
-}
diff --git a/screenpipe-server/src/server.rs b/screenpipe-server/src/server.rs
index 4601da105..b8832e617 100644
--- a/screenpipe-server/src/server.rs
+++ b/screenpipe-server/src/server.rs
@@ -6,7 +6,7 @@ use axum::{
},
http::StatusCode,
response::{IntoResponse, Json as JsonResponse, Response},
- routing::{get, post},
+ routing::get,
serve, Router,
};
use oasgen::{oasgen, OaSchema, Server};
@@ -22,6 +22,7 @@ use futures::{
use image::ImageFormat::{self};
use screenpipe_events::{send_event, subscribe_to_all_events, Event as ScreenpipeEvent};
+use crate::video_utils::extract_frame;
use crate::{
db_types::{ContentType, FrameData, Order, SearchMatch, SearchResult, Speaker, TagContentType},
embedding::embedding_endpoint::create_embeddings,
@@ -34,7 +35,6 @@ use crate::{
},
DatabaseManager,
};
-use crate::{plugin::ApiPluginLayer, video_utils::extract_frame};
use chrono::{DateTime, Utc};
use screenpipe_audio::{
default_input_device, default_output_device, list_audio_devices, AudioDevice, DeviceType,
@@ -283,7 +283,6 @@ pub struct HealthCheckResponse {
pub verbose_instructions: Option<String>,
}
-
#[derive(OaSchema, Serialize, Deserialize)]
pub struct SearchResponse {
pub data: Vec<ContentItem>,
@@ -295,10 +294,7 @@ pub struct SearchResponse {
pub(crate) async fn search(
Query(query): Query<SearchQuery>,
State(state): State<Arc<AppState>>,
-) -> Result<
- JsonResponse<SearchResponse>,
- (StatusCode, JsonResponse<serde_json::Value>),
-> {
+) -> Result<JsonResponse<SearchResponse>, (StatusCode, JsonResponse<serde_json::Value>)> {
info!(
"received search request: query='{}', content_type={:?}, limit={}, offset={}, start_time={:?}, end_time={:?}, app_name={:?}, window_name={:?}, min_length={:?}, max_length={:?}, speaker_ids={:?}, frame_name={:?}, browser_url={:?}, focused={:?}",
query.q.as_deref().unwrap_or(""),
@@ -433,7 +429,7 @@ pub(crate) async fn search(
}
info!("search completed: found {} results", total);
- Ok(JsonResponse( SearchResponse {
+ Ok(JsonResponse(SearchResponse {
data: content_items,
pagination: PaginationInfo {
limit: query.pagination.limit,
@@ -966,14 +962,7 @@ impl SCServer {
}
}
- pub async fn start<F>(
- self,
- api_plugin: F,
- enable_frame_cache: bool,
- ) -> Result<(), std::io::Error>
- where
- F: Fn(&axum::http::Request<axum::body::Body>) + Clone + Send + Sync + 'static,
- {
+ pub async fn start(self, enable_frame_cache: bool) -> Result<(), std::io::Error> {
let app_state = Arc::new(AppState {
db: self.db.clone(),
// device_manager: self.device_manager.clone(),
@@ -2786,7 +2775,7 @@ pub async fn purge_pipe_handler(
JsonResponse(json!({
"success": false,
"error": format!("failed to purge pipes: {}", e)
- }))
+ })),
))
}
}
diff --git a/screenpipe-vision/Cargo.toml b/screenpipe-vision/Cargo.toml
index 74797e327..55e4fde3a 100644
--- a/screenpipe-vision/Cargo.toml
+++ b/screenpipe-vision/Cargo.toml
@@ -43,7 +43,7 @@ tracing = { workspace = true }
which = "6.0"
serde = "1.0.200"
-xcap = "0.4.0"
+xcap = "0.3.3"
once_cell = { workspace = true }
base64 = "0.22.1"
diff --git a/screenpipe-vision/src/bin/screenpipe-vision.rs b/screenpipe-vision/src/bin/screenpipe-vision.rs
index c5c7552e5..a508631c3 100644
--- a/screenpipe-vision/src/bin/screenpipe-vision.rs
+++ b/screenpipe-vision/src/bin/screenpipe-vision.rs
@@ -36,7 +36,7 @@ async fn main() {
// Get monitor ID before spawning the task
let monitor_id =
- tokio::task::spawn_blocking(|| Monitor::all().unwrap().first().unwrap().id().unwrap())
+ tokio::task::spawn_blocking(|| Monitor::all().unwrap().first().unwrap().id())
.await
.unwrap();
diff --git a/screenpipe-vision/src/capture_screenshot_by_window.rs b/screenpipe-vision/src/capture_screenshot_by_window.rs
index 59e451091..8c72ee87b 100644
--- a/screenpipe-vision/src/capture_screenshot_by_window.rs
+++ b/screenpipe-vision/src/capture_screenshot_by_window.rs
@@ -201,10 +201,10 @@ pub async fn capture_all_visible_windows(
.into_iter()
.filter_map(|window| {
// Extract all necessary data from the window while in the main thread
- let app_name = window.app_name().unwrap();
- let title = window.title().unwrap();
- let is_focused = window.is_focused().unwrap();
- let process_id = window.pid().unwrap();
+ let app_name = window.app_name().to_string();
+ let title = window.title().to_string();
+ let is_focused = window.is_focused();
+ let process_id = window.pid();
// Capture image immediately while we have access to the window
match window.capture_image() {
Ok(buffer) => Some((app_name, title, is_focused, buffer, process_id)),
diff --git a/screenpipe-vision/src/monitor.rs b/screenpipe-vision/src/monitor.rs
index e6fa7d8fc..9a4947ba5 100644
--- a/screenpipe-vision/src/monitor.rs
+++ b/screenpipe-vision/src/monitor.rs
@@ -19,12 +19,12 @@ pub struct MonitorData {
impl SafeMonitor {
pub fn new(monitor: Monitor) -> Self {
- let monitor_id = monitor.id().unwrap();
+ let monitor_id = monitor.id();
let monitor_data = Arc::new(MonitorData {
- width: monitor.width().unwrap(),
- height: monitor.height().unwrap(),
- name: monitor.name().unwrap(),
- is_primary: monitor.is_primary().unwrap(),
+ width: monitor.width(),
+ height: monitor.height(),
+ name: monitor.name().to_string(),
+ is_primary: monitor.is_primary(),
});
Self {
@@ -40,10 +40,10 @@ impl SafeMonitor {
let monitor = Monitor::all()
.map_err(Error::from)?
.into_iter()
- .find(|m| m.id().unwrap() == monitor_id)
+ .find(|m| m.id() == monitor_id)
.ok_or_else(|| anyhow::anyhow!("Monitor not found"))?;
- if monitor.width().unwrap() == 0 || monitor.height().unwrap() == 0 {
+ if monitor.width() == 0 || monitor.height() == 0 {
return Err(anyhow::anyhow!("Invalid monitor dimensions"));
}
@@ -112,7 +112,7 @@ pub async fn get_monitor_by_id(id: u32) -> Option<SafeMonitor> {
Monitor::all()
.unwrap()
.into_iter()
- .find(|m| m.id().unwrap() == id)
+ .find(|m| m.id() == id)
.map(SafeMonitor::new)
})
.await