Skip to content
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

bugfix: Don't send and display typing updates from oneself. #1011

Closed
wants to merge 3 commits into from

Conversation

prah23
Copy link
Member

@prah23 prah23 commented Apr 26, 2021

First commit:

  • Typing events from oneself are currently handled and
    displayed on the footer. This commit adds an extra check in the
    typing event handler's conditional to verify that the sender
    isn't the logged in user themselves before displaying the update.
    Tests added.

Second commit:

  • Prior to this commit, typing updates were sent to all recipients of
    the current private message as specified in recipient_user_ids,
    which is an unnecesary expense for the server though minute.

  • This commit uses another list, typing_recipients, that stores all the
    recipient user_ids except for the user's own, that can be used to send
    typing updates. This list is initiated as a part of WriteBox for
    persistence to send start and stop updates.

@zulipbot zulipbot added the size: M [Automatic label added by zulipbot] label Apr 26, 2021
@neiljp
Copy link
Collaborator

neiljp commented Apr 26, 2021

@prah23 I can reproduce this issue - thanks for finding it and proposing a solution 👍

If I type in the webapp, then it does currently generate an event - shown in ZT on main - but doesn't show typing events in the webapp. So, this PR does fix this by blocking the final round-trip in such cases.

My concern is whether this solution is where the fix is ultimately important, or if it should be:

  • client-side for us (we check if sending into a particular conversation and block it) - it's a very minor network optimization anyhow!
  • server-side (the server blocks sender-id being one-person-sender PM narrows from triggering typing events)

Given the webapp doesn't show self-self typing notifications, I assume this is a minor bug in the server in a corner case, that should likely be fixed there, and we could skip sending such notifications in the first place instead of not acting on the events.

Even if the server doesn't change event handling and we adjust our sending, that would then leave the only case being "someone" typing in your account somewhere else triggering our event handling, which is then even more of a corner case. However, let's see what the server code looks like and if it's considered a bug there, for that case?

@prah23
Copy link
Member Author

prah23 commented Apr 28, 2021

Further context for anyone reading, this was discussed further at
#zulip-terminal > Typing status bugfix #T1011 and #backend > Send typing status when in narrow with oneself.

@zulipbot zulipbot added size: XL [Automatic label added by zulipbot] and removed size: M [Automatic label added by zulipbot] labels Apr 28, 2021
@prah23 prah23 force-pushed the typing_status_bugfix branch from d16633a to 021bb9a Compare April 28, 2021 18:10
@zulipbot zulipbot added size: L [Automatic label added by zulipbot] and removed size: XL [Automatic label added by zulipbot] labels Apr 28, 2021
@prah23 prah23 changed the title bugfix: model: Don't display typing updates from oneself. bugfix: Don't send and display typing updates from oneself. Apr 28, 2021
@prah23 prah23 force-pushed the typing_status_bugfix branch from 021bb9a to e5dfe97 Compare May 9, 2021 12:12
@prah23 prah23 force-pushed the typing_status_bugfix branch from e5dfe97 to fcbc20b Compare June 9, 2021 14:00
@prah23 prah23 added the PR needs review PR requires feedback to proceed label Jun 9, 2021
Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prah23 Just checking in on this small edge-case PR from a while back - it's well-structured and works fine, just a few queries before we merge 👍

# Updates server on PM typing events
# Is separate from recipient_user_ids because we
# don't include the user's own id in this list
self.typing_recipients: List[int] = []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice simple extra variable which works fine. My only thoughts are:

  • Maybe append _user_ids to indicate more clearly what's in it elsewhere
  • Should it be reset everywhere that recipient_user_ids is? It doesn't currently appear to be? (I know they have different uses, but it seems useful to be consistent)
  • If we're resetting/setting at similar times, should that be in a function, existing or otherwise? (maybe a refactor?)

@neiljp neiljp added PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback area: event handling How events from the server are responded to and removed PR needs review PR requires feedback to proceed labels Jul 4, 2021
prah23 added 3 commits July 5, 2021 02:00
Prior to this commit, typing events from oneself were handled and
displayed on the footer. This commit adds an extra check in the
typing event handler's conditional to verify that the sender
isn't the logged in user themselves before displaying the update.

Tests added.
Prior to this commit, typing updates were sent to all recipients of
the current private message as specified in `recipient_user_ids`,
which is an unnecesary expense for the server though minute.

This commit uses another list, `typing_recipient_user_ids`, that
stores all the `recipient user_ids` except for the user's own, that
can be used to send typing updates. This list is initiated as a part
of WriteBox for persistence to send start and stop updates.

Tests added.
This commit adds a helper method to synchronously set both types of
recipient user_ids stored in WriteBox instances, namely,
`recipient_user_id`s and `typing_recipient_user_ids`.
@prah23 prah23 force-pushed the typing_status_bugfix branch from fcbc20b to 78f42e6 Compare July 6, 2021 14:56
@prah23 prah23 added PR needs review PR requires feedback to proceed and removed PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback labels Jul 6, 2021
@neiljp
Copy link
Collaborator

neiljp commented Jul 16, 2021

@prah23 See my comment in the stream - I've also rebased this to resolve the minor conflict. This seems like an easy merge if my proposed changes look good to you 👍

@neiljp neiljp added PR ready to be merged PR has been reviewed & is ready to be merged area: UI General user interface update and removed PR needs review PR requires feedback to proceed labels Jul 16, 2021
@prah23
Copy link
Member Author

prah23 commented Jul 16, 2021

Thanks for resolving the conflict and extending the work @neiljp! The changes look good to me 👍. The method introduced here can be easily incorporated into #1057, and will help keep both types of user_ids in sync.

@neiljp
Copy link
Collaborator

neiljp commented Jul 17, 2021

@prah23 Thanks for getting back quickly so we can get this in - I merged as the commits prior to 733926d 🎉

@neiljp neiljp closed this Jul 17, 2021
@neiljp neiljp added this to the Next Release milestone Jul 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: event handling How events from the server are responded to area: UI General user interface update PR ready to be merged PR has been reviewed & is ready to be merged size: L [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants