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

make pipe manager optional (#1795)

shaik-zeeshan8e84fd51fed3
diff --git a/screenpipe-app-tauri/components/pipe-store.tsx b/screenpipe-app-tauri/components/pipe-store.tsx
index 44455f394..d1974c138 100644
--- a/screenpipe-app-tauri/components/pipe-store.tsx
+++ b/screenpipe-app-tauri/components/pipe-store.tsx
@@ -56,6 +56,9 @@ import { usePlatform } from "@/lib/hooks/use-platform";
import { invoke } from "@tauri-apps/api/core";
import { cn } from "@/lib/utils";
import { getAllWindows } from "@tauri-apps/api/window";
+import * as Sentry from "@sentry/react";
+import { defaultOptions } from "tauri-plugin-sentry-api";
+import { ToastAction } from "./ui/toast";
const corePipes: string[] = [];
@@ -109,6 +112,7 @@ export const PipeStore: React.FC = () => {
}, [pipes, searchQuery, showInstalledOnly]);
const [confirmOpen, setConfirmOpen] = useState(false);
const [isPurging, setIsPurging] = useState(false);
+ const [isPipeFunctionEnabled, setIsPipeFunctionEnabled] = useState(true);
// Add debounced search tracking
useEffect(() => {
@@ -428,6 +432,18 @@ export const PipeStore: React.FC = () => {
success: boolean;
};
+ // check if the pipe function is enabled
+ if (response.status === 403) {
+ console.log("pipe function is disabled", response.body)
+ setIsPipeFunctionEnabled(false);
+ toast({
+ title: "pipe function is disabled",
+ description: "please restart screenpipe to enable it",
+ variant: "destructive",
+ });
+ return;
+ }
+
if (!data.success) throw new Error("Failed to fetch installed pipes");
setInstalledPipes(data.data);
@@ -1311,13 +1327,13 @@ export const PipeStore: React.FC = () => {
};
}, [pipes, settings.user, settings.autoUpdatePipes, fetchInstalledPipes]);
- if (health?.status === "error") {
+ if (health?.status === "error" || !isPipeFunctionEnabled) {
return (
<div className="flex flex-col items-center justify-center h-screen p-4 space-y-4">
<div className="text-center space-y-4 max-w-md mx-auto justify-center items-center">
- <h3 className="text-lg font-medium">screenpipe is not recording</h3>
+ <h3 className="text-lg font-medium">{isPipeFunctionEnabled ? "screenpipe is not recording" : "pipes are disabled"}</h3>
<p className="text-sm text-muted-foreground">
- please start the screenpipe service to browse and manage pipes
+ {isPipeFunctionEnabled ? "please start the screenpipe service to browse and manage pipes" : "please restart screenpipe to enable the pipes"}
</p>
<div className="flex flex-col gap-2">
<Button
@@ -1331,14 +1347,16 @@ export const PipeStore: React.FC = () => {
/>
{isRestarting ? "restarting..." : "restart screenpipe"}
</Button>
- <Button
- variant="outline"
- onClick={openStatusDialog}
- className="gap-2"
+ {isPipeFunctionEnabled && (
+ <Button
+ variant="outline"
+ onClick={openStatusDialog}
+ className="gap-2"
>
- <Power className="h-4 w-4" />
- check service status
- </Button>
+ <Power className="h-4 w-4" />
+ check service status
+ </Button>
+ )}
</div>
{isMacOS && (
diff --git a/screenpipe-app-tauri/src-tauri/src/sidecar.rs b/screenpipe-app-tauri/src-tauri/src/sidecar.rs
index 4a21db3a4..3d91cd4f8 100644
--- a/screenpipe-app-tauri/src-tauri/src/sidecar.rs
+++ b/screenpipe-app-tauri/src-tauri/src/sidecar.rs
@@ -139,9 +139,7 @@ pub async fn stop_screenpipe(
{
// -15 from gnu man page
// ref: https://www.gnu.org/software/coreutils/manual/html_node/kill-invocation.html
- let command = format!(
- "pgrep -x screenpipe | xargs -I {{}} kill -15 {{}}",
- );
+ let command = format!("pgrep -x screenpipe | xargs -I {{}} kill -15 {{}}",);
match tokio::process::Command::new("sh")
.arg("-c")
.arg(command)
@@ -178,7 +176,10 @@ pub async fn spawn_screenpipe(
}
}
-fn spawn_sidecar(app: &tauri::AppHandle, override_args: Option<Vec<String>>) -> Result<CommandChild, String> {
+fn spawn_sidecar(
+ app: &tauri::AppHandle,
+ override_args: Option<Vec<String>>,
+) -> Result<CommandChild, String> {
let store = get_store(app, None).unwrap();
let audio_transcription_engine = store
@@ -301,7 +302,7 @@ fn spawn_sidecar(app: &tauri::AppHandle, override_args: Option<Vec<String>>) ->
println!("audio_chunk_duration: {}", audio_chunk_duration);
let port_str = port.to_string();
- let mut args = vec!["--port", port_str.as_str()];
+ let mut args = vec!["--port", port_str.as_str(), "--enable-pipe-manager"];
let fps_str = fps.to_string();
if fps != 0.2 {
args.push("--fps");
@@ -463,7 +464,9 @@ fn spawn_sidecar(app: &tauri::AppHandle, override_args: Option<Vec<String>>) ->
c = c.env("SENTRY_RELEASE_NAME_APPEND", "tauri");
// only supports --enable-realtime-vision for now, avoid adding if already present
- if !args.contains(&"--enable-realtime-vision") && override_args_as_vec.contains(&"--enable-realtime-vision".to_string()) {
+ if !args.contains(&"--enable-realtime-vision")
+ && override_args_as_vec.contains(&"--enable-realtime-vision".to_string())
+ {
args.extend(override_args_as_vec.iter().map(|s| s.as_str()));
}
let c = c.args(&args);
@@ -507,7 +510,9 @@ fn spawn_sidecar(app: &tauri::AppHandle, override_args: Option<Vec<String>>) ->
c = c.env("SENTRY_RELEASE_NAME_APPEND", "tauri");
// only supports --enable-realtime-vision for now, avoid adding if already present
- if !args.contains(&"--enable-realtime-vision") && override_args_as_vec.contains(&"--enable-realtime-vision".to_string()) {
+ if !args.contains(&"--enable-realtime-vision")
+ && override_args_as_vec.contains(&"--enable-realtime-vision".to_string())
+ {
args.extend(override_args_as_vec.iter().map(|s| s.as_str()));
}
let c = c.args(&args);
@@ -558,7 +563,11 @@ impl SidecarManager {
}
}
- pub async fn spawn(&mut self, app: &tauri::AppHandle, override_args: Option<Vec<String>>) -> Result<(), String> {
+ pub async fn spawn(
+ &mut self,
+ app: &tauri::AppHandle,
+ override_args: Option<Vec<String>>,
+ ) -> Result<(), String> {
info!("Spawning sidecar with override args: {:?}", override_args);
// Update settings from store
self.update_settings(app).await?;
diff --git a/screenpipe-server/src/bin/screenpipe-server.rs b/screenpipe-server/src/bin/screenpipe-server.rs
index 36b6dee2a..6adf6b36b 100644
--- a/screenpipe-server/src/bin/screenpipe-server.rs
+++ b/screenpipe-server/src/bin/screenpipe-server.rs
@@ -235,7 +235,12 @@ async fn main() -> anyhow::Result<()> {
None
};
- let pipe_manager = Arc::new(PipeManager::new(local_data_dir_clone.clone()));
+ let pipe_manager = if cli.enable_pipe_manager {
+ Arc::new(PipeManager::new(local_data_dir_clone.clone()))
+ } else {
+ Arc::new(PipeManager::new(PathBuf::from("")))
+ };
+
if let Some(ref command) = cli.command {
match command {
Command::Audio { subcommand } => match subcommand {
@@ -302,7 +307,7 @@ async fn main() -> anyhow::Result<()> {
return Ok(());
}
Command::Pipe { subcommand } => {
- handle_pipe_command(subcommand, &pipe_manager).await?;
+ handle_pipe_command(subcommand, &pipe_manager, cli.enable_pipe_manager).await?;
return Ok(());
}
Command::Migrate {
@@ -752,6 +757,7 @@ async fn main() -> anyhow::Result<()> {
cli.disable_audio,
cli.enable_ui_monitoring,
audio_manager.clone(),
+ cli.enable_pipe_manager,
);
// print screenpipe in gradient
@@ -1169,7 +1175,14 @@ async fn main() -> anyhow::Result<()> {
async fn handle_pipe_command(
command: &PipeCommand,
pipe_manager: &Arc<PipeManager>,
+ enable_pipe_manager: bool,
) -> anyhow::Result<()> {
+
+ if !enable_pipe_manager {
+ println!("note: pipe functionality is disabled");
+ return Ok(());
+ }
+
let client = reqwest::Client::new();
let server_url = "http://localhost";
diff --git a/screenpipe-server/src/cli.rs b/screenpipe-server/src/cli.rs
index 2bc48271d..503f0a837 100644
--- a/screenpipe-server/src/cli.rs
+++ b/screenpipe-server/src/cli.rs
@@ -281,6 +281,10 @@ pub struct Cli {
#[arg(long, default_value_t = false)]
pub capture_unfocused_windows: bool,
+ /// Enable pipe functionality (default: false)
+ #[arg(long, default_value_t = false)]
+ pub enable_pipe_manager: bool,
+
#[command(subcommand)]
pub command: Option<Command>,
diff --git a/screenpipe-server/src/server.rs b/screenpipe-server/src/server.rs
index 8265f593d..e8c727e4d 100644
--- a/screenpipe-server/src/server.rs
+++ b/screenpipe-server/src/server.rs
@@ -92,6 +92,7 @@ pub struct AppState {
pub vision_disabled: bool,
pub audio_disabled: bool,
pub ui_monitoring_enabled: bool,
+ pub enable_pipe_manager: bool,
pub frame_cache: Option<Arc<FrameCache>>,
pub frame_image_cache: Option<Arc<Mutex<FrameImageCache>>>,
pub element_cache: Arc<Mutex<Option<(Vec<UIElement>, Instant, String)>>>,
@@ -828,6 +829,15 @@ async fn download_pipe_handler(
State(state): State<Arc<AppState>>,
JsonResponse(payload): JsonResponse<DownloadPipeRequest>,
) -> Result<JsonResponse<serde_json::Value>, (StatusCode, JsonResponse<Value>)> {
+ if !state.enable_pipe_manager {
+ return Err((
+ StatusCode::FORBIDDEN,
+ JsonResponse(json!({
+ "error": "pipe functionality is disabled",
+ "success": false
+ })),
+ ));
+ }
debug!("Downloading pipe: {}", payload.url);
match state.pipe_manager.download_pipe(&payload.url).await {
Ok(pipe_dir) => Ok(JsonResponse(json!({
@@ -855,6 +865,15 @@ async fn download_pipe_private_handler(
State(state): State<Arc<AppState>>,
JsonResponse(payload): JsonResponse<DownloadPipePrivateRequest>,
) -> Result<JsonResponse<serde_json::Value>, (StatusCode, JsonResponse<Value>)> {
+ if !state.enable_pipe_manager {
+ return Err((
+ StatusCode::FORBIDDEN,
+ JsonResponse(json!({
+ "error": "pipe functionality is disabled",
+ "success": false
+ })),
+ ));
+ }
match state
.pipe_manager
.download_pipe_private(&payload.url, &payload.pipe_name, &payload.pipe_id)
@@ -885,6 +904,15 @@ async fn run_pipe_handler(
State(state): State<Arc<AppState>>,
JsonResponse(payload): JsonResponse<RunPipeRequest>,
) -> Result<JsonResponse<Value>, (StatusCode, JsonResponse<Value>)> {
+ if !state.enable_pipe_manager {
+ return Err((
+ StatusCode::FORBIDDEN,
+ JsonResponse(json!({
+ "error": "pipe functionality is disabled",
+ "success": false
+ })),
+ ));
+ }
debug!("starting pipe: {}", payload.pipe_id);
match state
@@ -919,6 +947,15 @@ async fn stop_pipe_handler(
State(state): State<Arc<AppState>>,
JsonResponse(payload): JsonResponse<RunPipeRequest>,
) -> Result<JsonResponse<Value>, (StatusCode, JsonResponse<Value>)> {
+ if !state.enable_pipe_manager {
+ return Err((
+ StatusCode::FORBIDDEN,
+ JsonResponse(json!({
+ "error": "pipe functionality is disabled",
+ "success": false
+ })),
+ ));
+ }
debug!("Stopping pipe: {}", payload.pipe_id);
match state
.pipe_manager
@@ -952,7 +989,16 @@ async fn update_pipe_config_handler(
State(state): State<Arc<AppState>>,
JsonResponse(payload): JsonResponse<UpdatePipeConfigRequest>,
) -> Result<JsonResponse<Value>, (StatusCode, JsonResponse<Value>)> {
- debug!("Updating pipe config for: {}", payload.pipe_id);
+ if !state.enable_pipe_manager {
+ return Err((
+ StatusCode::FORBIDDEN,
+ JsonResponse(json!({
+ "error": "pipe functionality is disabled",
+ "success": false
+ })),
+ ));
+ }
+ debug!("Updating pipe config: {}", payload.pipe_id);
match state
.pipe_manager
.update_config(&payload.pipe_id, payload.config)
@@ -980,7 +1026,16 @@ async fn update_pipe_version_handler(
State(state): State<Arc<AppState>>,
JsonResponse(payload): JsonResponse<UpdatePipeVersionRequest>,
) -> Result<JsonResponse<Value>, (StatusCode, JsonResponse<Value>)> {
- debug!("Updating pipe version for: {}", payload.pipe_id);
+ if !state.enable_pipe_manager {
+ return Err((
+ StatusCode::FORBIDDEN,
+ JsonResponse(json!({
+ "error": "pipe functionality is disabled",
+ "success": false
+ })),
+ ));
+ }
+ debug!("Updating pipe version: {}", payload.pipe_id);
match state
.pipe_manager
.update_pipe_version(&payload.pipe_id, &payload.source)
@@ -1008,6 +1063,15 @@ async fn get_pipe_info_handler(
State(state): State<Arc<AppState>>,
Path(pipe_id): Path<String>,
) -> Result<JsonResponse<Value>, (StatusCode, JsonResponse<Value>)> {
+ if !state.enable_pipe_manager {
+ return Err((
+ StatusCode::FORBIDDEN,
+ JsonResponse(json!({
+ "error": "pipe functionality is disabled",
+ "success": false
+ })),
+ ));
+ }
debug!("Getting pipe info for: {}", pipe_id);
match state.pipe_manager.get_pipe_info(&pipe_id).await {
Some(info) => Ok(JsonResponse(json!({
@@ -1025,12 +1089,21 @@ async fn get_pipe_info_handler(
}
#[oasgen]
-async fn list_pipes_handler(State(state): State<Arc<AppState>>) -> JsonResponse<Value> {
+async fn list_pipes_handler(State(state): State<Arc<AppState>>) -> Result<JsonResponse<Value>, (StatusCode, JsonResponse<Value>)> {
+ if !state.enable_pipe_manager {
+ return Err((
+ StatusCode::FORBIDDEN,
+ JsonResponse(json!({
+ "error": "pipe functionality is disabled",
+ "success": false
+ })),
+ ));
+ }
let pipes = state.pipe_manager.list_pipes().await;
- JsonResponse(json!({
+ Ok(JsonResponse(json!({
"data": pipes,
"success": true
- }))
+ })))
}
pub struct SCServer {
@@ -1042,6 +1115,7 @@ pub struct SCServer {
vision_disabled: bool,
audio_disabled: bool,
ui_monitoring_enabled: bool,
+ enable_pipe: bool,
}
impl SCServer {
@@ -1055,6 +1129,7 @@ impl SCServer {
audio_disabled: bool,
ui_monitoring_enabled: bool,
audio_manager: Arc<AudioManager>,
+ enable_pipe: bool,
) -> Self {
SCServer {
db,
@@ -1065,6 +1140,7 @@ impl SCServer {
audio_disabled,
ui_monitoring_enabled,
audio_manager,
+ enable_pipe,
}
}
@@ -1097,6 +1173,7 @@ impl SCServer {
vision_disabled: self.vision_disabled,
audio_disabled: self.audio_disabled,
ui_monitoring_enabled: self.ui_monitoring_enabled,
+ enable_pipe_manager: self.enable_pipe,
frame_cache: if enable_frame_cache {
Some(Arc::new(
FrameCache::new(self.screenpipe_dir.clone().join("data"), self.db.clone())
@@ -2538,46 +2615,20 @@ async fn get_pipe_build_status(
Path(pipe_id): Path<String>,
State(state): State<Arc<AppState>>,
) -> Result<JsonResponse<Value>, (StatusCode, JsonResponse<Value>)> {
+ if !state.enable_pipe_manager {
+ return Err((
+ StatusCode::FORBIDDEN,
+ JsonResponse(json!({
+ "error": "pipe functionality is disabled",
+ "success": false
+ })),
+ ));
+ }
let pipe_dir = state.screenpipe_dir.join("pipes").join(&pipe_id);
- let update_temp_dir = std::env::temp_dir().join(format!("{}_update", pipe_id));
- let temp_dir = pipe_dir.with_extension("_temp");
-
- // 1. First check if the update temp directory exists
- if update_temp_dir.exists() {
- debug!("Update temp directory exists for pipe: {}", pipe_id);
-
- // Check if there's a pipe.json in the update temp directory
- let update_pipe_json_path = update_temp_dir.join("pipe.json");
- if update_pipe_json_path.exists() {
- let pipe_json = tokio::fs::read_to_string(&update_pipe_json_path)
- .await
- .map_err(|e| {
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- JsonResponse(json!({"error": format!("Failed to read update temp pipe config: {}", e)})),
- )
- })?;
-
- let pipe_config: Value = serde_json::from_str(&pipe_json).map_err(|e| {
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- JsonResponse(
- json!({"error": format!("Failed to parse update temp pipe config: {}", e)}),
- ),
- )
- })?;
-
- // Return the buildStatus if it exists
- if let Some(build_status) = pipe_config.get("buildStatus") {
- debug!(
- "Found build status in update temp directory for pipe: {}",
- pipe_id
- );
- return Ok(JsonResponse(build_status.clone()));
- }
- }
- // If no buildStatus found in update temp directory, return a default in_progress status
+ // 1. First check if there's a lock file
+ let lock_file = pipe_dir.join(".download.lock");
+ if lock_file.exists() {
return Ok(JsonResponse(json!({
"status": "in_progress",
"step": "downloading",
@@ -2628,8 +2679,8 @@ async fn get_pipe_build_status(
}
} else {
// If pipe directory doesn't exist, check temp directory
- if temp_dir.exists() {
- let temp_pipe_json = temp_dir.join("pipe.json");
+ if pipe_dir.exists() {
+ let temp_pipe_json = pipe_dir.join("pipe.json");
if temp_pipe_json.exists() {
let pipe_json = tokio::fs::read_to_string(&temp_pipe_json)
.await
@@ -3040,21 +3091,30 @@ pub async fn delete_pipe_handler(
State(state): State<Arc<AppState>>,
Json(request): Json<DeletePipeRequest>,
) -> Result<JsonResponse<Value>, (StatusCode, JsonResponse<Value>)> {
+ if !state.enable_pipe_manager {
+ return Err((
+ StatusCode::FORBIDDEN,
+ JsonResponse(json!({
+ "error": "pipe functionality is disabled",
+ "success": false
+ })),
+ ));
+ }
match state.pipe_manager.delete_pipe(&request.pipe_id).await {
Ok(_) => Ok(JsonResponse(json!({
- "success": true,
- "message": "pipe deleted successfully"
+ "data": {
+ "pipe_id": request.pipe_id,
+ "message": "pipe deleted"
+ },
+ "success": true
}))),
- Err(e) => {
- error!("failed to delete pipe: {}", e);
- Err((
- StatusCode::INTERNAL_SERVER_ERROR,
- JsonResponse(json!({
- "success": false,
- "error": format!("failed to delete pipe: {}", e)
- })),
- ))
- }
+ Err(e) => Err((
+ StatusCode::BAD_REQUEST,
+ JsonResponse(json!({
+ "error": format!("failed to delete pipe: {}", e),
+ "success": false
+ })),
+ )),
}
}
@@ -3063,21 +3123,29 @@ pub async fn purge_pipe_handler(
State(state): State<Arc<AppState>>,
Json(_request): Json<PurgePipeRequest>,
) -> Result<JsonResponse<Value>, (StatusCode, JsonResponse<Value>)> {
+ if !state.enable_pipe_manager {
+ return Err((
+ StatusCode::FORBIDDEN,
+ JsonResponse(json!({
+ "error": "pipe functionality is disabled",
+ "success": false
+ })),
+ ));
+ }
match state.pipe_manager.purge_pipes().await {
Ok(_) => Ok(JsonResponse(json!({
- "success": true,
- "message": "pipes purged successfully"
+ "data": {
+ "message": "all pipes purged"
+ },
+ "success": true
}))),
- Err(e) => {
- error!("failed to purge pipes: {}", e);
- Err((
- StatusCode::INTERNAL_SERVER_ERROR,
- JsonResponse(json!({
- "success": false,
- "error": format!("failed to purge pipes: {}", e)
- })),
- ))
- }
+ Err(e) => Err((
+ StatusCode::BAD_REQUEST,
+ JsonResponse(json!({
+ "error": format!("failed to purge pipes: {}", e),
+ "success": false
+ })),
+ )),
}
}
diff --git a/screenpipe-server/tests/endpoint_test.rs b/screenpipe-server/tests/endpoint_test.rs
index 9d55d40b6..58ff58658 100644
--- a/screenpipe-server/tests/endpoint_test.rs
+++ b/screenpipe-server/tests/endpoint_test.rs
@@ -48,6 +48,7 @@ mod tests {
false,
false,
audio_manager,
+ true
);
let router = app.create_router(true).await;
diff --git a/screenpipe-server/tests/tags_test.rs b/screenpipe-server/tests/tags_test.rs
index 309000bb4..a7c21e72b 100644
--- a/screenpipe-server/tests/tags_test.rs
+++ b/screenpipe-server/tests/tags_test.rs
@@ -37,6 +37,7 @@ async fn setup_test_app() -> (Router, Arc<DatabaseManager>) {
false,
false,
audio_manager,
+ true,
);
let router = app.create_router(true).await;