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

feat: enhanced AI toggle — use screenpipe cloud for smarter suggestions

Louis Beaumontc21f3e9b750a
diff --git a/apps/screenpipe-app-tauri/components/settings/general-settings.tsx b/apps/screenpipe-app-tauri/components/settings/general-settings.tsx
index 0edeedc7c..551739660 100644
--- a/apps/screenpipe-app-tauri/components/settings/general-settings.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/general-settings.tsx
@@ -10,7 +10,7 @@ import { Switch } from "@/components/ui/switch";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Label } from "@/components/ui/label";
import { Separator } from "@/components/ui/separator";
-import { Rocket, Moon, Sun, Monitor, FlaskConical, Shield, ExternalLink, Layers, RefreshCw, Undo2, MessageSquare, Trash2 } from "lucide-react";
+import { Rocket, Moon, Sun, Monitor, FlaskConical, Shield, ExternalLink, Layers, RefreshCw, Undo2, MessageSquare, Trash2, Sparkles } from "lucide-react";
import { HelpTooltip } from "@/components/ui/help-tooltip";
import { useToast } from "@/components/ui/use-toast";
import { Button } from "@/components/ui/button";
@@ -185,6 +185,37 @@ export default function GeneralSettings() {
</CardContent>
</Card>
+ <Card className="border-border bg-card">
+ <CardContent className="px-3 py-2.5">
+ <div className="flex items-center justify-between">
+ <div className="flex items-center space-x-2.5">
+ <Sparkles className="h-4 w-4 text-muted-foreground shrink-0" />
+ <div>
+ <h3 className="text-sm font-medium text-foreground">Enhanced AI</h3>
+ <p className="text-xs text-muted-foreground">
+ use screenpipe cloud for smarter suggestions
+ </p>
+ <p className="text-[10px] text-muted-foreground/60 mt-0.5">
+ sends recent activity to screenpipe cloud for processing. we don&apos;t store your data (zero retention).
+ </p>
+ </div>
+ </div>
+ <Switch
+ id="enhanced-ai-toggle"
+ checked={settings?.enhancedAI ?? false}
+ onCheckedChange={async (checked) => {
+ handleSettingsChange({ enhancedAI: checked });
+ const token = settings?.user?.token || "";
+ try {
+ await commands.setEnhancedAiSuggestions(checked, token);
+ } catch {}
+ }}
+ className="ml-4"
+ />
+ </div>
+ </CardContent>
+ </Card>
+
{!isEnterprise && (
<Card className="border-border bg-card">
<CardContent className="px-3 py-2.5">
diff --git a/apps/screenpipe-app-tauri/lib/utils/tauri.ts b/apps/screenpipe-app-tauri/lib/utils/tauri.ts
index 62673495f..e2912d7cb 100644
--- a/apps/screenpipe-app-tauri/lib/utils/tauri.ts
+++ b/apps/screenpipe-app-tauri/lib/utils/tauri.ts
@@ -1353,7 +1353,9 @@ autoUpdate?: boolean;
/**
* Auto-update store-installed pipes that haven't been locally modified.
*/
-autoUpdatePipes?: boolean;
+autoUpdatePipes?: boolean;
+/** Use screenpipe cloud for AI features like suggestions (zero data retention). */
+enhancedAI?: boolean;
/**
* Timeline overlay mode: "fullscreen" (floating panel above everything) or
* "window" (normal resizable window with title bar).
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/apps/screenpipe-app-tauri/src-tauri/src/main.rs
index f314245c0..64dcd8bbe 100755
--- a/apps/screenpipe-app-tauri/src-tauri/src/main.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/main.rs
@@ -655,6 +655,7 @@ async fn main() {
// Suggestions
suggestions::get_cached_suggestions,
suggestions::force_regenerate_suggestions,
+ suggestions::set_enhanced_ai_suggestions,
// Config commands
config::validate_data_dir,
// Hardware detection
@@ -934,6 +935,7 @@ async fn main() {
// Suggestions
suggestions::get_cached_suggestions,
suggestions::force_regenerate_suggestions,
+ suggestions::set_enhanced_ai_suggestions,
// Config commands
config::validate_data_dir,
// Hardware detection
@@ -1591,9 +1593,25 @@ async fn main() {
// Auto-start suggestions scheduler (always on)
let suggestions_state = app_handle.state::<suggestions::SuggestionsState>();
+ // Initialize enhanced AI config from saved settings
+ {
+ if let Ok(Some(store)) = crate::store::SettingsStore::get(&app_handle) {
+ if store.enhanced_ai {
+ let token = store.user.token.clone().unwrap_or_default();
+ if !token.is_empty() {
+ let mut guard = suggestions_state.enhanced_ai.blocking_lock();
+ *guard = Some(suggestions::EnhancedAIConfig {
+ enabled: true,
+ token,
+ });
+ }
+ }
+ }
+ }
let suggestions_state_clone = suggestions::SuggestionsState {
cache: suggestions_state.cache.clone(),
scheduler_handle: suggestions_state.scheduler_handle.clone(),
+ enhanced_ai: suggestions_state.enhanced_ai.clone(),
};
tauri::async_runtime::spawn(async move {
suggestions::auto_start_scheduler(&suggestions_state_clone).await;
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/store.rs b/apps/screenpipe-app-tauri/src-tauri/src/store.rs
index dd90f9089..23bcf3cf6 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/store.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/store.rs
@@ -201,6 +201,10 @@ pub struct SettingsStore {
/// Auto-update store-installed pipes that haven't been locally modified.
#[serde(rename = "autoUpdatePipes", default = "default_true")]
pub auto_update_pipes: bool,
+ /// Use screenpipe cloud for AI-powered features like suggestions.
+ /// Better quality but sends activity context to the cloud (zero data retention).
+ #[serde(rename = "enhancedAI", default)]
+ pub enhanced_ai: bool,
/// Timeline overlay mode: "fullscreen" (floating panel above everything) or
/// "window" (normal resizable window with title bar).
#[serde(rename = "overlayMode", default = "default_overlay_mode")]
@@ -529,6 +533,7 @@ Rules:
device_id: uuid::Uuid::new_v4().to_string(),
auto_update: true,
auto_update_pipes: true,
+ enhanced_ai: false,
#[cfg(target_os = "macos")]
overlay_mode: "fullscreen".to_string(),
#[cfg(not(target_os = "macos"))]
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/suggestions.rs b/apps/screenpipe-app-tauri/src-tauri/src/suggestions.rs
index 92e974141..2c6aac78c 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/suggestions.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/suggestions.rs
@@ -30,11 +30,24 @@ pub struct CachedSuggestions {
pub tags: Vec<String>,
}
+// ─── Enhanced AI config ─────────────────────────────────────────────────────
+
+/// When enabled, uses screenpipe cloud (api.screenpi.pe) instead of Apple
+/// Intelligence for generating suggestions. Produces much better results
+/// but sends recent activity context to the cloud.
+#[derive(Debug, Clone)]
+pub struct EnhancedAIConfig {
+ pub enabled: bool,
+ /// User's Clerk JWT token for authenticating with screenpipe cloud.
+ pub token: String,
+}
+
// ─── Managed state ──────────────────────────────────────────────────────────
pub struct SuggestionsState {
pub cache: Arc<Mutex<Option<CachedSuggestions>>>,
pub scheduler_handle: Arc<Mutex<Option<tokio::task::JoinHandle<()>>>>,
+ pub enhanced_ai: Arc<Mutex<Option<EnhancedAIConfig>>>,
}
impl SuggestionsState {
@@ -42,6 +55,7 @@ impl SuggestionsState {
Self {
cache: Arc::new(Mutex::new(None)),
scheduler_handle: Arc::new(Mutex::new(None)),
+ enhanced_ai: Arc::new(Mutex::new(None)),
}
}
}
@@ -71,18 +85,37 @@ pub async fn get_cached_suggestions(
pub async fn force_regenerate_suggestions(
state: tauri::State<'_, SuggestionsState>,
) -> Result<CachedSuggestions, String> {
- let cached = generate_suggestions().await?;
+ let enhanced = state.enhanced_ai.lock().await.clone();
+ let cached = generate_suggestions(enhanced.as_ref()).await?;
let mut guard = state.cache.lock().await;
*guard = Some(cached.clone());
Ok(cached)
}
+/// Enable or disable enhanced AI suggestions (uses screenpipe cloud).
+#[tauri::command]
+#[specta::specta]
+pub async fn set_enhanced_ai_suggestions(
+ state: tauri::State<'_, SuggestionsState>,
+ enabled: bool,
+ token: String,
+) -> Result<(), String> {
+ let mut guard = state.enhanced_ai.lock().await;
+ if enabled && !token.is_empty() {
+ *guard = Some(EnhancedAIConfig { enabled, token });
+ } else {
+ *guard = None;
+ }
+ Ok(())
+}
+
// ─── Auto-start ─────────────────────────────────────────────────────────────
/// Auto-start the suggestions scheduler on app launch.
pub async fn auto_start_scheduler(state: &SuggestionsState) {
let cache = state.cache.clone();
let handle_arc = state.scheduler_handle.clone();
+ let enhanced_ai = state.enhanced_ai.clone();
let handle = tokio::spawn(async move {
info!("suggestions scheduler: started (10-min interval)");
@@ -105,8 +138,11 @@ pub async fn auto_start_scheduler(state: &SuggestionsState) {
continue;
}
+ // Read current enhanced AI config (picks up setting changes each cycle)
+ let enhanced = enhanced_ai.lock().await.clone();
+
// Fetch activity & generate suggestions
- match generate_suggestions().await {
+ match generate_suggestions(enhanced.as_ref()).await {
Ok(cached) => {
debug!(
"suggestions scheduler: generated {} suggestions (mode={}, ai={})",
@@ -993,37 +1029,66 @@ struct AiResult {
tags: Vec<String>,
}
+/// Screenpipe cloud API endpoint for enhanced AI suggestions.
+const SCREENPIPE_CLOUD_API: &str = "https://api.screenpi.pe/v1";
+
async fn generate_ai_suggestions(
mode: &str,
apps: &[AppActivity],
windows: &[WindowActivity],
+ enhanced_ai: Option<&EnhancedAIConfig>,
) -> Option<AiResult> {
- if !check_ai_available().await {
- info!("suggestions: Apple Intelligence not available, using templates");
+ // Determine which AI backend to use
+ let use_cloud = enhanced_ai
+ .as_ref()
+ .map_or(false, |c| c.enabled && !c.token.is_empty());
+
+ if !use_cloud && !check_ai_available().await {
+ info!("suggestions: Apple Intelligence not available and enhanced AI not enabled, using templates");
return None;
}
let context = build_activity_context(apps, windows).await;
- let prompt = format!("{}Activity mode: {}\n\n{}", AI_SYSTEM_PROMPT, mode, context);
-
debug!(
- "suggestions: AI prompt length = {} chars (~{} tokens)",
- prompt.len(),
- prompt.len() / 4
+ "suggestions: AI prompt ~{} tokens, backend={}",
+ context.len() / 4,
+ if use_cloud { "screenpipe-cloud" } else { "apple-intelligence" }
);
let client = reqwest::Client::new();
- let resp = client
- .post(format!("{}/ai/chat/completions", API))
- .json(&serde_json::json!({
- "messages": [
- {"role": "user", "content": prompt}
- ]
- }))
- .timeout(std::time::Duration::from_secs(30))
- .send()
- .await;
+
+ let resp = if use_cloud {
+ let config = enhanced_ai.unwrap();
+ client
+ .post(format!("{}/chat/completions", SCREENPIPE_CLOUD_API))
+ .header("Authorization", format!("Bearer {}", config.token))
+ .json(&serde_json::json!({
+ "model": "auto",
+ "messages": [
+ {"role": "system", "content": AI_SYSTEM_PROMPT},
+ {"role": "user", "content": format!("Activity mode: {}\n\n{}", mode, context)}
+ ],
+ "temperature": 0.7,
+ "max_tokens": 500
+ }))
+ .timeout(std::time::Duration::from_secs(30))
+ .send()
+ .await
+ } else {
+ // Apple Intelligence (on-device)
+ let prompt = format!("{}Activity mode: {}\n\n{}", AI_SYSTEM_PROMPT, mode, context);
+ client
+ .post(format!("{}/ai/chat/completions", API))
+ .json(&serde_json::json!({
+ "messages": [
+ {"role": "user", "content": prompt}
+ ]
+ }))
+ .timeout(std::time::Duration::from_secs(30))
+ .send()
+ .await
+ };
match resp {
Ok(r) if r.status().is_success() => {
@@ -1038,11 +1103,13 @@ async fn generate_ai_suggestions(
parse_ai_response(content)
}
Ok(r) => {
- warn!("suggestions: AI returned status {}", r.status());
+ warn!("suggestions: AI returned status {} (backend={})",
+ r.status(), if use_cloud { "cloud" } else { "apple" });
None
}
Err(e) => {
- warn!("suggestions: AI request failed: {}", e);
+ warn!("suggestions: AI request failed: {} (backend={})",
+ e, if use_cloud { "cloud" } else { "apple" });
None
}
}
@@ -1138,7 +1205,9 @@ fn extract_json_object(content: &str) -> Option<String> {
}
}
-async fn generate_suggestions() -> Result<CachedSuggestions, String> {
+async fn generate_suggestions(
+ enhanced_ai: Option<&EnhancedAIConfig>,
+) -> Result<CachedSuggestions, String> {
let (apps, windows) = tokio::join!(fetch_app_activity(), fetch_window_activity());
let apps = apps.unwrap_or_default();
let windows = windows.unwrap_or_default();
@@ -1155,7 +1224,7 @@ async fn generate_suggestions() -> Result<CachedSuggestions, String> {
// Try AI-powered suggestions + tags in one call
let (suggestions, tags, ai_generated) =
- match generate_ai_suggestions(mode, &apps, &windows).await {
+ match generate_ai_suggestions(mode, &apps, &windows, enhanced_ai).await {
Some(result) => {
info!(
"suggestions: AI generated {} suggestions + {} tags",