Workflow
User Data Synchronization
End-to-end sync of user settings: authentication, remote fetch, three-way merge, local apply, and notification of all components.
User Data Synchronization
Describes the process of syncing user settings: user authentication, fetching data from a remote store, three-way merge, applying changes locally, and notifying all parts of the application.
Verify against Mountain/Source/Environment/SynchronizationProvider.rs for the actual implementation.
Data Flow
Phase 1: Authentication
User clicks "Sign In"
-> AuthenticationService triggers OAuth session request
-> Cocoon AuthenticationProvider sends $getSession gRPC to Mountain
-> Mountain handles OAuth flow (browser redirect, callback)
-> Token stored securely in keyring via SecretsProvider
-> User signed in, UserDataSyncAccountService has identity + token
Phase 2: Triggering Synchronization
-> UserDataAutoSyncService triggered (after sign-in, manual, or interval)
-> Calls UserDataSyncService.sync()
-> Iterates through registered synchronizers (settings, extensions, etc.)
Phase 3: Synchronizing Settings
-> SettingsSynchronizer.fetches remote settings via UserDataSyncStoreService
-> GET request to cloud endpoint with OAuth token
-> Remote server returns stored settings.json
-> Mountain reads local settings.json via FsReader
-> Three-way merge: local + remote + base (last sync state)
-> Resolves conflicts intelligently
Phase 4: Applying Merged State
-> FsWriter writes merged settings.json to disk
-> ConfigurationService.reloadConfiguration()
-> Re-reads config files, reconstructs effective configuration
-> Updates AppState.Configuration
-> $acceptConfigurationChanged gRPC to Cocoon
-> sky://configuration/changed Tauri event to Wind
Phase 5: UI and Extension Host React
-> Cocoon ConfigurationProvider updates cache
-> Fires onDidChangeConfiguration (vscode.workspace.onDidChangeConfiguration)
-> Wind settings UI re-renders with new values
-> Editor applies settings like fontSize
-> Extensions receive new settings, adjust behaviorPhase 1: User Authentication (Wind/Sky -> Cocoon -> Mountain)
- User clicks “Sign In” in the Account menu.
workbench.action.authentication.signIndispatched. AuthenticationServicein Wind triggers a request to Cocoon’sAuthenticationProvider.- Cocoon makes
$getSessiongRPC to Mountain. Mountain handles OAuth flow (browser window, callback URI). - OAuth token stored in system keyring via
SecretsProvider.UserDataSyncAccountServicereceives identity and token.
Phase 2: Triggering Synchronization (Mountain)
UserDataAutoSyncServicetriggers (post-sign-in, manual, or scheduled). Orchestrates what to sync and in order.- Calls
UserDataSyncService.sync(), which iterates through registered synchronizers (settings, extensions, keybindings, snippets).
Phase 3: Three-Way Merge (Mountain)
SettingsSynchronizerfetches remotesettings.jsonvia authenticated GET to a cloud endpoint.- Reads local
settings.jsonviaFsReader. - Performs three-way merge: compares local, remote, and base versions (state from last successful sync, stored locally).
- Intelligently combines changes: if user added settings on both machines, merge contains both. Direct conflicts flagged for user resolution.
Phase 4: Applying Changes (Mountain)
FsWriterwrites merged content back to localsettings.json.ConfigurationService.reloadConfiguration()re-reads all settings files, reconstructs effective configuration, updatesConfigurationinAppState.
Phase 5: Notify Cocoon and Wind (Mountain -> All)
ConfigurationServicesends$acceptConfigurationChangedgRPC to Cocoon with changed key summary.- Emits
sky://configuration/changedTauri event to Wind/Sky. - Cocoon’s
ConfigurationProviderupdates its cache, firesonDidChangeConfigurationto extensions. - Wind components re-render with new values.
Key Source Files
Mountain/Source/Environment/SynchronizationProvider.rs— sync implementation (verify)vs/platform/userDataSync/common/settingsMerge.ts— merge logic
