From 78e7fa05cfaac5bf14b3d89120658f9ae4db5124 Mon Sep 17 00:00:00 2001 From: Shuki Vaknin Date: Thu, 20 Aug 2026 22:26:51 +0300 Subject: [PATCH] fix(search): scope the unread quick-filter to the current folder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clicking a folder's unread count (e.g. Inbox: 29) enabled the unread filter and ran advancedSearch with no folder scope, so searchMailboxId stayed "" and buildJMAPFilter added no inMailbox constraint — the result listed unread mail from every folder, including Trash and Spam, which contradicts the folder-local badge the user clicked. Set searchMailboxId to the clicked mailbox when enabling the filter (and clear it when toggling off) so the unread view matches the count. --- components/mail/mail-app.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/mail/mail-app.tsx b/components/mail/mail-app.tsx index 1cfd0d78..d74c8fd9 100644 --- a/components/mail/mail-app.tsx +++ b/components/mail/mail-app.tsx @@ -2514,13 +2514,19 @@ export function MailApp({ linkSegments }: MailAppProps = {}) { if (isTogglingOff) { // Disable the unread filter and show all emails clearSearchFilters(); + setSearchMailboxId(""); if (client) { await fetchEmails(client, mailboxId); } } else { - // Enable unread filter + // Enable the unread filter, scoped to THIS folder. advancedSearch runs + // across every mailbox when no folder scope is set, so a folder-local + // "unread" badge (e.g. Inbox: 29) would open a list that also pulls + // unread from Trash/Spam/etc. Scope to the clicked mailbox so the view + // matches the count. clearSearchFilters(); setSearchFilters({ isUnread: true }); + setSearchMailboxId(mailboxId); if (client) { await advancedSearch(client); }