feat: add --tmux-socket flag and TmuxClient socket routing - #360
feat: add --tmux-socket flag and TmuxClient socket routing#360kalbasit wants to merge 5 commits into
Conversation
|
This change is part of the following stack: Change managed by git-spice. |
34d1d97 to
d37708f
Compare
Add --tmux-socket <path> to `laio start` (with LAIO_TMUX_SOCKET env var as fallback) so laio can target a specific tmux server socket rather than the default one. When set, -S <path> is prepended to every tmux command so all operations hit the intended server. The flag is named --tmux-socket (not --socket) to make its scope explicit: it is tmux-specific and has no meaning for Zellij. A warning is emitted when --tmux-socket is passed with Zellij. The socket field on TmuxClient is private and exposed only via has_socket() to keep the detail encapsulated within the client. Also refactors process_windows() into process_windows_for() to accept an explicit session name and force_new_windows flag, preparing for in-session mode in the next commit. Tests cover flag parsing, LAIO_TMUX_SOCKET env fallback, and -S prepended to tmux commands. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
d37708f to
92a50f7
Compare
|
@ck3mp3r Thanks for Laio! My project swm makes use of laio, and this PR (and another upcoming PR) are required to make it work. Do you mind giving this a review? |
Inline test modules in source files conflict with the project convention of using separate _test.rs files. Move the Cli socket tests to src/app/cli/command_line_test.rs (declared from mod.rs) and widen resolved_socket() to pub(crate) so the sibling test module can access it.
Introducing a socket path broke the existing cmd_basic!("tmux", ...)
pattern because the socket prefix had to be injected per-call. The
temporary fix used explicit Type::Basic blocks everywhere. Add a
tmux_cmd!(socket, args=[...]) macro that incorporates the socket
prefix, then use it for all static-arg call sites; the two dynamic-
arg sites (create_session env args and register_command send-keys)
retain the tmux_cmd() helper method.
|
@kalbasit I think this use case is very specific to your workflow and changing the cli api and just adding socket support for tmux and not zellij does not feel like sound architecture. Also the implementation feels like a bolt on to be honest. I would have liked a more generic approach. Have you tried using an environment variable inside your cli to control where tmux has the socket for sessions wrapped by your cli? |
Thanks — the bolt-on critique is fair, and I think there's a cleaner path that doesn't add any CLI surface at all.
For zellij, the same pattern would apply with Would dropping |
Problem
When laio is used as a tmux plugin — where tmux runs on a non-default socket — every laio command was silently targeting the default tmux server. This caused laio to operate on the wrong server or fail outright.
Solution
Add a global
--tmux-socket <path>flag (andLAIO_TMUX_SOCKETenv var fallback) that pins all tmux operations to the specified server. The flag lives on the top-level CLI struct so it applies consistently to every subcommand without needing to be threaded through each one manually.TmuxClientstores the socket and prepends-S <path>to every tmux invocationstart,stop,list,config list,session list, andsession yamlall honor the resolved socketM-lpicker popup binding embeds--tmux-socketin the reopenedlaio start --show-pickercommand so the picker re-opens against the same server--tmux-socketwith Zellij emits a warning and is ignored (flag is tmux-specific)Test plan
cargo test --quietpasseslaio --tmux-socket /tmp/my.sock start <session>targets the correct server (tmux -S /tmp/my.sock lsconfirms)LAIO_TMUX_SOCKET=/tmp/my.sock laio start <session>works identically--tmux-sockettakes priority overLAIO_TMUX_SOCKETM-linside a session started with--tmux-socketreopens the picker on the same server