Skip to content

Regex with ^ doesn't work for title key #1148

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

Closed
2 tasks done
istudyatuni opened this issue May 31, 2025 · 8 comments · Fixed by ActivityWatch/aw-webui#684
Closed
2 tasks done

Regex with ^ doesn't work for title key #1148

istudyatuni opened this issue May 31, 2025 · 8 comments · Fixed by ActivityWatch/aw-webui#684

Comments

@istudyatuni
Copy link

  • I am on the latest ActivityWatch version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • OS name and version: NixOS unstable (nixpkgs 2025-05-25)
  • ActivityWatch version: v0.13.2 (rust)

Describe the bug

When I create "Category" rule of type "Regular expression" which starts with ^, it doesn't match anything

To Reproduce

  1. Go to settings
  2. Add new rule
  3. Write title of any not yet matched app and prepend it with ^ (so, if app name is "App Name", regex should be ^App Name), and set some color
  4. Go to Timeline and see that app is not highlighted

Expected behavior

App is categorized

Documentation

There are no related logs in browser's console

Additional context

$ works

Copy link

Hi there!
As you're new to this repo, please make sure you've used an appropriate issue template and searched for duplicates (it helps us focus on actual development!). We'd also like to suggest that you read our contribution guidelines and our code of conduct.
Thanks a bunch for opening your first issue! 🙏

@BelKed
Copy link
Contributor

BelKed commented May 31, 2025

Can't reproduce on my v0.13.2 (rust)

@istudyatuni
Copy link
Author

What's your system?

@istudyatuni
Copy link
Author

istudyatuni commented May 31, 2025

So, I tested more. I'm trying to write rules for aw-watcher-window. Regex, which starts with ^ works for app, but not for title

@istudyatuni istudyatuni changed the title Regex with ^ doesn't work Regex with ^ doesn't work for title key from aw-watcher-window May 31, 2025
@BelKed
Copy link
Contributor

BelKed commented May 31, 2025

Nope, you're very likely doing something incorrectly.
The OS doesn't matter, as the coloring categorisation is done on the server.
I'm on macOS though.

Ideally share exact RegEx-es you're using with the app name and title reported by AW.

@istudyatuni
Copy link
Author

istudyatuni commented May 31, 2025

coloring categorisation is done on the server

Is it?

Example: regex ^lazyjj, report:

  • app: Alacritty
  • title: lazyjj

@istudyatuni
Copy link
Author

Well...

// NOTE: this will not work/break category rules which reference `$` or `^`
return getCategoryColorFromString(e.data.app + ' ' + e.data.title);

@istudyatuni istudyatuni changed the title Regex with ^ doesn't work for title key from aw-watcher-window Regex with ^ doesn't work for title key May 31, 2025
@BelKed
Copy link
Contributor

BelKed commented Jun 1, 2025

Ohh, sorry, I've confused it with something else :(
Great catch and thanks for finding the root cause :)

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

Successfully merging a pull request may close this issue.

2 participants