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

autocomplete: Introduce topic input autocomplete #627

Merged
merged 5 commits into from
Aug 13, 2024

Conversation

Khader-1
Copy link
Collaborator

@Khader-1 Khader-1 commented Apr 23, 2024

Fixes: #310

Simulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-07-11.at.10.38.47.mp4

Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

Thanks @Khader-1! Generally this strategy looks good, modulo the comment already made in the chat thread. A few other high-level comments below.

lib/model/stream_topics.dart Outdated Show resolved Hide resolved
lib/widgets/compose_box.dart Outdated Show resolved Hide resolved
lib/model/stream_topics.dart Outdated Show resolved Hide resolved
lib/api/route/streams.dart Outdated Show resolved Hide resolved
@Khader-1 Khader-1 force-pushed the compose-topic_autocomplete branch 2 times, most recently from 9b465c3 to f0b4a3c Compare April 30, 2024 10:15
@Khader-1 Khader-1 requested a review from gnprice April 30, 2024 10:19
Copy link
Collaborator Author

@Khader-1 Khader-1 left a comment

Choose a reason for hiding this comment

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

Thanks @gnprice! I have made some changes. Yet this still needs some tests. Some comments about things I am not so sure about are below. Any other notes or suggestions are welcome.

lib/widgets/compose_box.dart Outdated Show resolved Hide resolved
lib/widgets/compose_box.dart Outdated Show resolved Hide resolved
lib/model/autocomplete.dart Outdated Show resolved Hide resolved
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

Cool, thanks for the revision. Some high-level comments below, but broadly the strategy looks good — I think the main next step is to write tests for this, and to otherwise get it into shape for a non-draft PR.

One theme I notice in several places is that there's code that looks to have been copy-pasted from some similar existing code, but that hasn't been fully edited to reflect the differences. This occurs particularly in comments. I figure that's part of the draft state of this PR — but as part of revising this into non-draft status, please do read through your changes again to look for anything that doesn't fit what's happening around it, particularly comments, and update those.

Similarly, there are several places with excess indentation, double blank lines, or other formatting nits; so please give the code a reread looking for those.

lib/model/autocomplete.dart Outdated Show resolved Hide resolved
lib/model/autocomplete.dart Outdated Show resolved Hide resolved
lib/model/autocomplete.dart Outdated Show resolved Hide resolved
lib/model/autocomplete.dart Outdated Show resolved Hide resolved
lib/model/autocomplete.dart Outdated Show resolved Hide resolved
lib/widgets/compose_box.dart Outdated Show resolved Hide resolved
lib/widgets/compose_box.dart Outdated Show resolved Hide resolved
lib/widgets/compose_box.dart Outdated Show resolved Hide resolved
lib/widgets/compose_box.dart Outdated Show resolved Hide resolved
@Khader-1 Khader-1 force-pushed the compose-topic_autocomplete branch 3 times, most recently from fa64db7 to b6c64d4 Compare May 27, 2024 17:22
@Khader-1 Khader-1 changed the title wip: Introduce Topic Autocomplete autocomplete: Introduce topic input autocomplete May 27, 2024
@Khader-1 Khader-1 marked this pull request as ready for review May 27, 2024 17:27
@Khader-1 Khader-1 added the buddy review GSoC buddy review needed. label May 28, 2024
@Khader-1 Khader-1 requested a review from sm-sayedi May 28, 2024 09:21
@Khader-1 Khader-1 force-pushed the compose-topic_autocomplete branch 2 times, most recently from 964eb9f to e3d5933 Compare May 29, 2024 21:56
Copy link
Collaborator

@sm-sayedi sm-sayedi left a comment

Choose a reason for hiding this comment

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

Thank you @Khader-1 for all the work on this. The generic approach seems promising. Added a few comments, mostly small. And, it would be better to see this PR rebased on the main for the next revision as some changes happened in MentionAutocompleteView in #693 being merged.

Also, the following commits fail the tests (need to pass):

  • e955ef9: autocomplete [nfc]: Remove unused narrow in MentionAutocompleteView
  • 3f55c7b: autocomplete[nfc]: Use generic fields in AutocompleteViewManager

lib/model/autocomplete.dart Outdated Show resolved Hide resolved
lib/model/autocomplete.dart Outdated Show resolved Hide resolved
lib/model/autocomplete.dart Outdated Show resolved Hide resolved
lib/model/autocomplete.dart Show resolved Hide resolved
test/model/autocomplete_test.dart Outdated Show resolved Hide resolved
lib/widgets/autocomplete.dart Outdated Show resolved Hide resolved
lib/widgets/autocomplete.dart Outdated Show resolved Hide resolved
lib/widgets/compose_box.dart Outdated Show resolved Hide resolved
lib/widgets/compose_box.dart Outdated Show resolved Hide resolved
lib/widgets/compose_box.dart Outdated Show resolved Hide resolved
@Khader-1 Khader-1 force-pushed the compose-topic_autocomplete branch 2 times, most recently from 4a34f33 to bb33514 Compare June 30, 2024 10:10
@Khader-1
Copy link
Collaborator Author

Thanks @sm-sayedi! you're comments are really helpful!
I've pushed a new revision PTAL and please refer to this discussion regarding naming (streams / topics).

Copy link
Collaborator

@sm-sayedi sm-sayedi left a comment

Choose a reason for hiding this comment

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

Thanks for the revision. Two comments below.

lib/model/autocomplete.dart Outdated Show resolved Hide resolved
lib/model/autocomplete.dart Outdated Show resolved Hide resolved
@Khader-1 Khader-1 force-pushed the compose-topic_autocomplete branch from a33ea7b to dfcf5af Compare July 1, 2024 12:27
@Khader-1
Copy link
Collaborator Author

Khader-1 commented Jul 1, 2024

Thanks @sm-sayedi! I've pushed a new revision PTAL.

@Khader-1 Khader-1 requested a review from sm-sayedi July 1, 2024 12:55
Copy link
Collaborator

@sm-sayedi sm-sayedi left a comment

Choose a reason for hiding this comment

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

Thanks @Khader-1 for all the work on this. LGTM.

Let's move on to the mentor review with @kenclary!

@sm-sayedi sm-sayedi added mentor review GSoC mentor review needed. and removed buddy review GSoC buddy review needed. labels Jul 1, 2024
@sm-sayedi sm-sayedi requested a review from kenclary July 1, 2024 13:16
Copy link
Collaborator

@kenclary kenclary left a comment

Choose a reason for hiding this comment

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

good stuff

@Khader-1 Khader-1 requested a review from chrisbobbe July 26, 2024 07:16
@chrisbobbe
Copy link
Collaborator

chrisbobbe commented Jul 26, 2024

Thanks! Looks like there's a conflict from the just-merged #805. I think you can resolve by skipping this commit:

autocomplete test [nfc]: Refactor widget setup in `setupToComposeInput`

and using TestZulipApp instead of ZulipApp in test/widgets/autocomplete_test.dart in the main commit.

Separately, if you get some test failures about TextDirection.ltr and TextDirection.rtl, run flutter run and rerun the tests, and they should succeed. (There's an autogenerated file that should get updated; let me know if that doesn't work.) Discussion: #805 (comment)

@Khader-1
Copy link
Collaborator Author

Thanks @chrisbobbe! I've resolved with a new revision. PTAL

@chrisbobbe
Copy link
Collaborator

Thanks! Marking as ready for Greg's review.

@chrisbobbe chrisbobbe added integration review Added by maintainers when PR may be ready for integration and removed maintainer review PR ready for review by Zulip maintainers labels Jul 29, 2024
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

Thanks @Khader-1, and thanks @sm-sayedi and @chrisbobbe for the previous reviews!

For this round, I've read the first two commits:
c6d3ae1 autocomplete [nfc]: Rename Autocomplete to ComposeContentAutocomplete
28c2694 autocomplete [nfc]: Factor out generic AutocompleteView

Comments on those below. I think some of the comments are likely to apply also to the third commit:
b2f9e5c autocomplete [nfc]: Factor out generic AutocompleteField

so please try to revise that as well where these comments relate to it.

lib/model/autocomplete.dart Outdated Show resolved Hide resolved
lib/model/autocomplete.dart Outdated Show resolved Hide resolved
lib/model/autocomplete.dart Outdated Show resolved Hide resolved
lib/model/autocomplete.dart Outdated Show resolved Hide resolved
lib/model/autocomplete.dart Outdated Show resolved Hide resolved
lib/model/autocomplete.dart Outdated Show resolved Hide resolved
test/model/autocomplete_checks.dart Outdated Show resolved Hide resolved
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

Thanks for the revision! Comments below.

For this round, I've read through these three commits:
265ad97 autocomplete [nfc]: Rename Autocomplete to ComposeContentAutocomplete
7d9cc85 autocomplete [nfc]: Factor out generic AutocompleteView
beaf4e2 autocomplete: Setup stream topics API binding

and part of these two:
7c24173 autocomplete [nfc]: Factor out generic AutocompleteField
b34f5c4 autocomplete: Implement targeted topic autocomplete

I think those latter two will be easier to read after acting on a couple of my comments below.

lib/model/autocomplete.dart Show resolved Hide resolved
lib/widgets/autocomplete.dart Outdated Show resolved Hide resolved
lib/widgets/autocomplete.dart Outdated Show resolved Hide resolved
lib/api/route/streams.dart Outdated Show resolved Hide resolved
lib/api/route/streams.dart Outdated Show resolved Hide resolved
lib/model/autocomplete.dart Outdated Show resolved Hide resolved
lib/model/autocomplete.dart Outdated Show resolved Hide resolved
lib/model/autocomplete.dart Outdated Show resolved Hide resolved
lib/model/autocomplete.dart Outdated Show resolved Hide resolved
lib/model/autocomplete.dart Outdated Show resolved Hide resolved
@Khader-1
Copy link
Collaborator Author

