Skip to content

Commit 0e3be73

Browse files
committed
Extract tool icon code
Signed-off-by: David Gageot <david.gageot@docker.com>
1 parent 898f2be commit 0e3be73

1 file changed

Lines changed: 18 additions & 19 deletions

File tree

  • internal/tui/components/tool

internal/tui/components/tool/tool.go

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,6 @@ func (mv *toolModel) View() string {
104104
// Render renders the message view content
105105
func (mv *toolModel) Render(width int) string {
106106
msg := mv.message
107-
var icon string
108-
109-
// Use predefined styles
110-
111-
switch msg.ToolStatus {
112-
case types.ToolStatusPending:
113-
icon = "⊙"
114-
case types.ToolStatusRunning:
115-
icon = "⚙"
116-
case types.ToolStatusCompleted:
117-
icon = styles.SuccessStyle.Render("✓")
118-
case types.ToolStatusError:
119-
icon = styles.ErrorStyle.Render("✗")
120-
case types.ToolStatusConfirmation:
121-
icon = styles.WarningStyle.Render("?")
122-
default:
123-
icon = styles.WarningStyle.Render("?")
124-
}
125107

126108
// Add spinner for pending and running tools
127109
var spinnerText string
@@ -133,7 +115,7 @@ func (mv *toolModel) Render(width int) string {
133115
team := mv.app.Team()
134116
agent := team.Agent(msg.Sender)
135117
displayName := agent.ToolDisplayName(context.TODO(), msg.ToolCall.Function.Name)
136-
content := fmt.Sprintf("%s %s%s", icon, styles.HighlightStyle.Render(displayName), spinnerText)
118+
content := fmt.Sprintf("%s %s%s", icon(msg.ToolStatus), styles.HighlightStyle.Render(displayName), spinnerText)
137119

138120
if msg.ToolCall.Function.Arguments != "" {
139121
lines := wrapLines(msg.ToolCall.Function.Arguments, mv.width-2)
@@ -195,3 +177,20 @@ func (mv *toolModel) Focus() tea.Cmd {
195177
func (mv *toolModel) Blur() {
196178
mv.focused = false
197179
}
180+
181+
func icon(status types.ToolStatus) string {
182+
switch status {
183+
case types.ToolStatusPending:
184+
return "⊙"
185+
case types.ToolStatusRunning:
186+
return "⚙"
187+
case types.ToolStatusCompleted:
188+
return styles.SuccessStyle.Render("✓")
189+
case types.ToolStatusError:
190+
return styles.ErrorStyle.Render("✗")
191+
case types.ToolStatusConfirmation:
192+
return styles.WarningStyle.Render("?")
193+
default:
194+
return styles.WarningStyle.Render("?")
195+
}
196+
}

0 commit comments

Comments
 (0)