Repository navigation
feat(cli): focus a session from outside the TUI - #1087
Draft
agent-manager-bots[bot] wants to merge 4 commits into
Draft
agent-manager-bots[bot] wants to merge 4 commits into
agent-manager-bots[bot] wants to merge 4 commits into
Conversation
agent-manager focus <session-id> and select <session-id> bring a session forward in the running manager from any shell. The manager answers on a Unix socket beside its tmux server's socket. The command connects, sends the session id and whether to open it, and reads back on the same connection what the manager did. Nothing is signalled and no request is shared, so a request cannot be answered for another, and the exit status reports the manager's own outcome. On a request the manager unfolds the groups above the session, drops a status filter hiding it and moves the cursor. focus then runs what enter does on that row and answers once the open lands. Layers that hold nothing typed (help, messages, the search, the row menu, a lifted row, a divider drag) close the way esc closes them. A dialog that may hold unfinished input stays open with the cursor moved under it, and focus reports that it did not open the session. A select leaves focus even on the session it names. A clicked notification takes the same select path, so it reaches sessions in folded groups. focus_session exposes the focus command over MCP. Ported from #726 onto the package layout #735 introduced. Refs #725
Each manager window now listens on its own socket, named after its process, beside the tmux server's socket. The command connects to every one that answers. None answering means no window is running, and two or more means the request is refused naming their processes, since nothing says which window the user is looking at. A socket left by a manager that crashed refuses the connection, so it never stands in for a live one, and a manager starting up removes such sockets once they are a minute old. Nothing is ever signalled by a recorded process id. A manager that cannot listen now says so on the status bar instead of staying silently unreachable, and it creates the tmux socket directory the way tmux does when it starts before the tmux server. A clicked notification leaves the user in the session when that is the one it names, as it did before, and moves the cursor like a select otherwise. A request for a live session while the archive view is on switches back to the live list. Closes #725
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
Staticcheck ST1005 rejects error strings that open with a capital.
Windows cannot set times on a Unix socket, so the sweep takes the current time and the test runs it as if an hour later. The sweep reads the socket with Lstat.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
agent-manager focus <session-id>andagent-manager select <session-id>bring a session forward in the running manager window from any shell, and thefocus_sessionMCP tool does whatfocusdoes. The manager unfolds the groups above the session, drops a status filter or the archive view if it hides the row, moves the cursor there and, forfocus, opens it the way enter does. Help, messages, the search and the row menu close the way esc closes them. A dialog that may hold typed input stays open with the cursor moved under it.This supersedes #726 (feat(cli): focus a session from outside the TUI, #726) by @calsmith1-nokia. The first commit is his work, authored by him and ported onto the package layout from #735. The second commit is mine.
Changes vs #726
Review cases from the 2026-10-07 review
selectleaves focus even on that session.Extras from #725 (CLI command to focus a session from outside the TUI, applied immediately rather than on the next poll, #725), #947 and #1084
--jsonprints the reason as anerrorobject.focus_session, described as one to call only when the user asked to be taken to a session.Conflict resolution
internal/sessioncmd/focus_endpoint.go, the reveal logic inrail.Model.RevealSession, and the request handling ininternal/ui/rail_adapter_forward.go, to fit the file and boundary checks.addTool,toolAnnotationsandtextContentmoved frommcpserver.gotointernal/mcpserver/tools.gosomcpserver.gostays under 1000 lines.Why
Scripts, dashboards and launchers want to take the user to a session without waiting for a poll or racing the manager's state.
Closes #725
Scope
Required behavior
A request reaches only a manager window on the same tmux server, never signals a process, and reports exactly what the manager did.
Why this approach
A per-window Unix socket gives liveness by connecting, a private answer per request, and a way to see that several windows are running.
agent-manager servehas no window and does not listen.Tool coverage
No tool-dependent behavior. It moves the manager's own cursor and opens rows the way enter does for every CLI.
How it was verified
gofmt -l .prints nothinggo vet ./...passesgo test -race ./...(ranenv -u TMUX TMUX_TMPDIR=/tmp/am726t go test -race -p 4 -timeout 30moninternal/sessioncmd,internal/cli,internal/mcpserver,internal/tmux,internal/ui/railandinternal/ui, all pass. CI runs the rest)go build ./...passes, also withGOOS=windowsandGOOS=darwinfocuson a session two folded groups deep unfolded them and focused it, returning in about 70 msselectwhile focused left focus and moved the cursorfocuswith the New Session form open kept the typed name and exited 1 naming the dialogVisual evidence
Not applicable because: the change is a CLI and MCP entry point. Before and after screen captures from the live check are text, and the result shows as the cursor moving to the unfolded row and the FOCUS badge.