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
feat: keychain permission recovery + quiet whatsapp non-JSON stdout
Louis Beaumont6915bbf508ff
diff --git a/apps/screenpipe-app-tauri/app/permission-recovery/page.tsx b/apps/screenpipe-app-tauri/app/permission-recovery/page.tsxindex cb369030b..a25b712e9 100644--- a/apps/screenpipe-app-tauri/app/permission-recovery/page.tsx+++ b/apps/screenpipe-app-tauri/app/permission-recovery/page.tsx@@ -5,7 +5,7 @@"use client";import React, { useState, useEffect, useCallback, useRef } from "react";-import { Monitor, Mic, Keyboard, Check, RefreshCw } from "lucide-react";+import { Monitor, Mic, Keyboard, Lock, Check, RefreshCw } from "lucide-react";import { commands } from "@/lib/utils/tauri";import { usePlatform } from "@/lib/hooks/use-platform";import posthog from "posthog-js";@@ -72,6 +72,9 @@ function PermissionRow({export default function PermissionRecoveryPage() {const [permissions, setPermissions] = useState<Record<string, string> | null>(null);+ // Keychain: "granted" if enabled or unavailable (no keychain on this OS),+ // "denied" only if the user previously opted in but access is now refused.+ const [keychainStatus, setKeychainStatus] = useState<"granted" | "denied" | "checking">("checking");const { isMac: isMacOS } = usePlatform();const restartTriggeredRef = useRef(false);@@ -86,14 +89,35 @@ export default function PermissionRecoveryPage() {}}, []);+ const checkKeychain = useCallback(async () => {+ try {+ const res = await commands.getKeychainStatus();+ if (res.status === "ok") {+ // "enabled" = user opted in and key accessible+ // "unavailable" = OS keychain missing (Linux without libsecret, etc.) — treat as ok+ // "disabled" = user never opted in OR access denied — only treat as denied on mac+ // where access-denied is actionable via re-enable.+ if (res.data.state === "enabled" || res.data.state === "unavailable") {+ setKeychainStatus("granted");+ } else {+ setKeychainStatus("denied");+ }+ }+ } catch {+ // keep previous status on error+ }+ }, []);+useEffect(() => {checkPermissions();+ if (isMacOS) checkKeychain();const interval = setInterval(() => {if (restartTriggeredRef.current) return;checkPermissions();+ if (isMacOS) checkKeychain();}, 3000);return () => clearInterval(interval);- }, [checkPermissions]);+ }, [checkPermissions, checkKeychain, isMacOS]);// Auto-close and restart when critical permissions are restoreduseEffect(() => {@@ -122,6 +146,12 @@ export default function PermissionRecoveryPage() {await checkPermissions();};+ const handleFixKeychain = async () => {+ posthog.capture("permission_recovery_manual_fix", { permission: "keychain" });+ try { await commands.enableKeychainEncryption(); } catch {}+ await checkKeychain();+ };+const screenStatus = permissions?.screenRecording === "granted" || permissions?.screenRecording === "notNeeded"? "granted" : permissions === null ? "checking" : "denied";const micStatus = permissions?.microphone === "granted" || permissions?.microphone === "notNeeded"@@ -174,6 +204,15 @@ export default function PermissionRecoveryPage() {onFix={() => handleFix("accessibility")}/>)}+ {isMacOS && keychainStatus === "denied" && (+ <PermissionRow+ icon={<Lock className="w-4 h-4" strokeWidth={1.5} />}+ label="secure storage"+ description="encrypt api keys & credentials"+ status={keychainStatus}+ onFix={handleFixKeychain}+ />+ )}</div><p className="font-mono text-[10px] text-muted-foreground text-center">diff --git a/crates/screenpipe-connect/src/whatsapp/mod.rs b/crates/screenpipe-connect/src/whatsapp/mod.rsindex 36ceefe2e..47a9f272c 100644--- a/crates/screenpipe-connect/src/whatsapp/mod.rs+++ b/crates/screenpipe-connect/src/whatsapp/mod.rs@@ -16,7 +16,7 @@ use std::sync::Arc;use tokio::io::{AsyncBufReadExt, BufReader};use tokio::process::{Child, Command};use tokio::sync::Mutex;-use tracing::{error, info, warn};+use tracing::{debug, error, info, warn};const GATEWAY_JS: &str = include_str!("gateway.mjs");@@ -189,7 +189,15 @@ impl WhatsAppGateway {let reader = BufReader::new(stdout);let mut lines = reader.lines();while let Ok(Some(line)) = lines.next_line().await {- match serde_json::from_str::<GatewayEvent>(&line) {+ // Skip non-JSON lines silently (Bun console.log debug output,+ // multi-line pretty-printed objects, etc.) — only try to parse+ // lines that look like JSON events.+ let trimmed = line.trim_start();+ if !trimmed.starts_with('{') {+ debug!("whatsapp gateway stdout: {}", line);+ continue;+ }+ match serde_json::from_str::<GatewayEvent>(trimmed) {Ok(GatewayEvent::Qr { data }) => {info!("whatsapp: qr code received");*status.lock().await = WhatsAppStatus::QrReady { qr: data };@@ -218,7 +226,7 @@ impl WhatsAppGateway {// send results are logged but not tracked in status}Err(e) => {- warn!("whatsapp gateway unparseable line: {} ({})", line, e);+ debug!("whatsapp gateway unparseable line: {} ({})", line, e);}}}@@ -243,7 +251,15 @@ impl WhatsAppGateway {let reader = BufReader::new(stderr);let mut lines = reader.lines();while let Ok(Some(line)) = lines.next_line().await {- warn!("whatsapp gateway stderr: {}", line);+ // Only WARN for actual errors. Bun prints noisy warnings+ // (e.g. "ws.WebSocket 'upgrade' event is not implemented")+ // and info messages to stderr that aren't actionable.+ let lower = line.to_lowercase();+ if lower.contains("error") || lower.contains("fatal") || lower.contains("panic") {+ warn!("whatsapp gateway stderr: {}", line);+ } else {+ debug!("whatsapp gateway stderr: {}", line);+ }}});@@ -375,7 +391,13 @@ impl WhatsAppGateway {let reader = BufReader::new(stdout);let mut lines = reader.lines();while let Ok(Some(line)) = lines.next_line().await {- match serde_json::from_str::<GatewayEvent>(&line) {+ // Skip non-JSON lines silently (see comment above).+ let trimmed = line.trim_start();+ if !trimmed.starts_with('{') {+ debug!("whatsapp gateway stdout: {}", line);+ continue;+ }+ match serde_json::from_str::<GatewayEvent>(trimmed) {Ok(GatewayEvent::Qr { data }) => {info!("whatsapp: qr code received");*s.lock().await = WhatsAppStatus::QrReady { qr: data };@@ -401,7 +423,7 @@ impl WhatsAppGateway {}Ok(GatewayEvent::SendResult { .. }) => {}Err(e) => {- warn!(+ debug!("whatsapp gateway unparseable line: {} ({})",line, e);@@ -425,7 +447,15 @@ impl WhatsAppGateway {let reader = BufReader::new(stderr);let mut lines = reader.lines();while let Ok(Some(line)) = lines.next_line().await {- warn!("whatsapp gateway stderr: {}", line);+ // Only WARN for actual errors. Bun prints noisy warnings+ // (e.g. "ws.WebSocket 'upgrade' event is not implemented")+ // and info messages to stderr that aren't actionable.+ let lower = line.to_lowercase();+ if lower.contains("error") || lower.contains("fatal") || lower.contains("panic") {+ warn!("whatsapp gateway stderr: {}", line);+ } else {+ debug!("whatsapp gateway stderr: {}", line);+ }}});