From bd4319f2bc28c0ad16946107e7d1d50fa924527e Mon Sep 17 00:00:00 2001 From: spoons-and-mirrors <212802214+spoons-and-mirrors@users.noreply.github.com> Date: Sun, 10 Aug 2025 03:22:16 +0200 Subject: Feat: Add Agent Name in the LLM Response Footer (and re-order it) (#1770) --- packages/tui/internal/components/chat/message.go | 32 ++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'packages/tui/internal/components/chat') diff --git a/packages/tui/internal/components/chat/message.go b/packages/tui/internal/components/chat/message.go index 6dcdcc989..5f4dc9612 100644 --- a/packages/tui/internal/components/chat/message.go +++ b/packages/tui/internal/components/chat/message.go @@ -324,9 +324,37 @@ func renderText( if time.Now().Format("02 Jan 2006") == timestamp[:11] { timestamp = timestamp[12:] } - info := fmt.Sprintf("%s (%s)", author, timestamp) - info = styles.NewStyle().Foreground(t.TextMuted()).Render(info) + // Check if this is an assistant message with mode (agent) information + var modelAndAgentSuffix string + if assistantMsg, ok := message.(opencode.AssistantMessage); ok && assistantMsg.Mode != "" { + // Find the agent index by name to get the correct color + var agentIndex int + for i, agent := range app.Agents { + if agent.Name == assistantMsg.Mode { + agentIndex = i + break + } + } + + // Get agent color based on the original agent index (same as status bar) + agentColor := util.GetAgentColor(agentIndex) + + // Style the agent name with the same color as status bar + agentName := strings.Title(assistantMsg.Mode) + styledAgentName := styles.NewStyle().Foreground(agentColor).Bold(true).Render(agentName) + modelAndAgentSuffix = fmt.Sprintf(" | %s | %s", assistantMsg.ModelID, styledAgentName) + } + + var info string + if modelAndAgentSuffix != "" { + // For assistant messages: "timestamp | modelID | agentName" + info = fmt.Sprintf("%s%s", timestamp, modelAndAgentSuffix) + } else { + // For user messages: "author (timestamp)" + info = fmt.Sprintf("%s (%s)", author, timestamp) + } + info = styles.NewStyle().Foreground(t.TextMuted()).Render(info) if !showToolDetails && toolCalls != nil && len(toolCalls) > 0 { content = content + "\n\n" for _, toolCall := range toolCalls { -- cgit v1.2.3