tmuxp load: Load multiple sessions with --append - #839
Conversation
5466251 to
e090550
Compare
e090550 to
4f20ba2
Compare
1989584 to
b30a864
Compare
why: ``tmuxp load f1 f2 f3 --append`` previously failed on the second file because each file was loaded against its own config's ``session_name``, and the second file's ``new_session`` would collide with the session the first file just created. Multi-file ``--append`` should land every workspace in a single shared target session. The fix has two parts because the old behavior was wrong on two layers: 1. Pre-resolve the target session name once, before the load loop. ``--new-session-name`` wins; otherwise fall back to the first workspace file's ``session_name`` config key. Apply the resolved name to every iteration's ``new_session_name`` so all loads target the same session. 2. Make ``_dispatch_build`` honor ``append`` even when the target session already exists in detached mode. Previously the ``if detached:`` branch unconditionally called ``builder.build()`` (no append arg), which re-tried session creation and raised ``TmuxSessionExists``. New hoisted check: when ``append=True`` and the named session already exists, build windows directly onto the existing session via ``builder.build(existing, append=True)``, honoring ``detached`` for whether to attach afterwards. what: - src/tmuxp/cli/load.py: pre-resolve append_target_session_name in command_load when args.append and len(workspace_files) > 1; force every loop iteration to use it as new_session_name. - src/tmuxp/cli/load.py: add session_name kwarg to _dispatch_build; hoist an append-to-existing-session branch above the detached/ attached split so detached + append + session-exists is honored. - tests/cli/test_load.py: two functional tests covering (a) ``load f1 f2 --append`` coalescing into f1's session_name, and (b) ``--new-session-name`` overriding the first file's session_name. Re-ports PR #839 (originally a single 2022 WIP commit). Drops the WIP's broken in-loop scoping of original_session_name and its type mismatch between ConfigReader._from_file (returns dict) and new_session_name (str).
4f20ba2 to
72fa331
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #839 +/- ##
==========================================
- Coverage 82.56% 82.38% -0.19%
==========================================
Files 31 31
Lines 2770 2798 +28
Branches 518 526 +8
==========================================
+ Hits 2287 2305 +18
- Misses 346 353 +7
- Partials 137 140 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
why: ``tmuxp load f1 f2 f3 --append`` previously failed on the second file because each file was loaded against its own config's ``session_name``, and the second file's ``new_session`` would collide with the session the first file just created. Multi-file ``--append`` should land every workspace in a single shared target session. The fix has two parts because the old behavior was wrong on two layers: 1. Pre-resolve the target session name once, before the load loop. ``--new-session-name`` wins; otherwise fall back to the first workspace file's ``session_name`` config key. Apply the resolved name to every iteration's ``new_session_name`` so all loads target the same session. 2. Make ``_dispatch_build`` honor ``append`` even when the target session already exists in detached mode. Previously the ``if detached:`` branch unconditionally called ``builder.build()`` (no append arg), which re-tried session creation and raised ``TmuxSessionExists``. New hoisted check: when ``append=True`` and the named session already exists, build windows directly onto the existing session via ``builder.build(existing, append=True)``, honoring ``detached`` for whether to attach afterwards. what: - src/tmuxp/cli/load.py: pre-resolve append_target_session_name in command_load when args.append and len(workspace_files) > 1; force every loop iteration to use it as new_session_name. - src/tmuxp/cli/load.py: add session_name kwarg to _dispatch_build; hoist an append-to-existing-session branch above the detached/ attached split so detached + append + session-exists is honored. - tests/cli/test_load.py: two functional tests covering (a) ``load f1 f2 --append`` coalescing into f1's session_name, and (b) ``--new-session-name`` overriding the first file's session_name. Re-ports PR #839 (originally a single 2022 WIP commit). Drops the WIP's broken in-loop scoping of original_session_name and its type mismatch between ConfigReader._from_file (returns dict) and new_session_name (str).
72fa331 to
2f428cb
Compare
why: ``tmuxp load f1 f2 f3 --append`` previously failed on the second file because each file was loaded against its own config's ``session_name``, and the second file's ``new_session`` would collide with the session the first file just created. Multi-file ``--append`` should land every workspace in a single shared target session. The fix has two parts because the old behavior was wrong on two layers: 1. Pre-resolve the target session name once, before the load loop. ``--new-session-name`` wins; otherwise fall back to the first workspace file's ``session_name`` config key. Apply the resolved name to every iteration's ``new_session_name`` so all loads target the same session. 2. Make ``_dispatch_build`` honor ``append`` even when the target session already exists in detached mode. Previously the ``if detached:`` branch unconditionally called ``builder.build()`` (no append arg), which re-tried session creation and raised ``TmuxSessionExists``. New hoisted check: when ``append=True`` and the named session already exists, build windows directly onto the existing session via ``builder.build(existing, append=True)``, honoring ``detached`` for whether to attach afterwards. what: - src/tmuxp/cli/load.py: pre-resolve append_target_session_name in command_load when args.append and len(workspace_files) > 1; force every loop iteration to use it as new_session_name. - src/tmuxp/cli/load.py: add session_name kwarg to _dispatch_build; hoist an append-to-existing-session branch above the detached/ attached split so detached + append + session-exists is honored. - tests/cli/test_load.py: two functional tests covering (a) ``load f1 f2 --append`` coalescing into f1's session_name, and (b) ``--new-session-name`` overriding the first file's session_name. Re-ports PR #839 (originally a single 2022 WIP commit). Drops the WIP's broken in-loop scoping of original_session_name and its type mismatch between ConfigReader._from_file (returns dict) and new_session_name (str).
2f428cb to
8f1aa2a
Compare
|
Automated review finding. Recorded here so it is not lost. Nothing has been pushed to this branch and no fix is applied — this is a note, not a change request.
|
tmuxp load workspace_1 workspace_2 --appendLoads to the same
session_nameas workspace_1, or uses the-s new_session_nameSomewhat released (not exactly): #674 #837