Skip to content

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

Go

fix(issues): restore an archived inbox notification from the issue page (#9653)

Spedymax39d8a11970dd
diff --git a/apps/ui-lab/src/product-fixtures.ts b/apps/ui-lab/src/product-fixtures.ts
index d7a2f70f32..d45d033e9e 100644
--- a/apps/ui-lab/src/product-fixtures.ts
+++ b/apps/ui-lab/src/product-fixtures.ts
@@ -330,6 +330,7 @@ export function createFixtureApi(getLocale: () => LabLocale = () => "en") {
listPins: async () => [],
listMyInvitations: async () => [],
getInboxUnreadSummary: async () => [],
+ listArchivedInboxPage: async () => ({ items: [], hasMore: false, nextCursor: null }),
getUnreadInboxCount: async () => ({ count: 0 }),
listChatSessions: async () => [],
listIssueViews: async () => [],
diff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsx
index e1eed695cf..88d46beeb3 100644
--- a/packages/views/issues/components/issue-detail.tsx
+++ b/packages/views/issues/components/issue-detail.tsx
@@ -112,6 +112,7 @@ import { ThreadMinimap, type ThreadMinimapThread } from "./thread-minimap";
import { collectThreadParticipants, collectThreadReplies, deriveThreadResolution } from "./thread-utils";
import { IssueAgentHeaderChip } from "./issue-agent-header-chip";
import { IssueWakeupHeaderChip } from "./issue-wakeup-header-chip";
+import { IssueInboxRestoreButton } from "./issue-inbox-restore-button";
import { ExecutionLogSection } from "./execution-log-section";
import { WakeupsSection } from "./wakeups-section";
import { QuickActionsSection } from "./quick-actions-section";
@@ -3231,6 +3232,8 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
It self-hides when no agent is active. */}
<IssueAgentHeaderChip issueId={id} onJumpToRun={jumpToRun} />
<IssueWakeupHeaderChip issueId={id} onOpen={openWakeups} />
+ {/* The inbox passes `onDone` and owns archive and restore there. */}
+ {!onDone && <IssueInboxRestoreButton issueId={id} />}
{onDone && !issueBehavesAsAny(issue, ["done", "closed"]) && (
<Tooltip>
<TooltipTrigger
diff --git a/packages/views/issues/components/issue-inbox-restore-button.test.tsx b/packages/views/issues/components/issue-inbox-restore-button.test.tsx
new file mode 100644
index 0000000000..a4164f3272
--- /dev/null
+++ b/packages/views/issues/components/issue-inbox-restore-button.test.tsx
@@ -0,0 +1,60 @@
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { I18nProvider } from "@multica/core/i18n/react";
+import { setApiInstance } from "@multica/core/api";
+import type { ApiClient } from "@multica/core/api/client";
+import type { InboxItem } from "@multica/core/types";
+import { RESOURCES } from "../../locales";
+import { IssueInboxRestoreButton } from "./issue-inbox-restore-button";
+
+vi.mock("sonner", () => ({ toast: { success: vi.fn(), error: vi.fn() } }));
+vi.mock("@multica/core/hooks", () => ({ useWorkspaceId: () => "ws" }));
+
+const notification = (patch: Partial<InboxItem>) => ({ id: "item-1", issue_id: "issue-1", archived: true, ...patch }) as InboxItem;
+
+function setup(archived: InboxItem[]) {
+ let rows = archived;
+ const listArchivedInboxPage = vi.fn(async (_filters: unknown, options: { groupId?: string }) => ({
+ items: rows.filter((row) => row.issue_id === options.groupId),
+ hasMore: false,
+ nextCursor: null,
+ }));
+ const unarchiveInbox = vi.fn(async (id: string) => {
+ rows = rows.filter((row) => row.id !== id);
+ return notification({ id, archived: false });
+ });
+ setApiInstance({
+ listArchivedInboxPage,
+ unarchiveInbox,
+ listInbox: async () => [],
+ getInboxUnreadSummary: async () => [],
+ } as unknown as ApiClient);
+ const qc = new QueryClient({ defaultOptions: { queries: { retry: false, staleTime: Infinity } } });
+ render(
+ <QueryClientProvider client={qc}>
+ <I18nProvider locale="en" resources={RESOURCES}>
+ <IssueInboxRestoreButton issueId="issue-1" />
+ </I18nProvider>
+ </QueryClientProvider>,
+ );
+ return { listArchivedInboxPage, unarchiveInbox };
+}
+
+afterEach(cleanup);
+
+describe("IssueInboxRestoreButton", () => {
+ it("stays hidden when the issue is not archived in the reader's inbox", async () => {
+ const api = setup([]);
+ await waitFor(() => expect(api.listArchivedInboxPage).toHaveBeenCalled());
+ expect(api.listArchivedInboxPage.mock.calls[0]![1]).toMatchObject({ groupId: "issue-1" });
+ expect(screen.queryByRole("button")).toBeNull();
+ });
+
+ it("restores the archived notification and hides itself", async () => {
+ const api = setup([notification({})]);
+ fireEvent.click(await screen.findByRole("button", { name: "Restore to inbox" }));
+ await waitFor(() => expect(api.unarchiveInbox).toHaveBeenCalledWith("item-1"));
+ await waitFor(() => expect(screen.queryByRole("button")).toBeNull());
+ });
+});
diff --git a/packages/views/issues/components/issue-inbox-restore-button.tsx b/packages/views/issues/components/issue-inbox-restore-button.tsx
new file mode 100644
index 0000000000..4ce070767e
--- /dev/null
+++ b/packages/views/issues/components/issue-inbox-restore-button.tsx
@@ -0,0 +1,46 @@
+"use client";
+
+import { focusManager, useQuery } from "@tanstack/react-query";
+import { ArchiveRestore } from "lucide-react";
+import { toast } from "sonner";
+import { useWorkspaceId } from "@multica/core/hooks";
+import { archivedInboxLookupOptions, useUnarchiveInbox } from "@multica/core/inbox";
+import { IconButton } from "@multica/ui/components/common/icon-button";
+import { useT } from "../../i18n";
+
+// An issue opened from search or a link has no other way out of Inbox → Archived.
+export function IssueInboxRestoreButton({ issueId }: { issueId: string }) {
+ const { t } = useT("issues");
+ const { t: tInbox } = useT("inbox");
+ const wsId = useWorkspaceId();
+ // Every inbox event refetches this lookup, so a hidden page skips it like the unread summary does.
+ const { data } = useQuery({
+ ...archivedInboxLookupOptions(wsId, issueId),
+ enabled: () => focusManager.isFocused(),
+ refetchOnWindowFocus: true,
+ });
+ const unarchive = useUnarchiveInbox();
+ const item = data?.items.find((i) => i.archived);
+ if (!item) return null;
+
+ return (
+ <IconButton
+ label={t(($) => $.detail.restore_to_inbox_tooltip)}
+ tooltipSide="bottom"
+ className="text-muted-foreground"
+ onClick={() =>
+ unarchive.mutate(item.id, {
+ onSuccess: () => toast.success(tInbox(($) => $.toasts.unarchived)),
+ onError: (err) =>
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : tInbox(($) => $.errors.unarchive_failed),
+ ),
+ })
+ }
+ >
+ <ArchiveRestore />
+ </IconButton>
+ );
+}
diff --git a/packages/views/locales/en/issues.json b/packages/views/locales/en/issues.json
index 70d6e1e0c4..85de9f20c0 100644
--- a/packages/views/locales/en/issues.json
+++ b/packages/views/locales/en/issues.json
@@ -471,6 +471,7 @@
"agents_group": "Agents",
"mark_done_tooltip": "Mark as done",
"archive_tooltip": "Archive",
+ "restore_to_inbox_tooltip": "Restore to inbox",
"pin_tooltip": "Pin to sidebar",
"unpin_tooltip": "Unpin from sidebar",
"quick_jump_label": "Quick navigation",
diff --git a/packages/views/locales/fr/issues.json b/packages/views/locales/fr/issues.json
index 26ee7b4733..9551e06e30 100644
--- a/packages/views/locales/fr/issues.json
+++ b/packages/views/locales/fr/issues.json
@@ -470,6 +470,7 @@
"agents_group": "Agents",
"mark_done_tooltip": "Marquer comme terminé",
"archive_tooltip": "Archiver",
+ "restore_to_inbox_tooltip": "Restaurer dans la boîte de réception",
"pin_tooltip": "Épingler à la barre latérale",
"unpin_tooltip": "Détacher de la barre latérale",
"quick_jump_label": "Navigation rapide",
diff --git a/packages/views/locales/ja/issues.json b/packages/views/locales/ja/issues.json
index c84661a118..a304e77648 100644
--- a/packages/views/locales/ja/issues.json
+++ b/packages/views/locales/ja/issues.json
@@ -466,6 +466,7 @@
"agents_group": "エージェント",
"mark_done_tooltip": "完了にする",
"archive_tooltip": "アーカイブ",
+ "restore_to_inbox_tooltip": "インボックスに戻す",
"pin_tooltip": "サイドバーにピン留め",
"unpin_tooltip": "サイドバーのピン留めを解除",
"quick_jump_label": "クイックナビゲーション",
diff --git a/packages/views/locales/ko/issues.json b/packages/views/locales/ko/issues.json
index a304f85735..fabe001e3c 100644
--- a/packages/views/locales/ko/issues.json
+++ b/packages/views/locales/ko/issues.json
@@ -466,6 +466,7 @@
"agents_group": "에이전트",
"mark_done_tooltip": "완료로 표시",
"archive_tooltip": "보관",
+ "restore_to_inbox_tooltip": "인박스로 복원",
"pin_tooltip": "사이드바에 고정",
"unpin_tooltip": "사이드바 고정 해제",
"quick_jump_label": "빠른 탐색",
diff --git a/packages/views/locales/zh-Hans/issues.json b/packages/views/locales/zh-Hans/issues.json
index 4497e8f121..e91eadd777 100644
--- a/packages/views/locales/zh-Hans/issues.json
+++ b/packages/views/locales/zh-Hans/issues.json
@@ -464,6 +464,7 @@
"agents_group": "智能体",
"mark_done_tooltip": "标记为已完成",
"archive_tooltip": "归档",
+ "restore_to_inbox_tooltip": "恢复到收件箱",
"pin_tooltip": "固定到侧边栏",
"unpin_tooltip": "从侧边栏取消固定",
"quick_jump_label": "快捷跳转",
diff --git a/packages/views/locales/zh-Hant/issues.json b/packages/views/locales/zh-Hant/issues.json
index a149d63ff0..51bd8ec801 100644
--- a/packages/views/locales/zh-Hant/issues.json
+++ b/packages/views/locales/zh-Hant/issues.json
@@ -463,6 +463,7 @@
"agents_group": "智慧體",
"mark_done_tooltip": "標記為已完成",
"archive_tooltip": "歸檔",
+ "restore_to_inbox_tooltip": "恢復到收件箱",
"pin_tooltip": "固定到側邊欄",
"unpin_tooltip": "從側邊欄取消固定",
"quick_jump_label": "快捷跳轉",