I think the usefulness of this would depend in part on how it would function with a multi-screen setup. If the tutor is active in another chat/window/app while the chat remains open on a different screen, then the message should not be shown as 'read' (because, in fact, the tutor hasn't read it – they're busy in another window). I mention this because of the observed behaviour of the alerts/notifications – they seem to consider the chat as active even when the tutor is not active in that chat. (And from the student's perspective, it would be better not to know if the message has been seen/read than to see it as 'read' and not receive a response.)
Usually, it's based on the window/tab which has the focus: if the LL window has the focus when the message arrives, it's considered as read, even if the user is looking away (same thing happens on WhatsApp, etc.).
What is considered 'focus' on a two-screen setup? As I describe in my recent comment on #100 , if I'm 'active' in another window but LL is in the foreground on the other screen, I didn't get an alert. Possibly this is because the LL tab was still 'in focus', even though I was active in a different window/screen? (I'd think the focus would be whichever window/screen I'm actively in, but maybe that's not the case?)
Focus = window where you clicked or typed for the last time. Typically, if you scroll down in a window, it means this window/tab has the focus (otherwise, you can't interact with it).
So, yes, if you're active in a window (click, scroll, type), this window has the focus.
Two windows can't be in focus simultaneously (unless on 2 different computers ;-)). And I don't think there is any other mechanism here than focus, so it's strange that you do not get a notification when active on another window.
Thanks for the clarification. It is quite strange indeed. Is it possible that the 'focus' could be per screen? So two windows could both have focus, one on each screen?
"Active" is sometime a bit strange. Indeed, on most computers (but still depends on the exact configuration) you should be able to continue to write in a window while scrolling in another. It's why there is multiple functions and ways to determine if a window is "active" or not. For now, we use document.hidden, which means that the tab should be completely hidden for a sound to be emitted. We could switch to document.hasFocus(), as described in this SO answer.
@bridubois , I think you've hit the nail on the head. Let us know if you make that change (to .hasFocus() ), and I'll test it in our next session.
The only thing that it doesn't quite address is the 'first' alert. Currently, no alerts are made until the first time the user returns to the tab/window. So when the tab is 'hidden', I don't get an alert until I go back to the tab, at which time I hear the alert. After that first time, when I 'hide' the tab again, I hear the alerts as expected.