Prevent first-time sync enable from overwriting remote settings#528
Draft
Prevent first-time sync enable from overwriting remote settings#528
Conversation
Agent-Logs-Url: https://github.com/salarcode/SmartProxy/sessions/69f46906-6c9e-45c5-8d08-6a4715b56051 Co-authored-by: salarcode <1272095+salarcode@users.noreply.github.com>
Agent-Logs-Url: https://github.com/salarcode/SmartProxy/sessions/69f46906-6c9e-45c5-8d08-6a4715b56051 Co-authored-by: salarcode <1272095+salarcode@users.noreply.github.com>
Agent-Logs-Url: https://github.com/salarcode/SmartProxy/sessions/69f46906-6c9e-45c5-8d08-6a4715b56051 Co-authored-by: salarcode <1272095+salarcode@users.noreply.github.com>
Agent-Logs-Url: https://github.com/salarcode/SmartProxy/sessions/69f46906-6c9e-45c5-8d08-6a4715b56051 Co-authored-by: salarcode <1272095+salarcode@users.noreply.github.com>
Agent-Logs-Url: https://github.com/salarcode/SmartProxy/sessions/69f46906-6c9e-45c5-8d08-6a4715b56051 Co-authored-by: salarcode <1272095+salarcode@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix settings sync behavior for new browser installations
Prevent first-time sync enable from overwriting remote settings
Apr 9, 2026
There was a problem hiding this comment.
Pull request overview
This PR adjusts the “enable settings sync” flow to avoid pushing an effectively empty local configuration on first enable (which could wipe existing synced settings). Instead, it pulls from the configured backend first, performs a one-time merge, and only uploads if the merge actually adds data.
Changes:
- Added an initial-sync merge flow in
SettingsOperationthat reads from the configured backend, merges local into remote, applies merged settings, and conditionally uploads. - Implemented merge helpers for proxy servers, proxy server subscriptions, smart profiles (including rules and rule subscriptions), plus a post-merge subscription reload.
- Updated the
SettingsPageSaveOptionshandler to intercept the first transition tosyncSettings = trueand route through the initial merge flow.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/core/SettingsOperation.ts | Adds initial-sync read/merge/apply logic and merge utilities to prevent first-time enable from overwriting remote. |
| src/core/Core.ts | Intercepts first-time sync enable during options save and runs the new initial merge flow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Change strict equality to loose equality for matching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enabling settings sync on a new browser instance could upload an effectively empty local config before reading existing synced data, wiping settings on other devices. This changes first-time sync enable to pull from the configured backend first, merge once, and only upload when needed.
Initial sync enable flow
SettingsPageSaveOptionswhensyncSettingstransitions from disabled to enabled.saveAllSync()path for that first enable.One-time merge behavior
Merge rules
applySyncSettingspath.Post-merge sync behavior
Runtime consistency
Example of the new control flow: