Repository navigation
Smart Sync: keep Owned blueprints the same across PCs (#567) - #598
Draft
Osiris-DevWorks wants to merge 1 commit into
Draft
Osiris-DevWorks wants to merge 1 commit into
Osiris-DevWorks wants to merge 1 commit into
Conversation
Share the owned blueprints through a folder the player's cloud app already syncs. Each PC writes only its own machine-<id>.json in a 'Smart Citizen Sync' folder and reads everyone's; the newest change per blueprint wins, so a blueprint moved back to Available stays there. - src/utils/smart_sync.py: Qt-free ledger, merge and folder sync - AppSettings: smart_sync/* keys (excluded from backups), the ledger recorded by set_owned_items, Import Settings adds while sync is on - SmartSyncWorker; MainWindow syncs at startup, after Owned changes, when the folder changes, and pushes a pending change at close - Config tab: Smart Sync folder picker, Turn Off, status line - UI strings and HELP in every language (AI text for non-English) - tests/test_smart_sync.py Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011hqxFfzZY3bs9NpC8k6upk
Open
This branch has not been deployed
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.
Requested by Amr · project thread
Closes #567.
What it does
Blueprints earned on one PC now show as Owned on the others. The player picks a folder their cloud app already syncs (Google Drive for Desktop, OneDrive, Dropbox, a NAS) in Config > Smart Sync, and picks the same folder on their other PCs. Smart Citizen makes no network calls itself.
<folder>\Smart Citizen Sync\machine-<8 random hex>.jsonand reads all of them, so the cloud app never has to resolve a conflict. Files are written in one step (atomic_io). A conflicted copy the cloud app makes anyway is read like the rest._recompute_owned), whenever aQFileSystemWatchersees another PC's file change, and at close for a change still waiting. The read/merge/write runs onSmartSyncWorker; the owned set is only written on the GUI thread.Changes
src/utils/smart_sync.py(new, Qt-free): ledgerrecord/baseline/merge, fileencode/decode,sync().src/utils/settings.py:smart_sync/folder,machine_id,owned_ledger,last_written, all inPROFILE_EXCLUDE_KEYSso a backup restored on another PC never brings this PC's id.set_owned_itemsrecords into the ledger while sync is on.import_valuesadds a backup's owned set while sync is on instead of replacing it (a replace would read as every newer blueprint moved back, and sync would spread that to every PC). With sync off, Import behaves as before.src/gui/workers.py:SmartSyncWorker(errors at WARNING, so no error box).src/gui/main_window.py: the sync hooks,_take_smart_sync_result(merges the local ledger once more so a change made during the sync wins), close handling.src/gui/config_tab.py: Smart Sync group: folder field (read-only), Browse, Turn Off, status line. Retranslates.ht, AI text inat. HELP.md bullet in every language.src/utils/CLAUDE.md,src/gui/CLAUDE.md,tests/CLAUDE.mdentries.Decisions worth a look
updatedthan it last wrote, it takes a new id and keeps merging.Tests
tests/test_smart_sync.py: 47 tests (core, settings, worker on a real thread, the window's result handling). All pass locally.Manual test (two PCs, or two data folders on one PC)
The tester Test Plan (
test_plan.py) still covers 3.0.0. I left that to the pre-release refresh.Generated by Claude Code