Skip to content

Add support for 'starred' typeaheads#794

Merged
neiljp merged 5 commits intozulip:masterfrom
neiljp:2020-09-01-starred-typeaheads
Sep 20, 2020
Merged

Add support for 'starred' typeaheads#794
neiljp merged 5 commits intozulip:masterfrom
neiljp:2020-09-01-starred-typeaheads

Conversation

@neiljp
Copy link
Collaborator

@neiljp neiljp commented Sep 2, 2020

This allows multiple aspects which improve the typeahead experience:

  • editing of typeahead with stars (currently @us may generate @**user**, but backspacing to @**u doesn't autocomplete)
  • specification of @** for autocompleting only users
  • specification of @* for autocompleting only groups (fixing Improve group typeahead #732)

This doesn't resolve the same issue experienced in topic typeahead in the topic recipient box, namely that only full words can be autocompleted.

@neiljp neiljp added enhancement New feature or request PR needs review PR requires feedback to proceed labels Sep 2, 2020
@neiljp neiljp added this to the Next Release milestone Sep 2, 2020
@neiljp neiljp requested a review from kaustubh-nair September 2, 2020 01:39
@zulipbot zulipbot added size: XL [Automatic label added by zulipbot] further discussion required Discuss this on #zulip-terminal on chat.zulip.org labels Sep 2, 2020
@neiljp neiljp requested a review from preetmishra September 2, 2020 01:43
Copy link
Member

@preetmishra preetmishra left a comment

Choose a reason for hiding this comment

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

@neiljp Thanks for refactoring and extending the typeaheads. This would make fixing any typeahead typo easier. 👍

I pulled the changes locally and they seem to work well. However, I am not sure if we should support * for any other typeahead than group (as it is actually a form of the original syntax).

Copy link
Member

@kaustubh-nair kaustubh-nair left a comment

Choose a reason for hiding this comment

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

@neiljp This looks like a great addition 👍
I've gone through this and it looks good to me.

@@ -171,22 +171,28 @@ def generic_autocomplete(self, text: str, state: Optional[int]

# Look in a reverse order to find the last autocomplete prefix used in
# the text. For instance, if text='@#example', use '#' as the prefix.
Copy link
Member

Choose a reason for hiding this comment

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

Not related to this commit, but I think I should point out that the server does allow names to start with #.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a bug I suppose, but I'm not sure what we can do unless we disable # autocomplete entirely? Even the new @**#example wouldn't find this in this PR, as # is later. We could maybe prioritize the length over the position, but that could be problematic for other reasons. We could explore this with other test cases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kaustubh-nair I added a FIXME to the code here for now.

One option I just thought of might be to allow multiple different autocompletes - maybe #@market<ctrl f> could give the option for #@**marketing** but also #**@markets**, if both actually matched?

@neiljp
Copy link
Collaborator Author

neiljp commented Sep 2, 2020

Following discussion in #general>Typeahead prefixes, I plan to remove at least the single-star silent mention and possibly the stream single-star version - these should be easy enough to add back later, and even without these this seems a very useful addition to typeahead.

@neiljp neiljp force-pushed the 2020-09-01-starred-typeaheads branch from 3c70149 to 1512017 Compare September 6, 2020 01:30
@neiljp
Copy link
Collaborator Author

neiljp commented Sep 6, 2020

As per discussion, I've just updated this, and I think it's ready for merging 👍

@aero31aero This summarizes the ZT position, which I think is essentially as I proposed and we (almost) agreed! Let's discuss further if we want to bring the different front ends together in this or a similar way.

The clarified main outcome, other than the refactors, is for autocomplete to work subsequent times after backspacing previously autocompleted text, ie. from #**stream, @_**user, @**user and @*group. This adds to the previous cases of autocompleting from #stream, @_user, @user and @group. Other than improved UI, this also fixes #732 since @*group or @* filters and shows only groups; a similar effect applies to users.

As it stands, this specifically now leaves single-star completion absent, except for groups. So, we cannot do #*stream to autocomplete to #**stream**, instead requiring #stream or #**stream. This seems reasonable, and to some extent guides users as to the correct markdown syntax.

Copy link
Member

@preetmishra preetmishra left a comment

Choose a reason for hiding this comment

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

@neiljp Thanks for the further amendments. 👍

This would add on to the user experience and make editing typeheads easier. Moreover, the consensus that we have reached on would hopefully promote the valid syntax.

This seems to works great locally. I have left two in-line comments.

if not found_prefix_indices:
return text

# Use latest longest matching prefix (so @_ beats @ and #* beats #)
Copy link
Member

Choose a reason for hiding this comment

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

[minor] Is this supposed to be '#** beats #'?

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 removed this later text, as it's added in a later commit now.

write_box.view.set_typeahead_footer.assert_not_called()

@pytest.mark.parametrize('text, state, footer_text', [
# no-text mentions
Copy link
Member

@preetmishra preetmishra Sep 15, 2020

Choose a reason for hiding this comment

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

[minor] The commit title says that * is added for non-silent mentions for groups & users. However, ** is being added for users as well.

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've clarified this text 👍

@neiljp neiljp force-pushed the 2020-09-01-starred-typeaheads branch from 1512017 to 4cb9cee Compare September 16, 2020 19:32
This generalizes the previous approach using `rfind`, to avoid the
special case for silent mentions.

Added note regarding limitation due to overlap between allowed
characters in streams and mentions.
This retains the existing @ format for autocompleting groups and users,
while adding the `@**` and `@*` prefixes to allow specifically
autocompleting only users and groups respectively.

Tests added.

Fixes zulip#732 (with the group autocomplete).
@neiljp
Copy link
Collaborator Author

neiljp commented Sep 16, 2020

Thanks for the feedback so far everyone - I've addressed the concerns I'm aware of, and opened #796 for the issue @kaustubh-nair raised.

Copy link
Member

@preetmishra preetmishra left a comment

Choose a reason for hiding this comment

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

@neiljp Thanks for further fine-tuning the commits and logging the related issue. This seems to work well and with my previous concerns resolved, I believe this is ready to be merged. 👍

@neiljp neiljp merged commit e3b47bb into zulip:master Sep 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request further discussion required Discuss this on #zulip-terminal on chat.zulip.org PR needs review PR requires feedback to proceed size: XL [Automatic label added by zulipbot]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants