Repository navigation
fix(tui): send messages to the correct agent after roster changes - #126820
Merged
Merged
Conversation
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Contributor
Author
|
Merged via squash.
|
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Aug 21, 2026
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
Fixes an issue where Terminal UI users could send their next message to the wrong agent after the selected agent disappeared from a refreshed Gateway roster. The visible agent changed to the replacement, but the selected session key, session ID, active run, pending prompt, and transcript projection still belonged to the removed agent.
Why This Change Was Made
The existing canonical synchronous session transition is now shared by explicit session selection and agent-roster fallback. The replacement agent's canonical session is resolved before any selected identity changes, then the complete previous session lifecycle is retired together. Global sessions retain their literal
globalkey while updating their owner, already-valid agent selections stay untouched, and the existing reconnect path remains the sole history-loading owner.Production delta is +48/-42 (net +6): most changed lines move the existing transition into its canonical shared owner; the small net increase passes the explicit replacement agent into the existing resolver and avoids a transient mismatched agent/session tuple. No Gateway protocol, authorization, configuration, persistence, or public API changes.
User Impact
When an agent disappears, the Terminal UI selects the surviving agent's actual session before accepting further messages. Stale runs, optimistic drafts, transcript rows, session-specific overrides, and old session IDs cannot bleed into the replacement conversation; global sessions and unchanged agents keep their existing behavior.
Evidence
be8e100abe1ede2dd38a21ce78ec32f1acd9e0fd.OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_VITEST_FS_MODULE_CACHE=0 node scripts/run-vitest.mjs src/tui/tui-session-actions.test.ts src/tui/tui.test.ts src/tui/tui-command-handlers.test.ts --configLoader runnerOPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_VITEST_FS_MODULE_CACHE=0 node scripts/run-vitest.mjs run --config test/vitest/vitest.tui-pty.config.ts --configLoader runner -t 'keeps session modes scoped while trace changes and delivery stays process-owned|reconciles active and terminal runs after reconnect history|refreshes pending approvals before loading history'AI-assisted.