Repository navigation
Description
Summary
tmuxp ls lists YAML and JSON workspace files on disk rather than running tmux servers, leaving users who work across multiple -L or -S sockets no tmuxp command to inspect active servers and sessions. Adding a tmuxp lobby subcommand backed by libtmux local server discovery (tmux-python/libtmux#764) lets tmuxp scan local sockets without starting dead servers and display the exact -L or -S commands to target each one. Supporting non-interactive output (human, --json, --ndjson) by default alongside an opt-in interactive selector covers both shell scripting and quick terminal switching.
Motivation
In tmuxp v1.84.0 (e250218), tmuxp load, tmuxp freeze, and tmuxp shell already accept -L <socket-name> and -S <socket-path>, whereas tmuxp ls inspects workspace files in the current directory tree and ~/.tmuxp/ without querying any tmux daemon. Users running isolated development, test, or agent servers across /tmp/tmux-<uid>/, $TMUX_TMPDIR, $TMUX, or project-local socket paths have to list socket directories manually, probe which sockets are alive versus stale, and hand-construct -L or -S flags for tmuxp and tmux.
Distinguishing -L from -S is error-prone by hand. A socket inside tmux's active socket directory (/tmp/tmux-<uid>/<name> or $TMUX_TMPDIR/tmux-<uid>/<name>) is addressable via -L <name>, whereas a socket at any other path requires -S <socket-path> because -L resolves only inside tmux's default directory.
Evidence
In tmuxp v1.84.0:
src/tmuxp/cli/ls.pylines 553-646 enumerates local and global workspace files throughOutputFormatter(HUMAN,JSON,NDJSON, and--tree).src/tmuxp/cli/load.pylines 748-761,src/tmuxp/cli/freeze.pylines 75-86, andsrc/tmuxp/cli/shell.pylines 74-85 accept-L(socket_name) and-S(socket_path).src/tmuxp/cli/utils.pylines 176-233 providesPrivatePath(~masking) andprompt_choicesfor terminal selection prompts without extra TUI dependencies.
Upstream in tmux-python/libtmux#764 (with final API naming tracked in tmux-python/libtmux#924), TmuxLobby scans /tmp/tmux-<uid>, $TMUX_TMPDIR, $TMUX, and custom paths or patterns with bounded non-starting probes, returning QueryList[TmuxLobbyServer] entries carrying alive, server, socket_name, socket_path, uid, pid, version, error, and .sessions / .windows / .panes.
Socket flag definitions in tmuxp v1.84.0
src/tmuxp/cli/load.py lines 748-761:
parser.add_argument(
"-L",
dest="socket_name",
metavar="socket_name",
action="store",
help="passthru to tmux(1) -L",
)
parser.add_argument(
"-S",
dest="socket_path",
metavar="socket_path",
action="store",
help="passthru to tmux(1) -S",
)Proposal
- Add
tmuxp lobby(src/tmuxp/cli/lobby.py) backed bylibtmux's server discovery API (tmux-python/libtmux#764/tmux-python/libtmux#924), supporting--pathand--patternfor extra socket locations plus--allto show stale or unresponsive sockets (alive=False, with probeerrortext) alongside live servers. - Default to non-interactive output through
OutputFormatter(human,--json,--ndjson, and--treeto expand each server's sessions, window counts, and attached clients) withPrivatePathhome-directory masking. - Display ready-to-run
tmuxpandtmuxcommands per discovered server, selecting-L <socket-name>whensocket_pathsits directly inside tmux's active socket directory and-S <socket-path>otherwise (shell-escaped viashlex.quote): for exampletmuxp load -L work <workspace>,tmuxp shell -L work,tmuxp freeze -L work <session>, andtmux -L work attach(or-S ./dev.sockfor custom paths). - Add an opt-in interactive display (
-i/--interactiveon a TTY) that lists live servers and sessions and lets the user attach (attachoutside tmux,switch-clientwhen$TMUXis set), opentmuxp shell, or runtmuxp freezeagainst the selected target.
Alternatives
Adding a --servers flag to tmuxp ls would avoid introducing a new top-level subcommand, at the cost of coupling static YAML and JSON file discovery (workspaces and global_workspace_dirs in tmuxp ls --json) with live socket probes and divergent JSON schemas. Leaving users to inspect /tmp/tmux-$(id -u) by hand misses $TMUX_TMPDIR, $TMUX, and project-local sockets, and bare tmux commands against stale sockets risk starting unintended daemons or hanging without a probe timeout. Dedicating tmuxp lobby to live server discovery keeps tmuxp ls focused on workspace files while aligning with libtmux's discovery vocabulary.
References
- Upstream
TmuxLobbypull request:tmux-python/libtmux#764 - Upstream local server discovery API selection:
tmux-python/libtmux#924 - Related socket-in-configuration feature request: Set socket in configuration #577
Activity