From af14291e2506525265cb3ab9ba1bc6ac5fc6f7f6 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Tue, 17 Nov 2026 17:49:12 +0000 Subject: [PATCH 1/2] fix(notifications): treat offline as a connection state, not an error A paused notification query means there is no connectivity, not that a fetch failed. Derive an explicit offline status so the tray and notifications view do not present the offline/reconnect transition as an error. --- .../components/GlobalEffects.test.tsx | 9 ++++++++ src/renderer/routes/Notifications.test.tsx | 11 +++++++++ src/renderer/routes/Notifications.tsx | 2 +- src/renderer/types.ts | 2 +- .../utils/notifications/status.test.ts | 23 +++++++++++++++++-- src/renderer/utils/notifications/status.ts | 11 +++++++-- 6 files changed, 52 insertions(+), 6 deletions(-) diff --git a/src/renderer/components/GlobalEffects.test.tsx b/src/renderer/components/GlobalEffects.test.tsx index 1c25503a7..6b64954dc 100644 --- a/src/renderer/components/GlobalEffects.test.tsx +++ b/src/renderer/components/GlobalEffects.test.tsx @@ -38,6 +38,15 @@ describe('renderer/components/GlobalEffects.tsx', () => { expect(setTrayIconColorAndTitleSpy).toHaveBeenCalledWith(-1, true); }); + it('does not report an error to the tray while the query is offline', async () => { + await act(async () => { + renderWithProviders(, { status: 'offline', notificationCount: 3 }); + }); + + expect(setTrayIconColorAndTitleSpy).toHaveBeenCalledWith(3, true); + expect(setTrayIconColorAndTitleSpy).not.toHaveBeenCalledWith(-1, true); + }); + it('resets all stores when the app is reset', async () => { await act(async () => { renderWithProviders(, { diff --git a/src/renderer/routes/Notifications.test.tsx b/src/renderer/routes/Notifications.test.tsx index d006dda72..86210579b 100644 --- a/src/renderer/routes/Notifications.test.tsx +++ b/src/renderer/routes/Notifications.test.tsx @@ -80,6 +80,17 @@ describe('renderer/routes/Notifications.tsx', () => { expect(screen.queryByText('Loading')).not.toBeInTheDocument(); }); + it('prefers the offline status over loading while the device is online', () => { + renderWithProviders(, { + status: 'offline', + isOnline: true, + }); + + expect(screen.getByText('Oops')).toBeInTheDocument(); + expect(screen.queryByText('Loading')).not.toBeInTheDocument(); + expect(screen.queryByText('AllRead')).not.toBeInTheDocument(); + }); + it('prefers the error state over loading', () => { renderWithProviders(, { globalError: getErrorDetails('UNKNOWN'), diff --git a/src/renderer/routes/Notifications.tsx b/src/renderer/routes/Notifications.tsx index 93441ddc5..2972aa070 100644 --- a/src/renderer/routes/Notifications.tsx +++ b/src/renderer/routes/Notifications.tsx @@ -35,7 +35,7 @@ export function NotificationsRoute() { [visibleNotifications], ); - if (!isOnline) { + if (!isOnline || status === 'offline') { return ; } diff --git a/src/renderer/types.ts b/src/renderer/types.ts index 2fb4c5d4e..e40e21bbf 100644 --- a/src/renderer/types.ts +++ b/src/renderer/types.ts @@ -52,7 +52,7 @@ export function toLinkOrNull(value: string | null | undefined): Link | null { export type SearchToken = Branded; -export type Status = 'loading' | 'success' | 'error'; +export type Status = 'loading' | 'offline' | 'success' | 'error'; export type Percentage = Branded; diff --git a/src/renderer/utils/notifications/status.test.ts b/src/renderer/utils/notifications/status.test.ts index c5abc40b6..ff20a23e6 100644 --- a/src/renderer/utils/notifications/status.test.ts +++ b/src/renderer/utils/notifications/status.test.ts @@ -26,8 +26,27 @@ describe('renderer/utils/notifications/status.ts', () => { expect(deriveStatus({ ...baseInput, isLoading: true, notifications: [] })).toBe('loading'); }); - it('reports error when the query is paused (offline)', () => { - expect(deriveStatus({ ...baseInput, isPaused: true, notifications: [clean] })).toBe('error'); + it('reports offline when the query is paused', () => { + expect(deriveStatus({ ...baseInput, isPaused: true, notifications: [clean] })).toBe( + 'offline', + ); + }); + + it('reports offline rather than error when paused with account errors', () => { + expect( + deriveStatus({ ...baseInput, isPaused: true, notifications: [networkError, networkError] }), + ).toBe('offline'); + }); + + it('reports offline before the initial fetch settles when paused', () => { + expect( + deriveStatus({ + ...baseInput, + isLoading: true, + isPaused: true, + notifications: [], + }), + ).toBe('offline'); }); it('reports error when the query failed', () => { diff --git a/src/renderer/utils/notifications/status.ts b/src/renderer/utils/notifications/status.ts index 07fad08ea..66a17da31 100644 --- a/src/renderer/utils/notifications/status.ts +++ b/src/renderer/utils/notifications/status.ts @@ -28,6 +28,10 @@ export interface NotificationStatusInput { * * Only the initial fetch (no settled success or error yet) reports `loading` - * background refetches of already-settled data keep their settled status. + * + * A paused query means there is no connectivity, not that a fetch failed, so it + * reports `offline` rather than `error`. This keeps the tray and notifications + * view from showing a failure while the app is offline or reconnecting. */ export function deriveStatus({ isLoading, @@ -35,12 +39,15 @@ export function deriveStatus({ isError, notifications, }: NotificationStatusInput): Status { + if (isPaused) { + return 'offline'; + } + if (isLoading) { return 'loading'; } - // Paused (offline) and outright query errors both surface as error status. - if (isPaused || isError) { + if (isError) { return 'error'; } From 7d5915fa2848c230cdbaf56d1d5ff81f117b352d Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Wed, 18 Nov 2026 06:15:57 +0000 Subject: [PATCH 2/2] refactor(notifications): clarify network vs notification offline state Name the device-level online flag separately from the paused-query presentation state, and document why the notifications view checks both. --- src/renderer/components/GlobalEffects.tsx | 6 +++--- src/renderer/routes/Notifications.tsx | 10 ++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/renderer/components/GlobalEffects.tsx b/src/renderer/components/GlobalEffects.tsx index 5aee33442..3d2f7eed8 100644 --- a/src/renderer/components/GlobalEffects.tsx +++ b/src/renderer/components/GlobalEffects.tsx @@ -36,7 +36,7 @@ export function GlobalEffects() { const useUnreadActiveIcon = useSettingsStore((s) => s.useUnreadActiveIcon); const trayIconAppearance = useSettingsStore((s) => s.trayIconAppearance); - const isOnline = useOnlineStatus(); + const isNetworkOnline = useOnlineStatus(); // Appearance side effects: color mode/scheme + design-language/material attributes useAppearance(); @@ -57,14 +57,14 @@ export function GlobalEffects() { // oxlint-disable-next-line react/exhaustive-deps -- We want to update the tray on setting or notification changes useEffect(() => { const trayCount = status === 'error' ? -1 : notificationCount; - setTrayIconColorAndTitle(trayCount, isOnline); + setTrayIconColorAndTitle(trayCount, isNetworkOnline); }, [ showNotificationsCountInTray, useUnreadActiveIcon, trayIconAppearance, status, notificationCount, - isOnline, + isNetworkOnline, ]); useEffect(() => { diff --git a/src/renderer/routes/Notifications.tsx b/src/renderer/routes/Notifications.tsx index 2972aa070..68886da2a 100644 --- a/src/renderer/routes/Notifications.tsx +++ b/src/renderer/routes/Notifications.tsx @@ -16,7 +16,7 @@ import { hasNoAccountErrors } from '../utils/notifications/status'; export function NotificationsRoute() { const { notifications, status, globalError, hasNotifications } = useNotifications(); - const isOnline = useOnlineStatus(); + const isNetworkOnline = useOnlineStatus(); const filteredAccounts = useFiltersStore((s) => s.accounts); const showAccountHeader = useSettingsStore((s) => s.showAccountHeader); @@ -35,7 +35,13 @@ export function NotificationsRoute() { [visibleNotifications], ); - if (!isOnline || status === 'offline') { + // The two conditions cover different orderings of the same transition: + // `!isNetworkOnline` is the device state before the query pauses, while + // `isNotificationsOffline` is a paused query after the network flag has + // already flipped back online. Keep both so neither ordering flashes. + const isNotificationsOffline = status === 'offline'; + + if (!isNetworkOnline || isNotificationsOffline) { return ; }