fix(pairing): avoid stale full config overwrite during origin patch#325
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(pairing): avoid stale full config overwrite during origin patch#325cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
auto_pair_device always patches gateway.controlUi.allowedOrigins. The previous implementation saved the entire config snapshot captured at read time, which could clobber concurrent user edits to gateway auth, models, or channels when WebSocket auto-pair ran during reconnect. Write only the allowedOrigins delta through the existing merge path so other fields on disk are preserved. Co-authored-by: 晴天 <1186258278@users.noreply.github.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.
Bug and impact
auto_pair_device()always callspatch_gateway_origins()on WebSocket reconnect (common on Windows pairing/origin failures). The previous implementation readopenclaw.json, patchedallowedOrigins, then wrote the entire stale snapshot back to disk.If the user saved config concurrently (gateway auth/token, models, channels, etc.), the stale snapshot could overwrite those edits — silent config loss.
Root cause
patch_gateway_origins/patchGatewayOriginstreated the read-time config as the full source of truth instead of issuing a targeted update. Even on Tauri,save_openclaw_jsonmerges shallowly, so a full stalegatewayobject could revert freshly savedgateway.authand other nested fields.This risk increased after the recent pairing stabilization work (
e16ff2b), which made origin patching run on every auto-pair attempt.Fix
pairing.rs): compute mergedallowedOrigins, then callsave_openclaw_jsonwith only{ gateway: { controlUi: { allowedOrigins } } }so merge preserves unrelated fields.dev-api.js): same partial patch, merged viamergeConfigsPreservingFieldsbefore write.Validation
tests/patch-gateway-origins.test.js(source-level regression guard)partial_gateway_patch_preserves_auth_tokenmerge test inconfig.rsnode --test tests/patch-gateway-origins.test.js→ 2/2 pass