Repository navigation
Description
Parent: #1739. Third of four issues. Depends on: #1815 (SessionSummary.Projects) and #1816 (group=project). Next: #1818.
Problem
The AGENTS pane (A) shows one row per coding agent with SESSIONS, LAST SEEN and COST <window>. It cannot show where an agent's spend went. This issue lets a reader expand an agent row into its projects. The pane is the same as it is today until the reader opens a row.
Target
AGENTS · MONTH SESSIONS LAST SEEN COST MONTH
▸ All agents 212 12s ago $184.20
▾ claude-code
All projects 160 12s ago $151.03
cortex 98 12s ago $97.40
moca 41 2h ago $38.11
Other 21 3d ago $15.52
▸ codex 44 1d ago $30.90
Other 8 5d ago $2.27
Decisions (fixed, do not reopen)
spaceopens and closes the row under the cursor. It is the only new key.spacereaches this pane today only as the table's page-down (table.DefaultKeyMap,table/table.go:119,133-135). On this pane, page-down stays ond,pgdnandf.- Handle
spaceinkeys.gobefore the fall-through tom.agentsTbl.Update(~line 1085). Skip it while a search is active. - On a sub-row,
spacecloses the parent and moves the cursor to the parent row.
- Rows start closed. The open state is a
map[string]boolkeyed by the agent label, with "" for All agents. It is not persisted (no field inUserSettings,settings.go:27-31). A refetch, the 20s poll (agents_pane.go:149),wandAkeep it. - Offer the expansion only when the data exists. A row shows
▸only when some listed session has a non-emptyProjects(asessionsNameProjects()besidesessionsNameAgents(),agents_pane.go:591-598). The agentOtherrow never shows▸: a client-narrowed snapshot has no series (agent_scope.go:12-18). Against an older server, the pane is exactly as it is today. - An open agent row is a heading. It is the label with
▾and blank figure cells. The All agents row already uses blank cells (agents_pane.go:356-364). Its figures move to its first sub-row,All projects, so no number shows twice. A closed row shows▸and its figures as today. Rows that cannot expand get two spaces in that place, so the labels stay aligned. - Sub-rows, in this order:
All projects, then one row per project ordered byusage.SortSeriesLabels, thenOther.Otherfolds theunknownseries (no PID, or the cwd/of an IDE agent that macOS started as an app, see feature: Record a project label on each request and session #1815) and the(other)overflow band (16 series,MaxSeriesInResponse).Otheris left out when its cost is 0 and no session counts in it. The ▸/▾ and the 4-space indent are literal text in the AGENT cell, as the events pane does for subagent blocks (events_blocks.go:49-60). - Project display name: the last path segment of the label. The label
~displays as~, and it is a normal project row, never part ofOther. When two sub-rows of one parent have the same last segment, show for each of them the shortest tail of segments that is unique among those rows. Two segments are not always enough:~/works/go/src/github.com/kagenti/kagenti-extensionsand~/git/kagenti/kagenti-extensionsboth end inkagenti/kagenti-extensions, so they showgithub.com/kagenti/kagenti-extensionsandgit/kagenti/kagenti-extensions. The full label is in the footer when the cursor is on the row. - Spend from before the upgrade is in
Other. Ledger rows written before feature: Cost by project in usage, ledger and agentop cost #1816 have no project and read asunknown. For aMONTHwindow,Othercan hold most of the spend for up to a month after the upgrade. Say this in the?overlay note and in the README. - COST partitions, SESSIONS does not. The projects plus
Otheradd up toAll projects. A session that used two projects counts under both. Say this in the?overlay note for this pane. - In this issue, Enter,
→andlon any sub-row act on the parent agent, as Enter on that agent row does today. feature: agentop: Scope views to a project from the Agents pane #1818 changes project sub-rows.x(erase) andS(server) act on the parent agent on the heading and onAll projects. On project and project-Othersub-rows they do nothing, and the footer does not offer them. - The
$band and drawer follow the cursor's PARENT agent on a sub-row (spendScopeAgent,spend.go:1030-1037). feature: agentop: Scope views to a project from the Agents pane #1818 narrows them to the project.
Design
- Data:
- When a row is open, fetch with the pane's window and resolution:
- a known agent X:
fetchUsageScoped(ctx, client, window, res, X, usage.GroupProject)(agent_scope.go:20) - All agents:
GetUsageWindow(..., usage.GroupProject)
- a known agent X:
- Fold each series across the window with
usage.FoldSeriesAcrossWindow, asagentRowsFromBucketsdoes. - Cost units come from
SeriesCurrencies, asagentRowsFromSnapshotdoes. - Store the result per agent label. Refetch it on the same events that refetch
m.agents: the poll,wandA. - A failed fetch keeps the old sub-rows and shows the error the way the pane shows a failed row fetch.
- When a row is open, fetch with the pane's window and resolution:
- SESSIONS and LAST SEEN for a project sub-row come from
m.sessions, likeagentSessionsCellandagentLastSeen(agents_pane.go:543-575):- a project sub-row: sessions where
agentRowLists(s, parent)is true ands.Projectscontains the label - the project
Othersub-row: those sessions wheres.Projectsis empty - under All agents: drop the agent test
- a project sub-row: sessions where
- Rows and cursor:
rebuildAgentsTable(agents_pane.go:318-391) builds the sub-rows.m.agentRowLabels(app.go:854-855) andselectedAgentScope(agents_pane.go:489-499) must stay in step. Replace the index arithmetic with one slice of row descriptors,{agent, kind, project}, that both of them read.kindis agent, heading, all-projects, project or project-other.- Cursor restore matches on the descriptor.
- Every caller of
selectedAgentScopemust get the parent agent for a sub-row: Enter (keys.go:642), the footer (keys.go:1432),openAgentErase(clear.go:81),server_picker.go:130,137andspendScopeAgent(spend.go:1032).
- Footer and help:
- The footer (
keys.go:1424-1452) adds[space] projectswhen the row under the cursor can expand, and[space] closeon an open row or sub-row. help_overlay.go:400-434: add the binding and the notes from decisions 7 and 8. Stay inside the line budget (TestHelpOverlayScrollHint_AbsentWhenEverythingFits).
- The footer (
- README (
cmd/agentop/README.md): add thespacerow to the keybindings table (~1526-1530) and a paragraph in the Agents prose (~1596-1607). Change the line "spaceanddare the table's page-down" (~1522) to say thatspaceopens projects on the Agents pane.
Acceptance (tests in cmd/agentop/tui/)
Use the existing helpers: scopedModel in agents_scope_test.go and cursorScopeModel in agents_cursor_scope_test.go. The cursorScopeModel server records each query. Tests:
- No session has
Projects: no▸, andspacepages down as before. spaceon claude-code fetchesagent=claude-code&group=project, and the rows match the Target.spaceon All agents fetchesgroup=projectwith noagent=.- Two labels that share a last segment show their shortest unique tails, including the
kagenti-extensionspair from decision 6. unknownand(other)fold into oneOther.Otheris absent when it is 0 and empty.- The open state and the cursor survive a refetch and
w. spaceon a sub-row closes the parent and puts the cursor on it.- Enter on a project sub-row scopes to the parent agent.
xandSdo nothing there. - The band follows the parent agent on a sub-row.
- The agent
Otherrow never expands. - The help overlay fits its budget.
Run scripts/dev/go-test-shards.sh -short cmd/agentop while you work. Before you push, run scripts/dev/go-test-shards.sh -race cmd/agentop.
Out of scope
Scoping views to a project (#1818). A PROJECT column in the Sessions pane. Persisting the open state.
Assisted-By: Claude (Anthropic AI) [email protected]
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
docs: Add the plan for projects on the Agents pane (#1817)
docs: Name the tests that read agentRowLabels in the plan (#1817)
feat: Fold project series into rows for the Agents pane
refactor: Read the Agents rows through one descriptor slice
docs: Describe projects on the Agents pane
Merge pull request #1824 from huang195/feat/agents-projects-1817-pP1-pP1