← Back to Pull requests

Sort unread topics by recency for n shortcut. #1625

Open
unknown opened this pull request with 380 lines diff across 4 files
View on GitHub
unknown unknown commented on Mar 08, 2026 07:06 UTC
Author

Fixes #1582.

<!-- See README for documentation, or ask in #zulip-terminal if unclear -->

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


<!-- [x] all that apply, specifying topic and adding numbers after # for issues/PRs -->
  • Discussed in #zulip-terminal in topic

  • Fully fixes #1582

  • Partially fixes issue #

  • Builds upon previous unmerged work in PR #

  • Is a follow-up to work in PR #

  • Requires merge of PR #

  • Merge will enable work on #
  • How did you test this?


    <!-- [x] all that apply -->
  • 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.

    <img width="441" height="685" alt="image" src="https://github.com/user-attachments/assets/79999e1f-b169-4224-b44e-7e25f22328b1" />
    <img width="441" height="685" alt="image" src="https://github.com/user-attachments/assets/35c5c6cf-2e4d-45c8-9c6f-0c2d8aa91d4a" />

    Diff: 380 lines (+285 / -95) across 4 files Reviewer: yummyPancake2607 Review duration: 341739m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.50) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 380 lines diff across 4 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.356
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #1625"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 49.9% (MEDIUM) · Higher = larger blast radius
    49.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.6% · Safe to merge
    27.6%