Skip to content

Add read and unread actions to search chat menus - #152

Merged
macosswift merged 12 commits into
TelegramMessenger:masterfrom
PystoyPlayer:codex/search-mark-unread
Oct 30, 2026
Merged

macosswift merged 12 commits into
TelegramMessenger:masterfrom
PystoyPlayer:codex/search-mark-unread

Conversation

@PystoyPlayer

@PystoyPlayer PystoyPlayer commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Key change

Add the ordinary chat list’s Mark as Unread/Read action to search results, recent peers and the top-peer strip, including top-level Saved Messages. Saved-message sub-chat results intentionally omit the action, matching their own list. Read current state when a menu opens and keep pin/folder/remove actions.

Reason

Search menus lacked a reminder action. Only peers actually in a chat-list group are eligible. Secret-chat namespaces remain excluded. Forums shown as messages or tabs retain Mark as Unread, matching the engine; other read forums omit the unsupported whole-peer action.

Screenshot/video result (before/after)

The retained comparison shows real production ContextMenuItems in a native AppKit popup using Saved Messages only. This is a diagnostic host, not a recreation of the custom glass renderer or a published chat list.

Before

Before: production search-result menu has no unread action

After

After: production search-result menu includes Mark as Unread

Confirmation

macOS 27.0.1 (26A434), Xcode 27.1; historical full-client captures use Telegram 13.1.0 (283357), Debug arm64.

python3 tools/tests/search-unread/run.py: 46/46 checks pass. Saved Messages shown as sub-chats now omit read/unread actions entirely, before querying or changing the peer's real private chat. Ordinary search/recent/popular peer menus retain the action, including the top-level Saved Messages chat. The shared helper receives the actual search target. Existing forum/manual-unread cases remain covered. The diagnostic toggle harness now holds a shared run lease through restoration, including when its window is closed and reopened; six lease tests cover ownership, restoration and rejecting an overlapping run. The historical native engine pass restored the Saved Messages flag and predates this follow-up. Current target/lease cases are controlled source checks, not new physical right-click/server-state verification.

The full Debug arm64 client workspace compiled successfully with these shipping sources and real native dependencies on macOS 27.0.1 / Xcode 27.1. It includes other pending changes and local SDK/profile overrides, so this is integration build coverage rather than an independent build of this PR alone.

  • I confirm that I have tested the affected behavior and verified that it works properly, or verified the content and links for a documentation-only change.
@macosswift

Copy link
Copy Markdown
Collaborator

Issues:

CONFIRMED: SearchPeerReadMenuItem.swift:14-31: for a forum shown as messages (View as Messages on), the menu takes its label from the thread-based read counters, which never reflect the manual unread mark, while the action sets that mark, so after Mark as Unread search keeps offering Mark as Unread (now a no-op) and never Mark as Read, and the mark cannot be cleared from search.

CONFIRMED: PR description: the description still says secret-chat results use the real chat ID and that read forums and monoforums omit the action, but at head secret chats get no read action at all and read forums shown as messages or tabs do offer Mark as Unread.

CONFIRMED: PR description: the description, README.md:9 and after-checks.txt still report 30/30 checks from revision 0884189, while the head runs 32, the native screenshots and state reports were not re-run after c144b16 changed both production files, and before-checks-window.png shows a status the committed harness cannot print.

CONFIRMED: SearchUnreadHarness.swift:27: the diagnostic window keeps NSWindow's default isReleasedWhenClosed = true while a global keeps and reuses it, so closing the fixture and opening it again messages a released window and crashes, contrary to the README's "reuses its window".

@macosswift

Copy link
Copy Markdown
Collaborator

Issues:

CONFIRMED: SearchUnreadHarness.swift:10: the harness keeps its window in a global that strongly holds the first AccountContext and is never cleared, so after switching accounts the "Search unread validation" button reopens the old window and "Check unread toggle" reads and flips the previous account's Saved Messages unread mark, and that account's context is never released.

@macosswift

Copy link
Copy Markdown
Collaborator

Issues:

  • SearchController.swift:387-391: when searching inside Saved Messages shown as chats, the results are Saved Messages sub-chats, but the new Mark as Read/Unread item reads and changes the real private chat with that peer, so right-clicking "Alice" and choosing Mark as Read marks your chat with Alice as read (sending read receipts) while clicking the same row opens the saved sub-chat, and the saved-messages chat list itself offers no read action.

  • SearchUnreadHarness.swift:65-71: the toggle run is single-flight only within one window instance: closing the window clears the global while a run is still in flight, so reopening the harness and starting a new run lets two runs overlap, and the account can end marked unread while the window reports "Original unread flag restored", contrary to README.md:9 ("toggle runs are single-flight").

@macosswift

Copy link
Copy Markdown
Collaborator

Issues:

  • PR description: The description says redundant alternate chat-ID plumbing was removed, but the diff against master removes no chat-ID handling at all; the sentence describes an intermediate commit of this branch (a chat ID parameter added in 7e8b5c8 and dropped in c144b16).

  • review-checks.txt:1: review-checks.txt still reports 37/37 checks while the suite now has 46 checks and current-checks.txt says 46/46, and verification/README.md says old numeric check outputs were removed so they are not presented as current results.

@macosswift
macosswift merged commit 7b3a083 into TelegramMessenger:master Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants