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

fix(cli): screenpipe connection list now shows browsers from running engine

Louis Beaumontd11ac566e556
diff --git a/Cargo.lock b/Cargo.lock
index a97939fcc..971ba729d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6870,7 +6870,7 @@ dependencies = [
[[package]]
name = "screenpipe-audio"
-version = "0.3.299"
+version = "0.3.300"
dependencies = [
"anyhow",
"audiopipe",
@@ -6931,7 +6931,7 @@ dependencies = [
[[package]]
name = "screenpipe-config"
-version = "0.3.299"
+version = "0.3.300"
dependencies = [
"dirs 6.0.0",
"serde",
@@ -6944,7 +6944,7 @@ dependencies = [
[[package]]
name = "screenpipe-connect"
-version = "0.3.299"
+version = "0.3.300"
dependencies = [
"anyhow",
"async-trait",
@@ -6976,7 +6976,7 @@ dependencies = [
[[package]]
name = "screenpipe-core"
-version = "0.3.299"
+version = "0.3.300"
dependencies = [
"accessibility",
"accessibility-sys",
@@ -7024,7 +7024,7 @@ dependencies = [
[[package]]
name = "screenpipe-db"
-version = "0.3.299"
+version = "0.3.300"
dependencies = [
"anyhow",
"chrono",
@@ -7050,7 +7050,7 @@ dependencies = [
[[package]]
name = "screenpipe-engine"
-version = "0.3.299"
+version = "0.3.300"
dependencies = [
"anyhow",
"arc-swap",
@@ -7122,7 +7122,7 @@ dependencies = [
[[package]]
name = "screenpipe-events"
-version = "0.3.299"
+version = "0.3.300"
dependencies = [
"anyhow",
"chrono",
@@ -7140,7 +7140,7 @@ dependencies = [
[[package]]
name = "screenpipe-screen"
-version = "0.3.299"
+version = "0.3.300"
dependencies = [
"accessibility-sys",
"anyhow",
@@ -7198,7 +7198,7 @@ dependencies = [
[[package]]
name = "screenpipe-vault"
-version = "0.3.299"
+version = "0.3.300"
dependencies = [
"argon2",
"chacha20poly1305",
diff --git a/Cargo.toml b/Cargo.toml
index 938e4bc0d..b535ade86 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,7 +6,7 @@ exclude = ["apps/screenpipe-app-tauri/src-tauri", "crates/screenpipe-integration
resolver = "2"
[workspace.package]
-version = "0.3.299"
+version = "0.3.300"
authors = ["louis030195 <[email protected]>"]
description = ""
repository = "https://github.com/screenpipe/screenpipe"
diff --git a/crates/screenpipe-engine/src/cli/connection.rs b/crates/screenpipe-engine/src/cli/connection.rs
index d174830f6..8bf4d27a6 100644
--- a/crates/screenpipe-engine/src/cli/connection.rs
+++ b/crates/screenpipe-engine/src/cli/connection.rs
@@ -37,6 +37,12 @@ pub async fn handle_connection_command(command: &ConnectionCommand) -> anyhow::R
let cm = ConnectionManager::new(screenpipe_dir.clone(), secret_store);
+ // Fetch browsers from the running engine — they live in the in-memory
+ // BrowserRegistry, not on disk, so the CLI must ask the server. Empty
+ // when no server is running, which is fine: a CLI-only invocation
+ // without a daemon has no real "browsers" to report.
+ let browsers = fetch_running_browsers().await;
+
match command {
ConnectionCommand::List { json: use_json } => {
let list = cm.list().await;
@@ -80,6 +86,14 @@ pub async fn handle_connection_command(command: &ConnectionCommand) -> anyhow::R
"description": wa_desc,
"connected": wa_connected,
}));
+ for b in &browsers {
+ items.push(json!({
+ "id": b.id,
+ "name": b.name,
+ "description": b.description,
+ "connected": b.ready,
+ }));
+ }
println!("{}", serde_json::to_string_pretty(&items)?);
} else {
println!("{:<20} {:<12} {:<40}", "ID", "STATUS", "NAME");
@@ -90,6 +104,10 @@ pub async fn handle_connection_command(command: &ConnectionCommand) -> anyhow::R
}
let wa_status = if wa_connected { "connected" } else { "-" };
println!("{:<20} {:<12} {:<40}", "whatsapp", wa_status, "WhatsApp");
+ for b in &browsers {
+ let status = if b.ready { "connected" } else { "-" };
+ println!("{:<20} {:<12} {:<40}", b.id, status, b.name);
+ }
}
}
@@ -223,3 +241,58 @@ pub async fn handle_connection_command(command: &ConnectionCommand) -> anyhow::R
Ok(())
}
+
+// ---------------------------------------------------------------------------
+// Browser registry — the engine's in-memory browser list. Lives only in the
+// running server, so the CLI must ask over HTTP. Empty result is fine: it
+// just means no engine is reachable, in which case "browsers" wouldn't have
+// real status anyway.
+// ---------------------------------------------------------------------------
+
+#[derive(serde::Deserialize, Debug)]
+struct BrowserSummaryWire {
+ id: String,
+ name: String,
+ description: String,
+ ready: bool,
+}
+
+#[derive(serde::Deserialize)]
+struct BrowsersResponse {
+ data: Vec<BrowserSummaryWire>,
+}
+
+async fn fetch_running_browsers() -> Vec<BrowserSummaryWire> {
+ // Honor the same auth knobs as the rest of the CLI: API_KEY env var,
+ // then the file fallback. If we can't read it, the engine returns 403
+ // and we silently degrade to "no browsers known" rather than spamming
+ // an error — the user's `connection list` is still useful.
+ let auth_token = std::env::var("SCREENPIPE_API_KEY")
+ .ok()
+ .or_else(read_auth_key_file);
+
+ let client = reqwest::Client::new();
+ let mut req = client
+ .get("http://localhost:3030/connections/browsers")
+ .timeout(std::time::Duration::from_secs(2));
+ if let Some(t) = auth_token {
+ req = req.header("Authorization", format!("Bearer {t}"));
+ }
+
+ match req.send().await {
+ Ok(resp) if resp.status().is_success() => match resp.json::<BrowsersResponse>().await {
+ Ok(body) => body.data,
+ Err(_) => Vec::new(),
+ },
+ _ => Vec::new(),
+ }
+}
+
+fn read_auth_key_file() -> Option<String> {
+ let path = screenpipe_core::paths::default_screenpipe_data_dir().join("auth.json");
+ let body = std::fs::read_to_string(path).ok()?;
+ let v: serde_json::Value = serde_json::from_str(&body).ok()?;
+ v.get("api_key")
+ .and_then(|s| s.as_str())
+ .map(|s| s.to_string())
+}