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

Add title-to-title scroll feature to Help Menu #1527

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Niloth-p
Copy link
Collaborator

@Niloth-p Niloth-p commented Jun 28, 2024

What does this PR do, and why?

Adds 2 new commands to refocus to view the previous/next help category section.

Hotkeys linting exclusion updated.
Hotkeys document regenerated.

Why?
This could be helpful when we have several help menu sections.

Outstanding aspect(s)

  • Would need to come up with a better way to display the navigation keys inside the Help Menu.
    This merely adds the functionality. The prompting for the user can be improved.
  • We could add an extra field to key bindings - something like exclude_from_help_menu to remove entries like these from being listed in the help menu. Currently, these are probably the only 2 commands that may need to be removed from the help menu, but with the addition of contexts, there may be more.
  • Does not add any tests

External discussion & connections

How did you test this?

  • Manually - Behavioral changes
  • Manually - Visual changes
  • Adapting existing automated tests
  • Adding automated tests for new behavior (or missing tests)
  • Existing automated tests should already cover this (only a refactor of tested code)

Self-review checklist for each commit

  • It is a minimal coherent idea
  • It has a commit summary following the documented style (title & body)
  • It has a commit summary describing the motivation and reasoning for the change
  • It individually passes linting and tests
  • It contains test additions for any new behavior
  • It flows clearly from a previous branch commit, and/or prepares for the next commit

@zulipbot zulipbot added the size: M [Automatic label added by zulipbot] label Jun 28, 2024
@Niloth-p Niloth-p added the further discussion required Discuss this on #zulip-terminal on chat.zulip.org label Jun 28, 2024
@Niloth-p Niloth-p added PR needs buddy review and removed further discussion required Discuss this on #zulip-terminal on chat.zulip.org labels Jul 6, 2024
Copy link
Member

@rsashank rsashank left a comment

Choose a reason for hiding this comment

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

LGTM! @Niloth-p 👍
Just requires a rebase to fix conflicts. The intention seems clear.

Add 2 new commands to refocus to view the previous/next help category
section.

Hotkeys linting exclusion updated.
Hotkeys document regenerated.
Copy link

@zormit zormit left a comment

Choose a reason for hiding this comment

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

Generally this seems to work fine. Also I personally like these two keys. So if we decide it's something to add (the Zulip thread doesn't have a definitive answer to that question yet), this could be the way to go.

I have left some comments, they are a bit more like "questions" than answers unfortunately, I'd be happy to help looking for answers. Gist is that I think the code can be iterated on a bit.

Also, did you consider writing tests? ("yes, but decided against them because it's too tricky" is a valid answer)

'GO_TO_PREVIOUS_TITLE': {
'keys': ['p'],
'help_text': 'Go to previous help category',
'key_category': 'navigation',
Copy link

Choose a reason for hiding this comment

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

I'm not sure whether navigation is a good category for this, but I don't see a better one either. The problem I see is that the two new commands are very specific to the "Help" popup while the other ones seem to be more generic. In that sense the new commands seem to be a bit similar to "Show/hide user information (from user list)": It could also be "Go to previous category (in Help Menu)" or something like that.

Copy link

Choose a reason for hiding this comment

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

I am also wondering whether it's useful to put hints towards those keys in the headline of the popup. It probably will get a bit crowded there.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For future reference, see the linked topic for some discussion. The keys aren't critical here, but my thoughts would be to use ones that

  • don't clash with existing more-global key use (like n & p; so don't need to remember context)
  • more easily translate to use more globally in the UI (reuse/memorization; can apply to other vertical sectioned lists)
  • have relative movement (like these, but not eg. numbered points to jump to)

Some options I raised were perhaps tab/shift-tab (depending on usage of that elsewhere), and various matching parentheses such as (/), or ], or }.

last_help_entry = len(self.log) - 1
if last_help_entry > last_visible_position:
for category_start_position in self.category_start_positions:
if category_start_position > focus_position:
Copy link

Choose a reason for hiding this comment

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

My LSP (I think) shows me a type error here. I think this file is not typed, so the CI passes on github. The error is:

Operator ">" not supported for types "int" and "Unknown | None"
Operator ">" not supported for types "int" and "None"

Which might be caused by the previous # type: ignore[misc]. I would be curious if there's a way to make mypy happy without the ignore.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For reference, I think this was caused by using a later version of Urwid here.

@@ -1261,6 +1261,33 @@ def __init__(self, controller: Any, title: str) -> None:

super().__init__(controller, widgets, "HELP", popup_width, title)
Copy link

Choose a reason for hiding this comment

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

It's mainly independent of this PR, but it seems a bit strange to me to have a super().__init__ call in the middle of a constructor. I would have expected it at the start of the constructor, but that doesn't seem to be a pattern in Zulip Terminal.

It seems that the general pattern is to have the super init at the end. But now that the setup code for category_start_positions relies on the parent to be initialized it lands in the middle.

Nevertheless I'd be curious if that's also something we can prevent, maybe by putting the responsibility for the category positions to the parent or something.

@Niloth-p Niloth-p added PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback and removed PR needs mentor review labels Jul 18, 2024
@neiljp
Copy link
Collaborator

neiljp commented Aug 20, 2024

@Niloth-p For some more direct feedback here, this looks to work OK, though I've not reviewed the code as there are other PRs underway!

Points to consider:

  • ?, n/p 'scrolls' quite cleanly (if abruptly, like J/K)
  • ?, jj, n leaves me half way into a category (navigation), needing kkkk to show the title?

Right now this works well separately from scrolling, but including that it gets confused - at least if the intention is to have a category title visible at the top? (on each title-to-title, except if the bottom is not 'aligned')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback size: M [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants