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
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix: Windows Specific calendar connection (#2695)
Ansh Grover6dcea5ce6c5d
diff --git a/apps/screenpipe-app-tauri/components/settings/calendar-card.tsx b/apps/screenpipe-app-tauri/components/settings/calendar-card.tsxindex 1b75d02f5..44c8c899a 100644--- a/apps/screenpipe-app-tauri/components/settings/calendar-card.tsx+++ b/apps/screenpipe-app-tauri/components/settings/calendar-card.tsx@@ -20,6 +20,28 @@ import {import { platform } from "@tauri-apps/plugin-os";import { invoke } from "@tauri-apps/api/core";import posthog from "posthog-js";+import { getStore } from "@/lib/hooks/use-settings";++const STORE_KEY = "calendarUserDisconnected";+const ENABLED_KEY = "calendarEnabled";++async function getCalendarPref(key: string): Promise<boolean> {+ try {+ const store = await getStore();+ const val = await store.get<boolean>(key);+ return val ?? false;+ } catch {+ return false;+ }+}++async function setCalendarPref(key: string, value: boolean): Promise<void> {+ try {+ const store = await getStore();+ await store.set(key, value);+ await store.save();+ } catch {}+}interface CalendarEventItem {id: string;@@ -34,7 +56,7 @@ interface CalendarEventItem {isAllDay: boolean;}-export function CalendarCard() {+export function CalendarCard({ onConnectionChange }: { onConnectionChange?: () => void } = {}) {const [os, setOs] = useState<string>("");const [enabled, setEnabled] = useState(false);const [authorized, setAuthorized] = useState(false);@@ -48,19 +70,30 @@ export function CalendarCard() {setOs(platform());}, []);- // Load enabled state from localStorage+ // Load enabled state from Tauri store (migrate from localStorage if needed)useEffect(() => {- try {- const stored = localStorage?.getItem("calendar-enabled");- if (stored !== null) setEnabled(stored === "true");- } catch {}+ (async () => {+ try {+ const stored = await getCalendarPref(ENABLED_KEY);+ // If nothing in store yet, check old localStorage for migration+ if (!stored) {+ const legacy = localStorage?.getItem("calendar-enabled");+ if (legacy !== null) {+ const val = legacy === "true";+ setEnabled(val);+ await setCalendarPref(ENABLED_KEY, val);+ localStorage?.removeItem("calendar-enabled");+ return;+ }+ }+ setEnabled(stored);+ } catch {}+ })();}, []);- const toggleEnabled = (val: boolean) => {+ const toggleEnabled = async (val: boolean) => {setEnabled(val);- try {- localStorage?.setItem("calendar-enabled", String(val));- } catch {}+ await setCalendarPref(ENABLED_KEY, val);posthog.capture(val ? "calendar_enabled" : "calendar_disabled");};@@ -79,18 +112,24 @@ export function CalendarCard() {setIsLoadingEvents(false);}, []);- // Check calendar authorization status+ // Check calendar authorization status, respecting user's explicit disconnectconst checkStatus = useCallback(async () => {try {- const status = await invoke<{- available: boolean;- authorized: boolean;- authorizationStatus: string;- calendarCount: number;- }>("calendar_status");+ const [status, userDisconnected] = await Promise.all([+ invoke<{+ available: boolean;+ authorized: boolean;+ authorizationStatus: string;+ calendarCount: number;+ }>("calendar_status"),+ getCalendarPref(STORE_KEY),+ ]);- setAuthorized(status.authorized);- setCalendarCount(status.calendarCount);+ // If the OS permission is granted but the user explicitly disconnected,+ // treat as not connected in the UI — don't auto-reconnect.+ const effectivelyAuthorized = status.authorized && !userDisconnected;+ setAuthorized(effectivelyAuthorized);+ setCalendarCount(effectivelyAuthorized ? status.calendarCount : 0);setAuthDenied(status.authorizationStatus === "Denied");} catch {}}, []);@@ -112,15 +151,16 @@ export function CalendarCard() {const authorizeCalendar = async () => {setIsAuthorizing(true);setAuthDenied(false);+ // Clear the explicit-disconnect flag so checkStatus won't suppress the connection+ await setCalendarPref(STORE_KEY, false);try {const result = await invoke<string>("calendar_authorize");if (result === "granted") {setAuthorized(true);setEnabled(true);- try {- localStorage?.setItem("calendar-enabled", "true");- } catch {}+ await setCalendarPref(ENABLED_KEY, true);posthog.capture("calendar_authorized", { result: "granted" });+ onConnectionChange?.();checkStatus();} else {setAuthDenied(true);@@ -264,12 +304,14 @@ export function CalendarCard() {<Buttonvariant="ghost"size="sm"- onClick={() => {+ onClick={async () => {setAuthorized(false);setEnabled(false);- try {- localStorage?.setItem("calendar-enabled", "false");- } catch {}+ await Promise.all([+ setCalendarPref(STORE_KEY, true),+ setCalendarPref(ENABLED_KEY, false),+ ]);+ onConnectionChange?.();posthog.capture("calendar_disconnected");}}className="text-xs text-muted-foreground hover:text-destructive h-7 px-2"diff --git a/apps/screenpipe-app-tauri/components/settings/connections-section.tsx b/apps/screenpipe-app-tauri/components/settings/connections-section.tsxindex 67e2c56f7..337baac84 100644--- a/apps/screenpipe-app-tauri/components/settings/connections-section.tsx+++ b/apps/screenpipe-app-tauri/components/settings/connections-section.tsx@@ -12,7 +12,7 @@ import { Label } from "@/components/ui/label";import { Download, ExternalLink, Check, Loader2, Copy, Terminal, LogIn, LogOut, Send, X, HelpCircle, Search, Calendar as CalendarIcon, Eye, EyeOff } from "lucide-react";import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";import { commands } from "@/lib/utils/tauri";-import { useSettings } from "@/lib/hooks/use-settings";+import { useSettings, getStore } from "@/lib/hooks/use-settings";import { ensureChatGptPreset } from "@/lib/utils/chatgpt-preset";import { showChatWithPrefill } from "@/lib/chat-utils";import { Command } from "@tauri-apps/plugin-shell";@@ -195,6 +195,7 @@ export function IntegrationIcon({ icon }: { icon: string }) {),"apple-intelligence": <img src="/images/apple-intelligence.png" alt="Apple Intelligence" className="w-5 h-5 rounded" />,"apple-calendar": <img src="/images/apple.svg" alt="Apple" className="w-5 h-5 dark:invert" />,+ "windows-calendar": <CalendarIcon className="h-5 w-5 text-muted-foreground" />,"google-calendar": <img src="/images/google-calendar.svg" alt="Google Calendar" className="w-5 h-5" />,"ics-calendar": <CalendarIcon className="h-5 w-5 text-muted-foreground" />,openclaw: <img src="/images/openclaw.png" alt="OpenClaw" className="w-5 h-5" />,@@ -1388,6 +1389,17 @@ export function ConnectionsSection() {const [cursorInstalled, setCursorInstalled] = useState(false);const [chatgptConnected, setChatgptConnected] = useState(false);const [browserExtConnected, setBrowserExtConnected] = useState(false);+ const [calendarUserDisconnected, setCalendarUserDisconnected] = useState(false);++ const refreshCalendarTile = useCallback(() => {+ getStore()+ .then((store) => store.get<boolean>("calendarUserDisconnected"))+ .then((val) => setCalendarUserDisconnected(val ?? false))+ .catch(() => {});+ }, []);++ // Re-read on panel open/close and on explicit connect/disconnect+ useEffect(() => { refreshCalendarTile(); }, [selected, refreshCalendarTile]);const refreshStatus = useCallback(() => {getInstalledMcpVersion().then(v => {@@ -1449,7 +1461,7 @@ export function ConnectionsSection() {{ id: "voice-memos", name: "Voice Memos", icon: "voice-memos", connected: false },] : []),{ id: "apple-intelligence", name: "Apple Intelligence", icon: "apple-intelligence", connected: false },- { id: "apple-calendar", name: "Apple Calendar", icon: "apple-calendar", connected: false },+ { id: "apple-calendar", name: os === "windows" ? "Windows Calendar" : "Apple Calendar", icon: os === "windows" ? "windows-calendar" : "apple-calendar", connected: false },{ id: "google-calendar", name: "Google Calendar", icon: "google-calendar", connected: false },{ id: "ics-calendar", name: "ICS Calendar", icon: "ics-calendar", connected: false },{ id: "openclaw", name: "OpenClaw", icon: "openclaw", connected: false },@@ -1473,8 +1485,11 @@ export function ConnectionsSection() {const api = integrations.find(i => i.id === h.id);if (api) h.connected = api.connected;}+ // If user explicitly disconnected calendar, suppress the dot regardless of OS state+ const calTile = hardcoded.find(h => h.id === "apple-calendar");+ if (calTile && calendarUserDisconnected) calTile.connected = false;return [...hardcoded, ...apiTiles];- }, [os, claudeInstalled, cursorInstalled, chatgptConnected, browserExtConnected, integrations]);+ }, [os, claudeInstalled, cursorInstalled, chatgptConnected, browserExtConnected, integrations, calendarUserDisconnected]);const filtered = useMemo(() => {if (!search.trim()) return allTiles;@@ -1495,7 +1510,7 @@ export function ConnectionsSection() {case "browser-url": return <BrowserUrlCard />;case "voice-memos": return <VoiceMemosCard />;case "apple-intelligence": return <AppleIntelligenceCard />;- case "apple-calendar": return <CalendarCard />;+ case "apple-calendar": return <CalendarCard onConnectionChange={refreshCalendarTile} />;case "google-calendar": return <GoogleCalendarCard />;case "ics-calendar": return <IcsCalendarCard />;case "openclaw": return <OpenClawCard />;