2016-08-17 01:15:35 +02:00
|
|
|
# Unread counts and the pointer
|
2016-08-11 22:14:22 +02:00
|
|
|
|
2024-05-20 17:38:40 +02:00
|
|
|
When you're using Zulip and you reload, or narrow to a channel, how
|
2016-08-11 22:14:22 +02:00
|
|
|
does Zulip decide where to place you?
|
|
|
|
|
2016-08-17 01:15:35 +02:00
|
|
|
Conceptually, Zulip takes you to the place where you left off
|
2024-07-04 12:33:43 +02:00
|
|
|
(e.g., the first unread message), not the most recent messages, to
|
2016-08-17 01:15:35 +02:00
|
|
|
facilitate reviewing all the discussions that happened while you were
|
|
|
|
away from your computer. The scroll position is then set to keep that
|
|
|
|
message in view and away from both the top and bottom of the visible
|
|
|
|
section of messages.
|
2016-08-11 22:14:22 +02:00
|
|
|
|
|
|
|
But there a lot of details around doing this right, and around
|
2016-08-17 01:15:35 +02:00
|
|
|
counting unread messages. Here's how Zulip currently decides which
|
|
|
|
message to select, along with some notes on improvements we'd like to
|
|
|
|
make to the model.
|
2016-08-11 22:14:22 +02:00
|
|
|
|
2016-08-17 01:15:35 +02:00
|
|
|
First a bit of terminology:
|
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
- "Narrowing" is the process of filtering to a particular subset of
|
2016-08-17 01:15:35 +02:00
|
|
|
the messages the user has access to.
|
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
- The blue cursor box (the "pointer") is around is called the
|
2021-08-20 21:53:28 +02:00
|
|
|
"selected" message. Zulip ensures that the currently selected
|
2016-08-17 01:15:35 +02:00
|
|
|
message is always in-view.
|
|
|
|
|
|
|
|
## Pointer logic
|
|
|
|
|
|
|
|
### Recipient bar: message you clicked
|
2016-08-11 22:14:22 +02:00
|
|
|
|
2021-08-20 22:54:08 +02:00
|
|
|
If you enter a narrow by clicking on a message group's _recipient bar_
|
2024-05-20 17:38:40 +02:00
|
|
|
(channel/topic or direct message recipient list at the top of a group
|
2017-01-15 05:13:22 +01:00
|
|
|
of messages), Zulip will select the message you clicked on. This
|
2016-08-17 01:15:35 +02:00
|
|
|
provides a nice user experience where you get to see the stuff near
|
|
|
|
what you clicked on, and in fact the message you clicked on stays at
|
|
|
|
exactly the same scroll position in the window after the narrowing as
|
|
|
|
it was at before.
|
2016-08-11 22:14:22 +02:00
|
|
|
|
2020-07-04 00:57:33 +02:00
|
|
|
### Search, sidebar click, or new tab: unread/recent matching narrow
|
|
|
|
|
|
|
|
If you instead narrow by clicking on something in the left sidebar,
|
|
|
|
typing some terms into the search box, reloading the browser, or any
|
|
|
|
other method that doesn't encode a specific message to visit, Zulip
|
|
|
|
will instead select the first unread message matching that narrow, or
|
|
|
|
if there are none, the most recent messages matching that narrow.
|
|
|
|
|
|
|
|
This provides the nice user experience of taking you to the start of
|
2022-02-08 00:13:33 +01:00
|
|
|
the new stuff (with enough messages you've seen before still in view
|
2020-07-04 00:57:33 +02:00
|
|
|
at the top to provide you with context), which is usually what you
|
|
|
|
want. (When finding the "first unread message", Zulip ignores unread
|
2024-05-20 17:38:40 +02:00
|
|
|
messages in muted channels or in muted topics within non-muted
|
|
|
|
channels.)
|
2016-08-11 22:14:22 +02:00
|
|
|
|
2016-08-17 01:15:35 +02:00
|
|
|
### Unnarrow: previous sequence
|
2016-08-11 22:14:22 +02:00
|
|
|
|
2024-07-04 12:33:43 +02:00
|
|
|
When you unnarrow using e.g., the `a` key, you will automatically be
|
2024-04-02 13:10:48 +02:00
|
|
|
taken to the same message that was selected in the Combined feed view before
|
2016-08-11 22:14:22 +02:00
|
|
|
you narrowed, unless in the narrow you read new messages, in which
|
|
|
|
case you will be jumped forward to the first unread and non-muted
|
2024-04-02 13:10:48 +02:00
|
|
|
message in the Combined feed view (or the bottom of the feed if there is
|
|
|
|
none). This makes for a nice experience reading threads via the Combined feed
|
2016-08-11 22:14:22 +02:00
|
|
|
view in sequence.
|
|
|
|
|
2016-08-17 01:15:35 +02:00
|
|
|
### Forced reload: state preservation
|
2016-08-11 22:14:22 +02:00
|
|
|
|
|
|
|
When the server forces a reload of a browser that's otherwise caught
|
|
|
|
up (which happens within 30 minutes when a new version of the server
|
2016-08-17 01:15:35 +02:00
|
|
|
is deployed, usually at a type when the user isn't looking at the
|
|
|
|
browser), Zulip will preserve the state -- what (if any) narrow the
|
|
|
|
user was in, the selected message, and even exact scroll position!
|
2016-08-11 22:14:22 +02:00
|
|
|
|
|
|
|
For more on the user experience philosophy guiding these decisions,
|
2019-09-30 19:37:56 +02:00
|
|
|
see [the architectural overview](../overview/architecture-overview.md).
|
2016-08-17 01:15:35 +02:00
|
|
|
|
|
|
|
## Unread count logic
|
|
|
|
|
|
|
|
How does Zulip decide whether a message has been read by the user?
|
|
|
|
The algorithm needs to correctly handle a range of ways people might
|
2021-08-20 21:53:28 +02:00
|
|
|
use the product. The algorithm is as follows:
|
2016-08-17 01:15:35 +02:00
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
- Any message which is selected or above a message which is selected
|
2021-08-20 21:53:28 +02:00
|
|
|
is marked as read. So messages are marked as read as you scroll
|
2016-08-17 01:15:35 +02:00
|
|
|
down the keyboard when the pointer passes over them.
|
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
- If the whitespace at the very bottom of the feed is in view, all
|
2016-08-17 01:15:35 +02:00
|
|
|
messages in view are marked as read.
|
|
|
|
|
|
|
|
These two simple rules, combined with the pointer logic above, end up
|
|
|
|
matching user expectations well for whether the product should treat
|
|
|
|
them as having read a set of messages (or not).
|
2017-04-26 00:35:52 +02:00
|
|
|
|
2019-07-10 02:03:41 +02:00
|
|
|
One key detail to highlight is that we only mark messages as read
|
|
|
|
through these processes in views that contain all messages in a
|
|
|
|
thread; search views will never mark messages as read.
|
|
|
|
|
2017-04-26 00:35:52 +02:00
|
|
|
## Testing and development
|
|
|
|
|
2021-09-08 00:23:24 +02:00
|
|
|
In a Zulip development environment, you can use
|
|
|
|
`manage.py mark_all_messages_unread` to set every user's pointer to 0
|
|
|
|
and all messages as unread, for convenience in testing unread count
|
|
|
|
related logic.
|
2017-04-26 00:35:52 +02:00
|
|
|
|
|
|
|
It can be useful to combine this with `manage.py populate_db -n 3000`
|
|
|
|
(which rebuilds the database with 3000 initial messages) to ensure a
|
|
|
|
large number of messages are present.
|