Skip to content

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

Go

fix(issues): move Restore to inbox into the issue's more-actions menu (#9883)

Jiayuan Zhangfbb8aac62059
diff --git a/packages/views/issues/components/issue-inbox-restore-button.test.tsx b/packages/views/issues/actions/__tests__/inbox-restore.test.tsx
similarity index 53%
rename from packages/views/issues/components/issue-inbox-restore-button.test.tsx
rename to packages/views/issues/actions/__tests__/inbox-restore.test.tsx
index a4164f3272..5d1ed16a29 100644
--- a/packages/views/issues/components/issue-inbox-restore-button.test.tsx
+++ b/packages/views/issues/actions/__tests__/inbox-restore.test.tsx
@@ -5,15 +5,34 @@ 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";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from "@multica/ui/components/ui/dropdown-menu";
+import { RESOURCES } from "../../../locales";
+import { InboxRestoreMenuItem, useArchivedInboxItemId } from "../inbox-restore";
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[]) {
+function Harness({ enabled }: { enabled: boolean }) {
+ const itemId = useArchivedInboxItemId("issue-1", enabled);
+ return (
+ <DropdownMenu open>
+ <DropdownMenuTrigger>more</DropdownMenuTrigger>
+ <DropdownMenuContent>
+ <DropdownMenuItem>Pin to sidebar</DropdownMenuItem>
+ {itemId && <InboxRestoreMenuItem itemId={itemId} Item={DropdownMenuItem} />}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+}
+
+function setup(archived: InboxItem[], enabled = true) {
let rows = archived;
const listArchivedInboxPage = vi.fn(async (_filters: unknown, options: { groupId?: string }) => ({
items: rows.filter((row) => row.issue_id === options.groupId),
@@ -34,7 +53,7 @@ function setup(archived: InboxItem[]) {
render(
<QueryClientProvider client={qc}>
<I18nProvider locale="en" resources={RESOURCES}>
- <IssueInboxRestoreButton issueId="issue-1" />
+ <Harness enabled={enabled} />
</I18nProvider>
</QueryClientProvider>,
);
@@ -43,18 +62,26 @@ function setup(archived: InboxItem[]) {
afterEach(cleanup);
-describe("IssueInboxRestoreButton", () => {
- it("stays hidden when the issue is not archived in the reader's inbox", async () => {
+describe("inbox restore menu entry", () => {
+ it("is absent 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();
+ await screen.findByRole("menuitem", { name: "Pin to sidebar" });
+ expect(screen.queryByRole("menuitem", { name: "Restore to inbox" })).toBeNull();
+ });
+
+ it("skips the lookup when the host owns inbox actions", async () => {
+ const api = setup([notification({})], false);
+ await screen.findByRole("menuitem", { name: "Pin to sidebar" });
+ expect(api.listArchivedInboxPage).not.toHaveBeenCalled();
+ expect(screen.queryByRole("menuitem", { name: "Restore to inbox" })).toBeNull();
});
- it("restores the archived notification and hides itself", async () => {
+ it("restores the archived notification and drops the entry", async () => {
const api = setup([notification({})]);
- fireEvent.click(await screen.findByRole("button", { name: "Restore to inbox" }));
+ fireEvent.click(await screen.findByRole("menuitem", { name: "Restore to inbox" }));
await waitFor(() => expect(api.unarchiveInbox).toHaveBeenCalledWith("item-1"));
- await waitFor(() => expect(screen.queryByRole("button")).toBeNull());
+ await waitFor(() => expect(screen.queryByRole("menuitem", { name: "Restore to inbox" })).toBeNull());
});
});
diff --git a/packages/views/issues/components/issue-inbox-restore-button.tsx b/packages/views/issues/actions/inbox-restore.tsx
similarity index 56%
rename from packages/views/issues/components/issue-inbox-restore-button.tsx
rename to packages/views/issues/actions/inbox-restore.tsx
index de72d88752..b2480fad88 100644
--- a/packages/views/issues/components/issue-inbox-restore-button.tsx
+++ b/packages/views/issues/actions/inbox-restore.tsx
@@ -5,31 +5,31 @@ import { ArchiveRestore } from "@multica/ui/icons";
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 type { MenuPrimitives } from "./issue-actions-menu-items";
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");
+/** The reader's archived inbox notification for this issue, if any. An issue
+ * opened from search or a link has no other way out of Inbox → Archived. */
+export function useArchivedInboxItemId(issueId: string, enabled: boolean): string | undefined {
const wsId = useWorkspaceId();
// Every inbox event refetches this lookup, so a hidden page skips it like the unread summary does.
+ // The host calls this rather than the lazily mounted menu, so the entry doesn't pop in after opening.
const { data } = useQuery({
...archivedInboxLookupOptions(wsId, issueId),
- enabled: () => focusManager.isFocused(),
+ enabled: () => enabled && focusManager.isFocused(),
refetchOnWindowFocus: true,
});
- const unarchive = useUnarchiveInbox();
- const item = data?.items.find((i) => i.archived);
- if (!item) return null;
+ return enabled ? data?.items.find((i) => i.archived)?.id : undefined;
+}
+export function InboxRestoreMenuItem({ itemId, Item }: { itemId: string; Item: MenuPrimitives["Item"] }) {
+ const { t } = useT("issues");
+ const { t: tInbox } = useT("inbox");
+ const unarchive = useUnarchiveInbox();
return (
- <IconButton
- label={t(($) => $.detail.restore_to_inbox_tooltip)}
- tooltipSide="bottom"
- className="text-muted-foreground"
+ <Item
onClick={() =>
- unarchive.mutate(item.id, {
+ unarchive.mutate(itemId, {
onSuccess: () => toast.success(tInbox(($) => $.toasts.unarchived)),
onError: (err) =>
toast.error(
@@ -40,7 +40,8 @@ export function IssueInboxRestoreButton({ issueId }: { issueId: string }) {
})
}
>
- <ArchiveRestore />
- </IconButton>
+ <ArchiveRestore className="h-3.5 w-3.5" />
+ {t(($) => $.actions.restore_to_inbox)}
+ </Item>
);
}
diff --git a/packages/views/issues/actions/index.ts b/packages/views/issues/actions/index.ts
index 0e1cfb5427..2fdfd2717a 100644
--- a/packages/views/issues/actions/index.ts
+++ b/packages/views/issues/actions/index.ts
@@ -1,6 +1,7 @@
export { useIssueActions } from "./use-issue-actions";
export type { UseIssueActionsResult } from "./use-issue-actions";
export { IssueActionsDropdown } from "./issue-actions-dropdown";
+export { useArchivedInboxItemId } from "./inbox-restore";
export {
IssueActionsContextMenu,
IssueContextMenuProvider,
diff --git a/packages/views/issues/actions/issue-actions-dropdown.tsx b/packages/views/issues/actions/issue-actions-dropdown.tsx
index ad241c829c..9d42f00672 100644
--- a/packages/views/issues/actions/issue-actions-dropdown.tsx
+++ b/packages/views/issues/actions/issue-actions-dropdown.tsx
@@ -21,6 +21,8 @@ interface IssueActionsDropdownProps {
/** If set, leave the page after the issue is deleted — back to wherever the
* user came from, or to this path when there is no in-app history. */
onDeletedFallbackPath?: string;
+ /** The reader's archived inbox notification for this issue; adds "Restore to inbox". */
+ archivedInboxItemId?: string;
}
export function IssueActionsDropdown({
@@ -28,6 +30,7 @@ export function IssueActionsDropdown({
trigger,
align = "end",
onDeletedFallbackPath,
+ archivedInboxItemId,
}: IssueActionsDropdownProps) {
const actions = useIssueActions(issue);
const [open, setOpen] = useState(false);
@@ -42,6 +45,7 @@ export function IssueActionsDropdown({
primitives={dropdownPrimitives}
onClose={() => setOpen(false)}
onDeletedFallbackPath={onDeletedFallbackPath}
+ archivedInboxItemId={archivedInboxItemId}
/>
</DropdownMenuContent>
</DropdownMenu>
diff --git a/packages/views/issues/actions/issue-actions-menu-items.tsx b/packages/views/issues/actions/issue-actions-menu-items.tsx
index dc7d2827d1..cdf8f078cb 100644
--- a/packages/views/issues/actions/issue-actions-menu-items.tsx
+++ b/packages/views/issues/actions/issue-actions-menu-items.tsx
@@ -63,6 +63,7 @@ import {
} from "@multica/ui/components/ui/context-menu";
import { copyText } from "@multica/ui/lib/clipboard";
import type { UseIssueActionsResult } from "./use-issue-actions";
+import { InboxRestoreMenuItem } from "./inbox-restore";
import { PluginHookMenuItems, PluginModalMenuItems } from "../../plugins";
import { useT } from "../../i18n";
@@ -108,6 +109,8 @@ interface IssueActionsMenuItemsProps {
* to the list the user came from and only falls back to this path when
* there is no in-app history. List surfaces leave it unset and stay put. */
onDeletedFallbackPath?: string;
+ /** The reader's archived inbox notification for this issue; adds "Restore to inbox". */
+ archivedInboxItemId?: string;
/** `sidebar` is the trimmed menu for sidebar rows, where only the title is
* visible: it names the issue in a header, shows current values beside
* Status / Priority / Assignee, and keeps only triage and navigation
@@ -124,6 +127,7 @@ export function IssueActionsMenuItems({
primitives: P,
onClose,
onDeletedFallbackPath,
+ archivedInboxItemId,
variant = "full",
onStopRun,
}: IssueActionsMenuItemsProps) {
@@ -415,6 +419,7 @@ export function IssueActionsMenuItems({
)}
{isPinned ? t(($) => $.actions.unpin_from_sidebar) : t(($) => $.actions.pin_to_sidebar)}
</P.Item>
+ {archivedInboxItemId && <InboxRestoreMenuItem itemId={archivedInboxItemId} Item={P.Item} />}
{sidebar &&
(unread ? (
<P.Item onClick={() => markRead(issue.id)}>
diff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsx
index e702917769..f4c8e84302 100644
--- a/packages/views/issues/components/issue-detail.tsx
+++ b/packages/views/issues/components/issue-detail.tsx
@@ -92,7 +92,7 @@ import { AssigneePicker } from "./pickers/assignee-picker";
import { LabelPicker } from "./pickers/label-picker";
import { CustomPropertyValueEditor, CustomPropertyValueDisplay } from "./pickers/custom-property-picker";
import { Switch } from "@multica/ui/components/ui/switch";
-import { IssueActionsDropdown, useIssueActions, IssueActionsContextMenu, IssueContextMenuProvider } from "../actions";
+import { IssueActionsDropdown, useIssueActions, useArchivedInboxItemId, IssueActionsContextMenu, IssueContextMenuProvider } from "../actions";
import { LabelChip } from "../../labels/label-chip";
import { IssueAgentActivityIndicator } from "./issue-agent-activity-indicator";
import { SubIssuesAgentWorkingChip } from "./sub-issues-agent-working-chip";
@@ -113,7 +113,6 @@ 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";
@@ -2566,6 +2565,8 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
// Called before the `if (!issue)` early return so hook order stays stable.
const actions = useIssueActions(issue);
const handleUpdateField = actions.updateField;
+ // The inbox passes `onDone` and owns archive and restore there.
+ const archivedInboxItemId = useArchivedInboxItemId(id, !onDone);
// Labels live in their own query (not on the issue body) — fetch the count
// here so seeding can decide whether the "Labels" optional row should be
@@ -3240,8 +3241,6 @@ 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
@@ -3298,6 +3297,7 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
// above and skip navigation. Otherwise the modal takes us back
// to the list we came from, falling back to all issues.
onDeletedFallbackPath={onDelete ? undefined : paths.issues()}
+ archivedInboxItemId={archivedInboxItemId}
trigger={
<IconButton
label={tCommon(($) => $.more_actions)}
diff --git a/packages/views/locales/en/issues.json b/packages/views/locales/en/issues.json
index 9f0625c0ef..03211a2f5b 100644
--- a/packages/views/locales/en/issues.json
+++ b/packages/views/locales/en/issues.json
@@ -536,7 +536,6 @@
"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",
@@ -971,6 +970,7 @@
"open_in_new_tab": "Open in new tab",
"pin_to_sidebar": "Pin to sidebar",
"unpin_from_sidebar": "Unpin from sidebar",
+ "restore_to_inbox": "Restore to inbox",
"mark_read": "Mark as read",
"mark_unread": "Mark as unread",
"copy_link": "Copy link",
diff --git a/packages/views/locales/fr/issues.json b/packages/views/locales/fr/issues.json
index 21e0f5dec1..874cb67c15 100644
--- a/packages/views/locales/fr/issues.json
+++ b/packages/views/locales/fr/issues.json
@@ -536,7 +536,6 @@
"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",
@@ -971,6 +970,7 @@
"open_in_new_tab": "Ouvrir dans un nouvel onglet",
"pin_to_sidebar": "Épingler à la barre latérale",
"unpin_from_sidebar": "Détacher de la barre latérale",
+ "restore_to_inbox": "Restaurer dans la boîte de réception",
"mark_read": "Marquer comme lu",
"mark_unread": "Marquer comme non lu",
"copy_link": "Copier le lien",
diff --git a/packages/views/locales/ja/issues.json b/packages/views/locales/ja/issues.json
index d05f62d4d5..0374cccbc0 100644
--- a/packages/views/locales/ja/issues.json
+++ b/packages/views/locales/ja/issues.json
@@ -529,7 +529,6 @@
"agents_group": "エージェント",
"mark_done_tooltip": "完了にする",
"archive_tooltip": "アーカイブ",
- "restore_to_inbox_tooltip": "インボックスに戻す",
"pin_tooltip": "サイドバーにピン留め",
"unpin_tooltip": "サイドバーのピン留めを解除",
"quick_jump_label": "クイックナビゲーション",
@@ -926,6 +925,7 @@
"open_in_new_tab": "新しいタブで開く",
"pin_to_sidebar": "サイドバーにピン留め",
"unpin_from_sidebar": "サイドバーのピン留めを解除",
+ "restore_to_inbox": "インボックスに戻す",
"mark_read": "既読にする",
"mark_unread": "未読にする",
"copy_link": "リンクをコピー",
diff --git a/packages/views/locales/ko/issues.json b/packages/views/locales/ko/issues.json
index 0b36972744..f8e3b1ff84 100644
--- a/packages/views/locales/ko/issues.json
+++ b/packages/views/locales/ko/issues.json
@@ -529,7 +529,6 @@
"agents_group": "에이전트",
"mark_done_tooltip": "완료로 표시",
"archive_tooltip": "보관",
- "restore_to_inbox_tooltip": "인박스로 복원",
"pin_tooltip": "사이드바에 고정",
"unpin_tooltip": "사이드바 고정 해제",
"quick_jump_label": "빠른 탐색",
@@ -926,6 +925,7 @@
"open_in_new_tab": "새 탭에서 열기",
"pin_to_sidebar": "사이드바에 고정",
"unpin_from_sidebar": "사이드바 고정 해제",
+ "restore_to_inbox": "인박스로 복원",
"mark_read": "읽음으로 표시",
"mark_unread": "읽지 않음으로 표시",
"copy_link": "링크 복사",
diff --git a/packages/views/locales/zh-Hans/issues.json b/packages/views/locales/zh-Hans/issues.json
index f488f01822..94c12dcde2 100644
--- a/packages/views/locales/zh-Hans/issues.json
+++ b/packages/views/locales/zh-Hans/issues.json
@@ -527,7 +527,6 @@
"agents_group": "智能体",
"mark_done_tooltip": "标记为已完成",
"archive_tooltip": "归档",
- "restore_to_inbox_tooltip": "恢复到收件箱",
"pin_tooltip": "固定到侧边栏",
"unpin_tooltip": "从侧边栏取消固定",
"quick_jump_label": "快捷跳转",
@@ -926,6 +925,7 @@
"open_in_new_tab": "在新标签页打开",
"pin_to_sidebar": "固定到侧边栏",
"unpin_from_sidebar": "从侧边栏取消固定",
+ "restore_to_inbox": "恢复到收件箱",
"mark_read": "标为已读",
"mark_unread": "标为未读",
"copy_link": "复制链接",
diff --git a/packages/views/locales/zh-Hant/issues.json b/packages/views/locales/zh-Hant/issues.json
index e21c22fa2e..0619d59c9f 100644
--- a/packages/views/locales/zh-Hant/issues.json
+++ b/packages/views/locales/zh-Hant/issues.json
@@ -527,7 +527,6 @@
"agents_group": "AI 代理",
"mark_done_tooltip": "標記為已完成",
"archive_tooltip": "歸檔",
- "restore_to_inbox_tooltip": "恢復到收件箱",
"pin_tooltip": "固定到側邊欄",
"unpin_tooltip": "從側邊欄取消固定",
"quick_jump_label": "快捷跳轉",
@@ -926,6 +925,7 @@
"open_in_new_tab": "在新標籤頁開啟",
"pin_to_sidebar": "固定到側邊欄",
"unpin_from_sidebar": "從側邊欄取消固定",
+ "restore_to_inbox": "恢復到收件箱",
"mark_read": "標為已讀",
"mark_unread": "標為未讀",
"copy_link": "複製連結",