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(oauth): surface unreadable-token state + log decryption failures
Louis Beaumont2359d1c2b35d
diff --git a/apps/screenpipe-app-tauri/lib/utils/calendar.ts b/apps/screenpipe-app-tauri/lib/utils/calendar.tsindex aca834de9..7bb4880d6 100644--- a/apps/screenpipe-app-tauri/lib/utils/calendar.ts+++ b/apps/screenpipe-app-tauri/lib/utils/calendar.ts@@ -266,11 +266,13 @@ async function fetchGoogleProvider(): Promise<ProviderCalendarResult> {let statusKnown = false;let statusConnected = false;+ let needsAttention = false;try {const status = await commands.oauthStatus("google-calendar", null);if (status.status === "ok") {statusKnown = true;statusConnected = status.data.connected;+ needsAttention = status.data.needs_attention === true;}} catch {// Fall back to probing the events endpoint below.@@ -278,9 +280,17 @@ async function fetchGoogleProvider(// Once OAuth status is available, disconnected means there is no recoverable// token. Avoid repeatedly probing an endpoint that can only fail until the- // user reconnects.+ // user reconnects. Exception: needs_attention means a token row exists but+ // the keychain key is unavailable (bundle ACL mismatch) — surface this as+ // "connected but failing" so the meeting-notes UI shows the error state+ // instead of pushing the user to a reconnect that won't actually help.if (statusKnown && !statusConnected) {- return { source: "google", connected: false, ok: true, events: [] };+ return {+ source: "google",+ connected: needsAttention,+ ok: !needsAttention,+ events: [],+ };}const events = await fetchGoogleCalendar(hoursBack, hoursAhead);diff --git a/apps/screenpipe-app-tauri/lib/utils/tauri.ts b/apps/screenpipe-app-tauri/lib/utils/tauri.tsindex fb3120c8e..1a151590d 100644--- a/apps/screenpipe-app-tauri/lib/utils/tauri.ts+++ b/apps/screenpipe-app-tauri/lib/utils/tauri.ts@@ -1493,7 +1493,7 @@ export type KeychainStatus = { state: string }export type LogFile = { name: string; path: string; modified_at: bigint }export type MonitorDevice = { id: number; stableId: string; name: string; isDefault: boolean; width: number; height: number }export type OAuthInstanceInfo = { instance: string | null; display_name: string | null }-export type OAuthStatus = { connected: boolean; display_name: string | null }+export type OAuthStatus = { connected: boolean; display_name: string | null; needs_attention?: boolean }export type OSPermission = "screenRecording" | "microphone" | "accessibility" | "automation"export type OSPermissionStatus = "notNeeded" | "empty" | "granted" | "denied"export type OSPermissionsCheck = { screenRecording: OSPermissionStatus; microphone: OSPermissionStatus; accessibility: OSPermissionStatus }diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lockindex 54bfe7976..7452452b1 100644--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock@@ -10580,7 +10580,7 @@ dependencies = [[[package]]name = "screenpipe-app"-version = "2.4.241"+version = "2.4.243"dependencies = ["aes","aes-gcm",diff --git a/apps/screenpipe-app-tauri/src-tauri/src/oauth.rs b/apps/screenpipe-app-tauri/src-tauri/src/oauth.rsindex 2fad73537..86d8670c9 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/oauth.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/oauth.rs@@ -22,6 +22,12 @@ use tracing::{error, info};pub struct OAuthStatus {pub connected: bool,pub display_name: Option<String>,+ /// True when a token row exists in the secret store but we can't read it+ /// (keychain key unavailable — usually a dev↔prod bundle ACL split). The+ /// UI should surface this as "needs attention" rather than "not connected"+ /// since the user can't fix it by reconnecting in the broken bundle.+ #[serde(default)]+ pub needs_attention: bool,}#[derive(Serialize, Deserialize, specta::Type, Clone)]@@ -406,6 +412,7 @@ pub async fn oauth_connect(Ok(OAuthStatus {connected: true,display_name,+ needs_attention: false,})}@@ -455,9 +462,22 @@ pub async fn oauth_status(None};+ // If we couldn't recover a token but a row exists in the store, the most+ // likely cause is a keychain ACL mismatch (e.g. dev↔prod bundle split) —+ // not a user-initiated disconnect. Surface that distinction so the UI can+ // show "needs attention" instead of pushing the user to reconnect blindly.+ let needs_attention = !connected+ && oauth::oauth_instance_token_exists(+ store.as_ref(),+ &integration_id,+ instance.as_deref(),+ )+ .await;+Ok(OAuthStatus {connected,display_name,+ needs_attention,})}diff --git a/crates/screenpipe-connect/src/oauth.rs b/crates/screenpipe-connect/src/oauth.rsindex c1dae6d18..9bd5b15af 100644--- a/crates/screenpipe-connect/src/oauth.rs+++ b/crates/screenpipe-connect/src/oauth.rs@@ -243,8 +243,21 @@ async fn load_oauth_json_exact(// Try SecretStore firstif let Some(s) = store {let key = store_key(integration_id, instance);- if let Ok(Some(val)) = s.get_json::<Value>(&key).await {- return Some(val);+ match s.get_json::<Value>(&key).await {+ Ok(Some(val)) => return Some(val),+ Ok(None) => {}+ Err(e) => {+ // Most common cause: encrypted token row exists but the keychain+ // key is unavailable (dev↔prod bundle ACL split, recent encryption+ // toggle, revoked keychain item). Without this log the disconnect+ // looks like a missing token and the user has to reconnect to+ // recover, which silently rewrites under the active bundle's key.+ tracing::warn!(+ "oauth: secret store read failed for {} (instance={:?}): {e:#}",+ integration_id,+ instance,+ );+ }}}@@ -324,6 +337,23 @@ pub async fn is_oauth_instance_connected(.is_some_and(oauth_json_is_recoverable)}+/// True when at least one token row exists in the store for this integration,+/// regardless of whether the value can be decrypted. Lets callers distinguish+/// "user disconnected / never connected" from "keychain key is currently+/// unavailable" — the former requires a reconnect, the latter just needs the+/// keychain to come back (or a bundle-id check).+pub async fn oauth_instance_token_exists(+ store: Option<&SecretStore>,+ integration_id: &str,+ instance: Option<&str>,+) -> bool {+ let instances = list_oauth_instances(store, integration_id).await;+ match instance {+ Some(name) => instances.iter().any(|i| i.as_deref() == Some(name)),+ None => !instances.is_empty(),+ }+}+/// List only instances that are recoverable: either the access token is still/// valid, or a refresh token exists and can keep the connection alive.pub async fn list_connected_oauth_instances(