Skip to content

fix(ui): preserve settings across concurrent Gateway writes - #114170

Closed
steipete wants to merge 1 commit into
mainfrom
codex/autoqa-settings-write-ownership-c66ca2fb-r2
Closed

steipete wants to merge 1 commit into
mainfrom
codex/autoqa-settings-write-ownership-c66ca2fb-r2

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users changing Control UI Settings, sidebar sessions,
locale, or chat preferences could lose updates, inherit the previous account's
private sidebar, or permanently stop saving after a same-client Gateway
reconnect, an already-loaded snapshot, or a concurrent configuration write.

Why This Change Was Made

Make the existing runtime configuration capability the sole physical Settings
writer. Carry the authoritative snapshot's actual physical connection epoch
through the owner, and fence subscriptions, sidebar projections, queued
writes, and stale callbacks by that same runtime, source object, content
hash, and epoch.

An already-loaded authoritative reconnect snapshot now permits the first
real preference writes immediately; a retained old-connection snapshot
still cannot bypass the refresh barrier. A permanently stalled previous
write queue is retired with its connection. A genuine foreign-owner CAS
conflict rebuilds from complete current configuration and retries once.

This change does not modify provider/SSE contracts, authentication, approval
policy, public Gateway protocol, SQLite state/schema, plugin/catalog trust,
or public CLI compatibility.

User Impact

Settings changes complete and physically persist when users reconnect or run
multiple sessions. The current account retains its own sidebar and locale;
delayed callbacks or dead writes from an old connection cannot corrupt or
block it. Concurrent Skills and MCP configuration owners retain their data.

Evidence

  • Exact clean main base:
    c66ca2fbb2b038f4796abfa76bd52dcc3b675b02.
  • Exact Peter-authored commit:
    049e0ea2ad566aabc43763da3ec6f08d1f1b2d18.
  • Initial current-main fail-first proof, with production byte-pristine:
    42 failed / 104 passed, exit 1.
  • A genuine first official reviewer identified a further snapshot-first
    reconnect P1. With all three production files still identical to the
    rejected commit, the new targeted regression produced 2 failed cases
    and zero physical writes, exit 1. The root cause is fixed rather than
    waived; the preserved rejected-review artifact is
    06e5087639bf9b22879612b52fed06f364d3eaac5162c008127b5ed7a503f7d2.
  • Corrected final owner suites: 149/149 passed. Root independently ran
    all 13 affected UI suites, including both newly merged Skills view and
    runtime-capability suites: 303/303 passed, exit 0.
  • Twelve marker, runtime, and arrival-order combinations each exercise ten
    stale callbacks and prove both new-owner system and fr physical
    config.patch writes. Foreign CAS, repeated content hashes, hashless
    acknowledgements, no-op, failed authoritative reload, updater suspension,
    Skills/MCP writer ownership, and sidebar privacy remain covered.
  • Fresh final gpt-5.6-sol high official structured review:
    019fa00e-4873-7f02-8717-3ff08afc2f56; PASS, zero findings,
    patch is correct, confidence 0.91, artifact SHA-256
    07242d002706c4a8968e4dc0845f1663a906036be1b65e847923b12324be40c4.
  • Full exact-source remote changed gate passed on sole Testbox
    tbx_01kyg0xne76f61m7t3we1s98jb, Actions run 30218488698:
    PASS, original wrapper exit 0, commandMs=274654,
    totalMs=306335, native exitCode=0, and zero warnings or errors.
    Both strict type-checks, formatting, package, architecture, SDK,
    translation, and 245-rule lint guards passed. The temporary full checkout
    correctly overlays the exact five committed source blobs onto synthetic
    current base c66; the six synchronized transport items are not claimed
    as six changed product files or a remote checkout of the local commit.
  • No Browser screenshot or current-head live-provider pass is claimed.
    Historical ten-session results are accurately historical; the new
    one-Gateway, ten-GPT-5.4, medium-sized-task scenario will set
    retryCount: 0 and run after the verified merge.
  • AI-assisted; the before/after reproduction, official-review finding,
    corrected source, current Skills consumers, and exact commit were each
    independently verified.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: XL maintainer Maintainer-authored PR labels Jul 26, 2026
@steipete
steipete marked this pull request as ready for review July 26, 2026 20:19
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jul 26, 2026
@clawsweeper

clawsweeper Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 26, 2026, 4:24 PM ET / 20:24 UTC.

ClawSweeper review

What this changes

This PR makes the Control UI use the runtime configuration capability as the sole settings writer, adding connection-epoch and snapshot-freshness fences so stale Gateway callbacks or concurrent writes cannot overwrite another account’s preferences, sidebar state, or locale.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 4 items remain

Keep this PR open for explicit maintainer handling. The branch has substantial targeted regression coverage and passed the supplied automated gates, but it changes Control UI preference/session reconciliation across Gateway reconnects and provides no independently inspectable after-fix runtime UI proof; the existing maintainer label also prevents cleanup closure.

Priority: P2
Reviewed head: 049e0ea2ad566aabc43763da3ec6f08d1f1b2d18

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation has substantial supplied automated coverage, but proof remains test-only for a browser-side reconnect and state-isolation change.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR body reports extensive tests, structured review, and changed-gate results, but does not include an inspectable after-fix Control UI runtime artifact; add a redacted recording, terminal/live output, or runtime logs showing reconnect plus competing preference writes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body reports extensive tests, structured review, and changed-gate results, but does not include an inspectable after-fix Control UI runtime artifact; add a redacted recording, terminal/live output, or runtime logs showing reconnect plus competing preference writes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 4 items Changed ownership boundary: The supplied diff adds a physical Gateway connection epoch and hasCurrentConfigSnapshot guard to the runtime configuration capability, then uses that capability from the Control UI settings path rather than a direct client writer.
Affected preference path: The supplied PR diff changes the preference queue to track the runtime configuration owner and connection epoch, and expands stale-hash handling around server preference reconciliation.
Regression coverage: The branch adds reconnect, authoritative-snapshot, and preference-write regression coverage in the runtime configuration and server preference test suites; the PR body reports the focused suites and changed gate passing.
Findings None None.
Security None None.

How this fits together

The Control UI receives Gateway connection snapshots, creates a runtime configuration owner, reconciles server-backed preferences and sidebar state, and sends configuration patches back to the Gateway. This PR changes how those snapshot updates and writes are tied to a physical Gateway connection so obsolete callbacks cannot affect a newer connection or account.

flowchart LR
  A[Gateway connection snapshot] --> B[Runtime configuration owner]
  B --> C[Authoritative configuration snapshot]
  C --> D[Preference and sidebar reconciliation]
  D --> E[Queued settings patch]
  E --> F[Gateway configuration write]
  B --> G[Connection epoch fence]
  G --> D
  G --> E
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body reports extensive tests, structured review, and changed-gate results, but does not include an inspectable after-fix Control UI runtime artifact; add a redacted recording, terminal/live output, or runtime logs showing reconnect plus competing preference writes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - This is a large client-side state-coordination change: a missed arrival order, reconnect transition, or stale callback could still regress sidebar privacy or prevent an existing user’s settings from persisting after reconnect.
  • Resolve merge risk (P1) - Automated tests and the supplied changed gate do not substitute for an after-fix Control UI run that visibly exercises reconnect plus competing preference writes.
  • Complete next step (P2) - The protected maintainer label and missing real behavior proof require a maintainer review rather than an automated repair or cleanup action.
Agent review details

Security

None.

PR surface

Source +280, Tests +1441. Total +1721 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 380 100 +280
Tests 2 1570 129 +1441
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 1950 229 +1721

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Capture a real reconnect scenario (recommended)
    Run the Control UI against a Gateway, reconnect the same client during settings/sidebar updates, and attach redacted after-fix terminal output, logs, or a recording that proves the new owner’s writes persist.
  2. Accept test-only evidence
    A maintainer may accept the expanded deterministic regression coverage without live UI evidence, explicitly owning the residual reconnect and account-isolation risk.

Technical review

Best possible solution:

Before merge, add redacted real Control UI evidence that starts from an existing loaded session, reconnects the Gateway while preference/sidebar changes occur, and demonstrates that the new account’s settings persist without inheriting the prior account’s sidebar state.

Do we have a high-confidence way to reproduce the issue?

No high-confidence live reproduction is available in the supplied review context. The changed ownership, snapshot, stale-callback, and queued-write paths are clear from the supplied diff and targeted tests, so the reported failure mode is source-reproducible but not independently reproduced here.

Is this the best way to solve the issue?

Unclear: centralizing physical writes in the existing runtime configuration capability is the right ownership direction and avoids a parallel writer, but a real reconnect-and-write scenario is still needed to establish that the epoch fence covers the browser/runtime ordering seen by users.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c66ca2fbb2b0.

Labels

