Fix model name display in TUI sidebar for all model types#2118
Conversation
The sidebar flickered because AgentInfoEvent was emitted multiple times per LLM turn (before and after the call) and never showed the actual model for rule-based routing. Three changes fix all issues: 1. sidebar.SetAgentInfo: early-return when agent name, model, and description are all unchanged. This is the single dedup point that prevents redundant re-renders from any emission source. 2. loop.go: move the per-iteration AgentInfo emission from stream start to right before the LLM call. Remove the post-call revert branch that caused the original flickering. Fallback models are handled via a dedicated post-call emission. 3. rulebased/client.go: wrap the stream returned by the selected sub-provider to override response.Model with the sub-provider's ID (the YAML-configured name). streaming.go emits AgentInfo as soon as the first chunk reveals a model different from the one already shown, so the sidebar updates immediately when a routed model starts responding. Assisted-By: docker-agent
There was a problem hiding this comment.
Review Summary
Assessment: 🟢 APPROVE
Summary
This PR successfully fixes the sidebar flickering issue through three well-coordinated changes:
-
Deduplication in sidebar.go: The
SetAgentInfomethod now properly checks all three fields (agent name, model ID, and description) before early-returning, preventing redundant re-renders. -
Event timing in loop.go: Moving the
AgentInfoemission to just before the LLM call (instead of at loop start) and removing the post-call revert logic eliminates the flickering caused by multiple emissions per turn. -
Rule-based routing support: The
rulebased.Clientnow tracks and exposes the selected sub-provider ID viaLastSelectedModelID(), which is properly consumed infallback.goto emit the correct model name for routed calls.
The changes are clean, well-commented, and include comprehensive test updates. The code correctly handles:
- Type assertions with ok checks (fallback.go:289)
- All three fields in the deduplication check (sidebar.go:274)
- Proper state tracking without race conditions
Findings
No issues found. The implementation is correct and addresses the stated problem effectively.
The sidebar flickered because AgentInfoEvent was emitted multiple times per LLM turn (before and after the call) and never showed the actual model for rule-based routing.
Three changes fix all issues:
sidebar.SetAgentInfo: early-return when agent name, model, and description are all unchanged. This is the single dedup point that prevents redundant re-renders from any emission source.
loop.go: move the per-iteration AgentInfo emission from stream start to right before the LLM call. Remove the post-call revert branch that caused the original flickering. Fallback models are handled via a dedicated post-call emission.
rulebased/client.go: wrap the stream returned by the selected sub-provider to override response.Model with the sub-provider's ID (the YAML-configured name). streaming.go emits AgentInfo as soon as the first chunk reveals a model different from the one already shown, so the sidebar updates immediately when a routed model starts responding.
Assisted-By: docker-agent