Khader-1 commented Aug 7, 2024

Thanks @gnprice! I've pushed a new revision PTAL.

Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

Thanks for the revision! Comments below. In this round I got through the whole PR.

lib/widgets/autocomplete.dart Outdated Show resolved Hide resolved
lib/widgets/autocomplete.dart Outdated Show resolved Hide resolved
lib/widgets/autocomplete.dart Outdated Show resolved Hide resolved
lib/api/route/channels.dart Outdated Show resolved Hide resolved
lib/model/autocomplete.dart Outdated Show resolved Hide resolved
lib/widgets/autocomplete.dart Outdated Show resolved Hide resolved
lib/widgets/autocomplete.dart Show resolved Hide resolved
lib/widgets/autocomplete.dart Outdated Show resolved Hide resolved
lib/widgets/autocomplete.dart Outdated Show resolved Hide resolved
lib/widgets/autocomplete.dart Outdated Show resolved Hide resolved
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

Thanks for the revision! This is quite close now. Just small comments below, and a couple of subthreads remain open from above — #627 (comment) as noted below, and #627 (comment) where I replied above.

import 'package:json_annotation/json_annotation.dart';

import '../core.dart';
part 'channels.g.dart';
Copy link
Member

Choose a reason for hiding this comment

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

Cool, this is a lot closer:

api: Set up stream topics API binding

Let's specifically match previous commits that added new endpoint bindings, though. Here's a command that shows those (as well as a few other matches):
$ git log --oneline lib/api/route | grep -vw nfc

So in particular
6d9f22d api: Add markAllAsRead, markStreamAsRead, and markTopicAsRead routes
dfcc6ca api: Add updateMessageFlags and updateMessageFlagsForNarrow routes
b8290cd api: Add routes registerFcmToken, registerApnsToken

For this, let's then say "api: Add route getStreamTopics".

lib/widgets/autocomplete.dart Outdated Show resolved Hide resolved
}

@override
Iterable<String> getSortedItemsToTest(TopicAutocompleteQuery query) => _topics;
Copy link
Member

Choose a reason for hiding this comment

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

(I think you already know this is still open, but bumping just so this remains visible in the new review)

lib/widgets/autocomplete.dart Show resolved Hide resolved
@Khader-1
Copy link
Collaborator Author

Thanks @gnprice! I've pushed a new revision PTAL.

@Khader-1 Khader-1 force-pushed the compose-topic_autocomplete branch 2 times, most recently from 93457aa to b3f111e Compare August 12, 2024 18:01
The name Autocomplete is too generic and it collides with flutter's
material Autocomplete widget name.

So this uses the more specific name 'ComposeContentAutocomplete'.
The mechanism of query and results is generic to the idea of
autocomplete in general, it's not specific to autocomplete on
@-mentions vs. topics vs. anything else.
Most of the logic in `ComposeAutocomplete` is not specific to the
content input it self rather it is general logic that applies to
any autocomplete field.
The filtering logic (in [TopicAutocompleteQuery.testTopic])
differs from zulip-mobile but agrees with web.  Details at:
  zulip#627 (comment)

Fixes: zulip#310
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

Thanks for the revision! Everything looks good now, with a couple of nits below; I'll fix those and merge.

I also tweaked the main commit's summary line:

-    autocomplete: Implement targeted topic autocomplete
+    autocomplete: Add autocomplete for topic to send to

because "targeted" sounded to me like it was a kind of autocomplete that was somehow "targeted". I think what you intended was instead that the topic was "targeted", as in being the topic the draft message is aimed toward, so reworded to hopefully make that clearer.

}

@override
Iterable<String> getSortedItemsToTest(TopicAutocompleteQuery query) => _topics;
Copy link
Member

Choose a reason for hiding this comment

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

Cool. Verifying the existing server's behavior isn't enough in itself, because that doesn't guarantee the server won't change behavior later… but that thread now also has Tim's agreement that we intend that as part of the API, and an intention to write it down in the docs. So that means we can rely on it for the future too.

TopicAutocompleteQuery(super.raw);

bool testTopic(String topic) {
return topic != raw && topic.toLowerCase().contains(raw.toLowerCase());
Copy link
Member

Choose a reason for hiding this comment

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

bump on one part of #627 (comment) : adding a TODO(#881) comment

Copy link
Member

Choose a reason for hiding this comment

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

Also I added a few words to the commit message saying we picked web's behavior over zulip-mobile's, and linking to this subthread.

@gnprice gnprice merged commit 046ceab into zulip:main Aug 13, 2024
@Khader-1 Khader-1 deleted the compose-topic_autocomplete branch August 13, 2024 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration review Added by maintainers when PR may be ready for integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autocomplete for topic to send to
6 participants