Label changes:

  • add P2: The change addresses persisted user preferences and private sidebar/session projections, but the available evidence does not establish an urgent production-wide regression.
  • add merge-risk: 🚨 session-state: The PR changes account-scoped sidebar and preference reconciliation across connection epochs, so an ordering error could associate state with the wrong active session.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports extensive tests, structured review, and changed-gate results, but does not include an inspectable after-fix Control UI runtime artifact; add a redacted recording, terminal/live output, or runtime logs showing reconnect plus competing preference writes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P2: The change addresses persisted user preferences and private sidebar/session projections, but the available evidence does not establish an urgent production-wide regression.
  • merge-risk: 🚨 session-state: The PR changes account-scoped sidebar and preference reconciliation across connection epochs, so an ordering error could associate state with the wrong active session.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports extensive tests, structured review, and changed-gate results, but does not include an inspectable after-fix Control UI runtime artifact; add a redacted recording, terminal/live output, or runtime logs showing reconnect plus competing preference writes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Changed ownership boundary: The supplied diff adds a physical Gateway connection epoch and hasCurrentConfigSnapshot guard to the runtime configuration capability, then uses that capability from the Control UI settings path rather than a direct client writer. (ui/src/lib/config/index.ts:118, 049e0ea2ad56)
  • Affected preference path: The supplied PR diff changes the preference queue to track the runtime configuration owner and connection epoch, and expands stale-hash handling around server preference reconciliation. (ui/src/app/server-prefs.ts:188, 049e0ea2ad56)
  • Regression coverage: The branch adds reconnect, authoritative-snapshot, and preference-write regression coverage in the runtime configuration and server preference test suites; the PR body reports the focused suites and changed gate passing. (ui/src/app/server-prefs.test.ts:1, 049e0ea2ad56)
  • Current review state: The provided GitHub context shows the PR is cleanly mergeable but still has in-progress checks, carries the protected maintainer label, and has no supplied screenshot, recording, redacted runtime log, or other directly inspectable after-fix Control UI evidence.

