Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce global "Filtered Actions" that are invoked when a filter evaluates to a non-empty result #7999

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Jermolene
Copy link
Member

This PR introduces a potentially highly dangerous new feature: the ability to execute action strings whenever a filter expression evaluates to a non-empty result.

A filtered action is a tiddler with the tag $:/tags/FilteredActions, and a filter field containing a filter expression. The actions are taken from the text field.

It is useful for automating actions. As an example, this PR amends the Tour plugin so that the user no longer needs to click the "next" button to advance to the next step.

To try a demo:

However, the danger is that it is very easy to set up a filtered action that is invoked continuously.

The system currently throttles filtered actions so that they occur no more often than every 500ms, which avoids the thrashing that would occur if the actions were allowed to occur as rapidly as possible.

I think the design may need to refined. For example, I wonder if the throttling should apply to individual filtered actions, rather than the whole set. It is also possible that we might avoid accidental thrashing if we only triggered a filter action the first time it returns a result, and ignore repeated results after the first one.

Progress

  • Basic throttled operation
  • Support providing variables to the filter expressions (needed by the step-success-filter-var feature of the Tour plugin)

Copy link

vercel bot commented Feb 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
tiddlywiki5 ✅ Ready (Inspect) Visit Preview Feb 22, 2024 5:29pm

@@ -0,0 +1,7 @@
title: $:/plugins/tiddlywiki/tour/filtered-action
tags: $:/tags/FilteredActions
filter: [{$:/config/ShowTour}!is[blank]else[show]match[show]then[$:/state/tour/step]get[text]get[step-success-filter]] :map[subfilter<currentTiddler>] :filter[<currentTiddler>!match[]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm. I'm not sure what this filter does, so I doubt users will be able to create something like this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would agree that complex filters are complex, but I don't know how that relates to this PR.

@saqimtiaz
Copy link
Member

While working with tm-http-request today I keep running into situations where this would be useful.

For example, a tiddler is meant to show data retrieved via a HTTP request. At present the best I can do is either ensure that the user navigates to this tiddler only via a button that triggers the request and the navigation simultaneously, or by adding a button along the lines of "click here to load the data" on the display tiddler, neither of which is palatable. So I am having to resort to using a modal so that I can control how the display of this part of this interface is initiated and also trigger the HTTP request.

It would be much more preferable to have the presence of the tiddler in the story river be the trigger for the HTTP request.

@Leilei332
Copy link
Contributor

Leilei332 commented Aug 26, 2024

Would it be possible to trigger actions at a certain time (like what crontab does in Linux) based on this feature? I think this is useful for tiddlywiki to run automated tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants