Repository navigation
feat(ui): delete a session on an SSH connection - #1086
Conversation
d, and Delete in the row menu, on an agent under an SSH connection now asks, then runs `agent-manager delete` on its host, the call delete_session already makes. The host's delete, from wainmann#1045, removes the pane, the row, the terminals under the agent and a clean worktree with its am/ branch, so the confirm counts those terminals the way a local delete does. When the host keeps a worktree, the status line says the agent was deleted there and why the worktree stayed. A host older than v0.49.0 does not know delete and fails with the existing "too old" error. d on a remote terminal closes it, as x does, since the host's delete takes agents only. Deleting a group on a connection stays refused, and the refusal now names the group: the host's delete-group moves its sessions to the root instead of deleting them. Part of wainmann#876.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
YoanWai
left a comment
There was a problem hiding this comment.
Thanks, merged! Ships in the next release.
What changed
don an agent under an SSH connection, or Delete in its row menu, now asks first and then deletes the agent on its host, the wayddeletes one on this machine. Before, it stopped with "delete isn't available on SSH connections yet".agent-manager delete --json -- <id>there, the calldelete_sessionalready makes for ahost::id(feat(cli): delete a session from the CLI and MCP #1045). That command removes the pane, the row, the terminals nested under the agent, and a clean worktree with itsam/branch, as a local delete does. The status line saysdeleted <name> on <host>, and the host is read again.delete api on box and 2 terminals? kills their tmux sessions there.The count is the host's terminals whose parent is the row, archived ones included, since the host'sdeletetakes those too.deleted <name> on <host>; worktree kept (has work): <path>, with the error style a local delete gives that notice.don a remote terminal closes it, asxdoes. The host'sdeletetakes agents only, andterminal closealready removes the terminal there, the way a local delete removes a local one.don a remote group still refuses, and now says what is missing:deleting a group isn't available on SSH connections yet.d delete, and the row menu offers Delete on live, dead and archived remote agents. The?key map lists delete among a connection's agent actions.docs/usage.mdanddocs/ssh-connections.mddrop delete from the refused list. The comment onremote.Client.Deletesaid the host refuses a worktree with unsaved work. It now says what the host does.tools/e2e/README.mdnow lists everything the scenario drives. It claimed attach is left to the unit tests, but the scenario already attaches. Happy to split that out if you prefer.Why
Kill, revive, archive and restore already run on the host, and delete did not, although the host side shipped in v0.49.0 with
agent-manager deleteandremote.Client.Delete. Only the list never called it.Part of #876
Scope
Required behavior
dand the menu's Delete on a remote agent (live, dead or archived) ask, then delete it on its host. No ssh call goes out before the answer, and none to an offline host.deletefails with a message that says to update it.don a remote group stays refused, with "deleting a group isn't available on SSH connections yet".don the connection row still removes the connection.Why this approach
It is the pattern kill, revive, archive and restore already use: one
Opininternal/ui/connectionswith its confirm, one entry inremoteOp, and oneuilink.Opthat calls the existing client method. No new protocol, host command, version check or setting.The terminal count sits on
connections.Row, filled where the row is found in the host's last snapshot.confirmRemotewords the delete confirm throughuisession.FollowConfirmLabel, the helper the local delete confirm uses, so both read the same.internal/ui/connectionsmay not importinternal/ui/session, so the wording happens in the root adapter, which already does.A host older than v0.49.0 does not know
delete. It falls through to its interactive manager, anddecodealready turns that intoagent-manager there is too old for SSH connections; update agent-manager on that host. This PR pins that with one test line and adds no code for it. The message says "for SSH connections" although every other call to that host still works. I left that wording alone because every older-host call shares it.Deleting a group on a connection stays out. The host's
delete-groupmoves its sessions to the root and keeps them running, whiledon a local group deletes them, so matching the key needs a new host call. It stays in #876 with the other actions there.Tool coverage
No tool-dependent behavior. The call deletes whatever agent the host runs, through the host's own
delete, which is the same for every CLI inbuiltinTools. Driven with the e2e fixture CLI (command-codeon a stub binary).How it was verified
Branch head 53a6b53, on main d8d389f. I rebased just before opening this. The full suite, the e2e and the real ssh drive ran on 7a4e9e5, which is the same commit on main f9b267e, and "Head" below means that commit. After the rebase I re-ran gofmt, vet, build and the tests under
internal/ui,internal/remoteandinternal/sessioncmd. They pass except the echo-latency test ininternal/ui/focus/watch, which CI skips on macOS.MRE first. Before the fix, the new rows in
TestRemoteActionsBuildTheirRemoteCallfailed withcalls = [], want one ["delete" "--json" "--" "s1"], and the SSH e2e scenario's new delete step timed out waiting for the confirm. On a build of main over a real ssh connection,dshoweddelete isn't available on SSH connections yet(frame below).Each new test fails without its fix. The terminal count, the notice line and the group refusal were checked on head; the rest on the first revision of this branch, where those tests were written.
SessionCalldelete branch, the adapter rows andTestSessionCallAnswersEveryRemoteActionfail.TestRowFindsAgentsAndTerminalsandTestRemoteDeleteConfirmCountsTheTerminalsItTakesfail (label "delete api on box? kills its tmux session there.", want "delete api on box and 2 terminals? kills their tmux sessions there.").TestADeleteReportsTheHostsNoticefails.TestUnsupportedRemoteActionsAreRefusedWithoutIOfails.TestRemoteLegendOffersDeleteOnAnAgentOnlyandTestConnectionMenusOfferOnlyRemoteActionsfail.e2e.
tools/e2e/ssh_scenarios.pynow deletes the grouped agent after the restore step:d, the confirm,deleted api on box, and the host's store no longer has the row. It passes on head.Real ssh. A build of head on its own socket and profile, with a connection to
localhostwhose binary is a wrapper that gives the host its ownHOME, profile and tmux socket. Before any delete, that host listed only the throwaway rows. Driven:don a remote group:deleting a group isn't available on SSH connections yet.don an agent: confirm,deleted plain on studio-iso, row gone, and the host'ssessionsand tmux server no longer have it.don an agent with two nested terminals:delete nest on studio-iso and 2 terminals? kills their tmux sessions there., then the agent and both terminals are gone from the host's snapshot and tmux server.don an agent with a clean worktree:deleted clean-wt on studio-iso, and on the host the worktree directory, itsgit worktreeentry and theam/clean-wtbranch are gone.deleted dirty-wt on studio-iso; worktree kept (has work): /private/tmp/…/repo-worktrees/dirty-wt. The host kept the worktree, the file and theam/dirty-wtbranch.don a remote terminal:close terminal loose-sh on studio-iso?, then gone on the host.d, confirm, thenold-host: agent-manager there is too old for SSH connections; update agent-manager on that host. The session stayed on that host.gofmt -l .prints nothinggo vet ./...passesmkdir -p /tmp/amtest && env -u TMUX TMUX_TMPDIR=/tmp/amtest go test -race ./...passes: everything exceptinternal/clipboardTestDarwinLiveCopy, which fails the same way on unchanged main (see the table)go build ./...passesRan it against real sessions
New behavior covers every applicable CLI, or Scope establishes a tool-specific fix, new CLI, or explicitly accepted feature exception
Holds for every supported platform (macOS, Linux, WSL2) and terminal including over SSH, or the description names what it leaves out
Every new action works by keyboard and by mouse, and every new setting lives on a Settings row
What ran where:
go test -race ./..., macOS, localinternal/clipboardTestDarwinLiveCopyfails.TestDarwinLiveCopyalone on unchanged main (f9b267e)pbpastereturns what the clipboard already held.go list -deps ./internal/clipboardnames onlytermseqandwslfrom this module.tools/e2e/ssh_scenarios.py)gofmt,go vet ./...,go build ./..., staticcheck 2026.2.2,check-ui-boundaries,check-file-names,check-file-sizesOnly macOS was driven, as the local machine and as the host. The change adds no platform or terminal branch: it reuses the confirm, the row menu and the remote call path kill already takes. I did not drive Linux, WSL2, or a Windows local machine.
Visual evidence
Text frames read back with
tmux capture-pane -p, as Capturing a TUI frame in CONTRIBUTING describes. Both builds ran on their own socket and profile against an isolated host over a realssh localhost. Each block is lines cut unchanged from one frame; blank lines separate frames or skipped rows.Before:
don a remote agent, on a build of main.After: the footer on a remote agent names
d:The rail with an agent that has two terminals nested under it (frame
04-plain-done), then the confirmdopens on it (frame05-nest-confirm), which counts them:After
dandyon another agent,plain, its row goes, and the host has no such session anymore:A clean worktree goes with the agent. Before the delete, the host's
git worktree listalso listedrepo-worktrees/clean-wt [am/clean-wt], andgit branch --listlistedam/clean-wt(07-host-git-before-clean.txt). After it (08-host-after-clean.txt):The row menu offers Delete (frame
09-dirty-row-menu), and a worktree with unsaved work stays on the host, with the notice (frame11-dirty-notice):don a remote group:A host on v0.48.1 (frame
blackbox/09-old-host-delete, first revision of this branch):Summary by CodeRabbit
don a terminal closes it, likex.