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: retry pipe fetch after settings load to avoid 401 race

Louis Beaumont91495fbd0afb
diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-pipes.ts b/apps/screenpipe-app-tauri/lib/hooks/use-pipes.ts
index a6f33633a..092da9267 100644
--- a/apps/screenpipe-app-tauri/lib/hooks/use-pipes.ts
+++ b/apps/screenpipe-app-tauri/lib/hooks/use-pipes.ts
@@ -4,6 +4,7 @@
import { useState, useEffect, useCallback } from "react";
import { localFetch } from "@/lib/api";
+import { useSettings } from "@/lib/hooks/use-settings";
export interface TemplatePipe {
name: string;
@@ -37,6 +38,7 @@ export function usePipes() {
const [promptPipes, setPromptPipes] = useState<TemplatePipe[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
+ const { isSettingsLoaded } = useSettings();
const fetchPipes = useCallback(async () => {
try {
@@ -74,9 +76,12 @@ export function usePipes() {
}
}, []);
+ // Refetch when settings load — ensures API auth key is available.
+ // The initial fetch may 401 if the webview loads before the server
+ // provides the API key via IPC.
useEffect(() => {
- fetchPipes();
- }, [fetchPipes]);
+ if (isSettingsLoaded) fetchPipes();
+ }, [isSettingsLoaded, fetchPipes]);
return { pipes, templatePipes, promptPipes, loading, error, refetch: fetchPipes };
}