tide: Prompt doesn't show immediately in new shell

Describe the bug

Upon launching the shell, the prompt will not appear until the enter key is pressed.

Steps to reproduce

Install fish and tide prompt.

Screenshots

wk2CsnO1HM

Environment

Output of tide bug-report:

fish version: 3.3.1
tide version: 4.3.4
term: xterm-256color
os: Ubuntu 20.04 on WSL2
terminal emulator: Windows Terminal

Additional context

Seems to have been fixed for others in the fish update to 3.3.1, but as you can see the issue persists for me after updating.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 7
  • Comments: 28 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Okay, then this is not the same bug, it’s an older bug that I don’t really care about. Thanks for reporting though 😄

I’ve made the changes suggested by @natecraddock that should fix the bug. I didn’t get around to reproducing it, or writing a test case yet.

I ran a git bisect on fish and I believe that b56b23007 introduced this bug.

  • With Tide installed the prompt fails to draw when the terminal first opens. The previous commit works as expected.
  • When I uninstalled tide to see how the default prompt behaved, both b56b23007 and the previous commit work perfectly fine.

I also reverted b56b23007 on the current fish master and that resolved the issue. I’m not aware of how Tide works, but I think this might still be something that needs to be solved in Tide because fish does work fine with the default prompt.

At this point I’m not sure where else to look. If there is anything else I can do to help let me know. Hopefully this information is helpful! 😃

b56b23007 was only partially reverted, and removing the remaining lines does solve the prompt failing to render when a terminal first opens

Describe and Reproduce

I have a similar bug on fish ver.3.3.1 and tide ver.5.0.0 (should be the latest for both of them). only_cursor When I start the terminal(alacritty), sometimes it shows only the cursor on the screen (the above image), and if I:

  • press enter directly, the prompt will show up.
  • just type “cd foo” then press enter, the prompt will show up but shows the wrong path (looks like it one step behind). Then if I continue to type any command, the prompt seems “catch up” or synced correctly and doesn’t affect by the previous “delay”. Just like the image below: cd

Some Extra Debug Info

In order to provide some information for debug, I added 4 lines (the commented lines in code) into fish_prompt.fish:

function _tide_refresh_prompt --on-variable $_tide_left_prompt_display_var --on-variable $_tide_right_prompt_display_var
    # echo "function _tide_refresh_prompt executed" >> ~/Misc/tmpfs/tide-debug.txt
    set -g _tide_self_repainting # prevents us from creating a second background job
    commandline --function repaint
end

function fish_prompt
    _tide_last_status=$status _tide_last_pipestatus=$pipestatus if not set -e _tide_self_repainting
        # echo "variable _tide_self_repainting exist" >> ~/Misc/tmpfs/tide-debug.txt
        jobs --query
        fish --command "_tide_jobs_status=$status CMD_DURATION=$CMD_DURATION COLUMNS=$COLUMNS \
            fish_bind_mode=$fish_bind_mode set -U $_tide_left_prompt_display_var (_tide_prompt)" &
        builtin disown

        command kill $_tide_last_pid 2>/dev/null
        set -g _tide_last_pid $last_pid
    end

    # echo "function fish_promt executed" >> ~/Misc/tmpfs/tide-debug.txt
    string unescape $$_tide_left_prompt_display_var
end

function _tide_on_fish_exit --on-event fish_exit
    # echo "function _tide_on_fish_exit executed" >> ~/Misc/tmpfs/tide-debug.txt
    set -e $_tide_left_prompt_display_var $_tide_right_prompt_display_var
end

Then I try to open and close terminal.
If tide start correctly(the prompt show up immediately), the contents in “tide-debug” file are:

variable _tide_self_repainting exist
function fish_promt executed
function _tide_refresh_prompt executed
function _tide_refresh_prompt executed
function fish_promt executed
variable _tide_self_repainting exist
function fish_promt executed
function _tide_on_fish_exit executed
function _tide_refresh_prompt executed
function _tide_refresh_prompt executed

If tide start in a bug way(only cursor), the contents are:

variable _tide_self_repainting exist
function fish_promt executed
function _tide_refresh_prompt executed
function fish_promt executed
function _tide_refresh_prompt executed
function _tide_on_fish_exit executed
function _tide_refresh_prompt executed
function _tide_refresh_prompt executed

I suspect there’s something wrong with the _tide_refresh_prompt function, maybe a race condition or something?
There are two ways to get rid of this issue (ABSOLUTELY NOT ACTUALLY FIX IT, just for debug purpose):

  1. comment the line set -g _tide_self_repainting
  2. add sleep 1 below the line string unescape $$_tide_left_prompt_display_var. In this case, the prompt show up correctly(of course with dealy) when terminal launch, however, the second prompt always show the wrong path(one step behind), it seems the prompt doesn’t get repaint correctly, but it doesn’t affect the prompts after it, just as the following image: sleep-1

Environments

❯ fish -v; tide -v; echo $TERM; uname -r; cat /etc/issue;
fish, version 3.3.1
tide, version 5.0.0
xterm-256color
5.10.56-1-lts
Arch Linux \r (\l)

Terminal Emulator: Alacritty

Maybe it is low priority but it is a blocker for me and therefore I stopped using tide. Such a pity.

Can someone with the bug verify that the dev branch fixes it?

@leafinote You’re awesome! 😄 Yup, it seems to be a race condition between the the left and right prompt vars being updated. I can solve this by just combining those vars into a single prompt var. That’s probably a slight performance improvement as well.

Thanks a ton for helping me debug this 😄

I see this issue in fish 3.3.1 as well, though only about 70% of the time. Sometimes when I open a new terminal the prompt does show as expected, otherwise I must press enter before it is displayed.

Okay, then this is not the same bug, it’s an older bug that I don’t really care about.

I would like to try solving this issue myself, but am wondering why you don’t care. Is it too hard to solve? Just low-priority? Basically I want to avoid unnecessary work if you have already determined this issue too tricky to solve 😃