Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions cmd/agentop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ agentop is for, and the others are surfaces you visit and leave.
4 14:23:09.40 out observe inference-parser claude-sonnet-5 ↑121.0kB api.anthropic.com

● connected 2.1 events/sec [/anthropic 2 matches] [sort: DURATION▼]
[↑↓] nav [b/f] page [↵] detail [c] columns [u] usage [s] hide passthru/skip [p] pause [/] search [n/N] next/prev [esc] back · [?] keys [q] quit
[b/f] page [↵] detail [c] columns [u] usage [/] search [n/N] next/prev [esc] back [?] keys [q] quit
```

Exchange 3 has no ↓ figure because there was nothing to count:
Expand Down Expand Up @@ -706,9 +706,7 @@ agentop is for, and the others are surfaces you visit and leave.
rows:

```
window 5m 1h [all] 10-26 14:28 → 10-26 20:08
14:28 15:17 16:06 37m 39m 18:41
model tools tok/s
window 5m 1h all ╷10-26 14:28 ╷15:17 ╷16:06 37m 10-26 20:08╷ model tools tok/s
main agent ▂█▃▅▃██▁▄▃▁▃█▁▆▁▂▇█▂▁▁▂████████▁▁▅▁███▅▁ ┆ ▄▁ ┆ ▂▁▆▂▁███▄▁│ 1.6h 29m 85

Survey cortex egress da ▃▂▁ ┆ ┆ │ 4m 1m 92
Expand Down Expand Up @@ -757,8 +755,8 @@ agentop is for, and the others are surfaces you visit and leave.
still running from earlier ("since 12:41:04"), each with its duration and its
command, path or description; a cell with no tool names the request `↵` would
open. `↵` opens the Events pane on the first event listed. `↑`/`↓` scroll the
agent rows, then the host rows, when they do not all fit; the footer offers
them only then. The pane refreshes at most once a second while the stream
agent rows, then the host rows, when they do not all fit; the `?` help lists
them, not the footer. The pane refreshes at most once a second while the stream
delivers that session's events, and every ten seconds while a call is in
flight with nothing new recorded. A failed fetch is retried after 1s, then
2s, 4s … up to 30s, and the first fetch of a visit waits up to 30s, since a
Expand All @@ -784,7 +782,7 @@ agentop is for, and the others are surfaces you visit and leave.
team2 1
default 1

[↑↓/jk] nav [↵] open [L] localhost:47601 [r] reload [?] keys [q] quit
[↵] open [L] localhost:47601 [r] reload [/] search [?] keys [q] quit
```

Without `--kubernetes`, a running local Cortex is connected to directly and
Expand Down Expand Up @@ -862,7 +860,6 @@ Layered on top of all of them:
| `/` | any pane, and the key help | search what the pane shows, as in a text editor: every row stays, the matched characters are highlighted, and the cursor (or, in a text view, the view) jumps to the first match at or after where you pressed `/`, wrapping past the end, as you type. Case-insensitive substring of the text the pane displays: a table's columns that are turned on, at full width (a value cut to `…` matches in full, and so does a column the terminal had no room for); an exchange's or plugin's detail line by line, before it is wrapped; the key help's and the usage chart's lines as drawn. `deny` finds denied events because ACTION shows it. `Enter` keeps the place; `Esc` puts the place and the previous search back; `Enter` on an empty box clears the search. Each pane keeps its own search; the events pane's and an exchange's detail's last while you stay with one session (the detail's carries from exchange to exchange), and none is saved. On the events pane, `Tab` in the prompt turns on `[x] details`: then `Enter`, `n` and `N` find the next row whose detail view shows the query — in either half, every field, the exact capture too. The proxy finds the matches in one pass over memory and the archive (`GET /v1/sessions/{id}/search`), and agentop checks the summary rows it holds itself, so nothing is fetched. The footer counts the matches, and also the matches in events older than the ones agentop holds: Enter on the timeline's `▲` row loads those. A Cortex that predates the search says so in the footer |
| `n` / `N` | any pane with a search, and the key help | next / previous match, wrapping at both ends; in a text view an off-screen match is scrolled to a third of the way down |
| `x` | sessions, agents | erase the row under the cursor, in memory and on disk: the highlighted session, or every session of the highlighted agent — on *All agents*, every session this Cortex holds; that confirmation also shows the size on disk. Asks first, with the count; `y` erases, `n`/`esc` keeps. The cost ledger is kept. An agent still using a session brings it back with its next request. Refused — with the proxy's reason — anywhere but a loopback-only laptop install. Not in the footer; the `?` overlay names it |
| `s` | events | toggle hiding exchanges no plugin acted on (default: shown; an exchange is hidden only when no plugin acted on either half; the events footer shows the hidden count) |
| `c` | events | open the column picker (`↑↓`/`jk` move, `space` toggle, `s` sort, `r` reset, `Esc`/`Enter`/`c` close); the selection and sort are saved on close |
| `s` | column picker | sort by the column under the cursor: descending → ascending → chronological. Pressing it on a different column starts that column descending. `#` is not sortable — its order already *is* chronological |
| `p` | any | pause/resume stream |
Expand Down Expand Up @@ -1926,8 +1923,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.

