Skip to content
New issue

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

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

Already on GitHub? # to your account

Prompt doesn't show immediately in new shell #171

Closed
kendofriendo opened this issue Jul 11, 2021 · 28 comments
Closed

Prompt doesn't show immediately in new shell #171

kendofriendo opened this issue Jul 11, 2021 · 28 comments
Labels
🐛 bug Something isn't working
Milestone

Comments

@kendofriendo
Copy link

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.

@kendofriendo kendofriendo added the 🐛 bug Something isn't working label Jul 11, 2021
@IlanCosman
Copy link
Owner

To clarify: Is it just that on launching the shell the prompt will not appear until a key is pressed? Or is the prompt always one step behind, for example if you switch directories it will still display the old one until you press a key.

@kendofriendo
Copy link
Author

It's only when first entering the fish shell. After that it works normally. I've tried launching fish directly from bash and replacing fish_greeting with a blank function and a newline with the same results.

@IlanCosman
Copy link
Owner

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

@IlanCosman IlanCosman changed the title Issue #168 (fish #8088) persists on 3.3.1 - Prompt does not repaint until enter key is pressed Prompt doesn't show immediately in new shell Jul 11, 2021
@nemonik

This comment has been minimized.

@IlanCosman

This comment has been minimized.

@nemonik

This comment has been minimized.

@IlanCosman

This comment has been minimized.

@nemonik

This comment has been minimized.

@nemonik

This comment has been minimized.

@natecraddock
Copy link

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 :)

@IlanCosman
Copy link
Owner

IlanCosman commented Jul 14, 2021

Sorry, saying that "I don't care" about the bug was the wrong language to use. It has just been low priority for me, and I believe it is not a Tide bug, both of which have dissuaded me from working on it.

For me, the bug appears only in one, fairly unique, terminal of the ones I have tested. That terminal also has this possibly related right_prompt bug:

function fish_right_prompt
    date
end
right-prompt-bug.mp4

This indicates to me that Fish/certain terminals just sometimes have problems with initial rendering, and I haven't really felt like tracking the problem down. If this bug really bothers people though, I can give it a go 😄

@natecraddock
Copy link

No worries about the language! I understand why this is low priority, as it doesn't interfere with actually using fish. However, I do use Tide for a reason and it would definitely be preferable to have a reliable prompt :)

You're right though that this might not even be an issue with Tide. A quick test just showed me that I don't see any issues with fish 3.2.2, so perhaps there was a regression in fish 3.3.0.

So yes, I would appreciate you looking into solving this, but I'm also happy to help! I'll try doing a bisect on fish later today to see if I can find which commit introduced the issue.

@Maverobot
Copy link

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

@natecraddock
Copy link

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! :)

@kidonng
Copy link
Contributor

kidonng commented Jul 15, 2021

I also reverted b56b23007 on the current fish master and that resolved the issue.

That commit has already been reverted in fish-shell/fish-shell@62d8f72 (landed in Fish 3.3.1), which fixed a similar bug (#168).

@natecraddock
Copy link

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

@kidonng
Copy link
Contributor

kidonng commented Jul 16, 2021

b56b23007 was only partially reverted

Indeed. Perhaps open an issue/leave a comment on fish-shell?

@IlanCosman
Copy link
Owner

Or even better, if you're up for it, submit a PR 😄 I'd have boundless appreciation ❤️

@kidonng
Copy link
Contributor

kidonng commented Jul 16, 2021

Or even better, if you're up for it, submit a PR 😄

That person won't be myself because I don't have this issue and thus can't test😃

krobelus added a commit to fish-shell/fish-shell that referenced this issue Jul 18, 2021
62d8f72 ("Revert "Avoid excessive polling of universal variable
file"") was not a complete revert, which seems to have caused the
problem reported in IlanCosman/tide#171.

See #8088
@krobelus
Copy link

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.

@natecraddock
Copy link

Thanks @krobelus for taking a look at this!

I would like to mention one thing now that I have tested this longer. I used my build with the fully reverted commit regularly over the weekend, and twice Tide failed to load in a new shell. When I noticed this, I would repeatedly open and close a terminal to replicate the behavior without success. So it seems that fully reverting the commit greatly helps, but there is still a small chance that Tide will not load.

I'm not sure if that's an issue with fish or Tide, but I figured I would report what I found

@yukina3230
Copy link

I am also having this bug on gnome terminal, every time I open a new terminal, I have to press Enter to get the Tide prompt to show up. If I remove Tide, the fish shell works normally. Hope you take a moment to fix it.

@kidonng
Copy link
Contributor

kidonng commented Jul 26, 2021

@gaumeo3230 Please at least read the latest comments on this thread and don't just spam it. It should already be fixed in latest fish master.

@IlanCosman IlanCosman added the 🏞️ upstream Due to upstream constraints label Jul 26, 2021
thunder-coding pushed a commit to thunder-coding/fish-shell that referenced this issue Jul 28, 2021
62d8f72 ("Revert "Avoid excessive polling of universal variable
file"") was not a complete revert, which seems to have caused the
problem reported in IlanCosman/tide#171.

See fish-shell#8088
@kidonng kidonng mentioned this issue Aug 5, 2021
@leafinote
Copy link

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

@IlanCosman
Copy link
Owner

@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 😄

@IlanCosman
Copy link
Owner

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

@leafinote
Copy link

I can confirm it works for me.

@IlanCosman IlanCosman removed the 🏞️ upstream Due to upstream constraints label Aug 13, 2021
@IlanCosman IlanCosman added this to the v5.0.1 milestone Aug 13, 2021
@HawkinsT
Copy link

HawkinsT commented Jan 11, 2022

Unfortunately this bug still appears to be preset (not fixed in v5.0.1) under WSL2 with Windows Terminal Preview.

Edit:
I appear to have found the cause of this, in my config.fish I had the line:

set -gx XDG_RUNTIME_DIR /tmp/runtime-user

Removing this line stops the issue. My assumption is that this is just a fringe case of the same bug.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 15, 2023
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

10 participants