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

v2.3.31

Louis Beaumont98328ed0091b
diff --git a/apps/screenpipe-app-tauri/components/settings/gmail-card.tsx b/apps/screenpipe-app-tauri/components/settings/gmail-card.tsx
index 7627cc68b..0b3bce6ca 100644
--- a/apps/screenpipe-app-tauri/components/settings/gmail-card.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/gmail-card.tsx
@@ -26,11 +26,22 @@ export function GmailCard() {
const fetchAccounts = useCallback(async () => {
try {
- const res = await commands.oauthStatus("gmail");
- if (res.status === "ok" && res.data.connected) {
- setAccounts([{ instance: null, displayName: (res.data as any).display_name ?? null }]);
+ const res = await commands.oauthListInstances("gmail");
+ if (res.status === "ok" && res.data.length > 0) {
+ setAccounts(
+ res.data.map((i) => ({
+ instance: i.instance,
+ displayName: i.display_name,
+ }))
+ );
} else {
- setAccounts([]);
+ // Fallback to single status check for backwards compat
+ const status = await commands.oauthStatus("gmail");
+ if (status.status === "ok" && status.data.connected) {
+ setAccounts([{ instance: null, displayName: status.data.display_name ?? null }]);
+ } else {
+ setAccounts([]);
+ }
}
} catch {
setAccounts([]);
@@ -59,7 +70,7 @@ export function GmailCard() {
const key = instance ?? "__default__";
setDisconnecting(key);
try {
- await commands.oauthDisconnect("gmail");
+ await commands.oauthDisconnect("gmail", instance);
posthog.capture("gmail_disconnected", { instance });
await fetchAccounts();
} catch (e) {
diff --git a/apps/screenpipe-app-tauri/lib/utils/tauri.ts b/apps/screenpipe-app-tauri/lib/utils/tauri.ts
index deb9d4ec2..c26a74072 100644
--- a/apps/screenpipe-app-tauri/lib/utils/tauri.ts
+++ b/apps/screenpipe-app-tauri/lib/utils/tauri.ts
@@ -813,9 +813,9 @@ async chatgptOauthModels() : Promise<Result<string[], string>> {
* Start the OAuth flow for any integration that has `oauth_config()` set.
* `integration_id` must match the integration's `def().id`.
*/
-async oauthConnect(integrationId: string) : Promise<Result<OAuthStatus, string>> {
+async oauthConnect(integrationId: string, instance?: string | null) : Promise<Result<OAuthStatus, string>> {
try {
- return { status: "ok", data: await TAURI_INVOKE("oauth_connect", { integrationId }) };
+ return { status: "ok", data: await TAURI_INVOKE("oauth_connect", { integrationId, instance: instance ?? null }) };
} catch (e) {
if(e instanceof Error) throw e;
else return { status: "error", error: e as any };
@@ -824,9 +824,9 @@ async oauthConnect(integrationId: string) : Promise<Result<OAuthStatus, string>>
/**
* Check whether a valid (non-expired) OAuth token exists for the given integration.
*/
-async oauthStatus(integrationId: string) : Promise<Result<OAuthStatus, string>> {
+async oauthStatus(integrationId: string, instance?: string | null) : Promise<Result<OAuthStatus, string>> {
try {
- return { status: "ok", data: await TAURI_INVOKE("oauth_status", { integrationId }) };
+ return { status: "ok", data: await TAURI_INVOKE("oauth_status", { integrationId, instance: instance ?? null }) };
} catch (e) {
if(e instanceof Error) throw e;
else return { status: "error", error: e as any };
@@ -835,9 +835,20 @@ async oauthStatus(integrationId: string) : Promise<Result<OAuthStatus, string>>
/**
* Remove the stored OAuth token for the given integration.
*/
-async oauthDisconnect(integrationId: string) : Promise<Result<boolean, string>> {
+async oauthDisconnect(integrationId: string, instance?: string | null) : Promise<Result<boolean, string>> {
try {
- return { status: "ok", data: await TAURI_INVOKE("oauth_disconnect", { integrationId }) };
+ return { status: "ok", data: await TAURI_INVOKE("oauth_disconnect", { integrationId, instance: instance ?? null }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+/**
+ * List all connected OAuth instances for a given integration.
+ */
+async oauthListInstances(integrationId: string) : Promise<Result<OAuthInstanceInfo[], string>> {
+ try {
+ return { status: "ok", data: await TAURI_INVOKE("oauth_list_instances", { integrationId }) };
} catch (e) {
if(e instanceof Error) throw e;
else return { status: "error", error: e as any };
@@ -1046,6 +1057,7 @@ export type IcsCalendarEntry = { name: string; url: string; enabled: boolean }
export type JsonValue = null | boolean | number | string | JsonValue[] | { [key in string]: JsonValue }
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 OSPermission = "screenRecording" | "microphone" | "accessibility" | "automation"
export type OSPermissionStatus = "notNeeded" | "empty" | "granted" | "denied"
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
index cedaf3812..dd25f5f0b 100644
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "screenpipe-app"
-version = "2.3.30"
+version = "2.3.31"
description = "24/7 memory for your desktop. 100% local."
authors = ["you"]
license = ""
diff --git a/apps/screenpipe-app-tauri/src-tauri/Info.plist b/apps/screenpipe-app-tauri/src-tauri/Info.plist
index e79d5aac3..fe49fe800 100644
--- a/apps/screenpipe-app-tauri/src-tauri/Info.plist
+++ b/apps/screenpipe-app-tauri/src-tauri/Info.plist
@@ -16,6 +16,11 @@
<string>screenpipe reads your calendar to detect meetings. Your calendar data stays on-device.</string>
<key>NSCalendarsFullAccessUsageDescription</key>
<string>screenpipe reads your calendar to detect meetings. Your calendar data stays on-device.</string>
+ <key>NSAppTransportSecurity</key>
+ <dict>
+ <key>NSAllowsLocalNetworking</key>
+ <true/>
+ </dict>
<key>NSSupportsAutomaticTermination</key>
<true/>
<key>NSSupportsSuddenTermination</key>
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/oauth.rs b/apps/screenpipe-app-tauri/src-tauri/src/oauth.rs
index 0e5be2692..d2e19fbe1 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/oauth.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/oauth.rs
@@ -8,6 +8,7 @@
//! screenpipe-connect is automatically handled by these commands.
//! Adding a new OAuth provider requires zero changes here.
+use base64::Engine;
use crate::store::SettingsStore;
use screenpipe_connect::connections::all_integrations;
use screenpipe_connect::oauth::{self, OAUTH_REDIRECT_URI, PENDING_OAUTH};
@@ -121,25 +122,35 @@ pub async fn oauth_connect(
.build()
.map_err(|e| format!("http client: {}", e))?;
- let token_data = oauth::exchange_code(&client, &integration_id, &code, redirect_uri)
+ let mut token_data = oauth::exchange_code(&client, &integration_id, &code, redirect_uri)
.await
.map_err(|e| {
error!("token exchange failed for {}: {}", integration_id, e);
format!("token exchange failed: {}", e)
})?;
+ // Extract email from id_token JWT if not already at the root (Google puts it in the JWT)
+ if token_data["email"].is_null() {
+ if let Some(id_token) = token_data["id_token"].as_str() {
+ if let Some(email) = extract_email_from_jwt(id_token) {
+ token_data["email"] = serde_json::Value::String(email);
+ }
+ }
+ }
+
// Auto-derive instance name from email in token response (for Google)
let effective_instance = instance.or_else(|| {
token_data["email"].as_str().map(String::from)
});
- // If this is the first account (no existing instances), store as default (None).
- // Otherwise store with the instance name.
+ // If no instance was explicitly provided and we couldn't derive one from the
+ // token, always store as the default instance (None) to avoid creating
+ // orphaned "default" named instances that oauthStatus can't find.
let existing = oauth::list_oauth_instances(&integration_id);
- let store_instance = if existing.is_empty() {
+ let store_instance = if existing.is_empty() || effective_instance.is_none() {
None
} else {
- effective_instance.as_deref().or(Some("default"))
+ effective_instance.as_deref()
};
oauth::write_oauth_token_instance(&integration_id, store_instance, &token_data)
@@ -231,3 +242,15 @@ pub async fn oauth_list_instances(integration_id: String) -> Result<Vec<OAuthIns
Ok(result)
}
+
+/// Extract email from an id_token JWT by decoding the payload (no signature verification).
+fn extract_email_from_jwt(jwt: &str) -> Option<String> {
+ let payload = jwt.split('.').nth(1)?;
+ // JWT uses base64url encoding (no padding)
+ let decoded = base64::engine::general_purpose::URL_SAFE_NO_PAD
+ .decode(payload)
+ .or_else(|_| base64::engine::general_purpose::URL_SAFE.decode(payload))
+ .ok()?;
+ let v: serde_json::Value = serde_json::from_slice(&decoded).ok()?;
+ v["email"].as_str().map(String::from)
+}
diff --git a/crates/screenpipe-connect/src/connections/calcom.rs b/crates/screenpipe-connect/src/connections/calcom.rs
index 5759c5794..fee65e0ab 100644
--- a/crates/screenpipe-connect/src/connections/calcom.rs
+++ b/crates/screenpipe-connect/src/connections/calcom.rs
@@ -14,7 +14,7 @@ use serde_json::{Map, Value};
static OAUTH: OAuthConfig = OAuthConfig {
auth_url: "https://app.cal.com/auth/oauth2/authorize",
client_id: "e9e319206428a99bfcb2207e51f827c96c1ed24821458a8633356e80632575dd",
- extra_auth_params: &[],
+ extra_auth_params: &[("scope", "READ_BOOKING READ_PROFILE")],
redirect_uri_override: None,
};