Expand Down
4 changes: 2 additions & 2 deletions cmd/agentop/tui/agents_projects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,8 @@ func TestAgentsProjects_FooterNamesTheFullLabel(t *testing.T) {
deliver(m, pressCmd(m, enterKey))
onDesc(t, m, agentRowDesc{agent: projAgent, kind: agentRowProject, project: label})
got := m.helpView()
if !strings.Contains(got, sanitizeLabel(label)) || strings.Contains(got, "[space]") {
t.Errorf("footer %q; want %q and no [space]", got, sanitizeLabel(label))
if !strings.HasPrefix(got, sanitizeLabel(label)+" [↵]") || strings.Contains(got, "[space]") {
t.Errorf("footer %q; want it to start with %q and no [space]", got, sanitizeLabel(label))
}
if strings.Contains(got, "\x1b") {
t.Errorf("footer carries a raw escape: %q", got)
Expand Down
18 changes: 3 additions & 15 deletions cmd/agentop/tui/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -648,26 +648,14 @@ type model struct {
detailSearch *detailSearch
detailSearchGen uint64
paused bool
// hideInactive toggles whether passthrough / skip-only messages are
// hidden from the events table. False (default) shows every message —
// the operator asked to see all network traffic, processed or not.
// Toggle with `s` to focus on plugin activity (deny/modify/allow/
// observe). hiddenInactive is the count from the most recent
// rebuildEventsTable, surfaced in the footer so a filtered timeline
// doesn't read as data loss.
hideInactive bool
hiddenInactive int

// olderNotFetched is how many events a session holds that its snapshot did not
// carry, reported by the server, keyed by session id.
//
// Keyed rather than a single number, because snapshots land asynchronously and for
// whichever session was selected when the fetch started. A single field let a late
// snapshot for an abandoned session describe the one on screen, and showed the
// previous session's count in the window between selecting a session and its
// snapshot arriving. Beside hiddenInactive in spirit — both answer "is this the
// whole timeline?" — but that one is a filter the operator chose and this is a
// bound they did not.
// snapshot arriving.
olderNotFetched map[string]int

// paging holds the backward-paging state of any session the operator has walked off
Expand Down Expand Up @@ -2586,7 +2574,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 {
Expand All @@ -2611,7 +2599,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 {
Expand Down
26 changes: 10 additions & 16 deletions cmd/agentop/tui/events_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ import (
// a subagent's.
type subagentBlock struct {
id string
// rows indexes cellContexts, in arrival order, among the rows that passed the
// inactive filter — the same population the row loop renders, so the header's
// rollup counts what expanding would show.
// rows indexes cellContexts, in arrival order — the same population the row loop
// renders, so the header's rollup counts what expanding would show.
rows []int
// tokens and cost are the block's rollup, from the same readings the TOKENS
// and COST cells sort by (rowTokens / rowCostUSD). A request whose response
Expand Down Expand Up @@ -102,23 +101,18 @@ func (m *model) blockOpen(id string, subtask, searching bool) bool {
return subtask
}

// rowInactiveHidden is the hideInactive (`s` toggle) predicate, stated once so the
// row loop and collectSubagentBlocks filter the same population: a block's rollup
// must count the rows expanding it would show, and a second spelling of the
// predicate here would drift with the first edit to either.
func (m *model) rowInactiveHidden(ctxs []cellContext, partner map[int]int, j int) bool {
return m.hideInactive && eventInactive(ctxs[j].invs) && !partnerActive(ctxs, partner, j)
// rowQuiet reports whether row j is background traffic: no plugin acted on it or on its
// partner. An unbridged CONNECT has no invocations, so it is quiet unless a gate denied it.
func rowQuiet(ctxs []cellContext, partner map[int]int, j int) bool {
return eventInactive(ctxs[j].invs) && !partnerActive(ctxs, partner, j)
}

// collectSubagentBlocks groups the rows that survive the inactive filter by their
// `subagent` field. Nil when no row names one, which is every session without
// Claude Code or Bob subagents — those rebuild exactly as before.
func (m *model) collectSubagentBlocks(ctxs []cellContext, partner map[int]int) map[string]*subagentBlock {
// collectSubagentBlocks groups the rows by their `subagent` field. Nil when no row
// names one, which is every session without Claude Code or Bob subagents — those
// rebuild exactly as before.
func (m *model) collectSubagentBlocks(ctxs []cellContext) map[string]*subagentBlock {
var blocks map[string]*subagentBlock
for j, cc := range ctxs {
if m.rowInactiveHidden(ctxs, partner, j) {
continue
}
id := cc.row.event.Subagent
if id == "" {
continue
Expand Down
52 changes: 0 additions & 52 deletions cmd/agentop/tui/events_blocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,58 +453,6 @@ func TestBlocks_CollapseStateIsPerSession(t *testing.T) {
}
}

// The block's population is the rows the pane would show: hideInactive hides a
// subagent's whole exchange, and a block with no surviving rows leaves no header
// behind — a header naming nothing is worse than no header, because it claims a
// subagent the filter just said produced nothing visible.
func TestBlocks_RollupFollowsTheInactiveFilter(t *testing.T) {
active := func(id, sub string, phase pipeline.SessionPhase) pipeline.SessionEvent {
return pipeline.SessionEvent{
Direction: pipeline.Outbound, Phase: phase, Host: "ete", RequestID: id, Subagent: sub,
Invocations: &pipeline.Invocations{Outbound: []pipeline.Invocation{
{Plugin: "inference-parser", Action: pipeline.ActionObserve},
}},
}
}
inactive := func(id, sub string, phase pipeline.SessionPhase) pipeline.SessionEvent {
return pipeline.SessionEvent{
Direction: pipeline.Outbound, Phase: phase, Host: "ete", RequestID: id, Subagent: sub,
}
}
events := []pipeline.SessionEvent{
active("m1", "", pipeline.SessionRequest),
active("a1", "a1", pipeline.SessionRequest),
// a1's response is inactive but kept: its partner is shown (an exchange
// hides whole or not at all).
inactive("a1", "a1", pipeline.SessionResponse),
active("m2", "", pipeline.SessionRequest),
// a2's whole exchange is inactive: no block, no header.
inactive("a2", "a2", pipeline.SessionRequest),
inactive("a2", "a2", pipeline.SessionResponse),
}
m := &model{selectedSess: "s", events: map[string][]pipeline.SessionEvent{"s": events}, hideInactive: true}
m.eventsTbl = newEventsTable()
m.rebuildEventsTable()

if _, ok := m.subagentBlocks["a2"]; ok {
t.Fatal("a2 has a block despite every row being hidden")
}
// Rendered: m1, header(a1), m2 — collapsed by default, so the kept exchange
// sits behind the header rather than on screen. No a2 header anywhere.
if got := len(m.eventsTbl.Rows()); got != 3 {
t.Fatalf("rendered rows = %d, want 3", got)
}
for i, b := range m.headerRows {
if b.id == "a2" {
t.Errorf("header for a2 at row %d", i)
}
}
// a1's header counts what expanding it would show: the kept exchange, 1 msg.
if h := m.eventsTbl.Rows()[1][0]; !strings.Contains(h, "1 msg") {
t.Errorf("a1 header = %q, want the kept exchange counted", h)
}
}

// The Timeline's Enter names subagent rows as readily as the conversation's, and
// a subagent's row inside a collapsed block is not on screen — the reveal must
// open the block rather than wait forever for a row that cannot appear.
Expand Down
Loading
Loading