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

release-app feat: add endpoint to start and stop sidecar for pipes

Louis Beaumont6e9eff01d5af
diff --git a/pipes/meeting/package.json b/pipes/meeting/package.json
index bb411ee2f..ea4846549 100644
--- a/pipes/meeting/package.json
+++ b/pipes/meeting/package.json
@@ -1,6 +1,6 @@
{
"name": "meeting",
- "version": "0.1.1",
+ "version": "0.1.3",
"private": true,
"repository": {
"type": "git",
diff --git a/screenpipe-app-tauri/app/page.tsx b/screenpipe-app-tauri/app/page.tsx
index 97d2f629c..00a02542f 100644
--- a/screenpipe-app-tauri/app/page.tsx
+++ b/screenpipe-app-tauri/app/page.tsx
@@ -98,7 +98,7 @@ export default function Home() {
}),
listen("shortcut-stop-recording", async () => {
- await invoke("kill_all_sreenpipes");
+ await invoke("stop_screenpipe");
toast({
title: "recording stopped",
@@ -115,7 +115,7 @@ export default function Home() {
description: `switched to ${profile} profile, restarting screenpipe now`,
});
- await invoke("kill_all_sreenpipes");
+ await invoke("stop_screenpipe");
await new Promise((resolve) => setTimeout(resolve, 1000));
diff --git a/screenpipe-app-tauri/components/dev-mode-settings.tsx b/screenpipe-app-tauri/components/dev-mode-settings.tsx
index f932d1036..475e12cc5 100644
--- a/screenpipe-app-tauri/components/dev-mode-settings.tsx
+++ b/screenpipe-app-tauri/components/dev-mode-settings.tsx
@@ -152,7 +152,7 @@ export const DevModeSettings = ({ localDataDir }: { localDataDir: string }) => {
duration: Infinity,
});
try {
- await invoke("kill_all_sreenpipes");
+ await invoke("stop_screenpipe");
await new Promise((resolve) => setTimeout(resolve, 2000));
toastId.update({
id: toastId.id,
diff --git a/screenpipe-app-tauri/components/onboarding/pipe-store.tsx b/screenpipe-app-tauri/components/onboarding/pipe-store.tsx
index 66644dbb0..60126fc06 100644
--- a/screenpipe-app-tauri/components/onboarding/pipe-store.tsx
+++ b/screenpipe-app-tauri/components/onboarding/pipe-store.tsx
@@ -39,7 +39,7 @@ const OnboardingPipeStore: React.FC<OnboardingPipeStoreProps> = ({
await fetch("http://localhost:3030/health");
} catch (error) {
// Screenpipe not running, try to spawn it
- await invoke("kill_all_sreenpipes");
+ await invoke("stop_screenpipe");
await new Promise((resolve) => setTimeout(resolve, 1_000));
await invoke("spawn_screenpipe");
await new Promise((resolve) => setTimeout(resolve, 5_000));
diff --git a/screenpipe-app-tauri/components/onboarding/status.tsx b/screenpipe-app-tauri/components/onboarding/status.tsx
index fffb348ac..946a96907 100644
--- a/screenpipe-app-tauri/components/onboarding/status.tsx
+++ b/screenpipe-app-tauri/components/onboarding/status.tsx
@@ -227,7 +227,7 @@ const OnboardingStatus: React.FC<OnboardingStatusProps> = ({
duration: Infinity,
});
try {
- await invoke("kill_all_sreenpipes");
+ await invoke("stop_screenpipe");
await new Promise((resolve) => setTimeout(resolve, 1_000));
await invoke("spawn_screenpipe");
diff --git a/screenpipe-app-tauri/components/recording-settings.tsx b/screenpipe-app-tauri/components/recording-settings.tsx
index 0c7c30b6e..ce8840dbe 100644
--- a/screenpipe-app-tauri/components/recording-settings.tsx
+++ b/screenpipe-app-tauri/components/recording-settings.tsx
@@ -314,7 +314,7 @@ export function RecordingSettings() {
}
}
- await invoke("kill_all_sreenpipes");
+ await invoke("stop_screenpipe");
await new Promise((resolve) => setTimeout(resolve, 1000));
// Start a new instance with updated settings
diff --git a/screenpipe-app-tauri/components/settings.tsx b/screenpipe-app-tauri/components/settings.tsx
index e758d073d..171fa174b 100644
--- a/screenpipe-app-tauri/components/settings.tsx
+++ b/screenpipe-app-tauri/components/settings.tsx
@@ -66,7 +66,7 @@ export function Settings() {
title: "Restarting Screenpipe",
description: "Please wait while we restart Screenpipe",
});
- await invoke("kill_all_sreenpipes");
+ await invoke("stop_screenpipe");
await new Promise((resolve) => setTimeout(resolve, 1000));
diff --git a/screenpipe-app-tauri/components/updater.tsx b/screenpipe-app-tauri/components/updater.tsx
index c946c87fb..bea1c8932 100644
--- a/screenpipe-app-tauri/components/updater.tsx
+++ b/screenpipe-app-tauri/components/updater.tsx
@@ -1,4 +1,4 @@
-import { check, } from "@tauri-apps/plugin-updater";
+import { check } from "@tauri-apps/plugin-updater";
import { ask, message } from "@tauri-apps/plugin-dialog";
import { relaunch } from "@tauri-apps/plugin-process";
import { invoke } from "@tauri-apps/api/core";
@@ -25,7 +25,7 @@ Release notes: ${update.body}
// on windows only - TODO shouldnt be necessary
const os = platform();
if (os === "windows") {
- await invoke("kill_all_sreenpipes");
+ await invoke("stop_screenpipe");
}
const toastId = toast({
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.lock b/screenpipe-app-tauri/src-tauri/Cargo.lock
index d5fdc0b54..8842c90ff 100755
--- a/screenpipe-app-tauri/src-tauri/Cargo.lock
+++ b/screenpipe-app-tauri/src-tauri/Cargo.lock
@@ -5289,7 +5289,7 @@ dependencies = [
[[package]]
name = "screenpipe-app"
-version = "0.31.7"
+version = "0.31.9"
dependencies = [
"anyhow",
"async-stream",
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.toml
index 4202cb760..08673027c 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 = "0.31.9"
+version = "0.32.0"
description = ""
authors = ["you"]
license = ""
diff --git a/screenpipe-app-tauri/src-tauri/src/main.rs b/screenpipe-app-tauri/src-tauri/src/main.rs
index ceb45b5aa..1ef54a34a 100755
--- a/screenpipe-app-tauri/src-tauri/src/main.rs
+++ b/screenpipe-app-tauri/src-tauri/src/main.rs
@@ -46,7 +46,7 @@ pub use commands::reset_all_pipes;
pub use commands::set_tray_health_icon;
pub use commands::set_tray_unhealth_icon;
pub use server::spawn_server;
-pub use sidecar::kill_all_sreenpipes;
+pub use sidecar::stop_screenpipe;
pub use sidecar::spawn_screenpipe;
pub use store::get_profiles_store;
pub use store::get_store;
@@ -613,7 +613,7 @@ async fn main() {
.manage(sidecar_state)
.invoke_handler(tauri::generate_handler![
spawn_screenpipe,
- kill_all_sreenpipes,
+ stop_screenpipe,
permissions::open_permission_settings,
permissions::request_permission,
permissions::do_permissions_check,
diff --git a/screenpipe-app-tauri/src-tauri/src/server.rs b/screenpipe-app-tauri/src-tauri/src/server.rs
index 8e160f315..5fcfa4672 100644
--- a/screenpipe-app-tauri/src-tauri/src/server.rs
+++ b/screenpipe-app-tauri/src-tauri/src/server.rs
@@ -159,6 +159,8 @@ pub async fn run_server(app_handle: tauri::AppHandle, port: u16) {
.route("/app-icon", axum::routing::get(get_app_icon_handler))
.route("/window-size", axum::routing::post(set_window_size))
.route("/sse/settings", axum::routing::get(settings_stream))
+ .route("/sidecar/start", axum::routing::post(start_sidecar))
+ .route("/sidecar/stop", axum::routing::post(stop_sidecar))
.layer(cors)
.layer(
TraceLayer::new_for_http()
@@ -351,6 +353,54 @@ async fn set_window_size(
}
}
+async fn start_sidecar(
+ State(state): State<ServerState>,
+) -> Result<Json<ApiResponse>, (StatusCode, String)> {
+ info!("received request to start sidecar");
+
+ let app_handle = state.app_handle.clone();
+ match crate::sidecar::spawn_screenpipe(
+ app_handle.clone().state::<crate::SidecarState>(),
+ app_handle,
+ ).await {
+ Ok(_) => Ok(Json(ApiResponse {
+ success: true,
+ message: "sidecar started successfully".to_string(),
+ })),
+ Err(e) => {
+ error!("failed to start sidecar: {}", e);
+ Err((
+ StatusCode::INTERNAL_SERVER_ERROR,
+ format!("failed to start sidecar: {}", e),
+ ))
+ }
+ }
+}
+
+async fn stop_sidecar(
+ State(state): State<ServerState>,
+) -> Result<Json<ApiResponse>, (StatusCode, String)> {
+ info!("received request to stop sidecar");
+
+ let app_handle = state.app_handle.clone();
+ match crate::sidecar::stop_screenpipe(
+ app_handle.clone().state::<crate::SidecarState>(),
+ app_handle,
+ ).await {
+ Ok(_) => Ok(Json(ApiResponse {
+ success: true,
+ message: "sidecar stopped successfully".to_string(),
+ })),
+ Err(e) => {
+ error!("failed to stop sidecar: {}", e);
+ Err((
+ StatusCode::INTERNAL_SERVER_ERROR,
+ format!("failed to stop sidecar: {}", e),
+ ))
+ }
+ }
+}
+
pub fn spawn_server(app_handle: tauri::AppHandle, port: u16) -> mpsc::Sender<()> {
let (tx, mut rx) = mpsc::channel(1);
diff --git a/screenpipe-app-tauri/src-tauri/src/sidecar.rs b/screenpipe-app-tauri/src-tauri/src/sidecar.rs
index 3c3da2ceb..435727fcf 100644
--- a/screenpipe-app-tauri/src-tauri/src/sidecar.rs
+++ b/screenpipe-app-tauri/src-tauri/src/sidecar.rs
@@ -78,7 +78,7 @@ impl User {
}
#[tauri::command]
-pub async fn kill_all_sreenpipes(
+pub async fn stop_screenpipe(
state: State<'_, SidecarState>,
_app: tauri::AppHandle,
) -> Result<(), String> {
diff --git a/screenpipe-app-tauri/src-tauri/src/updates.rs b/screenpipe-app-tauri/src-tauri/src/updates.rs
index b2cc73a94..eb055d9bf 100644
--- a/screenpipe-app-tauri/src-tauri/src/updates.rs
+++ b/screenpipe-app-tauri/src-tauri/src/updates.rs
@@ -1,4 +1,4 @@
-use crate::kill_all_sreenpipes;
+use crate::stop_screenpipe;
use crate::SidecarState;
use anyhow::Error;
use log::{error, info};
@@ -107,7 +107,7 @@ impl UpdatesManager {
.set_text("downloading latest version of screenpipe")?;
if let Err(err) =
- kill_all_sreenpipes(self.app.state::<SidecarState>(), self.app.clone())
+ stop_screenpipe(self.app.state::<SidecarState>(), self.app.clone())
.await
{
error!("Failed to kill sidecar: {}", err);
@@ -131,7 +131,7 @@ impl UpdatesManager {
#[cfg(not(target_os = "windows"))]
{
if let Err(err) =
- kill_all_sreenpipes(self.app.state::<SidecarState>(), self.app.clone())
+ stop_screenpipe(self.app.state::<SidecarState>(), self.app.clone())
.await
{
error!("Failed to kill sidecar: {}", err);