diff --git a/cmd/agentop/README.md b/cmd/agentop/README.md index 823b32163..7cea72fc6 100644 --- a/cmd/agentop/README.md +++ b/cmd/agentop/README.md @@ -1926,8 +1926,9 @@ when the match arrives with the fetch. `y` writes the half without its capture. `CTX(1M)` is a gauge, not a figure: how full the **conversation's** context was on its latest turn, against a fixed one-million-token window. The -brackets are the scale, drawn on every row, so a nearly-empty session reads -as empty-out-of-something rather than as a blank cell — and an em dash, which +fill is followed by a shaded `░` track for the rest of the window (`███▌░░░`), +so the scale shows on every row and a nearly-empty session reads as +empty-out-of-something rather than as a blank cell — and an em dash, which means *no context known*, stays distinguishable from the sliver a barely-used session gets. diff --git a/cmd/agentop/tui/app.go b/cmd/agentop/tui/app.go index dcfc07e1a..34a3cc378 100644 --- a/cmd/agentop/tui/app.go +++ b/cmd/agentop/tui/app.go @@ -2586,7 +2586,7 @@ func (m *model) paneView() string { renderTitle(title), styleDim.Render(renderDivider(m.width)), body, - renderTrailingHints(footer, keys), + renderTrailingKeyBar(footer, keys, m.width), ) } if m.pane == panePods { @@ -2611,7 +2611,7 @@ func (m *model) paneView() string { renderTitle(title), styleDim.Render(renderDivider(m.width)), body, - renderTrailingHints(footer, keys), + renderTrailingKeyBar(footer, keys, m.width), ) } if m.width == 0 { diff --git a/cmd/agentop/tui/events_cell_styles_test.go b/cmd/agentop/tui/events_cell_styles_test.go index 8dfa42de0..953ddbb1e 100644 --- a/cmd/agentop/tui/events_cell_styles_test.go +++ b/cmd/agentop/tui/events_cell_styles_test.go @@ -47,6 +47,23 @@ func assertInk(t *testing.T, view, text string, c lipgloss.AdaptiveColor, name s } } +// assertLastInk checks the last SGR before the first text in s. Unlike assertInk it allows +// text between them, for cells of one ink that the table draws as one run. +func assertLastInk(t *testing.T, s, text string, c lipgloss.AdaptiveColor, name string) { + t.Helper() + i := strings.Index(s, text) + if i < 0 { + t.Fatalf("%q is not in %q", text, ansi.Strip(s)) + } + j := strings.LastIndex(s[:i], "\x1b[") + if j < 0 { + t.Fatalf("no SGR before %q", text) + } + if sgr := s[j:i]; !strings.Contains(sgr, fgSGR(c)) { + t.Errorf("%q: last SGR %q has no %s ink (%s)", text, sgr, name, fgSGR(c)) + } +} + // cellStylesEvents is a modify exchange answered 200, an exchange answered 503 and an // unbridged CONNECT, so the ACTION and STATUS cells hold one value of each group. func cellStylesEvents() []pipeline.SessionEvent { @@ -97,9 +114,10 @@ func TestEventsCellStyles_ToolRows(t *testing.T) { t.Fatalf("DURATION = %q, want a running tool's ⋯ cell", dur) } view := m.eventsTbl.View() - assertInk(t, view, "┗⚒", colorTool, "tool") - assertInk(t, view, "Grep", colorTool, "tool") - assertInk(t, view, dur, colorTool, "tool") + assertLastInk(t, view, "┗", colorDim, "dim") + assertLastInk(t, view, "⚒", colorDim, "dim") + assertLastInk(t, view, "Grep", colorMuted, "muted") + assertLastInk(t, view, dur, colorWarn, "warn") assertInk(t, view, "running", colorWarn, "warn") } @@ -142,8 +160,8 @@ func TestEventsCellStyles_ToolRowsWithIndexHidden(t *testing.T) { if strings.Contains(ansi.Strip(view), "⚒") { t.Fatalf("# is hidden, but the view shows the tool mark:\n%s", ansi.Strip(view)) } - assertInk(t, view, "Grep", colorTool, "tool") - assertInk(t, view, dur, colorTool, "tool") + assertLastInk(t, view, "Grep", colorMuted, "muted") + assertLastInk(t, view, dur, colorWarn, "warn") } // A block header is accent when # is the only column: one visible column makes every row one @@ -157,3 +175,103 @@ func TestEventsCellStyles_BlockRowAccentOneColumn(t *testing.T) { // The # column is narrow, so the header's label is cut to "─ …". assertInk(t, view, "─ …", colorAccent, "accent") } + +// toolRowFg is the foreground the events hook gives each cell of row r, keyed by column id. +func toolRowFg(m *model, r int) map[eventColumnID]lipgloss.TerminalColor { + cols, _ := layoutColumns(m.eventColumns, m.eventColWidths, m.width) + kinds := make([]eventRowKind, len(m.visibleRows)) + for i, vr := range m.visibleRows { + if vr.tool != nil { + kinds[i] = eventRowTool + } + } + hook := eventCellStyle(cols, kinds) + row := m.eventsTbl.Rows()[r] + fg := map[eventColumnID]lipgloss.TerminalColor{} + for i, c := range cols { + if i < len(row) && strings.TrimSpace(row[i]) != "" { + fg[c.id] = hook(r, row, i).GetForeground() + } + } + return fg +} + +// drawnLine is the drawn line of view whose plain text contains text. +func drawnLine(t *testing.T, view, text string) string { + t.Helper() + for _, l := range strings.Split(view, "\n") { + if strings.Contains(ansi.Strip(l), text) { + return l + } + } + t.Fatalf("no line with %q in:\n%s", text, ansi.Strip(view)) + return "" +} + +// A tool row steps back (#2019 change 3): every cell is muted, only live state (running, ⋯) +// keeps the warn ink and a failed tool the error ink, and its ┗⚒/┣⚒ mark and a subagent │ +// are dim. The same holds in search results and inside an open subagent block. +func TestEventCellStyle_ToolRowsMuted(t *testing.T) { + withProfile(t, termenv.TrueColor) + okTool := trTool(2, "ok", "Grep", 12, 13, "x") + running := trTool(2, "run", "Bash", 12, -1, "") + failed := trTool(2, "err", "Edit", 12, 13, "") + failed.Error = true + lost := trTool(2, "lost", "Read", 12, 14, "") + lost.Lost = true + m := toolRowsModel(t, trExchange(1, 10, ""), &timeline.Timeline{Tools: []timeline.Tool{okTool, running, failed, lost}}) + want := map[string]map[eventColumnID]lipgloss.AdaptiveColor{ + "ok": {colStatus: colorMuted}, + "run": {colStatus: colorWarn, colDuration: colorWarn}, + "err": {colStatus: colorError}, + "lost": {colStatus: colorError}, + } + for id, special := range want { + r, row := toolRowAt(t, m, id) + for col, fg := range toolRowFg(m, r) { + c, ok := special[col] + if !ok { + c = colorMuted + } + if strings.TrimSpace(row[colPos(m, col)]) == "—" { + c = colorDim + } + if fg != c { + t.Errorf("%s: column %v = %v, want %v", id, col, fg, c) + } + } + } + view := m.eventsTbl.View() + assertLastInk(t, view, "┣", colorDim, "dim") + assertLastInk(t, view, "┗", colorDim, "dim") + assertLastInk(t, view, "⚒", colorDim, "dim") + assertLastInk(t, drawnLine(t, view, "Grep"), "ok", colorMuted, "muted") + + m.search = map[paneID]string{paneEvents: "Grep"} + m.rebuildEventsTable() + view = m.eventsTbl.View() + assertLastInk(t, drawnLine(t, view, "Grep"), "┣", colorDim, "dim") + assertLastInk(t, drawnLine(t, view, "Grep"), "ok", colorMuted, "muted") + if fg := toolRowFg(m, slices.IndexFunc(m.visibleRows, func(r eventRow) bool { return r.tool != nil && r.tool.ID == "ok" })); fg[colStatus] != colorMuted { + t.Errorf("search: STATUS ok = %v, want muted", fg[colStatus]) + } +} + +func TestEventCellStyle_ToolRowsMutedInSubagentBlock(t *testing.T) { + withProfile(t, termenv.TrueColor) + events := slices.Concat(trExchange(1, 10, ""), trExchange(2, 20, "a1"), trExchange(3, 30, "")) + tl := &timeline.Timeline{Tools: []timeline.Tool{trTool(4, "sub", "Read", 22, 23, "x")}} + tl.Tools[0].Agent = "a1" + m := toolRowsModel(t, events, tl) + m.subagentOpen = map[string]bool{"a1": true} + m.rebuildEventsTable() + r, _ := toolRowAt(t, m, "sub") + for col, fg := range toolRowFg(m, r) { + if fg != colorMuted && fg != colorDim { + t.Errorf("column %v = %v, want muted", col, fg) + } + } + line := drawnLine(t, m.eventsTbl.View(), "Read") + assertLastInk(t, line, "│", colorDim, "dim") + assertLastInk(t, line, "Read", colorMuted, "muted") +} diff --git a/cmd/agentop/tui/events_columns.go b/cmd/agentop/tui/events_columns.go index 326a64580..cb1b9b037 100644 --- a/cmd/agentop/tui/events_columns.go +++ b/cmd/agentop/tui/events_columns.go @@ -531,18 +531,19 @@ func eventCellStyle(cols []eventColumn, kinds []eventRowKind) table.CellStyleFun if col >= len(ids) || v == "" { return styleNone } + // A tool row steps back: all muted, except live state (running, ⋯) and a failed tool. if kind == eventRowTool { switch ids[col] { - case colIndex, colMethod: - return styleTool case colDuration: if strings.HasPrefix(v, "⋯") { - return styleTool + return styleWarn } case colStatus: - return groupStyle(statusGroup(v)) + if g := statusGroup(v); g == groupWarn || g == groupError { + return groupStyle(g) + } } - return styleNone + return styleMuted } switch ids[col] { case colIndex, colTime, colHost, colBytes: diff --git a/cmd/agentop/tui/footer.go b/cmd/agentop/tui/footer.go index 0f20dd7a1..7b8ea5c72 100644 --- a/cmd/agentop/tui/footer.go +++ b/cmd/agentop/tui/footer.go @@ -37,7 +37,7 @@ func (m *model) footerView() string { // reading right now. if m.flash != "" && m.flashSticky { return styleTitle.Render(fitFlashLine(m.flash, m.width)) + "\n" + - renderHints(fitHintLine(m.helpView(), m.width)) + renderKeyBar(fitHintLine(m.helpView(), m.width), m.width) } // Connection state dot. @@ -133,7 +133,7 @@ func (m *model) footerView() string { hint := fitHintLine(m.helpView(), m.width) - return fitStatusLine(status.String(), m.width) + "\n" + renderHints(hint) + return fitStatusLine(status.String(), m.width) + "\n" + renderKeyBar(hint, m.width) } // fitStatusLine bounds the status row to the terminal. diff --git a/cmd/agentop/tui/key_bar_test.go b/cmd/agentop/tui/key_bar_test.go new file mode 100644 index 000000000..a8cb1ca05 --- /dev/null +++ b/cmd/agentop/tui/key_bar_test.go @@ -0,0 +1,199 @@ +package tui + +import ( + "context" + "strings" + "testing" + + "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/x/ansi" + "github.com/muesli/termenv" +) + +// runeSGR returns, for each printed rune of s, the SGR parameters in force when it is drawn. +func runeSGR(s string) []string { + var out []string + cur := "" + for i := 0; i < len(s); { + if strings.HasPrefix(s[i:], "\x1b[") { + end := strings.IndexByte(s[i:], 'm') + params := s[i+2 : i+end] + if params == "0" || params == "" { + cur = "" + } else { + cur += ";" + params + ";" + } + i += end + 1 + continue + } + _, size := firstRune(s[i:]) + out = append(out, cur) + i += size + } + return out +} + +func firstRune(s string) (rune, int) { + for _, r := range s { + return r, len(string(r)) + } + return 0, 0 +} + +// sgrOf is the SGR parameters TrueColor emits for c in the current theme. +func sgrOf(c lipgloss.AdaptiveColor, bg bool) string { + hex := c.Light + if lipgloss.HasDarkBackground() { + hex = c.Dark + } + return ";" + termenv.TrueColor.Color(hex).Sequence(bg) + ";" +} + +// checkBar asserts out is the key bar for the plain hint fitted at width w. +func checkBar(t *testing.T, out, fitted string, w int) { + t.Helper() + if got := lipgloss.Width(out); got != w { + t.Fatalf("bar width %d, want %d", got, w) + } + want := chipText(fitted) + if got := strings.TrimRight(ansi.Strip(out), " "); got != strings.TrimRight(want, " ") { + t.Fatalf("bar text %q, want %q", got, want) + } + // Mark the runes of each chip in the plain text. + var chip []bool + for _, p := range splitHintChips(fitted) { + n := len([]rune(p.text)) + if p.chip { + n += 2 + } + for range n { + chip = append(chip, p.chip) + } + } + bar, chipBg, chipFg := sgrOf(colorBarBg, true), sgrOf(colorBarChipBg, true), sgrOf(colorBarChipFg, false) + for i, sgr := range runeSGR(out) { + if i < len(chip) && chip[i] { + if !strings.Contains(sgr, chipBg) || !strings.Contains(sgr, chipFg) { + t.Fatalf("chip rune %d drawn with %q, want %q and %q", i, sgr, chipBg, chipFg) + } + } else if !strings.Contains(sgr, bar) { + t.Fatalf("rune %d drawn with %q, want bar background %q", i, sgr, bar) + } + } +} + +func eachTheme(t *testing.T, f func(t *testing.T)) { + orig := lipgloss.HasDarkBackground() + t.Cleanup(func() { lipgloss.SetHasDarkBackground(orig) }) + for _, dark := range []bool{true, false} { + lipgloss.SetHasDarkBackground(dark) + t.Run(map[bool]string{true: "dark", false: "light"}[dark], f) + } +} + +func TestRenderKeyBar_FullWidthUnderColor(t *testing.T) { + withProfile(t, termenv.TrueColor) + h := "[↵] drill [u] usage [/] search [?] keys [q] quit" + eachTheme(t, func(t *testing.T) { + fitted := fitHintLine(h, 100) + checkBar(t, renderKeyBar(fitted, 100), fitted, 100) + // The trailing form: a head with brackets that are not keys. + line := "error: [::1] " + h + checkBarHead(t, renderTrailingKeyBar(line, h, 100), "error: [::1] ", h, 100) + }) +} + +// checkBarHead is checkBar for a trailing bar whose head keeps its brackets. +func checkBarHead(t *testing.T, out, head, keys string, w int) { + t.Helper() + if got := lipgloss.Width(out); got != w { + t.Fatalf("bar width %d, want %d", got, w) + } + if got, want := strings.TrimRight(ansi.Strip(out), " "), head+chipText(keys); got != want { + t.Fatalf("bar text %q, want %q", got, want) + } + bar := sgrOf(colorBarBg, true) + for i, sgr := range runeSGR(out)[:len([]rune(head))] { + if !strings.Contains(sgr, bar) { + t.Fatalf("head rune %d drawn with %q, want bar background", i, sgr) + } + } +} + +// Review Focus 4: a cut that starts with "… " and ends in half a bracket still fills the +// width with the bar, and the half bracket is not a chip. +func TestRenderKeyBar_CutHintFillsWidth(t *testing.T) { + withProfile(t, termenv.TrueColor) + h := "[↵] drill [u] usage [/] search [?] keys [q] quit" + eachTheme(t, func(t *testing.T) { + for _, w := range []int{30, 20, 6} { + fitted := fitHintLine(h, w) + if w == 30 && !strings.HasPrefix(fitted, "… ") { + t.Fatalf("fit at %d = %q, want a … cut", w, fitted) + } + checkBar(t, renderKeyBar(fitted, w), fitted, w) + } + half := "… [esc] back [es" + checkBar(t, renderKeyBar(half, 40), half, 40) + if s := ansi.Strip(renderKeyBar(half, 40)); !strings.Contains(s, "[es") { + t.Fatalf("half bracket became a chip: %q", s) + } + }) +} + +func TestRenderKeyBar_AsciiUnchanged(t *testing.T) { + withProfile(t, termenv.Ascii) + eachTheme(t, func(t *testing.T) { + for _, in := range []string{"[↵] open [/] search", "… [es"} { + if got, want := renderKeyBar(in, 100), renderHints(in); got != want { + t.Fatalf("renderKeyBar(%q) = %q, want %q", in, got, want) + } + if got, want := renderTrailingKeyBar("x "+in, in, 100), renderTrailingHints("x "+in, in); got != want { + t.Fatalf("renderTrailingKeyBar = %q, want %q", got, want) + } + } + }) +} + +func TestRenderKeyBar_NoPadWithoutWidth(t *testing.T) { + withProfile(t, termenv.TrueColor) + in := "[q] quit" + if got := lipgloss.Width(renderKeyBar(in, 0)); got != lipgloss.Width(in) { + t.Fatalf("width %d with no terminal width, want %d", got, lipgloss.Width(in)) + } +} + +// The last line of every screen that draws the key bar fills the terminal width; the status +// line above it is unchanged. +func TestKeyBar_LastLineOfEachScreen(t *testing.T) { + withProfile(t, termenv.TrueColor) + lastLine := func(s string) string { l := strings.Split(s, "\n"); return l[len(l)-1] } + bar := sgrOf(colorBarBg, true) + isBar := func(line string, w int) bool { + sgr := runeSGR(line) + return lipgloss.Width(line) == w && strings.Contains(sgr[0], ";48;") && strings.Contains(sgr[len(sgr)-1], bar) + } + + m := fitModel(t, paneSessions, 120, 30, nil) + m.layout() + if got := lastLine(m.footerView()); !isBar(got, 120) { + t.Fatalf("session footer bar %q: width %d, want 120 with the bar color", got, lipgloss.Width(got)) + } + m.flash, m.flashSticky = "yanked → /tmp/x", true + if got := lastLine(m.footerView()); !isBar(got, 120) { + t.Fatalf("sticky-flash footer bar: width %d, want 120", lipgloss.Width(got)) + } + + lister := &fakeLister{namespaces: fixtureNamespaces} + pm := newPickerModel(context.Background(), lister, nil) + updated, _ := pm.Update(pm.Init()()) + mm := updated.(*model) + mm.width, mm.height = 120, 30 + if got := lastLine(mm.View()); !isBar(got, 120) { + t.Fatalf("namespaces footer bar: width %d, want 120", lipgloss.Width(got)) + } + mm.pane = panePods + if got := lastLine(mm.View()); !isBar(got, 120) { + t.Fatalf("pods footer bar: width %d, want 120", lipgloss.Width(got)) + } +} diff --git a/cmd/agentop/tui/sessions_context.go b/cmd/agentop/tui/sessions_context.go index 3acdbe271..1d21e985f 100644 --- a/cmd/agentop/tui/sessions_context.go +++ b/cmd/agentop/tui/sessions_context.go @@ -122,36 +122,27 @@ func (m *model) rebaseSessionContext(id string, events []pipeline.SessionEvent) // contextGauge draws prompt tokens against contextWindowTokens, in exactly width columns. // -// A BRACKETED TRACK, because the brackets are what make the scale visible on every row. The -// three designs considered were this, a dotted remainder ("███▎····") and a single eighth-block -// cell; the brackets earn their two columns twice over. A session at 0.8% draws "▕▏ ▏", -// which reads as nearly-empty-out-of-something, where a bare "▏" floating in whitespace reads as -// a rendering fault — and the em dash for an unknown context stays unmistakably different from -// both, which it cannot be when an almost-empty bar is itself almost nothing. -// -// No ░ for the remainder. usage_glyphs.go rejected shaded blocks after measuring them: "█ -// against ▓ is nearly indistinguishable at a glance in most terminal fonts", and a track a -// reader cannot separate from the fill is worse than no track. +// A SHADED TRACK, which the author chose in #2019: the fill, then ░ for the rest of the window, +// so the scale shows on every row without the bracket pair the gauge drew before. A partial cell +// is followed directly by the track, and the small gap inside that cell is accepted. There is no +// "nearly full" color: the fill length is the whole signal. // // Fill arithmetic is tierBar's, reused rather than restated, which brings its rule with it: a // non-zero value never renders as an empty bar. That rule is the whole reason a 8,200-token -// context still shows a sliver. +// context still shows a sliver, and the em dash for an unknown context stays different from it. // // Exactly width columns, so every row's gauge starts and ends in the same place and the fills can // be compared down the column by eye. That is also what makes the column's alignment moot — see // sessionsRightAligned, which lists it for the em dash's sake. func contextGauge(promptTokens, width int) string { - // Three is brackets plus one cell of track. Below that there is nothing to draw, and a - // bracket pair alone would claim a scale it cannot show. - if width < 3 { + if width < 1 { return "" } if promptTokens <= 0 { return emptyCell } - budget := width - 2 - bar := tierBar(int64(promptTokens), contextWindowTokens, budget) - return "▕" + bar + strings.Repeat(" ", budget-lipgloss.Width(bar)) + "▏" + bar := tierBar(int64(promptTokens), contextWindowTokens, width) + return bar + strings.Repeat("░", width-lipgloss.Width(bar)) } // cachedMarker names a row whose events agentop holds and the server no longer lists (#870). diff --git a/cmd/agentop/tui/sessions_context_test.go b/cmd/agentop/tui/sessions_context_test.go index 7b20defb1..6cf555b75 100644 --- a/cmd/agentop/tui/sessions_context_test.go +++ b/cmd/agentop/tui/sessions_context_test.go @@ -7,7 +7,10 @@ import ( "time" "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/x/ansi" + "github.com/muesli/termenv" + "github.com/rossoctl/cortex/cmd/agentop/tui/table" "github.com/rossoctl/cortex/core/pipeline" "github.com/rossoctl/cortex/core/session" ) @@ -93,39 +96,32 @@ func subagent(id string, at time.Time, msgs, context int) []pipeline.SessionEven return roled(conversation(id, at, msgs, context), pipeline.AgentRoleSubagent) } -func TestContextGauge(t *testing.T) { +// The gauge is a shaded track (#2019): the fill, then ░ for the rest of the window. A partial +// cell leaves a gap before the track, which the author accepted. +func TestContextGauge_ShadedTrack(t *testing.T) { for _, tc := range []struct { name string tokens int width int want string }{ - // The track is always drawn, so a scale is visible on every row. - {"half full", 500_000, 10, "▕████ ▏"}, - {"nearly full", 991_200, 10, "▕███████▉▏"}, - {"full", 1_000_000, 10, "▕████████▏"}, - // A NON-ZERO CONTEXT NEVER RENDERS AS AN EMPTY TRACK. tierBar's rule, inherited: 8,200 - // of a million is 0.8%, which rounds to no block at all, so it gets the sliver instead. - // An empty track beside a live session reads as a rendering fault. - {"a sliver rather than nothing", 8_200, 10, "▕▏ ▏"}, - // Unknown is the em dash COST and SAVED use, and it must not be confusable with the - // sliver above — which is the whole reason the brackets are drawn. - {"unknown", 0, 10, emptyCell}, + {"half full", 500_000, 7, "███▌░░░"}, + // A NON-ZERO CONTEXT NEVER RENDERS AS AN EMPTY TRACK: tierBar's sliver rule. + {"a sliver rather than nothing", 8_200, 7, "▏░░░░░░"}, + {"full", 1_000_000, 7, "███████"}, // Over the window: capped rather than overflowing its column. - {"past the window", 1_400_000, 10, "▕████████▏"}, - // Narrow terminals shrink the track with the column. - {"the narrowest useful gauge", 500_000, 3, "▕▌▏"}, - // Below that there is nothing to draw; a bracket pair alone would claim a scale it - // cannot show. - {"too narrow to say anything", 500_000, 2, ""}, + {"past the window", 2_000_000, 7, "███████"}, + // Unknown is the em dash COST and SAVED use, never an empty track. + {"unknown", 0, 7, emptyCell}, + {"one cell", 500_000, 1, "▌"}, + {"no width", 5, 0, ""}, } { t.Run(tc.name, func(t *testing.T) { got := contextGauge(tc.tokens, tc.width) if got != tc.want { t.Errorf("contextGauge(%d, %d) = %q, want %q", tc.tokens, tc.width, got, tc.want) } - // Exactly the column's width, so every row's gauge starts and ends in the same - // place and the fills can be compared down the column by eye. + // Exactly the column's width, so the fills can be compared down the column by eye. if tc.want != "" && tc.want != emptyCell { if w := lipgloss.Width(got); w != tc.width { t.Errorf("gauge is %d columns, want %d: %q", w, tc.width, got) @@ -135,6 +131,48 @@ func TestContextGauge(t *testing.T) { } } +// Under color the CTX cell draws its fill in the accent ink and its ░ track dim, and the plain +// text is the plain gauge. +func TestSessionsGauge_TrueColorInk(t *testing.T) { + withProfile(t, termenv.TrueColor) + gauge := contextGauge(500_000, 7) + cols := []table.Column{{Title: "SESSION", Width: 8}, {Title: contextColumnTitle, Width: 7}} + rows := []table.Row{{"aaaaaaaa", gauge}, {"bbbbbbbb", gauge}, {"cccccccc", gauge}} + tbl := table.New(table.WithColumns(cols), table.WithRows(rows), table.WithHeight(4), + table.WithCellStyle(sessionsCellStyle(cols))) + tbl.SetStyles(tableStyles()) + tbl.SetCursor(0) + + lines, first := tableLines(t, tbl, "aaaaaaaa") + line := lines[first+2] // not the cursor row + if got := ansi.Strip(line); !strings.Contains(got, "cccccccc") || !strings.Contains(got, gauge) { + t.Fatalf("plain row is %q, want it to hold %q", got, gauge) + } + if p := sgrAt(line, "█"); !strings.Contains(p, fgOf(styleAccent)) { + t.Errorf("the fill has SGR %q, want the accent ink %q", p, fgOf(styleAccent)) + } + if p := sgrAt(line, "▌"); !strings.Contains(p, fgOf(styleAccent)) { + t.Errorf("the partial cell has SGR %q, want the accent ink %q", p, fgOf(styleAccent)) + } + // Every ░, not only the first, sits under the dim ink. + n := 0 + for at := 0; ; { + i := strings.Index(line[at:], "░") + if i < 0 { + break + } + at += i + if p := sgrAt(line[:at]+"\x00", "\x00"); !strings.Contains(p, fgOf(styleDim)) { + t.Errorf("track cell %d has SGR %q, want the dim ink %q", n, p, fgOf(styleDim)) + } + n++ + at += len("░") + } + if n != 3 { + t.Fatalf("the row draws %d ░, want 3", n) + } +} + // THE COLUMN REPLACED ACTIVE, and the row arity follows the header — which is the invariant // rebuildSessionsTable's own comment calls a crash rather than a cosmetic bug. func TestSessionsTable_ContextColumnReplacesActive(t *testing.T) { @@ -169,7 +207,7 @@ func TestSessionsTable_ContextColumnReplacesActive(t *testing.T) { } // 500k of 1M: a gauge half full, drawn to the fitted width. cell := row[len(row)-1] - if !strings.Contains(cell, "▕") || !strings.Contains(cell, "█") { + if !strings.Contains(cell, "░") || !strings.Contains(cell, "█") { t.Errorf("last cell is not a gauge: %q", cell) } if got, want := lipgloss.Width(cell), cols[len(cols)-1].Width; got != want { diff --git a/cmd/agentop/tui/sessions_context_wire_test.go b/cmd/agentop/tui/sessions_context_wire_test.go index 5eee7c249..3f5488652 100644 --- a/cmd/agentop/tui/sessions_context_wire_test.go +++ b/cmd/agentop/tui/sessions_context_wire_test.go @@ -451,7 +451,7 @@ func heldContextCell(t *testing.T, m *model, id string) string { return "" } -// assertGaugeFilled fails unless the cell is a bracketed track with something drawn IN it. +// assertGaugeFilled fails unless the cell is a gauge with a fill drawn in it. // // `!= emptyCell` is too weak, which a review caught: an EMPTY track is not the em dash, so it // would pass, and this package calls it a fault in its own right — "an empty track beside a live @@ -459,22 +459,17 @@ func heldContextCell(t *testing.T, m *model, id string) string { // a non-zero figure never drawing as an empty bar. // // NOT the sibling assertion's strings.Contains(cell, "█") though, which holds only for a large -// figure. Measured at this column's width: 500,000 of 1M draws "▕████▌ ▏", but 62,000 draws -// "▕▌ ▏" and 8,200 draws "▕▏ ▏" — no full block in either. Requiring one would fail -// the small figures the tests below deliberately use. Ink between the brackets is the property -// that holds for every non-zero figure. -// -// Sliced by byte offset rather than strings.Trim, and that is not pedantry: the one-eighth fill ▏ -// is THE SAME RUNE as the closing bracket, so Trim(cell, "▕▏") eats an 8,200-token sliver whole -// and then reports the empty track it was written to catch. +// figure. 62,000 of 1M draws a half-block sliver and 8,200 draws "▏" — no full block in either. +// Requiring one would fail the small figures the tests below deliberately use. A cell made only of +// the ░ track and fill runes, with at least one fill rune, is the property that holds for every +// non-zero figure. func assertGaugeFilled(t *testing.T, cell, when string) { t.Helper() - const openBracket, closeBracket = "▕", "▏" - if !strings.HasPrefix(cell, openBracket) || !strings.HasSuffix(cell, closeBracket) { + if cell == "" || strings.Trim(cell, "░█▉▊▋▌▍▎▏") != "" { t.Errorf("%s the row holds %q, which is not a gauge at all", when, cell) return } - if strings.TrimSpace(cell[len(openBracket):len(cell)-len(closeBracket)]) == "" { + if strings.Trim(cell, "░") == "" { t.Errorf("%s the row holds an EMPTY track %q — the figure reached contextRun and not "+ "the cell", when, cell) } @@ -484,10 +479,10 @@ func assertGaugeFilled(t *testing.T, cell, when string) { // table built the row against — a different question from assertGaugeFilled's, and the one the // tests below actually mean. // -// INK BETWEEN THE BRACKETS WAS NOT ENOUGH, measured rather than argued — and the measurement is the +// A FILL IN THE TRACK WAS NOT ENOUGH, measured rather than argued — and the measurement is the // DOUBLED figure. Drawing contextGauge(m.sessionContextFor(...)*2, contextW) in rebuildSessionsTable // left the whole tui suite green before this helper existed, and fails all five row tests below with -// it: a gauge at twice the figure still has ink between its brackets, so "the row repainted" was +// it: a gauge at twice the figure still has a fill in its track, so "the row repainted" was // pinned as "something was drawn". The figure and the cell have to be pinned TOGETHER. // // AND NOT THE CONSTANT GAUGE, which is the mutation the review that found this named first and which diff --git a/cmd/agentop/tui/spend_band.go b/cmd/agentop/tui/spend_band.go index 94091293e..7c90e05c6 100644 --- a/cmd/agentop/tui/spend_band.go +++ b/cmd/agentop/tui/spend_band.go @@ -358,9 +358,10 @@ func joinBandCells(cells []bandCell, ink *bandInk) string { return line.String() } -// styleBandValue dresses one band figure without changing its text: each amount bold, an amount -// in a unit that is not dollars warn, the "~" and "+" markers, the " + " between units and an em -// dash dim. "(mixed)" keeps the default ink: it is not an amount. +// styleBandValue dresses one band figure without changing its text: each amount bold in every +// unit, the word of a unit that is not dollars muted, the "~" and "+" markers, the " + " between +// units and an em dash dim. "(mixed)" keeps the default ink: it is not an amount. No unit is warn +// (#2019): a unit is not a problem. func styleBandValue(v string) string { switch v { case emptyCell: @@ -376,12 +377,10 @@ func styleBandValue(v string) string { } // styleBandAmount is one unit's amount with its markers: a leading "~" and a trailing "+" dim, -// the rest (with any "!") bold for dollars and warn for another unit. +// the amount (with any "!") bold, and for a unit that is not dollars, the trailing " " word +// (" Bobcoins") muted. func styleBandAmount(p string) string { ink := styleBold - if !strings.Contains(p, "$") { - ink = styleWarn - } var b strings.Builder for len(p) > 0 && (p[0] == '~' || p[0] == '!') { if p[0] == '~' { @@ -395,7 +394,11 @@ func styleBandAmount(p string) string { if body, ok := strings.CutSuffix(p, partialMarker); ok { p, tail = body, styleDim.Render(partialMarker) } - return b.String() + ink.Render(p) + tail + unit := "" + if i := strings.LastIndexByte(p, ' '); i >= 0 && !strings.Contains(p, "$") { + p, unit = p[:i], styleMuted.Render(p[i:]) + } + return b.String() + ink.Render(p) + unit + tail } // bandWidth is what these cells render at on one line, skipping the dropped ones. diff --git a/cmd/agentop/tui/spend_band_test.go b/cmd/agentop/tui/spend_band_test.go index 2ed132e69..bd61c7a61 100644 --- a/cmd/agentop/tui/spend_band_test.go +++ b/cmd/agentop/tui/spend_band_test.go @@ -1177,7 +1177,7 @@ func TestSpendBandNeedsScopeMarker_EveryPaneIsClassified(t *testing.T) { } } -// THE STYLED BAND IS THE PLAIN BAND IN COLOR (#2015): amounts bold, a foreign unit warn, +// THE STYLED BAND IS THE PLAIN BAND IN COLOR (#2015): amounts bold, a foreign unit word muted, // markers, em dashes and separators dim, labels muted, and not one column moved. func TestSpendBand_StyledTextAndWidth(t *testing.T) { withProfile(t, termenv.TrueColor) @@ -1204,7 +1204,8 @@ func TestSpendBand_StyledTextAndWidth(t *testing.T) { styled, _ := renderSpendBandStyled(s, 140, true) for _, want := range []struct{ name, part, plain string }{ {"amount bold", styleBold.Render("$703.18"), "$703.18"}, - {"Bobcoins amount warn", styleWarn.Render("7.80 Bobcoins"), "7.80 Bobcoins"}, + {"Bobcoins amount bold", styleBold.Render("7.80"), "7.80 Bobcoins"}, + {"Bobcoins unit muted", styleMuted.Render(" Bobcoins"), "7.80 Bobcoins"}, {"inexact marker dim", styleDim.Render("~"), "~$4.04"}, {"partial marker dim", styleDim.Render("+"), "$4.04+"}, {"em dash dim", styleDim.Render("—"), "—"}, @@ -1220,3 +1221,77 @@ func TestSpendBand_StyledTextAndWidth(t *testing.T) { } } } + +// warnFg is the escape sequence that sets the colorWarn foreground under the current profile. +func warnFg() string { + r := lipgloss.NewStyle().Foreground(colorWarn).Render("x") + return r[:strings.Index(r, "x")] +} + +// A FOREIGN UNIT IS NOT A WARNING (#2019): its amount is bold like dollars, and the unit word +// steps back. +func TestStyleBandValue_BobcoinsBoldNotWarn(t *testing.T) { + withProfile(t, termenv.TrueColor) + got := styleBandValue("12.40 Bobcoins") + for _, part := range []string{styleBold.Render("12.40"), styleMuted.Render(" Bobcoins")} { + if !strings.Contains(got, part) { + t.Errorf("styleBandValue = %q, want it to contain %q", got, part) + } + } + if strings.Contains(got, warnFg()) { + t.Errorf("styleBandValue = %q carries the warn ink", got) + } + if s := ansi.Strip(got); s != "12.40 Bobcoins" { + t.Errorf("plain text = %q, want 12.40 Bobcoins", s) + } + + got = styleBandValue("~12.40 Bobcoins+") + for _, part := range []string{styleDim.Render("~"), styleBold.Render("12.40"), styleMuted.Render(" Bobcoins"), styleDim.Render("+")} { + if !strings.Contains(got, part) { + t.Errorf("styleBandValue(marked) = %q, want it to contain %q", got, part) + } + } + if s := ansi.Strip(got); s != "~12.40 Bobcoins+" { + t.Errorf("plain text = %q, want ~12.40 Bobcoins+", s) + } +} + +// No money figure anywhere is drawn in the warn ink: the band, the drawer and the Usage cost view. +func TestNoCurrencyUsesWarn(t *testing.T) { + withProfile(t, termenv.TrueColor) + warn := warnFg() + + s := withSpan(bandSummary(), spanToday, func(r *spanReading) { + r.USD, r.Units = 7.8, []string{"Bobcoins"} + }) + band, _ := renderSpendBandStyled(s, 140, true) + + snap := &usage.Snapshot{ + Group: usage.GroupEndpoint, + Currencies: []string{"Bobcoins"}, + SeriesCurrencies: map[string][]string{"api.us-east.bob.ibm.com": {"Bobcoins"}}, + Buckets: []usage.Bucket{{ + Counts: usage.Counts{Requests: 3, PricedRequests: 3, CostMicros: 7_800_000}, + Series: map[string]usage.Counts{"api.us-east.bob.ibm.com": {Requests: 3, PricedRequests: 3, CostMicros: 7_800_000}}, + }}, + } + drawer := styleDrawerLines(renderSpendDrawer(snap, nil, usage.GroupEndpoint, "1h", 140)) + + m := fitModel(t, paneUsage, 120, 40, nil) + m.usage.snap = costChartSnapshot([]string{"Bobcoins"}) + m.usage.metric = metricCost + usageView := m.renderUsage(m.width, m.bodyHeight) + + for name, out := range map[string]string{ + "band": strings.Join(band, "\n"), + "drawer": strings.Join(drawer, "\n"), + "usage": usageView, + } { + if !strings.Contains(ansi.Strip(out), "Bobcoins") { + t.Fatalf("%s holds no Bobcoins figure, so the case asserts nothing:\n%s", name, ansi.Strip(out)) + } + if strings.Contains(out, warn) { + t.Errorf("%s draws something in the warn ink:\n%q", name, out) + } + } +} diff --git a/cmd/agentop/tui/styles.go b/cmd/agentop/tui/styles.go index a2e52baca..f84ae23aa 100644 --- a/cmd/agentop/tui/styles.go +++ b/cmd/agentop/tui/styles.go @@ -43,7 +43,10 @@ var ( colorZebraBg = lipgloss.AdaptiveColor{Light: "#F3F4F6", Dark: "#15151C"} // every second table row colorChipBg = lipgloss.AdaptiveColor{Light: "#E5E7EB", Dark: "#374151"} // key chip ground colorChipFg = lipgloss.AdaptiveColor{Light: "#111827", Dark: "#F3F4F6"} // key chip text - colorTool = lipgloss.AdaptiveColor{Light: "#B45309", Dark: "#F59E0B"} // agent tool rows + + colorBarBg = lipgloss.AdaptiveColor{Light: "#F3F4F6", Dark: "#1F2937"} // the key bar, the last line + colorBarChipBg = lipgloss.AdaptiveColor{Light: "#D1D5DB", Dark: "#4B5563"} // a key chip on the bar + colorBarChipFg = lipgloss.AdaptiveColor{Light: "#111827", Dark: "#F9FAFB"} // its text ) var ( @@ -59,8 +62,10 @@ var ( styleDim = lipgloss.NewStyle().Foreground(colorDim) styleBold = lipgloss.NewStyle().Bold(true) styleChip = lipgloss.NewStyle().Foreground(colorChipFg).Background(colorChipBg) + styleBar = lipgloss.NewStyle().Background(colorBarBg) + styleBarLabel = lipgloss.NewStyle().Foreground(colorMuted).Background(colorBarBg) + styleBarChip = lipgloss.NewStyle().Foreground(colorBarChipFg).Background(colorBarChipBg) styleSeg = lipgloss.NewStyle().Foreground(colorOnSeries).Background(colorAccent).Bold(true) - styleTool = lipgloss.NewStyle().Foreground(colorTool) styleAccent = lipgloss.NewStyle().Foreground(colorAccent) styleAccentBold = lipgloss.NewStyle().Foreground(colorAccent).Bold(true) styleMutedBold = lipgloss.NewStyle().Foreground(colorMuted).Bold(true) @@ -142,12 +147,11 @@ func tableStyles() table.Styles { } // tableGlyphs are the runes drawn in their own ink inside a styled cell: the CTX gauge's -// brackets and the BYTES arrows dim, the agents pane's open marks accent. -// -// shortcut: the gauge's one-eighth block is the same rune as its closing bracket (▏), so a fill -// under one eighth of a cell draws dim; give the gauge its own bracket rune if that matters. +// ░ track and the BYTES arrows dim, a tool row's ┗⚒/┣⚒ mark and the subagent │ dim, the agents +// pane's open marks accent. var tableGlyphs = map[rune]lipgloss.Style{ - '▕': styleDim, '▏': styleDim, '↑': styleDim, '↓': styleDim, + '░': styleDim, '↑': styleDim, '↓': styleDim, + '┗': styleDim, '┣': styleDim, '⚒': styleDim, '│': styleDim, '▸': styleAccent, '▾': styleAccent, } @@ -220,12 +224,16 @@ func renderHints(fitted string) string { if !colorOn() { return styleHint.Render(fitted) } + return chipHints(fitted, styleHint, styleChip) +} + +func chipHints(fitted string, label, chip lipgloss.Style) string { var b strings.Builder for _, p := range splitHintChips(fitted) { if p.chip { - b.WriteString(styleChip.Render(" " + p.text + " ")) + b.WriteString(chip.Render(" " + p.text + " ")) } else { - b.WriteString(styleHint.Render(p.text)) + b.WriteString(label.Render(p.text)) } } return b.String() @@ -237,17 +245,45 @@ func renderTrailingHints(fitted, keys string) string { if !colorOn() { return styleHint.Render(fitted) } + return trailingChipHints(fitted, keys, styleHint, styleChip) +} + +func trailingChipHints(fitted, keys string, label, chip lipgloss.Style) string { if head, ok := strings.CutSuffix(fitted, keys); ok { if head == "" { - return renderHints(keys) + return chipHints(keys, label, chip) } - return styleHint.Render(head) + renderHints(keys) + return label.Render(head) + chipHints(keys, label, chip) } // The fit cut into the keys, so no other text is left. if strings.HasSuffix(keys, strings.TrimPrefix(fitted, "… ")) { + return chipHints(fitted, label, chip) + } + return label.Render(fitted) +} + +// renderKeyBar is renderHints for the last line of the screen: with color, the line is a +// shaded bar padded to width (no pad when width <= 0). Under Ascii it is renderHints. +func renderKeyBar(fitted string, width int) string { + if !colorOn() { return renderHints(fitted) } - return styleHint.Render(fitted) + return padBar(chipHints(fitted, styleBarLabel, styleBarChip), width) +} + +// renderTrailingKeyBar is renderTrailingHints drawn as the key bar (see renderKeyBar). +func renderTrailingKeyBar(fitted, keys string, width int) string { + if !colorOn() { + return renderTrailingHints(fitted, keys) + } + return padBar(trailingChipHints(fitted, keys, styleBarLabel, styleBarChip), width) +} + +func padBar(line string, width int) string { + if pad := width - lipgloss.Width(line); pad > 0 { + line += styleBar.Render(strings.Repeat(" ", pad)) + } + return line } // titleMarkRe finds the parts of a title that are not bold default ink. diff --git a/cmd/agentop/tui/timeline_pane.go b/cmd/agentop/tui/timeline_pane.go index 53aa08267..ca90f7cc6 100644 --- a/cmd/agentop/tui/timeline_pane.go +++ b/cmd/agentop/tui/timeline_pane.go @@ -411,10 +411,9 @@ func (m *model) timelineLayoutNow() (tlLayout, bool) { // legend's lines and the cursor line. Each agent and host row takes two lines, its own and the // blank one that keeps a row's bars off the next row's. const ( - timelineFixedLines = 8 - // timelineLegendLines is how many lines legend draws. The tok/s note has a line of its own, - // so it is not cut at a width where the chart itself still fits. - timelineLegendLines = 2 + timelineFixedLines = 7 + // timelineLegendLines is how many lines legend draws. + timelineLegendLines = 1 ) // tlEmptyLines is what an empty side draws in place of its rows: a note and a blank line. @@ -774,14 +773,26 @@ func (m *model) renderTimeline() string { return b.String() } +// legend is one line that fits m.width: whole items drop from the right, never a wrap. func (m *model) legend() string { - sw := func(c lipgloss.AdaptiveColor, s string) string { - return lipgloss.NewStyle().Foreground(c).Render("█") + styleMuted.Render(" "+s+" ") + sw := func(sep string, c lipgloss.AdaptiveColor, s string) [2]string { + return [2]string{sep + "█ " + s, styleMuted.Render(sep) + lipgloss.NewStyle().Foreground(c).Render("█") + styleMuted.Render(" "+s)} + } + note := func(s string) [2]string { return [2]string{s, styleMuted.Render(s)} } + items := [][2]string{ + sw("", colorTLTool, "tools"), sw(" ", colorTLModel, "model"), sw(" ", colorTLRetry, "retrying"), + sw(" ", colorTLSubs, "waiting on subagents"), sw(" ", colorTLUser, "waiting on you"), + note(" ┆ time cut from the axis"), note(" ▁…█ requests in flight"), + } + var plain, styled strings.Builder + for _, it := range items { + if lipgloss.Width(plain.String()+it[0]) > m.width { + break + } + plain.WriteString(it[0]) + styled.WriteString(it[1]) } - return sw(colorTLTool, "tools") + sw(colorTLModel, "model") + sw(colorTLRetry, "retrying") + - sw(colorTLSubs, "waiting on subagents") + sw(colorTLUser, "waiting on you") + - styleMuted.Render("┆ time cut from the axis, in its colour ▁…█ requests in flight") + "\n" + - styleMuted.Render(" tok/s output per second of model time, last 60 s") + return styled.String() } func (m *model) timelineStatus(lay tlLayout) string { @@ -959,7 +970,7 @@ func (m *model) cursorAt(c int, s string) string { func (m *model) cursorStrip(lay tlLayout) string { c := m.timeline.cursor if c < 0 || c >= lay.axis.width() { - return renderHints("▸ [←→] pick a moment: lists the tools running then, with their durations and commands") + return "" // the row stays, blank, so the chart does not move when a moment is picked } cell := lay.axis.cells[c] head := fmt.Sprintf("▸ %s ", cell.from.Local().Format("15:04:05")) diff --git a/cmd/agentop/tui/timeline_pane_test.go b/cmd/agentop/tui/timeline_pane_test.go index c0b407ae4..5a2f45829 100644 --- a/cmd/agentop/tui/timeline_pane_test.go +++ b/cmd/agentop/tui/timeline_pane_test.go @@ -8,6 +8,7 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/x/ansi" "github.com/muesli/termenv" "github.com/rossoctl/cortex/cmd/agentop/tui/table" @@ -1628,27 +1629,93 @@ func TestTimelineRender_TokPerSecColumn(t *testing.T) { } } -// The tok/s note is the only text that explains the column, so the user must see it. The body -// cuts every line at the pane's width, so the note needs its own legend line to survive at the -// widths people use. -func TestTimelineRender_TokPerSecNoteReachesTheUser(t *testing.T) { - const note = "tok/s output per second of model time, last 60 s" - for _, w := range []int{140, 120} { +const fullTimelineLegend = "█ tools █ model █ retrying █ waiting on subagents █ waiting on you ┆ time cut from the axis ▁…█ requests in flight" + +// The legend is one line, and it no longer explains tok/s or says "in its colour". +func TestTimelineLegend_OneLine(t *testing.T) { + m := timelineModel(t, 200, 46) + plainWidth := lipgloss.Width(m.legend()) + restore := lipgloss.ColorProfile() + t.Cleanup(func() { lipgloss.SetColorProfile(restore) }) + lipgloss.SetColorProfile(termenv.TrueColor) + l := m.legend() + got := ansi.Strip(l) + if !strings.Contains(l, lipgloss.NewStyle().Foreground(colorTLTool).Render("█")) { + t.Errorf("tools swatch lost its color: %q", l) + } + if lipgloss.Width(l) != plainWidth { + t.Errorf("width %d under TrueColor, %d under Ascii", lipgloss.Width(l), plainWidth) + } + if got != fullTimelineLegend { + t.Errorf("legend = %q, want %q", got, fullTimelineLegend) + } + if strings.Contains(got, "\n") || strings.Contains(got, "tok/s") || strings.Contains(got, "in its colour") { + t.Errorf("legend = %q", got) + } +} + +// A legend too wide for the terminal drops whole items from the right and never wraps. +func TestTimelineLegend_DropsFromTheRight(t *testing.T) { + full := lipgloss.Width(fullTimelineLegend) + m := timelineModel(t, full-1, 46) + got := ansi.Strip(m.legend()) + if want := "█ tools █ model █ retrying █ waiting on subagents █ waiting on you ┆ time cut from the axis"; got != want { + t.Errorf("at %d columns legend = %q, want %q", full-1, got, want) + } + m = timelineModel(t, full-30, 46) + if got, want := ansi.Strip(m.legend()), "█ tools █ model █ retrying █ waiting on subagents █ waiting on you"; got != want { + t.Errorf("at %d columns legend = %q, want %q", full-30, got, want) + } + for w := 1; w <= full+2; w++ { m := timelineModel(t, w, 46) - m.timeline.windowIdx = 3 - body := stripANSI(m.timelineBody()) - if !strings.Contains(body, note) { - t.Errorf("at %d columns the body does not explain tok/s:\n%s", w, body) + l := m.legend() + if strings.Contains(l, "\n") || lipgloss.Width(l) > w { + t.Fatalf("at %d columns legend = %q (%d wide)", w, ansi.Strip(l), lipgloss.Width(l)) + } + if !strings.HasPrefix(fullTimelineLegend, ansi.Strip(l)) { + t.Fatalf("at %d columns legend %q is not a cut of the full text from the right", w, ansi.Strip(l)) } - for _, l := range strings.Split(stripANSI(m.legend()), "\n") { - if strings.Contains(l, note) && lipgloss.Width(l) > w { - t.Errorf("at %d columns the note's legend line is %d wide: %q", w, lipgloss.Width(l), l) + } +} + +// With no moment picked the cursor row stays, blank, so ← does not move the chart. +func TestCursorStrip_IdleRowIsBlank(t *testing.T) { + m := timelineModel(t, 140, 46) + m.timeline.windowIdx = 3 + lay, _ := m.timelineLayoutNow() + if s := m.cursorStrip(lay); s != "" { + t.Errorf("idle cursor strip = %q, want blank", ansi.Strip(s)) + } + firstRow := func() int { + for i, l := range strings.Split(stripANSI(m.renderTimeline()), "\n") { + if strings.Contains(l, "main agent") { + return i } } + t.Fatal("no main agent row") + return -1 + } + before := stripANSI(m.renderTimeline()) + at := firstRow() + lines := strings.Split(before, "\n") + if last := lines[len(lines)-1]; strings.TrimSpace(last) != "" { + t.Errorf("idle body ends with %q, want the blank cursor row", last) + } + // Fixed lines (7, one of them the legend) plus two per shown row, and nothing else. + agents := m.timelineAgentRows(lay) + if want := timelineFixedLines + tlEmptyLines(lay) + 2*agents + 2*m.timelineHostRows(lay, agents); len(lines) != want { + t.Errorf("idle body is %d lines, want %d:\n%s", len(lines), want, before) + } + m.handleKey(tea.KeyMsg{Type: tea.KeyLeft}) + if got := firstRow(); got != at { + t.Errorf("← moved the chart from line %d to %d", at, got) + } + if n, k := len(lines), len(strings.Split(stripANSI(m.renderTimeline()), "\n")); n != k { + t.Errorf("← changed the body from %d to %d lines", n, k) } } -// Color changes no text and no width on the timeline; the cursor strip's [←→] is a key chip. +// Color changes no text and no width on the timeline. func TestTimeline_PlainInvariant(t *testing.T) { for _, w := range []int{80, 100, 140} { m := timelineModel(t, w, 46) @@ -1658,7 +1725,7 @@ func TestTimeline_PlainInvariant(t *testing.T) { t.Cleanup(func() { lipgloss.SetColorProfile(restore) }) lipgloss.SetColorProfile(termenv.TrueColor) out := timelineModel(t, 140, 46).renderTimeline() - for _, want := range []string{styleChip.Render(" ←→ "), styleDim.Render("│")} { + for _, want := range []string{styleDim.Render("│")} { if !strings.Contains(out, want) { t.Errorf("timeline lacks %q", want) } diff --git a/docs/assets/cortex-demo.svg b/docs/assets/cortex-demo.svg index d5e7c6015..b19470e97 100644 --- a/docs/assets/cortex-demo.svg +++ b/docs/assets/cortex-demo.svg @@ -379,27 +379,27 @@ clipPath rect{width:100000px} - - - tools model retrying waiting on subagents waiting on you ┆ time cut from the axis, in its colour … re - - tok/s output per second of model time, last 60 s - - -▸ ←→ pick a moment: lists the tools running then, with their durations and commands - -● connected12.4 events/sec feedback: https://github.com/rossoctl/cortex/issues/new/choose - - - - - - - - - w all ←→ moment enter events / search esc back ? keys q quit - - + tools model retrying waiting on subagents waiting on you ┆ time cut from the axis + +● connected12.4 events/sec feedback: https://github.com/rossoctl/cortex/issues/new/choose + + + + + + + + + + + + + + + + w all ←→ moment enter events / search esc back ? keys q quit + + @@ -429,7 +429,7 @@ clipPath rect{width:100000px} main agent │ 1m 5.9s 91 - + @@ -460,7 +460,7 @@ clipPath rect{width:100000px} Audit the auth flow │ 40s 9.3s 78 - + @@ -488,7 +488,7 @@ clipPath rect{width:100000px} Review retry logic │ 31s 10s 69 - + @@ -514,9 +514,9 @@ clipPath rect{width:100000px} Check DB migrations │ 29s 5.0s 63 - + - + @@ -536,18 +536,18 @@ clipPath rect{width:100000px} Scan deps for CVEs │ 25s 1.0s 82 - + - + Review docs and CI │ 6.0s 0.2s 61 - + -╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ +╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ - + @@ -561,47 +561,47 @@ clipPath rect{width:100000px} api.anthropic.com LLM │ 62 req - + - + github.com 🔒 │ 2 req - + - + api.github.com 🔒 │ 1 req - + -──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── - + - - - tools model retrying waiting on subagents waiting on you ┆ time cut from the axis, in its colour … re - - tok/s output per second of model time, last 60 s - - -▸ ←→ pick a moment: lists the tools running then, with their durations and commands - -● connected12.4 events/sec feedback: https://github.com/rossoctl/cortex/issues/new/choose - - - - - - - - - w all ←→ moment enter events / search esc back ? keys q quit - - + tools model retrying waiting on subagents waiting on you ┆ time cut from the axis + +● connected12.4 events/sec feedback: https://github.com/rossoctl/cortex/issues/new/choose + + + + + + + + + + + + + + + + w all ←→ moment enter events / search esc back ? keys q quit + + @@ -628,7 +628,7 @@ clipPath rect{width:100000px} main agent │ 1m 5.9s 91 - + @@ -669,7 +669,7 @@ clipPath rect{width:100000px} Audit the auth flow │ 1m 17s 81 - + @@ -708,7 +708,7 @@ clipPath rect{width:100000px} Review retry logic │ 1m 14s 76 - + @@ -742,7 +742,7 @@ clipPath rect{width:100000px} Check DB migrations │ 43s 31s 64 - + @@ -779,7 +779,7 @@ clipPath rect{width:100000px} Scan deps for CVEs │ 1m 2.3s 81 - + @@ -804,7 +804,7 @@ clipPath rect{width:100000px} Review docs and CI │ 34s 11s 82 - + @@ -826,14 +826,14 @@ clipPath rect{width:100000px} api.anthropic.com LLM │ 116 req - + github.com 🔒 │ 2 req - + api.github.com 🔒 │ 1 req - + @@ -858,7 +858,7 @@ clipPath rect{width:100000px} main agent │ 1m 5.9s 91 - + @@ -910,7 +910,7 @@ clipPath rect{width:100000px} Audit the auth flow │ 1m 25s 63 - + @@ -959,7 +959,7 @@ clipPath rect{width:100000px} Review retry logic │ 1m 23s 67 - + @@ -1000,7 +1000,7 @@ clipPath rect{width:100000px} Check DB migrations │ 1m 42s 61 - + @@ -1045,7 +1045,7 @@ clipPath rect{width:100000px} Scan deps for CVEs │ 1m 3.0s 63 - + @@ -1079,7 +1079,7 @@ clipPath rect{width:100000px} Review docs and CI │ 52s 33s 63 - + @@ -1107,14 +1107,14 @@ clipPath rect{width:100000px} api.anthropic.com LLM │ 154 req - + github.com 🔒 │ 2 req - + api.github.com 🔒 │ 1 req - + @@ -1140,7 +1140,7 @@ clipPath rect{width:100000px} main agent │ 1m 5.9s 91 - + @@ -1194,7 +1194,7 @@ clipPath rect{width:100000px} Audit the auth flow │ 2m 36s 61 - + @@ -1249,7 +1249,7 @@ clipPath rect{width:100000px} Review retry logic │ 2m 24s 74 - + @@ -1293,7 +1293,7 @@ clipPath rect{width:100000px} Check DB migrations │ 1m 48s 56 - + @@ -1332,7 +1332,7 @@ clipPath rect{width:100000px} Scan deps for CVEs │ 2m 3.7s 70 - + @@ -1382,7 +1382,7 @@ clipPath rect{width:100000px} Review docs and CI │ 1m 48s 70 - + @@ -1418,14 +1418,14 @@ clipPath rect{width:100000px} api.anthropic.com LLM │ 204 req - + github.com 🔒 │ 2 req - + api.github.com 🔒 │ 1 req - + @@ -1447,7 +1447,7 @@ clipPath rect{width:100000px} main agent │ 1m 5.9s 91 - + @@ -1509,7 +1509,7 @@ clipPath rect{width:100000px} Audit the auth flow │ 2m 41s 76 - + @@ -1558,7 +1558,7 @@ clipPath rect{width:100000px} Review retry logic │ 2m 25s 85 - + @@ -1604,7 +1604,7 @@ clipPath rect{width:100000px} Check DB migrations │ 2m 56s 60 - + @@ -1648,7 +1648,7 @@ clipPath rect{width:100000px} Scan deps for CVEs │ 3m 4.7s 76 - + @@ -1695,7 +1695,7 @@ clipPath rect{width:100000px} Review docs and CI │ 1m 54s 86 - + @@ -1731,14 +1731,14 @@ clipPath rect{width:100000px} api.anthropic.com LLM │ 253 req - + github.com 🔒 │ 2 req - + api.github.com 🔒 │ 1 req - + @@ -1759,7 +1759,7 @@ clipPath rect{width:100000px} main agent │ 1m 5.9s 91 - + @@ -1823,7 +1823,7 @@ clipPath rect{width:100000px} Audit the auth flow │ 3m 53s 73 - + @@ -1879,7 +1879,7 @@ clipPath rect{width:100000px} Review retry logic │ 3m 28s 87 - + @@ -1925,7 +1925,7 @@ clipPath rect{width:100000px} Check DB migrations │ 2m 1m 74 - + @@ -1970,7 +1970,7 @@ clipPath rect{width:100000px} Scan deps for CVEs │ 3m 5.4s 74 - + @@ -2018,7 +2018,7 @@ clipPath rect{width:100000px} Review docs and CI │ 2m 1m 83 - + @@ -2059,17 +2059,17 @@ clipPath rect{width:100000px} api.anthropic.com LLM │ 291 req - + api.github.com 🔒 │ 15 req - + github.com 🔒 │ 2 req -window 5m [all]09-15 42:24 → 09-15 42:24 +window 5m [all]09-15 42:24 → 09-15 42:24 - + @@ -2092,7 +2092,7 @@ clipPath rect{width:100000px} main agent │ 1m 5.9s 91 - + @@ -2152,7 +2152,7 @@ clipPath rect{width:100000px} Audit the auth flow │ 3m 57s 77 - + @@ -2204,7 +2204,7 @@ clipPath rect{width:100000px} Review retry logic │ 3m 32s 89 - + @@ -2259,7 +2259,7 @@ clipPath rect{width:100000px} Check DB migrations │ 3m 1m 76 - + @@ -2298,7 +2298,7 @@ clipPath rect{width:100000px} Scan deps for CVEs │ 3m 5.4s 83 - + @@ -2349,7 +2349,7 @@ clipPath rect{width:100000px} Review docs and CI │ 2m 1m 81 - + @@ -2393,12 +2393,12 @@ clipPath rect{width:100000px} api.anthropic.com LLM │ 308 req - + api.github.com 🔒 │ 15 req - + @@ -2423,7 +2423,7 @@ clipPath rect{width:100000px} main agent │ 1m 6.1s 94 - + @@ -2476,7 +2476,7 @@ clipPath rect{width:100000px} Audit the auth flow │ 4m 1m 78 - + @@ -2525,7 +2525,7 @@ clipPath rect{width:100000px} Review retry logic │ 4m 33s 94 - + @@ -2580,7 +2580,7 @@ clipPath rect{width:100000px} Check DB migrations │ 3m 1m 81 - + @@ -2610,7 +2610,7 @@ clipPath rect{width:100000px} Scan deps for CVEs │ 3m 5.4s 83 - + @@ -2653,7 +2653,7 @@ clipPath rect{width:100000px} Review docs and CI │ 3m 1m 78 - + @@ -2696,11 +2696,11 @@ clipPath rect{width:100000px} api.anthropic.com LLM │ 345 req - + api.github.com 🔒 │ 15 req - + @@ -2721,7 +2721,7 @@ clipPath rect{width:100000px} main agent │ 1m 6.1s 94 - + @@ -2779,7 +2779,7 @@ clipPath rect{width:100000px} Audit the auth flow │ 4m 1m 75 - + @@ -2832,7 +2832,7 @@ clipPath rect{width:100000px} Review retry logic │ 4m 54s 90 - + @@ -2882,7 +2882,7 @@ clipPath rect{width:100000px} Check DB migrations │ 4m 1m 80 - + @@ -2902,7 +2902,7 @@ clipPath rect{width:100000px} Scan deps for CVEs │ 3m 5.4s 83 - + @@ -2946,7 +2946,7 @@ clipPath rect{width:100000px} Review docs and CI │ 3m 1m 79 - + @@ -2990,15 +2990,15 @@ clipPath rect{width:100000px} api.anthropic.com LLM │ 378 req - + api.github.com 🔒 │ 15 req - + github.com 🔒 │ 2 req - + @@ -3019,7 +3019,7 @@ clipPath rect{width:100000px} main agent │ 1m 6.1s 94 - + @@ -3071,7 +3071,7 @@ clipPath rect{width:100000px} Audit the auth flow │ 5m 1m 73 - + @@ -3117,7 +3117,7 @@ clipPath rect{width:100000px} Review retry logic │ 5m 54s 96 - + @@ -3166,7 +3166,7 @@ clipPath rect{width:100000px} Check DB migrations │ 5m 1m 74 - + @@ -3187,7 +3187,7 @@ clipPath rect{width:100000px} Scan deps for CVEs │ 3m 5.4s 83 - + @@ -3233,7 +3233,7 @@ clipPath rect{width:100000px} Review docs and CI │ 4m 1m 79 - + @@ -3278,11 +3278,11 @@ clipPath rect{width:100000px} api.anthropic.com LLM │ 413 req - + api.github.com 🔒 │ 15 req - + @@ -3301,7 +3301,7 @@ clipPath rect{width:100000px} main agent │ 1m 6.3s 92 - + @@ -3347,7 +3347,7 @@ clipPath rect{width:100000px} Audit the auth flow │ 5m 1m 73 - + @@ -3381,7 +3381,7 @@ clipPath rect{width:100000px} Review retry logic │ 5m 54s 96 - + @@ -3441,7 +3441,7 @@ clipPath rect{width:100000px} Check DB migrations │ 5m 1m 71 - + @@ -3462,7 +3462,7 @@ clipPath rect{width:100000px} Scan deps for CVEs │ 3m 5.4s 83 - + @@ -3501,7 +3501,7 @@ clipPath rect{width:100000px} Review docs and CI │ 5m 1m 73 - + @@ -3551,11 +3551,11 @@ clipPath rect{width:100000px} api.anthropic.com LLM │ 442 req - + api.github.com 🔒 │ 15 req - + @@ -3574,7 +3574,7 @@ clipPath rect{width:100000px} main agent │ 1m 6.3s 92 - + @@ -3627,7 +3627,7 @@ clipPath rect{width:100000px} Audit the auth flow │ 6m 1m 75 - + @@ -3672,7 +3672,7 @@ clipPath rect{width:100000px} Review retry logic │ 5m 54s 96 - + @@ -3724,7 +3724,7 @@ clipPath rect{width:100000px} Check DB migrations │ 6m 1m 69 - + @@ -3742,7 +3742,7 @@ clipPath rect{width:100000px} Scan deps for CVEs │ 3m 5.4s 83 - + @@ -3783,7 +3783,7 @@ clipPath rect{width:100000px} Review docs and CI │ 5m 1m 77 - + @@ -3828,14 +3828,14 @@ clipPath rect{width:100000px} api.anthropic.com LLM │ 463 req - + api.github.com 🔒 │ 15 req - + github.com 🔒 │ 2 req - + @@ -3858,7 +3858,7 @@ clipPath rect{width:100000px} main agent │ 1m 6.6s 88 - + @@ -3906,7 +3906,7 @@ clipPath rect{width:100000px} Audit the auth flow │ 7m 1m 77 - + @@ -3942,7 +3942,7 @@ clipPath rect{width:100000px} Review retry logic │ 5m 54s 96 - + @@ -3981,7 +3981,7 @@ clipPath rect{width:100000px} Check DB migrations │ 6m 1m 75 - + @@ -3992,7 +3992,7 @@ clipPath rect{width:100000px} Scan deps for CVEs │ 3m 5.4s 83 - + @@ -4037,7 +4037,7 @@ clipPath rect{width:100000px} Review docs and CI │ 6m 1m 79 - + @@ -4084,13 +4084,13 @@ clipPath rect{width:100000px} api.anthropic.com LLM │ 483 req - + api.github.com 🔒 │ 15 req -12:24 42:24 42:24 42:24 42:24 +12:24 42:24 42:24 42:24 42:24 - + @@ -4113,7 +4113,7 @@ clipPath rect{width:100000px} main agent │ 1m 6.6s 88 - + @@ -4170,7 +4170,7 @@ clipPath rect{width:100000px} Audit the auth flow │ 7m 1m 79 - + @@ -4203,7 +4203,7 @@ clipPath rect{width:100000px} Review retry logic │ 5m 54s 96 - + @@ -4247,7 +4247,7 @@ clipPath rect{width:100000px} Check DB migrations │ 6m 1m 75 - + @@ -4258,7 +4258,7 @@ clipPath rect{width:100000px} Scan deps for CVEs │ 3m 5.4s 83 - + @@ -4301,7 +4301,7 @@ clipPath rect{width:100000px} Review docs and CI │ 7m 1m 77 - + @@ -4354,11 +4354,11 @@ clipPath rect{width:100000px} api.anthropic.com LLM │ 500 req - + api.github.com 🔒 │ 15 req - + @@ -4381,7 +4381,7 @@ clipPath rect{width:100000px} main agent │ 1m 6.6s 88 - + @@ -4442,7 +4442,7 @@ clipPath rect{width:100000px} Audit the auth flow │ 8m 1m 79 - + @@ -4470,7 +4470,7 @@ clipPath rect{width:100000px} Review retry logic │ 5m 54s 96 - + @@ -4504,7 +4504,7 @@ clipPath rect{width:100000px} Check DB migrations │ 6m 1m 75 - + @@ -4513,7 +4513,7 @@ clipPath rect{width:100000px} Scan deps for CVEs │ 3m 5.4s 83 - + @@ -4551,7 +4551,7 @@ clipPath rect{width:100000px} Review docs and CI │ 7m 1m 76 - + @@ -4603,11 +4603,11 @@ clipPath rect{width:100000px} api.anthropic.com LLM │ 517 req - + api.github.com 🔒 │ 15 req - + @@ -4629,7 +4629,7 @@ clipPath rect{width:100000px} main agent │ 1m 6.6s 88 - + @@ -4684,7 +4684,7 @@ clipPath rect{width:100000px} Audit the auth flow │ 8m 1m 79 - + @@ -4717,7 +4717,7 @@ clipPath rect{width:100000px} Review retry logic │ 5m 54s 96 - + @@ -4749,7 +4749,7 @@ clipPath rect{width:100000px} Check DB migrations │ 6m 1m 75 - + @@ -4760,7 +4760,7 @@ clipPath rect{width:100000px} Scan deps for CVEs │ 3m 5.4s 83 - + @@ -4798,7 +4798,7 @@ clipPath rect{width:100000px} Review docs and CI │ 8m 1m 85 - + @@ -4850,11 +4850,11 @@ clipPath rect{width:100000px} api.anthropic.com LLM │ 529 req - + api.github.com 🔒 │ 15 req - + @@ -4884,7 +4884,7 @@ clipPath rect{width:100000px} main agent │ 2m 7.6s 81 - + @@ -4941,7 +4941,7 @@ clipPath rect{width:100000px} Audit the auth flow │ 8m 1m 79 - + @@ -4966,7 +4966,7 @@ clipPath rect{width:100000px} Review retry logic │ 5m 54s 96 - + @@ -4989,7 +4989,7 @@ clipPath rect{width:100000px} Check DB migrations │ 6m 1m 75 - + @@ -5000,7 +5000,7 @@ clipPath rect{width:100000px} Scan deps for CVEs │ 3m 5.4s 83 - + @@ -5032,7 +5032,7 @@ clipPath rect{width:100000px} Review docs and CI │ 8m 1m 101 - + @@ -5082,228 +5082,254 @@ clipPath rect{width:100000px} api.anthropic.com LLM │ 533 req - + api.github.com 🔒 │ 16 req - + github.com 🔒 │ 2 req -agentop · http://127.0.0.1:9094 +agentop · http://127.0.0.1:9094 -LAST 1H~$15.03 · TODAY~$15.03 · 7 DAYS~$15.03 · THIS MONTH~$15.03 +LAST 1H~$15.03 · TODAY~$15.03 · 7 DAYS~$15.03 · THIS MONTH~$15.03 -SESSION TITLE UPDATED EVENTS TOKENS COST SAVED~CTX(1M) +SESSION TITLE UPDATED EVENTS TOKENS COST SAVED~CTX(1M) -api-7f3c audit the repo before release just now 1109 53.8M $14.46 $0.30▕▍ ▏ +api-7f3c audit the repo before release just now 1109 53.8M $14.46 $0.30▋░░░░░░ - -▌web-2a91add dark mode toggle 12m ago 10 49.3k $0.14 —▕▏▏ + +▌web-2a91add dark mode toggle 12m ago 10 49.3k $0.14 —▏░░░░░░ -infra-55de debug the helm chart 12m ago 2 16.2k $0.02 — ▕▏▏ +infra-55de debug the helm chart 12m ago 2 16.2k $0.02 —▏░░░░░░ - + - + - + - + - + - + - + - + - + - + - + - + - + -● connected12.4 events/sec feedback: https://github.com/rossoctl/cortex/issues/new/choose +● connected12.4 events/sec feedback: https://github.com/rossoctl/cortex/issues/new/choose - - - - - - - - - - ↑↓ nav ↵ drill u usage $ spend / search p pause P plugins ? keys q quit + + + + + + + + + + + + + + + + + + + ↑↓ nav ↵ drill u usage $ spend / search p pause P plugins ? keys q quit -agentop · add dark mode toggle (web-2a91) +agentop · add dark mode toggle (web-2a91) -# TIME DIR ACTION PLUGIN METHOD STATUS DURATIONHOST +# TIME DIR ACTION PLUGIN METHOD STATUS DURATIONHOST -1 42:24:24.24outobserve 2 plugins claude-opus-5 200 2.90s api.anthropic.com +1 42:24:24.24outobserve 2 plugins claude-opus-5 200 2.90s api.anthropic.com - -┗⚒ 42:24:24.24 Read ok 17.10s + +┗⚒42:24:24.24 Read ok 17.10s -2 42:24:24.24outobserve 2 plugins claude-opus-5 200 2.90s api.anthropic.com +2 42:24:24.24outobserve 2 plugins claude-opus-5 200 2.90s api.anthropic.com - -┗⚒ 42:24:24.24 Grep ok 17.10s + +┗⚒42:24:24.24 Grep ok 17.10s -3 42:24:24.24outobserve 2 plugins claude-opus-5 200 2.90s api.anthropic.com +3 42:24:24.24outobserve 2 plugins claude-opus-5 200 2.90s api.anthropic.com - -┗⚒ 42:24:24.24 Edit ok 17.10s + +┗⚒42:24:24.24 Edit ok 17.10s -4 42:24:24.24outobserve 2 plugins claude-opus-5 200 2.90s api.anthropic.com +4 42:24:24.24outobserve 2 plugins claude-opus-5 200 2.90s api.anthropic.com - -▌┗⚒42:24:24.24Bash ok 17.10s + +▌┗⚒42:24:24.24Bash ok 17.10s -5 42:24:24.24outobserve 2 plugins claude-opus-5 200 2.90s api.anthropic.com +5 42:24:24.24outobserve 2 plugins claude-opus-5 200 2.90s api.anthropic.com - - - - - - - -… s hide passthru/skip p pause / search esc back · → 3 more columns ( c to choose) ? keys q quit + + + + + + + + + + + + + + + +… s hide passthru/skip p pause / search esc back · → 3 more columns ( c to choose) ? keys q quit -agentop · add dark mode toggle (web-2a91) · event +agentop · add dark mode toggle (web-2a91) · event - + REQUEST │ #5 · claude-opus-5 · 200 · 2.90s · 11.6k→180 tok · $0.0280 -▾ ━━ REQUEST · 42:24:24.24 · observe inference-parser +▾ ━━ REQUEST · 42:24:24.24 · observe inference-parser -{ +{ -"at": "2026-09-22T42:24:24.242424-42:24", +"at": "2026-09-22T42:24:24.242424-42:24", -▾ "client": { +▾ "client": { -"name": "claude-code", +"name": "claude-code", -"raw": "claude-cli/2.1.323 (external, cli)", +"raw": "claude-cli/2.1.323 (external, cli)", -"version": "2.1.323" +"version": "2.1.323" -}, +}, -"direction": "outbound", +"direction": "outbound", -"host": "api.anthropic.com", +"host": "api.anthropic.com", -"httpMethod": "POST", +"httpMethod": "POST", -"httpPath": "/v1/messages", +"httpPath": "/v1/messages", -▾ "inference": { +▾ "inference": { -"agentRole": "main", +"agentRole": "main", -▾ "messages": [ +▾ "messages": [ -▸ 8 earlier messages · 1.4kB +▸ 8 earlier messages · 1.4kB -▾ { +▾ { -"content": "Running the tests to confirm the change holds.", +"content": "Running the tests to confirm the change holds.", -"role": "assistant", +"role": "assistant", -"toolCallNames": "Bash", +"toolCallNames": "Bash", -▾ "toolCalls": [ +▾ "toolCalls": [ -▌▾ { +▌▾ { -▾ "arguments": { +▾ "arguments": { -"command": "npm test -- Settings" +"command": "npm test -- Settings" -}, +}, -"id": "toolu_web_04", +"id": "toolu_web_04", -"name": "Bash" +"name": "Bash" -} +} - - - - - - - - - - ↑↓ move ↵ fold tab response y yank request u usage / search esc back ? keys q quit + + + + + + + + + + + + + + + + + + + ↑↓ move ↵ fold tab response y yank request u usage / search esc back ? keys q quit -"httpMethod": "POST", +"httpMethod": "POST", -"httpPath": "/v1/messages", +"httpPath": "/v1/messages", -▾ "inference": { +▾ "inference": { -"agentRole": "main", +"agentRole": "main", -▾ "messages": [ +▾ "messages": [ -▸ 8 earlier messages · 1.4kB +▸ 8 earlier messages · 1.4kB -▾ { +▾ { -"content": "Running the tests to confirm the change holds.", +"content": "Running the tests to confirm the change holds.", -"role": "assistant", +"role": "assistant", -"toolCallNames": "Bash", +"toolCallNames": "Bash", -▾ "toolCalls": [ +▾ "toolCalls": [ -▾ { +▾ { -▾ "arguments": { +▾ "arguments": { -"command": "npm test -- Settings" +"command": "npm test -- Settings" -}, +}, -"id": "toolu_web_04", +"id": "toolu_web_04", -"name": "Bash" +"name": "Bash" -} +} -] +] -}, +}, -▾ { +▾ { -"role": "user", +"role": "user", -▾ "toolResults": [ +▾ "toolResults": [ -▾ { +▾ { -"content": │ +"content": │ -PASS src/pages/Settings.test.tsx +PASS src/pages/Settings.test.tsx - ✓ toggles dark mode (31 ms) + ✓ toggles dark mode (31 ms) -▌ ✓ keeps the choice after reload (12 ms) +▌ ✓ keeps the choice after reload (12 ms) @@ -5427,10 +5453,10 @@ clipPath rect{width:100000px} ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── SESSION TITLE UPDATED EVENTS TOKENS COST SAVED~CTX(1M) -▌api-7f3caudit the repo before release just now 32 625.1k $0.47 $0.05▕▎ ▏ +▌api-7f3caudit the repo before release just now 32 625.1k $0.47 $0.05▍░░░░░░ -web-2a91 add dark mode toggle 1m ago 10 49.3k $0.14 — ▕▏▏ -infra-55de debug the helm chart 1m ago 2 16.2k $0.02 — ▕▏▏ +web-2a91 add dark mode toggle 1m ago 10 49.3k $0.14 —▏░░░░░░ +infra-55de debug the helm chart 1m ago 2 16.2k $0.02 —▏░░░░░░ @@ -5457,16 +5483,25 @@ clipPath rect{width:100000px} ● connected12.4 events/sec feedback: https://github.com/rossoctl/cortex/issues/new/choose - - - - - - - - - - ↑↓ nav ↵ drill u usage $ spend / search p pause P plugins ? keys q quit + + + + + + + + + + + + + + + + + + + ↑↓ nav ↵ drill u usage $ spend / search p pause P plugins ? keys q quit @@ -5492,8 +5527,6 @@ clipPath rect{width:100000px} - - @@ -5502,12 +5535,14 @@ clipPath rect{width:100000px} - + - + - + + + @@ -5523,10 +5558,6 @@ clipPath rect{width:100000px} - - - - @@ -5535,31 +5566,29 @@ clipPath rect{width:100000px} - + - + - + - + + + - + - - + + - + - + - + - - - - @@ -5568,31 +5597,29 @@ clipPath rect{width:100000px} - + - + - + - + + + - + - - + + - + - + - + - - - - @@ -5601,31 +5628,29 @@ clipPath rect{width:100000px} - + - + - + - + + + - + - - + + - + - + - + - - - - @@ -5634,31 +5659,29 @@ clipPath rect{width:100000px} - + - + - + - + + + - + - - + + - + - + - + - - - - @@ -5667,504 +5690,482 @@ clipPath rect{width:100000px} - + - + - + - + + + - + - - + + - + - + - + - - - - - + - + - + - + - + + + - + - - + + - + - + - + - - - - - + - + - + - + - + + + - + - - + + - + - + - + - - - - - + - + - + - + - + + + - + - - + + - + - + - + - - - - - + - + - + - + - + + + - + - - + + - + - + - + - - - - - + - + - + - + - + + + - + - - + + - + - + - + - - - - - + - + - + - + - + + + - + - - + + - + - + - + - - - - - + - + - + - + - + + + - + - - + + - + - + - + - - - - - - + + - + - + - + - + + + - + - - + + - + - + - + - - - - - - + + - + - + - + - + + + - + - - + + - + - + - + - - - - - - + + - + - + - + - + + + - + - - + + - + - + - + - - - - - - + + - + - + - + - + + + - + - - + + - + - + - + - - - - - - + + - + - + - + - + + + - + - - + + - + - + - + - - - - + + + + + - + + + + + + + + + - + - + - + - - - - - - - - - + + + + - - - - - - - - - + - + - + - + + + - + + + + - - - - - - + - + + + + + @@ -6190,18 +6191,18 @@ clipPath rect{width:100000px} + - - - - - - + - + + + + + @@ -6226,11 +6227,7 @@ clipPath rect{width:100000px} - - - - - - + + diff --git a/docs/superpowers/plans/2026-11-19-tui-polish-2019.md b/docs/superpowers/plans/2026-11-19-tui-polish-2019.md new file mode 100644 index 000000000..68650e3e0 --- /dev/null +++ b/docs/superpowers/plans/2026-11-19-tui-polish-2019.md @@ -0,0 +1,242 @@ +# agentop: quieter rows, clearer panes and a shorter key bar (#2019) Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Make the important rows and numbers in agentop stand out, and make background traffic and general keys step back, with fewer words and fewer keys. + +**Architecture:** All work is in `cmd/agentop/tui` and the agentop docs. New colors go in `styles.go`. Table cells stay plain text: color comes from the `tui/table` cell-style hook (`CellStyleFunc func(r int, row Row, col int) lipgloss.Style`, already in `table/table.go:79`, so it already gets the row index). Chrome lines are styled after every cut or fit step, as #2015 does. + +**Tech Stack:** Go 1.26.10, Bubble Tea v1, Lip Gloss v1.1.0, `github.com/charmbracelet/x/ansi`, `github.com/muesli/termenv`. Add no dependency. + +**Spec:** issue #2019 (`gh issue view 2019 --repo rossoctl/cortex`). Read it in full before you start a task. Where this plan and the issue differ, the issue wins, except for the items under "Decisions". The mockups named in the issue are in `~/Documents/agentop-mockups/` (local files, read-only). + +## Global Constraints + +- The 8 rules of the issue's "Rules that stay from #2015" section apply to every task. In short: + 1. Never cut or pad a styled string with `runewidth.Truncate`, `runewidth.FillRight` or `len`. Style after those steps. `truncToWidth`, `ansi.Truncate` and `lipgloss.Width` may run after styling. + 2. Table cells keep no ANSI. Color is added inside `tui/table` through the cell-style hook. + 3. Search highlighting keeps working over every new style: match styles win, a marked row keeps its ink, the selected row keeps its tint. + 4. A cell style sets only foreground and bold. Never `Reverse` or `Background`. + 5. Each new color is a `lipgloss.AdaptiveColor` in `styles.go`. + 6. Under the Ascii profile (what `go test` gets), keys keep their brackets, and there is no bar, chip or selection mark. + 7. No regression of more than 10% in `BenchmarkRebuildEventsTable`, `BenchmarkRebuildEventsTableTrueColor` and `BenchmarkEventsTableView` (`tui/events_rebuild_bench_test.go`). + 8. The key grammar (`docs/superpowers/specs/2026-11-19-agentop-key-grammar-design.md`, `tui/key_grammar_test.go`) holds. A `[w]` hint shows the current value (`[w] 1h`). +- Each change has a test of the new look under a forced TrueColor profile, and the test checks the plain text with `ansi.Strip`. Use the profile helpers the #2015 tests use (for example `tui/cell_styles_test.go`, `tui/styles_test.go`). +- The `lipgloss.Width` of each line is the same under Ascii and TrueColor. +- Run Go commands from `cmd/agentop` with `GOWORK=off`. Always give `gofmt` a path (`gofmt -l .`). +- While you work: `scripts/dev/go-test-shards.sh -short cmd/agentop` (about 20 s) from the worktree root. The PR gate runs the full suite. +- Commits: `git commit -s`. End each message with `Assisted-By: Claude (Anthropic AI) `. No `Co-Authored-By`. +- Out of scope: everything in #2020 (part 2). Do not add: the title without the default URL, removal of the Usage pricing note, the server name in Events `HOST`. + +## Decisions (made here, with the reason) + +1. **PR split.** The estimate is about 2,210 counted lines, over 2,000. The issue says to split at change 6. So P1 has changes 1-5 (T1-T5) and P2 has changes 6-11 (T6-T11), stacked on P1. Reason: the issue names this split, and T6 and T11 need T3 and T5. +2. **Gauge (T1).** `contextGauge(promptTokens, width)` returns `tierBar(promptTokens, contextWindowTokens, width) + strings.Repeat("░", width-lipgloss.Width(bar))`. `width < 1` returns `""`. `promptTokens <= 0` returns `emptyCell`. Reason: `tierBar` (`spend_tiers.go:440`) already does the 8-step eighths and the "non-zero is never empty" rule. +3. **Gauge glyphs (T1).** Remove `'▕'` and `'▏'` from `tableGlyphs` and add `'░': styleDim`. The CTX column already has kind `cellAccent` (`sessionsCellKinds`), so the fill draws accent and the track draws dim. Delete the `shortcut:` comment about `▏`. +4. **Tool-row glyphs (T3).** Add `'┗'`, `'┣'`, `'⚒'` to `tableGlyphs` as `styleDim`. Draw the subagent `│` dim the same way: add `'│': styleDim`. The reviewer checked the base: the only table cell that holds `│` is the Events `DIR` column (`events_columns.go:253` and `:946`), so the glyph changes no other table, and an exchange row's `│` draws dim too (accepted). Reason: the glyph map is the #2015 way to draw a second ink in one cell. +5. **Bobcoins (T2).** In `styleBandAmount` (`spend_band.go:380`), an amount with no `$` is bold, and a trailing ` Bobcoins` word is `styleMuted`. `grep` found no other currency in `colorWarn` (`spend_drawer.go`, `spend_strip.go`, `usage_*.go` have none). The test keeps that true. +6. **Key bar (T4).** New palette: `colorBarBg {Light "#F3F4F6", Dark "#1F2937"}`, `colorBarChipBg {Light "#D1D5DB", Dark "#4B5563"}`, `colorBarChipFg {Light "#111827", Dark "#F9FAFB"}`. New helpers in `styles.go`: `renderKeyBar(fitted string, width int) string` and `renderTrailingKeyBar(fitted, keys string, width int) string`. Under Ascii they return exactly `renderHints(fitted)` / `renderTrailingHints(fitted, keys)`. With color, every run has `Background(colorBarBg)` (label text `colorMuted` on it, chips `colorBarChipFg` on `colorBarChipBg`), and the line is padded with bar-colored spaces to `width` (no pad when `width <= 0`). Use them only for the LAST line of the screen: `footer.go:40`, `footer.go:136`, and the Namespaces and Pods footers in `app.go` (about lines 2589 and 2614). Modal hint lines (`clear.go`, `server_picker.go`, `edit_overlay.go`, the help overlay foot) keep `renderHints`. Reason: the issue scopes the bar to the key-hint line. +7. **One-line legend (T5).** `legend()` returns exactly this plain text, swatch colors as today: `█ tools █ model █ retrying █ waiting on subagents █ waiting on you ┆ time cut from the axis ▁…█ requests in flight`. The fit width is `m.width`. When it does not fit, drop whole items from the right: first ` ▁…█ requests in flight`, then ` ┆ time cut from the axis`, then the swatch items one at a time from the right. Never wrap. `timelineFixedLines` 8 → 7 and `timelineLegendLines` 2 → 1. +8. **Idle cursor row (T5, T11).** `cursorStrip` with no moment picked returns `""`. The row stays (the `\n` is still written by `renderTimeline`). T11 then puts the `timelineStatus` notes there (see 11). +9. **Quiet predicate (T6).** `func rowQuiet(ctxs []cellContext, partner map[int]int, j int) bool { return eventInactive(ctxs[j].invs) && !partnerActive(ctxs, partner, j) }` in `events_blocks.go`. `rowInactiveHidden` becomes `m.hideInactive && rowQuiet(...)` in T6, and T7 deletes it. Tunnel rows need no special case: an unbridged CONNECT has no invocations, so `eventInactive` is true, and a gate deny on it makes it not quiet. Reason: the issue asks for ONE predicate. +10. **Quiet flags (T6).** Add `quiet bool` to `eventRow` and set it where the row loop renders an exchange row (`renderEventRow` in `rebuildEventsTable`). It is a field of the value in `m.visibleRows`, so `sortEventRows` moves it with its row. Add `eventRowQuiet` to `eventRowKind`, set from `m.visibleRows[i].quiet` where `kinds` is built (`events_pane.go:466`). Change the hook to `eventCellStyle(cols []eventColumn, kinds []eventRowKind, rows []table.Row) table.CellStyleFunc`. In a quiet row every cell is `styleMuted`, except: a STATUS whose `statusGroup` is `groupError` keeps `styleError`; `—` stays dim (`dashDim`); a cell in `colDir`, `colAction`, `colPlugin`, `colMethod` or `colHost` whose trimmed text equals the same column's trimmed text in row `r-1` is `styleDim`, but only when row `r-1` is also `eventRowQuiet`. Reason: a run reads as one block only when the rows touch, and the column ids come from `cols`, so the column picker cannot move the rule. +11. **Timeline header (T11).** One line: label column (26) + axis (exactly `lay.axis.width()` columns) + gutter (`" model tools tok/s"`, padded to `timelineGutterWidth`). + - Label column: `"window "` muted, then for each `offeredWindows` index one item: current = `styleSeg.Render(" "+label+" ")` with color, `"["+label+"]"` under Ascii; other = muted `" "+label+" "`. Pad to 26. Plain text with color: `window 5m 1h 24h all `. + - Axis: `func axisLabels(lay tlLayout) []axisLabel` places labels; `type axisLabel struct { cell int; text string; date int; bold bool }` where `cell` is the first column of `text`, `date` is the byte length of a leading `MM-DD ` date part (0 for none), and `bold` marks the two ends. `func renderAxisLine(labels []axisLabel, w int) string` styles them: `╷` dim, date muted, end times bold, other times muted, and returns exactly `w` columns. + - Order of placement: (a) start `╷` + `01-02 15:04` at cell 0; (b) finish `01-02 15:04` + `╷`, so the `╷` sits on cell `w-1`; (c) the gap-length and live-tail labels of today (no tick, centered as today); (d) middle times every 16 cells on non-gap cells, as `╷HH:MM`, with the date added (`╷01-02 HH:MM`) when its day differs from the day of the label placed before it. A label that touches or overlaps a placed one (keep today's one-cell gap) is dropped, never cut. + - Time format: `15:04`, or `15:04:05` when the window span is at most 10 minutes. Reason: today's axis uses seconds there, and 16-cell labels in a 5-minute window repeat the same minute otherwise. + - Narrow: if both dated ends do not fit with one blank cell between, use undated ends (`╷15:04`, `15:04╷`). If those do not fit, show only the undated start. If that does not fit, show nothing. + - `timelineStatus` returns only the notes (`oldest events not shown`, `refresh failed: …`, joined by ` · `), with no range. `cursorStrip` with no moment picked returns that text muted, or `""` when there is none. + - `timelineFixedLines` 7 → 5. +12. **Short ids (T8).** `sessionIDCell` returns the first 8 bytes of a session id (UUIDs are ASCII), no `…`. `default` and a pending bucket's agent name are not cut. `SESSION` is declared 8 wide, and the rebuild widens it to the widest cell of the listed sessions, counting ids as 8 (so `claude-code` gives 11). The `default` row is all `styleMuted` (Sessions cell style: a row whose id is `default`). Update the comments at `sessions_pane.go:37` ("SESSION is 12 at 97 columns and 14 from 100 up") and in `pending_bucket.go:31`. +13. **Key bar per pane (T9).** Remove only the general keys. New strings (`search` is `m.searchHints(m.pane)`): + - Sessions: `[↵] drill [u] usage [$] spend ` + search + (` [esc] agents` or ` [esc] pods` as today, else nothing) + ` [?] keys [q] quit`. + - Events: `[b/f] page [↵] detail [c] columns [u] usage ` + search + ` [esc] back` + the notices of today + ` [?] keys [q] quit`. (`[b/f]` stays: it is not a key a user guesses.) + - Detail: today's line without `[↑↓] move `. Pipeline: without `[↑↓] nav `. Plugin detail: without `[↑↓] scroll `. Timeline: without the `[↑↓] rows ` hint. Namespaces and Pods: without `[↑↓/jk] nav `. Agents: without `[↑↓] nav`, but the project label stays at the head of the line. Usage: no change. + - Every removed key keeps working, and the `?` help of that pane lists it. Add a help row where one is missing. +14. **Two-column help (T10).** `helpTwoColumnMinWidth = 115`: each column needs keyIndent 2 + key column 12 + gutter 2 + about 40 columns of description, so `2*56 + 3`. At a 140-column terminal the body is 134 wide (two columns). At 80 it is 74 (one column). Column width `colW = (width-3)/2`. Separator: `styleDim.Render(" │ ")`. Left: the pane's group (emphasized, as today) then GO TO ANOTHER PANE. Right: ANYWHERE, MOVING AROUND THIS HELP, INSIDE THE SPEND DRAWER (when `helpGlobalGroups` returns it), THE DRILL PATH. Pad each left line with `padRight` (it uses `lipgloss.Width`). The shorter column is padded with blank lines. EVERY PANE stays one column below, at full `width`. +15. **Live check and benchmark capture against the user's service** are for a human. See "For a human after review". + +## Review Focus + +1. A search on Events that matches a cell in a quiet row or a dim repeat: the match style wins, a marked row keeps its warn ink, the selected quiet row keeps its tint. Test in T6. +2. Events sorted by a column (`STATUS▼`) with quiet rows: the quiet flags and the dim repeats follow the sorted rows, not the arrival order. Test in T6. +3. The column picker hides `ACTION` and `PLUGIN`: the dim-repeat rule still keys by column id. Test in T6. +4. A `fitHintLine` cut that starts with `… ` on the shaded bar: the bar still covers the full width, the width is `m.width`, and no chip forms from a half bracket. Test in T4. +5. Help search (`/` in the `?` overlay) on a two-column body: a match in the right column is highlighted and `n` reaches it. Test in T10. + +## File map + +| File | Tasks | +|---|---| +| `cmd/agentop/tui/styles.go` | T1, T3, T4 | +| `cmd/agentop/tui/sessions_context.go`, `sessions_context_test.go` | T1 | +| `cmd/agentop/tui/spend_band.go`, `spend_band_test.go` | T2 | +| `cmd/agentop/tui/events_columns.go`, `events_cell_styles_test.go`, `events_tool_rows_test.go` | T3, T6 | +| `cmd/agentop/tui/footer.go`, `app.go` (picker footers), `footer_test.go` | T4 | +| `cmd/agentop/tui/timeline_pane.go`, `timeline_pane_test.go` | T5, T11 | +| `cmd/agentop/tui/events_pane.go`, `events_blocks.go`, `app.go` (model fields) | T6, T7 | +| `cmd/agentop/tui/keys.go` | T7, T9 | +| `cmd/agentop/tui/help_overlay.go`, `help_overlay_test.go` | T7, T9, T10 | +| `cmd/agentop/tui/sessions_pane.go`, `pending_bucket.go` and their tests | T8 | +| `docs/using-agentop.md`, `cmd/agentop/README.md` | T1, T7, T9 | +| `docs/superpowers/specs/2026-11-19-agentop-key-grammar-design.md` | T7 | + +--- + +### Task T1: Shaded-track context gauge (change 1) + +Depends on: none + +**Files:** `tui/sessions_context.go:123-155`, `tui/styles.go` (`tableGlyphs`), `tui/sessions_context_test.go` and any gauge test that pins `▕`/`▏`, `docs/using-agentop.md:44`, `cmd/agentop/README.md` (CTX section, `### How CTX is derived`). + +- [ ] Step 1: Write failing tests `TestContextGauge_ShadedTrack`: `contextGauge(500_000, 7) == "███▌░░░"`, `contextGauge(8_200, 7) == "▏░░░░░░"`, `contextGauge(1_000_000, 7) == "███████"`, `contextGauge(2_000_000, 7) == "███████"`, `contextGauge(0, 7) == emptyCell`, `lipgloss.Width` is 7 for every non-dash value, `contextGauge(5, 0) == ""`. And `TestSessionsGauge_TrueColorInk`: under TrueColor the rendered CTX cell has the fill in `colorAccent` and each `░` in `colorDim`, and `ansi.Strip` equals the plain gauge. +- [ ] Step 2: Run them. Expected: FAIL. +- [ ] Step 3: Implement Decisions 2 and 3. Rewrite the `contextGauge` comment: the author chose shaded blocks in #2019, the gap after a partial cell is accepted, and there is no "nearly full" color. Update the old gauge tests to the new text. +- [ ] Step 4: Change the sample `▕████ ▏` in `docs/using-agentop.md` to the 7-cell shaded form (`████░░░`), and the CTX text in `cmd/agentop/README.md` that names brackets. +- [ ] Step 5: Run `scripts/dev/go-test-shards.sh -short cmd/agentop`. Expected: PASS. Commit. + +### Task T2: Bobcoins are not yellow (change 2) + +Depends on: none + +**Files:** `tui/spend_band.go:360-398`, `tui/spend_band_test.go`. + +- [ ] Step 1: Write failing test `TestStyleBandValue_BobcoinsBoldNotWarn`: under TrueColor, `styleBandValue("12.40 Bobcoins")` contains `styleBold.Render("12.40")` and `styleMuted.Render(" Bobcoins")`, contains no `colorWarn` sequence, and `ansi.Strip` gives `12.40 Bobcoins`. Also `"~12.40 Bobcoins+"` keeps `~` and `+` dim. Add `TestNoCurrencyUsesWarn`: render the spend band, the spend drawer and the Usage cost view with a Bobcoins figure under TrueColor and assert that no output has the `colorWarn` foreground sequence. +- [ ] Step 2: Run. Expected: FAIL. +- [ ] Step 3: Implement Decision 5. Update the doc comments of `styleBandValue` and `styleBandAmount`. +- [ ] Step 4: Run the short shards. Expected: PASS. Commit. + +### Task T3: Tool rows step back (change 3) + +Depends on: none + +**Files:** `tui/events_columns.go:530-545` (`eventCellStyle`), `tui/styles.go` (remove `colorTool`, `styleTool`, add glyphs), `tui/events_tool_rows_test.go`, `tui/events_cell_styles_test.go`. + +- [ ] Step 1: Write failing test `TestEventCellStyle_ToolRowsMuted`: for a tool row, every non-empty cell is `styleMuted`; STATUS `ok` is muted; `running` and a DURATION starting with `⋯` are `styleWarn`; `lost`/`error` are `styleError`. Under TrueColor the drawn `┗⚒`/`┣⚒` and a subagent `│` carry the `colorDim` sequence. Check a tool row in search results and inside an open subagent block too. +- [ ] Step 2: Run. Expected: FAIL. +- [ ] Step 3: Implement Decision 4 and the rules above. Delete `colorTool` and `styleTool`. Their only users are `eventCellStyle` (`events_columns.go:537,540`) and `events_cell_styles_test.go`: change that test to expect `styleMuted`. +- [ ] Step 4: Run the short shards and the 3 benchmarks of Global Constraint 7 on the base commit and on HEAD (`GOWORK=off go test -run '^$' -bench 'RebuildEventsTable|EventsTableView' -count 6 ./tui/`). Expected: PASS, and no benchmark more than 10% slower. Commit. + +### Task T4: Full-width shaded key bar (change 4) + +Depends on: none + +**Files:** `tui/styles.go`, `tui/footer.go:40,136`, `tui/app.go` (Namespaces and Pods footers), `tui/footer_test.go`. + +- [ ] Step 1: Write failing tests `TestRenderKeyBar_FullWidthUnderColor`: under TrueColor, `lipgloss.Width(renderKeyBar(fitHintLine(h, 100), 100)) == 100`, every rune of the line has the `colorBarBg` background, chips have `colorBarChipBg` and `colorBarChipFg`, `strings.TrimRight(ansi.Strip(out), " ")` equals the chip form of the hint. `TestRenderKeyBar_AsciiUnchanged`: under Ascii the output equals `renderHints(fitted)`. A case with a `… ` cut and a half bracket (Review Focus 4). Run under both themes (`lipgloss.SetHasDarkBackground`). +- [ ] Step 2: Run. Expected: FAIL. +- [ ] Step 3: Implement Decision 6. The status line above does not change. +- [ ] Step 4: Run the short shards. Fix any test that compares the whole colored footer only where it checks the new background. Expected: PASS. Commit. + +### Task T5: One-line Timeline legend (change 5) + +Depends on: none + +**Files:** `tui/timeline_pane.go:410-440` (constants), `:770-785` (`legend`), `:959-963` (`cursorStrip`), `tui/timeline_pane_test.go`. + +- [ ] Step 1: Write failing tests: `TestTimelineLegend_OneLine` (`ansi.Strip(m.legend())` equals the Decision 7 text at a width of 200, has no `\n`, has no `tok/s`, no `in its colour`); `TestTimelineLegend_DropsFromTheRight` (at a width just under the full text the `▁…█` note is gone; narrower, the `┆` note is gone too; never wider than `m.width`, never two lines); `TestCursorStrip_IdleRowIsBlank` (with `cursor == -1` the row is present and empty, and the chart starts on the same line before and after `←`). Update the row-count tests for `timelineFixedLines` 7 and one legend line, and for nothing else. +- [ ] Step 2: Run. Expected: FAIL. +- [ ] Step 3: Implement Decisions 7 and 8. `legend()` gets the width it fits (`m.width`). Keep the `[←→]` footer hint and the `?` help text. +- [ ] Step 4: Run the short shards. Expected: PASS. Commit. + +### Task T6: Quiet background traffic (change 6) + +Depends on: T3 + +**Files:** `tui/events_blocks.go:105-111`, `tui/events_pane.go` (row loop, `kinds` at `:466`), `tui/events_columns.go` (`eventRowKind`, `eventCellStyle`), `tui/events_cell_styles_test.go`. + +**Interfaces:** Produces `rowQuiet(ctxs []cellContext, partner map[int]int, j int) bool` and `eventRow.quiet`, which T7 uses. + +- [ ] Step 1: Write failing tests: `TestRowQuiet` (no invocations → quiet; all skip → quiet; a shadow deny → not quiet; an inactive row with an active partner → not quiet; an unbridged tunnel row → quiet; a tunnel with a gate deny → not quiet). `TestEventCellStyle_QuietRows` under TrueColor: a quiet row is muted; a quiet row with STATUS 502 keeps `styleError`; in two adjacent quiet rows with the same HOST and METHOD, the second row's HOST and METHOD cells are `styleDim` and its TIME is muted; a non-quiet row between them stops the dim. `TestEventCellStyle_QuietFollowsSortAndColumns`: with `STATUS` sorted, and with `ACTION` and `PLUGIN` hidden in the column picker, the quiet ink and the dim repeats stay on the right rows and columns (Review Focus 2, 3). `TestQuietRows_SearchMatchWins` (Review Focus 1). +- [ ] Step 2: Run. Expected: FAIL. +- [ ] Step 3: Implement Decisions 9 and 10. +- [ ] Step 4: Run the short shards and the 3 benchmarks on the P1 tip and on HEAD (same command as T3). Expected: PASS, and no benchmark more than 10% slower. Commit. + +### Task T7: Remove the `s` toggle on Events (change 7) + +Depends on: T6 + +**Files:** `tui/app.go:651-660` (`hideInactive`, `hiddenInactive`), `tui/keys.go:495` (`case "s"`), `:1222-1247` (hints, `· N hidden`), `tui/events_blocks.go` (`rowInactiveHidden`, `collectSubagentBlocks`), `tui/events_pane.go` (row loop, comments), `tui/help_overlay.go:323`, tests that use `hideInactive`, `docs/using-agentop.md:161,245`, `cmd/agentop/README.md:566,865`, `docs/superpowers/specs/2026-11-19-agentop-key-grammar-design.md:35,76`. + +- [ ] Step 1: Write failing tests: `TestEventsS_DoesNothing` (press `s` on Events: the rows, the footer and the selected row are the same before and after); keep or add `TestColumnPicker_SSorts` (in the picker `s` still sorts). +- [ ] Step 2: Run. Expected: FAIL on the first. +- [ ] Step 3: Remove the fields, the key case, both hints, the hidden notice, `rowInactiveHidden` (the loops call nothing, every row renders), and the help row `{"s", "toggle passthru/skip rows"}`. Keep `eventInactive` and `rowQuiet`. Delete or rewrite the toggle tests. Fix the comments that name `hideInactive`. +- [ ] Step 4: Docs. `docs/using-agentop.md`: delete the line "`s` hides or shows the exchanges that no plugin acted on." and the Keys table row for `s` on Events. Add one line: rows where no plugin acted, and tunnel rows, show muted. `cmd/agentop/README.md`: delete the `s` row at line 865 and `[s] hide passthru/skip ` from the footer sample at 566. Key-grammar spec: change the `s` row of the Changes table to say that `s` on Events is removed (#2019) and that the column picker keeps `s` = sort. Line 76: drop the claim that `s` works on Events. +- [ ] Step 5: Run the short shards. Expected: PASS. Commit. + +### Task T8: Short session ids and wider titles (change 8) + +Depends on: none + +**Files:** `tui/sessions_pane.go:30-60` and the rebuild (`:270`, `:467`, `sessionsColumnsFor` at `:903`), `tui/pending_bucket.go:31-39`, `tui/sessions_rowid_test.go`, `tui/sessions_title_test.go`, `tui/pending_bucket_test.go`. + +- [ ] Step 1: Write failing tests: `TestSessionIDCell_EightChars` (`sessionIDCell("f0a50e1f-1234-…", w) == "f0a50e1f"`; `"default"` stays `"default"`); `TestSessionsTable_PendingBucketFullAgentName` (a bucket for `claude-code` shows `claude-code` and SESSION is 11 wide); `TestSessionsTable_TitleGetsFreedColumns` (at 140 columns with two agents listed so AGENT shows, TITLE is 30, it was 24); `TestSessionsTable_DefaultRowMuted` (TrueColor: every cell of the `default` row is muted); search and yank on a row still use the full id. Update the column-width tests that pin 14. +- [ ] Step 2: Run. Expected: FAIL. +- [ ] Step 3: Implement Decision 12. AGENT keeps `sessionsListTwoAgents`. Check `alignSessionsHeaders` and `growSessionsTitle` with the new width. +- [ ] Step 4: Run the short shards. Expected: PASS. Commit. + +### Task T9: A shorter key bar (change 9) + +Depends on: T7 + +**Files:** `tui/keys.go:1159-1374` (`helpView`), `tui/help_overlay.go` (`paneKeys` rows for removed hints), `tui/footer_fit_test.go` and tests that pin hint text, `cmd/agentop/README.md` (footer samples), `docs/using-agentop.md` (footer samples, if any). + +- [ ] Step 1: Write failing tests: `TestHelpView_SessionsShort` (`ansi.Strip` of the Sessions bar at 200 columns is `↵ drill u usage $ spend / search ? keys q quit` under TrueColor, and `[↵] drill [u] usage [$] spend [/] search [?] keys [q] quit` under Ascii); one test per changed pane for the Decision 13 string; `TestHelpOverlay_ListsRemovedKeys` (for each pane, each key removed from its bar is in that pane's `?` help). Keep `TestFitHintLine_KeepsQuitAndHelpAtEveryWidth` and `key_grammar_test.go` passing with no edit. +- [ ] Step 2: Run. Expected: FAIL. +- [ ] Step 3: Implement Decision 13. Keep the order "what must survive a narrow cut", and keep `[w]` with its value. Update the comments in `helpView` that explain removed hints (for example the `[P] plugins` placement note). +- [ ] Step 4: Update the footer samples in `cmd/agentop/README.md` and `docs/using-agentop.md` to the new strings. +- [ ] Step 5: Run the short shards. Expected: PASS. Commit. + +### Task T10: Help in two columns (change 10) + +Depends on: none + +**Files:** `tui/help_overlay.go:712-750` (`helpBodyLines`), `tui/help_overlay_test.go`. + +- [ ] Step 1: Write failing tests: `TestHelpBody_TwoColumnsAt140` (`helpBodyLines(paneSessions, 134)`: a line has the pane group's title on the left and `ANYWHERE` on the right with a `│` between; EVERY PANE is one column below); `TestHelpBody_OneColumnAt80` (width 74: no `│` separator, same order as today); `TestHelpBody_WrapsUnderDescription` (a long description in a column wraps to the description column, not the key column, and no line is wider than its column); `TestHelpBody_CurrentPaneEmphasis` (the pane group keeps `styleTitle`/`styleOK` under TrueColor); scroll still shows `[↑↓] scroll N%`; Review Focus 5. +- [ ] Step 2: Run. Expected: FAIL. +- [ ] Step 3: Implement Decision 14. `renderHelpOverlay` does not change. +- [ ] Step 4: Run the short shards. Expected: PASS. Commit. + +### Task T11: One Timeline header line with full start and finish (change 11) + +Depends on: T5 + +**Files:** `tui/timeline_pane.go:727-738` (header lines), `:787-840` (`timelineStatus`, `axisLabels`), `:959` (`cursorStrip`), `:410-420` (constants), `tui/timeline_pane_test.go`. + +**Interfaces:** Produces `axisLabels(lay tlLayout) []axisLabel`, `renderAxisLine(labels []axisLabel, w int) string` (Decision 11). + +- [ ] Step 1: Write failing tests: `TestAxisLabels_SameDay` (start `╷11-19 23:30` at cell 0, finish `11-19 23:59╷` with `╷` at cell `w-1`, middle labels `╷HH:MM`); `TestAxisLabels_AcrossMidnight` (the first label on the new day reads `╷11-20 00:01`); `TestAxisLabels_ThreeDays`; `TestAxisLabels_DropsOverlap` (a middle label that would touch the finish is dropped, no label is cut); `TestAxisLabels_NarrowUndated` (a width under 25 gives `╷23:30` and `00:30╷`); `TestAxisLabels_TickOnNamedCell` (each tick sits on the cell whose `from` is the label's time); `TestTimelineHeader_OneLine` (TrueColor: `ansi.Strip` of the line is `window 5m 1h 24h all ` padded to 26, the axis, then ` model tools tok/s`; the current window has the `styleSeg` background; Ascii shows `[1h]`; same `lipgloss.Width` in both); `TestTimelineStatus_OnIdleCursorRow` (with `Truncated` true and no moment picked, the cursor row reads `oldest events not shown`; with a moment picked, it shows that moment's tools). Update the row-count tests for `timelineFixedLines` 5, and for nothing else. +- [ ] Step 2: Run. Expected: FAIL. +- [ ] Step 3: Implement Decision 11. Delete the `from → to` range text and its line. +- [ ] Step 4: Run the short shards. Expected: PASS. Commit. + +## PRs + +Total about 2,210 counted lines: T1 110, T2 70, T3 110, T4 150, T5 170 (P1: 610); T6 260, T7 260, T8 140, T9 260, T10 260, T11 420 (P2: 1,600). Over 2,000, so two PRs, split where the issue says. + +| PR | Title | Parent | Tasks | estLines | +|---|---|---|---|---| +| P1 | `feat: Quiet agentop tool rows and Bobcoins, shade the key bar and shorten the Timeline legend` | "" | T1, T2, T3, T4, T5 | 610 | +| P2 | `feat: Quiet agentop background rows, drop the s toggle, shorten ids, keys and the Timeline header` | P1 | T6, T7, T8, T9, T10, T11 | 1600 | + +Order: P1 runs T1-T5 at the same time. P2 runs T6, T8, T10, T11 at the same time, then T7 after T6, then T9 after T7. + +## Gate + +From the worktree root: + +```sh +(cd cmd/agentop && GOWORK=off go vet ./... && test -z "$(gofmt -l .)" && GOWORK=off go test -race $(GOWORK=off go list ./... | grep -v 'agentop$')) && scripts/dev/go-test-shards.sh -race cmd/agentop && pre-commit run --from-ref 32085fa1ce566d47bef9ad840acc0f096e8d547a --to-ref HEAD +``` + +Gate check (plan review, on the unchanged base): `GOWORK=off go vet ./...` and `gofmt -l .` from `cmd/agentop` both pass. No change to how the gate is called. + +## For a human after review + +Live check (needs T1-T11, or T1-T5 for P1 alone). It drives agentop against the local Cortex service, so a person runs it: + +1. `cd cmd/agentop && GOWORK=off go build -o /tmp/agentop-2019 .` +2. With `expect`, open Sessions, Events, Timeline and the `?` help at 140×30 and 80×24 against `http://127.0.0.1:47601`. Capture each screen and compare it with the mockups in `~/Documents/agentop-mockups/` (`shade_ctx.html`, `ctx_compare.html`, `tool_rows.html`, `footer_bar.html`, `timeline_legend3.html`, `timeline_oneline.html`, `ideas.html`, `ideas2.html`, `ideas3.html`). Where the issue text and a mockup differ, the issue wins (for example, AGENT shows when two agents are listed). +3. Do not run `make dev-install` or restart the service. diff --git a/docs/using-agentop.md b/docs/using-agentop.md index ef3b8e47e..66e764b23 100644 --- a/docs/using-agentop.md +++ b/docs/using-agentop.md @@ -41,9 +41,9 @@ LAST 1H TODAY 7 DAYS MONTH $4.04 $18.80 $216.44 $703.18 ──────────────────────────────────────────────────────────────────────────────────────────────────── SESSION TITLE UPDATED EVENTS TOKENS COST SAVED~ CTX(1M) - ctx-abc-123-4… …pend-spans 3s ago 42 48.2k $0.12 $0.01 ▕████ ▏ - ctx-def-567-4… weather-ag… 18m ago 15 1.2k <$0.01 — ▕▏ ▏ - ctx-ghi-901-4… 42m ago 7 2.9k — — ▕██ ▏ + ctx-abc-123-4… …pend-spans 3s ago 42 48.2k $0.12 $0.01 ████░░░ + ctx-def-567-4… weather-ag… 18m ago 15 1.2k <$0.01 — ▏░░░░░░ + ctx-ghi-901-4… 42m ago 7 2.9k — — ██░░░░░ default 1h ago 8 — — — — ● connected 2.1 events/sec feedback: https://github.com/rossoctl/cortex/issues/new/choose