timc1/kbar

Possibility to define actions that are always shown / never filtered out from the results list

aghster opened this issue · 7 comments

I would like to be able to define actions that are always part of the results list, irrespecitve of the current search string. However, this is not possible, because actions for which command-score returns 0 will not be included in the results list due to:

kbar/src/useMatches.tsx

Lines 196 to 198 in 54b9fd8

if (score > 0) {
matches.push({ score, action });
}

My suggestion is that any action whose keywords include a special wildcard keyword will always be included in the results list. For example this special wildcard keyword could be *.

As it seems, this could easily be implemented by ameding the above condition as follows:

      if (score > 0 || action.keywords?.split(" ").indexOf("*") !== -1) {
        matches.push({ score, action });
      }

@timc1, would you consider this generally useful and add this feature to kbar?

timc1 commented

@aghster I'm open to it – curious what are some of those actions you had in mind that would always be part of the list?

In my use case I have only two or three static actions, but depending on the search string more actions are dynamically added. However, I want the static actions to be always quickly accessible, even if a search string was entered that does not match these actions.

eMerzh commented

I have a usecase where i have a few "action" like

  • toggle this
  • go to Y

but i also want to fallback to an action where i go "Search ${query}" where you launch a full faceted search with the current search term but ability to add a bunch of stuff

for that i need to be able to append a * query , and be able to use the search term in the perform & the action name

I agree with this idea; it would be nice to have some actions to fallback on instead of showing nothing or an empty component that can't perform any actions.

stale commented

Hey! This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

eMerzh commented

I'm interested in this... Please do not close 😁

Hey! This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.