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

feat: more categorization and support for select_keys #286

Closed

Conversation

iloveitaly
Copy link
Contributor

Similar to this PR (and as discussed here this contains a additional app categorizations.

Some additional changes:

  • Added select_keys to the rule. This is helpful for matching on the domain name of an event.
  • Added prettier colors (screenshot below)

image

@codecov
Copy link

codecov bot commented May 5, 2021

Codecov Report

Base: 25.05% // Head: 25.40% // Increases project coverage by +0.35% 🎉

Coverage data is based on head (5073642) compared to base (12effc6).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #286      +/-   ##
==========================================
+ Coverage   25.05%   25.40%   +0.35%     
==========================================
  Files          27       27              
  Lines        1489     1496       +7     
  Branches      240      247       +7     
==========================================
+ Hits          373      380       +7     
  Misses       1086     1086              
  Partials       30       30              
Impacted Files Coverage Δ
src/util/classes.ts 82.40% <100.00%> (+1.21%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@iloveitaly iloveitaly changed the title More categorization and support for select_keys feat: more categorization and support for select_keys Jan 19, 2022
@iloveitaly
Copy link
Contributor Author

@ErikBjare friendly reminder on this PR :)

Before I fix the last failing test, I want to make sure this is the sort of thing you'd be ok merging in.

Comment on lines +63 to +75
{
name: ['Work', 'Programming'],
rule: { type: 'regex', select_keys: ['url'], regex: 'github.com' },
data: { color: COLOR_SUPER_GREEN },
},
Copy link
Member

@ErikBjare ErikBjare Feb 8, 2022

Choose a reason for hiding this comment

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

Does having several category rules with the same name work correctly in the web UI? (editing etc)

Seems redundant to specify data several times (how would collisions/differences be handled?).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does seem to work from my testing!

Copy link
Member

Choose a reason for hiding this comment

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

This rule will only work in those cases where there is a url set on events at all (only on macOS), which makes me not want this as a default rule (esp with the "hidden" select_keys specifier).

I think it will be very confusing to users which would expect this to work, given it's a default, but for most users it won't (and without a select_keys UI, it would be a mystery why it doesn't work if they were to e.g. edit it).

Comment on lines -51 to +97
data: { color: '#F80' },
data: { color: COLOR_RED },
Copy link
Member

@ErikBjare ErikBjare Feb 8, 2022

Choose a reason for hiding this comment

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

Was orange, now red (intentional/improvement?)

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
data: { color: '#F80' },
data: { color: COLOR_RED },
data: { color: COLOR_ORANGE },

Comment on lines -56 to +102
data: { color: '#F33' },
data: { color: COLOR_RED },
Copy link
Member

Choose a reason for hiding this comment

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

Was a dimmer/desaturated red, now a darker/saturated red. Worse contrast with the black text.

Comment on lines 65 to 111
data: { color: '#FCC400' },
data: { color: COLOR_RED },
Copy link
Member

Choose a reason for hiding this comment

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

Was yellow, now red.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can revert it back, but I think the dark red looks ok:

image

Maybe just personal preference on my end, so happy to revert if you'd like.

},
{
name: ['Media', 'Music'],
rule: {
type: 'regex',
regex: 'Spotify|Deezer',
regex: 'Spotify|Deezer|Amazon Music',
ignore_case: true,
},
data: { color: '#A8FC00' },
Copy link
Member

@ErikBjare ErikBjare Feb 8, 2022

Choose a reason for hiding this comment

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

Can this color be lifted out into a constant too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

const COLOR_GREEN = '#96cd39',
COLOR_SUPER_GREEN = '#54e346',
COLOR_UNCAT = '#CCC',
COLOR_ORANGE_GREEN = '#f5ff65',
Copy link
Member

Choose a reason for hiding this comment

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

Maybe rename/change this slightly to a yellow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@iloveitaly iloveitaly force-pushed the more-categorization branch from 9a4ec7b to 9fe3fe0 Compare June 14, 2022 14:30
@iloveitaly
Copy link
Contributor Author

@ErikBjare Finally getting back to this, take another look and let me know what you think!

Copy link
Member

@ErikBjare ErikBjare left a comment

Choose a reason for hiding this comment

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

Just a couple minor things and I'll merge :)

name: ['Work', 'Writing'],
rule: {
type: 'regex',
select_keys: ['app'],
Copy link
Member

Choose a reason for hiding this comment

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

So this is set, but there is no way to change it in the UI?

All select_keys should probably be removed from the default categories until the UI supports it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's right.

You can't set them via the UI, but you can import a config file which contains them. I think we should add select_keys to the default config since you can 'export, modify, import' and to mutate these keys and it makes it more explicit how we are deciding which app is in use.

Copy link
Member

Choose a reason for hiding this comment

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

But that's very confusing for the user. They have no indication there is even a select_keys for those categories, right? (unless they export and inspect)

I really don't want to add this specifier to the default rules without:

  1. UI support for it
  2. More thorough testing of these new "multi-rule" categories in the UI.
    • What happens in the UI if a category with multiple rules has children?
    • What happens when you rename a category with multiple rules? Or assign it to a different parent?
    • What happens to color keys when you have multiple rules?
    • Ideally, a category with multiple rules should be listed only once in the category tree, with an indication that there are multiple rules for this one category (without listing it as two seperate categories, since that's likely to get confusing).

Comment on lines 27 to 34
// https://colorhunt.co/palette/4802
const COLOR_GREEN = '#96cd39',
COLOR_SUPER_GREEN = '#54e346',
COLOR_BRIGHT_GREEN = '#A8FC00',
COLOR_UNCAT = '#CCC',
COLOR_SLIGHTLY_YELLOW = '#f5ff65',
COLOR_ORANGE = '#ffba47',
COLOR_RED = '#ff5b44';
Copy link
Member

Choose a reason for hiding this comment

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

Please revert these to previous colors (but good to keep them as constants!)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted!

src/util/classes.ts Outdated Show resolved Hide resolved
@iloveitaly
Copy link
Contributor Author

@ErikBjare finally fixed this. Collapsed the commits & rebased. Hopefully this is what we need to get this in!

Copy link
Member

@ErikBjare ErikBjare left a comment

Choose a reason for hiding this comment

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

Was hoping to merge this but I still find the hidden-from-user select_keys behavior problematic.

I really want to see a UI for it before I feel okay with adding the selector to the default categories, as I otherwise think users will be very confused.

The "multi-rule" categories also make me uneasy, as I didn't design for it so I would want to review/test this much more thoroughly before I feel confident merging it (see comments for specifics).

To support multi-rule categories like this without causing trouble, I think it'd be best if we allowed the rule property to be a array of rules. Instead of having several categories with the same name implicitly be the same (troublesome with the data property, renaming, parents, etc).

All these color changes are also very hard to review. I generally don't want them changed. I tried to leave comments where I found differences, but I'm sure I didn't spot them all.

If you want, we can strip the select_keys and merge this now (so we get the color constants etc.), or we can leave this open if you want to give the UI part a shot.

Comment on lines +63 to +75
{
name: ['Work', 'Programming'],
rule: { type: 'regex', select_keys: ['url'], regex: 'github.com' },
data: { color: COLOR_SUPER_GREEN },
},
Copy link
Member

Choose a reason for hiding this comment

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

This rule will only work in those cases where there is a url set on events at all (only on macOS), which makes me not want this as a default rule (esp with the "hidden" select_keys specifier).

I think it will be very confusing to users which would expect this to work, given it's a default, but for most users it won't (and without a select_keys UI, it would be a mystery why it doesn't work if they were to e.g. edit it).

Comment on lines +52 to +60
},
{
name: ['Work', 'General'],
rule: {
type: 'regex',
regex: 'Preview|Finder|Todoist|1Password|Soulver|System Preferences|VNC Viewer|Streaks',
select_keys: ['app'],
},
data: { color: COLOR_SLIGHTLY_YELLOW },
Copy link
Member

@ErikBjare ErikBjare Dec 23, 2022

Choose a reason for hiding this comment

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

Suggested change
},
{
name: ['Work', 'General'],
rule: {
type: 'regex',
regex: 'Preview|Finder|Todoist|1Password|Soulver|System Preferences|VNC Viewer|Streaks',
select_keys: ['app'],
},
data: { color: COLOR_SLIGHTLY_YELLOW },

Sorry, but I don't like this as a default category. It's too broad to be generally useful, imo. Better to leave underspecified stuff like this up to the user (or if one would keep it, it would belong better in the parent category 'Work', such that child-categories can override).

regex:
'Messenger|Messages|Discord|Telegram|Signal|WhatsApp|Rambox|Slack|Riot|Element|Discord|Textual|Nheko|Texts',
},
data: { color: COLOR_ORANGE },
Copy link
Member

Choose a reason for hiding this comment

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

Why override the #9FF comms color with something very different?

Suggested change
data: { color: COLOR_ORANGE },

{
name: ['Comms', 'Email'],
rule: { type: 'regex', regex: 'Gmail|Thunderbird|mutt|alpine' },
data: { color: COLOR_ORANGE },
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

Suggested change
data: { color: COLOR_ORANGE },

{
name: ['Comms', 'Meetings'],
rule: { type: 'regex', regex: 'Zoom|Calendar|Cron' },
data: { color: COLOR_SLIGHTLY_YELLOW },
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
data: { color: COLOR_SLIGHTLY_YELLOW },

@@ -197,6 +268,7 @@ function pickDeepest(categories: Category[]) {
return _.maxBy(categories, c => c.name.length);
}

// TODO this is only used colorize the categories, all categorization is done on the backend
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// TODO this is only used colorize the categories, all categorization is done on the backend
// NOTE: this is only used to colorize the categories, all actual categorization is done on the backend

name: ['Work', 'Writing'],
rule: {
type: 'regex',
select_keys: ['app'],
Copy link
Member

Choose a reason for hiding this comment

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

But that's very confusing for the user. They have no indication there is even a select_keys for those categories, right? (unless they export and inspect)

I really don't want to add this specifier to the default rules without:

  1. UI support for it
  2. More thorough testing of these new "multi-rule" categories in the UI.
    • What happens in the UI if a category with multiple rules has children?
    • What happens when you rename a category with multiple rules? Or assign it to a different parent?
    • What happens to color keys when you have multiple rules?
    • Ideally, a category with multiple rules should be listed only once in the category tree, with an indication that there are multiple rules for this one category (without listing it as two seperate categories, since that's likely to get confusing).

COLOR_YELLOW = '#FCC400',
COLOR_SLIGHTLY_YELLOW = '#f5ff65',
COLOR_ORANGE = '#ffba47',
COLOR_RED = '#F80';
Copy link
Member

Choose a reason for hiding this comment

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

Red is orange now? Previous red was #F33.

Suggested change
COLOR_RED = '#F80';
COLOR_RED = '#F33';

Comment on lines -32 to -34
name: ['Work'],
rule: { type: 'regex', regex: 'Google Docs|libreoffice|ReText' },
data: { color: '#0F0' },
Copy link
Member

@ErikBjare ErikBjare Dec 23, 2022

Choose a reason for hiding this comment

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

Better to keep this parent-category explicit imo. Even if without a rule, such that children inherit color and don't need to be set explicitly for each child.

Comment on lines -51 to +97
data: { color: '#F80' },
data: { color: COLOR_RED },
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
data: { color: '#F80' },
data: { color: COLOR_RED },
data: { color: COLOR_ORANGE },

@iloveitaly
Copy link
Contributor Author

Makes sense! I don't have any additional time to spend on this, so someone else will have to take this up to get it across the finish line.

@CVirus
Copy link

CVirus commented May 31, 2023

bump

@iloveitaly
Copy link
Contributor Author

Closing out in favor of the simplier #495

@iloveitaly iloveitaly closed this Oct 22, 2023
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