Skip to content

feature: agentop TUI switches the server for a key from S #1981

Closed

Description

@huang195

Part C2 of #1975 (agentop TUI). Parent design: #1975. Depends on B (the key_routes: config map, the key_of invocation detail and SessionSummary.InferenceKeyOf) and A1/A2 (SessionSummary.InferenceServer). Also depends on C1 (servers.KeyRouteChanges, the --key-of commands).

Problem

After C1, the user can switch the server for a key from the shell (agentop server use <s> --key-of <s>). The TUI cannot do it, and it does not show which key a session sent. The TUI and the shell must do the same things.

Goal

The user can switch the server for a key from the TUI and see the effect before they apply it. A key is never shown: agentop names a key only by its server's name.

key_routes: is one hop only (as B defines it): with {team-b: team-a, team-a: team-c}, team-b's key goes to team-a.

Sessions pane S (cmd/agentop/tui/server_picker.go)

Today the picker has one step: select a server, Enter moves the session (openSessionServerPicker :200, serverPickerKey :161, applyServerChoice :243-275).

New: when the session's summary has InferenceKeyOf (sub-issue B) that names a configured server, Enter on a server opens a second step:

Move to: team-a

  > This session only
    This session and new sessions that send team-b's key   (2 other running sessions stay on team-b)
  • Row 1 does what Enter does today (SessionChanges).
  • Row 2 writes SessionChanges and KeyRouteChanges(team-b, team-a) in one WritePluginConfig. When the target is team-b itself, it removes the key_routes entry.
  • Row 2 does not move the other running sessions. A switch changes only new sessions, as the Agents pane switch does today. "N other running sessions stay on team-b" counts the other conversation sessions in m.sessions whose InferenceKeyOf is team-b and whose server is team-b. Follow sessionsStaying (:478-491). With N = 0, leave the note out.
  • The helper servers.KeyRouteChanges comes from C1.
  • When the session's agent has an agents: entry, row 2 stays and says why it has no effect for that agent: (claude-code ignores this: the Agents pane sends it to glm).
  • Esc on the second step goes back to the server list.
  • With no InferenceKeyOf, the picker stays one step, as today.
  • The flash after the change (serverSwitchedText :366, sessionSwitchedText :418) says what row 2 changed.

The picker opens its cursor on the session's server from InferenceServer (A2 changes :230).

Agents pane S (openServerPicker, server_picker.go:136)

  • The row ownChoiceEntry = "its own choice (not routed)" (:552) becomes Each terminal's key decides. It writes the same change as today (removes the agent's agents: entry).
  • Under it, a muted line counts the agent's conversation sessions in m.sessions by the server each one goes to by key: the key_routes: target of its InferenceKeyOf (one hop), else InferenceKeyOf. Example: now: 2 sessions → team-b, 1 → team-a. With no session that sent a known key: no session sends a known key now.
  • The SERVER cell for an agent with no agents: entry (agentOwnChoice = "own choice", server_route.go:116) becomes by key.

Docs (cmd/agentop/README.md)

  • "Choosing an agent's server (S)" (:1028-1075): the renamed row and its count line (:1039, :1053).
  • "Choosing an inference server" (:1241-1275): the Sessions pane second step. Fix :1268: it says the Sessions pane move confirms the cost first. It does not. It shows a muted line about the cost (server_picker.go:606-607).

Acceptance

Tests assert on substrings, as the existing ones do (tui/server_picker_test.go, sessions_server_test.go:114, server_route_test.go:322):

  • Sessions pane: a session with InferenceKeyOf: team-b gets the second step; row 1 writes only the session entry; row 2 writes the session entry and the key_routes entry and moves no other session; the "stay on team-b" count is right; a session with no InferenceKeyOf gets one step; the "ignores this" text appears when the agent has an agents: entry; Esc goes back.
  • Agents pane: the renamed row, the count line, and by key in the SERVER cell.
  • Run scripts/dev/go-test-shards.sh -short cmd/agentop while you work, and once scripts/dev/go-test-shards.sh -race cmd/agentop plus go test -race $(go list ./... | grep -v 'agentop$') from cmd/agentop before the PR.

Assisted-By: Claude (Anthropic AI) noreply@anthropic.com

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementlaptop

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions