Skip to content

general chat #1: add support at most places #1297

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

Merged
merged 6 commits into from
Mar 10, 2025
Merged

Conversation

PIG208
Copy link
Member

@PIG208 PIG208 commented Jan 22, 2025

Stacked on top of #1342.

This addresses part of #1250.

This is the bare minimum needed for making TopicName.displayName nullable before we can work on the more intricate details on how parts like sending from compose box or live hint text updates work.

The last three commits enable support for empty topics for testing. When merging, we leave those three commits out because we haven't yet finished working other other parts mentioned above. This allows us to review and merge related changes without interrupting beta releases with user-visible changes.

See the screenshots for what changes are included here.

@PIG208 PIG208 force-pushed the pr-general-chat branch 11 times, most recently from da55117 to b38c9bc Compare January 29, 2025 23:59
@PIG208 PIG208 marked this pull request as ready for review January 30, 2025 23:48
@PIG208

This comment was marked as outdated.

@PIG208 PIG208 added the maintainer review PR ready for review by Zulip maintainers label Feb 6, 2025
@PIG208 PIG208 requested a review from chrisbobbe February 6, 2025 18:56
@PIG208

This comment was marked as resolved.

@PIG208 PIG208 removed the request for review from chrisbobbe February 7, 2025 21:35
@PIG208 PIG208 removed the maintainer review PR ready for review by Zulip maintainers label Feb 7, 2025
@PIG208 PIG208 force-pushed the pr-general-chat branch 2 times, most recently from b3f2081 to bc157cf Compare February 8, 2025 01:22
@PIG208
Copy link
Member Author

PIG208 commented Feb 8, 2025

Screenshots:

Autocomplete
autocomplete filtered autocomplete-empty
Message list page
msg-list
topic narrow combined
Compose box
topic channel-non-empty channel-empty

(sending to empty topics from channel narrow is not supported on this branch; more in #1364)

@PIG208 PIG208 force-pushed the pr-general-chat branch 2 times, most recently from 49751d6 to d88c355 Compare February 8, 2025 01:34
@PIG208 PIG208 requested a review from chrisbobbe February 8, 2025 01:38
@PIG208 PIG208 added maintainer review PR ready for review by Zulip maintainers and removed maintainer review PR ready for review by Zulip maintainers labels Feb 8, 2025
@PIG208 PIG208 removed the request for review from chrisbobbe February 10, 2025 22:08
@PIG208 PIG208 changed the title general chat #1: add support in most places general chat #1: add support at most places Feb 22, 2025
Copy link
Collaborator

@chrisbobbe chrisbobbe left a comment

Choose a reason for hiding this comment

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

Thanks, and sorry for the delay in my review! Small comments below.

Comment on lines 419 to 429
final String? _realmEmptyTopicDisplayName; // TODO(#668): update this realm setting
String get realmEmptyTopicDisplayName {
assert(_realmEmptyTopicDisplayName != null); // TODO(log)
return _realmEmptyTopicDisplayName ?? 'general chat';
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

checkTopicShown(topic3, store, expected: true);
checkTopicShown('Topic one', store, expected: false);
checkTopicShown('Topic two', store, expected: true);
checkTopicShown('Topic three', store, expected: true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

autocomplete test [nfc]: Use plain strings for finding topic

instead of inferring it from a TopicName

Signed-off-by: Zixuan James Li <[email protected]>

Commit-message nit: I think "inferring" isn't quite the right word; if you have a TopicName and you want its display name, you just look at its displayName field; no inference is needed

@@ -921,7 +921,7 @@ class TopicAutocompleteView extends AutocompleteView<TopicAutocompleteQuery, Top
}

TopicAutocompleteResult? _testTopic(TopicAutocompleteQuery query, TopicName topic) {
if (query.testTopic(topic)) {
if (query.testTopic(store, topic)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

autocomplete: Handle autocompleting to empty topic

Signed-off-by: Zixuan James Li <[email protected]>

This commit is NFC, right?

// This checks for inequality because there is nothing to autocomplete to
// when `raw` already matches the topic exactly.
return topic.displayName != raw
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about:

    // Skip this option if it matches the query exactly

(a little less verbose)

@@ -537,13 +537,16 @@ class _TopicItem extends StatelessWidget {
child: Text(
style: TextStyle(
fontSize: 17,
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
fontStyle: topic.displayName == null ? FontStyle.italic : null,
Copy link
Collaborator

Choose a reason for hiding this comment

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

msglist: Display realmEmptyTopicDisplayName where empty topic appears

Signed-off-by: Zixuan James Li <[email protected]>

This is another NFC commit, right? (And it doesn't actually do what the summary line says it does, because empty topics don't appear anywhere yet?)

Copy link
Member Author

@PIG208 PIG208 Feb 26, 2025

Choose a reason for hiding this comment

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

Yeah, these commits are structured in a way so that they are not user visible without the final "do not merge" series. This way we can start merging part of these changes while still have a way to test them.

It will do what the summary says, but only after we allow empty topics in our data structures.

@@ -366,8 +366,11 @@ class MessageListAppBarTitle extends StatelessWidget {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(child: Text(topic.displayName, style: const TextStyle(
Copy link
Collaborator

Choose a reason for hiding this comment

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

msglist: Display realmEmptyTopicDisplayName where empty topic appears

Signed-off-by: Zixuan James Li <[email protected]>

(Same comment about this being an NFC commit.)

@@ -90,6 +92,7 @@ Future<GetMessagesResult> getMessages(ApiConnection connection, {
bool? applyMarkdown,
// bool? useFirstUnreadAnchor // omitted because deprecated
}) {
final supportsEmptyTopics = connection.zulipFeatureLevel! >= 334; // TODO(server-10)
Copy link
Collaborator

Choose a reason for hiding this comment

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

clientGravatar looks like another client-capability param, but that one is exposed to the caller of this binding. I think we should maybe also expose supportsEmptyTopics, to make the binding as thin as possible? (Here and in other bindings)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ended up rewriting most of the last commit, and added a bunch of new tests.

@PIG208
Copy link
Member Author

PIG208 commented Feb 26, 2025

Thanks for the review! This should be ready again.

@chrisbobbe
Copy link
Collaborator

chrisbobbe commented Mar 4, 2025

Thanks, looks mostly good! For these NFC commits:

[…]
autocomplete [nfc]: Handle autocompleting to empty topic
[…]
inbox [nfc]: Display realmEmptyTopicDisplayName where empty topic appears
msglist [nfc]: Display realmEmptyTopicDisplayName where empty topic appears
[…]

I see that you've explained them in the PR discussion:

#1297 (comment)

Yeah, these commits are structured in a way so that they are not user visible without the final "do not merge" series. This way we can start merging part of these changes while still have a way to test them.

It will do what the summary says, but only after we allow empty topics in our data structures.

But the commit messages themselves look confusing; they say NFC but they also read as descriptions of a user-facing change. How about adding a brief note in each commit-message body saying that the described change doesn't actually happen until we allow empty topics in our data structures, which will come in a later series of commits.

Anyway, marking for Greg's review. :)

@chrisbobbe chrisbobbe requested review from gnprice and removed request for chrisbobbe March 4, 2025 00:08
@chrisbobbe chrisbobbe assigned gnprice and unassigned chrisbobbe Mar 4, 2025
@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 Mar 4, 2025
@PIG208 PIG208 force-pushed the pr-general-chat branch from cb1334d to 6b838e1 Compare March 4, 2025 04:23
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 to you both! Generally this looks good; comments below.

(I haven't read the "do not merge" commits.)

@@ -939,10 +943,16 @@ class TopicAutocompleteView extends AutocompleteView<TopicAutocompleteQuery, Top
class TopicAutocompleteQuery extends AutocompleteQuery {
TopicAutocompleteQuery(super.raw);

bool testTopic(TopicName topic) {
bool testTopic(PerAccountStore store, TopicName topic) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: candidate result first, then the contextual data — follow pattern of other testFoo methods on other FooAutocompleteQuery classes

@@ -414,6 +417,11 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
/// For docs, please see [InitialSnapshot.realmWaitingPeriodThreshold].
final int realmWaitingPeriodThreshold; // TODO(#668): update this realm setting
final int maxFileUploadSizeMib; // No event for this.
String get realmEmptyTopicDisplayName {
assert(_realmEmptyTopicDisplayName != null); // TODO(log)
Copy link
Member

Choose a reason for hiding this comment

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

This calls for a comment explaining why this condition is supposed to be unreachable — it doesn't seem obvious.

Copy link
Member

Choose a reason for hiding this comment

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

Or maybe clearest: a bit of dartdoc saying not to access this unless zulipFeatureLevel is at least such-and-such. That's the idea for why this shouldn't happen, right?

Comment on lines +420 to +430
String get realmEmptyTopicDisplayName {
assert(_realmEmptyTopicDisplayName != null); // TODO(log)
return _realmEmptyTopicDisplayName ?? 'general chat';
}
final String? _realmEmptyTopicDisplayName; // TODO(#668): update this realm setting
Copy link
Member

Choose a reason for hiding this comment

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

nit: set this group off with blank lines

Comment on lines 422 to 426
await tester.enterText(topicInputFinder, 'general ch');
await tester.enterText(topicInputFinder, 'general cha');
await tester.pumpAndSettle();

check(find.text(eg.defaultRealmEmptyTopicDisplayName)).findsOne();
Copy link
Member

Choose a reason for hiding this comment

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

This test is already relying on the value of eg.defaultRealmEmptyTopicDisplayName being what it is (or something like it), namely that it contains "general chat", in order for the search steps to work.

So the test should instead give explicitly the value of realmEmptyTopicDisplayName that it's counting on. Then it can use that in this check too.

Comment on lines 953 to 950
// Skip this option if it matches the query exactly.
return topic.displayName != raw
Copy link
Member

Choose a reason for hiding this comment

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

This comment seems to just restate what the line after it says. Cleanest to leave it out.

Comment on lines 533 to 534
fontSize: 17,
fontStyle: topic.displayName == null ? FontStyle.italic : null,
height: (20 / 17),
Copy link
Member

Choose a reason for hiding this comment

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

nit: keep fontSize and height next to each other — the "17" in height is a reference to the "17" in fontSize

(And even if we hadn't written height that way, those two properties are closely related and one naturally wants to read them together)

Comment on lines 315 to 316
unreadMessages: [eg.streamMessage(stream: channel, topic: '')]);

check(find.text(eg.defaultRealmEmptyTopicDisplayName)).findsOne();
Copy link
Member

Choose a reason for hiding this comment

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

nit: keep checks joined into same stanza after the setup that leads to them

Suggested change
unreadMessages: [eg.streamMessage(stream: channel, topic: '')]);
check(find.text(eg.defaultRealmEmptyTopicDisplayName)).findsOne();
unreadMessages: [eg.streamMessage(stream: channel, topic: '')]);
check(find.text(eg.defaultRealmEmptyTopicDisplayName)).findsOne();

Comment on lines 1100 to 1105
style: recipientHeaderTextStyle(context).copyWith(
fontStyle: topic.displayName == null ? FontStyle.italic : null,
Copy link
Member

Choose a reason for hiding this comment

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

Instead of copying the style object right after making it, let's have this recipientHeaderTextStyle helper take a parameter. Can just be fontStyle directly.

@@ -339,8 +339,9 @@ class MessageListAppBarTitle extends StatelessWidget {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(child: Text(topic.displayName, style: const TextStyle(
Flexible(child: Text(topic.displayName ?? store.realmEmptyTopicDisplayName, style: TextStyle(
Copy link
Member

Choose a reason for hiding this comment

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

Let's have a test for this part too. Should be quick, I think; can go in the "app bar" group.

@PIG208 PIG208 force-pushed the pr-general-chat branch 3 times, most recently from 9b72b20 to 61fe655 Compare March 5, 2025 01:09
@PIG208
Copy link
Member Author

PIG208 commented Mar 5, 2025

Updated the PR. Thanks for the review!

PIG208 added 6 commits March 10, 2025 11:41
instead of reading TopicName.displayName

Signed-off-by: Zixuan James Li <[email protected]>
While this appears to be a user facing change, it's not visible yet, not
until TopicName.displayName becomes nullable.  This is a part of a
series of changes to handle empty topics.

Signed-off-by: Zixuan James Li <[email protected]>
…ears

While this appears to be a user facing change, it's not visible yet, not
until TopicName.displayName becomes nullable.  This is a part of a
series of changes to handle empty topics.

Signed-off-by: Zixuan James Li <[email protected]>
…ppears

While this appears to be a user facing change, it's not visible yet, not
until TopicName.displayName becomes nullable.  This is a part of a
series of changes to handle empty topics.

Signed-off-by: Zixuan James Li <[email protected]>
@gnprice
Copy link
Member

gnprice commented Mar 10, 2025

Thanks! Looks good; merging.

@gnprice gnprice merged commit 8e21f98 into zulip:main Mar 10, 2025
@PIG208 PIG208 deleted the pr-general-chat branch March 10, 2025 18:51
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.

3 participants