Skip to content

Commit 312cf67

Browse files
authored
fix(desktop): remember Inbox unread-only choice (#7672)
## Summary Inbox forgets the **Show unread only** choice after navigation or restart. Save the toggle with the existing safe storage helpers and restore it when Inbox opens. The preference stays on this installation and applies across accounts and communities. Fresh installations keep the current off default. If storage fails, the current view remains usable, but the choice may not survive navigation. ### Related issue Related report: #3669. Overlaps with #6105 and #3682. #6151 also persists category filters and pane widths. This draft keeps the change to the unread toggle and reuses the existing storage helpers. ### Testing The mock Desktop regression passed: enable the toggle, navigate to Agents and back, reload, then repeat with the toggle disabled. Both choices were restored. This exercises the UI with a synthetic fixture; a native app restart was not tested. The full local repository CI gate is pending. Keep this PR in draft until validation completes. ### Before and after behavior Same synthetic Desktop fixture in Chromium, 1280×720, on macOS. **Before:** production source from `41c5ace93740261ee5a5d962c2a17e8d846c2c1b`. **After:** PR head `b50c1a06d53fdc080e7aae6ee9aa2e9ad6b60a82`. The capture test asserted the displayed toggle state before taking each screenshot. 1. Enable **Show unread only**, open **Agents**, go back to **Inbox**, and reopen **Inbox options**. 2. Enable the toggle again, reload the page, and reopen **Inbox options**. Before the fix the toggle is off after both journeys; after the fix it stays on. These are mock-backed UI captures, not a native Desktop restart or live relay test. | Journey | Before: resets to off | After: stays on | | --- | --- | --- | | Inbox → Agents → back | ![before-navigation](https://raw.githubusercontent.com/block/buzz/8a4d4845a51ab096d573f96bd528aa0e7abb1dc9/pr-7672--before-navigation.png) | ![after-navigation](https://raw.githubusercontent.com/block/buzz/8a4d4845a51ab096d573f96bd528aa0e7abb1dc9/pr-7672--after-navigation.png) | | Enable → page reload | ![before-reload](https://raw.githubusercontent.com/block/buzz/8a4d4845a51ab096d573f96bd528aa0e7abb1dc9/pr-7672--before-reload.png) | ![after-reload](https://raw.githubusercontent.com/block/buzz/8a4d4845a51ab096d573f96bd528aa0e7abb1dc9/pr-7672--after-reload.png) | Generated with Codex Signed-off-by: Diem Nguyen <[email protected]>
1 parent 7e96f91 commit 312cf67

2 files changed

Lines changed: 37 additions & 2 deletions

File tree

‎desktop/src/features/home/ui/HomeView.tsx‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import { KIND_REACTION } from "@/shared/constants/kinds";
6666
import { topChromeInset } from "@/shared/layout/chromeLayout";
6767
import { cn } from "@/shared/lib/cn";
6868
import { normalizePubkey } from "@/shared/lib/pubkey";
69+
import { getStorageItem, setStorageItem } from "@/shared/lib/safeStorage";
6970
import { useElementWidth } from "@/shared/hooks/use-mobile";
7071
import { useThreadPanelWidth } from "@/shared/hooks/useThreadPanelWidth";
7172
import { AUXILIARY_PANEL_SINGLE_COLUMN_BREAKPOINT_PX } from "@/shared/layout/AuxiliaryPanel";
@@ -81,6 +82,8 @@ const INBOX_SEARCH_KEYS = [
8182
"profileView",
8283
] as const;
8384

85+
const INBOX_UNREAD_ONLY_STORAGE_KEY = "buzz.desktop.inbox-unread-only";
86+
8487
type HomeViewProps = {
8588
feed?: HomeFeedResponse;
8689
isLoading?: boolean;
@@ -110,7 +113,15 @@ export function HomeView({
110113
homeInboxWidthPx > 0 &&
111114
homeInboxWidthPx < INBOX_SINGLE_COLUMN_BREAKPOINT_PX;
112115
const [filter, setFilter] = React.useState<InboxFilter>("all");
113-
const [unreadOnly, setUnreadOnly] = React.useState(false);
116+
const [unreadOnly, setUnreadOnly] = React.useState(
117+
() => getStorageItem(INBOX_UNREAD_ONLY_STORAGE_KEY) === "true",
118+
);
119+
const handleUnreadOnlyChange = React.useCallback((value: boolean) => {
120+
setUnreadOnly(value);
121+
// Match other local preferences: storage failures keep the current view
122+
// usable, while safeStorage records a warning if persistence is unavailable.
123+
setStorageItem(INBOX_UNREAD_ONLY_STORAGE_KEY, String(value));
124+
}, []);
114125
// Explicit selections are mirrored to the URL (`?item=`), so back/forward
115126
// restores the detail pane each history entry was showing and reloads
116127
// restore it from the URL. Default/automatic selection stays local-only —
@@ -745,7 +756,7 @@ export function HomeView({
745756
handleUserSelectItem(null);
746757
setSelectedReminderId(reminderId);
747758
}}
748-
onUnreadOnlyChange={setUnreadOnly}
759+
onUnreadOnlyChange={handleUnreadOnlyChange}
749760
reminderPubkey={currentPubkey}
750761
reminders={pendingReminders}
751762
selectedConversationId={selectedConversationId}

‎desktop/tests/e2e/navigation.spec.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,30 @@ test("open thread panels survive reload", async ({ page }) => {
277277
await expect(threadPanel).toBeVisible();
278278
});
279279

280+
test("inbox unread-only choice survives navigation and reload", async ({
281+
page,
282+
}) => {
283+
await page.goto("/");
284+
const options = page.getByRole("button", { name: "Inbox options" });
285+
const unreadOnly = page.getByRole("switch", { name: "Show unread only" });
286+
await options.click();
287+
await expect(unreadOnly).not.toBeChecked();
288+
289+
for (const enabled of [true, false]) {
290+
await unreadOnly.setChecked(enabled);
291+
await page.keyboard.press("Escape");
292+
await page.getByTestId("open-agents-view").click();
293+
await expect(page.getByTestId("home-inbox-list")).not.toBeVisible();
294+
await page.getByTestId("global-back").click();
295+
await options.click();
296+
await expect(unreadOnly).toBeChecked({ checked: enabled });
297+
298+
await page.reload();
299+
await options.click();
300+
await expect(unreadOnly).toBeChecked({ checked: enabled });
301+
}
302+
});
303+
280304
test("home inbox selection survives reload and back restores it", async ({
281305
page,
282306
}) => {

0 commit comments

Comments
 (0)