Repository navigation
fix(ui): persist Control UI settings across reconnects via gateway-owned LWW prefs writes - #114286
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 27, 2026, 1:07 AM ET / 05:07 UTC. ClawSweeper reviewWhat this changesThe branch lets the gateway accept narrowly constrained hash-free last-writer-wins writes for Merge readiness⛔ Blocked until stronger real behavior proof is added - 5 items remain Keep this PR open. It addresses a plausible P1 regression at the correct gateway/UI ownership boundary, but the proposed hash-free Priority: P1 Review scores
Verification
How this fits togetherControl UI settings are mirrored locally in the browser and synchronized to gateway configuration. Browser edits pass through the gateway’s configuration write path, then flow back through runtime configuration snapshots to update connected tabs and devices. flowchart LR
A[Control UI settings edit] --> B[Pending browser preference intent]
B --> C[Gateway config.patch request]
C --> D{ui.prefs leaf-only write?}
D -->|Yes| E[Gateway LWW config write]
D -->|No| F[Strict whole-config CAS]
E --> G[Gateway config snapshot]
F --> G
G --> H[UI reconciliation and refresh]
Decision needed
Why: This is a deliberate compatibility and concurrency-policy change, not only a local UI repair; the gateway boundary determines its long-term behavior for all callers. Before merge
Agent review detailsSecurityNone. PR surfaceSource +189, Tests +898. Total +1087 across 9 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep strict whole-document CAS as the default, accept the leaf-only Do we have a high-confidence way to reproduce the issue? Unclear for a high-confidence live reproduction from the available evidence. The new focused tests and detailed failure model make the source path reproducible, but the claimed real gateway run has no inspectable artifact or transcript. Is this the best way to solve the issue? Unclear. Moving concurrent-write serialization to the gateway is a stronger boundary than the closed client-only predecessor, but maintainers must first decide whether the generic configuration patch protocol should carry this permanent leaf-level LWW exception. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 16d2b7e46784. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Addressing the review's decision item and rank-up moves:
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
Merged via squash.
|
…ned LWW prefs writes (openclaw#114286) * fix(ui): sync Control UI prefs via hash-free LWW config.patch * test(ui): prove prefs reconnect replay end to end * fix(gateway): surface hash-free prefs commit races instead of replaying stale intent * fix(ui): never re-reconcile a retained config snapshot over acked prefs * fix(ui): merge persisted pending prefs across tabs instead of clobbering * test(ui): pass current runtime config through sidebar prefs reconcile fixture
What Problem This Solves
Control UI settings (theme, language, chat preferences, sidebar sessions) sync
into gateway config
ui.prefsthroughconfig.patchguarded by awhole-document CAS
baseHash. Two tabs or a Gateway reconnect lose writes:the browser-side queue fetches
config.get, patches with that hash, retriesonce, then silently drops the edit. Edits made while disconnected never
replay, and a tab that loses a CAS race to a sibling tab never persists its
preference. This is the issue PR #114170 attempted to fix client-side; its
own live two-tab reconnect proof failed twice (on head
049e0eaand on thestronger unpublished candidate
85adc15), so that PR is closed in favor ofthis boundary-correct replacement.
Why This Change Was Made
Only the gateway can serialize concurrent preference writers; per-tab module
state categorically cannot fence a sibling tab. This PR therefore fixes the
issue at the ownership boundary:
config.patchnow accepts a hash-free patch iff every changedpath is inside the documented last-writer-wins preference subtree
(
ui.prefs) AND the patch is a leaf-level operation (container replacementor deletion at/above
ui.prefsstill requires the document CAS, so a staleclient cannot wipe concurrently added keys). The server already owns the
merge, validation, destructive-array guard, and a lock-time CAS inside
replaceConfigFile. A lost commit race deliberately surfaces to the clientinstead of retrying server-side: a server retry would replay frozen stale
intent over the winner, while the client's retry replays current intent.
Every other path keeps the strict document CAS unchanged,
baseHashwasalready optional in the wire schema, and no protocol or config surface
changes.
config.get-before-patch, and stale-hashsuppression set are deleted. Local edits become per-key pending intent that
shadows server reconciliation until the gateway acks, persists per gateway
scope in localStorage, and replays on reconnect (
flushServerUiPrefsfireson the connected transition even when the reconnect reuses the client
object). Commit-race conflicts retry once, then reschedule a bounded
delayed drain — conflicts imply another writer made progress, so this
converges. After each ack the runtime config capability refreshes, and its
existing request-version fencing discards stale in-flight
config.getresponses, closing the echo flip-flop window.
dead prior-connection flight no longer blocks the explicit-op FIFO after
reconnect, and
set()captures its connection epoch at enqueue so apre-reconnect submission cannot commit into the new connection.
User Impact
Settings changes persist across Gateway restarts, reconnects, and multiple
concurrent tabs/devices. Edits made while disconnected are retained and
written once the connection returns. Concurrent writers on disjoint
preferences no longer conflict; same-key writers converge last-writer-wins,
matching user expectation for UI preferences. Viewer-scope clients keep the
existing silent device-local degrade. No config or protocol surface changes.
Evidence
src/gateway/server-methods/config.test.ts(hash-free LWWgate, mixed-path rejection, destructive-array guard, noop, stale-hash
strict-mode preservation, commit-race retry),
ui/src/app/server-prefs.test.ts(pending-intent model incl. offline retention + reconnect flush, shadowed
reconciliation, retained-snapshot memo, cross-tab pending merge, conflict
retry vs validation drop),
ui/src/lib/config/index.test.ts(FIFO release +epoch-captured set). 126 tests green via
node scripts/run-vitest.mjs(20 gateway + 103 ui + 3 e2e); expandedcheck-changed(formatting, core/UI typechecks, lint, architecture,storage guards) passed remotely on Blacksmith Testbox, exit 0.
ui/src/e2e/settings-prefs-reconnect.e2e.test.ts(real Chromium executed, no skips): offline edit replays after a
same-client reconnect as a hash-free
config.patch(asserted: nobaseHash, no CASconfig.get, zero patches escape while disconnected);two pages with disjoint keys both persist; a server delta applies without
reverting a pending local key.
fixed in-branch (server-side retry replaying frozen stale intent over a
race winner; container-level hashless ops; retained-snapshot
re-reconciliation reverting acked prefs; cross-tab persisted-pending
clobber). Two findings consciously rejected with code proof: post-backoff
epoch recheck (the guard is the first statement of every attempt
iteration) and retain-on-transient-error (retention would permanently
stick the pending shadow for viewer-scope clients; drop releases the
shadow and matches the documented device-local degrade). Final delta
review clean:
patch is correct (0.91).tbx_01kygyxbpxr8awqaxdd5j73qkn(Actions run
30238422165): production build, isolated loopback gateway(port 43019, dedicated state dir, real
/readyz), two authenticated realChromium pages (
/settings/appearance,/settings/general). Onlinetheme=knotpersisted; SIGTERM; both pages reached reconnecting; offlinetheme=dash+locale=frwith zero patches escaping while down; gatewayrestart; after reconnect the gateway's
openclaw.jsonphysically ended as{"locale":"fr","theme":"dash"}— and the dash replay survived a livestale-config rejection through the client retry, the exact point where
both fix(ui): preserve settings across concurrent Gateway writes #114170 candidates failed. Artifact SHA-256:
initial.png 692e41aa…187c78,pre-reconnect.png 839df5f2…450c63,disconnected.png 63688719…bfca08, final pagese63d0790…694e77/ddb7a013…8d0ad3,result.json bad03705…27a076,gateway.log c08625fd…9741f4,structured-stdout.log e8b4c270…12da1e.One honest residual: the page that selected French offline kept English
chrome until reload because
i18n.setLocalenever retries a lazy bundlefetch that failed while the gateway was down — a pre-existing
mainbugindependent of this PR (the sibling page rendered French correctly via the
server delta); follow-up task filed.
app-host.test.tsfixturethat predated the new reconcile identity fence (fake context without
runtimeConfig); fixed inf50600b. Full CI green on that head: Actionsrun
30238640504.verification by maintainer session).