After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 650196 - Message tray should send typing notifications
Message tray should send typing notifications
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: message-tray
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2011-05-14 18:21 UTC by Jonny Lamb
Modified: 2011-08-04 01:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
telepathyClient: send typing notifications (3.58 KB, patch)
2011-05-15 00:11 UTC, Jonny Lamb
reviewed Details | Review
telepathyClient: send typing notifications (3.61 KB, patch)
2011-05-18 07:54 UTC, Jonny Lamb
reviewed Details | Review
telepathyClient: send typing notifications (3.52 KB, patch)
2011-07-07 13:24 UTC, Alban Crequy
reviewed Details | Review
telepathyClient: send typing notifications (3.92 KB, patch)
2011-07-07 15:06 UTC, Alban Crequy
none Details | Review
telepathyClient: send typing notifications (4.19 KB, patch)
2011-07-07 15:38 UTC, Alban Crequy
accepted-commit_now Details | Review

Description Jonny Lamb 2011-05-14 18:21:57 UTC
I'm not sure how to show typing notifications, if at all, but it should at least send them.
Comment 1 Jonny Lamb 2011-05-15 00:11:45 UTC
Created attachment 187830 [details] [review]
telepathyClient: send typing notifications

Here's a patch.

Author: Jonny Lamb <jonnylamb@gnome.org>
Date:   Sun May 15 01:07:44 2011 +0100

    telepathyClient: send typing notifications

    If we're typing we want to send composing. If we empty the entry we
    want to send active. If we're typing but don't type any more for
    COMPOSING_STOP_TIMEOUT seconds, we want to send paused. Simple.

    This behaviour was stolen from Empathy where it has won many awards.

    Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
Comment 2 Jasper St. Pierre (not reading bugmail) 2011-05-18 02:00:43 UTC
Review of attachment 187830 [details] [review]:

Nice.

We should probably be displaying any state changes from our contact, but this helps us play nice with others first.

::: js/ui/telepathyClient.js
@@ +396,3 @@
         this._history = [];
         this._timestampTimeoutId = 0;
+

No blank line

@@ +566,3 @@
+        let text = this._responseEntry.get_text();
+
+        // If we're typing we want to send composing. If we empty the

This comment was extremely confusing for me... probably because it's late. It might read better:

  // If we're typing, we want to send COMPOSING.
  // If we empty the entry, we want to send ACTIVE.
  // If we've stopped typing for COMPOSING_STOP_TIMEOUT
  //    seconds, we want to send PAUSED.
  // Simple.

@@ +577,3 @@
+                this._composingTimeoutId = 0;
+            } else {
+                this.source.setChatState(Tp.ChannelChatState.COMPOSING);

Why are we only COMPOSING if we don't have a timeout?
Comment 3 Jasper St. Pierre (not reading bugmail) 2011-05-18 02:00:46 UTC
Review of attachment 187830 [details] [review]:

Nice.

We should probably be displaying any state changes from our contact, but this helps us play nice with others first.

::: js/ui/telepathyClient.js
@@ +396,3 @@
         this._history = [];
         this._timestampTimeoutId = 0;
+

No blank line

@@ +566,3 @@
+        let text = this._responseEntry.get_text();
+
+        // If we're typing we want to send composing. If we empty the

This comment was extremely confusing for me... probably because it's late. It might read better:

  // If we're typing, we want to send COMPOSING.
  // If we empty the entry, we want to send ACTIVE.
  // If we've stopped typing for COMPOSING_STOP_TIMEOUT
  //    seconds, we want to send PAUSED.
  // Simple.

@@ +577,3 @@
+                this._composingTimeoutId = 0;
+            } else {
+                this.source.setChatState(Tp.ChannelChatState.COMPOSING);

Why are we only COMPOSING if we don't have a timeout?
Comment 4 Jonny Lamb 2011-05-18 07:54:09 UTC
Created attachment 188016 [details] [review]
telepathyClient: send typing notifications

(In reply to comment #3)
> We should probably be displaying any state changes from our contact, but this
> helps us play nice with others first.

Yeah, I didn't know how this should be displayed, so I just left it for now.

> No blank line

Done.

> This comment was extremely confusing for me... probably because it's late. It
> might read better:
> 
>   // If we're typing, we want to send COMPOSING.
>   // If we empty the entry, we want to send ACTIVE.
>   // If we've stopped typing for COMPOSING_STOP_TIMEOUT
>   //    seconds, we want to send PAUSED.
>   // Simple.

OK, done.

> Why are we only COMPOSING if we don't have a timeout?

If we have a timeout it means we have already sent COMPOSING. We don't want to send COMPOSING every time you type a letter into the entry.
Comment 5 Jasper St. Pierre (not reading bugmail) 2011-05-18 19:02:58 UTC
Review of attachment 188016 [details] [review]:

::: js/ui/telepathyClient.js
@@ +577,3 @@
+            } else {
+                this.source.setChatState(Tp.ChannelChatState.COMPOSING);
+            }

> If we have a timeout it means we have already sent COMPOSING. We don't want to
> send COMPOSING every time you type a letter into the entry.

OK, that makes perfect sense, but I'm still finding the code confusing... I didn't catch that we only have an active timeout if we're already in COMPOSING... additionally, piggybacking onto the "if" statement that clears the timeout didn't help.

So, how about we make it explicit: "this._chatState" that gets set in setChatState, and you only make the call out to Tp if it's changed. (Is there a condition where Tp changes it behind our back?)

You remove the timeout unconditionally, and do:

  // Any time the entry has changed, we need to re-evaluate our timeout.
  if (this._composingTimeoutId > 0) {
     ...
  }

  // If we're typing, we want to ...

  if (text != '') {
      this.source.setChatState(Tp.ChannelChatState.COMPOSING);
      this._composingTimeoutId = Mainloop.timeout_add_seconds( ... );
  } else {
      this.source.setChatState(Tp.ChannelChatState.ACTIVE);
  }
Comment 6 Alban Crequy 2011-07-07 13:24:48 UTC
Created attachment 191447 [details] [review]
telepathyClient: send typing notifications

(In reply to comment #5)
> So, how about we make it explicit: "this._chatState" that gets set in
> setChatState, and you only make the call out to Tp if it's changed. (Is there a
> condition where Tp changes it behind our back?)

Empathy could changes it behind gnome-shell's back if the user types both in the gnome-shell's message tray and in the Empathy conversation window. But I don't think it worth fixing typing notifications in this weird use case.

The attached patch refreshes Jonny's patch and updates it with your review in Comment #5.
Comment 7 Jasper St. Pierre (not reading bugmail) 2011-07-07 14:48:33 UTC
Review of attachment 191447 [details] [review]:

::: js/ui/telepathyClient.js
@@ +413,3 @@
+    setChatState: function(state) {
+        if (state != this._chat_state) {
+          this._chat_state = state;

this._chatState

All JS code gets "camelCase"

Additionally, you never seem to initally set it in _init. You should do that.
Comment 8 Alban Crequy 2011-07-07 15:06:20 UTC
Created attachment 191468 [details] [review]
telepathyClient: send typing notifications

(In reply to comment #7)
> Review of attachment 191447 [details] [review]:
> 
> ::: js/ui/telepathyClient.js
> @@ +413,3 @@
> +    setChatState: function(state) {
> +        if (state != this._chat_state) {
> +          this._chat_state = state;
> 
> this._chatState
> 
> All JS code gets "camelCase"

Fixed.

> Additionally, you never seem to initially set it in _init. You should do that.

It is initialized actually:
+        this._composingTimeoutId = 0;
+        this._chatState = Tp.ChannelChatState.ACTIVE;

I also added a comment in setChatState() about the possibility of Empathy changing the chat state behind our back, as you suggested on IRC.
Comment 9 Alban Crequy 2011-07-07 15:38:34 UTC
Created attachment 191472 [details] [review]
telepathyClient: send typing notifications

Update patch: initialize _chatState in ChatSource._init
Comment 10 Jasper St. Pierre (not reading bugmail) 2011-08-03 19:16:59 UTC
Review of attachment 191472 [details] [review]:

LGTM.
Comment 11 Jasper St. Pierre (not reading bugmail) 2011-08-04 01:49:12 UTC
Looks like this was already pushed. Oh well.