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

Support 'Narrow to current compose box recipient'. #1194

Conversation

srdeotarse
Copy link
Collaborator

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?

  • Manually
  • Existing tests (adapted, if necessary)
  • New tests added (for any new behavior)
  • Passed linting & tests (each commit)

Commit flow

Notes & Questions

Currently I have used shortcut - . instead of ctrl+. as ctrl+. doesn't seem to work in my local development environment (WSL2 Windows 10)

Interactions

Visual changes

@srdeotarse srdeotarse force-pushed the issue-1182-support-Narrow-to-current-compose-box-recipient branch from d4a0229 to 91e6939 Compare April 10, 2022 16:27
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.

@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>|
Copy link
Collaborator

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? :)

Copy link
Collaborator Author

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.

Comment on lines 657 to 660
"Message is sent outside of current narrow. Press 'Ctrl .' to narrow to message recipient. {}".format(
NARROW_TO_MESSAGE_RECIPIENT,
)
Copy link
Collaborator

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.

Copy link
Collaborator Author

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?

Copy link
Collaborator Author

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?

Copy link
Collaborator

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.

zulipterminal/ui_tools/boxes.py Outdated Show resolved Hide resolved
@neiljp neiljp added area: hotkeys PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback labels Apr 11, 2022
@zulipbot
Copy link
Member

Hello @zulip/server-hotkeys members, this pull request was labeled with the "area: hotkeys" label, so you may want to check it out!

@srdeotarse srdeotarse force-pushed the issue-1182-support-Narrow-to-current-compose-box-recipient branch from 91e6939 to 7689c1d Compare April 11, 2022 10:06
@zulipbot zulipbot added size: M and removed size: S labels Apr 11, 2022
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.

@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.

zulipterminal/ui_tools/boxes.py Outdated Show resolved Hide resolved
zulipterminal/ui_tools/boxes.py Outdated Show resolved Hide resolved
zulipterminal/helper.py Outdated Show resolved Hide resolved
zulipterminal/helper.py Outdated Show resolved Hide resolved
zulipterminal/config/keys.py Outdated Show resolved Hide resolved
"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,
Copy link
Collaborator

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].

Copy link
Collaborator

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

@zulipbot zulipbot added PR needs review PR requires feedback to proceed and removed PR needs review PR requires feedback to proceed labels Apr 14, 2022
@srdeotarse srdeotarse force-pushed the issue-1182-support-Narrow-to-current-compose-box-recipient branch from 7689c1d to fbc1bb2 Compare April 15, 2022 18:18
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.

@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.

@@ -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.',
Copy link
Collaborator

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 Show resolved Hide resolved
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."
Copy link
Collaborator

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.

@@ -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:
Copy link
Collaborator

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.

@srdeotarse srdeotarse force-pushed the issue-1182-support-Narrow-to-current-compose-box-recipient branch 3 times, most recently from c7270f7 to c6a0423 Compare April 16, 2022 03:55
@srdeotarse
Copy link
Collaborator Author

@zulipbot add "PR needs review".

@zulipbot zulipbot added the PR needs review PR requires feedback to proceed label Apr 16, 2022
@neiljp neiljp force-pushed the issue-1182-support-Narrow-to-current-compose-box-recipient branch from c6a0423 to 1ad6e3a Compare April 17, 2022 02:17
@neiljp neiljp added PR soon to be merged PR has been reviewed & is ready to be merged and removed PR needs review PR requires feedback to proceed PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback labels Apr 17, 2022
@neiljp
Copy link
Collaborator

neiljp commented Apr 17, 2022

@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 🎉

@neiljp neiljp added this to the Next Release milestone Apr 17, 2022
@neiljp neiljp merged commit 2195904 into zulip:main Apr 17, 2022
srdeotarse added a commit to srdeotarse/zulip-terminal that referenced this pull request Apr 17, 2022
neiljp added a commit to neiljp/zulip-terminal that referenced this pull request Apr 18, 2022
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.
neiljp added a commit that referenced this pull request Apr 21, 2022
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: hotkeys PR soon to be merged PR has been reviewed & is ready to be merged size: M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support 'Narrow to current compose box recipient'
3 participants