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
feat(cloud-sync): add Tauri commands and settings UI (Phase 4)
Louis Beaumont1d2d72840a5f
diff --git a/screenpipe-app-tauri/components/settings/sync-settings.tsx b/screenpipe-app-tauri/components/settings/sync-settings.tsxnew file mode 100644index 000000000..0d6ee13ea--- /dev/null+++ b/screenpipe-app-tauri/components/settings/sync-settings.tsx@@ -0,0 +1,631 @@+"use client";++import React, { useEffect, useState } from "react";+import { Button } from "@/components/ui/button";+import { Card } from "@/components/ui/card";+import { Label } from "@/components/ui/label";+import { Switch } from "@/components/ui/switch";+import { Progress } from "@/components/ui/progress";+import { Separator } from "@/components/ui/separator";+import { Badge } from "@/components/ui/badge";+import {+ Cloud,+ CloudOff,+ RefreshCw,+ Laptop,+ Trash2,+ Lock,+ Unlock,+ HardDrive,+ Clock,+ AlertCircle,+ CheckCircle2,+ Loader2,+} from "lucide-react";+import { toast } from "@/components/ui/use-toast";+import { invoke } from "@tauri-apps/api/core";+import {+ AlertDialog,+ AlertDialogAction,+ AlertDialogCancel,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogFooter,+ AlertDialogHeader,+ AlertDialogTitle,+ AlertDialogTrigger,+} from "@/components/ui/alert-dialog";+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "@/components/ui/select";+import { Input } from "@/components/ui/input";++interface SyncStatus {+ enabled: boolean;+ isSyncing: boolean;+ lastSync: string | null;+ lastError: string | null;+ storageUsed: number | null;+ storageLimit: number | null;+ deviceCount: number | null;+ deviceLimit: number | null;+ syncTier: string | null;+}++interface SyncDevice {+ id: string;+ deviceId: string;+ deviceName: string | null;+ deviceOs: string;+ lastSyncAt: string | null;+ createdAt: string;+ isCurrent: boolean;+}++interface SyncConfig {+ enabled: boolean;+ syncIntervalMinutes: number;+ syncTranscripts: boolean;+ syncOcr: boolean;+ syncAudio: boolean;+ syncFrames: boolean;+}++function formatBytes(bytes: number): string {+ if (bytes === 0) return "0 B";+ const k = 1024;+ const sizes = ["B", "KB", "MB", "GB", "TB"];+ const i = Math.floor(Math.log(bytes) / Math.log(k));+ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];+}++function formatRelativeTime(dateString: string): string {+ const date = new Date(dateString);+ const now = new Date();+ const diffMs = now.getTime() - date.getTime();+ const diffMins = Math.floor(diffMs / 60000);+ const diffHours = Math.floor(diffMs / 3600000);+ const diffDays = Math.floor(diffMs / 86400000);++ if (diffMins < 1) return "just now";+ if (diffMins < 60) return `${diffMins}m ago`;+ if (diffHours < 24) return `${diffHours}h ago`;+ return `${diffDays}d ago`;+}++export function SyncSettings() {+ const [status, setStatus] = useState<SyncStatus | null>(null);+ const [devices, setDevices] = useState<SyncDevice[]>([]);+ const [config, setConfig] = useState<SyncConfig | null>(null);+ const [isLoading, setIsLoading] = useState(true);+ const [isSyncing, setIsSyncing] = useState(false);+ const [showPasswordDialog, setShowPasswordDialog] = useState(false);+ const [password, setPassword] = useState("");+ const [isInitializing, setIsInitializing] = useState(false);++ useEffect(() => {+ loadSyncData();+ }, []);++ const loadSyncData = async () => {+ try {+ setIsLoading(true);+ const [statusResult, configResult, devicesResult] = await Promise.all([+ invoke<SyncStatus>("get_sync_status"),+ invoke<SyncConfig>("get_sync_config"),+ invoke<SyncDevice[]>("get_sync_devices"),+ ]);+ setStatus(statusResult);+ setConfig(configResult);+ setDevices(devicesResult);+ } catch (error) {+ console.error("failed to load sync data:", error);+ toast({+ title: "failed to load sync settings",+ description: String(error),+ variant: "destructive",+ });+ } finally {+ setIsLoading(false);+ }+ };++ const handleToggleSync = async (enabled: boolean) => {+ if (enabled && !status?.enabled) {+ // Need to initialize sync+ setShowPasswordDialog(true);+ return;+ }++ try {+ await invoke("set_sync_enabled", { enabled });+ setStatus((prev) => (prev ? { ...prev, enabled } : null));+ toast({+ title: enabled ? "sync enabled" : "sync disabled",+ description: enabled+ ? "your data will now sync to the cloud"+ : "sync has been paused",+ });+ } catch (error) {+ toast({+ title: "failed to update sync",+ description: String(error),+ variant: "destructive",+ });+ }+ };++ const handleInitSync = async () => {+ if (!password) {+ toast({+ title: "password required",+ description: "please enter a password to encrypt your data",+ variant: "destructive",+ });+ return;+ }++ try {+ setIsInitializing(true);+ const isNewUser = await invoke<boolean>("init_sync", { password });+ setShowPasswordDialog(false);+ setPassword("");++ toast({+ title: isNewUser ? "sync initialized" : "sync connected",+ description: isNewUser+ ? "your encryption keys have been generated"+ : "connected to your existing sync data",+ });++ await loadSyncData();+ } catch (error) {+ toast({+ title: "failed to initialize sync",+ description: String(error),+ variant: "destructive",+ });+ } finally {+ setIsInitializing(false);+ }+ };++ const handleTriggerSync = async () => {+ try {+ setIsSyncing(true);+ await invoke("trigger_sync");+ toast({+ title: "sync started",+ description: "syncing your data to the cloud",+ });++ // Poll for completion+ const checkSync = async () => {+ const newStatus = await invoke<SyncStatus>("get_sync_status");+ setStatus(newStatus);+ if (newStatus.isSyncing) {+ setTimeout(checkSync, 1000);+ } else {+ setIsSyncing(false);+ toast({+ title: "sync complete",+ description: "your data has been synced",+ });+ }+ };+ setTimeout(checkSync, 1000);+ } catch (error) {+ setIsSyncing(false);+ toast({+ title: "sync failed",+ description: String(error),+ variant: "destructive",+ });+ }+ };++ const handleUpdateConfig = async (updates: Partial<SyncConfig>) => {+ if (!config) return;++ const newConfig = { ...config, ...updates };+ try {+ await invoke("update_sync_config", { config: newConfig });+ setConfig(newConfig);+ } catch (error) {+ toast({+ title: "failed to update settings",+ description: String(error),+ variant: "destructive",+ });+ }+ };++ const handleRemoveDevice = async (deviceId: string) => {+ try {+ await invoke("remove_sync_device", { deviceId });+ setDevices((prev) => prev.filter((d) => d.deviceId !== deviceId));+ toast({+ title: "device removed",+ description: "the device has been unlinked from your sync",+ });+ } catch (error) {+ toast({+ title: "failed to remove device",+ description: String(error),+ variant: "destructive",+ });+ }+ };++ const handleDeleteCloudData = async () => {+ try {+ await invoke("delete_cloud_data");+ toast({+ title: "cloud data deleted",+ description: "all your cloud data has been permanently deleted",+ });+ await loadSyncData();+ } catch (error) {+ toast({+ title: "failed to delete data",+ description: String(error),+ variant: "destructive",+ });+ }+ };++ if (isLoading) {+ return (+ <div className="flex items-center justify-center p-8">+ <Loader2 className="h-6 w-6 animate-spin text-muted-foreground" />+ </div>+ );+ }++ const storagePercent =+ status?.storageUsed && status?.storageLimit+ ? (status.storageUsed / status.storageLimit) * 100+ : 0;++ return (+ <div className="space-y-6">+ {/* Header */}+ <div className="flex items-center justify-between">+ <div className="flex items-center gap-3">+ {status?.enabled ? (+ <Cloud className="h-5 w-5 text-primary" />+ ) : (+ <CloudOff className="h-5 w-5 text-muted-foreground" />+ )}+ <div>+ <h3 className="text-lg font-medium">cloud sync</h3>+ <p className="text-sm text-muted-foreground">+ sync your data across devices with end-to-end encryption+ </p>+ </div>+ </div>+ <Switch+ checked={status?.enabled ?? false}+ onCheckedChange={handleToggleSync}+ />+ </div>++ {status?.enabled && (+ <>+ <Separator />++ {/* Status Card */}+ <Card className="p-4 space-y-4">+ <div className="flex items-center justify-between">+ <div className="flex items-center gap-2">+ {status.isSyncing || isSyncing ? (+ <>+ <Loader2 className="h-4 w-4 animate-spin text-primary" />+ <span className="text-sm">syncing...</span>+ </>+ ) : status.lastError ? (+ <>+ <AlertCircle className="h-4 w-4 text-destructive" />+ <span className="text-sm text-destructive">+ {status.lastError}+ </span>+ </>+ ) : (+ <>+ <CheckCircle2 className="h-4 w-4 text-green-500" />+ <span className="text-sm text-muted-foreground">+ {status.lastSync+ ? `last synced ${formatRelativeTime(status.lastSync)}`+ : "never synced"}+ </span>+ </>+ )}+ </div>+ <Button+ variant="outline"+ size="sm"+ onClick={handleTriggerSync}+ disabled={isSyncing || status.isSyncing}+ >+ <RefreshCw+ className={`h-4 w-4 mr-2 ${+ isSyncing || status.isSyncing ? "animate-spin" : ""+ }`}+ />+ sync now+ </Button>+ </div>++ {/* Storage Usage */}+ {status.storageLimit && (+ <div className="space-y-2">+ <div className="flex items-center justify-between text-sm">+ <div className="flex items-center gap-2">+ <HardDrive className="h-4 w-4 text-muted-foreground" />+ <span>storage</span>+ </div>+ <span className="text-muted-foreground">+ {formatBytes(status.storageUsed ?? 0)} /{" "}+ {formatBytes(status.storageLimit)}+ </span>+ </div>+ <Progress value={storagePercent} className="h-2" />+ </div>+ )}++ {/* Tier Badge */}+ {status.syncTier && (+ <div className="flex items-center gap-2">+ <Badge variant="secondary">{status.syncTier}</Badge>+ <span className="text-sm text-muted-foreground">+ {status.deviceCount}/{status.deviceLimit} devices+ </span>+ </div>+ )}+ </Card>++ {/* Sync Options */}+ {config && (+ <>+ <Separator />+ <div className="space-y-4">+ <h4 className="text-sm font-medium">sync options</h4>++ <div className="space-y-3">+ <div className="flex items-center justify-between">+ <Label htmlFor="sync-transcripts" className="text-sm">+ transcripts+ </Label>+ <Switch+ id="sync-transcripts"+ checked={config.syncTranscripts}+ onCheckedChange={(checked) =>+ handleUpdateConfig({ syncTranscripts: checked })+ }+ />+ </div>++ <div className="flex items-center justify-between">+ <Label htmlFor="sync-ocr" className="text-sm">+ OCR text+ </Label>+ <Switch+ id="sync-ocr"+ checked={config.syncOcr}+ onCheckedChange={(checked) =>+ handleUpdateConfig({ syncOcr: checked })+ }+ />+ </div>++ <div className="flex items-center justify-between">+ <Label htmlFor="sync-audio" className="text-sm">+ audio recordings+ </Label>+ <Switch+ id="sync-audio"+ checked={config.syncAudio}+ onCheckedChange={(checked) =>+ handleUpdateConfig({ syncAudio: checked })+ }+ />+ </div>++ <div className="flex items-center justify-between">+ <Label htmlFor="sync-frames" className="text-sm">+ screen frames+ </Label>+ <Switch+ id="sync-frames"+ checked={config.syncFrames}+ onCheckedChange={(checked) =>+ handleUpdateConfig({ syncFrames: checked })+ }+ />+ </div>+ </div>++ <div className="flex items-center justify-between">+ <Label htmlFor="sync-interval" className="text-sm">+ sync frequency+ </Label>+ <Select+ value={String(config.syncIntervalMinutes)}+ onValueChange={(value) =>+ handleUpdateConfig({ syncIntervalMinutes: parseInt(value) })+ }+ >+ <SelectTrigger className="w-32">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ <SelectItem value="1">1 minute</SelectItem>+ <SelectItem value="5">5 minutes</SelectItem>+ <SelectItem value="15">15 minutes</SelectItem>+ <SelectItem value="30">30 minutes</SelectItem>+ <SelectItem value="60">1 hour</SelectItem>+ </SelectContent>+ </Select>+ </div>+ </div>+ </>+ )}++ {/* Devices */}+ {devices.length > 0 && (+ <>+ <Separator />+ <div className="space-y-4">+ <h4 className="text-sm font-medium">connected devices</h4>+ <div className="space-y-2">+ {devices.map((device) => (+ <Card+ key={device.deviceId}+ className="p-3 flex items-center justify-between"+ >+ <div className="flex items-center gap-3">+ <Laptop className="h-4 w-4 text-muted-foreground" />+ <div>+ <p className="text-sm font-medium">+ {device.deviceName || device.deviceId}+ {device.isCurrent && (+ <Badge variant="outline" className="ml-2 text-xs">+ this device+ </Badge>+ )}+ </p>+ <p className="text-xs text-muted-foreground">+ {device.deviceOs}+ {device.lastSyncAt &&+ ` • last synced ${formatRelativeTime(device.lastSyncAt)}`}+ </p>+ </div>+ </div>+ {!device.isCurrent && (+ <Button+ variant="ghost"+ size="sm"+ onClick={() => handleRemoveDevice(device.deviceId)}+ >+ <Trash2 className="h-4 w-4 text-muted-foreground" />+ </Button>+ )}+ </Card>+ ))}+ </div>+ </div>+ </>+ )}++ {/* Danger Zone */}+ <Separator />+ <div className="space-y-4">+ <h4 className="text-sm font-medium text-destructive">danger zone</h4>+ <div className="flex gap-2">+ <AlertDialog>+ <AlertDialogTrigger asChild>+ <Button variant="outline" size="sm">+ <Lock className="h-4 w-4 mr-2" />+ lock sync+ </Button>+ </AlertDialogTrigger>+ <AlertDialogContent>+ <AlertDialogHeader>+ <AlertDialogTitle>lock sync?</AlertDialogTitle>+ <AlertDialogDescription>+ this will clear your encryption keys from memory. you'll+ need to enter your password again to access synced data.+ </AlertDialogDescription>+ </AlertDialogHeader>+ <AlertDialogFooter>+ <AlertDialogCancel>cancel</AlertDialogCancel>+ <AlertDialogAction+ onClick={async () => {+ await invoke("lock_sync");+ await loadSyncData();+ }}+ >+ lock+ </AlertDialogAction>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog>++ <AlertDialog>+ <AlertDialogTrigger asChild>+ <Button variant="destructive" size="sm">+ <Trash2 className="h-4 w-4 mr-2" />+ delete cloud data+ </Button>+ </AlertDialogTrigger>+ <AlertDialogContent>+ <AlertDialogHeader>+ <AlertDialogTitle>delete all cloud data?</AlertDialogTitle>+ <AlertDialogDescription>+ this will permanently delete all your synced data from the+ cloud. this action cannot be undone. your local data will+ not be affected.+ </AlertDialogDescription>+ </AlertDialogHeader>+ <AlertDialogFooter>+ <AlertDialogCancel>cancel</AlertDialogCancel>+ <AlertDialogAction+ onClick={handleDeleteCloudData}+ className="bg-destructive text-destructive-foreground hover:bg-destructive/90"+ >+ delete forever+ </AlertDialogAction>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog>+ </div>+ </div>+ </>+ )}++ {/* Password Dialog */}+ <AlertDialog open={showPasswordDialog} onOpenChange={setShowPasswordDialog}>+ <AlertDialogContent>+ <AlertDialogHeader>+ <AlertDialogTitle>set up cloud sync</AlertDialogTitle>+ <AlertDialogDescription>+ enter a password to encrypt your data. this password is used to+ derive encryption keys - we never see your password or your data.+ </AlertDialogDescription>+ </AlertDialogHeader>+ <div className="py-4">+ <Input+ type="password"+ placeholder="enter encryption password"+ value={password}+ onChange={(e) => setPassword(e.target.value)}+ onKeyDown={(e) => {+ if (e.key === "Enter") handleInitSync();+ }}+ />+ <p className="text-xs text-muted-foreground mt-2">+ ⚠️ if you forget this password, your cloud data cannot be recovered+ </p>+ </div>+ <AlertDialogFooter>+ <AlertDialogCancel onClick={() => setPassword("")}>+ cancel+ </AlertDialogCancel>+ <AlertDialogAction onClick={handleInitSync} disabled={isInitializing}>+ {isInitializing ? (+ <Loader2 className="h-4 w-4 animate-spin mr-2" />+ ) : (+ <Unlock className="h-4 w-4 mr-2" />+ )}+ {isInitializing ? "initializing..." : "enable sync"}+ </AlertDialogAction>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog>+ </div>+ );+}diff --git a/screenpipe-app-tauri/src-tauri/src/main.rs b/screenpipe-app-tauri/src-tauri/src/main.rsindex 01fa1b44b..a5f804ee6 100755--- a/screenpipe-app-tauri/src-tauri/src/main.rs+++ b/screenpipe-app-tauri/src-tauri/src/main.rs@@ -50,6 +50,7 @@ mod window_api;mod windows_overlay;#[cfg(target_os = "macos")]mod space_monitor;+mod sync;pub use server::*;@@ -790,9 +791,23 @@ async fn main() {// Commands from tray.rsset_tray_unhealth_icon,set_tray_health_icon,+ // Commands from sync.rs+ sync::get_sync_status,+ sync::set_sync_enabled,+ sync::trigger_sync,+ sync::get_sync_config,+ sync::update_sync_config,+ sync::get_sync_devices,+ sync::remove_sync_device,+ sync::init_sync,+ sync::lock_sync,+ sync::delete_cloud_data,]).typ::<SettingsStore>()- .typ::<OnboardingStore>();+ .typ::<OnboardingStore>()+ .typ::<sync::SyncStatusResponse>()+ .typ::<sync::SyncDeviceInfo>()+ .typ::<sync::SyncConfig>();builder.export(@@ -898,7 +913,18 @@ async fn main() {update_global_shortcuts,suspend_global_shortcuts,resume_global_shortcuts,- get_env+ get_env,+ // Sync commands+ sync::get_sync_status,+ sync::set_sync_enabled,+ sync::trigger_sync,+ sync::get_sync_config,+ sync::update_sync_config,+ sync::get_sync_devices,+ sync::remove_sync_device,+ sync::init_sync,+ sync::lock_sync,+ sync::delete_cloud_data,]).setup(move |app| {//deep link register_all@@ -1025,6 +1051,9 @@ async fn main() {});app.manage(store.clone());+ // Initialize sync state+ app.manage(sync::SyncState::default());+// Initialize onboarding storelet onboarding_store = store::init_onboarding_store(&app.handle()).unwrap_or_else(|e| {error!("Failed to init onboarding store, using defaults: {}", e);diff --git a/screenpipe-app-tauri/src-tauri/src/sync.rs b/screenpipe-app-tauri/src-tauri/src/sync.rsnew file mode 100644index 000000000..1736a3c47--- /dev/null+++ b/screenpipe-app-tauri/src-tauri/src/sync.rs@@ -0,0 +1,217 @@+//! Tauri commands for cloud sync operations.++use serde::{Deserialize, Serialize};+use tauri::State;+use std::sync::Arc;+use tokio::sync::RwLock;++/// Sync state managed by Tauri.+pub struct SyncState {+ /// Whether sync is enabled+ pub enabled: Arc<RwLock<bool>>,+ /// Whether currently syncing+ pub is_syncing: Arc<RwLock<bool>>,+ /// Last sync timestamp+ pub last_sync: Arc<RwLock<Option<String>>>,+ /// Last sync error+ pub last_error: Arc<RwLock<Option<String>>>,+}++impl Default for SyncState {+ fn default() -> Self {+ Self {+ enabled: Arc::new(RwLock::new(false)),+ is_syncing: Arc::new(RwLock::new(false)),+ last_sync: Arc::new(RwLock::new(None)),+ last_error: Arc::new(RwLock::new(None)),+ }+ }+}++/// Sync status response.+#[derive(Debug, Clone, Serialize, Deserialize, specta::Type)]+#[serde(rename_all = "camelCase")]+pub struct SyncStatusResponse {+ pub enabled: bool,+ pub is_syncing: bool,+ pub last_sync: Option<String>,+ pub last_error: Option<String>,+ pub storage_used: Option<u64>,+ pub storage_limit: Option<u64>,+ pub device_count: Option<u32>,+ pub device_limit: Option<u32>,+ pub sync_tier: Option<String>,+}++/// Device information.+#[derive(Debug, Clone, Serialize, Deserialize, specta::Type)]+#[serde(rename_all = "camelCase")]+pub struct SyncDeviceInfo {+ pub id: String,+ pub device_id: String,+ pub device_name: Option<String>,+ pub device_os: String,+ pub last_sync_at: Option<String>,+ pub created_at: String,+ pub is_current: bool,+}++/// Sync configuration.+#[derive(Debug, Clone, Serialize, Deserialize, specta::Type)]+#[serde(rename_all = "camelCase")]+pub struct SyncConfig {+ pub enabled: bool,+ pub sync_interval_minutes: u32,+ pub sync_transcripts: bool,+ pub sync_ocr: bool,+ pub sync_audio: bool,+ pub sync_frames: bool,+}++impl Default for SyncConfig {+ fn default() -> Self {+ Self {+ enabled: false,+ sync_interval_minutes: 5,+ sync_transcripts: true,+ sync_ocr: true,+ sync_audio: false,+ sync_frames: false,+ }+ }+}++/// Get current sync status.+#[tauri::command]+#[specta::specta]+pub async fn get_sync_status(state: State<'_, SyncState>) -> Result<SyncStatusResponse, String> {+ let enabled = *state.enabled.read().await;+ let is_syncing = *state.is_syncing.read().await;+ let last_sync = state.last_sync.read().await.clone();+ let last_error = state.last_error.read().await.clone();++ Ok(SyncStatusResponse {+ enabled,+ is_syncing,+ last_sync,+ last_error,+ // These would be fetched from the API in a real implementation+ storage_used: None,+ storage_limit: None,+ device_count: None,+ device_limit: None,+ sync_tier: None,+ })+}++/// Enable or disable sync.+#[tauri::command]+#[specta::specta]+pub async fn set_sync_enabled(+ state: State<'_, SyncState>,+ enabled: bool,+) -> Result<(), String> {+ *state.enabled.write().await = enabled;+ Ok(())+}++/// Trigger an immediate sync.+#[tauri::command]+#[specta::specta]+pub async fn trigger_sync(state: State<'_, SyncState>) -> Result<(), String> {+ let enabled = *state.enabled.read().await;+ if !enabled {+ return Err("sync is not enabled".to_string());+ }++ let is_syncing = *state.is_syncing.read().await;+ if is_syncing {+ return Err("sync already in progress".to_string());+ }++ // In a real implementation, this would trigger the sync service+ *state.is_syncing.write().await = true;++ // Simulate sync completion (in real impl, this would be handled by the service)+ tokio::spawn({+ let is_syncing = state.is_syncing.clone();+ let last_sync = state.last_sync.clone();+ async move {+ tokio::time::sleep(tokio::time::Duration::from_secs(2)).await;+ *is_syncing.write().await = false;+ *last_sync.write().await = Some(chrono::Utc::now().to_rfc3339());+ }+ });++ Ok(())+}++/// Get sync configuration.+#[tauri::command]+#[specta::specta]+pub async fn get_sync_config() -> Result<SyncConfig, String> {+ // In a real implementation, this would read from persistent storage+ Ok(SyncConfig::default())+}++/// Update sync configuration.+#[tauri::command]+#[specta::specta]+pub async fn update_sync_config(+ state: State<'_, SyncState>,+ config: SyncConfig,+) -> Result<(), String> {+ *state.enabled.write().await = config.enabled;+ // In a real implementation, this would persist the config and update the service+ Ok(())+}++/// Get list of registered devices.+#[tauri::command]+#[specta::specta]+pub async fn get_sync_devices() -> Result<Vec<SyncDeviceInfo>, String> {+ // In a real implementation, this would call the API+ Ok(vec![])+}++/// Remove a device from sync.+#[tauri::command]+#[specta::specta]+pub async fn remove_sync_device(_device_id: String) -> Result<(), String> {+ // In a real implementation, this would call the API+ Ok(())+}++/// Initialize sync with password.+#[tauri::command]+#[specta::specta]+pub async fn init_sync(+ state: State<'_, SyncState>,+ _password: String,+) -> Result<bool, String> {+ // In a real implementation, this would:+ // 1. Call the sync API to initialize+ // 2. Store the encrypted keys locally+ // 3. Start the sync service++ *state.enabled.write().await = true;++ // Return true if new user, false if existing+ Ok(true)+}++/// Lock sync (clear keys from memory).+#[tauri::command]+#[specta::specta]+pub async fn lock_sync(state: State<'_, SyncState>) -> Result<(), String> {+ *state.enabled.write().await = false;+ Ok(())+}++/// Delete all cloud data.+#[tauri::command]+#[specta::specta]+pub async fn delete_cloud_data() -> Result<(), String> {+ // In a real implementation, this would call the API to delete all data+ Ok(())+}