formatDebugEvent renders one event as a single line, color-coded by level and source. The leading `# ` is what the user passes to /debug show. A trailing dot marks events that have an inspectable payload.
(e debug.Event)
| 803 | // and source. The leading `#<id>` is what the user passes to /debug show. |
| 804 | // A trailing dot marks events that have an inspectable payload. |
| 805 | func formatDebugEvent(e debug.Event) string { |
| 806 | id := fmt.Sprintf("#%-4d", e.ID) |
| 807 | ts := e.Time.Format("15:04:05.000") |
| 808 | source := fmt.Sprintf("%-10s", e.Source) |
| 809 | switch e.Source { |
| 810 | case "provider": |
| 811 | source = lipgloss.NewStyle().Foreground(lipgloss.Color("36")).Render(source) |
| 812 | case "tool": |
| 813 | source = lipgloss.NewStyle().Foreground(lipgloss.Color("114")).Render(source) |
| 814 | case "compact": |
| 815 | source = lipgloss.NewStyle().Foreground(lipgloss.Color("220")).Render(source) |
| 816 | default: |
| 817 | if strings.HasPrefix(e.Source, "tool/") { |
| 818 | source = lipgloss.NewStyle().Foreground(lipgloss.Color("141")).Render(source) |
| 819 | } |
| 820 | } |
| 821 | msg := e.Message |
| 822 | switch e.Level { |
| 823 | case debug.LevelError: |
| 824 | msg = lipgloss.NewStyle().Foreground(lipgloss.Color("203")).Render(msg) |
| 825 | case debug.LevelWarn: |
| 826 | msg = lipgloss.NewStyle().Foreground(lipgloss.Color("214")).Render(msg) |
| 827 | } |
| 828 | marker := " " |
| 829 | if e.Payload != "" { |
| 830 | marker = lipgloss.NewStyle().Foreground(lipgloss.Color("245")).Render("•") |
| 831 | } |
| 832 | line := Dimmed(id) + " " + Dimmed(ts) + " " + marker + " " + source + " " + msg |
| 833 | // A response carries its CorrelatedID; surface it inline so the user |
| 834 | // can read the conversation flow without entering detail mode. |
| 835 | if e.CorrelatedID != 0 { |
| 836 | line += " " + lipgloss.NewStyle().Foreground(lipgloss.Color("141")).Render( |
| 837 | fmt.Sprintf("↩ #%d", e.CorrelatedID)) |
| 838 | } |
| 839 | return line |
| 840 | } |
| 841 | |
| 842 | // ── view ────────────────────────────────────────────────────────────────── |
| 843 |
no test coverage detected