Reduced Duo Agentic Chat messages processing
What does this MR do and why?
TL;DR; The change reduces the load, related to processing the Duo Chat messages, reduces the flickering and disappearance of the messages
The MR is addressing the discoveries as presented in #571307 (comment 2883850958). In particular:
- stop updating the messages list on every message from WebSocket
- don't wipe out
state.messageson every new arriving message - use only the latest message from ui_chat_log in the checkpoint to reduce processing on every WebSocket message. This is a temporary solution while we address it properly on the BE
- since we do not wipe messages and don't iterate over all of the messages in the ui_chat_log, we preserve the messages already output on the screen. There's an issue in BE where BE replaces a message after a failed tool request instead of appending. This MR temporarily addresses that issue while we deal with it on the BE
References
- Duo Agentic Chat - Agent messages disappearing ... (#571307)
- Chat messages disappear momentarily when restar... (#579861)
Screenshots or screen recordings
The main benefit of this MR, alongside the improved UX is the JS usage reduction. Here's the comparison of the allocation sampling profiles and the chart representation of it. Note that we use about 2,6kB of JS after the change vs 6+kB (about **45% **reduction) before for exactly the same operation (new prompt with some responses from the agent)
| Before | After |
|---|---|
|
|
|
|
Visual changes
Note how the messages appear, disappear, appear again in Before vs. After
| Before | After |
|---|---|
| disappearing-thought-message2 | fix2_-_disappearing-thought-message |
How to set up and validate locally
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #571307



