From ca8104149c80d638940538db8f0db8948f1829ea Mon Sep 17 00:00:00 2001 From: nic <139033898+dicnunz@users.noreply.github.com> Date: Wed, 20 May 2026 17:43:58 -0400 Subject: [PATCH 1/2] Disable auto-sync when logged out --- .../settings/components/SyncSection.tsx | 15 +++++++-- .../settings/components/sync-section-state.ts | 17 ++++++++++ .../contracts/sync-settings.contract.test.ts | 33 +++++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 apps/studio/app/(main)/(dashboard)/settings/components/sync-section-state.ts create mode 100644 apps/studio/tests/contracts/sync-settings.contract.test.ts diff --git a/apps/studio/app/(main)/(dashboard)/settings/components/SyncSection.tsx b/apps/studio/app/(main)/(dashboard)/settings/components/SyncSection.tsx index 0c6ee4a..0ea6e6b 100644 --- a/apps/studio/app/(main)/(dashboard)/settings/components/SyncSection.tsx +++ b/apps/studio/app/(main)/(dashboard)/settings/components/SyncSection.tsx @@ -4,6 +4,7 @@ import { useState, useEffect } from "react"; import { CloudSync, CheckCircle2, History, LucideIcon } from "lucide-react"; import { cn } from "@/lib/utils"; +import { useUserStore } from "@/store/useUserStore"; import { Switch } from "@veriworkly/ui"; @@ -17,6 +18,7 @@ import { loadWorkspaceSettingsFromLocalStorage, } from "@/features/documents/services/workspace-settings"; import { setAllResumesSyncEnabled } from "@/features/resume/services/resume-service"; +import { getAutoSyncControlState } from "./sync-section-state"; interface TelemetryState { lastAttemptAt: string | null; @@ -24,6 +26,7 @@ interface TelemetryState { } export default function SyncSection() { + const isLoggedIn = useUserStore((state) => state.isLoggedIn); const [loading, setLoading] = useState(false); const [autoSync, setAutoSync] = useState(false); @@ -56,6 +59,8 @@ export default function SyncSection() { }, []); const handleToggle = async (checked: boolean) => { + if (!isLoggedIn) return; + setAutoSync(checked); setAutoSyncEnabledInLocalStorage(checked); setAllResumesSyncEnabled(checked); @@ -67,6 +72,8 @@ export default function SyncSection() { } }; + const autoSyncControl = getAutoSyncControlState({ autoSync, isLoggedIn, loading }); + return (
@@ -75,7 +82,7 @@ export default function SyncSection() { Cloud & Data -

Manage background synchronization.

+

{autoSyncControl.description}

@@ -83,7 +90,11 @@ export default function SyncSection() { Auto-Sync - +
diff --git a/apps/studio/app/(main)/(dashboard)/settings/components/sync-section-state.ts b/apps/studio/app/(main)/(dashboard)/settings/components/sync-section-state.ts new file mode 100644 index 0000000..a8b9248 --- /dev/null +++ b/apps/studio/app/(main)/(dashboard)/settings/components/sync-section-state.ts @@ -0,0 +1,17 @@ +export function getAutoSyncControlState({ + autoSync, + isLoggedIn, + loading, +}: { + autoSync: boolean; + isLoggedIn: boolean; + loading: boolean; +}) { + return { + checked: isLoggedIn && autoSync, + disabled: loading || !isLoggedIn, + description: isLoggedIn + ? "Manage background synchronization." + : "Sign in to enable background synchronization.", + }; +} diff --git a/apps/studio/tests/contracts/sync-settings.contract.test.ts b/apps/studio/tests/contracts/sync-settings.contract.test.ts new file mode 100644 index 0000000..f599148 --- /dev/null +++ b/apps/studio/tests/contracts/sync-settings.contract.test.ts @@ -0,0 +1,33 @@ +import { describe, expect, it } from "vitest"; + +import { getAutoSyncControlState } from "@/app/(main)/(dashboard)/settings/components/sync-section-state"; + +describe("sync settings contract", () => { + it("disables and unchecks auto-sync when the user is logged out", () => { + expect( + getAutoSyncControlState({ + autoSync: true, + isLoggedIn: false, + loading: false, + }), + ).toEqual({ + checked: false, + disabled: true, + description: "Sign in to enable background synchronization.", + }); + }); + + it("preserves the saved auto-sync state for logged-in users", () => { + expect( + getAutoSyncControlState({ + autoSync: true, + isLoggedIn: true, + loading: false, + }), + ).toEqual({ + checked: true, + disabled: false, + description: "Manage background synchronization.", + }); + }); +}); From 7e6ba845201db1c77218d4c69aeb81bb4836ee92 Mon Sep 17 00:00:00 2001 From: Gautam Raj <63155224+Gautam25Raj@users.noreply.github.com> Date: Fri, 22 May 2026 00:42:03 +0530 Subject: [PATCH 2/2] Delete apps/studio/tests/contracts/sync-settings.contract.test.ts --- .../contracts/sync-settings.contract.test.ts | 33 ------------------- 1 file changed, 33 deletions(-) delete mode 100644 apps/studio/tests/contracts/sync-settings.contract.test.ts diff --git a/apps/studio/tests/contracts/sync-settings.contract.test.ts b/apps/studio/tests/contracts/sync-settings.contract.test.ts deleted file mode 100644 index f599148..0000000 --- a/apps/studio/tests/contracts/sync-settings.contract.test.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { describe, expect, it } from "vitest"; - -import { getAutoSyncControlState } from "@/app/(main)/(dashboard)/settings/components/sync-section-state"; - -describe("sync settings contract", () => { - it("disables and unchecks auto-sync when the user is logged out", () => { - expect( - getAutoSyncControlState({ - autoSync: true, - isLoggedIn: false, - loading: false, - }), - ).toEqual({ - checked: false, - disabled: true, - description: "Sign in to enable background synchronization.", - }); - }); - - it("preserves the saved auto-sync state for logged-in users", () => { - expect( - getAutoSyncControlState({ - autoSync: true, - isLoggedIn: true, - loading: false, - }), - ).toEqual({ - checked: true, - disabled: false, - description: "Manage background synchronization.", - }); - }); -});