Skip to content

fix: clear stale diagnostics after Gateway changes - #140426

Merged
shakkernerd merged 2 commits into
mainfrom
fix-gateway-event-history
Sep 6, 2026
Merged

shakkernerd merged 2 commits into
mainfrom
fix-gateway-event-history

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Sep 6, 2026 •

Copy link
Copy Markdown
Member

Fixes #137108

What Problem This Solves

Fixes an issue where operators switching Gateway connections continued to see diagnostic event payloads from the previous Gateway in Debug and Live activity.

Why This Change Was Made

Diagnostic history now retires when a different connection is selected or the accepted handshake changes authentication scope. Activity observes the same retirement while preserving incremental updates and expanded entries during unchanged reconnects.

User Impact

Switching Gateways or authentication context clears preceding diagnostic data, including when the new connection fails. Ordinary reconnects retain useful troubleshooting history.

Evidence

  • New regression cases fail on the original code with retained messages and Activity previews, then pass with the repair.
  • All 257 affected tests, the full changed-path gate, and the UI build passed on Blacksmith Testbox at e47b00cb3496e7eccf6b586f5d534f7ac2bafee2.
  • The branch was rebased onto 270762e51d6559dfb4ede3f9fd5d8d1aaa342ac4 to follow the Control UI documentation split. Range-diff confirms the unchanged UI patch; all 15 UI source and test files are byte-identical, and the browser dependencies and authentication contracts are unchanged. Only the two documentation updates moved to their new canonical pages.
  • CI checks cover production/test types, UI E2E, builds, performance, lint, and docs for the current head.
  • The browser scenarios use the real Control UI in Vite source mode with synthetic Gateway replies. Both versions use identical fixtures and a 1440 × 1000 viewport; all four scenarios completed without page errors.
  • Independent media review confirmed the visible transitions and preserved expansion on unchanged reconnects. All five public attachments were fetched without authentication and matched the local capture bytes and SHA-256 hashes.

Visual evidence

View Before After
Debug after Gateway switch Gateway A message remains alongside B after connecting to Gateway B Only Gateway B message remains after switching connections
Live activity after account change Account A tool preview remains after account B connects Previous account tool preview is cleared when account B connects

Gateway switch and mounted Activity account-change recording

137108-recording.webm

Visual verification

  • Baseline: 140d9e7
  • Exact head: 3a072714c5852e9c0d6c1121e8a4d7b74625dcd5
  • Scenario: Switch from Gateway A to B in Debug, then reconnect the same Gateway as a different authenticated account while Live activity stays mounted.
  • Runtime/build: Vite source mode captured at e47b00c; reused for the patch-equivalent rebased head after range-diff and relevant runtime/dependency inspection; Node v24.19.0; Chromium 144.0.7559.0; synthetic Gateway fixtures and build labels
  • Old Gateway messages after switching: 1 before; 0 after; new Gateway messages remain visible
  • Old Activity previews after account change: 1 before; 0 after; the same Activity element remains mounted
  • Unchanged reconnect: Preview and expansion preserved before and after
  • New account tool event: One new preview after repair; no prior-account preview
  • Browser errors: 0 in all before and after scenarios
  • Screenshots inspected at original resolution; full recorded sequences reviewed.
  • Raw source recordings retained.
  • Removing the stale Debug row shortens the page and changes its scroll position.
  • Independent review inspected all ten screenshots and full recorded sequences with no blocking findings.
  • All five public assets returned HTTP 200 without authentication and matched the complete local bytes and SHA-256 hashes.
  • The rebase changes only the canonical locations of the two documentation updates; all 15 changed UI source and test files are byte-identical to the captured head.

@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui size: L maintainer Maintainer-authored PR labels Sep 6, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 5:40 PM ET / 21:40 UTC.

ClawSweeper review

What this changes

Clear Debug event history and Live activity previews when the selected Gateway or authenticated account changes, while preserving history during ordinary reconnects.

Merge readiness

✅ Ready for maintainer review

The repair remains necessary on current main, and no introduced blocking defect was found. The verified test merge resolves the previous conflict concern. This maintainer-authored PR should remain open for the normal landing process.

