Skip to content

Fix model name display in TUI sidebar for all model types#2118

Merged
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/the-showing-of-which-model-is-currently-fa66a995
Mar 16, 2026
Merged

Fix model name display in TUI sidebar for all model types#2118
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/the-showing-of-which-model-is-currently-fa66a995

Conversation

@dgageot
Copy link
Member

@dgageot dgageot commented Mar 16, 2026

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

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
@dgageot dgageot requested a review from a team as a code owner March 16, 2026 10:57
Copy link

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Assessment: 🟢 APPROVE

Summary

This PR successfully fixes the sidebar flickering issue through three well-coordinated changes:

  1. Deduplication in sidebar.go: The SetAgentInfo method now properly checks all three fields (agent name, model ID, and description) before early-returning, preventing redundant re-renders.

  2. Event timing in loop.go: Moving the AgentInfo emission 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.

  3. Rule-based routing support: The rulebased.Client now tracks and exposes the selected sub-provider ID via LastSelectedModelID(), which is properly consumed in fallback.go to 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.

@dgageot dgageot merged commit 9a75703 into docker:main Mar 16, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants