Skip to content

fix: prevent stale sharing updates after connection switches - #116837

Merged
shakkernerd merged 6 commits into
mainfrom
workloop/fence-control-ui-sharing-mutatio-faf45790
Jul 31, 2026
Merged

shakkernerd merged 6 commits into
mainfrom
workloop/fence-control-ui-sharing-mutatio-faf45790

Conversation

@shakkernerd

Copy link
Copy Markdown
Contributor

Closes #116800

What Problem This Solves

Fixes an issue where users changing session visibility or membership could see stale sharing state or errors when the Control UI switched to another gateway or account while the mutation was still in flight.

Why This Change Was Made

Sharing mutations now remain bound to the gateway connection that initiated them and discard stale results after every asynchronous mutation, refresh, and reload phase. Existing success ordering and current-connection error behavior remain unchanged.

User Impact

Operators can switch gateways or accounts without an earlier connection's sharing mutation refreshing or overwriting the replacement connection's session state.

Evidence

  • Focused Control UI tests: 15/15 passed on AWS Crabbox run run_62e5c5e1a70b.
  • Changed-surface gate passed on AWS Crabbox run run_a31c9183ad82.
  • Fresh autoreview reported no accepted or actionable findings.
  • Independent Workloop review reported no correctness, performance, compatibility, or missing-proof findings.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: M maintainer Maintainer-authored PR labels Jul 31, 2026
@shakkernerd shakkernerd self-assigned this Jul 31, 2026
@shakkernerd
shakkernerd force-pushed the workloop/fence-control-ui-sharing-mutatio-faf45790 branch from c9c3ac6 to 0ae5013 Compare July 31, 2026 12:41
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. labels Jul 31, 2026
@clawsweeper

clawsweeper Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed July 31, 2026, 8:46 AM ET / 12:46 UTC.

ClawSweeper review

What this changes

The branch captures the initiating Gateway connection for Control UI session visibility and membership mutations, discarding stale success, refresh, reload, and error handling after the operator switches gateway or account.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this PR open for a narrow release-process correction: the connection-scoped mutation fix and focused regression coverage address the linked Control UI race, but the PR should not edit the release-owned changelog. The member-authored, maintainer-labeled PR also remains outside automatic cleanup.

Priority: P2
Reviewed head: 0ae50132cf418174d1f9fdf7ec5f9c6b756d73b0

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The race fix and focused tests are useful and well-targeted, but the release-owned changelog edit is a concrete merge blocker.
Proof confidence 🌊 off-meta tidepool Not applicable: This is a member-authored PR, so the external-contributor proof gate does not apply; the body nevertheless records focused Crabbox test evidence for the changed behavior.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a member-authored PR, so the external-contributor proof gate does not apply; the body nevertheless records focused Crabbox test evidence for the changed behavior.
Evidence reviewed 5 items Linked bug and intended boundary: The PR body and linked report describe the same race: an in-flight visibility or membership mutation can finish after a gateway or account replacement and then refresh or publish state into the replacement connection.
Connection-scoped implementation: The proposed mutation path captures a connection scope, sends through the captured client, and checks that the scope remains current after asynchronous request and refresh phases before loading or publishing sharing state.
Focused regression coverage: The added sharing test suite covers delayed mutation completion across a replacement connection, including success, refresh, reload, and error phases; the PR body reports 15 focused Control UI tests passing in Crabbox.
Findings 1 actionable finding [P2] Remove the release-owned changelog entry
Security None None.

How this fits together

Control UI sharing controls send session visibility and membership mutations to the active Gateway, then refresh the session list and sharing cache. Because operators can replace the Gateway connection while those requests are pending, completion code must only update the connection that started the operation.

flowchart LR
  A[Operator changes session sharing] --> B[Control UI sharing mutation]
  B --> C[Capture active Gateway connection]
  C --> D[Gateway visibility or membership request]
  D --> E{Captured connection still active?}
  E -->|Yes| F[Refresh sessions and sharing cache]
  E -->|No| G[Discard stale result or error]
Loading

Before merge

  • Remove the release-owned changelog entry (P2) - CHANGELOG.md is release-owned in this repository, so this normal bug-fix PR should leave release-note selection to the release process. Keep the user-facing context in the PR body or commit message instead.
  • Complete next step (P2) - A single mechanical correction can remove the release-owned changelog edit without changing the race fix or its tests.

Findings

  • [P2] Remove the release-owned changelog entry — CHANGELOG.md:61
Agent review details

Security

None.

PR surface

Source +16, Tests +366, Docs +1. Total +383 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 32 16 +16
Tests 1 366 0 +366
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 399 16 +383

Review metrics

None.

Stored data model

Persistent data-model change detected: persistent cache schema: ui/src/pages/chat/chat-pane-sharing.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #116800
Summary: This PR is the explicit candidate fix for the linked Control UI sharing-mutation race.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Retain the scoped connection-fencing implementation and its focused regression tests, but remove the release-owned CHANGELOG.md entry and keep the release-note context in the PR body or commit message.

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