Likely related people:

  • steipete: The supplied branch’s sole commit implements the runtime-configuration ownership and preference-sync changes across the affected Control UI files; no separate current-main feature-history evidence was available in the read-only review context. (role: recent Control UI contributor; confidence: medium; commits: 049e0ea2ad56; files: ui/src/app/app-host.ts, ui/src/app/server-prefs.ts, ui/src/lib/config/index.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach redacted after-fix runtime evidence for a same-client Gateway reconnect while settings or sidebar state are updated.
  • Let the remaining in-progress checks complete against the exact reviewed head.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer review update: do not merge this head. I reproduced the precise Control UI reconnect concern from the ClawSweeper review against the actual reviewed commit 049e0ea2ad566aabc43763da3ec6f08d1f1b2d18, using a real isolated Gateway and real Chromium on individually owned Blacksmith Testbox tbx_01kyg22kcxvskvhm339y9yhhyw (Actions run 30219209225).

The remote Git HEAD and all five changed source blobs were verified against the published commit. The actual production build passed, including 654 precompressed Control UI sidecars and the performance budget. The browser opened real /settings/appearance and /settings/general pages; an initial theme edit physically persisted through a real config.patch before Gateway shutdown.

After an orderly restart of that same isolated Gateway and state directory:

  • The Appearance browser opened four real Gateway WebSockets, observed three closes, and made four genuine config.get calls.
  • The General browser opened four real Gateway WebSockets, observed three closes, and made three genuine config.get calls.
  • The theme dash and language fr were selected on the two actual pages while the Gateway was disconnected.
  • Both pages reconnected, but neither offline edit produced a post-reconnect config.patch and neither physically persisted within 45 seconds.
  • The real reconnect scenario correctly failed (exitCode=1, commandMs=78089). Both privately owned Gateway processes were stopped. The user Gateway was never touched, no provider credentials were supplied, and an incidental unauthenticated background provider attempt was not counted as live-model proof.

I preserved and independently decoded the real 1440×1000 browser screenshots and redacted failure manifest. Their SHA-256 values are:

01-appearance-initial-real-gateway.png       b742784adee45af0cbd55ee83ebcfdef9571e11c052c7528e4b6859ebe6feb24
02-pre-reconnect-theme-persisted.png         6456eaf29bf3aa11ac33976cc76ae6d1765d55fd901f66a9b0044550a118605c
03-real-gateway-disconnected-settings.png   47ad4d670a739df566dff81ca9273516ad2ba0920e7577939b729ac12978238b
settings-reconnect-failure.json             66c02f5541b9c8f5cd50a0b43b4ca68581f16f85e79c3c0431c29db77543f428

I am preserving this focused PR and will repair the canonical preference owner so edits made during an actual disconnect are retained until a current-epoch authoritative snapshot arrives, then drain through the sole runtime configuration writer. I will rerun the same real two-page reconnect and preserve final screenshots before requesting a fresh review. The currently green hosted CI is not a substitute for the failed real product scenario.

@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer update: still blocked; do not merge the currently published 049e0ea2ad566aabc43763da3ec6f08d1f1b2d18 head.

I independently ran the actual production-built Control UI and two real authenticated Chromium tabs against a dedicated, loopback-bound Gateway and its real /readyz endpoint. The stronger unpublished candidate 85adc1538a0bc8d5a63ac76d503946a7f9af4fdd fixes the original offline loss and updater-resume race, passes all 14 relevant suites (312 tests), and has a fresh clean exact-commit structured review, but it still fails the real competing-tab reconnect scenario.

After the Gateway restart, the Appearance and General tabs both physically submitted their preserved offline preference writes using the same real source revision:

cf55122c492be34d301c8ad10fa5a8abbc85802ccaf66e4d5712a81bb9058e4e

  • Appearance successfully committed theme=dash.
  • General attempted locale=fr; the Gateway returned INVALID_REQUEST: config changed since last load; re-run config.get and retry.
  • General reconnected and successfully fetched authoritative configuration again, but never retried or acknowledged the French preference.
  • Appearance: 4 real sockets, 3 closes, 6 successful config.get responses, 2 acknowledged patches including its initial theme=knot.
  • General: 5 real sockets, 4 closes, 4 successful config.get responses, 0 acknowledged patches.
  • After 45 seconds, the actual remote browser proof failed with exitCode=1; no final success screenshot exists.

Independently preserved original evidence:

  • OpenClaw-Control-UI-PR-114170-85adc153-01-initial.png: 4aa28e0405117ced14193b8da3151bb2ca7f64bae727ee92002b79dd8ab3665d.
  • OpenClaw-Control-UI-PR-114170-85adc153-02-before-reconnect.png: 12e6b63346af8964a5c712011a2c51d796ef51cbccf4e77b1a23acb2e3a2c5d8.
  • OpenClaw-Control-UI-PR-114170-85adc153-03-disconnected.png: 239965ab1a9fd26760f282e05478a78856959eefef4f5479e9f4a781228a7d85.
  • OpenClaw-Control-UI-PR-114170-85adc153-real-cas-reconnect-failure.json: 7443ab0babf9cdbafe165ed1c8207fba336654e3fb81f69c069c225ccf38f8a4.

The remote runner intentionally uses a synthetic c66ca2fbb2b038f4796abfa76bd52dcc3b675b02 Git HEAD with all six verified candidate source blobs overlaid; it was not misidentified as a remote 85adc... checkout. The dedicated Gateway and its Testbox were both stopped. The clean 312-test run and independent review do not override this genuine live failure. I am retaining the unpublished candidate and will first add an actual competing-revision, failed-ack, fresh-owner replay regression; the PR must stay blocked until both tabs physically acknowledge and durably preserve their preferences.

@steipete

Copy link
Copy Markdown
Contributor Author

Closing in favor of the boundary-correct replacement: #114286.

Both live two-tab reconnect proofs against this PR's approach failed (head 049e0ea2ad5 lost offline edits entirely; the stronger unpublished candidate 85adc1538a0 lost the CAS race between tabs and never recovered), and the root cause is structural: every fence in this PR lives in per-tab browser module state, but only the Gateway can serialize concurrent preference writers. No amount of client-side epoch/hash bookkeeping can fence a sibling tab.

The replacement fixes it at the ownership boundary instead:

  • The Gateway accepts hash-free config.patch writes restricted to leaf operations inside the documented LWW preference subtree (ui.prefs), keeping the strict document CAS for everything else (baseHash was already optional in the wire schema — no protocol change).
  • The Control UI's CAS queue and stale-hash suppression are deleted in favor of per-key pending intent that shadows reconciliation until acked, persists per gateway scope, and replays on reconnect.
  • The exact failing scenario is now a committed Playwright regression (ui/src/e2e/settings-prefs-reconnect.e2e.test.ts) plus a real-gateway two-page Testbox proof on the replacement PR.

Evidence and proof runs are on #114286.

@steipete steipete closed this Jul 27, 2026
@RomneyDa
RomneyDa deleted the codex/autoqa-settings-write-ownership-c66ca2fb-r2 branch October 22, 2026 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant