Skip to content

tmuxp load: Load multiple sessions with --append#839

Open
tony wants to merge 1 commit intomasterfrom
test-cli-load-multiple--append
Open

tmuxp load: Load multiple sessions with --append#839
tony wants to merge 1 commit intomasterfrom
test-cli-load-multiple--append

Conversation

@tony
Copy link
Copy Markdown
Member

@tony tony commented Oct 29, 2022

tmuxp load workspace_1 workspace_2 --append

Loads to the same session_name as workspace_1, or uses the -s new_session_name

Somewhat released (not exactly): #674 #837

@tony tony force-pushed the test-cli-load-multiple--append branch 2 times, most recently from 5466251 to e090550 Compare October 29, 2022 15:25
@tony tony force-pushed the test-cli-load-multiple--append branch from e090550 to 4f20ba2 Compare November 13, 2022 14:42
@tony tony force-pushed the master branch 2 times, most recently from 1989584 to b30a864 Compare May 27, 2023 16:53
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).
@tony tony force-pushed the test-cli-load-multiple--append branch from 4f20ba2 to 72fa331 Compare April 26, 2026 11:14
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 26, 2026

Codecov Report

❌ Patch coverage is 62.96296% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.76%. Comparing base (7237fe6) to head (72fa331).

Files with missing lines Patch % Lines
src/tmuxp/cli/load.py 62.96% 7 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #839      +/-   ##
==========================================
- Coverage   81.96%   81.76%   -0.20%     
==========================================
  Files          28       28              
  Lines        2545     2572      +27     
  Branches      485      493       +8     
==========================================
+ Hits         2086     2103      +17     
- Misses        328      335       +7     
- Partials      131      134       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant