Repository navigation
Add the portable settings document for settings sync - #989
Merged
Merged
Conversation
Define the versioned document that carries a user's preferences between desktops: app settings, custom switch profiles, switch bindings including keys, point scan and scan preferences, keyboard layout and remote switch slots. Device identity, pairing, telemetry consent, setup progress and startup registration stay local. Incoming documents are parsed (rejecting newer schema versions), fully validated, and merged with local-only values before anything changes. Only sections that differ are applied, each through the same path as a local save. save_settings now shares apply_app_settings with this path. Refs #985 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Address review on the portable settings document: - Require an exact JSON round trip when parsing, so partial documents or fields from a newer build are rejected instead of silently resetting point scan or scan preferences. A test pins the synced point scan fields. - Reserve built-in profile names on every platform. A custom profile synced from a Mac named after Windows' Grid 3 is renamed rather than blocking the whole document, and local saves now reject reserved names. - Compare profile names ASCII case-insensitively, as local saves do. - Document main-thread use and retry-converges semantics of apply. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Address re-review: a custom profile saved under a now-reserved built-in
name (e.g. "Grid 3" on a Mac) is renamed once when the model loads, so
it stays editable, and synced documents rename the same way. The suffix
skips names already in use ("(custom 2)", ...) so two such profiles
cannot block sync.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Closes #985
Part of #988.
What
Adds
src-tauri/src/portable_settings.rs, the versioned document (schemaVersion: 1) that the sync engine (#986) will store indesktop_preferences.payload.Synced:
Kept local:
desktopId, paired devices and pairing tokens, telemetry install id and consent, setup flags,startWithSystem, the remote configrevisioncounter, the current scan mode, and the legacy point-scan key fields (superseded by switch bindings).Deviation from the plan:
shareDiagnosticsis also kept local. It is the telemetry consent, and consent should be given on each install rather than arrive from another machine.Applying incoming documents
parserejects documents with a newerschemaVersion(ParseError::Newer, with an "update Switchify PC" message) as well as malformed ones. Unknown fields are rejected, so additions require a schema bump.planvalidates every section before anything changes. App settings usenormalized(); switches and remote slots usevalidate(); point scan usesConfig::validate(); profiles use the samevalidate_profilerules plus the uniqueness and 32-profile limits.planalso merges in local-only values and returns only the sections that differ, so unchanged sections are never re-applied. (A point-scan apply resets the scanner.)applyruns on the main thread and goes through the existing save paths:switch_runtime::Controller::save(pausing point scan first), thenremote_scan::applyremote_scan::savepoint_scan_runtime::configureupdate_point_settingapply_app_settings, newly extracted fromsave_settingsso startup, consent, dwell, repeat and overlay side effects stay identicalAppModel::persistIt refuses to run during switch practice, like the settings commands.
Profile versions: a profile whose bindings, name or provider changed gets a version above both copies, so connected phones pick it up. An unchanged profile keeps its local version.
Nothing calls the module yet;
#986wires it into the sync engine. It carries#![allow(dead_code)]until then.Validation
npm run prediction-model,npm run lint,npm test(254 passed) andnpm run buildcargo fmt --checkandcargo clippy --all-targets -D warnings: cleancargo test: 660 passed, 3 ignored, including 21 newportable_settingstests covering:🤖 Generated with Claude Code