I started looking into implementing this feature and found some oddities related to how the combination of Slack subscriptions for categories and tags work. I submitted a PR for one issue, but can see some additional ones that we may need to tackle.
Currently, a Slack plugin subscription in the UI makes it look like you can choose a category and a set of tags for a single filter. But in my tests, it looks like any time you add a tag, it sets the category to “all” when you save the filter.
I think this is OK, since nowhere else in the application do we allow you to combine a category and set of tags in a single filter (eg, user notification preferences).
Can I proceed with the assumption that we don’t actually want to allow a user to choose a category other than “all” in a filter that includes tags?
More concretely, I think it may make sense to work towards a design where a subscription is analogous to a user’s notification preferences. But instead of the user_id being the key, the Slack channel would be the key.
Each Slack channel would have at most 1 subscription.
Updating a channel’s subscription would just mutate one record, and the code would enforce that a given category or tag can only belong to one of the respective lists. Notifications would match topics to a subscription filter based on whether the category OR any tags match, and continue to use the existing logic for precedence of muted over watching and following.
If we are keeping the feature to combine categories and tags in a single filler, then doing something closer to what you’ve described makes sense. I think this may introduce more complexities in the UX, particularly when it comes to updating them via Slack commands, though, and I personally question whether it’s worth it.
If we are keeping the ability to have categories & tags in one rule, then this is the UX I’ve been working on within slack. It’s based on the existing slack plugin, with some adaptations which I hope make it better
/discourse watch some-category
would just add the rule to the list, sorted in order of precedence (topmost matching rule wins).
You can also have multiple tags in the same command /discourse watch some-category tag:food tag:new
And completely miss out the category if you like (‘all categories’ is assumed) /discourse watch tag:test
Then deleting the second rule in the list is as simple as /discourse remove 2
I think having simple add/remove rules options is a simpler UX than the existing interface (which tries to work out how to augment the existing rules in order to match your command). It also matches the admin UI exactly which should help. There would still be some simple logic to avoid duplicates.
What do you think? Does that help with the UX complexities you describe?
If you see value in supporting the ability to create a filter with multiple tags in one command, I might suggest this syntax instead though, which more closely matches how things are displayed:
/discourse watch some-category tags:foo,bar,baz
One way to think about the current implementation is that a given tuple (category, tag) can only have one status associated with it from the following set: (watching, following, muted, nil). And a user can only modify a single tuple at a time. (This is where the “it tries to work out how to augment the existing rules” comes in. But I don’t think it’s actually too difficult to reason about from the user’s perspective).
To make things simpler, the Slack command UX currently only allows you to create or update filters where category or tag is nil. But thinking about it more now, I don’t think it would be too difficult or add too much additional complexity to support the combination of category/tag filters in the current design.
That said, I’m not attached to it if you find that the design you’re currently exploring is the way things should go.
I would recommend exploring this a bit more since I agree that seems like the biggest change in your new design. See if you can think of likely ways that people may end up with filters that have overlapping matches and what, if anything, the plugin should do to try to help there.
You might also want to take a peek at the code for the plugin as it exists in my current fork as I think the implementation for the rule augmentation has been simplified quite a bit, but this pull request is still pending.