Repository navigation
feat: add optional periodic config sync (autoSync) - #107
Open
Rahulsharma0810 wants to merge 1 commit into
Open
Rahulsharma0810 wants to merge 1 commit into
Rahulsharma0810 wants to merge 1 commit into
Conversation
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 #98
What
Optional periodic config sync, off by default:
{ "autoSync": { "enabled": true, "intervalSec": 300, "push": true, "pull": true } }intervalSecdefaults to 300 and is clamped to a minimum of 30.unref'd, cleared ondispose, re-evaluated against the config file on every tick, and skipped while another sync holds the lock) runs one pass:syncLocalToRepo;Why not just reuse the startup flow
runStartuppulls and applies the remote as soon as it is ahead, without checking for unpushed local edits. Running that every few minutes would silently overwrite edits made since the last sync, so the periodic pass checks for local changes first and stops on a conflict. I did not change startup behaviour in this PR.Notes
opencode-synced.jsoncis itself a synced file, so enablingautoSyncon one machine enables it on the others at their next pull. This is documented in the README and exercised by the test.getAheadBehindinrepo.tsis now exported so the cycle can reuse it.syncIntervalSecsetting is unchanged and still only applies to session sync.Tests
config.test.ts: normalization (disabled by default, minimum interval, invalid values,push/pulldefaults).service.test.ts(auto sync), using two machines against a local bare remote and drivingrunAutoSyncCycledirectly:conflict, the local edit is kept, the sync clone is left clean, the remote is untouched, and the notice is shown once across two passes;push: falsestages nothing and leaves the clone clean;pull: falseskips when the remote is ahead;setIntervalwith the configured period when enabled, cleared ondispose.bun run check,bun run test(210 passing) andbun run buildpass.