tmux-python / tmux-python/tmuxp

skip existing named windows on tmuxp load -a workspace

Open
#872 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4.6k
Forks
248
Avg merge
2h 13m
Merged PRs (30d)
1

Description

Step 1: Provide a summary of your problem
  • tmuxp load -a workspace duplicates existing windows in a session, when called a second time inside tmux
Step 2: Provide tmuxp details
tmux version: 3.3
libtmux version: 0.21.0
tmuxp version: 1.27.0
Step 3: Describe the problem:

Running tmuxp load -a workspace inside tmux duplicates existing windows in a session - it would be nice if existing named windows are not recreated.
So - closing a tmux window, updating the tmuxp workspace config file and rerunning tmuxp load -a workspace should recreate the closed window only (if all windows are named)

Steps to reproduce:

Run tmuxp load -a workspace inside tmux a second time - windows are duplicated

Relevant Code:

The following patch to tmuxp/workspace/builder.py skips existing named windows - but I'm new to tmuxp - a option for enabling this behavior would be necessary - and I don't know, if this is even the correct place for this patch.

--- builder.py.orig	2023-03-16 12:59:43.399597590 +0100
+++ builder.py	2023-03-21 20:46:05.998656705 +0100
@@ -346,6 +346,8 @@ class WorkspaceBuilder:
             Newly created window, and the section from the tmuxp configuration
             that was used to create the window.
         """
+        session_window_names = set([w.window_name for w in session.windows if w.window_name])
+
         for window_iterator, window_config in enumerate(
             self.session_config["windows"], start=1
         ):
@@ -353,6 +355,9 @@ class WorkspaceBuilder:
                 window_name = None
             else:
                 window_name = window_config["window_name"]
+                if window_name in session_window_names:
+                    # skip existing window
+                    continue
 
             is_first_window_pass = self.first_window_pass(
                 window_iterator, session, append

Thanks,
Gerald

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading tmuxp/workspace/builder.py around WorkspaceBuilder's window creation logic and compare the requested behavior with the supplied patch. Determine how the behavior should be enabled and what should happen for named versus unnamed windows. Done means rerunning tmuxp load -a workspace does not recreate existing named windows while still recreating a closed named window.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.