Thursday, February 2, 2012

The Hunt for Unobtrusive Chat

Once apon a time, Instant messaging or 'Online Chat' was a primary task on it's own. That is, I remember the days when I would switch on my computer, sign in to 'MSN Messenger' (as it was called back then), have a voice conversation with my father (who was working in England at the time), and then be done with it. However, over the last few years, not only have we started to rely more on it, but it's also become more of a secondary (or even tertiary) task. For example, these days I keep in contact with the rest of the telepathy-kde (or is it kde-telepathy now, or just 'ktp' yet?) team on IRC while I'm developing; talk to my friends (with a steam voice call) while playing a game and so on.

The thing is that, things like that need to be able to be done simultaneously while still maintaining maximum efficiency. Which becomes painfully impossible when you have to switch windows, or the way most IM clients are implemented these days.

So, shortly before joining the Telepathy-KDE team, I set out to figure out what would allow me to talk to someone while doing my work with the minimum overhang (interruptions).

First off, switching windows:
If someone talks to me while I'm typing away at something, and the only way I can respond to them is using my mouse (which would involve moving my hands away from my keyboard, clicking on something and then moving back), I will eventually start slicing my wrists.
So, it has to be a global shortcut with a hotkey.
The best example I've seen of that is Kopete:
     Whenever I saw this Icon on my system tray, I would know someone has said something to me. I hit Ctrl + Shift + I and it would take me to the chat window of that person.

I press it again, and it goes to the next person that said something. I keep doing that till I've responded to everyone.

Now, that was brilliant at propagating a conversation and talking to many people at once. But it still had the problem that once I've responded to everyone, switching back to my work was a pain. Granted, I tried to keep my work in a different virtual desktop (and these days Plasma Activities might handle this reasonably well). But that just wasn't good enough for me as it meant I had to waste time managing all the chat windows and switching desktops.

Next Up: Out of the way
I don't like having a window open just to talk to one person, and having one window with tabs for multiple people is even worse (IMHO). A conversation needs to be easily visible, but not be the main focus of my screen - that should be whatever I'm working on at the time.
Best example of that I've seen is in Gmail: when I check my emails, I can have conversations with my Google Talk contacts at the bottom.

These things were brilliant as they meant my conversations were on-screen, but not hogging up the screen. The problem with them were that they were in the browser, and switching tabs or to another window meant they would go away and were very painful to find again.

So, it will have to sit in my panel, probably as a popup widget.

Right, with those two important points in mind, I set out actually creating a solution.
Here, you can see the (very) early (not quite ready for testing) test version of the plasmoid. Currently, it's implemented as a TelepathyTextObserver, which means that the standard text-ui has to be open for it to work, which makes it rather useless. I'll probably change that in the future, but I'm still waiting on a method to be implemented in Telepathy-Qt to allow for two text handlers to play nice with each other.
If that doesn't magically implemented by someone, I'll probably ship this as a handler meaning if the user has this in their desktop, then the standard text-ui won't show up at all ever.
My original idea was to have this only handle a specific set of contacts (i.e. everyone in your 'Favourites' group) and open the normal text-ui for the rest. This also gave me the idea of having single-user plasmoids, that will be there from the start and handle all message to/from that user, thus effectively allowing you to 'pin' a contact to your panel.

And as you can see in this screenshot, if there are unread messages in a conversation, a little bubble will appear telling how many (just like facebook). I couldn't find any plasma theme element that's in any way logical for it, so for now it's hardcoded red and white. If any plasma devs have any ideas, let me know.

Also, just like kopete, clicking Ctrl + Shift + J (I'll make it configurable when I figure out how) will pop up the next conversation with unread messages. And if you were already at the last one, they'll all go away, leaving you back to your work. 

The last part was that I wanted it to feel tightly 'integrated' so I tried to make it look like the task-manager applet. While it may look like I succeed (to a certain degree) in that screenshot, the moment you use it, you'll notice it behaves differently. As it turns out the task-manager widget is quite complex and not something I can easily reproduce in QML. I have to either wait for the plasma team to eventually port it to QML or make a C++ extension and steal their code. 

So, what do you guys think? 
PS: This is my first 'real' contribution to KDE, so please go easy on your (constructive) criticism. :-)