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
chore: restore shell completions
Louis Beaumonte6c9d0423be4
diff --git a/screenpipe-server/src/bin/screenpipe-server.rs b/screenpipe-server/src/bin/screenpipe-server.rsindex f19192ba5..5ee6b78c0 100644--- a/screenpipe-server/src/bin/screenpipe-server.rs+++ b/screenpipe-server/src/bin/screenpipe-server.rs@@ -197,9 +197,12 @@ async fn main() -> anyhow::Result<()> {};let pipe_manager = Arc::new(PipeManager::new(local_data_dir_clone.clone()));-- if let Some(command) = cli.command {+ if let Some(ref command) = cli.command {match command {+ Command::Completions { shell } => {+ cli.handle_completions(shell.clone())?;+ return Ok(());+ }Command::Pipe { subcommand } => {handle_pipe_command(subcommand, &pipe_manager).await?;return Ok(());@@ -297,7 +300,7 @@ async fn main() -> anyhow::Result<()> {let local_data_dir = get_base_dir(&data_dir)?;// Update logging filter if debug is enabled- if debug {+ if *debug {tracing::subscriber::set_global_default(tracing_subscriber::registry().with(@@ -323,14 +326,14 @@ async fn main() -> anyhow::Result<()> {);handle_index_command(local_data_dir,- path,- pattern,+ path.to_string(),+ pattern.clone(),db,- output,- ocr_engine,- metadata_override,- copy_videos,- use_embedding,+ output.clone(),+ ocr_engine.clone(),+ metadata_override.clone(),+ *copy_videos,+ *use_embedding,).await?;return Ok(());@@ -1051,7 +1054,7 @@ async fn main() -> anyhow::Result<()> {}async fn handle_pipe_command(- command: PipeCommand,+ command: &PipeCommand,pipe_manager: &Arc<PipeManager>,) -> anyhow::Result<()> {let client = reqwest::Client::new();diff --git a/screenpipe-server/src/cli.rs b/screenpipe-server/src/cli.rsindex b158e1421..0ba41f2c6 100644--- a/screenpipe-server/src/cli.rs+++ b/screenpipe-server/src/cli.rs@@ -1,6 +1,8 @@use std::path::PathBuf;-use clap::{Parser, Subcommand};+use clap::{Parser, Subcommand, ValueHint};+use clap_complete::{generate, Shell};+use clap::CommandFactory;use screenpipe_audio::{vad_engine::VadSensitivity, AudioTranscriptionEngine as CoreAudioTranscriptionEngine};use screenpipe_vision::{custom_ocr::CustomOcrConfig, utils::OcrEngine as CoreOcrEngine};use clap::ValueEnum;@@ -150,7 +152,7 @@ pub struct Cli {pub list_audio_devices: bool,/// Data directory. Default to $HOME/.screenpipe- #[arg(long)]+ #[arg(long, value_hint = ValueHint::DirPath)]pub data_dir: Option<String>,/// Enable debug logging for screenpipe modules@@ -281,6 +283,11 @@ impl Cli {}Ok(unique_langs.into_iter().collect())}+ pub fn handle_completions(&self, shell: Shell) -> anyhow::Result<()> {+ let mut cmd = Self::command();+ generate(shell, &mut cmd, "screenpipe", &mut std::io::stdout());+ Ok(())+ }}#[derive(Subcommand)]@@ -295,7 +302,7 @@ pub enum Command {/// Path to folder containing video filespath: String,/// Data directory. Default to $HOME/.screenpipe- #[arg(long)]+ #[arg(long, value_hint = ValueHint::DirPath)]data_dir: Option<String>,/// Output format#[arg(short = 'o', long, value_enum, default_value_t = OutputFormat::Text)]@@ -307,7 +314,7 @@ pub enum Command {#[arg(short = 'o', long, value_enum)]ocr_engine: Option<CliOcrEngine>,/// Path to JSON file containing metadata overrides- #[arg(long)]+ #[arg(long, value_hint = ValueHint::FilePath)]metadata_override: Option<PathBuf>,/// Copy videos to screenpipe data directory#[arg(long, default_value_t = true)]@@ -327,6 +334,12 @@ pub enum Command {},/// Run database migrationsMigrate,+ /// Generate shell completions+ Completions {+ /// The shell to generate completions for+ #[arg(value_enum)]+ shell: Shell,+ },}diff --git a/screenpipe-server/src/video.rs b/screenpipe-server/src/video.rsindex 8137d2016..3da2bb434 100644--- a/screenpipe-server/src/video.rs+++ b/screenpipe-server/src/video.rs@@ -1,11 +1,11 @@use chrono::Utc;use crossbeam::queue::ArrayQueue;use image::ImageFormat::{self};-use tracing::{debug, error, info, warn};use screenpipe_core::{find_ffmpeg_path, Language};use screenpipe_vision::{capture_screenshot_by_window::WindowFilters, continuous_capture, CaptureResult, OcrEngine,};+use std::borrow::Cow;use std::path::PathBuf;use std::process::Stdio;use std::sync::Arc;@@ -16,6 +16,7 @@ use tokio::io::BufReader;use tokio::process::{Child, ChildStderr, ChildStdin, ChildStdout, Command};use tokio::sync::mpsc::channel;use tokio::time::sleep;+use tracing::{debug, error, info, warn};pub(crate) const MAX_FPS: f64 = 30.0; // Adjust based on your needsconst MAX_QUEUE_SIZE: usize = 10;@@ -384,8 +385,9 @@ pub async fn finish_ffmpeg_process(child: Child, stdin: Option<ChildStdin>) {match child.wait_with_output().await {Ok(output) => {debug!("FFmpeg process exited with status: {}", output.status);- if !output.status.success() {- error!("FFmpeg stderr: {}", String::from_utf8_lossy(&output.stderr));+ let stderr = String::from_utf8_lossy(&output.stderr);+ if !output.status.success() && stderr != Cow::Borrowed("") {+ error!("FFmpeg stderr: {}", stderr);}}Err(e) => error!("Failed to wait for FFmpeg process: {}", e),