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

[WIP] Add help text on how to interact with message links. #1478

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Sushmey
Copy link
Collaborator

@Sushmey Sushmey commented Mar 28, 2024

What does this PR do, and why?

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

Visual changes

Screenshot 2024-03-28 at 11 38 11 PM

@zulipbot zulipbot added the size: M [Automatic label added by zulipbot] label Mar 28, 2024
@Sushmey Sushmey marked this pull request as draft March 29, 2024 18:11
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.

@Sushmey I left some preliminary feedback. Please let me know here or on czo if you have points that I've not answered.

Comment on lines 1070 to 1079
widgets.append(
urwid.AttrWrap(strip, None if index % 2 else "popup_contrast")
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This may be better moved into the loop:

  • updating the the loop index in the loop is confusing
  • do we want the category wrapped in popup_contrast?
  • maybe we could style the second column title differently to the category title?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes updating the loop index is confusing. Figured out a better way to get what I expected.

No we don't need to wrap the popup_contrast. I did it because I was trying to make it visually discernible, updated it to work without the wrap.

We can have a discussion about the style.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't necessarily need to think about a style in this first version, but at the time it struck me as an additional motivator for adjusting the loop.

@neiljp neiljp added the PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback label Apr 3, 2024
@Sushmey Sushmey force-pushed the clarify-message-link-interaction branch from e2d625f to 8916629 Compare April 6, 2024 11:02
@zulipbot zulipbot added size: XL [Automatic label added by zulipbot] and removed size: M [Automatic label added by zulipbot] labels Apr 6, 2024
@neiljp
Copy link
Collaborator

neiljp commented Apr 6, 2024

I believe I covered your questions so far in the stream or here.

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.

@Sushmey It'd be great to get the category headings infrastructure merged, so I left some more feedback on what you have here 👍

Please do reply if you have other issues with the typing.

[
"contents",
"column_widths",
"expected_instance",
Copy link
Collaborator

Choose a reason for hiding this comment

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

instance is rather vague - what does this function return?

I believe each part of the instance is essentially a row, which we don't mention in the docstring and maybe in the code that uses it, but could be a useful refactor?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed the parameter name to expected_widget_type to be more descriptive since the docstring also mentions that the function is returning list of widgets.

Re second part, are you saying each widget of the list is essentially a row and that the docstring needs a refactor? I feel the current docstring is good enough, it does return a list of widgets that is used to make the table.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Using widget is consistent with the current docstring and terms used 👍

The second point was my noting that the code might be more readable if we referred to the returned data as rows; widgets are any UI element, so are less specific.

"widget_with_str",
],
)
def test_make_table_with_categories(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Having this test is great, but it does focus on the urwid form of the output, so it may be worth adding a suffix to the test name to emphasize that, eg. __instances based on your naming elsewhere (which can be improved).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Adding an __instances suffix. Although I wonder if this implies there's a test that focuses on make_table_with_categories as a whole and not on some specific thing like instances.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree that it could suggest another test exists, but also means it won't conflict with another later ;) If there are multiple tests for a function, my preferred form now is to separate the function and the intention behind the test.

I suggested __instances since that's what you were checking in the test, and used in the expected part of the test case name, as per another comment - so let's sync them up if you think the updated expected parameter name is better :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'e used types everywhere instead of instance because it seems more intuitive than instances. So let's change it to __types in the function name also?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, that'd be good 👍

@neiljp neiljp added the area: UI General user interface update label Apr 14, 2024
@neiljp
Copy link
Collaborator

neiljp commented Apr 14, 2024

Should the linked issue be #1372, not #1002?

@Sushmey Sushmey force-pushed the clarify-message-link-interaction branch from 8916629 to 62008af Compare April 18, 2024 13:29
This is not a part of this PR. This is just to resolve issue zulip#1226.
@Sushmey Sushmey force-pushed the clarify-message-link-interaction branch 2 times, most recently from 5a41187 to fbad442 Compare April 18, 2024 23:23
@Sushmey Sushmey force-pushed the clarify-message-link-interaction branch from fbad442 to 09b5850 Compare April 25, 2024 17:47
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.

@Sushmey Glad to see you got the types sorted 👍 There seems to be a failing test? Maybe try check-branch locally, to see what commit is failing?

I replied to some previous comments and left a few more inline.

The PR could do with removing the exploratory parts, eg. commented out, and that would make it clearer what exactly is changing.

Comment on lines 217 to 219
widgets = self.pop_up_view.make_table_with_categories(contents, column_widths)
for index, widget in enumerate(widgets):
assert isinstance(widget, expected_widget_type[index])
Copy link
Collaborator

Choose a reason for hiding this comment

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

My only thought on rereading this would be to suggest zip, since it's clearer.

One caveat with zip is that it pauses at the shorter, but we should test that the length is the same in any case, since that would be a bigger issue.

Copy link
Collaborator Author

@Sushmey Sushmey Apr 27, 2024

Choose a reason for hiding this comment

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

zip is used to combine two iterables, right? Not sure how we can use that here.

Edit: Just realised what you meant.

assert len(widgets) == len(expected_widget_type)
for widget, expected_type in zip(widgets,expected_widget_type):
      assert isinstance(widget, expected_type)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep, I already saw you changed it in the code :)

@@ -1603,7 +1611,7 @@ def __init__(
full_raw_message_keys = "[{}]".format(
", ".join(map(str, display_keys_for_command("FULL_RAW_MESSAGE")))
)
msg_info = [
msg_info: PopUpViewTableContent = [
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know I mentioned this might be an option previously, but you should be able to skip this and therefore not need the isinstance assert further below.

Without the explicit typing, mypy will know it's a list, so accept that it's mutable (modifiable).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It doesn't work otherwise since PopUpViewTableContent also has types which doesn't support append so need an explicit assertion.
I can't not explicitly type it as PopUpViewTableContent since Mypy assumes it to be the type of the first data assigned to it.

Comment on lines 1053 to 1054
if isinstance(category, tuple) and isinstance(content, list):
content.append(category)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I didn't pick up on this before, but the isinstance check on the content allows mypy to treat the content as mutable. That allows the code you have to work, but also makes the use of Sequence pointless - the code here does not work unless it is specifically a list being passed in.

Is there a reason the other style of category heading cannot be added to the widgets here, rather than copied into the content?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for pointing it out. There was no reason to put it as content. Changed it and removed the condition too.

Sushmey added 5 commits April 27, 2024 16:34
Updating the function `make_table_with_categories`.

So that right aligned hint text can be appended to heading.
Amend `calculate_table_widths` to add case of category with help text.
@Sushmey Sushmey force-pushed the clarify-message-link-interaction branch from 09b5850 to 8ba5ad7 Compare April 27, 2024 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: UI General user interface update PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback size: XL [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants