Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout is broken with 1.9.2 #704

Closed
muraii opened this issue Jul 22, 2021 · 26 comments
Closed

Layout is broken with 1.9.2 #704

muraii opened this issue Jul 22, 2021 · 26 comments
Labels
bug Something isn't working

Comments

@muraii
Copy link

muraii commented Jul 22, 2021

Step 1: Provide a summary of your problem

Specifying a main-vertical layout with a main-pane-width attribute, or not, results in a main pane rendered with a width of 1 or 2 cells. This is very similar to #309, and may be identical in its root cause(s), but that issue was closed. Note that running this identical configuration on Ubuntu 18.04 with tmuxp 1.7.2 and tmux 2.6 renders the configuration as expected.

Step 2: Provide tmuxp details

$ tmux debug-info

environment:
        dist: Linux-5.4.72-microsoft-standard-WSL2-x86_64-with-glibc2.33
        arch: x86_64
        uname: Linux; CIN2LAP4536; 5.4.72-microsoft-standard-WSL2
        version: #1 SMP Wed Oct 28 23:40:43 UTC 2020
-------------------------
python version: 3.9.6 (default, Jun 30 2021, 10:22:16)  [GCC 11.1.0]
system PATH: /home/dblack/.pyenv/shims:/home/dblack/neovim/bin:/usr/lib/jvm/java-1.11.0-openjdk-amd64:/home/dblack/.local/bin:/home/dblack/.poetry/bin:/home/dblack/.pyenv/bin:/usr/local/opt/vim/bin/vim:/usr/local/sbin:/home/dblack/bin:/home/dblack/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/dblack/.pyenv/bin:/home/dblack/winHome/gitrepos/fzf/bin:/opt/apache-spark/spark-2.4.4-bin-hadoop2.7/bin:/opt/mssql-tools/bin
tmux version: 3.2
libtmux version: 0.10.1
tmuxp version: 1.9.2
tmux path: /usr/sbin/tmux
tmuxp path: /home/dblack/.local/pipx/venvs/tmuxp/lib/python3.9/site-packages/tmuxp/__init__.py
shell: /usr/sbin/zsh
-------------------------
tmux sessions:

        no server running on /tmp/tmux-1000/default
tmux windows:

        no server running on /tmp/tmux-1000/default
tmux panes:

        no server running on /tmp/tmux-1000/default
tmux global options:

        no server running on /tmp/tmux-1000/default
tmux window options:

        no server running on /tmp/tmux-1000/default

Step 3: Describe the problem:

Steps to reproduce:

  1. Install tmuxp with pipx (unsure if relevant)
  2. Create .tmuxp.yaml configuration file as noted below.
  3. Start tmux with tmuxp load .
  4. Observe that the main pane is extremely narrow.

Observed Results:

Notice the main pane is very narrow.
image

Expected Results:

After detaching and reattaching, the rendering corrects itself.
image

Relevant Code:

.tmuxp.yaml

session_name: 'glorp'
# Reference this issue for why we need to use `source` here:
# https://github.com/tmux-python/tmuxp/issues/412
shell_command_before:
- source $(poetry env info --path)/bin/activate
windows:
- focus: 'true'
window_name: main_work
# layout: 222e,209x48,0,0{104x48,0,0,0,104x48,105,0[104x24,105,0,1,104x23,105,25,2]}
# layout: 1658,209x48,0,0{134x48,0,0,1,74x48,135,0[74x24,135,0,2,74x23,135,25,3]}
layout: main-vertical
options: {
  main-pane-width: 134
}
panes:
- focus: 'true'
  shell_command: clear
  # - vifm
- pane
- shell_command:
    - clear
    - ipython

Other output as requested for #309:

tmux show-window-options

automatic-rename off
main-pane-width 134

tmux show-options

default-size 800x600

tmux show-window-options -g

aggressive-resize off
allow-rename off
alternate-screen on
automatic-rename on
automatic-rename-format "#{?pane_in_mode,[tmux],#{pane_current_command}}#{?pane_dead,[dead],}"
clock-mode-colour blue
clock-mode-style 24
copy-mode-match-style bg=cyan,fg=black
copy-mode-current-match-style bg=magenta,fg=black
copy-mode-mark-style bg=red,fg=black
main-pane-height 24
main-pane-width 80
mode-keys vi
mode-style bg=yellow,fg=black
monitor-activity off
monitor-bell on
monitor-silence 0
other-pane-height 0
other-pane-width 0
pane-active-border-style fg=colour254
pane-base-index 0
pane-border-format "#{?pane_active,#[reverse],}#{pane_index}#[default] \"#{pane_title}\""
pane-border-lines single
pane-border-status off
pane-border-style fg=colour240
remain-on-exit off
synchronize-panes off
window-active-style default
window-size latest
window-style default
window-status-activity-style none
window-status-bell-style reverse
window-status-current-format "#[fg=colour234,bg=colour31,nobold,nounderscore,noitalics]#[fg=colour117,bg=colour31] #I #[fg=colour231,bg=colour31,bold] #W #[fg=colour31,bg=colour234,nobold,nounderscore,noitalics]"
window-status-current-style default
window-status-format "#[fg=colour244,bg=colour234] #I #[fg=colour250,bg=colour234] #W "
window-status-last-style default
window-status-separator ''
window-status-style none,fg=colour250,bg=colour234
wrap-search on
xterm-keys on

tmux show-options -g

@plugin christoomey/vim-tmux-navigator                                                                                                                                                                             activity-action other                                                                                                                                                                                              assume-paste-time 1                                                                                                                                                                                                base-index 0                                                                                                                                                                                                       bell-action any                                                                                                                                                                                                    default-command ''                                                                                                                                                                                                 default-shell /usr/sbin/zsh                                                                                                                                                                                        default-size 80x24                                                                                                                                                                                                 destroy-unattached off                                                                                                                                                                                             detach-on-destroy on                                                                                                                                                                                               display-panes-active-colour red                                                                                                                                                                                    display-panes-colour blue                                                                                                                                                                                          display-panes-time 1000                                                                                                                                                                                            display-time 750                                                                                                                                                                                                   history-limit 2000                                                                                                                                                                                                 key-table root                                                                                                                                                                                                     lock-after-time 0                                                                                                                                                                                                  lock-command "lock -np"   
message-command-style fg=colour231,bg=colour31
message-style fg=colour231,bg=colour31
mouse on
prefix C-a
prefix2 None
renumber-windows off
repeat-time 500
set-titles off
set-titles-string "#S:#I:#W - \"#T\" #{session_alerts}"
silence-action other
status on
status-bg default
status-fg default
status-format[0] "#[align=left range=left #{status-left-style}]#[push-default]#{T;=/#{status-left-length}:status-left}#[pop-default]#[norange default]#[list=on align=#{status-justify}]#[list=left-marker]<#[list=right-marker]>#[list=on]#{W:#[range=window|#{window_index} #{window-status-style}#{?#{&&:#{window_last_flag},#{!=:#{window-status-last-style},default}}, #{window-status-last-style},}#{?#{&&:#{window_bell_flag},#{!=:#{window-status-bell-style},default}}, #{window-status-bell-style},#{?#{&&:#{||:#{window_activity_flag},#{window_silence_flag}},#{!=:#{window-status-activity-style},default}}, #{window-status-activity-style},}}]#[push-default]#{T:window-status-format}#[pop-default]#[norange default]#{?window_end_flag,,#{window-status-separator}},#[range=window|#{window_index} list=focus #{?#{!=:#{window-status-current-style},default},#{window-status-current-style},#{window-status-style}}#{?#{&&:#{window_last_flag},#{!=:#{window-status-last-style},default}}, #{window-status-last-style},}#{?#{&&:#{window_bell_flag},#{!=:#{window-status-bell-style},default}}, #{window-status-bell-style},#{?#{&&:#{||:#{window_activity_flag},#{window_silence_flag}},#{!=:#{window-status-activity-style},default}}, #{window-status-activity-style},}}]#[push-default]#{T:window-status-current-format}#[pop-default]#[norange list=on default]#{?window_end_flag,,#{window-status-separator}}}#[nolist align=right range=right #{status-right-style}]#[push-default]#{T;=/#{status-right-length}:status-right}#[pop-default]#[norange default]"
status-format[1] "#[align=centre]#{P:#{?pane_active,#[reverse],}#{pane_index}[#{pane_width}x#{pane_height}]#[default] }"
status-interval 15
status-justify left
status-keys vi
status-left "#[fg=colour16,bg=colour254,bold] #S #[fg=colour254,bg=colour234,nobold,nounderscore,noitalics]"
status-left-length 100
status-left-style none
status-position bottom
status-right "#[fg=colour236,bg=colour234,nobold,nounderscore,noitalics]#[fg=colour247,bg=colour236] %Y-%m-%d  %H:%M #[fg=colour252,bg=colour236,nobold,nounderscore,noitalics]#[fg=colour235,bg=colour252] #h "status-right-length 100
status-right-style none
status-style none,bg=colour234
update-environment[0] DISPLAY
update-environment[1] KRB5CCNAME
update-environment[2] SSH_ASKPASS
update-environment[3] SSH_AUTH_SOCK
update-environment[4] SSH_AGENT_PID
update-environment[5] SSH_CONNECTION
update-environment[6] WINDOWID
update-environment[7] XAUTHORITY
visual-activity off
visual-bell off
visual-silence off
word-separators " "
@tony tony added the bug Something isn't working label Aug 24, 2021
@tony
Copy link
Member

tony commented Aug 24, 2021

If we had this testable via our CI (some how, not sure how we could) that'd be awesome. That'd assure our fix works across tmux versions and future PRs.

@tony
Copy link
Member

tony commented Aug 24, 2021

@muraii If you (or anyone experiencing this) removes stuff from your config file, such as removing / commenting out shell_command_before and other things, is anything different?

I'm on tmuxp 1.9.2 + wsl 2 + tmux 3.2a and have gotten into a habit of redoing the layout by hand. This is one I need help on

@muraii
Copy link
Author

muraii commented Aug 25, 2021

@muraii If you (or anyone experiencing this) removes stuff from your config file, such as removing / commenting out shell_command_before and other things, is anything different?

I'm on tmuxp 1.9.2 + wsl 2 + tmux 3.2a and have gotten into a habit of redoing the layout by hand. This is one I need help on

Removing shell_command_before seems to do the trick, yeah. I think I'd prefer to leave it in and detach/reattach, since that shell command is activating a virtual environment, but at least that's something. I'm on the same versions of tmuxp/WSL/tmux as you.

ETA: I'm noticing that this problem is intermittent. I can't figure out what causes it to behave correctly or incorrectly. Could it happen because whatever the shell command I'm running with shell_command_before takes too long to execute?

@tony
Copy link
Member

tony commented Aug 25, 2021

@muraii That is interesting though. There must be something timing-wise that we need to list to, so we change the layout at the correct time.

Could it happen because whatever the shell command I'm running with shell_command_before takes too long to execute?

I think so - possibly. Assuming this is the cause, if we wanted to fix this, we'd need to make it so certain types of commands are queue'd / blocking / delay'd.

Perhaps we can introduce something like:

session_name: 'glorp'
# Reference this issue for why we need to use `source` here:
# https://github.com/tmux-python/tmuxp/issues/412
shell_command_before:
- command: source $(poetry env info --path)/bin/activate
  wait: 500

or sleep: 500

And maybe something that'd give it enough space in between. (still though, we're not sure this is a (or the root) cause of layout issues yet)

@categulario
Copy link
Contributor

I think this issue relates to #667 , which was reproduced in versions 1.7.2 and 1.9.2. I can reproduce it myself with this yaml:

session_name: some
start_directory: ./
windows:
  - focus: 'true'
    layout: main-horizontal
    options:
      main-pane-height: 35
    panes:
    - pane
    - pane
    - pane
    window_name: foo

@tony
Copy link
Member

tony commented Jan 11, 2022

Did we ever get a test recreation of this breaking in a pull request? That would be very helpful.

If anyone could assist / spend some time on it that'd be helpful!

@tony
Copy link
Member

tony commented Mar 14, 2022

@muraii

Regarding sleep, if you try 1.10.0b4+, how does this work?

Live in 1.10.0b4 pypi branch

pip install --user --upgrade --pre tmuxp==1.10.0b4

or pipx install --suffix=@1.10.0b4 'tmuxp==1.10.0b4' then tmuxp@1.10.0b4 load <yaml file>

docs: skip command execution

session_name: 'glorp'
# Reference this issue for why we need to use `source` here:
# https://github.com/tmux-python/tmuxp/issues/412
shell_command_before:
- cmd: source $(poetry env info --path)/bin/activate
  sleep_before: 1
  sleep_after: 1
windows:
  - panes:
    - echo "hello"

You'd this this would be possible

session_name: 'glorp'
# Reference this issue for why we need to use `source` here:
# https://github.com/tmux-python/tmuxp/issues/412
windows:
  - panes:
    - shell_command:
      - cmd: source $(poetry env info --path)/bin/activate
        sleep_after: 1
      - echo "hello"

@categulario
Copy link
Contributor

Hi @tony !

Did we ever get a test recreation of this breaking in a pull request? That would be very helpful.

I just tried to run the tests on my computer and I get four failures in tests/test_cli.py and then it gets stuck at about the 10th test in tests/test_workspacebuilder.py. More details bellow.

test-log.txt

Of the four tests that fail two are caused by a window object being None and two complain about getting id from a None but provide no more information, although the last line shown in the traceback is a call to exec.

It might be related to this, it might not. Maybe something in my environment (and @muraii 's) that causes this failures are also causing the layout problem, which is still happening for me in tmuxp 1.11.1, libtmux 0.11.0

@tony
Copy link
Member

tony commented May 17, 2022

Welcome @categulario!!

Of the four tests that fail two are caused by a window object being None and two complain about getting id from a None but provide no more information, although the last line shown in the traceback is a call to exec.

I'm interested if you were to check out a development environment and tweak around with WorkspaceBuilder, is there anything you can do to further isolate it?

It might be related to this, it might not. Maybe something in my environment (and @muraii 's) that causes this failures are also causing the layout problem, which is still happening for me in tmuxp 1.11.1, libtmux 0.11.0

That may be the case indeed. Do you think you're reporting a potentially (perhaps new) test issue? If you do, maybe report in a new issue until we can tie it to this?

Do you have tmuxp debug-info and your OS/shell/etc info too?

@categulario
Copy link
Contributor

I'm interested if you were to check out a development environment and tweak around with WorkspaceBuilder, is there anything you can do to further isolate it?

I'll try to isolate the four exceptions (and the test hanging the whole test suite). Is there any advice/suggestions/protocols you follow to do this? I'm more of a print-debugger :P

Do you think you're reporting a potentially (perhaps new) test issue? If you do, maybe report in a new issue until we can tie it to this?

Sure. Should I just open a tracking issue and attach the log?

Do you have tmuxp debug-info and your OS/shell/etc info too?

debug-info.txt

I think the debug info includes the OS/Shell.

@tony
Copy link
Member

tony commented May 17, 2022

I'll try to isolate the four exceptions (and the test hanging the whole test suite). Is there any advice/suggestions/protocols you follow to do this? I'm more of a print-debugger :P

I'm a bit sleepy now as I wake up early AM, but you can check out the source code and do tmuxp load . inside the git directory

  • make start to rerun on file change

  • test tests/test_workspacebuidler.py

    env PYTEST_ADDOPTS="-s -x -vv tests/test_workspacebuilder.py" poetry run make start

  • test test_automatic_rename_option() in tests/test_workspacebuidler.py

    env PYTEST_ADDOPTS="-s -x -vv tests/test_workspacebuilder.py::test_automatic_rename_option" poetry run make start

  • add assert False to stop at an area of code

  • use a debug loop

    1. pip install ipython
    2. env PYTEST_ADDOPTS="-s -x -vv --pdb --pdbcls=IPython.terminal.debugger:TerminalPdb" poetry run make start
    3. you can now run pdb commands

let me know if any of these help

and I think you should repost this in a new issue and we continue from there (so we don't side-track in the event this is unrelated)

@muraii
Copy link
Author

muraii commented May 17, 2022 via email

@tony
Copy link
Member

tony commented May 17, 2022

@categulario @muraii I updated the development docs, it's not a lot but should help a bit: https://tmuxp.git-pull.com/developing.html#test-runner

@categulario
Copy link
Contributor

Thanks for the updated docs @tony !

tony added a commit to tmux-python/libtmux that referenced this issue May 20, 2022
Fixes #368, as retry() in its current form is broke and won't work within a
`with` block. The function is deprecated and will be removed in 0.13.x. 0.12.x
will warn when using it.

retry_until() is now available and will either raise or return False if raise=False
is passed.

See also:
- tmux-python/tmuxp#620
- tmux-python/tmuxp#704 (comment)
nvasilas added a commit to nvasilas/tmuxp that referenced this issue Aug 7, 2022
…on#704

Use tmux default session size 80x24 when creating a new session
tony pushed a commit to nvasilas/tmuxp that referenced this issue Aug 14, 2022
…on#704

Use tmux default session size 80x24 when creating a new session
tony pushed a commit to nvasilas/tmuxp that referenced this issue Aug 21, 2022
…on#704

Use tmux default session size 80x24 when creating a new session
tony added a commit that referenced this issue Aug 21, 2022
@tony
Copy link
Member

tony commented Aug 21, 2022

@muraii, @nodeselector, @samm81, @askielboe, @mohammadne

v1.13.1 is live with a fix, via @nvasilas from #793

PyPI, GitHub Tag

pip install tmuxp==1.13.1

Any better now?

P.S. You may need to kill your tmux server or try on a fresh one by passing something like tmuxp ./workspacefile.yaml -L OtherTmuxServer

tony added a commit that referenced this issue Sep 10, 2022
This may negate the fix from #737 (for #667 and #704)
that helped certain layouts.

If a client hasn't yet been attached, 80x24 isn't enough 
to handle workspace building splitting the panes out.
tony added a commit that referenced this issue Sep 10, 2022
tony added a commit that referenced this issue Sep 10, 2022
@samm81
Copy link

samm81 commented Sep 12, 2022

I see that you've just reverted it (temporarily), but wanted to say I got it installed before the revert and it seems to work great! thank you! I'm integrating tmuxp back into my workflow now :)

@muraii
Copy link
Author

muraii commented Feb 13, 2023

Thanks for all your work on this, team. I updated to v 1.27.0 and still see the issue, fwiw (issue originally posted against v1.9.2).

EDIT: I appear to have spoken too soon. I had shut down all sessions and retried but now that I've fiddled a bit more the layout appears to be correct on creating a new session.

@Bassadin
Copy link

Bassadin commented Nov 7, 2023

@muraii Could you share your config? I'm also still running into this problem every morning when I start my tmuxp config :D

@muraii
Copy link
Author

muraii commented Nov 22, 2023

@muraii Could you share your config? I'm also still running into this problem every morning when I start my tmuxp config :D

I haven't used this setup in a while, but I just tried it on two different machines with tmux 3.3a and tmuxp 1.9.3 as well as tmuxp 1.27.9 with libtmux 0.21.0. Still renders with the main pane at approximately 10-15 px wide. When I detach then reattach, it renders perfectly.

# Reference this issue for why we need to use `source` here:
# https://github.com/tmux-python/tmuxp/issues/412
shell_command_before:
  - source $(poetry env info --path)/bin/activate
windows:
- focus: 'true'
  window_name: main_work
  # layout: 222e,209x48,0,0{104x48,0,0,0,104x48,105,0[104x24,105,0,1,104x23,105,25,2]}
  # layout: 1658,209x48,0,0{134x48,0,0,1,74x48,135,0[74x24,135,0,2,74x23,135,25,3]}
  layout: main-vertical
  options: {
    main-pane-width: 134
    }
  panes:
  - focus: 'true'
    shell_command: clear
    # - vifm
  - pane
  - shell_command:
      - clear
      - ipython

@tony
Copy link
Member

tony commented Apr 7, 2024

@muraii @Bassadin @samm81 @sohang3112

I have a PR at #926 testing a fix for this longstanding issue. If you have any time to try it out, you can using these instructions. If you do, does it work any better?

@tony
Copy link
Member

tony commented Apr 13, 2024

If you try v1.46.0 (docs, changes, release, PyPI), is anything better?

Instructions:

pip install --user --upgrade tmuxp

tmuxp -V should show at least 1.46.0.

@sohang3112
Copy link

@tony I tried with tmuxp v1.46.0 - it's working fine for me in WSL Ubuntu. Thanks for fixing the issue 👍

@Bassadin
Copy link

Works like a charm for me now as well in Arch :) Thanks!

@tony
Copy link
Member

tony commented Apr 19, 2024

@sohang3112 @Bassadin Thank you, both! With that in mind I will consider this issue fixed and close this.

@tony tony closed this as completed Apr 19, 2024
@muraii
Copy link
Author

muraii commented May 28, 2024

@tony I apologize for not having responded much after having opened the issue. I'm currently on tmux 3.3a and tmuxp 1.27.0/libtmux 0.21.0, and loading my saved layout/config works fine in limited testing. I haven't been using this setup for some time, but I think it's time to return. :)

Thanks for all the hard work over almost three years since I opened the issue.

@tony
Copy link
Member

tony commented May 28, 2024

@muraii Thanks for getting back.

If it already works, even with that older tmuxp and libtmux version, that's nice.

FYI - for you to get the effect of the change you'd need at least v1.46.0 (docs, changes, release, PyPI). If you do try recent versions, the layout issues should be resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants