-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
Support 'Narrow to current compose box recipient'. #1194
Support 'Narrow to current compose box recipient'. #1194
Conversation
d4a0229
to
91e6939
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.
@srdeotarse This is a good start, thanks! 👍
This does appear to suffer from ctrl .
not working for me too, which may be an issue with terminals in general. I'd suggest meta .
(ie. alt .
) in the meantime, unless/until we can find out why it is failing.
There is an issue where exiting compose seems to trigger going to all messages which we need to resolve before this can be merged. This appears to only happen if the new action is triggered and then the compose is cancelled/closed (or sent and then cancelled/closed).
Tests would also be good if possible.
docs/hotkeys.md
Outdated
@@ -54,6 +54,7 @@ | |||
|Show/hide Emoji picker popup for current message|<kbd>:</kbd>| | |||
|Narrow to the stream of the current message|<kbd>s</kbd>| | |||
|Narrow to the topic of the current message|<kbd>S</kbd>| | |||
|Narrow to compose box message recipient.|<kbd>.</kbd>| |
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.
Good use of the script? :)
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.
Definitely, you just have to change the key in keys.py
and run the script to update hotkeys.md
instead of changing manually. Really helpful.
zulipterminal/helper.py
Outdated
"Message is sent outside of current narrow. Press 'Ctrl .' to narrow to message recipient. {}".format( | ||
NARROW_TO_MESSAGE_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.
We should programmatically fetch the key and substitute it in here.
I'm not sure about the use of the arrow here.
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.
You had mentioned an UI element being proposed in #design > button to go to conversation. Should that arrow like symbol appear in compose box when messaging outside current narrow?
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.
So, if we change the shortcut for narrowing to current message recipient, the key in the message should also change. Right?
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.
The arrow issue is now at #1203.
Hello @zulip/server-hotkeys members, this pull request was labeled with the "area: hotkeys" label, so you may want to check it out! |
91e6939
to
7689c1d
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.
@srdeotarse Thanks for the improved iteration, though it's still not quite performing right for me.
We've discussed this a little in the stream which should help with the next iteration.
You mentioned the hotkeys script; we don't lint for this and I'm not sure we have an issue for that, if you want to take that up. It would be useful in CI (and locally) to ensure that any changes are synchronized, and could be part of make fix
too.
tests/helper/test_helper.py
Outdated
"Message is sent outside of current narrow." | ||
"Message is sent outside of current narrow. Press {} to narrow to message recipient. {}".format( | ||
KEY_BINDINGS["NARROW_MESSAGE_RECIPIENT"]["keys"][0], | ||
NARROW_TO_MESSAGE_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.
As per discussion in the stream, let's skip the icon for now; I think it'd be a representation of the key somehow if we did, a little like we have [P]
.
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.
Again, this is now #1203
7689c1d
to
fbc1bb2
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.
@srdeotarse If we assume #1201 is reasonable, this PR seems functional 🎉
I've noted a few outstanding points, but otherwise this is close to merging.
We could add a test for the UI function, but the code is rather simple and UI code can be challenging to test and fragile.
zulipterminal/config/keys.py
Outdated
@@ -164,6 +164,11 @@ class KeyBinding(TypedDict, total=False): | |||
'help_text': 'Narrow to the topic of the current message', | |||
'key_category': 'msg_actions', | |||
}), | |||
('NARROW_MESSAGE_RECIPIENT', { | |||
'keys': ['meta .'], | |||
'help_text': 'Narrow to compose box message 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.
Note that other help_text doesn't end with a .
We may want to lint for this somewhere.
zulipterminal/helper.py
Outdated
key = primary_key_for_command("NARROW_MESSAGE_RECIPIENT") | ||
|
||
controller.report_success( | ||
f"Message is sent outside of current narrow. Press [{key}] to narrow to conversation." |
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.
If we keep this message this long, I'd welcome this being displayed a little longer (eg. the 6 we used in the other PR).
However, my remaining query here is whether we want to customize this logic/message a little further:
- in all-messages narrow, we never see this, but may still want to go to the conversation
- in stream (or all-PM) narrows which hold the message, we may also still want to go to the conversation
- if a message is outside the narrow, we always want to show this
To address these combinations we may want to split this messaging change out into a followup commit and/or PR, since the functionality itself will be present and consistent with the help menu and documentation already in the rest of this commit. This is an extra hint, and it'd be good to handle it well.
zulipterminal/ui_tools/boxes.py
Outdated
@@ -773,6 +773,27 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: | |||
if self.msg_edit_state is not None: | |||
self.keypress(size, primary_key_for_command("GO_BACK")) | |||
assert self.msg_edit_state is None | |||
elif is_command_key("NARROW_MESSAGE_RECIPIENT", key): | |||
if not self.to_write_box: |
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.
These branches would be more readable using compose_box_status
.
c7270f7
to
c6a0423
Compare
@zulipbot add "PR needs review". |
c6a0423
to
1ad6e3a
Compare
@srdeotarse Thanks for updating this 👍 I adjusted the other conditional to use compose_box_status and will be merging shortly. This is going to be very helpful day to day 🎉 |
These unrelated aspects being tied together was not an issue previously, when narrowing was always done outside of compose. However, with integration of zulip#1194 as 2195904 this is no longer the case, so this is required to ensure that narrowing does not prematurely end editor mode, since otherwise container widgets would steal keypresses. This may be improved later through further refactoring of the keypress handling.
These unrelated aspects being tied together was not an issue previously, when narrowing was always done outside of compose. However, with integration of #1194 as 2195904 this is no longer the case, so this is required to ensure that narrowing does not prematurely end editor mode, since otherwise container widgets would steal keypresses. This may be improved later through further refactoring of the keypress handling.
What does this PR do?
This PR adds support to 'Narrow to current compose box recipient' after sending a message outside current narrow.
Shortcut -
ctrl
+.
Fixes #1182
CZO - https://chat.zulip.org/#narrow/stream/206-zulip-terminal/topic/Support.20'Narrow.20to.20current.20compose.20box.20recipient'
Tested?
Commit flow
Notes & Questions
Currently I have used shortcut -
.
instead ofctrl
+.
asctrl
+.
doesn't seem to work in my local development environment (WSL2 Windows 10)Interactions
Visual changes