usrme / wishlistlite

The lesser SSH directory ✨
MIT License
3 stars 0 forks source link

Investigate showing spinner up until the point of a connection/failure #8

Closed usrme closed 1 year ago

usrme commented 2 years ago

It feels like this could be a nice feature to show a loading spinner in the main screen without immediately jumping to the SSH process, though this will definitely require a refactor to how the SSH process is handled. If a pseudoterminal is allocated or the connection fails entirely, then the user should immediately just see that and the wishlistlite process should finish. Everything up until either of those should "just" be a visible spinner to indicate that something is happening.

usrme commented 2 years ago

Some potentially helpful links:

usrme commented 2 years ago

There's also a good discussion here, but I'm still not quite sure how that could be leveraged for an executable that doesn't (seemingly) send anything back aside from packets.

usrme commented 1 year ago

The latest commit dc23362 adds showing a ~spinner~ pulsation and a stopwatch up until the point of the connection :tada:

It works by starting an SSH process in the background upon selecting an item from the list. The process is set up using the 'ControlMaster', 'ControlPersist', and 'ControlPath' SSH options, which set up a control socket for connection sharing that is then connected to right after anything is read from the standard output of said process.

After a lot of research this was the best way I could come up with short of leveraging the 'ssh' package for Go, but would have meant writing a lot more code that I didn't necessarily want to do. It would have also meant that I would have missed out on learning about those nifty SSH options!

There is still some clean-up, refactoring, and documenting to do, but overall this is fine for my use case in terms of functionality and risk vectors.

usrme commented 1 year ago

It seems as if having a spinner and a stopwatch interferes with the update rate of both of them, at least in the current scenario in commit c523c4a where I also had the following in the default block here:

cmds = append(cmds, m.spinner.Tick)
m.spinner, cmd = m.spinner.Update(msg)
cmds = append(cmds, cmd)

The ~spinner~ pulsation was going way too fast and seemingly taking precedence over the stopwatch, which was going far too slow in relation to the actual elapsed time. I'll see if I can conjure up a minimally reproducible example and if it's still a problem, then I'll create an issue to Bubble Tea.

usrme commented 1 year ago

The refactoring that I mentioned above should ideally use the Send() functionality shown here as that would enable me to have the terminal interface logic in gui.go and everything related to calling ssh in main.go.

usrme commented 1 year ago

Going ahead and closing this as injecting messages outside of the program loop would not work for my use case as I'm explicitly dealing with a return value from the inside of the program loop to carry on. So, I'll just leave things as they are now and carry on with other things :hourglass_flowing_sand: