Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(inbox): show a retry state when Snoozed fails to load (#11048)

Frezc4593bd313b00
diff --git a/apps/docs/content/docs/inbox.fr.mdx b/apps/docs/content/docs/inbox.fr.mdx
index 98183278ba..e771bcb198 100644
--- a/apps/docs/content/docs/inbox.fr.mdx
+++ b/apps/docs/content/docs/inbox.fr.mdx
@@ -127,6 +127,8 @@ Tant qu'une tâche est reportée :
Le report est personnel : il ne change que votre boîte de réception. Tout ce que vous avez reporté se trouve dans la vue **Reportés** sous Vues, aussi accessible via **Voir les reportés** dans le menu de la boîte de réception.
+Si la vue Reportés ne se charge pas, sélectionnez **Réessayer**. Les éléments déjà chargés restent visibles si l'actualisation échoue.
+
## Quand une notification quitte la boîte de réception
Lire une notification ne la retire pas. Une ligne quitte la boîte de réception uniquement :
diff --git a/apps/docs/content/docs/inbox.ja.mdx b/apps/docs/content/docs/inbox.ja.mdx
index d000c857b3..8c939e6c7e 100644
--- a/apps/docs/content/docs/inbox.ja.mdx
+++ b/apps/docs/content/docs/inbox.ja.mdx
@@ -127,6 +127,8 @@ multica inbox snooze <id>... --until tomorrow # RFC 3339、30m、3h、1d、1w
スヌーズは自分のインボックスだけに影響します。スヌーズ中のタスクは Views の **スヌーズ中** ビュー、またはインボックスメニューの **スヌーズ中を表示** から確認できます。
+スヌーズ中ビューを読み込めない場合は、 **再試行** を選びます。更新に失敗しても、読み込み済みの項目は表示されたままです。
+
## 通知がインボックスから外れるとき
既読にしても通知はインボックスから消えません。行が外れるのは次の場合だけです。
diff --git a/apps/docs/content/docs/inbox.ko.mdx b/apps/docs/content/docs/inbox.ko.mdx
index 15c7435815..ba6a45d12e 100644
--- a/apps/docs/content/docs/inbox.ko.mdx
+++ b/apps/docs/content/docs/inbox.ko.mdx
@@ -127,6 +127,8 @@ multica inbox snooze <id>... --until tomorrow # RFC 3339, 30m, 3h, 1d, 1w; uns
미루기는 내 인박스에만 영향을 줍니다. 미뤄둔 태스크는 Views의 **미뤄둔 항목** 뷰나 인박스 메뉴의 **미뤄둔 항목 보기**에서 볼 수 있습니다.
+미뤄둔 항목을 불러오지 못하면 **다시 시도** 를 선택하세요. 새로고침에 실패해도 이미 불러온 항목은 계속 표시됩니다.
+
## 알림이 인박스에서 빠지는 경우
읽어도 알림은 인박스에서 사라지지 않습니다. 행이 빠지는 경우는 다음뿐입니다.
diff --git a/apps/docs/content/docs/inbox.mdx b/apps/docs/content/docs/inbox.mdx
index 954b33d70d..8ac2a8f125 100644
--- a/apps/docs/content/docs/inbox.mdx
+++ b/apps/docs/content/docs/inbox.mdx
@@ -127,6 +127,8 @@ While an issue is snoozed:
Snooze is personal: it only changes your own inbox. Everything you've snoozed is in the **Snoozed** view under Views, also reachable from **View snoozed** in the inbox menu.
+If the Snoozed view can't load, choose **Retry**. Previously loaded items stay visible if a refresh fails.
+
## When a notification leaves the inbox
Reading a notification doesn't remove it. A row leaves the inbox only when:
diff --git a/apps/docs/content/docs/inbox.zh-Hant.mdx b/apps/docs/content/docs/inbox.zh-Hant.mdx
index b8ed6b983b..740f84bf2e 100644
--- a/apps/docs/content/docs/inbox.zh-Hant.mdx
+++ b/apps/docs/content/docs/inbox.zh-Hant.mdx
@@ -127,6 +127,8 @@ multica inbox snooze <id>... --until tomorrow # RFC 3339、30m、3h、1d、1w
延後只影響你自己的收件箱。所有延後的任務都在檢視裡的 **已延後** 中,也可以從收件箱選單的 **查看已延後** 進入。
+如果已延後檢視無法載入,可以點擊 **重試**。重新整理失敗時,已載入的任務會繼續顯示。
+
## 通知何時離開收件箱
通知不會因為已讀而離開收件箱。只有以下幾種情況,一列才會移出:
diff --git a/apps/docs/content/docs/inbox.zh.mdx b/apps/docs/content/docs/inbox.zh.mdx
index 9ddf2030c9..b26771947c 100644
--- a/apps/docs/content/docs/inbox.zh.mdx
+++ b/apps/docs/content/docs/inbox.zh.mdx
@@ -127,6 +127,8 @@ multica inbox snooze <id>... --until tomorrow # RFC 3339、30m、3h、1d、1w
延后只影响你自己的收件箱。所有延后的任务都在视图里的 **已延后** 中,也可以从收件箱菜单的 **查看已延后** 进入。
+如果已延后视图无法加载,可以点击 **重试**。刷新失败时,已加载的任务会继续显示。
+
## 通知何时离开收件箱
通知不会因为已读而离开收件箱。只有以下几种情况,一行才会移出:
diff --git a/packages/views/inbox/components/snoozed-inbox-page.test.tsx b/packages/views/inbox/components/snoozed-inbox-page.test.tsx
index 38b58b6a29..07ae68b2c1 100644
--- a/packages/views/inbox/components/snoozed-inbox-page.test.tsx
+++ b/packages/views/inbox/components/snoozed-inbox-page.test.tsx
@@ -1,6 +1,7 @@
-import { fireEvent, screen } from "@testing-library/react";
+import { act, fireEvent, screen, waitFor } from "@testing-library/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { beforeEach, describe, expect, it, vi } from "vitest";
+import { ApiError } from "@multica/core/api/client";
import { snoozedInboxOptions } from "@multica/core/inbox/queries";
import { issueDetailOptions } from "@multica/core/issues/queries";
import type { Issue, SnoozedInboxIssue } from "@multica/core/types";
@@ -9,11 +10,16 @@ import { NavigationProvider, type NavigationAdapter } from "../../navigation";
import { SnoozedInboxPage } from "./snoozed-inbox-page";
const state = vi.hoisted(() => ({
+ listSnoozed: vi.fn<() => Promise<SnoozedInboxIssue[]>>(),
snooze: vi.fn(() => Promise.resolve()),
unsnooze: vi.fn(() => Promise.resolve()),
}));
vi.mock("sonner", () => ({ toast: { success: vi.fn(), error: vi.fn() } }));
+vi.mock("@multica/core/api", async (importOriginal) => {
+ const actual = await importOriginal<typeof import("@multica/core/api")>();
+ return { ...actual, api: { ...actual.api, listSnoozedInbox: state.listSnoozed } };
+});
vi.mock("@multica/core/hooks", async (importOriginal) => ({
...(await importOriginal<typeof import("@multica/core/hooks")>()),
useWorkspaceId: () => "ws-1",
@@ -40,10 +46,10 @@ function entry(issueId: string, until: Date, updates = 0): SnoozedInboxIssue {
};
}
-function renderPage(snoozed: SnoozedInboxIssue[]) {
+function renderPage(snoozed?: SnoozedInboxIssue[]) {
const client = new QueryClient({ defaultOptions: { queries: { retry: false, staleTime: Infinity } } });
- client.setQueryData(snoozedInboxOptions("ws-1").queryKey, snoozed);
- for (const { issue_id } of snoozed) {
+ if (snoozed !== undefined) client.setQueryData(snoozedInboxOptions("ws-1").queryKey, snoozed);
+ for (const { issue_id } of snoozed ?? []) {
client.setQueryData(issueDetailOptions("ws-1", issue_id).queryKey, {
id: issue_id,
identifier: `MUL-${issue_id.slice(-1)}`,
@@ -67,10 +73,11 @@ function renderPage(snoozed: SnoozedInboxIssue[]) {
</NavigationProvider>
</QueryClientProvider>,
);
- return nav;
+ return { client, nav };
}
beforeEach(() => {
+ state.listSnoozed.mockReset();
state.snooze.mockClear();
state.unsnooze.mockClear();
});
@@ -95,13 +102,13 @@ describe("SnoozedInboxPage", () => {
// A UUID address is rewritten to the identifier once the issue loads, which
// mounts the issue page a second time on web.
it("opens an issue at its identifier", () => {
- const nav = renderPage([{ ...entry("issue-1", new Date(Date.now() + HOUR)), issue_identifier: "MUL-41" }]);
+ const { nav } = renderPage([{ ...entry("issue-1", new Date(Date.now() + HOUR)), issue_identifier: "MUL-41" }]);
fireEvent.click(screen.getByText("Issue issue-1"));
expect(nav.push).toHaveBeenCalledWith("/acme/issues/MUL-41");
});
it("takes the identifier from the loaded issue when the server sent none", () => {
- const nav = renderPage([entry("issue-2", new Date(Date.now() + HOUR))]);
+ const { nav } = renderPage([entry("issue-2", new Date(Date.now() + HOUR))]);
fireEvent.click(screen.getByText("Issue issue-2"));
expect(nav.push).toHaveBeenCalledWith("/acme/issues/MUL-2");
});
@@ -110,4 +117,34 @@ describe("SnoozedInboxPage", () => {
renderPage([]);
expect(screen.getByText("Nothing snoozed")).toBeInTheDocument();
});
+
+ it("lets the viewer retry a failed load before showing the empty state", async () => {
+ let completeRetry!: (issues: SnoozedInboxIssue[]) => void;
+ const pendingRetry = new Promise<SnoozedInboxIssue[]>((resolve) => {
+ completeRetry = resolve;
+ });
+ state.listSnoozed
+ .mockRejectedValueOnce(new ApiError("Temporarily unavailable", 503, "Service Unavailable"))
+ .mockReturnValueOnce(pendingRetry);
+ renderPage();
+
+ expect(await screen.findByRole("alert")).toHaveTextContent("Failed to load notifications");
+ expect(screen.queryByText("Nothing snoozed")).toBeNull();
+ const retry = screen.getByRole("button", { name: "Retry" });
+ fireEvent.click(retry);
+ await waitFor(() => expect(retry).toBeDisabled());
+ expect(screen.getByRole("alert")).toBeInTheDocument();
+ completeRetry([]);
+ expect(await screen.findByText("Nothing snoozed")).toBeInTheDocument();
+ });
+
+ it("keeps loaded items visible when a background refresh fails", async () => {
+ state.listSnoozed.mockRejectedValueOnce(new ApiError("Temporarily unavailable", 503, "Service Unavailable"));
+ const { client } = renderPage([entry("issue-1", new Date(Date.now() + HOUR))]);
+ await act(() => client.invalidateQueries({ queryKey: snoozedInboxOptions("ws-1").queryKey }));
+
+ expect(state.listSnoozed).toHaveBeenCalledTimes(1);
+ expect(screen.getByText("Issue issue-1")).toBeInTheDocument();
+ expect(screen.queryByRole("alert")).toBeNull();
+ });
});
diff --git a/packages/views/inbox/components/snoozed-inbox-page.tsx b/packages/views/inbox/components/snoozed-inbox-page.tsx
index b0119a604c..b9f8837f92 100644
--- a/packages/views/inbox/components/snoozed-inbox-page.tsx
+++ b/packages/views/inbox/components/snoozed-inbox-page.tsx
@@ -25,6 +25,7 @@ import { useBuiltinViewLabel } from "../../issue-views/builtin-views";
import { useLocale, useT } from "../../i18n";
import { InboxSnoozeMenu } from "./inbox-snooze-menu";
import { formatSnoozeTime } from "./inbox-snooze-time";
+import { inboxListLoad } from "./use-filtered-inbox-rows";
import { useInboxSnooze } from "./use-inbox-snooze";
const DAY_MS = 24 * 60 * 60 * 1000;
@@ -59,7 +60,9 @@ export function SnoozedInboxPage() {
const qc = useQueryClient();
const locale = useLocale();
const title = useBuiltinViewLabel()("snoozed");
- const { data: snoozed, isLoading } = useQuery(snoozedInboxOptions(wsId));
+ const snoozedQuery = useQuery(snoozedInboxOptions(wsId));
+ const snoozed = snoozedQuery.data;
+ const load = inboxListLoad(snoozedQuery);
const { snooze, unsnooze } = useInboxSnooze();
const groups = useMemo<CollectionGroup<SnoozedInboxIssue>[]>(() => {
@@ -126,7 +129,19 @@ export function SnoozedInboxPage() {
return (
<div className="flex flex-1 min-h-0 flex-col">
<CollectionPageHeader icon={AlarmClock} title={title} />
- {isLoading ? (
+ {load === "failed" ? (
+ <CollectionPageState
+ icon={AlarmClock}
+ tone="warning"
+ role="alert"
+ title={t(($) => $.errors.load_failed)}
+ actions={
+ <Button variant="outline" disabled={snoozedQuery.isFetching} onClick={() => void snoozedQuery.refetch()}>
+ {t(($) => $.list.retry)}
+ </Button>
+ }
+ />
+ ) : load === "loading" ? (
<div className="space-y-2 p-4">
{Array.from({ length: 4 }).map((_, i) => (
<Skeleton key={i} className="h-8 w-full" />