@@ -113,18 +113,10 @@ func renderAssistantMessage(
113113 width int,
114114 position int,
115115) []uiMessage {
116− // find the user message that is before this assistant message
117− var userMsg message.Message
118− for i := msgIndex - 1; i >= 0; i-- {
119− msg := allMessages[i]
120− if msg.Role == message.User {
121− userMsg = allMessages[i]
122− break
123− }
124− }
125−
126116 messages := []uiMessage{}
127117 content := msg.Content().String()
118+ thinking := msg.IsThinking()
119+ thinkingContent := msg.ReasoningContent().Thinking
128120 finished := msg.IsFinished()
129121 finishData := msg.FinishPart()
130122 info := []string{}
@@ -133,7 +125,7 @@ func renderAssistantMessage(
133125 if finished {
134126 switch finishData.Reason {
135127 case message.FinishReasonEndTurn:
136− took := formatTimeDifference(userMsg.CreatedAt, finishData.Time)
128+ took := formatTimeDifference(msg.CreatedAt, finishData.Time)
137129 info = append(info, styles.BaseStyle.Width(width-1).Foreground(styles.ForgroundDim).Render(
138130 fmt.Sprintf(" %s (%s)", models.SupportedModels[msg.Model].Name, took),
139131 ))
@@ -166,6 +158,9 @@ func renderAssistantMessage(
166158 })
167159 position += messages[0].height
168160 position++ // for the space
161+ } else if thinking && thinkingContent != "" {
162+ // Render the thinking content
163+ content = renderMessage(thinkingContent, false, msg.ID == focusedUIMessageId, width)
169164 }
170165
171166 for i, toolCall := range msg.ToolCalls() {
@@ -218,10 +213,40 @@ func toolName(name string) string {
218213 return "View"
219214 case tools.WriteToolName:
220215 return "Write"
216+ case tools.PatchToolName:
217+ return "Patch"
221218 }
222219 return name
223220}
224221
222+func getToolAction(name string) string {
223+ switch name {
224+ case agent.AgentToolName:
225+ return "Preparing prompt..."
226+ case tools.BashToolName:
227+ return "Building command..."
228+ case tools.EditToolName:
229+ return "Preparing edit..."
230+ case tools.FetchToolName:
231+ return "Writing fetch..."
232+ case tools.GlobToolName:
233+ return "Finding files..."
234+ case tools.GrepToolName:
235+ return "Searching content..."
236+ case tools.LSToolName:
237+ return "Listing directory..."
238+ case tools.SourcegraphToolName:
239+ return "Searching code..."
240+ case tools.ViewToolName:
241+ return "Reading file..."
242+ case tools.WriteToolName:
243+ return "Preparing write..."
244+ case tools.PatchToolName:
245+ return "Preparing patch..."
246+ }
247+ return "Working..."
248+}
249+
225250// renders params, params[0] (params[1]=params[2] ....)
226251func renderParams(paramsWidth int, params ...string) string {
227252 if len(params) == 0 {
@@ -490,8 +515,47 @@ func renderToolMessage(
490515 if nested {
491516 width = width - 3
492517 }
518+ style := styles.BaseStyle.
519+ Width(width - 1).
520+ BorderLeft(true).
521+ BorderStyle(lipgloss.ThickBorder()).
522+ PaddingLeft(1).
523+ BorderForeground(styles.ForgroundDim)
524+
493525 response := findToolResponse(toolCall.ID, allMessages)
494526 toolName := styles.BaseStyle.Foreground(styles.ForgroundDim).Render(fmt.Sprintf("%s: ", toolName(toolCall.Name)))
527+
528+ if !toolCall.Finished {
529+ // Get a brief description of what the tool is doing
530+ toolAction := getToolAction(toolCall.Name)
531+
532+ // toolInput := strings.ReplaceAll(toolCall.Input, "\n", " ")
533+ // truncatedInput := toolInput
534+ // if len(truncatedInput) > 10 {
535+ // truncatedInput = truncatedInput[len(truncatedInput)-10:]
536+ // }
537+ //
538+ // truncatedInput = styles.BaseStyle.
539+ // Italic(true).
540+ // Width(width - 2 - lipgloss.Width(toolName)).
541+ // Background(styles.BackgroundDim).
542+ // Foreground(styles.ForgroundMid).
543+ // Render(truncatedInput)
544+
545+ progressText := styles.BaseStyle.
546+ Width(width - 2 - lipgloss.Width(toolName)).
547+ Foreground(styles.ForgroundDim).
548+ Render(fmt.Sprintf("%s", toolAction))
549+
550+ content := style.Render(lipgloss.JoinHorizontal(lipgloss.Left, toolName, progressText))
551+ toolMsg := uiMessage{
552+ messageType: toolMessageType,
553+ position: position,
554+ height: lipgloss.Height(content),
555+ content: content,
556+ }
557+ return toolMsg
558+ }
495559 params := renderToolParams(width-2-lipgloss.Width(toolName), toolCall)
496560 responseContent := ""
497561 if response != nil {
@@ -504,12 +568,6 @@ func renderToolMessage(
504568 Foreground(styles.ForgroundDim).
505569 Render("Waiting for response...")
506570 }
507− style := styles.BaseStyle.
508− Width(width - 1).
509− BorderLeft(true).
510− BorderStyle(lipgloss.ThickBorder()).
511− PaddingLeft(1).
512− BorderForeground(styles.ForgroundDim)
513571
514572 parts := []string{}
515573 if !nested {