feat(tui): show router inference metrics beside router lines

This commit is contained in:
2026-06-03 15:41:51 +04:00
parent c2fb17f6ee
commit 80a72d370e
6 changed files with 45 additions and 7 deletions
+12
View File
@@ -1,6 +1,7 @@
package app
import (
"fmt"
"os"
"strings"
@@ -352,6 +353,9 @@ func (m Model) routerRows(w, h int) []string {
for _, ln := range wrap(e.Content, w) {
rows = append(rows, t.span(ln, t.P.Fg))
}
if s := metricsSuffix(e.Metrics); s != "" {
rows = append(rows, t.span(s, t.P.Faint))
}
case "tool":
rows = append(rows, t.span("· tool output ("+itoaLen(e.Content)+" chars) — ^x to view", t.P.Dim))
case "narration", "stage":
@@ -570,6 +574,14 @@ func itoa(n int) string {
func itoaLen(s string) string { return itoa(len(s)) }
// metricsSuffix formats the faint latency+token annotation for a ROUTER turn.
func metricsSuffix(mtr *TurnMetrics) string {
if mtr == nil {
return ""
}
return fmt.Sprintf(" %.1fs · %d tokens", float64(mtr.LatencyMs)/1000.0, mtr.TotalTokens)
}
// wrap splits s into lines no wider than w (rune-based, whitespace-greedy).
func wrap(s string, w int) []string {
if w < 1 {