inquire icon indicating copy to clipboard operation
inquire copied to clipboard

Allow re-rendering after the data in a prompt becomes stale (maybe by allowing cancellation?)

Open darklajid opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe.

I have a Select to let the user - well - select items and toggle some state based on that. Occasionally some items on the list change or new items are added - but that isn't reflected in the Select prompt of course.

Describe the solution you'd like

I would like to be able to ideally cancel (or otherwise: timeout) a prompt to be able to "refresh" the TUI. Basically abort the prompt and re-render/re-prompt with an updated state. A "Christmas came early" cherry on top solution could re-render lists while keeping state (search, maybe even 'selected item' using PartialEq or Hash?), but let's not get carried away.

Describe alternatives you've considered

I've tried emulating pressing an escape key and going from there, but am stuck so far

darklajid avatar Aug 02 '23 03:08 darklajid

Hey, sorry for the delay, just got back from vacation. This is a really important feature and allowing list refreshes on the fly is certainly something i want to implement before v1

mikaelmello avatar Sep 16 '23 20:09 mikaelmello

I tried solving a similar problem by using the AutoComplete Trait that is available on the Text Prompt.

I was trying to make a Query builder for JQL(Jira Query Language) where the options would be completions provided by the Jira API, Which was possible, but I was querying the Jira API on any input that changed due to how get_suggestions and get_completion are called on any change to the input. Which I attempted to solve by adding debounce logic, but that proved quite diffuctult.

My initial idea was a new Prompt named Query which accepts and show options similar to Select but allows to refresh the options similar to Text and it's AutoComplete trait. But it could potentially be solved by expanding the AutoComplete trait with a refresh_options function and a config option to enable debouncing input.

Baarsgaard avatar Oct 01 '23 13:10 Baarsgaard