Skip to content

Sort unread topics by recency for n shortcut.#1625

Open
archie-2006 wants to merge 1 commit intozulip:mainfrom
archie-2006:fix-unread-topic-sorting
Open

Sort unread topics by recency for n shortcut.#1625
archie-2006 wants to merge 1 commit intozulip:mainfrom
archie-2006:fix-unread-topic-sorting

Conversation

@archie-2006
Copy link
Copy Markdown
Collaborator

Fixes #1582.

What does this PR do, and why?

Before, using the n keybinding (NEXT_UNREAD_TOPIC) jumps to the next unread topic alphabetically within a stream. But it should be sorting unread topics by recency.

this pull request fixes this issue #1582 by using recency-based sorting

  1. helper.py: Updated sort_unread_topics to accept an optional topic_msg_ids dictionary. Modified the sorting key to evaluate the maximum message_id within each topic (-max(...)), ensuring that the most recently active topics go to the top (bubble). The alphabetical topic name sorting (from earlier) is still being used as a secondary tie breaker.
  2. model.py: Updated calls to sort_unread_topics in next_unread_topic_from_message_id to pass self.index["topic_msg_ids"]

External discussion & connections

How did you test this?

  • Manually - Behavioral changes
  • Manually - Visual changes
  • Adapting existing automated tests
  • Adding automated tests for new behavior (or missing tests)
  • Existing automated tests should already cover this (only a refactor of tested code)

Self-review checklist for each commit

  • It is a minimal coherent idea
  • It has a commit summary following the documented style (title & body)
  • It has a commit summary describing the motivation and reasoning for the change
  • It individually passes linting and tests
  • It contains test additions for any new behavior
  • It flows clearly from a previous branch commit, and/or prepares for the next commit

Visual Changes

Navigating with n in Explore mode. The selection correctly jumps from the recently active (checkmark) test topic to the next most recent unread topic (test), rather than sorting alphabetically, like earlier.

The header shows being in the test checkmark in the first screenshot (this is before pressing n)

In the second ss, after pressing n, the ui changes and the header now shows test without the checkmark and the message history of unread messages for that topic beneath it.

image image

@zulipbot zulipbot added size: S [Automatic label added by zulipbot] missing feature: user A missing feature for all users, present in another Zulip client version parity: <=2.1 labels Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing feature: user A missing feature for all users, present in another Zulip client size: S [Automatic label added by zulipbot] version parity: <=2.1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using n should move between topics by recency

2 participants