Repository navigation
fix(ui): enforce authoritative Gateway observer lifecycle - #117017
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 31, 2026, 3:54 PM ET / 19:54 UTC. ClawSweeper reviewWhat this changesThis PR centralizes Control UI Gateway observer delivery and prevents replaced or stopped browser clients from continuing to publish state, reconnect, or start sockets. Merge readiness⛔ Blocked until stronger real behavior proof is added - 6 items remain Keep this PR open for protected human review. Current Priority: P1 Review scores
Verification
How this fits togetherThe Control UI Gateway store creates and owns the browser WebSocket client, then publishes connection snapshots, raw events, and event-log updates to application subscribers. Gateway callbacks update this store and may start, replace, reconnect, or stop the browser client that powers the UI session. flowchart LR
A[Gateway Browser Client] --> B[Control UI Gateway Store]
B --> C[Current Client Check]
C --> D[Snapshot and Event Log]
D --> E[UI Observers]
C --> F[Start Reconnect or Stop]
F --> A
Decision needed
Why: The Before merge
Agent review detailsSecurityNone. PR surfaceSource +11, Tests +305. Total +316 across 2 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain one canonical observer-delivery and current-client predicate in the Gateway store, then obtain a Control UI owner’s approval after an exact-head, redacted browser diagnostic or recording demonstrates the stop, replacement, and healthy-delivery scenarios. Do we have a high-confidence way to reproduce the issue? Yes, from source: on current Is this the best way to solve the issue? Yes, provisionally: consolidating notification isolation and checking whether the publishing client remains authoritative matches the Gateway store’s owner boundary, rather than compensating in individual UI consumers. Exact-head source and proof still need inspection before treating this as the final merge solution. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8b5871e1b703. 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)
|
|
Merged via squash.
|
* origin/main: (22 commits) fix(cron): preserve lazy ownership and bounded notification lifetimes (#117018) fix: live updater no-op restarts healthy gateways (#117038) fix(bedrock): release streaming clients (#117039) fix(google): restore canonical Gemini and Vertex provider invariants (#117042) fix(channels): preserve accepted LINE and Mattermost delivery (#117024) fix(feishu): unify truthful delivery and media ownership (#117023) fix(ui): isolate gateway observer lifecycles (#117017) fix(tui): keep reset transitions isolated from stale input (#116873) fix(gateway): centralize streamed media descriptor ownership (#117000) feat(plugins): externalize OpenCode provider (#117035) fix(onboarding): restore skill dependency consent (#116644) fix(streaming): preserve incomplete bracket tails in final replies (#116983) fix: allow slower gateway readiness after updates (#117032) fix(plugin-state): avoid shared SQLite corruption when CLI starts during gateway runtime (#113204) fix(cli): keep config file output raw under JSON logging (#116968) fix(ai): malformed Anthropic stream frames expose raw event payloads (#116938) fix(qa): authenticate actual scenario execution evidence (#117004) feat(plugins): externalize NovitaAI provider (#117007) fix(text): preserve fenced tool markers in visible-text sanitizer (#116939) (#116971) fix(channels): reset metadata memos with plugin lifecycle (#117005) ...
Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
A faulty Control UI observer could turn a successful Gateway hello into a failed connection, corrupt snapshot or event-log fanout, or publish retired connection state. More subtly, a presence observer could replace its client before that client's event was logged, while connecting and event-gap observers could synchronously replace or stop a client that stale producer code then started or reconnected anyway.
These failures caused missing UI updates, cross-connection history pollution, ghost WebSockets, duplicate reconnects, and explicitly stopped Gateways unexpectedly restarting.
Why This Change Was Made
The existing Gateway store is the authoritative owner of snapshot, event, event-log, and browser-client lifecycle delivery. The repair replaces three divergent mutable fanout loops with one isolated observer-delivery path, then applies one canonical current-client-plus-not-stopped predicate to producer continuations, presence projection, gap recovery, and event delivery.
This preserves existing diagnostic labels and public behavior while fixing ownership where it changes. The existing 777-line owner suite stays untouched; 10 original-order regressions live in a focused new 305-line suite. The justified production delta is 38 added / 27 removed / net +11.
User Impact
Evidence
36b80ada3ceae2de21b3d8710b883d778e4c4578.74ee66be3cd2347f6efb835b6a03cb977e645cd3.GatewayBrowserClient, actual browser WebSocket adapter, and a deterministic local Gateway peer exercised the exact PR head. Throwing snapshot and event-log observers remained isolated, healthy observers received their event/log, and forced disconnect reconnected across three real sockets.{ "candidateSha": "74ee66be3cd2347f6efb835b6a03cb977e645cd3", "browser": "Google Chrome 150.0.7871.187", "repaired": true, "invariant": "retired presence cannot enter the replacement Gateway event log", "results": { "replaced": true, "staleLogs": [], "staleEvents": [] } }{ "candidateSha": "74ee66be3cd2347f6efb835b6a03cb977e645cd3", "browser": "real-system-google-chrome", "ok": true, "results": [ { "variant": "connecting-replace", "handled": true, "socketDelta": 1, "phase": "connected" }, { "variant": "connecting-stop", "handled": true, "socketDelta": 0, "phase": "stopped" }, { "variant": "gap-replace", "handled": true, "socketDelta": 1, "phase": "connected" }, { "variant": "gap-stop", "handled": true, "socketDelta": 0, "phase": "stopped" } ] }staleLogs=["presence"]before repair andstaleLogs=[]after.--max-priority P3with genuine TruffleHog 3.96.0: zero findings,patch is correct, confidence 0.90.Distinct root causes (7):
ClawSweeper rank-up moves
ui/src/app/gateway-store.tsandui/src/app/gateway-store.observers.test.tswere independently inspected at74ee66be3cd2347f6efb835b6a03cb977e645cd3; the pull request is mergeable, exact-head hosted CI is green, and the complete exact-head owner suite plus full-branch P3 review both passed. The repository-native maintainer review/prepare workflow checks the current merge result before landing.