Skip to content

Commit 25b6c8a

Browse files
committed
neo: Route fetch_objs through engine for unified command execution
Replace direct tmux_cmd() call in fetch_objs() with server.cmd() to route all tmux commands through the server's engine. This provides: - Control mode persistent connection applies to list-sessions/windows/panes - attach_to validation now triggers on first fetch operation - Consistent error handling across all tmux operations - Single execution path for all commands (no more abstraction leak) The attach_missing_session test now passes - engine initialization and attach_to preflight checks happen when server.sessions is accessed.
1 parent eaf08df commit 25b6c8a

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

src/libtmux/neo.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from collections.abc import Iterable
99

1010
from libtmux import exc
11-
from libtmux.common import tmux_cmd
1211
from libtmux.formats import FORMAT_SEPARATOR
1312

1413
if t.TYPE_CHECKING:
@@ -195,28 +194,24 @@ def fetch_objs(
195194
list_cmd: ListCmd,
196195
list_extra_args: ListExtraArgs = None,
197196
) -> OutputsRaw:
198-
"""Fetch a listing of raw data from a tmux command."""
199-
formats = list(Obj.__dataclass_fields__.keys())
200-
201-
cmd_args: list[str | int] = []
197+
"""Fetch a listing of raw data from a tmux command.
202198
203-
if server.socket_name:
204-
cmd_args.insert(0, f"-L{server.socket_name}")
205-
if server.socket_path:
206-
cmd_args.insert(0, f"-S{server.socket_path}")
199+
Routes all commands through the server's engine, enabling:
200+
- Control mode persistent connection for fetch operations
201+
- Engine-specific validation (e.g., attach_to preflight checks)
202+
- Consistent error handling across all tmux operations
203+
"""
204+
formats = list(Obj.__dataclass_fields__.keys())
207205
tmux_formats = [f"#{{{f}}}{FORMAT_SEPARATOR}" for f in formats]
208206

209-
tmux_cmds = [
210-
*cmd_args,
211-
list_cmd,
212-
]
213-
207+
# Build command arguments for the list command
208+
cmd_args: list[str] = []
214209
if list_extra_args is not None and isinstance(list_extra_args, Iterable):
215-
tmux_cmds.extend(list(list_extra_args))
216-
217-
tmux_cmds.append("-F{}".format("".join(tmux_formats)))
210+
cmd_args.extend(list(list_extra_args))
211+
cmd_args.append("-F{}".format("".join(tmux_formats)))
218212

219-
proc = tmux_cmd(*tmux_cmds) # output
213+
# Route through engine via server.cmd()
214+
proc = server.cmd(list_cmd, *cmd_args)
220215

221216
if proc.stderr:
222217
raise exc.LibTmuxException(proc.stderr)

0 commit comments

Comments
 (0)