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

unreads: Fix false positives in a debug check; log in another case when helpful #1150

Merged
merged 3 commits into from
Jan 7, 2025

Conversation

chrisbobbe
Copy link
Collaborator

In manual testing for my work on resolve/unresolve #744, I noticed some surprising debug-log lines that turned out to be false positives, so this fixes those.

It also makes the debug check run in a helpful case where it wasn't running before.

@chrisbobbe chrisbobbe added the maintainer review PR ready for review by Zulip maintainers label Dec 13, 2024
@chrisbobbe chrisbobbe requested a review from PIG208 December 13, 2024 03:57
Copy link
Member

@PIG208 PIG208 left a comment

Choose a reason for hiding this comment

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

Looks good! Left a comment.

});
}

doTestCommon('unread DM message', unreadDmMessage.id, true);
Copy link
Member

Choose a reason for hiding this comment

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

nit: Should we make the third parameter use a keyword? Just by looking at it it is not so obvious what this is supposed to mean.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure; made this a named param.

We don't expect UpdateMessageEvent to signal a change in a message's
read state; that's what UpdateMessageFlagsEvent is for. Our unreads
model does process `UpdateMessageEvent`s, though, to apply changes
in a message's mentioned state.

Also, we expect the client to be synced with the server for all
messages' read state, assuming !oldUnreadsMissing.

Where we process `UpdateMessageEvent`s, we have a `debugLog` line to
alert us if one of these expectations isn't being met. It's been
giving false positives when we get an UpdateMessageEvent for a bulk
message move where some of the moved messages are read and some
aren't. Since the server only intends the event's `flags` to apply
to the event's `messageId` (one message), we should only be checking
that message, not all the messages in the event's `messageIds`.
From the API doc on `flags`:

https://zulip.com/api/get-events#update_message
> The user's personal message flags for the message with ID
> message_id following the edit.
And make it public, with dartdoc and tests, while we're at it.
For this debug check to work, it just needs a known read state for
one message.

When `oldUnreadsMissing` is false (the common case), the model holds
one of two answers for a message's read state: known-unread or
known-read.

When `oldUnreadsMissing` is true, the model holds known-unread or
unknown.

Before, we were skipping the debug check on seeing that
`oldUnreadsMissing` is true. That's earlier than we need to abort,
because the model might still hold a known-unread state for the
message. Now, we go ahead with the debug check if that's the case,
and still skip it otherwise.

Done by using our new `isUnread` helper, in this separate commit
because it's not NFC in debug mode.
@chrisbobbe chrisbobbe force-pushed the pr-unreads-debug-log-fix branch from 2f7f021 to 7d64e2f Compare January 3, 2025 23:08
@chrisbobbe
Copy link
Collaborator Author

chrisbobbe commented Jan 3, 2025

Thanks for the review! Revision pushed. Since you had just one nit, which I've fixed, I'll go ahead and mark 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 Jan 3, 2025
@chrisbobbe chrisbobbe assigned gnprice and unassigned PIG208 Jan 3, 2025
@chrisbobbe chrisbobbe requested a review from gnprice January 3, 2025 23:09
@gnprice gnprice merged commit 7d64e2f into zulip:main Jan 7, 2025
1 check passed
@gnprice
Copy link
Member

gnprice commented Jan 7, 2025

Thanks! Looks good; merging.

@chrisbobbe chrisbobbe deleted the pr-unreads-debug-log-fix branch January 8, 2025 02:40
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