mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 11:20:43 +00:00
fix(ui): skip chat history reload during active sends to prevent message card delay
When a user sends a message, the Control UI performs an optimistic update to
display the message immediately. However, if a session.message gateway event
arrives during the send, it triggers an unconditional loadChatHistory() call.
This race condition resets chatStream to null, causing the optimistic message
card to disappear until the first LLM delta arrives.
The fix adds a guard to skip history reload while a chat run is active
(host.chatRunId is set). The chat event handler already manages streaming state
and appends the final assistant message, making the concurrent reload unnecessary
during active sends. External message refresh is preserved for idle sessions.
Fixes the regression introduced in commit 20266c14cb (added session.message
event handling for qa-lab testing).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -422,6 +422,14 @@ function handleSessionMessageGatewayEvent(
|
||||
if (!sessionKey || sessionKey !== host.sessionKey) {
|
||||
return;
|
||||
}
|
||||
// Skip history reload while a chat run is active. The chat event handler
|
||||
// manages streaming state and appends the final assistant message. Reloading
|
||||
// history mid-run races with the optimistic user-message update and resets
|
||||
// chatStream, which delays the user message card from appearing until the
|
||||
// first LLM delta arrives.
|
||||
if (host.chatRunId) {
|
||||
return;
|
||||
}
|
||||
void loadChatHistory(host as unknown as ChatState);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user