Feat: Add Agent Name in the LLM Response Footer (and re-order it) (#1770)

This commit is contained in:
spoons-and-mirrors
2025-08-10 03:22:16 +02:00
committed by GitHub
parent 696ab1a752
commit bd4319f2bc
4 changed files with 81 additions and 31 deletions

View File

@@ -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 {