MCPcopy Create free account
hub / github.com/MiniCodeMonkey/chief / renderToolResult

Method renderToolResult

internal/tui/log.go:421–456  ·  view source on GitHub ↗

renderToolResult renders a tool result.

(entry LogEntry)

Source from the content-addressed store, hash-verified

419
420// renderToolResult renders a tool result.
421func (l *LogViewer) renderToolResult(entry LogEntry) []string {
422 resultStyle := lipgloss.NewStyle().Foreground(MutedColor)
423 checkStyle := lipgloss.NewStyle().Foreground(SuccessColor)
424
425 text := entry.Text
426 if text == "" {
427 return []string{resultStyle.Render(checkStyle.Render(" ↳ ") + "(no output)")}
428 }
429
430 // Use pre-computed syntax highlighting if available
431 if entry.highlightedCode != "" {
432 lines := strings.Split(entry.highlightedCode, "\n")
433 var result []string
434 result = append(result, checkStyle.Render(" ↳ ")) // Result indicator
435 // Limit to 20 lines to keep the log view manageable
436 maxLines := 20
437 for i, line := range lines {
438 if i >= maxLines {
439 result = append(result, resultStyle.Render(fmt.Sprintf(" ... (%d more lines)", len(lines)-maxLines)))
440 break
441 }
442 result = append(result, " "+line)
443 }
444 return result
445 }
446
447 // Fallback: show a compact single-line result
448 maxLen := l.width - 8
449 if maxLen < 20 {
450 maxLen = 20
451 }
452 if len(text) > maxLen {
453 text = text[:maxLen-3] + "..."
454 }
455 return []string{resultStyle.Render(checkStyle.Render(" ↳ ") + text)}
456}
457
458// highlightCode applies syntax highlighting to code based on file extension.
459func (l *LogViewer) highlightCode(code, filePath string) string {

Callers 1

renderEntryMethod · 0.95

Calls 1

RenderMethod · 0.45

Tested by

no test coverage detected