@@ -226,11 +226,18 @@ func renderText(message client.MessageInfo, text string, author string) string {
226226 if message .Role == client .Assistant {
227227 markdownWidth = width - padding - 4 - 3
228228 }
229- if message .Role == client .User {
230- text = strings .ReplaceAll (text , "<" , "\\ <" )
231- text = strings .ReplaceAll (text , ">" , "\\ >" )
229+ minWidth := max (markdownWidth , (width - 4 )/ 2 )
230+ messageStyle := styles .NewStyle ().
231+ Width (minWidth ).
232+ Background (t .BackgroundPanel ()).
233+ Foreground (t .Text ())
234+ if textWidth < minWidth {
235+ messageStyle = messageStyle .AlignHorizontal (lipgloss .Right )
236+ }
237+ content := messageStyle .Render (text )
238+ if message .Role == client .Assistant {
239+ content = toMarkdown (text , markdownWidth , t .BackgroundPanel ())
232240 }
233- content := toMarkdown (text , markdownWidth , t .BackgroundPanel ())
234241 content = strings .Join ([]string {content , info }, "\n " )
235242
236243 switch message .Role {
@@ -409,7 +416,7 @@ func renderToolInvocation(
409416 title = fmt .Sprintf ("WRITE %s" , relative (filename ))
410417 if content , ok := toolArgsMap ["content" ].(string ); ok {
411418 body = renderFile (filename , content )
412-
419+
413420 // Add diagnostics at the bottom if they exist
414421 if diagnostics := renderDiagnostics (metadata , filename ); diagnostics != "" {
415422 body += "\n " + renderContentBlock (diagnostics , WithFullWidth (), WithBorderColor (t .Error ()))
@@ -753,7 +760,7 @@ func renderDiagnostics(metadata client.MessageMetadata_Tool_AdditionalProperties
753760 continue
754761 }
755762
756- line := diag .Range .Start .Line + 1 // 1-based
763+ line := diag .Range .Start .Line + 1 // 1-based
757764 column := diag .Range .Start .Character + 1 // 1-based
758765 errorDiagnostics = append (errorDiagnostics , fmt .Sprintf ("Error [%d:%d] %s" , line , column , diag .Message ))
759766 }
0 commit comments