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

fix: hide cloud preset for enterprise builds & fix AI preset fallback retry

Louis Beaumont6b251d0e2bcd
diff --git a/apps/screenpipe-app-tauri/components/rewind/ai-presets-selector.tsx b/apps/screenpipe-app-tauri/components/rewind/ai-presets-selector.tsx
index ed5194f65..a1304df56 100644
--- a/apps/screenpipe-app-tauri/components/rewind/ai-presets-selector.tsx
+++ b/apps/screenpipe-app-tauri/components/rewind/ai-presets-selector.tsx
@@ -58,6 +58,7 @@ import {
} from "@/components/ui/select";
import { Textarea } from "@/components/ui/textarea";
import { AIPreset, commands } from "@/lib/utils/tauri";
+import { useIsEnterpriseBuild } from "@/lib/hooks/use-is-enterprise-build";
// Helper to detect UUID-like strings and format preset names nicely
const formatPresetName = (name: string): string => {
@@ -181,6 +182,7 @@ export function AIProviderConfig({
const [isLoadingModels, setIsLoadingModels] = useState(false);
const [idError, setIdError] = useState<string | null>(null);
const [showApiKey, setShowApiKey] = useState(false);
+ const isEnterprise = useIsEnterpriseBuild();
const [piAvailable, setPiAvailable] = useState(false);
// Check Pi availability (installed at app startup by Rust background thread)
@@ -195,11 +197,13 @@ export function AIProviderConfig({
console.error("Failed to check pi:", e);
}
};
- checkPi();
+ if (!isEnterprise) {
+ checkPi();
+ }
// Re-check periodically in case background install finishes
- const interval = setInterval(checkPi, 5000);
- return () => clearInterval(interval);
- }, []);
+ const interval = isEnterprise ? null : setInterval(checkPi, 5000);
+ return () => { if (interval) clearInterval(interval); };
+ }, [isEnterprise]);
const [formData, setFormData] = useState<AIPreset>({
provider: defaultPreset?.provider || "openai",
apiKey: defaultPreset?.apiKey || "",
@@ -913,9 +917,13 @@ export const AIPresetsSelector = ({
>();
const isControlled = onControlledSelect !== undefined;
+ const isEnterprise = useIsEnterpriseBuild();
// eslint-disable-next-line react-hooks/exhaustive-deps
- const aiPresets = (settings?.aiPresets || []) as AIPreset[];
+ const aiPresets = useMemo(() => {
+ const presets = (settings?.aiPresets || []) as AIPreset[];
+ return isEnterprise ? presets.filter((p) => p.provider !== "pi") : presets;
+ }, [settings?.aiPresets, isEnterprise]);
const selectedPreset = useMemo(() => {
if (isControlled) return controlledPresetId ?? undefined;
diff --git a/apps/screenpipe-app-tauri/components/settings/ai-presets.tsx b/apps/screenpipe-app-tauri/components/settings/ai-presets.tsx
index 0f3006613..314c9ca78 100644
--- a/apps/screenpipe-app-tauri/components/settings/ai-presets.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/ai-presets.tsx
@@ -53,6 +53,7 @@ import { Badge } from "../ui/badge";
import { toast } from "../ui/use-toast";
import { Card, CardContent } from "../ui/card";
import { AIProviderType } from "@screenpipe/browser";
+import { useIsEnterpriseBuild } from "@/lib/hooks/use-is-enterprise-build";
import {
AlertDialog,
AlertDialogAction,
@@ -1487,6 +1488,7 @@ export const AIPresets = () => {
null
);
const [isDuplicating, setIsDuplicating] = useState(false);
+ const isEnterprise = useIsEnterpriseBuild();
const [piAvailable, setPiAvailable] = useState(false);
// Check Pi availability (installed at app startup by Rust background thread)
@@ -1497,11 +1499,13 @@ export const AIPresets = () => {
setPiAvailable(true);
}
};
- checkPi();
+ if (!isEnterprise) {
+ checkPi();
+ }
// Re-check periodically in case background install finishes
- const interval = setInterval(checkPi, 5000);
- return () => clearInterval(interval);
- }, []);
+ const interval = isEnterprise ? null : setInterval(checkPi, 5000);
+ return () => { if (interval) clearInterval(interval); };
+ }, [isEnterprise]);
useEffect(() => {
if (!createPresetsDialog) {
@@ -1690,7 +1694,7 @@ export const AIPresets = () => {
</div>
<div className="w-full grid grid-cols-1 md:grid-cols-2 gap-6">
- {settings.aiPresets.map((preset) => {
+ {settings.aiPresets.filter((preset) => !isEnterprise || preset.provider !== "pi").map((preset) => {
const isDefault = preset.defaultPreset;
const hasValidation = preset.provider && preset.model && preset.url;
diff --git a/crates/screenpipe-core/src/pipes/mod.rs b/crates/screenpipe-core/src/pipes/mod.rs
index 7e384df21..f736c618f 100644
--- a/crates/screenpipe-core/src/pipes/mod.rs
+++ b/crates/screenpipe-core/src/pipes/mod.rs
@@ -1350,6 +1350,12 @@ impl PipeManager {
/// Run a pipe once with an explicit trigger type.
async fn run_pipe_with_trigger(&self, name: &str, trigger: &str) -> Result<PipeRunLog> {
+ self.run_pipe_with_trigger_inner(name, trigger, 0).await
+ }
+
+ /// Inner implementation with retry depth tracking for preset fallback.
+ fn run_pipe_with_trigger_inner<'a>(&'a self, name: &'a str, trigger: &'a str, retry_depth: usize) -> std::pin::Pin<Box<dyn std::future::Future<Output = Result<PipeRunLog>> + Send + 'a>> {
+ Box::pin(async move {
let (config, body, _raw) = {
let pipes = self.pipes.lock().await;
pipes
@@ -1708,11 +1714,36 @@ impl PipeManager {
cleanup_pipe_token(token, self.token_registry.as_ref());
}
+ // Immediate fallback retry: if the pipe failed with a retryable error
+ // and there are fallback presets available, retry now instead of waiting
+ // for the next scheduled run.
+ if !log.success && config.preset.len() > 1 && retry_depth < config.preset.len() - 1 {
+ // Check if the circuit breaker picked a different preset for retry
+ if let Some((next_preset_id, _)) = self.fallback_registry.pick_preset(&config.preset) {
+ let should_retry = match &active_preset_id {
+ Some(current_id) => next_preset_id != current_id.as_str(),
+ None => false,
+ };
+ if should_retry {
+ info!(
+ "pipe '{}': primary preset failed, immediately retrying with fallback '{}'",
+ name, next_preset_id
+ );
+ // Save log of the failed attempt
+ self.append_log(name, &log).await;
+ let _ = self.write_log_to_disk(name, &log);
+ // Retry with next preset
+ return self.run_pipe_with_trigger_inner(name, trigger, retry_depth + 1).await;
+ }
+ }
+ }
+
// Save log (in-memory + disk)
self.append_log(name, &log).await;
let _ = self.write_log_to_disk(name, &log);
Ok(log)
+ }) // end Box::pin(async move { ... })
}
/// Enable or disable a pipe (writes back to pipe.md front-matter).
diff --git a/crates/screenpipe-core/src/pipes/preset_fallback.rs b/crates/screenpipe-core/src/pipes/preset_fallback.rs
index 822ad23f7..50d45ecb5 100644
--- a/crates/screenpipe-core/src/pipes/preset_fallback.rs
+++ b/crates/screenpipe-core/src/pipes/preset_fallback.rs
@@ -292,8 +292,9 @@ impl PresetFallbackRegistry {
let combined = format!("{} {}", stderr, stdout).to_lowercase();
let reason = if combined.contains("rate limit")
- || combined.contains("429")
|| combined.contains("rate_limit")
+ || combined.contains("usage limit")
+ || combined.contains("429")
{
FailureReason::RateLimit
} else if combined.contains("insufficient")