Repository navigation
feat(gateway/ui): split session group mutations to avoid concurrent add loss - #112227
xialonglee wants to merge 1 commit into
Conversation
f221356 to
6805ab0
Compare
|
Codex review: blocked before merge. Reviewed September 24, 2026, 3:53 AM ET / 07:53 UTC (Revision 36). ClawSweeper reviewWhat this changesThe branch adds atomic session-group creation and reordering to the Gateway, moves the Control UI and Apple clients onto group-add support, and retains catalog replacement for older native gateways. Regression provenancePossible regression — probable (reproduction; failure trace). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 6 items remain Keep this PR open. The linked concurrent-creation bug remains on current main, and the PR provides strong after-fix Gateway evidence. A public Swift initializer break, unresolved partial-reorder contract, and current merge conflicts block landing. Priority: P1 Review scores
Verification
How this fits togetherThe Gateway owns the shared session-group catalog and sidebar order in SQLite. Web and native clients send group mutations to it, then receive the resulting catalog and change notifications. flowchart LR
A[Web and Apple clients] --> B[Gateway group requests]
B --> C{Add or reorder?}
C --> D[Session group catalog]
D --> E[SQLite state]
E --> F[Updated catalog and change event]
Decision needed
Why: Both are plausible persistent ordering contracts; the implementation and protocol comment currently disagree, and prior review requested explicit acceptance. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +202, Tests +462, Other +160. Total +824 across 49 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep atomic creation at the Gateway owner, preserve the existing Swift initializer for callers, choose and document one partial-reorder contract, then reconcile the branch with the current state-worker path and complete screenshot delivery. Do we have a high-confidence way to reproduce the issue? Yes. The linked report gives a two-tab, stale-catalog reproduction, current main still uses full replacement, and the PR supplies a before/after Gateway trace. Is this the best way to solve the issue? Yes for atomic group creation at the Gateway boundary. The partial-reorder persistence rule needs one approved contract, and the Swift API should retain its existing initializer. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ffb17b275480. LabelsLabel changes:
Label 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 (35 earlier review cycles; latest 8 shown)
|
6805ab0 to
4bc9063
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
4bc9063 to
f09f327
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
One separate collaboration question, since your real multi-Agent Gateway testing is unusually relevant here: I’m preparing a controlled test of the NodeRooms |
faeab83 to
77f6a99
Compare
|
@clawsweeper re-review Rebased onto upstream/main, addressed the four latest findings, and refreshed the real Gateway proof:
Real behavior proof (two authenticated tabs) passes end-to-end, including concurrent adds, full reorder + section order, partial reorder preserving unlisted group sections, and legacy put semantics. All targeted tests and lint/format checks are green. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Addressed the three remaining P1 findings from the latest review:
Also regenerated the plugin-sdk API baseline and native-app i18n inventory. Swift build/toolchain verification will need CI (no local Swift toolchain). Focused TS tests and lint/format pass locally. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Rebased onto upstream/main and resolved conflicts. Addressed the remaining P1 finding:
Verified: |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review The latest revision addresses the remaining P1 findings from your review:
Also updated all E2E group-creation assertions to use Validation runTwo-tab concurrent-group proofScreenshots captured locally:
Exact head: |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Addressed all five findings and the CI failures on the reviewed head:
CI repairs on top: protocol registry module count, assertion-safety baseline shrink, gateway-root shard limit, sessions/chat-pane test fixtures, group-identity e2e deferred method, Swift test Local validation: Note: the |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Rebased onto the latest upstream/main and addressed both remaining findings:
Negative control: with the mock's add handler temporarily emulating the stale read-modify-write replacement (each stale write replacing the catalog), the e2e fails because Validation:
Exact head: |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
Closing due to inactivity. |
Fixes #106362
What Problem This Solves
Fixes an issue where users creating different custom session groups concurrently from two Control UI tabs would silently lose one of the groups. Both tabs sent a full replacement catalog derived from their stale local state, and the later
sessions.groups.putdeleted everything before re-inserting its own list.Why This Change Was Made
The fix splits the monolithic
sessions.groups.putcatalog replacement into three finer-grained Gateway operations so Control UI no longer has to replace the whole catalog for every mutation:sessions.groups.addappends a single new group without touching existing rows (fixes the concurrent-add loss).sessions.groups.reorderupdates the position order for the listed groups, and optionally atomically persists the complete sidebarsectionOrderin the same SQLite transaction. This keeps cross-section ordering (work / custom groups / ungrouped) consistent when groups are reordered.sessions.groups.putkeeps the historical full-replacement contract for older clients and the client-side fallback for older gateways.Control UI always dispatches the atomic RPCs (
sessions.groups.add/sessions.groups.reorder) and forwards the fullsectionOrderon reorders so the server persists it atomically alongside the group positions; a failed atomic write surfaces an error instead of falling back to a locally-constructed full-catalogput(the destructive fallback was removed in the 2026-08-28 revision). Shared Apple clients negotiatesupportsGroupAddwhen the route lease is captured and only use the legacy read-modify-writeputGroupspath against genuinely older gateways that do not advertisesessions.groups.add.Changes since last review cycle
Rebased onto the latest
upstream/mainand addressed the remaining ClawSweeper P1 findings from the most recent review:Fall back when Gateway method metadata is absent (P1):
ui/src/lib/sessions/session-group-catalog.tsnow treats a missingfeatures.methodsarray (returned byisGatewayMethodAdvertised) as legacy for bothsessions.groups.addandsessions.groups.reorder, routing metadata-less older gateways to the supportedsessions.groups.putreplacement instead of sending an unknown RPC.Restrict Apple fallback to unsupported-method errors (P1):
apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+SessionActions.swiftnow catches only the recognized old-GatewayINVALID_REQUEST/ "unknown method: sessions.groups.add" response before falling back to the legacy read-modify-writeputGroupspath. Authorization, transport, decoding, and post-dispatch failures now propagate instead of being silently converted into a destructive full-catalog replacement.Wire the new group-add closure into all lease constructors (P1):
addGroupis now supplied by the direct iOS (IOSGatewayChatTransport.swift), macOS (MacGatewayChatTransport+SessionActions.swift), and shared-test (ChatViewModelSessionActionTests.swift)OpenClawChatSessionGroupsRouteLeaseconstructors, fixing the Swift compilation failures.Previous review-cycle items remain in place:
normalizeSidebarSectionOrdernow normalizes against the complete resulting catalog (listed groups plus unlisted groups) instead of only the caller's input list. This keeps sidebar slots for groups that are not mentioned in a partialsessions.groups.reorderfrom being silently stripped.ChatViewModel+SessionActions.swiftnow usessessions.groups.addfirst, falling back to the legacysessions.groups.putonly when the gateway does not advertise the new method. The route lease, request builder, transport protocol, and unit tests were updated to supportaddGroup.sessions.groups.addandsessions.groups.reorderare appended at the end of thesessions-groupsfamily insrc/gateway/methods/core-descriptors.tswithsince: "2026.8", matching the next release train. The Android generated protocol enum (GatewayProtocol.kt) was regenerated and is consistent with the new method list.reorderSessionGroupsfilters the inputnamesagainst the existing catalog before assigning positions, so unknown names do not consume slots or leave gaps.sessions.groups.reorder:SessionsGroupsReorderParamsSchemaaccepts an optionalsectionOrder, andreorderSessionGroupswrites it tosidebar_sectionsinside the same transaction that updates group positions. The Control UI reorder path forwards its fullnextsection order throughgroupsReorder.sessions.groups.put: existing callers can still remove groups by submitting a catalog without them.packages/gateway-protocol/src/schema/sessions.tsand are compiled invalidator-registry.ts.sessions.groups.put, (b) concurrent adds survive through the atomicsessions.groups.addpath, (c)sessions.groups.reorderpersists the providedsectionOrder, (d) partial reorders preserve unlisted group sections, (e) nonexistent reorder names are discarded, (f) metadata-less gateways fall back tosessions.groups.putfor both add and reorder, and (g) ApplecreateSessionGrouponly falls back on the unsupported-method error.User Impact
sessions.groups.putreplacing the catalog keep working unchanged.putfallback (removed 2026-08-28 because a silent destructive retry was worse than a visible error). Existingsessions.groups.putcallers (scripts, older Apple clients) keep working unchanged: the Gateway retains the full-replacement operation, and Apple clients only fall back to it against gateways that do not advertisesessions.groups.add.Evidence
Unit tests
src/gateway/session-groups.test.ts— 15 tests pass (replacement semantics + concurrent-add preservation + section order persistence + normalized partial reorder + consecutive partial reorder regression + nonexistent-name discard)src/gateway/method-scopes.test.ts— 148 tests pass (new method scopes verified)src/gateway/methods/core-descriptors.since.test.ts— 1 test pass (sessions.groups.add,sessions.groups.reorderdated2026.8)src/gateway/server-methods-list.test.ts— 23 tests pass (new handlers registered)ui/src/lib/sessions/index.test.ts— 33 tests pass, including new metadata-less fallback cases forgroupsAddandgroupsReorderui/src/components/app-sidebar.test.ts— 245 tests pass (section reordering and custom group reordering cases)ui/src/pages/sessions/sessions-page.test.ts— 28 tests passapps/shared/OpenClawKit/Tests/OpenClawKitTests/ChatViewModelSessionActionTests.swift— updated/added tests for atomic add path, unsupported-method fallback, and propagation of non-unsupported errorsLint / format
node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json <changed-files>— 0 warnings, 0 errorspnpm format:check -- <changed-files>— all matched files use correct formatBaselines
pnpm plugin-sdk:api:gen+pnpm plugin-sdk:api:check— plugin SDK API baseline refreshed and verified.pnpm native:i18n:baseline+pnpm native:i18n:verify— native app i18n inventory refreshed and verified.Real Gateway behavior proof
Verified against a freshly built Gateway with two authenticated operator clients (simulating two Control UI tabs). The proof exercises the changed RPCs end-to-end through WebSocket requests:
This shows:
sessions.groups.addcalls from two tabs preserve both groups.sessions.groups.reorderchanges the group order and atomically persists the complete sidebar section order.sessions.groups.putremains a full catalog replacement: submitting["Client-A"]removes the other groups.CI proof: exact-head before/after
A secretless GitHub Actions workflow on the proof branch
fix/issue-106362-concurrent-session-groups-proofbuilds the Gateway at the exact PR head and base commits, starts a real local Gateway with token auth for each, and drives two loopback CLI clients through the changed RPCs.82167b0f5ae58828Key markers from the CI artifact (
proof.log):This confirms:
sessions.groups.putcalls result in only the last write surviving (Client-B).sessions.groups.addcalls preserve both groups (Client-AandClient-B).Gateway authorization
sessions.groups.addandsessions.groups.reorderregistered insrc/gateway/methods/core-descriptors.tswithscope: "operator.write"andsince: "2026.9".src/gateway/method-scopes.test.ts.src/gateway/server-methods/sessions-groups.tslazy handler list.src/plugins/registry-runtime-session-ownership.ts.sessions.changed, and returns typed errors; no authorization bypass introduced.UI before/after screenshots (two-tab concurrent group creation)
Captured 2026-09-16 at head
28522c11067with the Control UI E2E harness (vitest.ui-e2e.config.ts, headless Chromium, mock Gateway,OPENCLAW_CAPTURE_UI_PROOF=1). All content is synthetic (groups Alpha/Beta, fixture sessions); screenshots were inspected and contain no private data. Assets are served from the fork'sproof-112227-ui-screenshotsbranch so they render inline here and in the PR.Before — legacy replacement semantics (negative control): the mock Gateway's
sessions.groups.addhandler was temporarily switched to emulate the pre-fix read-modify-write replacement (each submission replaces the whole catalog with its own stale singleton list, mirroring whatsessions.groups.putdid with a stale snapshot). Both tabs submit from the same empty catalog; the later write wipes the earlier group.BETAremains in its sidebar (the user-facing bug from Control UI: concurrent custom-group creation silently loses one group #106362).ALPHAonly through its own session row; the shared catalog entry is gone (BETA— the other tab's group — leads the catalog order). Assertions for this negative control: tab 1 sections[Alpha, Beta], tab 2 sections[Beta]only.After — atomic
sessions.groups.addat this head (no code change between the two runs except the mock's add handler):Both tabs concurrently created a group from the same pre-mutation (empty) catalog — both
ALPHAandBETAsections are visible in both tabs, and the test asserts exactly onesessions.groups.addRPC per tab.Existing-state upgrade/reopen preservation proof
Real Gateway, isolated state dir. Phase 1 seeds a pre-PR user state through the legacy RPC surface only (
sessions.groups.putcatalog + section order,sessions.groups.updatedefaults,sessions.createwith group categories for memberships). Phase 2 performs a full Gateway restart and verifies the existing catalog, sidebar section order, group defaults, and session memberships survive untouched. Phase 3 applies the newadd+ partialreorderon top, and Phase 4 restarts again to prove the ordering contract persists without touching defaults or memberships:This also serves as the data-model compatibility evidence for the stored catalog/sidebar state: state written by the legacy operations is read back unchanged after reopen, and the new mutations introduce no DDL — they update existing rows in the same SQLite tables.
Revision (2026-08-28)
Addressed the latest ClawSweeper P1 findings and CI failures:
Removed destructive fallback in Control UI
sessions.groups.add/reorder(ui/src/lib/sessions/session-group-catalog.ts)addandreorderno longer fall back to a locally-constructed full-catalogsessions.groups.putwhen the Gateway call fails. If the atomic operation cannot complete, the error is surfaced instead of silently overwriting another tab's groups.reordernow callspublishPathFreeMutation(..., readSidebarSectionOrder(result))so the complete sidebar section order is persisted atomically in the same request.Redacted error strings in custom-group UI (
ui/src/pages/sessions/custom-groups.ts)formatUiError(error)for the caught error branch instead ofString(error), so raw internal messages are not exposed to the operator.Split session-group schema and method-scope coverage
packages/gateway-protocol/src/schema/sessions.tsto a newpackages/gateway-protocol/src/schema/session-groups.tsand updated barrel/fragment imports.src/gateway/method-scopes.test.tsintosrc/gateway/method-scopes.session-groups.test.tsto keep the file size within policy.Updated E2E tests to use atomic group creation
sessions.groups.addin their mock Gateway handlers, matching the production code path.sessions.groups.putis still advertised infeatureMethodswhere the UI checks menu permissions, because the permission model keys off the advertised method list.ui/src/e2e/session-management.concurrent-groups.e2e.test.ts, opens two Control UI tabs, creates group Alpha in tab 1 and group Beta in tab 2, and asserts both groups are visible in both tabs viashareSessionGroupsAcrossTabslocalStorage synchronization.Validation (after revision)
pnpm tsgo:core:test— passpnpm tsgo:ui— passsession-groups,method-scopes.session-groups,ui/src/lib/sessions) — 203 + 70 passnode scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/session-management.*.e2e.test.ts— 71 passpnpm format:check— passnode scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json <changed-files>— 0 warnings, 0 errorsTwo-tab concurrent group proof
Captured screenshots:
.artifacts/control-ui-e2e/thread-management/concurrent-groups-tab1-both.png.artifacts/control-ui-e2e/thread-management/concurrent-groups-tab2-both.pngExact head after revision:
8f075f36856Revision (2026-09-07): rebase onto current upstream/main
Rebased onto
upstream/main(3b7bc9cb9de, ~6.4k commits) and resolved all conflicts. The feature is still needed: #106362 remains open, ClawSweeper's 2026-09-06 review confirms the empty-group concurrent-add loss is still reproducible on currentmainand v2026.9.2, and upstream #133005 only rejectssessions.groups.putdrops of non-empty groups — two tabs concurrently creating empty groups still lose one. No upstream implementation of atomic group mutations exists.Conflict resolutions and upstream adaptations:
putSessionGroupsupstream now takes an options object ({ cfg, names, sectionOrder, env, assertCurrent, assertTargetCurrent }) and rejects dropping non-empty groups; the reorder regression tests were updated to the new signature.PLUGIN_GATEWAY_GLOBAL_SESSION_MUTATION_METHODStosrc/plugins/registry-runtime-session-ownership.ts;sessions.groups.add/sessions.groups.reorderare registered in the global session mutation set there.packages/gateway-protocol/src/schema/session-groups.tsmodule (upstream's copy of the group schemas inschema/sessions.tswas dropped as duplicate).createSessionCapabilitymoved out of theui/src/lib/sessions/index.tsbarrel intoui/src/lib/sessions/create-session-capability.ts, and the new atomic-group RPC tests moved intoui/src/lib/sessions/index.session-groups.test.ts, keeping both files within the max-lines budget (699→701 and 995→1057 were over; now 32/670 and 995/70).server-methods-list.test-fixtures.ts,core-descriptors.since.test.ts) updated for the two new methods alongside upstream'ssessions.goal.*additions.makeSessionGroupsRouteLeasewiring (iOS) reconciled with upstream's transport changes; Swift cannot be compiled on this Linux host — macOS CI owns that lane.Validation (after rebase)
session-groups.test.ts,method-scopes.session-groups.test.ts,core-descriptors.since.test.ts,server-methods/sessions-groups.test.ts,server-methods-list.test.ts— all pass.index.test.ts,index.session-groups.test.ts(new),app-sidebar.test.ts,sessions-page.test.ts— 405 pass.session-management.concurrent-groups,session-management.groups,session-management.new-group,session-management.sidebar,chat-continue-in-terminal— all pass.concurrent-groups-tab1-both.pngshows both ALPHA (created in tab 1) and BETA (created in tab 2) groups in tab 1's sidebar.tsgocore + ui + gateway test shards — pass;run-oxlint.mjs— 0 warnings, 0 errors;oxfmt— clean;check:import-cycles— clean;plugin-sdk:surface:check— pass.Behavior is unchanged from the previously approved proof (
proof: sufficient); this revision is a rebase adaptation, so the earlier authenticated-Gateway concurrency traces and CI before/after proof remain valid.Exact head after rebase:
17a267e874cRevision (2026-09-16): rebase onto latest upstream/main
Rebased onto
upstream/main(33c15b86fea) and resolved all conflicts; the 10 prior commits are squashed into one. The feature is still needed:upstream/mainhas nosessions.groups.add/sessions.groups.reorder(verified by tree search), #106362 remains open, and the merged #133005 guard only rejectssessions.groups.putdrops of non-empty groups — two tabs concurrently creating empty groups still lose one.Conflict resolutions and upstream adaptations:
protocol-schema-fragment-*.tsfiles in favor of derived registration (protocol-schema-selection.tsoverschema-modules.ts). The group schemas stay in the PR-ownedpackages/gateway-protocol/src/schema/session-groups.ts, now wired throughschema-modules.ts(66→67 modules;check-protocol-registry.mtscount updated).createSessionCapabilityinline inui/src/lib/sessions/index.ts(with a reworked event pipeline), so the PR'screate-session-capability.tsextraction was dropped and thegroupsAdd/groupsReorderwiring plus the payload-envelope SAFETY annotation were applied directly to upstream's inline factory.ui/src/test-helpers/app-sidebar.tstook upstream'sarchiveState/archiveProvenancemachinery and re-added the PR'sgroupsAdd/groupsReordermocks with the typed result style.GatewayModels.swift(+28),GatewayProtocol.kt(+2),OpenClawProtocolConstants.kt, and the workboardcontrol-uibundle hash inextensions/workboard/openclaw.plugin.json(3655fa4e…).ui/src/lib/sessions/index.tsentry.supportsGroupAddviagatewayAdvertisesMethod) reconciled with upstream's transport changes; Swift cannot be compiled on this Linux host — macOS CI owns that lane.Validation (after this rebase)
session-groups.test.ts(32),method-scopes.session-groups.test.ts+core-descriptors.since.test.ts+server-methods/sessions-groups.test.ts+server-methods-list.test.ts(53),method-scopes.test.ts— all pass.app-sidebar.test.ts+index.test.ts(468),sessions-page.groups/sessions-page/chat-pane/custom-groups(41),index.session-groups.test.ts(new) — all pass.protocol-registry:check,protocol:check:swift,protocol:check:kotlin,check-protocol-since— all pass; assertion-safety ratchet — pass.run-oxlint.mjs(0 errors; 2 pre-existing max-lines warnings also present on upstream/main),oxfmt --checkclean,tsgocore + gateway test shards + UI + scripts — all pass.xialonglee/openclaw@proof-112227-ui-screenshots.Exact head after rebase:
28522c11067