diff options
| author | spoons-and-mirrors <[email protected]> | 2025-08-10 03:22:16 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-09 20:22:16 -0500 |
| commit | bd4319f2bc28c0ad16946107e7d1d50fa924527e (patch) | |
| tree | e1a404ee7e1aebe7f6a4b804a847b2530ca37de9 /packages/tui/internal/components | |
| parent | 696ab1a752e5bfa520379e21d933be1cd3058ce0 (diff) | |
| download | opencode-bd4319f2bc28c0ad16946107e7d1d50fa924527e.tar.gz opencode-bd4319f2bc28c0ad16946107e7d1d50fa924527e.zip | |
Feat: Add Agent Name in the LLM Response Footer (and re-order it) (#1770)
Diffstat (limited to 'packages/tui/internal/components')
| -rw-r--r-- | packages/tui/internal/components/chat/message.go | 32 | ||||
| -rw-r--r-- | packages/tui/internal/components/status/status.go | 30 |
2 files changed, 37 insertions, 25 deletions
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 { diff --git a/packages/tui/internal/components/status/status.go b/packages/tui/internal/components/status/status.go index be34dd938..1634bd6c5 100644 --- a/packages/tui/internal/components/status/status.go +++ b/packages/tui/internal/components/status/status.go @@ -121,30 +121,14 @@ func (m *statusComponent) View() string { var modeBackground compat.AdaptiveColor var modeForeground compat.AdaptiveColor - switch m.app.AgentIndex { - case 0: + + agentColor := util.GetAgentColor(m.app.AgentIndex) + + if m.app.AgentIndex == 0 { modeBackground = t.BackgroundElement() - modeForeground = t.TextMuted() - case 1: - modeBackground = t.Secondary() - modeForeground = t.BackgroundPanel() - case 2: - modeBackground = t.Accent() - modeForeground = t.BackgroundPanel() - case 3: - modeBackground = t.Success() - modeForeground = t.BackgroundPanel() - case 4: - modeBackground = t.Warning() - modeForeground = t.BackgroundPanel() - case 5: - modeBackground = t.Primary() - modeForeground = t.BackgroundPanel() - case 6: - modeBackground = t.Error() - modeForeground = t.BackgroundPanel() - default: - modeBackground = t.Secondary() + modeForeground = agentColor + } else { + modeBackground = agentColor modeForeground = t.BackgroundPanel() } |
