Repository navigation
feat: sync OpenChamber preferences with a per-field newest-wins merge - #108
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 #97
What
Opt-in sync of OpenChamber settings, off by default:
{ "openChamber": { "enabled": true, "include": [], "exclude": [], "path": "<optional>" } }~/.config/openchamber/preferences.jsonis stored as{ "version": 1, "fields": { "<name>": { "value": ..., "updatedAt": ... } } }. This merges it field by field, newestupdatedAtwins, in both directions:config/openchamber/preferences.jsonin the sync repo (sorted keys, written only when something changed).Safety
includereplaces it (a trailing*is a prefix wildcard),excluderemoves from it. Selected and recent models, projects and everything else stay local unless added.include(token,secret,password,credential,private,api key,vapid,identity).surfacesis per-device (for example a theme imported on one machine) and is never written to the repo; localsurfacesare preserved on pull.preferences.json.pre-opencode-syncedbackup. A missing local file is never created, a malformed file is skipped, and aversionmismatch skips the merge.Why not
extraConfigPathsExtra paths copy whole files, so machine-local state (selected model, recents) is overwritten on every pull, the running app can clobber the result, and there is no field allowlist. See #97 for the longer discussion.
Integration
resolveOpenChamberPlan()builds the plan;syncRepoToLocalandsyncLocalToRepotake it as an optional option, and the six existing call sites inservice.tspass it. With the feature disabled the plan isnulland nothing changes.statusprintsOpenChamber preferences: enabled|disabled.Tests
openchamber.test.ts: allowlist/include/exclude and wildcard behaviour, credential-like names refused even if included, push copies only allowed fields and dropssurfaces, newest-wins in both directions, no rewrite when nothing is newer, missing/malformed/version-mismatched files, backup made once, mode preserved, missing local file not created, plan resolution (disabled, default path, custom~path).apply.test.ts: push then pull throughsyncLocalToRepo/syncRepoToLocal, and no OpenChamber activity without a plan.preferences.json(69 fields): 17 default fields were synced, the other 52 and allsurfacesstayed local, and a second push and a pull were no-ops.bun run check,bun run test(219 passing) andbun run buildpass.