Repository navigation
fix(gateway): keep reconnect chat replays in the canonical thread; empty branch list for fresh sessions - #112756
Merged
Merged
Conversation
…ct replays stay in the visible thread
steipete
marked this pull request as ready for review
July 22, 2026 20:55
Contributor
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(gateway): keep reconnect chat replays in the canonical thread; empty branch list for fresh sessions This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
Contributor
Author
|
Merged via squash.
|
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Jul 24, 2026
…pty branch list for fresh sessions (openclaw#112756) * fix(gateway): return empty branch list for not-yet-materialized sessions * fix(gateway): canonicalize global agent alias in chat.send so reconnect replays stay in the visible thread * test(gateway): assert canonical-key error broadcast for global agent alias sends
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Live stress-testing the shipped web rewind/fork/branch flows (isolated dev gateway, OpenAI-key inference, real browser driving) surfaced two gateway bugs:
Reconnect replays split the thread. The web outbox stores the default agent's thread under the shipped
globalalias scope. On reconnect, the durable-outbox drain flusheschat.sendwithsessionKey: "global"+agentId, and session load materialized a parallel literalglobalsession instead of the canonical agent main thread. Queued messages and their model replies landed in a hidden transcript: the user sees their message vanish after reconnect while tokens are spent invisibly. Reproduced 3/3 (isolated gateway, latest main); agent-DBsession_entriesshowed bothagent:main:mainandglobalrows, with the queued turns + replies in the orphan session. Online sends were unaffected because the foreground path routes with the page's concrete session key.Fresh sessions error on branch listing.
sessions.branches.listrespondedINVALID_REQUEST: session not foundfor a session key that simply has not materialized yet (every new-chat page load), putting spurious failures in gateway logs and forcing clients to special-case a well-defined empty state.Why This Change Was Made
chat.sendsession load now canonicalizes theglobal+ agentId alias toresolveAgentMainSessionKey(...)(the same resolver history/routes use) whenever the configured session scope is notglobal, and the admission/pre-admission reloads reuse that same key, so one thread can no longer split. Configured global scope keeps its literal key.sessions.branches.listreturns{ branches: [] }for a not-yet-materialized session; the mutating siblings (rewind/switch/fork) still treat a missing session as an error.User Impact
Messages queued offline in the web UI now land in the visible thread with their replies after reconnect, instead of disappearing into a hidden parallel transcript. New-chat loads no longer emit gateway error-log noise for branch listing.
Evidence
chat.directive-tags.test.ts("resolves per-sender global agent aliases to the canonical agent main session" — asserts dispatch lands onagent:main:mainand rawglobalis never loaded) andsessions-rewind.test.ts(empty list for unmaterialized session). Focused runs green: 150/150 and 21/21.fig/grape/honeydew) + replies landed in orphan sessionfd8f35fa…(keyglobal); post-fix, the same offline→reconnect cycle landedkiwi+ reply in the currentagent:main:mainsession (96a034d0…) with the outbox drained and the reply visible in the UI.sessionStoragewrite trap (drain reconcile atui/src/pages/chat/chat-send.ts:1393) plus agent-DB transcript queries.