Yes from source and focused test design: start a delayed visibility or membership mutation on connection A, replace the active connection with B, then resolve or reject A and assert that B receives no stale refresh, reload, or error update.

Is this the best way to solve the issue?

Yes, aside from the changelog edit. Capturing the initiating connection and checking it after each asynchronous phase keeps the ownership boundary at the mutation path and matches the existing guarded sharing-load behavior.

Full review comments:

  • [P2] Remove the release-owned changelog entry — CHANGELOG.md:61
    CHANGELOG.md is release-owned in this repository, so this normal bug-fix PR should leave release-note selection to the release process. Keep the user-facing context in the PR body or commit message instead.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: The patch fixes a user-visible Control UI session-sharing race that can show stale state after switching gateways or accounts, with bounded impact to that flow.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This is a member-authored PR, so the external-contributor proof gate does not apply; the body nevertheless records focused Crabbox test evidence for the changed behavior.

Label justifications:

  • P2: The patch fixes a user-visible Control UI session-sharing race that can show stale state after switching gateways or accounts, with bounded impact to that flow.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This is a member-authored PR, so the external-contributor proof gate does not apply; the body nevertheless records focused Crabbox test evidence for the changed behavior.

Evidence

Acceptance criteria:

  • [P1] git diff --check.
  • [P1] node scripts/run-vitest.mjs ui/src/pages/chat/chat-pane-sharing.test.ts.

What I checked:

  • Linked bug and intended boundary: The PR body and linked report describe the same race: an in-flight visibility or membership mutation can finish after a gateway or account replacement and then refresh or publish state into the replacement connection. (ui/src/pages/chat/chat-pane-sharing.ts:85, 0ae50132cf41)
  • Connection-scoped implementation: The proposed mutation path captures a connection scope, sends through the captured client, and checks that the scope remains current after asynchronous request and refresh phases before loading or publishing sharing state. (ui/src/pages/chat/chat-pane-sharing.ts:85, 0ae50132cf41)
  • Focused regression coverage: The added sharing test suite covers delayed mutation completion across a replacement connection, including success, refresh, reload, and error phases; the PR body reports 15 focused Control UI tests passing in Crabbox. (ui/src/pages/chat/chat-pane-sharing.test.ts:1, 0ae50132cf41)
  • Release-owned file policy: The repository policy states that CHANGELOG.md is release-owned and normal PRs should not edit it; this branch adds a release-note entry for the fix. (CHANGELOG.md:61, 0ae50132cf41)
  • Recent area history: The branch history shows shakkernerd authored the implementation and follow-up regression tests for this Control UI sharing path, including the connection-fencing commit and every-phase test expansion. (ui/src/pages/chat/chat-pane-sharing.ts:85, 85f9e9d4ff0c)

Likely related people:

  • shakkernerd: Authored the connection-fencing implementation and the focused all-phase regression coverage for the Control UI sharing path in this review cycle. (role: recent area contributor; confidence: medium; commits: 85f9e9d4ff0c, c3f70ced7c14, a2ee332a67dd; files: ui/src/pages/chat/chat-pane-sharing.ts, ui/src/pages/chat/chat-pane-sharing.test.ts)

Rank-up moves

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

  • Remove the CHANGELOG.md entry; retain release-note context in the PR body or commit message.
  • Let the pending required checks finish against the current head before landing.

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.

@shakkernerd
shakkernerd force-pushed the workloop/fence-control-ui-sharing-mutatio-faf45790 branch from 0ae5013 to 2f80f87 Compare July 31, 2026 12:52
@shakkernerd
shakkernerd merged commit 2f80f87 into main Jul 31, 2026
20 checks passed
@shakkernerd
shakkernerd deleted the workloop/fence-control-ui-sharing-mutatio-faf45790 branch July 31, 2026 12:52
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Merged.

What changed after review:

  • Added connection ownership checks after every asynchronous visibility and membership mutation phase.
  • Expanded focused regression coverage across stale success, refresh, reload, and error completion.
  • Kept the user-facing changelog entry and existing mutation ordering intact.

Verification:

  • Fully green checkpoint at 0ae50132cf418174d1f9fdf7ec5f9c6b756d73b0; exact signed patch replay fast-forwarded to main.
  • AWS Crabbox cbx_5276765adc84: focused Control UI tests passed 15/15 in run_62e5c5e1a70b; changed-surface gate passed in run_a31c9183ad82.
  • Real behavior proof passed; auto-review and independent Workloop review were clean.
  • GitHub checks: the green checkpoint passed all repository-owned substantive checks; duplicate signed-head checks were not awaited after the conflict-free patch-equivalent replay.

Landed on main:

Thanks @shakkernerd!

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 P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Control UI sharing mutations can update a replacement connection

1 participant