Priority: P2
Reviewed head: 3a072714c5852e9c0d6c1121e8a4d7b74625dcd5

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with strong supplied browser evidence and meaningful lifecycle regressions; no blocking patch defect was found.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (recording): Preserved the supplied browser-proof assessment: the real Control UI with synthetic Gateway replies demonstrates Debug retirement, mounted Activity clearing after account change, and preserved expansion on unchanged reconnects. Media and earlier-head equivalence could not be independently rechecked in this environment; that is a reviewer limitation, not a contributor proof deficit.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (recording): Preserved the supplied browser-proof assessment: the real Control UI with synthetic Gateway replies demonstrates Debug retirement, mounted Activity clearing after account change, and preserved expansion on unchanged reconnects. Media and earlier-head equivalence could not be independently rechecked in this environment; that is a reviewer limitation, not a contributor proof deficit.
Evidence reviewed 10 items Current main still needs the repair: Current main retains an application-lifetime eventLog. Connection changes invalidate chat snapshots but do not retire diagnostic history, and the accepted handshake does not bind that history to its recovery scope.
Owner-level retirement: The introduced code retires history synchronously for changed connection settings, binds subsequent history to the accepted handshake scope, and fences reentrant publication against replaced history or clients.
Both diagnostic consumers covered: Debug already subscribes to event-log changes. Activity now observes retirement revisions separately from incremental events, clears expanded previews, and uses a weak Clear boundary so retired payloads are not retained by that marker.
Findings None None.
Security None None.

How this fits together

The Control UI’s application Gateway store receives connection handshakes and event payloads. Its retained event history feeds Debug and Live activity, so retirement must reach both views when the connection identity changes.

flowchart TD
  A[Connection settings] --> C[Gateway history owner]
  B[Authenticated handshake] --> C
  C --> D{Identity changed?}
  D -->|Yes| E[Clear history and previews]
  D -->|No| F[Preserve reconnect history]
  E --> G[Debug and Live activity]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +80, Tests +425, Docs +1. Total +506 across 17 files.

View PR surface stats
Area Files Added Removed Net
Source 4 110 30 +80
Tests 11 426 1 +425
Docs 2 2 1 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 17 538 32 +506

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +80 lines; tests and test support net +425 lines Production growth implements shared history retirement and consumer invalidation; the larger test delta exercises lifecycle and reentrancy boundaries.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #137108
Summary: This PR is the candidate repair for the paired open diagnostic-history issue.

Members:

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

Technical review

Best possible solution:

Keep diagnostic retirement centralized in the Gateway store, with both views clearing on identity changes and retaining useful same-context reconnect history.

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

Yes, source establishes the path: receive an event from Gateway A, switch to B without reloading, and current main retains A’s event log. This reviewer did not execute that path.

Is this the best way to solve the issue?

Yes. Retiring history at its producer and notifying existing consumers is a focused repair that preserves ordinary reconnect behavior without adding configuration or durable-state changes.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7921ec48f82d.

Labels

Label changes:

  • add proof: 🎥 video: Contributor real behavior proof includes video or recording evidence. Preserved the supplied browser-proof assessment: the real Control UI with synthetic Gateway replies demonstrates Debug retirement, mounted Activity clearing after account change, and preserved expansion on unchanged reconnects. Media and earlier-head equivalence could not be independently rechecked in this environment; that is a reviewer limitation, not a contributor proof deficit.

Label justifications:

  • P2: This is a bounded Control UI repair for stale diagnostics after connection or account changes.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (recording): Preserved the supplied browser-proof assessment: the real Control UI with synthetic Gateway replies demonstrates Debug retirement, mounted Activity clearing after account change, and preserved expansion on unchanged reconnects. Media and earlier-head equivalence could not be independently rechecked in this environment; that is a reviewer limitation, not a contributor proof deficit.
  • proof: sufficient: Contributor real behavior proof is sufficient. Preserved the supplied browser-proof assessment: the real Control UI with synthetic Gateway replies demonstrates Debug retirement, mounted Activity clearing after account change, and preserved expansion on unchanged reconnects. Media and earlier-head equivalence could not be independently rechecked in this environment; that is a reviewer limitation, not a contributor proof deficit.
  • proof: 🎥 video: Contributor real behavior proof includes video or recording evidence. Preserved the supplied browser-proof assessment: the real Control UI with synthetic Gateway replies demonstrates Debug retirement, mounted Activity clearing after account change, and preserved expansion on unchanged reconnects. Media and earlier-head equivalence could not be independently rechecked in this environment; that is a reviewer limitation, not a contributor proof deficit.

Evidence

What I checked:

  • Current main still needs the repair: Current main retains an application-lifetime eventLog. Connection changes invalidate chat snapshots but do not retire diagnostic history, and the accepted handshake does not bind that history to its recovery scope. (ui/src/app/gateway-store.ts:158, 7921ec48f82d)
  • Owner-level retirement: The introduced code retires history synchronously for changed connection settings, binds subsequent history to the accepted handshake scope, and fences reentrant publication against replaced history or clients. (ui/src/app/gateway-store.ts:379, 3a072714c585)
  • Both diagnostic consumers covered: Debug already subscribes to event-log changes. Activity now observes retirement revisions separately from incremental events, clears expanded previews, and uses a weak Clear boundary so retired payloads are not retained by that marker. (ui/src/pages/activity/activity-page.ts:119, 3a072714c585)
  • Existing handshake contract: The server derives recoveryScope from authenticated principal/device or existing credential identity. The browser forwards the accepted hello to the application store. The patch consumes this existing identity signal without granting authority or changing authentication, persistence, or protocol contracts. (src/gateway/server/ws-connection/connect-hello.ts:97, 3a072714c585)
  • Previous conflict concern resolved: Raw test-merge parents are the pinned base 1873328 followed by the exact PR head. Inspection of its production delta confirms the intended retirement changes survive integration; the previous review’s conflict warning is no longer supported. (ui/src/app/gateway-store.ts, 28a2883ce87f)
  • Captured browser proof: The supplied body at sourceRevision f19def371467949e2d057355c265cbcdb10a841564e0adfdb9e6962a78ee0c2d records real Control UI browser runs with synthetic Gateway replies: old Debug messages and mounted Activity previews each fall from one to zero after identity changes; unchanged reconnects preserve previews and expansion. It links before/after screenshots and recording https://github.com/user-attachments/assets/0ecfd380-0582-4d60-897c-7f1d6040fe15. Captures were made at e47b00c and the body reports byte-identical UI files after rebase. Existing proof sufficiency is preserved; this reviewer could not independently reopen media or compare the unavailable earlier commit because GitHub network access failed. (e47b00cb3496)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • RoboClaw: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-06T20:30:39.625Z sha 4827e58 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-06T20:42:48.136Z sha e47b00c :: blocked before merge. :: none
  • reviewed 2026-09-06T21:18:50.198Z sha e47b00c :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 6, 2026
@shakkernerd
shakkernerd force-pushed the fix-gateway-event-history branch from e47b00c to 3a07271 Compare September 6, 2026 21:34
@clawsweeper clawsweeper Bot added the proof: 🎥 video Contributor real behavior proof includes video or recording evidence. label Sep 6, 2026
@shakkernerd shakkernerd self-assigned this Sep 6, 2026
@shakkernerd
shakkernerd merged commit 294df33 into main Sep 6, 2026
137 of 139 checks passed
@shakkernerd
shakkernerd deleted the fix-gateway-event-history branch September 6, 2026 21:58
@shakkernerd

Copy link
Copy Markdown
Member Author

Fixed: switching Gateway or authentication context clears stale Debug and Live activity diagnostics while ordinary reconnects preserve history.

vincentkoc added a commit that referenced this pull request Sep 6, 2026
* commit '294df333c58f2da104eccffc623ccb3c4d43d4d8': (1802 commits)
  fix: clear stale diagnostics after Gateway changes (#140426)
  fix: keep plugin catalogs intact after discovery timeouts (#140441)
  perf(tui): prepare session picker rows once per overlay (#140462)
  refactor(config): reuse environment substitution for write-back (#140460)
  refactor(discord): remove retired auto-presence templates (#140463)
  fix(ui): finish roster refreshes during session activity (#140459)
  fix(setup): match prepared credentials to the model provider (#140461)
  fix: keep MiniMax discovery on the selected credential (#140438)
  refactor(tests): remove unused parent context cache reset (#140456)
  fix: avoid repeated xAI OAuth refresh during discovery (#140434)
  perf(routing): reuse prepared event session targets (#140454)
  fix(media): keep deferred audio and extraction providers discoverable (#139231)
  refactor(codex): remove redundant app-server forwarding (#140451)
  fix(test): avoid false native polling timeouts (#140119)
  test(gateway): retain saved source in reload fixtures (#140453)
  fix(gateway): reduce repeated model work when listing sessions (#140414)
  fix(feishu): fall back to post mode over table limit (#136382)
  fix: use the bundle-compatible Proxyline runtime under Bun (#140411)
  refactor(trace): reuse the canonical usage counter type (#140444)
  refactor(node-host): share execution policy result fields (#140446)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
Clear stale Debug history and Live activity previews after Gateway or authentication changes while preserving ordinary reconnect history.

Fixes openclaw#137108.
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 docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Debug event log retains events from the previous Gateway after switching connections

1 participant