diff --git a/cmd/agentop/README.md b/cmd/agentop/README.md index 48fc40ccd..176d7e4c0 100644 --- a/cmd/agentop/README.md +++ b/cmd/agentop/README.md @@ -237,7 +237,7 @@ subcommand if a title looks wrong. The UI has these panes. `Enter` drills in; `Esc` backs out. **Sessions is the only pane you land on.** Pipeline (`P`), Usage (`u`), Timeline -(`T`), Agents (`A`) and the plugin catalog (`C`) are each opened by a key from the session views +(`T`) and Agents (`A`) are each opened by a key from the session views and return to the pane you pressed it on. There is no tab strip: Sessions is what agentop is for, and the others are surfaces you visit and leave. @@ -293,8 +293,8 @@ agentop is for, and the others are surfaces you visit and leave. `session.max_sessions` eviction takes a row off it. Enter opens an old session like any other; its events are read back from disk a page at a time — the latest on Enter, older ones from the timeline's first row, as for a resident session — so a long one - costs no more to open than a short one. `X` erases all of it, after asking; see - the keybindings below. + costs no more to open than a short one. `x` on the agents pane's *All agents* row + erases all of it, after asking; see the keybindings below. **Every figure in this table is a per-session total**, summed over that session's whole history rather than over a clock window — which is why its @@ -601,13 +601,18 @@ agentop is for, and the others are surfaces you visit and leave. `P` from Sessions, Events or Detail; `Esc` returns to whichever of those it was opened from. Columns: position, direction, plugin name, DEPS (✓/✗ — see "Plugin dependencies" below), writes, body access, event count. `e` opens - the editor. Outside the viewer, `agentop pipeline get` prints the same + the editor. Under the chain, an `── available ──` divider lists every plugin the + running binary can build (`/v1/plugins`) that the chain does not run, so you can + see what to add before you edit. Those rows have no position, direction, DEPS or + events, and `Enter` on one opens its detail. The list is fetched each time `P` + opens the pane. This section replaced the plugin catalog pane, which had its own + key, `C`. Outside the viewer, `agentop pipeline get` prints the same composition — plus each plugin's description and config — and `--json` emits `/v1/pipeline`'s own shape for a script. It has no DEPS or event count: one is derived from the chain rather than reported by the proxy, the other counts invocations in cached session events, which a one-shot command has none of. -- **Plugin detail**: drill-into-row for Pipeline or Catalog. Shows +- **Plugin detail**: drill-into-row for a Pipeline row, available rows included. Shows description, position, reads/writes, body access, plugin config, and per-dependency satisfaction status against the active chain. - **Usage**: time-bucketed charts of volume, errors, latency and cost, @@ -765,36 +770,11 @@ agentop is for, and the others are surfaces you visit and leave. before the proxy captured agent ids show their subagents as one row; a client Cortex does not recognise shows host rows alone. A proxy too old to serve the endpoint gets a line saying so. -- **Catalog**: registered-plugin browser, opened by `C` from any - session-view pane. Lists every plugin the running binary knows how to - construct, including ones not in the active pipeline. Useful for - discovering what's available before adding to the pipeline. Sourced - from `/v1/plugins`. - - REQUIRES lists a plugin's hard dependencies comma-separated; an either-or - group appears as one entry joined by `|`. Both are checked against the - ACTIVE pipeline in the Pipeline pane's DEPS column, not here — this pane - lists what the binary can build, not what is wired up. - - ``` - agentop · http://localhost:9094 · catalog - - NAME REQUIRES DESCRIPTION - jwt-validation Validate inbound JWTs against JWKS - token-exchange RFC 8693 exchange for a target audience - mcp-parser Parse MCP JSON-RPC requests and results - inference-parser Parse LLM chat/completions traffic - ibac mcp-parser Intent-based access control - tool-prune inference-parser Drop unused tool definitions - - [↑↓] nav [↵] plugin detail [r] refresh [esc] back [?] keys [q] quit - ``` - - **Kubernetes Namespaces** (optional): the way in when agentop has no endpoint to connect to — one row per namespace holding an AuthBridge agent, then a Pods pane, then an automatic `kubectl port-forward` into the session view. Shown when `--endpoint` was not given and either no local Cortex is answering - or `--kubernetes` was passed; `[l]` leaves it for the Cortex on this machine. + or `--kubernetes` was passed; `[L]` leaves it for the Cortex on this machine. ``` agentop · pick namespace @@ -804,7 +784,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 + [↑↓/jk] nav [↵] open [L] localhost:47601 [r] reload [?] keys [q] quit ``` Without `--kubernetes`, a running local Cortex is connected to directly and @@ -820,10 +800,9 @@ Layered on top of all of them: 1. the current pane, highlighted — what it shows, then its own keys; 2. **GO TO ANOTHER PANE** — the keys that leave, each naming the pane it opens and what is on it. Rendered per pane and only where the - key actually works: all four (`u`, `P`, `C`, `$`) from the session - views, `C` alone on Usage, and on the two pickers the heading kept - with a line saying they open once you're connected, rather than four - dead keys; + key actually works: `u`, `P` and `$` from the session views, and on + the two pickers the heading kept with a line saying they open once + you're connected, rather than dead keys; 3. **THE DRILL PATH** — `namespaces → pods → sessions → events → event detail` on one line, since that spine is also what `Esc` walks back. If you're on one of its five panes it's in brackets; the four @@ -872,9 +851,9 @@ Layered on top of all of them: | `?` | any (not while searching or mid-edit) | open the key-help overlay (`?`/`Esc`/`q` closes) | | `↑ ↓` / `k j`, `b`/`f`, `u`/`d`, `g`/`G` | key help | scroll the overlay | | `↑ ↓` / `k j` | picker, list | navigate rows | -| `Enter` | namespaces | open the namespace | -| `l` | namespaces | connect directly to this machine's Cortex, or to `localhost:9094` when none is installed | -| `Enter` | pods | port-forward + connect | +| `Enter` / `→` / `l` | namespaces | open the namespace | +| `L` | namespaces | connect directly to this machine's Cortex, or to `localhost:9094` when none is installed. Capital, because `l` opens the row here as on every list | +| `Enter` / `→` / `l` | pods | port-forward + connect | | `Esc` | pods | back to namespaces | | `r` | namespaces, pods | reload agent list from cluster | | `Enter` / `→` / `l` | sessions, events | drill into selection; on a subagent block's header row in the events pane, collapse/expand the block instead | @@ -882,17 +861,15 @@ Layered on top of all of them: | `Esc` | sessions | back to the agents picker when the list was reached by picking an agent there; otherwise (picker mode) tear down port-forward and back to pods. Sessions and the agents picker above it are the only panes that tear down — every key-opened surface returns to its caller instead | | `/` | 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 | clear all history: every session this Cortex holds, in memory and on disk. Asks first, with the count and the size on disk; `y` erases, `n`/`esc` keeps. The cost ledger is kept. Refused — with the proxy's reason — anywhere but a loopback-only laptop install. Not in the footer, like `A`: a destructive key should not be advertised on the always-visible line | -| `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*, everything, as `X`. 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, like `X` | +| `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`/`x` 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 | | `y` | detail | yank the event of the section the cursor is in (request or response) to `~/.cortex/agentop-events` (path stays until the next keypress) | | `Tab` | detail | jump to the other section's title: request or response | -| `g` / `G` | lists | jump to top / bottom. In the events timeline this also sets where the *next* session opens — see [Where a session opens](#where-a-session-opens) | +| `g` / `G` | lists | jump to top / bottom. In the events timeline this also sets where the *next* session opens — see [Where a session opens](#where-a-session-opens). On a paged-back events timeline, `G` also goes back to the live tail and resumes updates | | `Enter` on the `▲` row | events | load the page before the oldest event shown. When a session holds more events than one response, the timeline's first row reads `▲ press Enter to load N older events`, and the footer says `N older (▲ at top)` | -| `t` | events | back to the live tail from a paged-back timeline — resumes receiving updates | | `u` | sessions, events, detail | open the usage charts (sessions: all sessions; events/detail: the selected session) | | `T` | sessions, events, detail | open the timeline (sessions: the highlighted row; events/detail: the selected session) | | `w` | timeline | cycle window: 5m / 1h / 24h / all, only the windows shorter than the session | @@ -906,23 +883,19 @@ Layered on top of all of them: | `w` | agents | cycle the pane's window, drawer open or not: the rows, the title and the breakdown move together through the same four spans. Opens on today; the drawer's own span on other panes is left alone | | `m` | usage | cycle metric: tokens / requests / errors / latency / cost | | `w` | usage | cycle window: 10m / 1h / 6h | -| `b` | usage | cycle breakdown: none / status / method / plugin / host (not offered for latency — there is no per-label latency — or under an agent or project scope) | -| `s` | usage | toggle between this session and all sessions | +| `o` | usage | cycle breakdown: none / status / method / plugin / host (not offered for latency — there is no per-label latency — or under an agent or project scope). Not `b`, which pages up everywhere else. The pane's scope comes from where `u` was pressed: all sessions from Sessions, the session being read from Events or Detail | | `Esc` | usage | back to the pane it was opened from | | `P` | sessions, events, detail | open the pipeline. Capital `P` because lowercase `p` pauses the stream and has no replacement worth the trade — `space` and `d` page the table, except on the agents pane, where `space` opens projects and `d`, `PgDn` and `f` still page down | | `Esc` | pipeline | back to the pane `P` was pressed on | -| `C` | any session-view pane (not the picker) | open the registered-plugin catalog. Was `P` until the pipeline took that letter | -| `r` | catalog | refresh the catalog from `/v1/plugins` | | `A` | any session-view pane (not the picker) | open the per-agent breakdown — each coding agent's sessions, when it was last seen, and what it has spent today (`w` moves the window), plus a row for any agent that owns a listed session but has spent nothing in it, since the sessions list is not limited to today and every session in it needs a row to scope to. Capital `A` because lowercase `a` cycles the spend drawer's axis. Refetches on every press and opens however many agents it finds, one or none included; pressed on the agents pane it only refreshes the rows. Not in the footer, for width; the `?` overlay names it | | `↑↓` / `jk` | agents | move the cursor | -| `space` | agents | on a sub-row, close the parent and move the cursor there; on an agent row that opens, the same as `↵`; on any other row, it pages down. Offered only when sessions record a project; the `Other` row never opens | | `↵` | agents | on a row that opens (sessions record a project), open it into its projects or close it. Opening puts the cursor on its `All projects` sub-row, so `↵` `↵` lists the agent's sessions. On any other row, scope to the agent under the cursor and list its sessions, whichever pane `A` was pressed on — including the agent already scoped, which stays scoped. **The first row, All agents, clears the scope** — from its `All projects` sub-row when sessions record a project. It reaches the sessions list, the usage pane, and the spend band and its drawer — except on the agents pane itself, where the band and the drawer follow the highlighted row instead of the committed scope; `agentop cost --agent` is a separate process. On a project sub-row, `↵` scopes to that project and its agent; on a project under All agents, to the project only; on the project `Other`, to the sessions and spend that record no project. `All projects` clears only the project scope. `x` and `S` act on the parent on the open row and on `All projects`, and do nothing on a project or `Other` sub-row | | `S` | agents | choose the inference server the highlighted agent's new sessions use: a picker over the pane, its cursor on what the agent has now. `↵` applies the highlighted entry, `Esc`/`q`/`Ctrl+C` close it, and an entry the config file already holds writes nothing. Opens only on an agent's row, when agentop is attached to this machine's Cortex and its `inference-router` routes; elsewhere a panel says why. See [Choosing an agent's server](#choosing-an-agents-server-s) | | `S` | sessions | move the highlighted session to another server: a picker, its cursor on the server the session uses now, so `↵` at once changes nothing. Opens only when agentop is attached to this machine's Cortex and its `inference-router` routes; elsewhere a notice says why | | `Esc` | agents | back to the pane `A` was pressed on, leaving the scope as it is. When the picker opened itself at startup, or was reached with `Esc` from the sessions list, it is the level above that list instead, and `Esc` backs out as `Esc` on sessions does: to the pods picker, or nowhere with `--endpoint` | | `e` | pipeline | edit pipeline subtree in `$EDITOR` | | `y` | edit/diff | apply the edit | -| `N` | edit/diff | abort the edit | +| `n` / `Esc` | edit/diff | cancel the edit | | `r` | edit/error | retry: re-open the editor (post-edit failure) or refetch (fetch failure) | | `Esc` | edit/{fetching,editing,applying} | abort the edit, return to Pipeline pane | | `Esc` | edit/{waiting,rollback} | background the watch; result lands as a footer flash | @@ -1003,7 +976,7 @@ two agents are listed, and the agents pane `SESSIONS` and `LAST SEEN` once sessi name their agent. Those two describe the whole sessions list; `COST ` is the pane's only windowed column, and `w` moves it. -**`↵` opens an agents row into its projects, and closes it.** `space` does too. An open row shows `All projects` +**`↵` opens an agents row into its projects, and closes it.** An open row shows `All projects` (the agent's figures), one row per project, then `Other`. A project row shows the last path segment, or the shortest unique tail of segments when two share it, for example `github.com/kagenti/kagenti-extensions` and `git/kagenti/kagenti-extensions`. `Other` @@ -1564,7 +1537,7 @@ archive got full, and an `error:` line when the agent failed. The exit status is **What it does not change.** A session that Cortex captured live is skipped, and the import never changes it. An imported copy that is as new as its transcript is skipped. A newer transcript replaces the imported copy, and only its new -turns are counted as cost. A session that you erased with `x` or `X` comes back +turns are counted as cost. A session that you erased with `x` comes back as an imported session while its transcript is still on disk. Its cost is not counted again, because the erase kept the ledger rows. @@ -1644,7 +1617,7 @@ defaults. To change the pipeline, see [Editing the pipeline](#editing-the-pipeli Press `e` on the Pipeline pane to edit the runtime `pipeline:` subtree in `$EDITOR` (or `vi` if unset). On save, agentop shows a diff and asks -`apply this change? (y/N)`. Confirming writes the change back, then polls the +`apply this change? [y] apply [n] cancel`. `y` writes the change back, then polls the framework's `/reload/status` until the reload completes (success or failure). Where it writes depends on what you are connected to, not on how agentop was @@ -1732,13 +1705,13 @@ cluster, or about a second later locally: • [outbound] ibac pos 1: Requires "mcp-parser", but it is not in the outbound chain ``` -The y/N prompt becomes "apply anyway? (y/N)" — agentop's check is +The prompt becomes "apply anyway? [y] apply [n] cancel" — agentop's check is non-blocking. The framework's own validateRelationships is the source of truth and will fire again at reload regardless. -Validation is silently skipped when the catalog isn't loaded -(operator hasn't pressed `P` yet). Visit the catalog pane once to -populate it for the rest of the session. +Validation is silently skipped when the catalog isn't loaded. `P` loads +it each time it opens the Pipeline pane, so this happens only when that +fetch failed. #### Agent-name resolution diff --git a/cmd/agentop/tui/agents_nav_test.go b/cmd/agentop/tui/agents_nav_test.go index 03aba380a..f76eed7a2 100644 --- a/cmd/agentop/tui/agents_nav_test.go +++ b/cmd/agentop/tui/agents_nav_test.go @@ -172,19 +172,14 @@ func TestAgentsPane_AOverAListReachedThroughThePickerIsAnOverlay(t *testing.T) { } } -// `A` on the picker above Sessions refreshes it without turning it into an overlay, and so does -// the catalog's round trip: esc still backs out of the connection rather than landing on Sessions. -func TestAgentsPane_ThePickerAboveSessionsSurvivesARefreshAndTheCatalog(t *testing.T) { +// `A` on the picker above Sessions refreshes it without turning it into an overlay: esc still +// backs out of the connection rather than landing on Sessions. +func TestAgentsPane_ThePickerAboveSessionsSurvivesARefresh(t *testing.T) { m := navModel(t, paneSessions, true) m.enterAgentsAtStartup() m = pressA(t, m, navRows()) - m.handleKey(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'C'}}) - if m.pane != paneCatalog { - t.Fatalf("`C` landed on %v", m.pane) - } - pressEsc(m) if m.pane != paneAgents { - t.Fatalf("esc from the catalog landed on %v, want the picker", m.pane) + t.Fatalf("`A` landed on %v, want the picker", m.pane) } pressEsc(m) if m.pane != panePods { diff --git a/cmd/agentop/tui/agents_pane.go b/cmd/agentop/tui/agents_pane.go index a73ac4f89..7d15c9854 100644 --- a/cmd/agentop/tui/agents_pane.go +++ b/cmd/agentop/tui/agents_pane.go @@ -267,8 +267,8 @@ func (m *model) fetchAgentRowsCmd(open agentsOpen, from paneID) tea.Cmd { // agentsColumns is the table's declared layout, at the width it wants on a wide terminal. // -// A FUNCTION RATHER THAN A LITERAL INSIDE newAgentsTable, matching pipelineColumns and -// catalogColumns, because layout() has to re-fit these on every resize and must do it from +// A FUNCTION RATHER THAN A LITERAL INSIDE newAgentsTable, matching pipelineColumns, +// because layout() has to re-fit these on every resize and must do it from // THESE definitions rather than from the live table's columns — refitting the live ones // compounds each narrowing, so widening the terminal back up never restores what it took away. // @@ -290,7 +290,7 @@ func agentsColumns(window string) []table.Column { // be worth a picker. // // ONE FETCH FROM initSessionView, which is the single place every entry point converges on: -// `--endpoint` mode's Init, the pod picker's portForwardReadyMsg, and `[l]`'s local endpoint all +// `--endpoint` mode's Init, the pod picker's portForwardReadyMsg, and `[L]`'s local endpoint all // call it, and each replaces m.client first. Hooking it there rather than in Init is what makes // the gate run again when the operator backs out to the pod picker and enters a DIFFERENT pod — // a different proxy has different agents on it, and the answer from the previous one is not an diff --git a/cmd/agentop/tui/agents_pane_test.go b/cmd/agentop/tui/agents_pane_test.go index eb67ea7c2..c0d60c9c3 100644 --- a/cmd/agentop/tui/agents_pane_test.go +++ b/cmd/agentop/tui/agents_pane_test.go @@ -169,13 +169,13 @@ func TestAgentRowsFromBuckets_MoneySaturatesRatherThanWrapping(t *testing.T) { // esc leaves the AGENTS pane and lands where `A` was pressed. // -// A KEY-OPENED SURFACE MUST RETURN TO ITS CALLER, which is the rule paneCatalog's own esc -// case states and the reason the sessions pane is the only one whose esc costs the +// A KEY-OPENED SURFACE MUST RETURN TO ITS CALLER, which is the rule every key-opened +// pane's esc case states and the reason the sessions pane is the only one whose esc costs the // connection. Without a case of its own a new pane is a DEAD END: esc falls through, the // reader is stuck, and the only way out is `q`. // // The paneNone fallback is Sessions rather than the pane enum's zero value. It is reachable -// rather than defensive — the same way paneCatalog's is — and Sessions is the one pane that is +// rather than defensive, and Sessions is the one pane that is // always a defensible place to land; falling back to the zero value would drop the reader on // the Kubernetes namespace picker, tearing down nothing but looking like the connection went // away. diff --git a/cmd/agentop/tui/agents_projects_test.go b/cmd/agentop/tui/agents_projects_test.go index 2f30feeff..0e2de43d2 100644 --- a/cmd/agentop/tui/agents_projects_test.go +++ b/cmd/agentop/tui/agents_projects_test.go @@ -253,7 +253,7 @@ func onDesc(t *testing.T, m *model, d agentRowDesc) { func openClaudeCode(t *testing.T, m *model) { t.Helper() onRow(t, m, projAgent) - deliver(m, pressCmd(m, spaceKey)) + deliver(m, pressCmd(m, enterKey)) } var ( @@ -296,7 +296,7 @@ func TestAgentsProjects_NoProjectsNoMarkerAndSpacePagesDown(t *testing.T) { } } -func TestAgentsProjects_SpaceOnAnAgentFetchesItsProjects(t *testing.T) { +func TestAgentsProjects_EnterOnAnAgentFetchesItsProjects(t *testing.T) { m, asked := projectsModel(t, defaultProjectSeries) openClaudeCode(t, m) if q := asked(); !hasQuery(q, "agent=claude-code", "group=project") { @@ -316,10 +316,10 @@ func TestAgentsProjects_SpaceOnAnAgentFetchesItsProjects(t *testing.T) { } } -func TestAgentsProjects_SpaceOnAllAgentsFetchesWithoutAgent(t *testing.T) { +func TestAgentsProjects_EnterOnAllAgentsFetchesWithoutAgent(t *testing.T) { m, asked := projectsModel(t, defaultProjectSeries) onRow(t, m, "") - deliver(m, pressCmd(m, spaceKey)) + deliver(m, pressCmd(m, enterKey)) q := asked() if !hasQuery(q, "group=project") { t.Fatalf("queries %v; want a group=project one", q) @@ -380,11 +380,23 @@ func TestAgentsProjects_OpenStateAndCursorSurviveRefetchAndW(t *testing.T) { } } -func TestAgentsProjects_SpaceOnASubRowClosesTheParent(t *testing.T) { +// Space no longer closes a row from a sub-row: it is the table's page-down, as everywhere. +// Enter on the open agent row is how to close it. +func TestAgentsProjects_SpaceOnASubRowDoesNotCloseTheParent(t *testing.T) { m, _ := projectsModel(t, defaultProjectSeries) openClaudeCode(t, m) onDesc(t, m, cortexRow) runCmds(pressCmd(m, spaceKey)) + if !m.agentsExpanded[projAgent] { + t.Error("space closed the row; only Enter on the agent row does") + } +} + +func TestAgentsProjects_EnterOnTheOpenAgentClosesIt(t *testing.T) { + m, _ := projectsModel(t, defaultProjectSeries) + openClaudeCode(t, m) + onDesc(t, m, agentRowDesc{agent: projAgent, kind: agentRowHeading}) + runCmds(pressCmd(m, enterKey)) if len(m.agentsExpanded) != 0 { t.Errorf("rows still open: %v", m.agentsExpanded) } @@ -492,11 +504,11 @@ func TestAgentsProjects_FooterNamesTheFullLabel(t *testing.T) { if got := m.helpView(); !strings.Contains(got, "[↵] projects") { t.Errorf("closed row footer %q; want [↵] projects", got) } - deliver(m, pressCmd(m, spaceKey)) + 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] close") { - t.Errorf("footer %q; want %q and [space] close", got, sanitizeLabel(label)) + if !strings.Contains(got, sanitizeLabel(label)) || strings.Contains(got, "[space]") { + t.Errorf("footer %q; want %q and no [space]", got, sanitizeLabel(label)) } if strings.Contains(got, "\x1b") { t.Errorf("footer carries a raw escape: %q", got) @@ -523,8 +535,8 @@ func TestAgentsProjects_FetchErrorClearsOnCloseAndW(t *testing.T) { m.Update(agentProjectsLoadedMsg{agent: projAgent, err: errors.New("boom"), window: m.agentsSpanDef().window}) } fail() - onDesc(t, m, cortexRow) - runCmds(pressCmd(m, spaceKey)) + onDesc(t, m, agentRowDesc{agent: projAgent, kind: agentRowHeading}) + runCmds(pressCmd(m, enterKey)) if strings.Contains(m.View(), "refresh failed") { t.Error("error still shows after the last row closed") } diff --git a/cmd/agentop/tui/agents_scope_test.go b/cmd/agentop/tui/agents_scope_test.go index dc62c0e96..5c51e5805 100644 --- a/cmd/agentop/tui/agents_scope_test.go +++ b/cmd/agentop/tui/agents_scope_test.go @@ -97,7 +97,7 @@ func TestAgentsPane_EnterListsThePickedAgentsSessionsFromAnyCaller(t *testing.T) {label: "claude-code/2.1.270", Counts: usage.Counts{Requests: 10, PricedRequests: 10}}, {label: "bob-shell/2.0.5", Counts: usage.Counts{Requests: 8}}, } - for _, from := range []paneID{paneSessions, paneEvents, paneDetail, paneUsage, panePipeline, paneCatalog} { + for _, from := range []paneID{paneSessions, paneEvents, paneDetail, paneUsage, panePipeline} { m := &model{ pane: from, previousPane: paneNone, @@ -272,19 +272,19 @@ func TestUsageTitle_NamesTheAgentScope(t *testing.T) { } } -// [b] is omitted from the footer while a scope is active, because it cannot act. +// [o] is omitted from the footer while a scope is active, because it cannot act. // // The wire axis is the agent's while scoped, so there is no second axis to break down by. Same -// treatment the footer already gives [b] under latency, and for the same stated reason: a footer +// treatment the footer already gives [o] under latency, and for the same stated reason: a footer // that advertises an inert key is worse than a shorter footer. func TestUsageFooter_OmitsTheBreakdownKeyWhileScoped(t *testing.T) { m := fitModel(t, paneUsage, 120, 40, nil) - if !strings.Contains(m.helpView(), "[b] breakdown") { - t.Fatal("the unscoped footer does not offer [b]; this test is measuring the wrong thing") + if !strings.Contains(m.helpView(), "[o] breakdown") { + t.Fatal("the unscoped footer does not offer [o]; this test is measuring the wrong thing") } m.agentScope = "claude-code/2.1.270" - if strings.Contains(m.helpView(), "[b] breakdown") { - t.Error("the footer still advertises [b] under an agent scope, where it cannot act") + if strings.Contains(m.helpView(), "[o] breakdown") { + t.Error("the footer still advertises [o] under an agent scope, where it cannot act") } } diff --git a/cmd/agentop/tui/app.go b/cmd/agentop/tui/app.go index ec4c82b19..dcbb34b1e 100644 --- a/cmd/agentop/tui/app.go +++ b/cmd/agentop/tui/app.go @@ -38,7 +38,6 @@ const ( paneDetail panePipeline panePluginDetail - paneCatalog paneUsage // paneAgents shows what each CODING AGENT has spent, and picks which one the views are // scoped to; see agentScope. Not to be confused with paneNamespaces, @@ -83,19 +82,19 @@ type connStateInfo struct { // confirmation) stays in the footer. const flashDuration = 3 * time.Second -// defaultLocalEndpoint is where `[l]` connects when nothing better is known: +// defaultLocalEndpoint is where `[L]` connects when nothing better is known: // the session API's in-cluster default port, reached through an existing // `kubectl port-forward`. Useful when agentop runs inside the mesh, or when the // cluster's pod list isn't visible to their kubeconfig but a tunnel is. // // A local install listens somewhere else entirely (47601 by default), so // RunOptions.LocalEndpoint overrides this with the address read from the -// machine's own Cortex config. Hardcoding 9094 sent `[l]` to the wrong port on +// machine's own Cortex config. Hardcoding 9094 sent `[L]` to the wrong port on // every laptop. const defaultLocalEndpoint = "http://localhost:9094" // localEndpointOr returns the resolved local endpoint, falling back to the -// in-cluster default. One accessor so `[l]`, the footer and the help overlay +// in-cluster default. One accessor so `[L]`, the footer and the help overlay // cannot disagree about where the key goes. func (m *model) localEndpointOr() string { if m.localEndpoint != "" { @@ -116,7 +115,7 @@ func (m *model) localEndpointOr() string { // Local wins when the endpoint on screen IS the local Cortex. Deliberately a // question about the connection rather than about how agentop was started, so // `--endpoint http://127.0.0.1:47601` aimed at your own proxy edits it just -// like a bare `agentop` does, and `[l]` gains the same ability mid-session. +// like a bare `agentop` does, and `[L]` gains the same ability mid-session. // Compared against localEndpoint rather than localEndpointOr(): the fallback // is the in-cluster 9094, and matching that would claim a hand-run // port-forward to a POD is this machine's config file. @@ -176,7 +175,7 @@ func isLoopbackHost(h string) bool { return ip != nil && ip.IsLoopback() } -// localProbeTimeout bounds the pre-connect reachability check for `[l]`. +// localProbeTimeout bounds the pre-connect reachability check for `[L]`. // Without it, a dead localEndpoint would leave the operator in an empty // session view wondering why nothing streams; with it they get a footer // error and stay in the picker. @@ -386,7 +385,7 @@ type model struct { endpoint string client *apiclient.Client - // localEndpoint is what `[l]` connects to and what the footer and help + // localEndpoint is what `[L]` connects to and what the footer and help // overlay name. Resolved from the local Cortex config when there is one. localEndpoint string @@ -716,7 +715,6 @@ type model struct { sessionRowIDs []string eventsTbl table.Model pipelineTbl table.Model - catalogTbl table.Model detailVp viewport.Model // detailDoc is detailVp's text, searched — see searchdoc.go. Shared by message detail // and plugin detail, as the viewport is. @@ -911,7 +909,7 @@ type model struct { // or quit. activePF cluster.PortForward - // localDirect is true when the session view was entered via `[l]` + // localDirect is true when the session view was entered via `[L]` // (direct connection to localEndpoint) rather than by picking a pod. // There is no pod to go back to, so Esc returns to the Namespaces // pane instead of Pods. @@ -1024,7 +1022,6 @@ func New(ctx context.Context, c *apiclient.Client, opts ...Option) tea.Model { sessionsTbl: newSessionsTable(), eventsTbl: newEventsTable(), pipelineTbl: newPipelineTable(), - catalogTbl: newCatalogTable(), agentsTbl: newAgentsTable(), previousPane: paneNone, // paneNone, not the zero value: paneNamespaces is 0, and a return pane @@ -1070,7 +1067,7 @@ func (m *model) initSessionView() tea.Cmd { // ctx / cancel is derived from m.parentCtx so the next session-view // entry has a usable context. // -// When the session was entered via `[l]` there is no pod to return to, +// When the session was entered via `[L]` there is no pod to return to, // so the destination is the Namespaces pane instead. func (m *model) backToPodsPane() { // Cancel current ctx — stops the SSE goroutine and any in-flight @@ -1136,7 +1133,6 @@ func (m *model) backToPodsPane() { // different framework instance with potentially different plugin // versions registered. The next `P` press refetches. m.catalog = nil - m.catalogTbl.SetRows(nil) // pickerHarvested and pickerShowing are deliberately NOT reset here. They are edge-derived: the // next refresh tick recomputes "is the picker showing", finds it disagrees with the recorded // pickerShowing, and clears the budget on that inequality. Resetting them here would make this @@ -1204,7 +1200,7 @@ func (m *model) backToPodsPane() { m.ctx, m.cancel = context.WithCancel(m.parentCtx) if m.localDirect { - // Entered via `[l]`: no pod was ever selected, so the Pods pane + // Entered via `[L]`: no pod was ever selected, so the Pods pane // would render an empty table for a namespace the user never // picked. Go back to where they actually were. m.localDirect = false @@ -1307,9 +1303,8 @@ type catalogLoadedMsg struct { err error } -// loadCatalogCmd fetches /v1/plugins. Called lazily when the user -// presses `P` to enter the catalog pane; the result is cached on the -// model and refreshed on demand. +// loadCatalogCmd fetches /v1/plugins: on each `P`, for the pipeline pane's +// available rows, and kept on the model for the pipeline editor. func (m *model) loadCatalogCmd() tea.Cmd { return func() tea.Msg { cat, err := m.client.GetPluginCatalog(m.ctx) @@ -1843,7 +1838,7 @@ func (m *model) update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, nil } m.catalog = msg.catalog - m.rebuildCatalogTable() + m.rebuildPipelineTable() return m, nil case snapshotLoadedMsg: @@ -2103,12 +2098,12 @@ func (m *model) update(msg tea.Msg) (tea.Model, tea.Cmd) { // // The pod fields are CLEARED rather than assumed empty. They are only // empty when no pod was ever visited: backToPodsPane clears ~20 fields - // but not these, so "pick a pod → esc → [l]" arrives here with + // but not these, so "pick a pod → esc → [L]" arrives here with // selectedNamespace / selectedPod naming the pod and statusURL naming // its closed port-forward. Since pipelineStore falls back to the // ConfigMap branch on exactly those three, leaving them set let `e` // kubectl-apply against a pod the screen was not showing — and poll a - // forward this path never established. Harmless while `[l]` sessions + // forward this path never established. Harmless while `[L]` sessions // were assumed storeless; a wrong-target write once they were not. m.selectedNamespace = "" m.selectedPod = "" @@ -2564,7 +2559,7 @@ func (m *model) paneView() string { if m.namespaces != nil && len(m.namespaces) == 0 && m.pickerErr == "" { body = styleHint.Render( "No Cortex agents found in this cluster.\n" + - "Press [l] to connect to " + m.localEndpointOr() + " (an existing\n" + + "Press [L] to connect to " + m.localEndpointOr() + " (an existing\n" + "port-forward), or use `agentop --endpoint http://...`.") } else { body = m.namespacesTbl.View() @@ -2725,15 +2720,6 @@ func (m *model) paneView() string { case paneTimeline: title = m.sessionHeader(m.timeline.session, "timeline") body = m.timelineBody() - case paneCatalog: - title = fmt.Sprintf("%s · %s · catalog", m.appName(), m.endpoint) - if m.catalog == nil { - body = styleHint.Render("(loading catalog…)") - } else if len(m.catalog.Plugins) == 0 { - body = styleHint.Render("(no registered plugins reported by /v1/plugins)") - } else { - body = m.catalogTbl.View() - } } // The band above every pane is scoped too, so every pane says so; usage and agents word it @@ -2932,7 +2918,7 @@ type RunOptions struct { Endpoint string Lister cluster.Lister PortForwarder cluster.PortForwarder - // LocalEndpoint overrides where `[l]` connects. Empty means + // LocalEndpoint overrides where `[L]` connects. Empty means // defaultLocalEndpoint. LocalEndpoint string // LocalConfigPath and LocalStatsURL describe the Cortex running on this diff --git a/cmd/agentop/tui/catalog_pane.go b/cmd/agentop/tui/catalog_pane.go deleted file mode 100644 index 88c4ffd49..000000000 --- a/cmd/agentop/tui/catalog_pane.go +++ /dev/null @@ -1,86 +0,0 @@ -package tui - -import ( - "strings" - - "github.com/rossoctl/cortex/cmd/agentop/apiclient" - "github.com/rossoctl/cortex/cmd/agentop/tui/table" -) - -// catalogColumns is the full-width column set, fitted to the terminal by layout(). 110 -// declared plus bubbles' two per cell is 116 rendered columns — wider than any default -// terminal — and DESCRIPTION is the column with room to give. -func catalogColumns() []table.Column { - return []table.Column{ - {Title: "NAME", Width: 22}, - {Title: "REQUIRES", Width: 28}, - {Title: "DESCRIPTION", Width: 60}, - } -} - -// newCatalogTable builds the registered-plugin catalog table. Same -// styling as the pipeline table for visual consistency when switching -// between them via the `P` keybind. -func newCatalogTable() table.Model { - t := table.New( - table.WithColumns(catalogColumns()), - table.WithFocused(true), - ) - t.SetStyles(tableStyles()) - return t -} - -// rebuildCatalogTable populates the catalog table from m.catalog. -// Empty rows when the catalog hasn't loaded yet — caller renders -// "(loading…)" in the title. -func (m *model) rebuildCatalogTable() { - if m.catalog == nil { - m.catalogTbl.SetRows(nil) - return - } - rows := make([]table.Row, 0, len(m.catalog.Plugins)) - for _, e := range m.catalog.Plugins { - // Combine Requires and RequiresAny (the "any" group joined by " | ") - // so operators see the full dependency picture in one column. - reqs := []string{} - reqs = append(reqs, e.Requires...) - if len(e.RequiresAny) > 0 { - reqs = append(reqs, strings.Join(e.RequiresAny, "|")) - } - rows = append(rows, table.Row{ - e.Name, - strings.Join(reqs, ", "), - e.Description, - }) - } - m.catalogTbl.SetRows(rows) -} - -// selectedCatalogEntry returns the catalog entry under the cursor as -// a synthetic PipelinePlugin so showPluginDetail can render it. Direction -// is left blank and Position is 0 — showPluginDetail elides those fields -// when empty so the detail view degrades gracefully for catalog entries. -func (m *model) selectedCatalogEntry() *apiclient.PipelinePlugin { - if m.catalog == nil { - return nil - } - rows := m.catalogTbl.Rows() - i := m.catalogTbl.Cursor() - if i < 0 || i >= len(rows) { - return nil - } - name := rows[i][0] - for _, e := range m.catalog.Plugins { - if e.Name == name { - p := apiclient.PipelinePlugin{ - Name: e.Name, - ReadsBody: e.ReadsBody, - Requires: e.Requires, - RequiresAny: e.RequiresAny, - Description: e.Description, - } - return &p - } - } - return nil -} diff --git a/cmd/agentop/tui/catalog_pane_test.go b/cmd/agentop/tui/catalog_pane_test.go deleted file mode 100644 index 686e535b0..000000000 --- a/cmd/agentop/tui/catalog_pane_test.go +++ /dev/null @@ -1,90 +0,0 @@ -package tui - -import ( - "context" - "strings" - "testing" - - "github.com/rossoctl/cortex/cmd/agentop/apiclient" -) - -func TestRebuildCatalogTable_RendersEntries(t *testing.T) { - m := newPickerModel(context.Background(), nil, nil) - m.catalog = &apiclient.PluginCatalog{ - Plugins: []apiclient.PluginCatalogEntry{ - {Name: "alpha", Description: "First plugin"}, - {Name: "beta", Requires: []string{"alpha"}, Description: "Second"}, - }, - } - m.rebuildCatalogTable() - rows := m.catalogTbl.Rows() - if len(rows) != 2 { - t.Fatalf("rows = %d, want 2", len(rows)) - } - if rows[0][0] != "alpha" || !strings.Contains(rows[0][2], "First plugin") { - t.Errorf("rows[0] = %+v", rows[0]) - } - if rows[1][0] != "beta" || !strings.Contains(rows[1][1], "alpha") { - t.Errorf("rows[1] = %+v (expected requires=alpha)", rows[1]) - } -} - -func TestSelectedCatalogEntry_ReturnsCursorRow(t *testing.T) { - m := newPickerModel(context.Background(), nil, nil) - m.catalog = &apiclient.PluginCatalog{ - Plugins: []apiclient.PluginCatalogEntry{ - {Name: "alpha", Description: "First", Requires: []string{"x"}}, - {Name: "beta", Description: "Second"}, - }, - } - m.rebuildCatalogTable() - m.catalogTbl.SetCursor(1) - got := m.selectedCatalogEntry() - if got == nil { - t.Fatal("expected entry, got nil") - } - if got.Name != "beta" { - t.Fatalf("Name = %q, want beta", got.Name) - } -} - -func TestRebuildCatalogTable_NilCatalogClearsRows(t *testing.T) { - m := newPickerModel(context.Background(), nil, nil) - m.catalog = nil - m.rebuildCatalogTable() - if rows := m.catalogTbl.Rows(); len(rows) != 0 { - t.Fatalf("rows should be empty when catalog nil, got %d", len(rows)) - } -} - -// TestSelectedCatalogEntry_AsPipelinePlugin verifies the converter -// preserves the metadata fields the plugin-detail pane reads, so -// pressing Enter on a catalog row renders the full detail. -func TestSelectedCatalogEntry_AsPipelinePlugin(t *testing.T) { - m := newPickerModel(context.Background(), nil, nil) - m.catalog = &apiclient.PluginCatalog{ - Plugins: []apiclient.PluginCatalogEntry{ - { - Name: "ibac", - Description: "Judge", - Requires: []string{"mcp-parser"}, - }, - }, - } - m.rebuildCatalogTable() - got := m.selectedCatalogEntry() - if got == nil { - t.Fatal("nil entry") - } - if got.Description != "Judge" { - t.Errorf("Description = %q", got.Description) - } - if len(got.Requires) != 1 || got.Requires[0] != "mcp-parser" { - t.Errorf("Requires = %v", got.Requires) - } - // Direction and Position deliberately blank for catalog entries — - // showPluginDetail elides them. - if got.Direction != "" || got.Position != 0 { - t.Errorf("Direction/Position should be zero for catalog entry, got %q/%d", got.Direction, got.Position) - } -} diff --git a/cmd/agentop/tui/clear_test.go b/cmd/agentop/tui/clear_test.go index 87805fa20..f386595df 100644 --- a/cmd/agentop/tui/clear_test.go +++ b/cmd/agentop/tui/clear_test.go @@ -44,13 +44,14 @@ func clearStack(t *testing.T, allowed bool) (*model, *session.Store) { return m, store } -// X asks before it erases, and says what it is about to erase: the count and the size come from -// the archive's own list, not from what agentop happens to hold. -func TestXKey_OpensTheConfirmationWithCounts(t *testing.T) { +// Clear-all asks before it erases, and says what it is about to erase: the count and the size come +// from the archive's own list, not from what agentop happens to hold. It is reached by `x` on All +// agents (erase_test.go); `X` is no longer a key. +func TestClearAll_OpensTheConfirmationWithCounts(t *testing.T) { m, _ := clearStack(t, true) - cmd := m.handleKey(keyRune('X')) + cmd := m.openClearConfirm() if m.clearConfirm == nil || cmd == nil { - t.Fatal("X on the sessions pane opened no confirmation") + t.Fatal("openClearConfirm opened no confirmation") } m.Update(cmd()) view := m.View() @@ -59,10 +60,9 @@ func TestXKey_OpensTheConfirmationWithCounts(t *testing.T) { t.Errorf("the confirmation does not say %q:\n%s", want, view) } } - m.pane = paneEvents m.clearConfirm = nil if m.handleKey(keyRune('X')); m.clearConfirm != nil { - t.Fatal("X opened the confirmation off the sessions pane") + t.Fatal("X opened the confirmation; the key was removed") } } @@ -73,7 +73,7 @@ func TestClearConfirm_YClearsAndResetsState(t *testing.T) { m.events["s1"] = []pipeline.SessionEvent{{Seq: 1}} m.events["gone-from-server"] = []pipeline.SessionEvent{{Seq: 1}} // a cached-only row m.selectedSess = "s1" - m.Update(m.handleKey(keyRune('X'))()) + m.Update(m.openClearConfirm()()) cmd := m.handleKey(keyRune('y')) if cmd == nil { t.Fatal("y sent no clear") @@ -96,7 +96,7 @@ func TestClearConfirm_YClearsAndResetsState(t *testing.T) { func TestClearConfirm_NAndEscCancel(t *testing.T) { for _, k := range []tea.KeyMsg{keyRune('n'), keyRune('N'), {Type: tea.KeyEsc}} { m, store := clearStack(t, true) - m.Update(m.handleKey(keyRune('X'))()) + m.Update(m.openClearConfirm()()) if cmd := m.handleKey(k); cmd != nil || m.clearConfirm != nil { t.Fatalf("%q: confirm=%v cmd=%v, want closed and nothing sent", k.String(), m.clearConfirm, cmd != nil) } @@ -110,7 +110,7 @@ func TestClearConfirm_NAndEscCancel(t *testing.T) { // other than y erases anything. func TestClearConfirm_SwallowsOtherKeys(t *testing.T) { m, store := clearStack(t, true) - m.Update(m.handleKey(keyRune('X'))()) + m.Update(m.openClearConfirm()()) for _, k := range []tea.KeyMsg{keyRune('u'), keyRune('?'), keyRune('/'), keyRune('H'), keyRune('X'), keyRune('$'), {Type: tea.KeyEnter}} { if cmd := m.handleKey(k); cmd != nil { t.Errorf("%q returned a command", k.String()) @@ -129,7 +129,7 @@ func TestClearConfirm_SwallowsOtherKeys(t *testing.T) { func TestClearConfirm_ShowsTheServersRefusal(t *testing.T) { m, store := clearStack(t, false) m.events["s1"] = []pipeline.SessionEvent{{Seq: 1}} - m.Update(m.handleKey(keyRune('X'))()) + m.Update(m.openClearConfirm()()) m.Update(m.handleKey(keyRune('y'))()) if !strings.Contains(m.flash, "loopback only") { t.Fatalf("flash = %q, want the server's reason", m.flash) @@ -148,7 +148,7 @@ func TestSnapshot_FromBeforeAClearIsDropped(t *testing.T) { if _, ok := stale.(snapshotLoadedMsg); !ok { t.Fatalf("snapshot = %T, want snapshotLoadedMsg", stale) } - m.Update(m.handleKey(keyRune('X'))()) + m.Update(m.openClearConfirm()()) m.Update(m.handleKey(keyRune('y'))()) m.Update(stale) if evs := m.events["s1"]; len(evs) != 0 { diff --git a/cmd/agentop/tui/divider_test.go b/cmd/agentop/tui/divider_test.go index ba37a392f..7d23f0f7a 100644 --- a/cmd/agentop/tui/divider_test.go +++ b/cmd/agentop/tui/divider_test.go @@ -28,7 +28,7 @@ func dividerLine(view string) int { func TestDivider_DrawnOnEveryPaneAtEverySize(t *testing.T) { panes := map[string]paneID{ "sessions": paneSessions, "events": paneEvents, "pipeline": panePipeline, - "detail": paneDetail, "catalog": paneCatalog, "usage": paneUsage, + "detail": paneDetail, "usage": paneUsage, "namespaces": paneNamespaces, "pods": panePods, } for _, dim := range fitSizes { diff --git a/cmd/agentop/tui/edit_overlay.go b/cmd/agentop/tui/edit_overlay.go index 2ab4c58c8..1100351ff 100644 --- a/cmd/agentop/tui/edit_overlay.go +++ b/cmd/agentop/tui/edit_overlay.go @@ -40,7 +40,7 @@ type editState struct { // /reload/status confirms it landed. Captured together when the cycle // begins, and read from here rather than off the model for the rest of it, // so one transaction always targets one proxy — an operator who switches - // pods or presses [l] mid-edit cannot have the apply land somewhere the + // pods or presses [L] mid-edit cannot have the apply land somewhere the // fetch never came from. store edit.Store statusURL string @@ -128,9 +128,9 @@ func renderEditOverlay(s editState, width, height int) string { b.WriteString(s.diff) b.WriteString("\n") if len(s.validationErrs) > 0 { - b.WriteString(styleHint.Render("apply anyway? (y/N)")) + b.WriteString(styleHint.Render("apply anyway? [y] apply [n] cancel")) } else { - b.WriteString(styleHint.Render("apply this change? (y/N)")) + b.WriteString(styleHint.Render("apply this change? [y] apply [n] cancel")) } case editPhaseApplying: b.WriteString(styleTitle.Render("Edit pipeline")) diff --git a/cmd/agentop/tui/edit_overlay_test.go b/cmd/agentop/tui/edit_overlay_test.go index d7a4a41ad..be53f1a72 100644 --- a/cmd/agentop/tui/edit_overlay_test.go +++ b/cmd/agentop/tui/edit_overlay_test.go @@ -123,7 +123,7 @@ func TestEditOverlayRender_Diff(t *testing.T) { if !strings.Contains(out, "old line") || !strings.Contains(out, "new line") { t.Fatalf("diff content missing:\n%s", out) } - if !strings.Contains(out, "(y/N)") { + if !strings.Contains(out, "[y] apply [n] cancel") { t.Fatalf("confirm prompt missing:\n%s", out) } } diff --git a/cmd/agentop/tui/footer_fit_test.go b/cmd/agentop/tui/footer_fit_test.go index 41390a539..89ed52ae5 100644 --- a/cmd/agentop/tui/footer_fit_test.go +++ b/cmd/agentop/tui/footer_fit_test.go @@ -69,7 +69,7 @@ func TestFitHintLine_DropsFromTheFront(t *testing.T) { func TestFitHintLine_EveryPaneFitsAt80(t *testing.T) { for _, pane := range []paneID{ paneNamespaces, panePods, paneSessions, paneEvents, - paneDetail, paneUsage, paneTimeline, panePipeline, panePluginDetail, paneCatalog, + paneDetail, paneUsage, paneTimeline, panePipeline, panePluginDetail, } { m := &model{pane: pane, eventColumns: defaultColumnSelection()} got := fitHintLine(m.helpView(), 80) diff --git a/cmd/agentop/tui/help_overlay.go b/cmd/agentop/tui/help_overlay.go index 559494b54..2d9476b24 100644 --- a/cmd/agentop/tui/help_overlay.go +++ b/cmd/agentop/tui/help_overlay.go @@ -104,8 +104,7 @@ var helpNavKeys = keyGroup{ notes: []string{ "All three work on every pane, because they move this overlay rather than " + "what is behind it. With it closed they move the pane's own list instead — " + - "except on the usage pane, which has no list: there b cycles the breakdown " + - "and g / G do nothing.", + "except on the usage pane, which has no list: there they do nothing.", }, } @@ -192,13 +191,10 @@ func (jt jumpTarget) name() string { return strings.ToLower(paneName(jt.pane)) } -// jumpTargets are the four keys that leave the pane you are on. +// jumpTargets are the keys that leave the pane you are on. // -// `C` WAS `P` UNTIL THE PIPELINE TOOK THAT LETTER, and this section is the reason -// that swap was cheap: `P`-for-catalog was never shown in any footer, so there -// was close to no muscle memory behind it — and the discoverability problem the -// overlay existed to solve for it is now a titled section rather than one line in -// a group of ten. +// NO `C`: the plugin catalog was its own pane under `C`, and is now the pipeline +// pane's "available" section, so one key shows what runs and what could. var jumpTargets = []jumpTarget{ {key: "u", pane: paneUsage, desc: "charts over the events the proxy has seen — every session from the " + @@ -206,9 +202,7 @@ var jumpTargets = []jumpTarget{ {key: "T", pane: paneTimeline, desc: "the selected session's agents, tools and hosts on a time axis"}, {key: "P", pane: panePipeline, - desc: "the plugin chain this proxy runs, editable in $EDITOR"}, - {key: "C", pane: paneCatalog, - desc: "every plugin the proxy offers, from /v1/plugins"}, + desc: "the plugin chain this proxy runs, editable in $EDITOR, then the plugins it could run"}, {key: "A", pane: paneAgents, desc: "what each coding agent has spent today; pick one to scope the views"}, {key: "$", pane: paneNone, label: "spend", @@ -288,8 +282,8 @@ var paneKeys = map[paneID]keyGroup{ purpose: "Kubernetes agent workloads grouped by namespace; where agentop starts", bindings: []keyBinding{ {"↑↓ / jk", "navigate"}, - {"↵", "open namespace"}, - {"l", "connect to the local session API"}, + {"↵ / → / l", "open namespace"}, + {"L", "connect to the local session API"}, {"r", "reload agent list"}, // `esc` ALONE, not "q · esc": quit is already in ANYWHERE, and `q` here made // this the one pane group that restated a key from it. What is pane-specific @@ -303,7 +297,7 @@ var paneKeys = map[paneID]keyGroup{ purpose: "the agent pods in that namespace, each with a proxy to connect to", bindings: []keyBinding{ {"↑↓ / jk", "navigate"}, - {"↵", "port-forward + connect"}, + {"↵ / → / l", "port-forward + connect"}, {"esc", "back to namespaces"}, {"r", "reload agent list"}, }, @@ -315,8 +309,8 @@ var paneKeys = map[paneID]keyGroup{ bindings: []keyBinding{ {"↑↓ / jk", "navigate"}, {"↵ / → / l", "drill into session"}, - {"X", "clear all history, in memory and on disk (asks first; the cost ledger is kept)"}, {"x", "erase this session, in memory and on disk (asks first; the cost ledger is kept)"}, + {"S", "move this session to another inference server"}, {"esc", "back to the agents picker, else pods picker"}, }, }, @@ -332,7 +326,7 @@ var paneKeys = map[paneID]keyGroup{ {"c then s", "sort by a column: desc → asc → chronological"}, {"⚒ rows", "tool calls. DURATION, for a tool: from the reply to the next request of the same agent"}, {"↵ on ▲ row", "load the page before the oldest event shown"}, - {"t", "back to the live tail (resumes updates)"}, + {"G", "the newest row; when paged back, the live tail (resumes updates)"}, {"esc / ← / h", "back to sessions"}, }, }, @@ -349,7 +343,7 @@ var paneKeys = map[paneID]keyGroup{ }, panePipeline: { title: "PIPELINE (this pane)", - purpose: "the plugin chain this proxy runs, in the order it runs them", + purpose: "the plugin chain this proxy runs, in order, then the plugins available to add", bindings: []keyBinding{ {"↑↓ / jk", "navigate"}, {"↵ / → / l", "plugin detail"}, @@ -371,8 +365,7 @@ var paneKeys = map[paneID]keyGroup{ bindings: []keyBinding{ {"m", "cycle metric (tokens/requests/errors/latency/cost)"}, {"w", "cycle window (10m/1h/6h)"}, - {"b", "cycle breakdown (none/status/method/plugin/host; not for latency or a scope)"}, - {"s", "toggle session / all sessions"}, + {"o", "cycle breakdown (none/status/method/plugin/host; not for latency or a scope)"}, {"esc", "back"}, }, }, @@ -387,16 +380,6 @@ var paneKeys = map[paneID]keyGroup{ {"esc", "back"}, }, }, - paneCatalog: { - title: "PLUGIN CATALOG (this pane)", - purpose: "every plugin the proxy offers, whether or not the pipeline runs it", - bindings: []keyBinding{ - {"↑↓ / jk", "navigate"}, - {"↵ / → / l", "plugin detail"}, - {"r", "refresh from /v1/plugins"}, - {"esc / ← / h", "back"}, - }, - }, paneAgents: { title: "AGENTS (this pane)", // "coding" is load-bearing and pinned by @@ -409,9 +392,6 @@ var paneKeys = map[paneID]keyGroup{ {"↑↓ / jk", "navigate"}, // Said here too because the footer only describes the row under the cursor. {"↵", "open/close a row's projects; on a sub-row, scope and list its sessions"}, - // One line each, at 76 columns here and 90 in the note: Other under a project is - // where spend from before the upgrade lands, so a month view can be mostly Other. - {"space", "close from a sub-row; COST adds up, SESSIONS overlap, pre-upgrade is Other"}, {"S", "choose the inference server this agent's new sessions use"}, {"w", "cycle the window: the rows and the breakdown together"}, {"x", "erase this agent's sessions (asks first); on All agents, everything"}, @@ -431,6 +411,9 @@ var paneKeys = map[paneID]keyGroup{ // views can honour it rather than whether any can. notes: []string{ "Opens at 2 agents. Agent/project scopes sessions, usage pane, spend band. Other: unknowns.", + // Other under a project is where spend from before the upgrade lands, so a month + // view can be mostly Other. + "COST adds up; SESSIONS overlap; pre-upgrade spend is Other.", }, }, } @@ -439,7 +422,7 @@ var paneKeys = map[paneID]keyGroup{ // the overlay is stable across openings (Go map iteration is random). var otherPaneOrder = []paneID{ paneNamespaces, panePods, paneSessions, paneEvents, - paneDetail, paneAgents, paneUsage, paneTimeline, panePipeline, panePluginDetail, paneCatalog, + paneDetail, paneAgents, paneUsage, paneTimeline, panePipeline, panePluginDetail, } // helpKeyColWidth is the fixed width of the key column so descriptions diff --git a/cmd/agentop/tui/help_overlay_test.go b/cmd/agentop/tui/help_overlay_test.go index 7438d37b9..6d34878e5 100644 --- a/cmd/agentop/tui/help_overlay_test.go +++ b/cmd/agentop/tui/help_overlay_test.go @@ -129,7 +129,7 @@ func TestHelpOverlayRendersAndEmphasizesCurrentPane(t *testing.T) { func TestHelpOverlayAvailableInSessionPanes(t *testing.T) { for _, pane := range []paneID{ paneSessions, paneEvents, paneDetail, - panePipeline, panePluginDetail, paneCatalog, + panePipeline, panePluginDetail, } { m := newPickerModel(context.Background(), &fakeLister{}, nil) m.pane = pane @@ -301,17 +301,17 @@ func TestFooterHintsMentionUsageKey(t *testing.T) { // The usage pane's own footer must not fall through to the bare default. m.pane = paneUsage got := m.helpView() - for _, want := range []string{"[m] metric", "[w] window", "[b] breakdown"} { + for _, want := range []string{"[m] metric", "[w] window", "[o] breakdown"} { if !strings.Contains(got, want) { t.Errorf("usage footer omits %q:\n %s", want, got) } } - // Latency has no per-label breakdown, so the footer must not advertise [b] + // Latency has no per-label breakdown, so the footer must not advertise [o] // there — a key shown as available but inert reads as a broken binding. m.usage.metric = metricLatency got = m.helpView() - if strings.Contains(got, "[b]") { + if strings.Contains(got, "[o]") { t.Errorf("latency footer advertises the inert breakdown key:\n %s", got) } if !strings.Contains(got, "[m] metric") { @@ -331,8 +331,8 @@ func TestUsageFooterMatchesHandledKeys(t *testing.T) { // been kept in sync by hand — which is the drift the test exists to catch. // // Each key is pressed on a fresh model and counted as handled if it changed the - // pane's state. `m`/`b` cycle enums, `w` refetches with a new window, `s` toggles - // scope; a key the switch stopped handling changes nothing and is reported. + // pane's state. `m`/`o` cycle enums, `w` refetches with a new window; a key the + // switch stopped handling changes nothing and is reported. handled := []string{} for _, probe := range []struct { key rune @@ -340,8 +340,7 @@ func TestUsageFooterMatchesHandledKeys(t *testing.T) { }{ {'m', func(b, a *usageState) bool { return a.metric != b.metric }}, {'w', func(b, a *usageState) bool { return a.windowIdx != b.windowIdx }}, - {'b', func(b, a *usageState) bool { return a.group != b.group }}, - {'s', func(b, a *usageState) bool { return a.session != b.session }}, + {'o', func(b, a *usageState) bool { return a.group != b.group }}, } { mm := &model{pane: paneUsage, selectedSess: "s1"} before := mm.usage @@ -361,13 +360,14 @@ func TestUsageFooterMatchesHandledKeys(t *testing.T) { } } // And the retired ones must be gone from both surfaces. - for _, k := range []string{"[t]", "[g]", "[r]"} { + // `b` pages everywhere now and `s` scope is set by where `u` was pressed. + for _, k := range []string{"[t]", "[g]", "[r]", "[b]", "[s]"} { if strings.Contains(footer, k) { t.Errorf("footer still advertises retired key %s:\n %s", k, footer) } } for _, kb := range paneKeys[paneUsage].bindings { - if kb.keys == "t" || kb.keys == "g" || kb.keys == "r" { + if kb.keys == "t" || kb.keys == "g" || kb.keys == "r" || kb.keys == "b" || kb.keys == "s" { t.Errorf("help overlay still lists retired key %q", kb.keys) } } @@ -475,7 +475,7 @@ func TestHelpOverlayScrolls(t *testing.T) { // The last group must be off-screen initially, and reachable by // scrolling — that is the whole point of this change. - if strings.Contains(mm.View(), "PLUGIN CATALOG") { + if strings.Contains(mm.View(), "PLUGIN DETAIL") { t.Fatal("setup: expected the tail of the reference to be off-screen") } u, _ := mm.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'G'}}) @@ -483,7 +483,7 @@ func TestHelpOverlayScrolls(t *testing.T) { if !mm.helpVp.AtBottom() { t.Fatal("`G` should jump to the bottom of the help body") } - if !strings.Contains(mm.View(), "PLUGIN CATALOG") { + if !strings.Contains(mm.View(), "PLUGIN DETAIL") { t.Fatalf("after scrolling to the bottom, the tail should be visible:\n%s", mm.View()) } @@ -745,3 +745,18 @@ func TestHelp_EventsExplainsToolTime(t *testing.T) { } } } + +// `S` works on Sessions (it moves the highlighted session), so the Sessions group names it, and +// the removed `X` is gone from it. +func TestPaneKeys_SessionsListsSAndNotX(t *testing.T) { + keys := map[string]bool{} + for _, kb := range paneKeys[paneSessions].bindings { + keys[kb.keys] = true + } + if !keys["S"] { + t.Error("the Sessions group does not list `S`") + } + if keys["X"] { + t.Error("the Sessions group still lists the removed `X`") + } +} diff --git a/cmd/agentop/tui/help_pane_map_test.go b/cmd/agentop/tui/help_pane_map_test.go index b774984d1..2f4fcbef5 100644 --- a/cmd/agentop/tui/help_pane_map_test.go +++ b/cmd/agentop/tui/help_pane_map_test.go @@ -411,13 +411,13 @@ func TestHelpNavKeys_MoveTheOverlayOnEveryPane(t *testing.T) { } // And the exception the note names: with the overlay closed, usage is the one pane -// where `b` is not paging and `g` moves nothing. +// where the nav keys move nothing. `b` no longer changes the breakdown there (`o` does). func TestHelpNavKeys_NoteNamesTheOneExceptionCorrectly(t *testing.T) { m := &model{pane: paneUsage, selectedSess: "s1"} before := m.usage.group m.handleKey(keyRune('b')) - if m.usage.group == before { - t.Errorf("`b` no longer cycles the usage breakdown — the nav note says it does") + if m.usage.group != before { + t.Errorf("`b` changed the usage breakdown; it pages on every pane, and `o` is the breakdown key") } // The note also claims g/G do nothing on usage. goTop has no case for it; assert @@ -443,6 +443,20 @@ func TestHelpNavKeys_NoteNamesTheOneExceptionCorrectly(t *testing.T) { } } +// `s` was Usage's session toggle. Removed, it must do nothing there, not reach the +// global hide-inactive toggle for an Events table the user cannot see. +func TestUsagePane_RemovedSKeyDoesNothing(t *testing.T) { + m := &model{pane: paneUsage, selectedSess: "s1"} + m.usage.session = "s1" + m.handleKey(keyRune('s')) + if m.hideInactive { + t.Error("`s` on Usage toggled hideInactive through the global handler") + } + if m.pane != paneUsage || m.usage.session != "s1" { + t.Errorf("`s` on Usage changed pane %v or scope %q", m.pane, m.usage.session) + } +} + // `a` and `w` are live only while the drawer is open, so listing them beside // the keys that work everywhere taught a binding that mostly does nothing. func TestHelpBody_SpendDrawerKeysAreTheirOwnSection(t *testing.T) { diff --git a/cmd/agentop/tui/keys.go b/cmd/agentop/tui/keys.go index 7b34d89c1..1c3a8183d 100644 --- a/cmd/agentop/tui/keys.go +++ b/cmd/agentop/tui/keys.go @@ -144,17 +144,15 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { m.usage.cycleWindow() m.persistUsage() return m.beginFetch() - case "b": + case "o": // Breakdown. NOT `g` for "group": `g` is globally "go to top" (see - // goTop below), and shadowing a vim-style motion inside one pane is - // worse than picking a second-choice mnemonic. + // goTop below). NOT `b`, which pages up on every other pane: one letter + // keeps one meaning wherever the pane allows it. // // Ignored while viewing latency: the aggregator holds no per-label // latency, so there is no per-status or per-model mean to plot. The // footer and the [?] overlay both say so, which is what keeps this from - // reading as a broken binding — `b` reaches no other handler for this - // pane (pageActivePane has no paneUsage case), so breaking here simply - // drops it. + // reading as a broken binding. if m.usage.metric.isLatency() { break } @@ -172,15 +170,11 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { m.persistUsage() return m.beginFetch() case "s": - // Toggle scope between this session and all sessions. Only offered - // when a session is selected; otherwise there is nothing to toggle to. - if m.usage.session != "" { - m.usage.session = "" - } else if m.selectedSess != "" { - m.usage.session = m.selectedSess - } - return m.beginFetch() + // Was the session toggle. Swallowed so it cannot reach the global hideInactive toggle. + return nil } + // No scope key: the pane `u` was pressed on sets it — Sessions charts every + // session, Events and Detail the one being read. } // `u` opens the Usage pane. Scope depends on where it was pressed: from the @@ -190,7 +184,7 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { // // Gated on !m.colPicker as well: this handler sits above the picker block, so // without it `u` reached openUsage while m.colPicker stayed true — View() drew - // the picker popup over the Usage pane, paneUsage's own m/w/b/s bindings went + // the picker popup over the Usage pane, paneUsage's own m/w/o bindings went // live underneath it, and `esc` then closed the picker onto Usage instead of the // events timeline the picker was opened from. (`?` above is deliberately NOT // gated: it layers help over the picker without changing panes, and closing it @@ -391,14 +385,15 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { // Picker panes handle their own keys before session-view logic. if m.pane == paneNamespaces { switch msg.String() { - case "enter": + case "enter", "right", "l": if cur := m.namespacesTbl.Cursor(); cur < len(m.namespaces) { m.selectedNamespace = m.namespaces[cur].Name m.pane = panePods m.rebuildPodsTable() } return nil - case "l": + case "L": + // Capital, because lowercase `l` opens the row here as on every other list. // Skip the cluster entirely and talk to whatever session API // is already listening locally — an existing port-forward, an // in-mesh agentop, or a tunnel from a kubeconfig that can't list @@ -428,7 +423,7 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { if m.pane == panePods { switch msg.String() { - case "enter": + case "enter", "right", "l": pods := m.currentPodsList() if cur := m.podsTbl.Cursor(); cur < len(pods) { if !pods[cur].Ready { @@ -486,7 +481,7 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { // so anything the refetch still misses can arrive off the stream // without a duplicate. NOT while paged back: a snapshot ends the // paging window, so this refetch would jump an operator reading an - // old page to the tail — [t] does that on purpose, [p] must not. + // old page to the tail — [G] does that on purpose, [p] must not. if id := m.watchingSessionID(); id != "" && !m.pagedBack(id) { return m.snapshotCmd(id) } @@ -496,7 +491,7 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { // Toggle hiding of passthrough / skip-only messages. Default is // off (show everything); turning it on focuses the timeline on // plugin activity. Only meaningful while the events pane is - // active, but accepting the key on any pane keeps the keybinding + // active, but accepting the key on other panes keeps the keybinding // simple and lets operators set their preference before drilling // into a session. rebuildEventsTable is a no-op when no session // is selected. @@ -506,7 +501,7 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { case "esc", "left", "h": // Back-out: plugin-detail → pipeline (or catalog if we came from there); - // detail → events; events → sessions; pipeline, catalog and usage → the + // detail → events; events → sessions; pipeline and usage → the // pane that opened them. Sessions is the only top-level pane now, and in // picker mode it backs out further to the Pods picker, tearing down PF + // SSE. It is the ONLY pane that does that — a key-opened surface returning @@ -514,48 +509,13 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { from := m.pane switch m.pane { case panePluginDetail: - // Return to whichever pane invoked the detail (Pipeline or Catalog). - if m.previousPane == paneCatalog { - m.pane = paneCatalog - m.previousPane = paneNone - } else { - m.pane = panePipeline - } + // The pipeline is the one pane that opens a plugin, catalog rows included. + m.pane = panePipeline case paneAgents: // Leaving WITHOUT touching the scope, which is the difference between this and the // Enter arm below. esc means "back out" on every other pane here, and a key that // silently discarded a scope on the way out would be the one exception. return m.leaveAgentsPane() - case paneCatalog: - // Return to whichever pane the user pressed `C` from. - // - // The fallback is SESSIONS, not the pipeline. It was the pipeline while the - // pipeline was a top-level pane; now that it is a key-opened surface, being - // dropped into it is being dropped somewhere the operator never asked to be, - // with a return pane of paneNone underneath. Sessions is the only pane that - // is always a defensible place to land. - // - // The branch is reachable, not just defensive: drilling catalog → plugin - // detail overwrites previousPane with paneCatalog and the detail's esc - // clears it, so the catalog backs out with no caller recorded. - if m.previousPane != paneNone { - m.pane = m.previousPane - m.previousPane = paneNone - } else { - m.pane = paneSessions - } - // Returning INTO Usage has to restart its polling chain. The tick - // that was in flight when the catalog opened was dropped by the - // `m.pane != paneUsage` guard, so without this nothing reschedules - // and the 20s auto-refresh is silently dead until the user backs all - // the way out and re-enters with `u` — `r` refetches once but starts - // no chain. - if m.pane == paneUsage { - return m.resumeUsagePolling() - } - if m.pane == paneTimeline { - return m.resumeTimeline() - } case paneTimeline: // esc only: the pane binds left/h to its cursor, ahead of this arm. if m.timeline.returnPane != paneNone { @@ -576,8 +536,7 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { m.timeline.session = "" case paneUsage: // Return to whichever pane opened it, from usageState's own field — - // model.previousPane is shared with the catalog overlay and gets - // clobbered when the catalog is opened from here. + // model.previousPane is shared with other panes. if m.usage.returnPane != paneNone { m.pane = m.usage.returnPane m.usage.returnPane = paneNone @@ -587,9 +546,8 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { // End the polling chain on the way out. m.usage.tickGen++ case panePipeline: - // Back to the pane `P` was pressed on, from the pipeline's OWN field — - // model.previousPane is the catalog's and gets clobbered when the catalog - // is opened from here, exactly as it did for Usage. + // Back to the pane `P` was pressed on, from the pipeline's OWN field, as + // Usage does. // // IT USED TO BE GROUPED WITH paneSessions BELOW, which meant esc here tore // down the port-forward and the SSE stream and dropped the operator at the @@ -665,7 +623,7 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { // session whatever the scope, so the reader landed back in the session they were // reading — under a title naming an agent it might not belong to. esc keeps that exit; // it changes nothing, so going back is all it can mean. previousPane is spent as - // leaveAgentsPane spends it, since the catalog shares the field. The spend band and + // leaveAgentsPane spends it, since other panes share the field. The spend band and // drawer restart under the new scope, so no figure from the old one stays on screen // beneath it. esc on that list comes back here. m.pane = paneSessions @@ -812,18 +770,12 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { m.previousPane = panePipeline m.showPluginDetail(p, true) m.pane = panePluginDetail + if p.Direction == "" { + return nil // an available row is not in the chain: no counters to refresh + } // Fetch immediately rather than waiting for the next refresh tick: // opening the pane is exactly when someone wants current counters. return m.loadPipelineCmd() - case paneCatalog: - p := m.selectedCatalogEntry() - if p == nil { - return nil - } - m.previousPane = paneCatalog - m.showPluginDetail(p, true) - m.pane = panePluginDetail - return nil } return nil @@ -896,14 +848,12 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { case "G": m.goBottom() - return nil - - case "t": - // Back to the live tail from a paged-back timeline. - if m.pane != paneEvents { - return nil + // On a paged-back timeline the bottom is the live tail, so `G` goes back to it: + // one key for "the newest end", where there used to be `G` and `t`. + if m.pane == paneEvents && m.pagedBack(m.selectedSess) { + return m.returnToTail() } - return m.returnToTail() + return nil case "pgup", "pgdown", "pgdn", "b", "f": // Page the active pane. Sessions can hold up to session.max_events @@ -917,7 +867,9 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { case "x": // Erase the row under the cursor, after a confirmation: the highlighted session on the // sessions pane, every session of the highlighted agent on the agents pane — on All agents, - // everything, which is X's confirmation. Off the footer, like X — the `?` overlay names it. + // everything (openClearConfirm). There is no second key for "everything": one key with + // the row deciding is one fewer Shift slip on a key that cannot be undone. Off the footer; + // the `?` overlay names it. if m.client == nil { return nil } @@ -929,15 +881,6 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { } return nil - case "X": - // Clear all history, after a confirmation. Capital, and off the footer like `A`: a - // destructive key should not be one stray press of a common letter, nor advertised on - // the always-visible line. The `?` overlay names it. - if m.client == nil || m.pane != paneSessions { - return nil - } - return m.openClearConfirm() - case "P": // Open the pipeline. `P` REPLACED `tab` HERE, and took the letter off the // plugin catalog (now `C`) to do it. @@ -946,15 +889,14 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { // other spelling of it — lowercase `p` — pauses the stream, is printed in // two footers, and has no replacement worth the trade: `space` and `d` are // bubbles' page-down and half-page-down, and every free letter is a worse - // pause mnemonic than `p` is a pipeline one. The catalog's claim on `P` was - // the weaker of the two (it only fit by borrowing the "Plugin" in "plugin - // catalog") and `C` for Catalog is a better key than it gave up. + // pause mnemonic than `p` is a pipeline one. The plugin catalog, once its own + // pane under `C`, is the pane's second section: plugins available but not run. // // The allowlist is the same three panes `u` opens Usage from, deliberately: // two top-level surfaces reached from the same places is a rule an operator // can hold, whereas two overlapping sets is a lookup. It also keeps the - // pipeline out of the nested-overlay cases (opened from Usage or from the - // catalog) where the pane to return to is ambiguous. + // pipeline out of the nested-overlay case (opened from Usage) where the pane + // to return to is ambiguous. // // The panes match; the CONDITIONS do not, and the difference is deliberate. // `u` additionally requires a selected session on Events/Detail, because its @@ -965,10 +907,10 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { // DO NOT MOVE THIS UP BESIDE `u` ON THE STRENGTH OF THAT SYMMETRY. `u`, `$`, // `c` and `?` sit ABOVE the modal blocks and each carries explicit // `!m.searching && !m.colPicker && m.editState.phase == editPhaseDone` guards - // to compensate. `P` and `C` carry none, and do not need to, because they sit + // to compensate. `P` carries none, and does not need to, because it sits // BELOW all three: the column picker ends in `default: return nil`, the search // prompt returns unconditionally after feeding the input, and an in-flight edit - // returns via handleEditKey. The safety here is POSITIONAL. Hoisting either + // returns via handleEditKey. The safety here is POSITIONAL. Hoisting the // key above those blocks without adopting the guards would make `P` change // panes under a modal popup and swallow a `P` someone was typing into the // search — silently, since nothing in the type system notices. @@ -986,7 +928,9 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { // build from already; rebuild rather than refetch. A nil pipeline renders // "(loading pipeline…)" and rebuildPipelineTable is a no-op on it. m.rebuildPipelineTable() - return nil + // The available-plugin rows come from /v1/plugins, fetched on every open so a + // rebuilt binary's plugins show without a refresh key. + return m.loadCatalogCmd() case "S": // Choose where the highlighted agent's new sessions go, or move the highlighted session. @@ -1005,8 +949,7 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { // Open the per-agent cost breakdown. // // `A` CAPITALISED, for the reason `P` is: lowercase `a` is the spend drawer's axis - // cycle. Available wherever `C` is — anywhere past the pickers, since it needs a - // connection. + // cycle. Available anywhere past the pickers, since it needs a connection. // // ALWAYS REFETCHED, never opened from cached rows: how many agents have been seen changes // while agentop runs. The reply enters the pane. @@ -1025,32 +968,6 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { // reply lands the reader may have navigated elsewhere. return m.fetchAgentRowsCmd(agentsOpenOnPress, m.pane) - case "C": - // Open the registered-plugin catalog. Available from any - // session-view pane; in --endpoint mode the picker fields - // don't matter — the catalog comes via the same /v1/* endpoint - // agentop is already pointed at. - // - // `C` for Catalog, moved off `P` when the pipeline took that letter. See - // the `P` case above for why this side of the swap is the cheap one — and - // note this key's own doc in globalKeys, which records that `P` was never - // advertised in any footer, so the muscle memory being broken is thin. - if m.client == nil { - return nil - } - switch m.pane { - case paneNamespaces, panePods: - return nil - } - m.previousPane = m.pane - m.pane = paneCatalog - // Fetch on first open; cached afterward (refresh via `r`). - if m.catalog == nil { - return m.loadCatalogCmd() - } - m.rebuildCatalogTable() - return nil - // Dispatch j/k/up/down to the active component's Update. } @@ -1088,32 +1005,15 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { } } return cmd - case paneCatalog: - // `r` here refreshes the catalog (in the catalog pane only — the - // top-level `r` is reserved for the picker). All other keys go to - // the table for navigation. - if msg.String() == "r" { - return m.loadCatalogCmd() - } - var cmd tea.Cmd - m.catalogTbl, cmd = m.catalogTbl.Update(msg) - return cmd case paneAgents: // Without this arm the pane's navigation keys fell off the end of the switch and // returned nil, while its footer printed "[↑↓] nav" and the help overlay listed // "↑↓ / jk navigate" — an advertised key that does nothing. The table is built // WithFocused(true), so it drew a selection highlight on a cursor nothing could move. // - // NO `r` BRANCH, unlike the catalog above: the rows are refetched by every `A` press, - // which is why the footer advertises no refresh key either. - // - // SPACE opens or closes a row's projects. On a row that cannot open, it goes to the table, - // which pages down. - if msg.String() == " " { - if cmd, ok := m.toggleAgentRow(); ok { - return cmd - } - } + // NO `r` BRANCH: the rows are refetched by every `A` press, which is why the footer + // advertises no refresh key either. NO SPACE BRANCH: Enter opens and closes a row, and + // esc backs out, so space is the table's page-down here as everywhere else. var cmd tea.Cmd m.agentsTbl, cmd = m.agentsTbl.Update(msg) return cmd @@ -1125,8 +1025,6 @@ func (m *model) handleKey(msg tea.KeyMsg) tea.Cmd { // empty-table guard and clamps, so goBottom does not need the row count. func (m *model) goTop() { switch m.pane { - case paneCatalog: - setCursorVisible(&m.catalogTbl, 0) case paneSessions: setCursorVisible(&m.sessionsTbl, 0) case paneEvents: @@ -1156,8 +1054,6 @@ func (m *model) goBottom() { m.setOpenAtOldest(false) case panePipeline: setCursorVisible(&m.pipelineTbl, len(m.pipelineTbl.Rows())-1) - case paneCatalog: - setCursorVisible(&m.catalogTbl, len(m.catalogTbl.Rows())-1) case paneDetail: m.detailCursorKey("G") case panePluginDetail: @@ -1192,8 +1088,6 @@ func (m *model) pageActivePane(msg tea.KeyMsg) tea.Cmd { page(&m.sessionsTbl) case panePipeline: page(&m.pipelineTbl) - case paneCatalog: - page(&m.catalogTbl) case paneDetail: m.detailCursorKey(msg.String()) case panePluginDetail: @@ -1235,7 +1129,7 @@ func (m *model) persistSettings() { // persistUsage records the usage pane's view, then saves. // -// Its own helper rather than three copies of the two lines: [m], [w] and [b] each +// Its own helper rather than three copies of the two lines: [m], [w] and [o] each // change one of the three, and all three belong in the file together — a reader // returning to the pane expects the view they left, not two thirds of it. func (m *model) persistUsage() { @@ -1274,7 +1168,7 @@ func (m *model) helpView() string { } switch m.pane { case paneNamespaces: - return "[↑↓/jk] nav [↵] open [l] " + shortHost(m.localEndpointOr()) + + return "[↑↓/jk] nav [↵] open [L] " + shortHost(m.localEndpointOr()) + " [r] reload " + m.searchHints(m.pane) + " [?] keys [q] quit" case panePods: return "[↑↓/jk] nav [↵] connect [Esc] back [r] reload " + m.searchHints(m.pane) + " [?] keys [q] quit" @@ -1306,9 +1200,8 @@ func (m *model) helpView() string { // column is PLUGIN. The footer is where a key gets DISCOVERED, so it is named // for what the pane shows rather than for the concept behind it; the [?] // overlay, which has room, carries the precise version ("the plugin chain this - // proxy runs"). Not to be confused with [C], the plugin CATALOG — every plugin - // the proxy offers, against the chain it actually runs. That pair is only ever - // adjacent in the overlay, since [C] appears in no footer. + // proxy runs"). The pane also lists the plugins the proxy offers but does not run, + // under its "available" divider. // // MEASURED, because the intuition here is off by more than it looks: the // un-drilled line is 98 columns, and [P] survives down to 34 columns at the @@ -1365,9 +1258,9 @@ func (m *model) helpView() string { // silently stopped updating is the same class of lie as one that silently // omitted its beginning. if st := m.paging[m.selectedSess]; st != nil { - note := "paged back, live paused ([t] for tail)" + note := "paged back, live paused ([G] for tail)" if st.droppedNewer { - note = "paged back, newer dropped ([t] for tail)" + note = "paged back, newer dropped ([G] for tail)" } base = fmt.Sprintf("%s · %s", base, note) } @@ -1416,17 +1309,9 @@ func (m *model) helpView() string { } return "[w] window [←→] moment " + scroll + "[enter] events " + m.searchHints(m.pane) + " [esc] back [?] keys [q] quit" case paneUsage: - // [s] only appears when there is a session to scope to, so the footer - // never advertises a key that would do nothing. - scopeHint := "" - if m.usage.session != "" { - scopeHint = " [s] all sessions" - } else if m.selectedSess != "" { - scopeHint = " [s] this session" - } - // [b] is omitted under latency rather than shown as a no-op: a footer that + // [o] is omitted under latency rather than shown as a no-op: a footer that // advertises an inert key is worse than a shorter footer. - breakdownHint := " [b] breakdown" + breakdownHint := " [o] breakdown" // Omitted under an agent or a project scope for the same reason as under latency: the scope has taken // the wire axis, so there is no second one to break down by, and a footer that advertises // an inert key is worse than a shorter footer. @@ -1438,13 +1323,8 @@ func (m *model) helpView() string { } // No [r]: the pane polls every 20s on its own, so a manual refresh key // bought nothing but a line of footer. - return "[m] metric [w] window" + breakdownHint + scopeHint + + return "[m] metric [w] window" + breakdownHint + " " + m.searchHints(m.pane) + " [esc] back [?] keys [q] quit" - case paneCatalog: - if m.catalog == nil { - return "loading catalog… [esc] back [?] keys [q] quit" - } - return "[↑↓] nav [↵] plugin detail [r] refresh [esc] back " + m.searchHints(m.pane) + " [?] keys [q] quit" case paneAgents: // [↵] LABELLED BY WHAT IT WILL SHOW: the highlighted agent, or every agent on the All // agents row. @@ -1465,13 +1345,9 @@ func (m *model) helpView() string { enterHint = " [↵] all agents" } } - // [space] after [↵], and the full project label after nav: the cell may show only a tail. - navHint, spaceHint := "[↑↓] nav", "" + // The full project label after nav: the cell may show only a tail. + navHint := "[↑↓] nav" if d, ok := m.selectedAgentRow(); ok { - // Only on a sub-row: on an agent row [↵] already says it. - if d.kind != agentRowAgent && d.kind != agentRowHeading { - spaceHint = " [space] close" - } if d.kind == agentRowProject { navHint += " " + sanitizeLabel(d.project) } @@ -1493,7 +1369,7 @@ func (m *model) helpView() string { // key gets discovered. The drawer here breaks down the row under the cursor. spendHint := " [$] spend" // [w] the pane's window, which the title names; see cycleAgentsWindow. - return navHint + enterHint + spaceHint + escHint + serverHint + " [w] window" + spendHint + " " + m.searchHints(m.pane) + " [?] keys [q] quit" + return navHint + enterHint + escHint + serverHint + " [w] window" + spendHint + " " + m.searchHints(m.pane) + " [?] keys [q] quit" } return "[?] keys [q] quit" } diff --git a/cmd/agentop/tui/layout.go b/cmd/agentop/tui/layout.go index 4890f5a20..88f9586c7 100644 --- a/cmd/agentop/tui/layout.go +++ b/cmd/agentop/tui/layout.go @@ -73,7 +73,6 @@ func (m *model) layout() { // SetColumns. rebuildSessionsTable owns both; see its doc. It is called below, after the // heights are set. m.pipelineTbl.SetColumns(fitTableColumns(pipelineColumns(), m.width)) - m.catalogTbl.SetColumns(fitTableColumns(catalogColumns(), m.width)) m.rebuildAgentsTable() m.sessionsTbl.SetHeight(bodyH) @@ -96,20 +95,12 @@ func (m *model) layout() { // a window resize too. m.rebuildEventsTable() m.pipelineTbl.SetHeight(bodyH) - // The catalog table had no height set anywhere: it kept bubbles' table.New - // default of 20 rows for the life of the process, so on a terminal shorter than - // that the pane rendered past the bottom (scrolling the title away) and on a - // taller one it left the remaining rows unused. TestLayout_EveryPaneFitsTheTerminal - // covered this pane but never populated m.catalog, so it only ever measured the - // "loading catalog…" line. - m.catalogTbl.SetHeight(bodyH) - // The agents table had the catalog's bug, whose comment above is this one's history: nothing - // sized it anywhere, so it kept bubbles' table.New default for the life of the process and - // rendered past the bottom of any shorter terminal. The catalog's blind spot was an empty - // fixture; this one was a size larger, and it is the class that will recur: - // TestLayout_EveryPaneFitsTheTerminal enumerates the panes it measures in a HAND-WRITTEN - // map, and paneAgents was simply not in it — so no fixture could have helped, and adding a - // pane means adding it to that map too. + // The agents table had no height set anywhere: it kept bubbles' table.New default for the + // life of the process and rendered past the bottom of any shorter terminal. The plugin + // catalog's own table (now the pipeline pane's available rows) had the same bug before it. + // It is the class that will recur: TestLayout_EveryPaneFitsTheTerminal enumerates the panes + // it measures in a HAND-WRITTEN map, and paneAgents was simply not in it — so adding a pane + // means adding it to that map too. m.agentsTbl.SetHeight(bodyH) m.detailVp.Width = m.width // The event detail's fixed line takes one row (#1681). Every pane but the plugin detail diff --git a/cmd/agentop/tui/layout_fit_test.go b/cmd/agentop/tui/layout_fit_test.go index 5bb9cfafd..634f8b3ff 100644 --- a/cmd/agentop/tui/layout_fit_test.go +++ b/cmd/agentop/tui/layout_fit_test.go @@ -42,7 +42,6 @@ func fitModel(t *testing.T, p paneID, w, h int, events []pipeline.SessionEvent) m.eventsTbl = newEventsTable() m.sessionsTbl = newSessionsTable() m.pipelineTbl = newPipelineTable() - m.catalogTbl = newCatalogTable() m.namespacesTbl = newNamespacesTable() m.podsTbl = newPodsTable() // The real constructors build this one too (New and the picker's both call @@ -174,7 +173,6 @@ func fitModel(t *testing.T, p paneID, w, h int, events []pipeline.SessionEvent) // count, but the fit assertions measure precisely what layout() produced. m.rebuildSessionsTable() m.rebuildPipelineTable() - m.rebuildCatalogTable() m.rebuildAgentsTable() if p == paneDetail && len(events) > 0 { // An event on the page, so the fixed line above the viewport is measured too (#1681). @@ -214,7 +212,7 @@ func TestLayout_EveryPaneFitsTheTerminal(t *testing.T) { forceColor(t) panes := map[string]paneID{ "sessions": paneSessions, "events": paneEvents, "pipeline": panePipeline, - "detail": paneDetail, "catalog": paneCatalog, "usage": paneUsage, + "detail": paneDetail, "usage": paneUsage, "agents": paneAgents, "timeline": paneTimeline, } for _, dim := range fitSizes { @@ -299,7 +297,6 @@ func TestLayout_TablesFitTheirTerminal(t *testing.T) { }{ {"sessions", tableWidth(m.sessionsTbl.Columns()), len(m.sessionsTbl.Columns())}, {"pipeline", tableWidth(m.pipelineTbl.Columns()), len(m.pipelineTbl.Columns())}, - {"catalog", tableWidth(m.catalogTbl.Columns()), len(m.catalogTbl.Columns())}, } { if tc.width > dim[0] { t.Errorf("%s table is %d columns wide (%d columns) at terminal width %d", diff --git a/cmd/agentop/tui/namespaces_pane.go b/cmd/agentop/tui/namespaces_pane.go index 990341fc0..6dc0f5e92 100644 --- a/cmd/agentop/tui/namespaces_pane.go +++ b/cmd/agentop/tui/namespaces_pane.go @@ -47,7 +47,7 @@ func loadAgentsCmd(ctx context.Context, lister cluster.Lister) tea.Cmd { } // localConnectedMsg carries the result of probing localEndpoint for the -// `[l]` shortcut. client is non-nil only when the probe succeeded. +// `[L]` shortcut. client is non-nil only when the probe succeeded. type localConnectedMsg struct { client *apiclient.Client endpoint string @@ -105,7 +105,6 @@ func newPickerModel(ctx context.Context, lister cluster.Lister, pf cluster.PortF sessionsTbl: newSessionsTable(), eventsTbl: newEventsTable(), pipelineTbl: newPipelineTable(), - catalogTbl: newCatalogTable(), agentsTbl: newAgentsTable(), previousPane: paneNone, // Mirrors New, per this constructor's doc comment. paneNone rather than diff --git a/cmd/agentop/tui/open_at.go b/cmd/agentop/tui/open_at.go index 3bb346ff7..cdd8cd513 100644 --- a/cmd/agentop/tui/open_at.go +++ b/cmd/agentop/tui/open_at.go @@ -9,7 +9,7 @@ package tui // would flip the setting under an operator who was simply scrolling. // // Persisted immediately rather than on pane exit: there is no "closing" event for -// a session view (Esc, [l], a pod switch and quitting all leave it), so waiting for +// a session view (Esc, [L], a pod switch and quitting all leave it), so waiting for // one means the common paths never save. func (m *model) setOpenAtOldest(oldest bool) { if Settings.Events.OpenAtOldest == oldest { diff --git a/cmd/agentop/tui/paging.go b/cmd/agentop/tui/paging.go index cdd762fc8..2c942f649 100644 --- a/cmd/agentop/tui/paging.go +++ b/cmd/agentop/tui/paging.go @@ -219,7 +219,7 @@ func (m *model) applyOlderPage(msg olderPageLoadedMsg) { // Refused here rather than by teaching ViewPage to reject high cursors, because the store // cannot tell a re-created session from a trimmed one, and this check does not need to. if own := ownOldest(held, msg.id); own != nil && msg.events[len(msg.events)-1].At.After(own.At) { - m.setFlash("session restarted — [t] for the tail") + m.setFlash("session restarted — [G] for the tail") m.abandonIfTentative(msg.id, st) return } diff --git a/cmd/agentop/tui/paging_test.go b/cmd/agentop/tui/paging_test.go index 23cefb97d..220e11801 100644 --- a/cmd/agentop/tui/paging_test.go +++ b/cmd/agentop/tui/paging_test.go @@ -435,7 +435,7 @@ func TestFooter_SaysWhenPagedBack(t *testing.T) { m.rebuildEventsTable() got := m.helpView() - if !strings.Contains(got, "live paused") || !strings.Contains(got, "[t]") { + if !strings.Contains(got, "live paused") || !strings.Contains(got, "[G]") { t.Errorf("footer does not report the paged-back state: %q", got) } @@ -445,6 +445,26 @@ func TestFooter_SaysWhenPagedBack(t *testing.T) { } } +// `G` on a paged-back timeline goes back to the live tail, where `t` used to: one key for "the +// newest end". It is a snapshot request, and not one while the timeline follows live. +func TestGKey_ReturnsToTheTailWhenPagedBack(t *testing.T) { + m := pagedModel(t, pagedEvents(11, 10)) + m.rebuildEventsTable() + if cmd := m.handleKey(keyRune('G')); cmd == nil || !m.paging["sess-1"].returning { + t.Fatal("`G` on a paged-back timeline did not return to the tail") + } + + live := pagedModel(t, pagedEvents(11, 10)) + live.paging = map[string]*pagingState{} + live.rebuildEventsTable() + if cmd := live.handleKey(keyRune('G')); cmd != nil { + t.Error("`G` on a live timeline asked for a snapshot") + } + if cmd := live.handleKey(keyRune('t')); cmd != nil { + t.Error("`t` still does something; `G` replaced it") + } +} + // A linked bucket's event can sort first, and its seq counts in the bucket: paging goes by the // session's own oldest event, both for the cursor and for the restart guard. func TestOlderPage_GoesByTheSessionsOwnOldestEvent(t *testing.T) { diff --git a/cmd/agentop/tui/picker_test.go b/cmd/agentop/tui/picker_test.go index 2f9d39f31..62f7aba0a 100644 --- a/cmd/agentop/tui/picker_test.go +++ b/cmd/agentop/tui/picker_test.go @@ -454,13 +454,13 @@ func TestLocalhostKeybindConnects(t *testing.T) { updated, _ := m.Update(m.Init()()) mm := updated.(*model) - // `l` should dispatch a probe Cmd and mark the model loading. - _, cmd := mm.Update(keyRune('l')) + // `L` should dispatch a probe Cmd and mark the model loading. + _, cmd := mm.Update(keyRune('L')) if cmd == nil { - t.Fatal("`l` on paneNamespaces should produce a connect Cmd") + t.Fatal("`L` on paneNamespaces should produce a connect Cmd") } if !mm.loading { - t.Fatal("`l` should set m.loading while the probe is in flight") + t.Fatal("`L` should set m.loading while the probe is in flight") } // Run the probe against the stub (not the real localhost:9094) and feed @@ -553,7 +553,7 @@ func TestLocalhostEscReturnsToNamespaces(t *testing.T) { } } -// The namespaces footer and empty state must advertise `[l]`, otherwise +// The namespaces footer and empty state must advertise `[L]`, otherwise // the shortcut is undiscoverable. func TestLocalhostKeybindIsAdvertised(t *testing.T) { m := newPickerModel(context.Background(), &fakeLister{namespaces: fixtureNamespaces}, nil) @@ -561,31 +561,31 @@ func TestLocalhostKeybindIsAdvertised(t *testing.T) { mm := updated.(*model) updated, _ = mm.Update(tea.WindowSizeMsg{Width: 120, Height: 40}) mm = updated.(*model) - if !strings.Contains(mm.View(), "[l] localhost:9094") { - t.Fatalf("namespaces footer should advertise [l]:\n%s", mm.View()) + if !strings.Contains(mm.View(), "[L] localhost:9094") { + t.Fatalf("namespaces footer should advertise [L]:\n%s", mm.View()) } - // Empty-state hint: the no-agents case is exactly when `l` is most + // Empty-state hint: the no-agents case is exactly when `L` is most // useful, so it should be mentioned there too. m2 := newPickerModel(context.Background(), &fakeLister{namespaces: []cluster.AgentNamespace{}}, nil) u2, _ := m2.Update(m2.Init()()) mm2 := u2.(*model) - if !strings.Contains(mm2.View(), "[l]") { - t.Fatalf("empty-state hint should mention [l]:\n%s", mm2.View()) + if !strings.Contains(mm2.View(), "[L]") { + t.Fatalf("empty-state hint should mention [L]:\n%s", mm2.View()) } } -// `l` must not be swallowed when the picker is mid-load, and must not -// hijack the vim-right binding in the session panes. +// `L` must not be swallowed when the picker is mid-load, and `l` must not +// connect in the session panes, where it is vim-right. func TestLocalhostKeybindScoping(t *testing.T) { srv := sessionAPIStub(t) m := newPickerModel(context.Background(), &fakeLister{namespaces: fixtureNamespaces}, nil) updated, _ := m.Update(m.Init()()) mm := updated.(*model) mm.loading = true - _, cmd := mm.Update(keyRune('l')) + _, cmd := mm.Update(keyRune('L')) if cmd != nil { - t.Fatal("`l` while loading should be a no-op") + t.Fatal("`L` while loading should be a no-op") } mm.loading = false diff --git a/cmd/agentop/tui/pipeline_available_test.go b/cmd/agentop/tui/pipeline_available_test.go new file mode 100644 index 000000000..827d5c1d6 --- /dev/null +++ b/cmd/agentop/tui/pipeline_available_test.go @@ -0,0 +1,90 @@ +package tui + +import ( + "context" + "testing" + + tea "github.com/charmbracelet/bubbletea" + + "github.com/rossoctl/cortex/cmd/agentop/apiclient" +) + +// availableModel is a pipeline that runs mcp-parser, and a catalog that also offers ibac. +func availableModel() *model { + m := newPickerModel(context.Background(), nil, nil) + m.client = deadClient() + m.pipeline = &apiclient.PipelineView{Outbound: []apiclient.PipelinePlugin{ + {Name: "mcp-parser", Direction: "outbound", Position: 1}, + }} + m.catalog = &apiclient.PluginCatalog{Plugins: []apiclient.PluginCatalogEntry{ + {Name: "mcp-parser", Description: "Parses MCP"}, + {Name: "ibac", Description: "Judge", Requires: []string{"mcp-parser"}, ReadsBody: true}, + }} + m.rebuildPipelineTable() + return m +} + +// The catalog's plugins that the chain does not run follow an "available" divider; a plugin +// that runs is listed once, in the chain. +func TestPipelinePane_ListsAvailablePluginsAfterTheChain(t *testing.T) { + m := availableModel() + rows := m.pipelineTbl.Rows() + // (app) divider, mcp-parser, available divider, ibac. + if len(rows) != 4 { + t.Fatalf("rows = %d, want 4: %v", len(rows), rows) + } + if !isDividerRow(rows, 2) || rows[2][2] != availableDivider { + t.Errorf("rows[2] = %v, want the available divider", rows[2]) + } + if rows[3][2] != "ibac" || rows[3][4] != "yes" { + t.Errorf("rows[3] = %v, want ibac with BODY yes", rows[3]) + } + for _, p := range m.availablePlugins() { + if p.Name == "mcp-parser" { + t.Error("a plugin the chain runs is also listed as available") + } + } +} + +// No catalog yet: no divider and no available rows. +func TestPipelinePane_NoCatalogNoAvailableSection(t *testing.T) { + m := availableModel() + m.catalog = nil + m.rebuildPipelineTable() + for i := range m.pipelineTbl.Rows() { + if m.pipelineTbl.Rows()[i][2] == availableDivider { + t.Fatal("the available divider shows with no catalog") + } + } +} + +// An available row's plugin carries the catalog's metadata, with no Direction or Position. +func TestSelectedPlugin_AvailableRowIsACatalogEntry(t *testing.T) { + m := availableModel() + m.pipelineTbl.SetCursor(3) + got := m.selectedPlugin() + if got == nil || got.Name != "ibac" { + t.Fatalf("selectedPlugin = %+v, want ibac", got) + } + if got.Description != "Judge" || len(got.Requires) != 1 || got.Requires[0] != "mcp-parser" { + t.Errorf("metadata lost: %+v", got) + } + if got.Direction != "" || got.Position != 0 { + t.Errorf("Direction/Position = %q/%d, want blank for an available row", got.Direction, got.Position) + } +} + +// Enter on an available row opens the plugin detail, and esc comes back to the pipeline. +func TestPipelinePane_EnterOnAvailableRowOpensDetail(t *testing.T) { + m := availableModel() + m.pane = panePipeline + m.pipelineTbl.SetCursor(3) + m.handleKey(tea.KeyMsg{Type: tea.KeyEnter}) + if m.pane != panePluginDetail { + t.Fatalf("Enter on an available row landed on %v, want panePluginDetail", m.pane) + } + m.handleKey(tea.KeyMsg{Type: tea.KeyEsc}) + if m.pane != panePipeline { + t.Errorf("esc from the plugin detail landed on %v, want panePipeline", m.pane) + } +} diff --git a/cmd/agentop/tui/pipeline_key_test.go b/cmd/agentop/tui/pipeline_key_test.go index e18b882e9..ab2c96608 100644 --- a/cmd/agentop/tui/pipeline_key_test.go +++ b/cmd/agentop/tui/pipeline_key_test.go @@ -67,7 +67,7 @@ func TestPipelineKey_OpensFromTheSamePanesAsUsage(t *testing.T) { // panes that are themselves key-opened surfaces. `P` from any of them would // have to pick a pane to return to, and there is no good answer — so it does // nothing, and that must stay true rather than becoming an accident. - for _, from := range []paneID{paneUsage, paneCatalog, panePluginDetail, panePipeline} { + for _, from := range []paneID{paneUsage, panePluginDetail, panePipeline} { m := &model{ pane: from, client: deadClient(), @@ -122,51 +122,52 @@ func TestPipelineKey_EscReturnsToTheCallerAndKeepsTheConnection(t *testing.T) { } // The return pane is the pipeline's OWN field, not model.previousPane, which the -// catalog also writes. Opening the catalog from the pipeline and backing out +// plugin detail also writes. Opening a plugin from the pipeline and backing out // twice has to land where the operator started; sharing one field is the bug // usageState.returnPane was introduced to fix, arriving through a third door. // // STARTS FROM EVENTS, NOT SESSIONS, and that is the whole point of the test. A -// pipeline sharing previousPane loses the caller to the catalog's write and then +// pipeline sharing previousPane loses the caller to the detail's write and then // falls back — and the fallback is paneSessions, so starting from Sessions the // broken implementation reaches the right pane by luck and the test proves // nothing. Verified by mutation: with the shared field, the Sessions version of // this test passes and this one fails. -func TestPipelineKey_ReturnPaneSurvivesTheCatalogClobbering(t *testing.T) { +func TestPipelineKey_ReturnPaneSurvivesThePluginDetail(t *testing.T) { m := &model{ pane: paneEvents, client: deadClient(), selectedSess: "s1", previousPane: paneNone, pipelineReturnPane: paneNone, + pipelineTbl: newPipelineTable(), + pipeline: &apiclient.PipelineView{Outbound: []apiclient.PipelinePlugin{{Name: "mcp-parser", Direction: "outbound", Position: 1}}}, } - m.handleKey(keyRune('P')) // events -> pipeline - m.handleKey(keyRune('C')) // pipeline -> catalog (writes previousPane) - if m.pane != paneCatalog { - t.Fatalf("precondition: `C` did not open the catalog (got %v)", m.pane) + m.handleKey(keyRune('P')) // events -> pipeline + m.handleKey(tea.KeyMsg{Type: tea.KeyEnter}) // pipeline -> plugin detail (writes previousPane) + if m.pane != panePluginDetail { + t.Fatalf("precondition: Enter did not open the plugin (got %v)", m.pane) } - m.handleKey(tea.KeyMsg{Type: tea.KeyEsc}) // catalog -> pipeline + m.handleKey(tea.KeyMsg{Type: tea.KeyEsc}) // detail -> pipeline if m.pane != panePipeline { - t.Fatalf("esc from the catalog landed on %v, want panePipeline", m.pane) + t.Fatalf("esc from the plugin detail landed on %v, want panePipeline", m.pane) } m.handleKey(tea.KeyMsg{Type: tea.KeyEsc}) // pipeline -> events if m.pane == paneSessions { - t.Fatal("esc from the pipeline fell back to Sessions — the catalog clobbered the return pane") + t.Fatal("esc from the pipeline fell back to Sessions — the detail clobbered the return pane") } if m.pane != paneEvents { t.Errorf("esc from the pipeline landed on %v, want paneEvents", m.pane) } } -// The catalog moves off `P` and onto `C`, which is the better mnemonic of the -// two: `P` only ever fit by borrowing the "Plugin" in "plugin catalog", and the -// pipeline has the stronger claim on the letter. -func TestCatalogKey_MovedFromPToC(t *testing.T) { +// The plugin catalog is the pipeline pane's "available" section now, so `C` opens +// nothing, and `P` fetches /v1/plugins on every open to fill that section. +func TestCatalogKey_FoldedIntoThePipeline(t *testing.T) { onC := &model{pane: paneSessions, client: deadClient(), previousPane: paneNone} onC.handleKey(keyRune('C')) - if onC.pane != paneCatalog { - t.Errorf("`C` opened pane %v, want paneCatalog", onC.pane) + if onC.pane != paneSessions { + t.Errorf("`C` opened pane %v; the catalog has no pane of its own any more", onC.pane) } onP := &model{ @@ -175,34 +176,11 @@ func TestCatalogKey_MovedFromPToC(t *testing.T) { previousPane: paneNone, pipelineReturnPane: paneNone, } - onP.handleKey(keyRune('P')) - if onP.pane == paneCatalog { - t.Error("`P` still opens the catalog; that key belongs to the pipeline now") + if cmd := onP.handleKey(keyRune('P')); cmd == nil { + t.Error("`P` returned no command; it must fetch the catalog for the available rows") } -} - -// The catalog's fallback for "no caller recorded" used to be the pipeline, which -// was defensible while the pipeline was a top-level pane. It is not one any more, -// so the fallback has to be Sessions — the only pane left that an operator can be -// dropped into without having asked for it. -// -// The branch is reachable: drilling catalog → plugin detail overwrites -// previousPane with paneCatalog and the detail's own esc clears it, so the -// catalog backs out with nothing recorded. -func TestCatalogEsc_FallsBackToSessionsNotThePipeline(t *testing.T) { - m := &model{ - pane: paneCatalog, - client: deadClient(), - previousPane: paneNone, - pipelineReturnPane: paneNone, - } - m.handleKey(tea.KeyMsg{Type: tea.KeyEsc}) - - if m.pane == panePipeline { - t.Fatal("esc from the catalog fell back to the pipeline, which is no longer a top-level pane") - } - if m.pane != paneSessions { - t.Errorf("esc from the catalog with no caller recorded landed on %v, want paneSessions", m.pane) + if onP.pane != panePipeline { + t.Errorf("`P` opened pane %v, want panePipeline", onP.pane) } } @@ -310,8 +288,8 @@ func TestHelpOverlay_DocumentsTheRemappedKeys(t *testing.T) { if got := target["P"]; got != panePipeline { t.Errorf("jumpTargets does not point `P` at the pipeline (got pane %v)", got) } - if got := target["C"]; got != paneCatalog { - t.Errorf("jumpTargets does not point `C` at the plugin catalog (got pane %v)", got) + if _, ok := target["C"]; ok { + t.Error("jumpTargets still lists `C`; the catalog is the pipeline's available section") } desc := map[string]string{} diff --git a/cmd/agentop/tui/pipeline_pane.go b/cmd/agentop/tui/pipeline_pane.go index f1bbd8623..024025b01 100644 --- a/cmd/agentop/tui/pipeline_pane.go +++ b/cmd/agentop/tui/pipeline_pane.go @@ -2,6 +2,7 @@ package tui import ( "fmt" + "strings" "github.com/rossoctl/cortex/cmd/agentop/apiclient" "github.com/rossoctl/cortex/cmd/agentop/tui/table" @@ -37,7 +38,9 @@ func newPipelineTable() table.Model { } // rebuildPipelineTable renders the plugin list with a "(app)" divider row -// between inbound and outbound. +// between inbound and outbound, then an "available" divider and one row for each +// plugin the proxy offers (/v1/plugins) that the chain does not run. That second +// section was the plugin catalog's own pane, under its own key. func (m *model) rebuildPipelineTable() { if m.pipeline == nil { m.pipelineTbl.SetRows(nil) @@ -57,6 +60,16 @@ func (m *model) rebuildPipelineTable() { for _, p := range m.pipeline.Outbound { rows = append(rows, pipelineRow(p, counts[p.Name], m.pipeline.Outbound)) } + if avail := m.availablePlugins(); len(avail) > 0 { + rows = append(rows, table.Row{"", "", availableDivider, "", "", ""}) + for _, p := range avail { + body := "no" + if p.ReadsBody { + body = "yes" + } + rows = append(rows, table.Row{"", "", p.Name, "", body, ""}) + } + } m.pipelineTbl.SetRows(rows) // If cursor is on the divider row, nudge to the next plugin. A relative move so // the viewport offset stays reconciled — see setCursorVisible. @@ -96,15 +109,50 @@ func pipelineRow(p apiclient.PipelinePlugin, events int, chain []apiclient.Pipel } } +const availableDivider = "── available ──" + +// isDividerRow reports a divider: no position, and a "──" label. A plugin row always +// has a position, and an available row never starts its name with "──". func isDividerRow(rows []table.Row, i int) bool { if i < 0 || i >= len(rows) { return false } - return rows[i][2] == "── (app) ──" + return rows[i][0] == "" && strings.HasPrefix(rows[i][2], "──") +} + +// availablePlugins is the catalog minus every plugin the chain runs, in catalog order, +// as synthetic PipelinePlugins: Direction blank and Position 0, which showPluginDetail +// elides and which tells selectedPlugin's callers the row is not in the chain. +func (m *model) availablePlugins() []apiclient.PipelinePlugin { + if m.catalog == nil || m.pipeline == nil { + return nil + } + running := map[string]bool{} + for _, p := range m.pipeline.Inbound { + running[p.Name] = true + } + for _, p := range m.pipeline.Outbound { + running[p.Name] = true + } + var out []apiclient.PipelinePlugin + for _, e := range m.catalog.Plugins { + if running[e.Name] { + continue + } + out = append(out, apiclient.PipelinePlugin{ + Name: e.Name, + ReadsBody: e.ReadsBody, + Requires: e.Requires, + RequiresAny: e.RequiresAny, + Description: e.Description, + }) + } + return out } // selectedPlugin returns the PipelinePlugin under the cursor, or nil when -// the cursor sits on the divider or the table is empty. +// the cursor sits on a divider or the table is empty. An available row's plugin has +// a blank Direction. func (m *model) selectedPlugin() *apiclient.PipelinePlugin { if m.pipeline == nil { return nil @@ -131,6 +179,11 @@ func (m *model) selectedPlugin() *apiclient.PipelinePlugin { return &m.pipeline.Outbound[j] } } + for _, p := range m.availablePlugins() { + if p.Name == name { + return &p + } + } return nil } diff --git a/cmd/agentop/tui/project_scope_test.go b/cmd/agentop/tui/project_scope_test.go index 4ab848441..9c2fd3026 100644 --- a/cmd/agentop/tui/project_scope_test.go +++ b/cmd/agentop/tui/project_scope_test.go @@ -112,7 +112,7 @@ func TestProjectScope_AProjectUnderAllAgentsHasNoAgent(t *testing.T) { series := map[string]map[string]int64{"": {"~/works/cortex": 1_000_000, "~/moca": 2_000_000}} m, _ := projectsModel(t, series) m.agentsTbl.SetCursor(0) - deliver(m, pressCmd(m, spaceKey)) + deliver(m, pressCmd(m, enterKey)) onDesc(t, m, agentRowDesc{kind: agentRowProject, project: "~/works/cortex"}) pressCmd(m, enterKey) wantScopes(t, m, "", "~/works/cortex") diff --git a/cmd/agentop/tui/removed_keys_test.go b/cmd/agentop/tui/removed_keys_test.go new file mode 100644 index 000000000..384158160 --- /dev/null +++ b/cmd/agentop/tui/removed_keys_test.go @@ -0,0 +1,37 @@ +package tui + +import ( + "go/ast" + "go/parser" + "go/token" + "os" + "strings" + "testing" +) + +func TestNoStringNamesARemovedKey(t *testing.T) { + removed := []string{"[t]", "[C]", "[X]"} + fset := token.NewFileSet() + pkgs, err := parser.ParseDir(fset, ".", func(fi os.FileInfo) bool { + return !strings.HasSuffix(fi.Name(), "_test.go") + }, 0) + if err != nil { + t.Fatal(err) + } + for _, pkg := range pkgs { + for _, f := range pkg.Files { + ast.Inspect(f, func(n ast.Node) bool { + lit, ok := n.(*ast.BasicLit) + if !ok || lit.Kind != token.STRING { + return true + } + for _, k := range removed { + if strings.Contains(lit.Value, k) { + t.Errorf("%s: %s names removed key %s", fset.Position(lit.Pos()), lit.Value, k) + } + } + return true + }) + } + } +} diff --git a/cmd/agentop/tui/search_panes_test.go b/cmd/agentop/tui/search_panes_test.go index 45145daf4..22e91b008 100644 --- a/cmd/agentop/tui/search_panes_test.go +++ b/cmd/agentop/tui/search_panes_test.go @@ -36,7 +36,6 @@ func newPanesModel(t *testing.T) *model { m.rebuildNamespacesTable() m.rebuildPodsTable() m.rebuildPipelineTable() - m.rebuildCatalogTable() m.rebuildAgentsTable() return m } @@ -50,7 +49,6 @@ func TestSearch_EveryCellOfEveryOtherTableIsSearchable(t *testing.T) { {paneNamespaces, &m.namespacesTbl}, {panePods, &m.podsTbl}, {panePipeline, &m.pipelineTbl}, - {paneCatalog, &m.catalogTbl}, {paneAgents, &m.agentsTbl}, } { t.Run(paneName(tc.pane), func(t *testing.T) { @@ -83,14 +81,14 @@ func TestSearch_SlashOnThePickers(t *testing.T) { } } -// TestSearch_OnAPaneWithNoRows: the catalog before it loads has no table rows at all. +// TestSearch_OnAPaneWithNoRows: the pipeline before it loads has no table rows at all. func TestSearch_OnAPaneWithNoRows(t *testing.T) { m := newPanesModel(t) - m.catalog = nil - m.catalogTbl.SetRows(nil) - m.pane = paneCatalog + m.pipeline = nil + m.rebuildPipelineTable() + m.pane = panePipeline typeKeys(m, "/x") - if st := m.searchStatus(paneCatalog); st != "[/x: no match]" { + if st := m.searchStatus(panePipeline); st != "[/x: no match]" { t.Errorf("status = %q, want [/x: no match]", st) } press(m, tea.KeyEnter) @@ -121,18 +119,19 @@ func TestSearch_ThePaneChangesUnderTheOpenPrompt(t *testing.T) { func TestSearch_NextAndPreviousOnAnotherTable(t *testing.T) { m := newPanesModel(t) - m.pane = paneCatalog - typeKeys(m, "/plugin") + m.pane = panePipeline + typeKeys(m, "/alpha") press(m, tea.KeyEnter) - if c := m.catalogTbl.Cursor(); c != 0 { - t.Fatalf("cursor = %d, want 0 (alpha's \"First plugin\")", c) + // Rows: jwt-validation, (app), token-exchange, available, alpha, beta. + if c := m.pipelineTbl.Cursor(); c != 4 { + t.Fatalf("cursor = %d, want 4 (the available row alpha)", c) } m.Update(keyRune('n')) - if c := m.catalogTbl.Cursor(); c != 0 { + if c := m.pipelineTbl.Cursor(); c != 4 { t.Errorf("n with one match moved the cursor to %d", c) } - if got := m.catalogTbl.Matches(); !slices.Equal(got, []int{0}) { - t.Errorf("Matches = %v, want [0]", got) + if got := m.pipelineTbl.Matches(); !slices.Equal(got, []int{4}) { + t.Errorf("Matches = %v, want [4]", got) } } @@ -188,7 +187,7 @@ func TestHelp_SearchIsAnAnywhereKey(t *testing.T) { // agentop exits, so those three stay. func TestSearch_LeavingTheConnectionClearsItsSearches(t *testing.T) { m := newPanesModel(t) - for p, q := range map[paneID]string{panePipeline: "jwt", paneCatalog: "alpha", panePods: "weather"} { + for p, q := range map[paneID]string{panePipeline: "jwt", paneAgents: "claude", panePods: "weather"} { m.pane = p typeKeys(m, "/"+q) press(m, tea.KeyEnter) @@ -202,7 +201,7 @@ func TestSearch_LeavingTheConnectionClearsItsSearches(t *testing.T) { } m.backToPodsPane() - for p, tbl := range map[paneID]*table.Model{panePipeline: &m.pipelineTbl, paneCatalog: &m.catalogTbl} { + for p, tbl := range map[paneID]*table.Model{panePipeline: &m.pipelineTbl, paneAgents: &m.agentsTbl} { if m.search[p] != "" || len(tbl.Matches()) != 0 { t.Errorf("pane %v kept its search: query %q, matches %v", p, m.search[p], tbl.Matches()) } diff --git a/cmd/agentop/tui/search_surfaces.go b/cmd/agentop/tui/search_surfaces.go index 4c93b6042..72da2a249 100644 --- a/cmd/agentop/tui/search_surfaces.go +++ b/cmd/agentop/tui/search_surfaces.go @@ -17,8 +17,6 @@ func (m *model) surface(t paneID) searchSurface { return eventsSurface{m} case panePipeline: return tableSurface{m, t, &m.pipelineTbl} - case paneCatalog: - return tableSurface{m, t, &m.catalogTbl} case paneAgents: return tableSurface{m, t, &m.agentsTbl} case paneNamespaces: diff --git a/cmd/agentop/tui/settings_persist_test.go b/cmd/agentop/tui/settings_persist_test.go index 4145a84c2..5cfcf05db 100644 --- a/cmd/agentop/tui/settings_persist_test.go +++ b/cmd/agentop/tui/settings_persist_test.go @@ -435,7 +435,7 @@ func TestUsagePane_ViewChoicesArePersisted(t *testing.T) { }{ {"m cycles the metric", 'm', func(u UsageSettings) bool { return u.Metric != "" }, "Metric"}, {"w cycles the window", 'w', func(u UsageSettings) bool { return u.Window != "" }, "Window"}, - {"b cycles the breakdown", 'b', func(u UsageSettings) bool { return u.Group != "" }, "Group"}, + {"o cycles the breakdown", 'o', func(u UsageSettings) bool { return u.Group != "" }, "Group"}, } { t.Run(tc.name, func(t *testing.T) { m := newTestEventsModel(t) diff --git a/cmd/agentop/tui/spend_band_test.go b/cmd/agentop/tui/spend_band_test.go index 2c4dafd96..b307696ff 100644 --- a/cmd/agentop/tui/spend_band_test.go +++ b/cmd/agentop/tui/spend_band_test.go @@ -1155,7 +1155,7 @@ func TestSpendBandNeedsScopeMarker_EveryPaneIsClassified(t *testing.T) { // its own header, and a user who scoped it to one session chose that. manySessions := map[paneID]bool{ paneSessions: true, panePipeline: true, panePluginDetail: true, - paneCatalog: true, paneUsage: true, paneAgents: true, + paneUsage: true, paneAgents: true, paneNamespaces: true, panePods: true, } diff --git a/cmd/agentop/tui/spend_drawer.go b/cmd/agentop/tui/spend_drawer.go index e29578360..fb911a9c1 100644 --- a/cmd/agentop/tui/spend_drawer.go +++ b/cmd/agentop/tui/spend_drawer.go @@ -286,7 +286,7 @@ func spendDrawerHostPane(pane paneID) (bool, string) { // its key handler runs before this one and returns, so the drawer's own keys could never // reach it. A drawer whose hint line advertises [w] on the one pane where `w` belongs to // something else is a lie printed on screen. - return false, "spend: the usage pane is the breakdown — use its own [b] and [w]" + return false, "spend: the usage pane is the breakdown — use its own [o] and [w]" case paneTimeline: // Its own [w] picks the time window, and runs before the drawer's. return false, "spend: the timeline's [w] is its window — open the drawer from the events pane" diff --git a/cmd/agentop/tui/spend_drawer_test.go b/cmd/agentop/tui/spend_drawer_test.go index 581317138..8b4eaf0d5 100644 --- a/cmd/agentop/tui/spend_drawer_test.go +++ b/cmd/agentop/tui/spend_drawer_test.go @@ -635,7 +635,7 @@ func TestToggleSpendDrawer_RefusesPerPaneWithTheRightReason(t *testing.T) { {name: "namespaces picker", pane: paneNamespaces, wantSub: "until a pod is connected"}, // That pane IS the breakdown, and it owns the keys the drawer's hint line would // advertise. - {name: "usage pane", pane: paneUsage, wantSub: "usage pane is the breakdown"}, + {name: "usage pane", pane: paneUsage, wantSub: "usage pane is the breakdown — use its own [o] and [w]"}, } { t.Run(tc.name, func(t *testing.T) { // A terminal with ample room, so height cannot be the cause of any refusal. @@ -906,7 +906,6 @@ func TestSpendDrawerHost_CoversEveryPane(t *testing.T) { paneDetail: true, panePipeline: true, panePluginDetail: true, - paneCatalog: true, } for p := paneID(0); p <= lastPaneID; p++ { expect, listed := want[p] diff --git a/cmd/agentop/tui/spend_strip_test.go b/cmd/agentop/tui/spend_strip_test.go index 9ca705b56..684dfe00b 100644 --- a/cmd/agentop/tui/spend_strip_test.go +++ b/cmd/agentop/tui/spend_strip_test.go @@ -98,7 +98,7 @@ func TestSpendStripVisible_HiddenOnPreConnectionPickers(t *testing.T) { } func TestSpendStripVisible_ShownOnTheDataPanes(t *testing.T) { - for _, p := range []paneID{paneSessions, paneEvents, paneDetail, panePipeline, paneUsage, paneCatalog} { + for _, p := range []paneID{paneSessions, paneEvents, paneDetail, panePipeline, paneUsage} { m := &model{height: 40} m.pane = p if !m.spendStripVisible() { diff --git a/cmd/agentop/tui/usage_state_test.go b/cmd/agentop/tui/usage_state_test.go index 8e4cd05cc..409dc16ca 100644 --- a/cmd/agentop/tui/usage_state_test.go +++ b/cmd/agentop/tui/usage_state_test.go @@ -94,26 +94,26 @@ func TestUsage_StaleTickChainDoesNotReschedule(t *testing.T) { } } -// esc must return to the pane Usage was opened from, even after the catalog -// overlay has been opened on top. model.previousPane is shared with the catalog, +// esc must return to the pane Usage was opened from, even after the agents +// pane has been opened on top. model.previousPane is shared with that pane, // so relying on it sent esc to Sessions instead of Events. -func TestUsage_ReturnPaneSurvivesCatalogOverlay(t *testing.T) { +func TestUsage_ReturnPaneSurvivesAgentsOverlay(t *testing.T) { m := &model{pane: paneEvents, selectedSess: "s1", previousPane: paneNone} m.openUsage("s1") if m.usage.returnPane != paneEvents { t.Fatalf("returnPane = %v, want paneEvents", m.usage.returnPane) } - // Simulate opening the catalog from Usage and escaping back out of it: the - // catalog uses previousPane and clears it on the way out. + // Simulate opening the agents pane from Usage and escaping back out of it: it + // uses previousPane and clears it on the way out. m.previousPane = paneUsage - m.pane = paneCatalog + m.pane = paneAgents m.previousPane = paneNone m.pane = paneUsage // Usage's own esc must still know where it came from. if m.usage.returnPane != paneEvents { - t.Errorf("returnPane = %v after a catalog round trip, want paneEvents", m.usage.returnPane) + t.Errorf("returnPane = %v after an agents round trip, want paneEvents", m.usage.returnPane) } } @@ -227,30 +227,30 @@ func TestRenderUsageChart_PicksTheRightForm(t *testing.T) { } } -// Returning into Usage from the catalog overlay must restart the poll chain. -// The tick in flight when the catalog opened was dropped by the focus guard, so +// Returning into Usage from the agents pane must restart the poll chain. +// The tick in flight when that pane opened was dropped by the focus guard, so // without an explicit restart the 20s auto-refresh is silently dead: the chart // freezes and only `r` (a one-shot refetch) or backing all the way out and // re-entering with `u` brings it back. -func TestUsage_CatalogRoundTripRestartsPolling(t *testing.T) { +func TestUsage_AgentsRoundTripRestartsPolling(t *testing.T) { m := &model{pane: paneEvents, selectedSess: "s1", previousPane: paneNone} m.openUsage("s1") genBefore := m.usage.tickGen - // P opens the catalog from Usage; previousPane records where to return. + // A opens the agents pane from Usage; previousPane records where to return. m.previousPane = paneUsage - m.pane = paneCatalog + m.pane = paneAgents - // A tick from the pre-catalog chain arrives while the catalog has focus and + // A tick from the earlier chain arrives while the agents pane has focus and // is dropped — this is what leaves nothing scheduled. if _, cmd := m.Update(usageTickMsg{gen: genBefore}); cmd != nil { - t.Error("a tick was rescheduled while the catalog had focus") + t.Error("a tick was rescheduled while the agents pane had focus") } - // esc out of the catalog, back into Usage. + // esc out of the agents pane, back into Usage. cmd := m.handleKey(tea.KeyMsg{Type: tea.KeyEsc}) if m.pane != paneUsage { - t.Fatalf("pane = %v after esc from catalog, want paneUsage", m.pane) + t.Fatalf("pane = %v after esc from the agents pane, want paneUsage", m.pane) } if cmd == nil { t.Fatal("returning into Usage scheduled no work — the poll chain is dead") @@ -265,7 +265,7 @@ func TestUsage_CatalogRoundTripRestartsPolling(t *testing.T) { t.Error("the restarted chain does not reschedule") } if _, c := m.Update(usageTickMsg{gen: genBefore}); c != nil { - t.Error("the pre-catalog chain is still alive — two chains would double the poll rate") + t.Error("the earlier chain is still alive — two chains would double the poll rate") } } diff --git a/docs/using-agentop.md b/docs/using-agentop.md index 918c8d0b4..ef3b8e47e 100644 --- a/docs/using-agentop.md +++ b/docs/using-agentop.md @@ -14,8 +14,8 @@ For every flag and key, read the [agentop reference](../cmd/agentop/README.md). | See charts of tokens, requests, errors, latency and cost | `u` | [Usage](#see-charts-usage) | | Change the inference server of an agent or a session | `S` | [Servers](#change-the-inference-server) | | Find text in any pane | `/` | [Search](#search) | -| See, add and change the plugins that run | `P`, `C` | [Plugins](#see-and-change-the-plugins) | -| Erase sessions, in memory and on disk | `x`, `X` | [Erase history](#erase-history) | +| See, add and change the plugins that run | `P` | [Plugins](#see-and-change-the-plugins) | +| Erase sessions, in memory and on disk | `x` | [Erase history](#erase-history) | ## Open it @@ -186,8 +186,7 @@ On Sessions, the charts show all sessions. On Events or Detail, they show the se |---|---| | `m` | Change the metric: tokens, requests, errors, latency or cost | | `w` | Change the window: 10m, 1h or 6h | -| `b` | Change the breakdown: none, status, method, plugin or host. Not for latency, or when the view is scoped to an agent or a project | -| `s` | Change between this session and all sessions | +| `o` | Change the breakdown: none, status, method, plugin or host. Not for latency, or when the view is scoped to an agent or a project | ## Change the inference server @@ -210,8 +209,8 @@ On the Events pane, press `Tab` after `/` to search the details of each row. - `P` opens the Pipeline pane. It shows the plugins that run, in order. - On the Pipeline pane, `e` opens the pipeline in `$EDITOR`. When you save, agentop shows the change, and `y` applies it. Cortex loads the new pipeline with no restart. -- `C` opens the catalog of all the plugins that Cortex has, also the plugins that do not run. -- `Enter` on a Pipeline or Catalog row shows the plugin. +- Under the plugins that run, the `available` section lists the plugins that Cortex has but does not run. +- `Enter` on a Pipeline row shows the plugin. Read [Editing the pipeline](../cmd/agentop/README.md#editing-the-pipeline) and the [plugin catalog](plugin-catalog.md). @@ -222,7 +221,7 @@ You cannot get them back. agentop asks before it deletes. - `x` on Sessions erases the highlighted session. - `x` on Agents erases all sessions of the highlighted agent. -- `X` on Sessions erases all sessions. +- `x` on the *All agents* row of the Agents pane erases all sessions. The cost history stays. When an agent still uses a session, its next request starts that session again. @@ -242,11 +241,10 @@ When an agent still uses a session, its next request starts that session again. | `A` | Open the Agents pane | | `S` | On Agents, select the server for the new sessions of the agent. On Sessions, move the session to a different server | | `P` | Open the Pipeline pane | -| `C` | Open the plugin catalog | | `c` | On Events, open the column picker | | `s` | On Events, hide or show the exchanges that no plugin acted on | | `y` | On Detail, write the event to a file | -| `x` / `X` | On Sessions, erase the session / all sessions. On Agents, `x` erases the sessions of the agent | +| `x` | On Sessions, erase the session. On Agents, erase the sessions of the agent, or all sessions on the *All agents* row | | `p` | Pause or resume the live stream | | `q` / `Ctrl+C` | Quit |