Repository navigation
fix(tui): preserve run and session ownership across async events - #130147
Merged
Merged
Conversation
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
steipete
marked this pull request as ready for review
August 26, 2026 13:45
Contributor
Author
|
Merged via squash.
|
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Aug 27, 2026
…nclaw#130147) * fix(tui): preserve run and session ownership across async events * test: stabilize filesystem mocks and gateway restart completion
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
The TUI could silently discard an embedded provider failure or final response that arrived before its submit acknowledgement after a previous run had completed. That left the editor stuck in
sendingand hid actionable provider diagnostics such as xAI account spending limits.Two related asynchronous ownership gaps also allowed an old session to affect a newly selected session: an unnecessary nested session-patch await could apply private model/settings metadata after an agent switch, and a terminal send acknowledgement could overwrite the new session's status or display the previous session's error after history finished loading.
Why This Change Was Made
An embedded backend legitimately emits chat events without the Gateway's per-run payload sequence. The TUI orphan-event fence only recognized acknowledged submissions, overlooking its already-authoritative ownership of the exact provisional local run. Recognize that run only when local mode, pending phase, exact run ID, local ownership, and existing session/agent checks all agree, then preserve that ownership through stream registration.
Move session patching into its single actual owner so one captured session incarnation covers the RPC, immediate setting application, post-patch refresh, and error handling. Revalidate that same incarnation after terminal-ack history loading. This continues the ownership work from #129681 and #129810 while removing the nested helper that created the cross-agent microtask race.
The first hosted run also exposed two existing shard-sensitive CI failures unrelated to the TUI: agent-deletion tests replaced the whole filesystem-safety module while mocking only trash movement, and a Gateway restart test polled lane drainage before the actual delegated approval promise had settled. Preserve the original filesystem exports in both test mocks, and await authoritative approval completion before checking that its lane drains. Both are test-only fixes for the exact failed shards; production behavior is unchanged.
User Impact
sending.Evidence
Red-first owner regressions reproduced all three failure families before the repair: unacknowledged embedded errors/finals remained invisible with a stuck pending submit; terminal
error,timeout, andokacknowledgements mutated a replacement session after history awaited; nested settings patches and delayed refresh failures leaked across agents. Existing xAI real-terminal coverage also failed on unmodified currentmain.After the fix:
Direct production-module replay changed from
{"phase":"sending","visible":false,"pending":"sending"}to{"phase":"sending","visible":true,"message":"run error: monthly spending limit","pending":null}. Negative owner regressions separately prove unrelated local runs, remote unsequenced events, and foreign-session events stay fenced.The affected interface is a terminal, so the running-surface proof is the authenticated real PTY suite and its rendered spending-limit assertion rather than a graphical screenshot.