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

Make prompt asynchronous #15

Closed
IlanCosman opened this issue Aug 2, 2020 · 21 comments
Closed

Make prompt asynchronous #15

IlanCosman opened this issue Aug 2, 2020 · 21 comments
Labels
🌊 enhancement New feature or request

Comments

@IlanCosman
Copy link
Owner

IlanCosman commented Aug 2, 2020

Is your feature request related to a problem? Please describe.
The prompt can be slow at times, especially when in a git repository.

Describe the solution you'd like
An asynchronous prompt that allows the user to run commands without being blocked by the prompt loading.

fish-async-prompt already works fairly well with Tide so adapting it and then baking it in is probably the easiest path.

@IlanCosman IlanCosman added the 🌊 enhancement New feature or request label Aug 2, 2020
@IlanCosman IlanCosman pinned this issue Aug 2, 2020
@IlanCosman IlanCosman unpinned this issue Sep 14, 2020
@ferologics
Copy link

+1

@IlanCosman
Copy link
Owner Author

Sorry for the message blast 😅 If anyone is interested in trying this out early, you can install it with fisher install ilancosman/tide@async. I'd really appreciate any feedback on it, there's almost certainly some bugs lurking. I'll probably release v3.0 in a week or so, there's a bunch of documentation stuff to do.

@jorgebucaran @deathtrip @PatrickF1 @gokulsoumya @sgorblex @andre95d @branchvincent @limakzi @joaolrpaulo

@ferologics
Copy link

Installing :)

@IlanCosman
Copy link
Owner Author

@ferologics Anything to report? What do you think?

@ferologics
Copy link

@IlanCosman so far so good. I only have one issue when using the emojis & special characters keyboard. Not sure if it's related but I think that it used to work fine prior to the install. It adds a newline and makes the prompt disappear if I use an emoji.
image

@ferologics
Copy link

Gets pretty hectic 😅
image

@IlanCosman
Copy link
Owner Author

Glad to hear it's (mostly 😂) working well for you! I can't replicate your emoji error on my mac, so we'll just have to wait and see. Thanks for beta testing 😄

@ferologics
Copy link

@IlanCosman maybe this is a problem with the prompt type, I didn't use to have the icons on the side (the 🍎) but when I updated to async prompt I changed my configuration. How can I dump the config for you to reproduce?

@IlanCosman
Copy link
Owner Author

That would be tide bug-report --verbose. No need to do it now though, I'd prefer it to be in a new issue after the v3 release 😄

@ferologics
Copy link

I got the feeling that you're not rushing to the rescue here @IlanCosman 😄 good luck with the update 😝 I'll have to suffer in the meantime 🙂

@IlanCosman
Copy link
Owner Author

Yah sorry about that 😞I get the impression after a bit of digging that the bug isn't originating from Tide though. Emojis have a ton of issues with shells in general.

@sgorblex
Copy link

Hi. I've tested the async branch on my machine and some Docker containers (official images + installed fish). Here's what i found. I'm a big fan of this project, I really hope this helps :)

1. My machine, Arch

It could be relevant that I'm using tmux. Output of tide bug-report:

fish, version 3.1.2
tide, version 2.5.0
screen-256color

Issues

  1. The prompt doesn't load when the shell starts, however it loads as soon as i update it for any reason (e.g. pressing enter).
  2. The prompt is considerably slower to load comparing it to the main branch.
  3. Sometimes, tipically when starting the shell, fish's colors and completion don't show up (colors are just grey)(however completion seems to work despite appearing as whitespace tabs). (Un)fortunately upon reinstalling the prompt i can't reproduce this problem anymore.
  4. Vim mode randomly changes modes in a way in which I can't really detect a pattern.

2. Arch Docker

Output of tide bug-report:

fish, version 3.1.2
tide, version 2.5.0
xterm

Issues

  1. Vim mode seems to be broken. Sometimes it completely inverts default and insert modes, however this only happens if you switch the modes once. Sometimes it seems more random (see 1.4)

3. Debian Docker

Output of tide bug-report:

fish, version 3.0.2
tide, version 2.5.0
xterm

Issues

  1. After installing (before the guided autoconfig) i get this.
  2. Every time the prompt loads i get this.

4. Ubuntu Docker

Output of tide bug-report:

fish, version 3.1.0
tide, version 2.5.0
xterm

Issues

  • the prompt doesn't show at all.

5. Alpine Docker

Output of tide bug-report:

fish, version 3.1.2
tide, version 2.5.0
xterm

Issues

  1. For some reason sometimes this screen from BusyBox shows up:
BusyBox v1.31.1 () multi-call binary.

Usage: basename FILE [SUFFIX]

Strip directory path and .SUFFIX from FILE

I'm not familiar with Alpine Linux, so I'm not sure if this is related.
2. Vim mode issues similar to the previously quoted.

@IlanCosman
Copy link
Owner Author

IlanCosman commented Dec 14, 2020

Wow! Thank you so much for your extensive work @sgorblex! 😄

The prompt doesn't load when the shell starts, however it loads as soon as i update it for any reason (e.g. pressing enter).

This one I already knew about, and I'm not really sure how to fix it. It doesn't happen on my Arch VM, but does happen on my Mac. I'll look into it, however it's definitely not a release-blocking bug.

The prompt is considerably slower to load comparing it to the main branch.

That's interesting. May I ask what hardware you're using? On my newish hardware there isn't a perceptible difference. In a git repo, the new version is light years faster.

There is unfortunately a quirk of fish where the perceived speed of the prompt seems to be effected by the duration of the new fish instance being created in the background. You can look at this yourself by comparing your perceived speed in a big git repo vs a regular dir. Then, compare the time fish_prompt in each. You'll find that the time fish_prompt doesn't change much, but the perceived speed is way slower. I'd love to get to the bottom of this.

I'll try to reproduce each of these bugs in VMs, as in my limited experience they're more likely to be a realistic depiction of a user's machine. However it's obviously still an issue if Tide doesn't work in docker containers, so afterwards I'll check that out.

Unfortunately I don't use tmux or vim, but I'll do my best. I'd wager however that tmux and or docker is probably messing things up for Tide (or the other way depending on your perspective 😂) . Your $TERMs are also quite interesting to me. "Normal" users will usually have xterm-256color.

Again, thank you so much for your work 😄 I had been planning to release today, but after this it's clear I'll need to do some more testing 😂 Might delay the release for a weekish because finals are upon me. This was sort of my last day to get it done beforehand.

@PatrickF1
Copy link
Contributor

Hi @IlanCosman, I've also conducted some tests. Here are my notes

  1. I have the same bug where the prompt doesn't show on a new tab load until I press enter, after which it works fine.
  2. time fish_prompt returns 2ms on both master and async branches.
  3. Haven't encountered any bugs on async otherwise.

@sudormrfbin
Copy link

sudormrfbin commented Dec 14, 2020

I encountered a problem while running fisher install ilancosman/tide@async, I'm not sure if the previous installation is conflicting somehow with the update:

Click to expand
fetching https://codeload.github.com/ilancosman/tide/tar.gz/async
sourcing /home/gokul/.config/fish/fisher/functions/_tide_cursor_right.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_cursor_up.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_decolor.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_detect_os.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_git_prompt_set_vars.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_item_cmd_duration.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_item_context.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_item_git_prompt.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_item_jobs.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_item_nvm.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_item_os.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_item_prompt_char.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_item_pwd.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_item_rust.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_item_status.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_item_time.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_item_vi_mode.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_item_virtual_env.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_left_prompt.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_prompt.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_right_prompt.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_sub_bug-report.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_sub_configure.fish
sourcing /home/gokul/.config/fish/fisher/functions/_tide_sub_test.fish
sourcing /home/gokul/.config/fish/fisher/functions/fish_mode_prompt.fish
sourcing /home/gokul/.config/fish/fisher/functions/fish_prompt.fish
sourcing /home/gokul/.config/fish/fisher/functions/fish_right_prompt.fish
sourcing /home/gokul/.config/fish/fisher/functions/tide.fish
sourcing /home/gokul/.config/fish/fisher/conf.d/_tide_init.fish
source: Error encountered while sourcing file “/home/gokul/.config/fish/functions/tide/configure/choices/all/style.fish”:
source: No such file or directory
fish: Unknown command: _load_config
~/.config/fish/fisher/conf.d/_tide_init.fish (line 16):
    _load_config 'lean'
    ^
in function '_tide_init_install'
	called on line 1 of file ~/.config/fish/fisher/functions/fisher.fish
in event handler: handler for generic event “_tide_init_install”
	called on line 142 of file ~/.config/fish/fisher/functions/fisher.fish
source: Error encountered while sourcing file “/home/gokul/.config/fish/functions/tide/configure/choices/all/finish.fish”:
source: No such file or directory
fish: Unknown command: _tide_finish
~/.config/fish/fisher/conf.d/_tide_init.fish (line 19):
    _tide_finish
    ^
in function '_tide_init_install'
	called on line 1 of file ~/.config/fish/fisher/functions/fisher.fish
in event handler: handler for generic event “_tide_init_install”
	called on line 142 of file ~/.config/fish/fisher/functions/fisher.fish
source: Error encountered while sourcing file “/home/gokul/.config/fish/functions/fish_prompt.fish”:
source: No such file or directory
Configure tide prompt? [Y/n]

The last line asking for prompt configuration seems to be continuously clearing the line and printing the text again (the cursor shifts back and forth between the beginning and end of the line), and it's unresponsive with ^C also.

Force closing the terminal instance and opening a new one doesn't leave any trace of the error during installation.

@ferologics
Copy link

ferologics commented Dec 14, 2020

IDK if this is related but I started getting this strange error when using open command:

The application cannot be opened for an unexpected reason, error=Error Domain=NSOSStatusErrorDomain Code=-600 "procNotFound: no eligible process with specified descriptor" UserInfo={_LSLine=379, _LSFunction=_LSAnnotateAndSendAppleEventWithOptions}

@sgorblex
Copy link

@IlanCosman

Your $TERMs are also quite interesting to me. "Normal" users will usually have xterm-256color.

To be honest I too just found out that I don't have xterm-256color, it might be related with tmux, but I'm not familiar with the TERM thing so I can't really give you a solid opinion. xterm in Docker is probably standard, I guess.

(btw, I'm trying to learn Docker containers so this tests were doubly useful :D )

In a regular directory I get times similar to these, however for some reason my perceived speed is the way around. It might be caused by the phenomenon you mentioned, again I'm not familiar with this stuff.

async:

________________________________________________________
Executed in  900.00 micros    fish           external
   usr time  817.00 micros  817.00 micros    0.00 micros
   sys time    0.00 micros    0.00 micros    0.00 micros

main:

________________________________________________________
Executed in    4.41 millis    fish           external
   usr time    1.22 millis    1.22 millis    0.00 micros
   sys time    3.41 millis    3.41 millis    0.00 micros

In a git repo (openjdk/jdk) I get these times:

async:

________________________________________________________
Executed in  842.00 micros    fish           external
   usr time  781.00 micros  781.00 micros    0.00 micros
   sys time    0.00 micros    0.00 micros    0.00 micros

main:

________________________________________________________
Executed in  280.30 millis    fish           external
   usr time  161.19 millis    9.52 millis  151.67 millis
   sys time  188.06 millis    6.91 millis  181.15 millis

So yes, async is way faster on paper.

Also, I have no idea what causes this but sometimes the prompt takes a billion years (like 30 secs) to load in a big repo like that. This happens in the main branch, I'm not sure in async.

When starting the shell I also encountered this error message (which I didn't have prior to installing async but I'm not sure it's related) related to thefuck.

> Traceback (most recent call last):
  File "/usr/bin/thefuck", line 13, in <module>
    sys.exit(main())
  File "/usr/lib/python3.9/site-packages/thefuck/entrypoints/main.py", line 29, in main
    print_alias(known_args)
  File "/usr/lib/python3.9/site-packages/thefuck/entrypoints/alias.py", line 26, in print_alias
    print(_get_alias(known_args))
  File "/usr/lib/python3.9/site-packages/colorama/ansitowin32.py", line 41, in write
    self.__convertor.write(text)
  File "/usr/lib/python3.9/site-packages/colorama/ansitowin32.py", line 162, in write
    self.write_and_convert(text)
  File "/usr/lib/python3.9/site-packages/colorama/ansitowin32.py", line 190, in write_and_convert
    self.write_plain_text(text, cursor, len(text))
  File "/usr/lib/python3.9/site-packages/colorama/ansitowin32.py", line 196, in write_plain_text
    self.wrapped.flush()
BrokenPipeError: [Errno 32] Broken pipe
Exception ignored in: <colorama.ansitowin32.StreamWrapper object at 0x7fc954b89220>
BrokenPipeError: [Errno 32] Broken pipe

Again, thank you so much for your work

Thank you for providing this awesome software. I'd love to contribute but if I'm being honest I don't really know this area and on top of that I have very little time in this period. Maybe in some time things will change :). In the meantime I hope I'm being helpful with these reports (I might also open an issue with some ideas that I thought would be cool). Keep up the good stuff!

P.S. I'm a non-native English speaker so bear with me on that.

@IlanCosman
Copy link
Owner Author

@sgorblex Alright so I did a little bit of testing, and as far as I can tell the vi indicator is always displaying the previous state, in other words it's always one step behind what it should be. Sigh It's probably some annoying interaction between event handlers and universal variables and prompt repainting.

As for the other bugs, your debian ones are presumably caused by an old fish version; Tide only works with 3.1.0+. Your Ubuntu one I can't reproduce with a 20.04 VM. Alpine 🤷‍♂️If anyone complains about it I'll look into it lol.

P.S. Your English is excellent, I had no idea you weren't a native speaker! No worries there regardless 😄

@IlanCosman
Copy link
Owner Author

Nope, was actually dead easy! I just had to use force-repaint instead of repaint. force-repaint doesn't "coalesce multiple successive prompts" whatever that means 😂

@sgorblex Could you do a little testing after the latest commit? I don't really know vi mode well enough to tell if things aren't working as expected.

@IlanCosman IlanCosman pinned this issue Dec 18, 2020
@sgorblex
Copy link

I didn't upgrade yet and recently I'm getting this

<W> fish: Locking the universal var file took too long (0.361 seconds).

(with various times)

Anyway I'm upgrading right now.

@IlanCosman
Copy link
Owner Author

Hi all, with the release of v3, please report any problems in new issues. Thanks 😄

@IlanCosman IlanCosman unpinned this issue Dec 23, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🌊 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants