2e3s / awatcher

Activity and idle watchers
Mozilla Public License 2.0
126 stars 4 forks source link

AFK Entries don't include time before idle-timeout-seconds #19

Open arbyste opened 4 months ago

arbyste commented 4 months ago

In the activitywatch docs, it says that if you are AFK for longer than the value in idle-timeout-seconds, then it is recorded as AFK for the full duration of the time you were AFK (https://docs.activitywatch.net/en/latest/faq.html#how-does-activitywatch-know-when-i-am-afk).

In awatcher however, it only counts AFK time starting after idle-timeout-seconds has elapsed. I'm using the bundled version, so I don't know whether this is a problem with awatcher or with upstream activity watch.

Expected behavior: If idle-timeout-seconds = 180, and you're AFK for 3.5 minutes, then an AFK entry with length 3.5 minutes should be recorded.

Actual behavior: If idle-timeout-seconds = 180, and you're AFK for 3.5 minutes, then an AFK entry with length 30 seconds is recorded.

2e3s commented 4 months ago

Hello, thank you for your report. I think you may be right, I didn't pay attention into this. I'll look into this issue.

2e3s commented 3 months ago

I have looked into the issue, it seems that the bug was present only on Wayland idle handlers (KDE, Sway etc) which work differently from the original watchers. Unified the code which should fix it: https://github.com/2e3s/awatcher/releases/tag/v0.2.6

arbyste commented 3 months ago

Thanks for looking into that, it seems to be working now, however now there's some new slightly strange behavior. It looks like when I'm AFK, it actually creates 2 separate entries. Both entries start at the same time, but one of them ends a few seconds after the other. Is that expected behavior?

2e3s commented 3 months ago

I'm not sure that the AW API allows to create separate parallel entries for AFK. Could you please show what you mean with a screenshot?

arbyste commented 3 months ago

This is what it looks like on the timeline view. Notice there's a black vertical line towards the end: image

When I click on the left side of the black line, this comes up: image

When I click on the right side, this comes up: image

I couldn't take a screenshot while hovering over the respective areas, but when I hover over them, I get more precise timestamps. Both of them start at 21:31:20, the first ends at 21:34:25, and the second ends at 23:34:45.

And this is what it looks like on the Raw Data page: image

2e3s commented 2 months ago

I have figured out the reason for this, and I've changed the logic to accommodate the timeout correctly. There is a downside for the most correct working for Wayland-protocol-based handlers: the non-idle time now looks lagging. The reason is that between you're AFK and timeout gets fired, there is a time period when the watcher may report incorrectly that you're not AFK which is wrong. Hence it reports only the last time where you were surely online which is now - timeout.

I will test and look at possible issues.

2e3s commented 2 months ago

Been a while, but I have seemingly fixed related issues and released https://github.com/2e3s/awatcher/releases/tag/v0.3.0