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
Sets current narrow marker for empty narrows. #278
base: main
Are you sure you want to change the base?
Conversation
4efc9cc
to
67c0123
Compare
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.
@sumanthvrao I've left some preliminary thoughts, though this is mostly on coding style rather than the approach to fixing the problem - though I do see it works in practice, based on manual testing.
I know you mentioned this doesn't work for muted streams, but it also doesn't for other types of general empty narrows, including eg. PMs (select a user in the right-hand list, for example).
I'm wondering if these changes can be split into smaller parts (and commits) which can then be connected in a later commit?
You might find adding some tests would make it clearer to yourself (and to reviewers) what features you're adding, as you can eg. add a parameter and a test for that function with the parameter, often alone in one commit.
I'm thinking we should show a 'special message' (ie. message 'content') rather than an empty message with a header, if we go this route; what do you think? (also @amanagr and anyone else)
3574948
to
333ddf0
Compare
333ddf0
to
87835fb
Compare
a9a7398
to
3174de5
Compare
814eb2f
to
2b0b628
Compare
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.
This is quite a large PR and most is in one commit, which makes it difficult to understand in one go. I've left some comments, but with some refactoring and addition of the features in multiple commits it should be easier to understand.
d2a11ae
to
24ff1a8
Compare
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.
Thanks for doing the work on splitting this - it's a lot more readable post-splitting 👍 If you can place the refactoring before the features/fixes, and keep the test changes with each code change, that will make this even more easily reviewable - ie. make the 'story' clearer :)
Note that you can have multiple lines in the text after the commit title, so you can eg. discuss the what/why you changed in one paragraph, and then have a blank line before another sentence, if those things are not related (like that you included test changes).
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.
@sumanthvrao Returning to this PR I remember how complex & involved it is!
I've done some manual testing, which uncovered that s
or S
from a private dummy message goes to all messages, which seems unexpected!
I'm a little unsure of the (new?) last commit (Prevent narrows from being marked 'M'); it looks like addressing a symptom (forcing the count up), rather than the problem (not increasing it in the first place). I'm not precisely sure what triggers this case (the commit message isn't entirely obvious) - is this set_count
being called by Model.set_message_ids_as_read
? If so, can we just fix the problem at source, which is probably in MessageView.read_message
?
The commit flow looks pretty good, though I'm marginally wary of the 2nd commit being present before the parameters are added to create_msg_box_list
, though I think we can't actually trigger that in the code at that point, perhaps? Either way, it seems strange adding an invalid call to a function before the function is updated to allow the extra parameters. Do you see my concern?
zulipterminal/ui_tools/views.py
Outdated
@@ -87,6 +90,9 @@ def load_new_messages(self, anchor: int) -> None: | |||
else: | |||
last_message = None | |||
|
|||
# This for the dummy message | |||
if current_ids == set(): | |||
return |
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.
While the first part of this commit seems straightforward, I'm not sure this either solves anything major (I commented it out and couldn't easily trigger an exception) or is logically quite right?
The check here is after fetching messages, and we're just examining the current_ids
, which could be empty if the index hasn't records for any stream/topic/etc.
As such, if we do include this check, I think this should definitely use the same approach as the first part - check for a log and look at the top message id.
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 did try commenting it and it did not produce an exceptions. On the other hand, I seem to have forgotten why this was added in the first place. To be on the safe side, I followed the third approach here, mainly to rewrite the code similar to the first part - check for log; check for top message in the log; and check if it is a dummy message. Thanks for this 👍
return_value = create_msg_box_list(model, messages, focus_msg_id) | ||
return_value = create_msg_box_list(model, messages, focus_msg_id, | ||
stream_details=stream_details, | ||
pm_details=pm_details) | ||
assert len(return_value) == len_w_list |
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.
Are there any extra asserts here that would be suitable, given the change in the test? We could maybe check for calls to MessageBox
, which would test assumptions about the empty narrows?
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 did add another assert here to check the number of times MessageBox
is called. Further, tests have been added in previous commits specifically in test_main_view_generates_dummy_message
which tests for assumptions in empty narrow.
8d831c9
to
ca49966
Compare
@neiljp Thanks for patiently reviewing this again. I apologise for the delay. Here is a small CHANGELOG from the previous iteration:
Need clarification on :
|
@neiljp I rebased this and resolved the conflicts. Its now good for a review. :) |
Dummy messages are displayed in narrows with no previous messages. The action of HotKeys like 'r', 'c', 'z', 'quote', 'reactions' on dummy messages are different, as they don't have any defined 'context' (without a real message). Tests added.
This is necessary in boxes & buttons which act with the associated narrowing methods in core.py This addition is made use of in successive commit.
We send specific information through the function that makes accessing parameters more easier when building dummy message; Added parameters to create_msg_box function definition.
Handles 'Up' and 'Down' keys on dummy message; Otherwise it would raise an exception as there are neither old/new messages above/below the dummy message.
We use the passed parameters (recipient details, stream details) while building a dummy message with 'author' as Welcome Bot, 'topic' as the stream description. Tests added.
This commit handles the logic of replacing the dummy message when an incoming message, meant for the same narrow appears. * Ensure dummy message for stream and user PM is replaced when the first message in those respective narrows appear. * Ensure group PM messages do not replace dummy message in user PM narrow. * Ensure dummy message for self-message narrow is replaced. Tests added.
We mark new PMs which replace the dummy message as being 'unread'. This avoids marking 'All messages', 'All Private' and other PM narrows with 'M'.
Heads up @sumanthvrao, 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 |
This PR address setting labels in narrow's with no previous message. A dummy message is created for such narrows with Welcome-Bot as the author and a suitable content, This message gets discarded when the first message arrives. Further, it contains tests for the added features.
In streams with no previous messages.
In PM with no previous messages.
Fixes : #259, #266