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
Add typing indicators for streams. #17040
Conversation
@showell I see this in the issue page.
Could you do a review and tell if I should open a thread for this in #backend |
zerver/lib/actions.py
Outdated
@@ -1888,20 +1888,27 @@ def do_send_typing_notification( | |||
realm: Realm, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to just have a separate action function for stream notifications, so that you don't need the optional parameters and the conditional logic. Two simple functions are better than one complex one, and we're not really sharing any useful logic here.
I would also consider just having a new type
(no pun intended) for the event with the value stream_typing
, so that the documentation piece is easier here (again, no Union types would be needed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, having a different type would make it simpler and separating the function will make it seem less complex. Will make the required changes.
(Thought I'd make the changes and ask for another review soon but not I'm getting a chance to work on this as most of my time is going into academics. Leaving an update since it's been 2weeks..:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think the separate function makes sense, with a bit of preparatory refactoring to avoid duplicating code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separated the function. There wasn't much duplicate code.
Also added type
stream_typing
.
Sorry for the delay. Haven't been getting time due to academics. Our teachers are tending to give more assignments as everything is online 😬 Made the changes based on reviews. I'll try to do the other work i.e adding frontend tests and documenting in the weekend. |
@@ -263,6 +264,7 @@ run_test("basics", () => { | |||
// test that we correctly detect if worker.get_recipient | |||
// and typing_status.state.current_recipient are the same | |||
|
|||
compose_state.get_message_type = () => "private"; | |||
compose_pm_pill.get_user_ids_string = () => "1,2,3"; | |||
typing_status.state.current_recipient = typing.get_recipient(); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't added/modified tests here as it's intended to test typing_status.js
to which this PR makes no changes. But we make use of this module to send start/stop requests from client which only extends the possible values for status.current_recipient
to also be an object consisting stream_id
and topic
. since we only check if current recipient is equal to previous recipient, adding tests to include recipient format of object:stream_id, topic
will be redundant and won't add much value I think.
Will add few tests to also include that format for current_recipient
if you think it's necessary.
Do we want to show "several people are typing..." only for streams or for PMs too if more than 3 users are typing? (The PR shows it for both) |
c3f0c47
to
6bb27dc
Compare
You can ignore the below. Was not much familiar with API docs and tests, and ended up generating a wrong curl example. Fixed and added examples for python too. Didn't add any js example for stream typing as this params.to.length in zulip-js causes an error because there's no How do I fix the API test failure? I'm unable to figure out a solution. Here's the issue: Tried adding this in zulip.yaml, but it still didn't work.
I think we should still have this. will push it once we figure out a fix for the failure. |
4905c9f
to
81094e9
Compare
zerver/openapi/python_examples.py
Outdated
@@ -1081,6 +1081,7 @@ def set_typing_status(client: Client) -> None: | |||
"to": [user_id1, user_id2], | |||
} | |||
result = client.set_typing_status(request) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this space(and below) intentionally to make it look good in API docs with each of start, stop separated as a different chunk.
8643f8c
to
7ed65fa
Compare
For the timing part of sending requests, it will be same as pms as the code in typing_status.js is being reused for that purpose. As a note, `state.current_recipient` and `new_recipient` of update() in typing_status.js used to be a string of recipients ids always previously but it can now be either of: 1) An object of format {stream_id: 2, topic:'hello'} 2) a string of recipient user ids like previously Also made required changes in typing_status.js and typing_status.js.flow i.e documenting the new format of new_recipient.
We used this function to show who's typing in private messages narrow. With addition of stream typists to `typist_dct` in next commit, this might be confusing. So, renamed it. This commit adresses the discussed issue by replacing get_all_typists() with get_all_pms_typists().
These existing typing related functions are re-usable in case of stream typing except that the key differs. So, to make it possible to re-use the code in these functions, this commit removes the `get_key` call in those functions and instead passes the key directly. Also, renamed `get_key` to `get_pms_key` to differentiate it from the `get_topic_key` we'll add later for stream typing.
Returns `stream_id` if narrowed to stream else `undefined`. Required for displaying stream typing notifications.
A write up as requested in #19200 (comment)
Sending start/stop notificationsThis primarily relies on
The only part that changes when we integrate stream typing notifications is, the But the insides of (All this is done in the first commit) Displaying typing... notifications for the receiverThe flow of this so far looks as follows:
The flow is the same for stream typing notifications too but now we want to store
|
Display/hide "X is typing" notification on receiving start/stop typing event for streams.
Filters muted users in get_stream_typists().
Heads up @chdinesh1089, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the |
@chdinesh1089 hi! I'd love to see typing indicators for streams and it seems like this PR of yours gets us there! Thanks! ❤️ I noticed a related topic in chat and asked about this PR there. It sounds like the next step is to rebase. I just thought I'd pass that along. Have a great weekend! 🏖️ |
In the event that @chdinesh1089 has no intention of working on it, I would be interested in taking over. Thank you!! |
@brijsiyag great! Locally I rebased
Here are the two places where I hope this helps either you or @chdinesh1089. ❤️ I haven't set up a dev environment yet, but maybe I can help with testing or something. 😅 Update (after setting up a dev environment): Here's how I resolved the conflicts above:
After committing I realized there were further conflicts in these files:
I'm not sure where the conflicts end, to be honest. |
Thanks for bumping this thread, @pdurbin! I haven't been getting much free time these days. I might delay this if I pick up again. I'd be super happy to see this feature merged soon so I'd appreciate if @brijsiyag or anyone would like to take this forward. 🙂 @pdurbin it's quite simple to setup development environment. see https://zulip.readthedocs.io/en/latest/development/overview.html |
@chdinesh1089 sure. Coming from Slack and Matrix, I'm interested in this feature. @brijsiyag are you interested in taking over? I do have a dev environment set up now (you're right, @chdinesh1089, not too bad to set up), but I'm having trouble resolving all the merge conflicts. I put a few additional details in my comment above. There are more conflicts than I realized. (I'm used to a merge workflow rather than a rebase workflow.) Also, the label "size: XL" makes me a bit nervous, as I haven't contributed before. |
Yes @pdurbin , I'm working on this. |
4ec3636
to
88b200c
Compare
Closing in favor of #26904, thanks for all the work on this @chdinesh1089! |
Fixes #11152
This is almost done. Things left to be done are
stream_id
andtopic
forapi/v1/typing
inzerver/openapi/zulip.yaml
.Sending a request to streams with 0 or 1 subscriber(only sender) won't throw any error. Do we want to return any error for that?