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
fix: CLI shows WhatsApp by checking session on disk, no API call needed
Louis Beaumont5eb6f10b07ba
diff --git a/crates/screenpipe-engine/src/cli/connection.rs b/crates/screenpipe-engine/src/cli/connection.rsindex 63ff9f0bf..6af4ed87c 100644--- a/crates/screenpipe-engine/src/cli/connection.rs+++ b/crates/screenpipe-engine/src/cli/connection.rs@@ -6,40 +6,6 @@ use super::ConnectionCommand;use screenpipe_connect::connections::ConnectionManager;use serde_json::{json, Map, Value};-/// Try to get connection list from the running server (includes WhatsApp etc).-/// Falls back to local ConnectionManager if the server isn't reachable.-async fn fetch_connections_list(- screenpipe_dir: &std::path::Path,-) -> Vec<Value> {- // Try the running server first — it includes dynamic integrations like WhatsApp- if let Ok(resp) = reqwest::Client::new()- .get("http://localhost:3030/connections")- .timeout(std::time::Duration::from_secs(2))- .send()- .await- {- if let Ok(body) = resp.json::<Value>().await {- if let Some(arr) = body.get("data").and_then(|d| d.as_array()) {- return arr.clone();- }- }- }-- // Fallback: use local ConnectionManager (no WhatsApp / dynamic integrations)- let cm = ConnectionManager::new(screenpipe_dir.to_path_buf());- cm.list()- .into_iter()- .map(|info| {- json!({- "id": info.def.id,- "name": info.def.name,- "description": info.def.description,- "connected": info.connected,- })- })- .collect()-}-/// Handle connection subcommands (standalone — does NOT require a running server).pub async fn handle_connection_command(command: &ConnectionCommand) -> anyhow::Result<()> {let screenpipe_dir = dirs::home_dir()@@ -50,36 +16,81 @@ pub async fn handle_connection_command(command: &ConnectionCommand) -> anyhow::Rmatch command {ConnectionCommand::List { json: use_json } => {- let list = fetch_connections_list(&screenpipe_dir).await;+ let mut list = cm.list();++ // Add WhatsApp — check session on disk+ let wa_connected = screenpipe_dir+ .join("whatsapp-session")+ .join("creds.json")+ .exists();+ let wa_desc = if wa_connected {+ "Send messages: curl -X POST http://localhost:3035/send -H 'Content-Type: application/json' -d '{\"to\":\"PHONE\",\"text\":\"MSG\"}'".to_string()+ } else {+ "Pair via Settings > Connections in the desktop app".to_string()+ };+if *use_json {- println!("{}", serde_json::to_string_pretty(&list)?);- } else if list.is_empty() {- println!("no connections available");+ let mut items: Vec<Value> = list+ .iter()+ .map(|info| {+ json!({+ "id": info.def.id,+ "name": info.def.name,+ "description": info.def.description,+ "connected": info.connected,+ })+ })+ .collect();+ items.push(json!({+ "id": "whatsapp",+ "name": "WhatsApp",+ "description": wa_desc,+ "connected": wa_connected,+ }));+ println!("{}", serde_json::to_string_pretty(&items)?);} else {println!("{:<20} {:<12} {:<40}", "ID", "STATUS", "NAME");println!("{}", "-".repeat(72));- for item in &list {- let id = item.get("id").and_then(|v| v.as_str()).unwrap_or("-");- let name = item.get("name").and_then(|v| v.as_str()).unwrap_or("-");- let connected = item.get("connected").and_then(|v| v.as_bool()).unwrap_or(false);- let status = if connected { "connected" } else { "-" };- println!("{:<20} {:<12} {:<40}", id, status, name);+ for info in &list {+ let status = if info.connected { "connected" } else { "-" };+ println!(+ "{:<20} {:<12} {:<40}",+ info.def.id, status, info.def.name+ );}+ let wa_status = if wa_connected { "connected" } else { "-" };+ println!("{:<20} {:<12} {:<40}", "whatsapp", wa_status, "WhatsApp");}}ConnectionCommand::Get { id, json: use_json } => {- // WhatsApp: show gateway info instead of credentialsif id == "whatsapp" {- let info = fetch_whatsapp_info().await;+ let connected = screenpipe_dir+ .join("whatsapp-session")+ .join("creds.json")+ .exists();+ let info = if connected {+ json!({+ "id": "whatsapp",+ "connected": true,+ "description": "Send messages: curl -X POST http://localhost:3035/send -H 'Content-Type: application/json' -d '{\"to\":\"PHONE\",\"text\":\"MSG\"}'"+ })+ } else {+ json!({+ "id": "whatsapp",+ "connected": false,+ "description": "Pair via Settings > Connections in the desktop app"+ })+ };if *use_json {println!("{}", serde_json::to_string_pretty(&info)?);} else {- let status = info.get("status").and_then(|v| v.as_str()).unwrap_or("unknown");+ let status = if connected { "connected" } else { "not connected" };println!("whatsapp: {}", status);- if let Some(desc) = info.get("description").and_then(|v| v.as_str()) {- println!("\n{}", desc);- }+ println!(+ "\n{}",+ info.get("description").and_then(|v| v.as_str()).unwrap_or("")+ );}return Ok(());}@@ -147,22 +158,3 @@ pub async fn handle_connection_command(command: &ConnectionCommand) -> anyhow::ROk(())}--/// Fetch WhatsApp gateway info from the running server.-async fn fetch_whatsapp_info() -> Value {- if let Ok(resp) = reqwest::Client::new()- .get("http://localhost:3030/connections/whatsapp/status")- .timeout(std::time::Duration::from_secs(2))- .send()- .await- {- if let Ok(body) = resp.json::<Value>().await {- return body;- }- }-- json!({- "status": "unknown",- "description": "WhatsApp gateway status unavailable. Make sure screenpipe is running."- })-}