Skip to content

Commit d563d21

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 1eaf801 commit d563d21

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:
@@ -182,28 +181,24 @@ def fetch_objs(
182181
list_cmd: ListCmd,
183182
list_extra_args: ListExtraArgs = None,
184183
) -> OutputsRaw:
185-
"""Fetch a listing of raw data from a tmux command."""
186-
formats = list(Obj.__dataclass_fields__.keys())
187-
188-
cmd_args: list[str | int] = []
184+
"""Fetch a listing of raw data from a tmux command.
189185
190-
if server.socket_name:
191-
cmd_args.insert(0, f"-L{server.socket_name}")
192-
if server.socket_path:
193-
cmd_args.insert(0, f"-S{server.socket_path}")
186+
Routes all commands through the server's engine, enabling:
187+
- Control mode persistent connection for fetch operations
188+
- Engine-specific validation (e.g., attach_to preflight checks)
189+
- Consistent error handling across all tmux operations
190+
"""
191+
formats = list(Obj.__dataclass_fields__.keys())
194192
tmux_formats = [f"#{{{f}}}{FORMAT_SEPARATOR}" for f in formats]
195193

196-
tmux_cmds = [
197-
*cmd_args,
198-
list_cmd,
199-
]
200-
194+
# Build command arguments for the list command
195+
cmd_args: list[str] = []
201196
if list_extra_args is not None and isinstance(list_extra_args, Iterable):
202-
tmux_cmds.extend(list(list_extra_args))
203-
204-
tmux_cmds.append("-F{}".format("".join(tmux_formats)))
197+
cmd_args.extend(list(list_extra_args))
198+
cmd_args.append("-F{}".format("".join(tmux_formats)))
205199

206-
proc = tmux_cmd(*tmux_cmds) # output
200+
# Route through engine via server.cmd()
201+
proc = server.cmd(list_cmd, *cmd_args)
207202

208203
if proc.stderr:
209204
raise exc.LibTmuxException(proc.stderr)

0 commit comments

Comments
 (0)