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: auto-refresh user data on app start to sync subscription status

Louis Beaumontbdbae26650a4
diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
index a1b72f7bc..26ba02f24 100644
--- a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
+++ b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
@@ -474,6 +474,21 @@ export const SettingsProvider: React.FC<{ children: React.ReactNode }> = ({ chil
};
}, []);
+ // Auto-refresh user data from API when app starts with a stored token.
+ // This ensures subscription status (cloud_subscribed) stays current —
+ // e.g. when a subscription is granted after the user last logged in.
+ useEffect(() => {
+ if (!isSettingsLoaded) return;
+ const token = settings.user?.token;
+ if (!token) return;
+
+ // Force reload to bypass localforage cache
+ loadUser(token, true).catch((err) => {
+ console.warn("auto-refresh user data failed:", err);
+ });
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [isSettingsLoaded]);
+
// Identify with persistent analyticsId for consistent tracking across frontend/backend
useEffect(() => {
if (settings.analyticsId) {