miversen33 / netman.nvim

Neovim (Lua powered) Network Resource Manager
MIT License
338 stars 1 forks source link

We need a **clear** way for providers to communicate their needs to consumers #151

Closed miversen33 closed 10 months ago

miversen33 commented 1 year ago

As of now there is no great way for a provider to indicate "Hey I need X" to the calling consumer. This is by design, a provider should never directly interact with the user, and consumers should never directly interact with providers.

However, there are absolutely cases where a provider may need some form of input from the end user. As they are not allowed to talk to the end user directly and the end user cannot talk to them, we have put the provider in the impossible position of "figuring" out how to do something where it needs input from the user. An example, your provider needs a password (for something. Lets say SSH). The provider simply cannot do its job in that situation.

There are a few different ways I have played with for this but none are "great".

My current thought process is that the provider returns something in their response (similar to how the error attribute works in responses) that says "Hey I need X. Get it for me with this prompt string and then call this callback with whatever you get so I can continue processing". The obvious issue with relying on callbacks however is that forces consumers (and providers) to operate asynchronously by default. Which is fine but per #117 we just don't have an asynchronous framework in place yet (and it wont be the default interaction mechanism for the API). This isn't bad per say, but it does add alot more complexity to what should be an otherwise simple process.

Currently, (synchronously) opening a resource looks like this

Adding something like above turns this into a more complex set of steps

It is very important that we maintain the provider cannot directly get this information as the rendering UI may be anything from vim itself to a GUI program over top, Neo-tree, or who knows what. Netman (nor the provider) can ensure UI likeness in its prompts with whatever consumer reached into it. So instead we should rely on bubbling.

Tagging @chipsenkbeil for thoughts (or ignore this, thats absolutely fine too 😄) as this is directly related to a bit of conversation we had on #150 (adding some sort of "connection" mechanic to the provider spec).

miversen33 commented 10 months ago

This has been complete via the message table response. https://github.com/miversen33/netman.nvim/blob/v1.15/doc/consumerguide.md#how-a-provider-communicates-with-you