Jump to content

One-run script filters


ctwise

Recommended Posts

There are lots of issues reported with scripts that fire for each keystroke and new feature options discussed, e.g., delay script firing until the user stops typing for x milliseconds. Here's another option that might work better and be simpler to implement. Provide support for script filters that are only run once. Then Alfred will be responsible for comparing the search text against the script results. For example:

 

item 1: cooking

item 2: cleaning

item 3: shopping

 

The user triggers the script filter. The script filter returns its complete list of items. The user keeps typing and enters 'c'. Alfred displays only items 1 & 2. The user then enters 'cl' and Alfred displays only item 2.

 

For script filters that need the query to get any results, this wouldn't be an option. For script filters that generate a complete list and then filter the results themselves, it would be. Alfred can also support fuzzy matching this way. The biggest benefit would be performance. If I have a script filter that returns results in milliseconds, it won't matter. But, if I have a script filter that takes a second or two, it will perform much, much better if I only have to fire the script once at the beginning of typing.

 

Obviously, the item title should be searchable but it's an open question whether the sub-title should be as well or whether it should be a checkbox.

Link to comment
Share on other sites

I can understand how this could be useful in concept and I've made a note to have a think about this, however, there are many unanswered questions in how the subsequent filtering would actually work to keep things consistent across Alfred.

 

Could you give an example [real life] of where you would use this one-shot type filter?

 

Also, as Alfred only runs a script filter a second time once the first run has fully completed, have you thought about just writing your results to a temporary file and reading them out of there instead on the second request. I'm sure David is doing this kind of caching in a number of places.

Link to comment
Share on other sites

I can understand how this could be useful in concept and I've made a note to have a think about this, however, there are many unanswered questions in how the subsequent filtering would actually work to keep things consistent across Alfred.

 

Could you give an example [real life] of where you would use this one-shot type filter?

 

Also, as Alfred only runs a script filter a second time once the first run has fully completed, have you thought about just writing your results to a temporary file and reading them out of there instead on the second request. I'm sure David is doing this kind of caching in a number of places.

 

Caching to a temporary file only works when the results aren't time or location dependent. It's also not possible to effectively provide any other caching since Alfred doesn't give you a session-specific key that lets you tie one script invocation to another, e.g., a UUID that says script invocation #2, #3, etc. are later invocations for the same keyboard entry (looking at whether the text is a superstring of the previous invocation isn't reliable enough).

 

A real-world example is the menus workflow. For large applications it can take half a second to a second and a half to dump a menu structure. Even a half second throws off the user since the lag in results update makes for confusing feedback. If you could dump the menu structure at the start of typing and let Alfred filter the results, it would be much cleaner (and much more efficient).

 

Other examples which would benefit from but don't necessarily require this, would be: a list of recent documents, a list of running processes, a list of mail messages, a list of bonjour results, a list of git repositories, a list of tasks, etc. In all of those examples, the script most likely dumps out a whole list and then uses script filtering to reduce the list down to match what the user is typing.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...