Repository navigation
refactor(gateway): unify chat run state - #113157
Merged
Merged
Conversation
steipete
marked this pull request as ready for review
July 23, 2026 22:08
Contributor
Author
|
Merged via squash.
|
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Jul 24, 2026
* refactor(gateway): unify chat run state * test(gateway): align chat run fixtures
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
Gateway chat runs stored one logical run across parallel maps for buffers, plan state, timestamps, abort markers, registration queues, and tool-event recipients. That made lifecycle cleanup easy to miss on one surface and forced the same state bundle through request, maintenance, restart, and local-runtime boundaries.
Why This Change Was Made
This replaces the parallel storage with one insertion-ordered
Map<runId, ChatRunRecord>. Registration queues and tool recipients share the same record owner, transient projection cleanup is centralized, and abort tombstones plus FIFO/recipient lifetimes remain intact. Protocol event and persistence shapes are unchanged.User Impact
There is no user-visible behavior change. Gateway chat state now has one lifecycle owner, reducing the risk of stale buffers, incomplete cleanup, or mismatched per-run metadata during aborts, reloads, and restart shutdown.
Evidence
src/gateway/server-chat.agent-events.test.ts129/129 passed on both implementations.src/gateway/server-chat-state.test.ts10/10 passed.check:changedpassed for core + core tests, including production/test typecheck, format, lint, max-lines, import cycles, and database-first guards: https://github.com/openclaw/openclaw/actions/runs/30047457810