Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(inbox): Z undoes the inline undo on the Inbox Zero screen (MUL-9822) (#11172)
Jiayuan Zhang18e5be6904c0
diff --git a/apps/docs/content/docs/inbox.mdx b/apps/docs/content/docs/inbox.mdxindex 4f1b89fd14..275864d16e 100644--- a/apps/docs/content/docs/inbox.mdx+++ b/apps/docs/content/docs/inbox.mdx@@ -139,7 +139,7 @@ Reading a notification doesn't remove it. A row leaves the inbox only when:Open windows drop an archived row right away, except the one you have open. When its notification leaves the inbox some other way (you set the issue to `done` from its status, another window archived it, or an edit took it out of the section's filters), the row stays lit where it was and the inbox bar says what happened. When a change you make from the bar archives the notification, the bar names it, as in *Changed to In Progress · Notification archived*, and keeps **Status**, **Assignee** and **Quick actions** for the next change. **Undo** (or `Z`) brings the notification back, and **Next** (or `E`) opens the next row. The row leaves once you move on. When it was the last notification in your inbox, the bar says **Inbox cleared** instead, with how many issues are snoozed, and offers **Go to My work** in place of **Next**; `E` opens the cleared inbox. That is **After archiving → Stay on the issue**, the default; with **Open the next one**, a change you make that archives the open notification opens the next row, or the cleared inbox, right away, and the confirmation offers **Undo**.-When you take the open row out yourself, from the inbox bar, its row, the hover card, or a bulk action that includes it, the next row opens instead. With nothing left to open, the inbox page opens on **Inbox cleared**. It names what you just did, with **Undo** to bring it back, shows how many issues are snoozed and when the next one returns, and links to **My work**, the agents that are working, and **View archived**. When filters hid the rest of your inbox, it says how many notifications are left and offers **Clear filters and continue** instead. Going back returns to the issue. Archiving and the bulk actions confirm with **Undo**, which brings the notifications back and leaves the issue's status as it is. Confirmations that offer **Undo**, for archiving, snoozing and unsubscribing alike, stay for 10 seconds, and while one shows, `Z` undoes that latest action.+When you take the open row out yourself, from the inbox bar, its row, the hover card, or a bulk action that includes it, the next row opens instead. With nothing left to open, the inbox page opens on **Inbox cleared**. It names what you just did, with **Undo** (or `Z`) to bring it back, shows how many issues are snoozed and when the next one returns, and links to **My work**, the agents that are working, and **View archived**. When filters hid the rest of your inbox, it says how many notifications are left and offers **Clear filters and continue** instead. Going back returns to the issue. Archiving and the bulk actions confirm with **Undo**, which brings the notifications back and leaves the issue's status as it is. Confirmations that offer **Undo**, for archiving, snoozing and unsubscribing alike, stay for 10 seconds, and while one shows, `Z` undoes that latest action.A later notification on the issue lands in the inbox again.diff --git a/apps/docs/content/docs/inbox.zh.mdx b/apps/docs/content/docs/inbox.zh.mdxindex c5b7f1616c..657fc3dfb8 100644--- a/apps/docs/content/docs/inbox.zh.mdx+++ b/apps/docs/content/docs/inbox.zh.mdx@@ -139,7 +139,7 @@ multica inbox snooze <id>... --until tomorrow # RFC 3339、30m、3h、1d、1w打开着的窗口会立即移除已归档的行,但你正打开的那一行除外。它的通知因为其他原因离开收件箱时(你在状态里把任务改为 `done`、别的窗口归档了它,或修改后不再符合分区的筛选),这一行会在原位保持高亮,收件箱栏会说明发生了什么。在栏里改**状态**、**负责人**或运行**快捷操作**后通知被归档时,栏会写明是哪一项,比如“已改为进行中 · 通知已归档”,这几个操作也留在栏里,可以接着改。**撤销**(或按 `Z`)让通知回来,**下一条**(或按 `E`)打开下一行。你离开之后,这一行才会移出。如果这是收件箱里的最后一条通知,栏会改为显示**收件箱已清空**和延后中的任务数,用**前往我的工作**代替**下一条**;按 `E` 会打开已清空的收件箱。这是**归档后 → 停在当前任务**(默认)的行为;选**打开下一条**时,你的操作归档了正打开的通知后,会直接打开下一行(没有下一行时打开已清空的收件箱),提示里可以**撤销**。-如果是你自己把正打开的这一行处理掉(在收件箱栏、它所在的行、悬停卡片,或包含它的批量操作里),会直接打开下一行;没有剩下的行时,会打开收件箱页面,显示**收件箱已清空**:写明你刚才的操作,可以**撤销**把它找回,显示延后中的任务数和下一条回来的时间,并提供**我的工作**、正在工作的智能体和**查看已归档**入口。如果是筛选隐藏了收件箱里的其余通知,会改为说明还剩多少条,并提供**清除筛选,继续处理**。返回上一页可以回到任务。归档和批量操作的提示里都可以**撤销**:通知会回来,任务的状态保持不变。带**撤销**的提示(归档、延后、取消订阅都一样)会停留 10 秒;提示还在时,按 `Z` 撤销这次操作。+如果是你自己把正打开的这一行处理掉(在收件箱栏、它所在的行、悬停卡片,或包含它的批量操作里),会直接打开下一行;没有剩下的行时,会打开收件箱页面,显示**收件箱已清空**:写明你刚才的操作,可以**撤销**(或按 `Z`)把它找回,显示延后中的任务数和下一条回来的时间,并提供**我的工作**、正在工作的智能体和**查看已归档**入口。如果是筛选隐藏了收件箱里的其余通知,会改为说明还剩多少条,并提供**清除筛选,继续处理**。返回上一页可以回到任务。归档和批量操作的提示里都可以**撤销**:通知会回来,任务的状态保持不变。带**撤销**的提示(归档、延后、取消订阅都一样)会停留 10 秒;提示还在时,按 `Z` 撤销这次操作。之后该任务再有新通知,会重新进入收件箱。diff --git a/apps/docs/content/docs/shortcuts.mdx b/apps/docs/content/docs/shortcuts.mdxindex 121a2a2242..62f51dfae1 100644--- a/apps/docs/content/docs/shortcuts.mdx+++ b/apps/docs/content/docs/shortcuts.mdx@@ -38,7 +38,7 @@ Selecting a result opens it. Hold `⌘` (`Ctrl` on Windows and Linux) while clic| Find in issue | `⌘F` | `Ctrl+F` | See below. || Archive notification | `E` | `E` | On an issue opened from the inbox, archives its notification and opens the next one. In archived notifications, restores the open one. See [Inbox](/inbox#handle-notifications). || Snooze notification | `H` | `H` | On an issue opened from the inbox, snoozes it and opens the next one. On a snoozed issue, brings it back now. See [Inbox](/inbox#snooze-an-issue). |-| Undo inbox action | `Z` | `Z` | While an archive, snooze or unsubscribe confirmation shows, undoes that action. Without one, puts back the open notification once it is archived. See [Inbox](/inbox#when-a-notification-leaves-the-inbox). |+| Undo inbox action | `Z` | `Z` | While an archive, snooze or unsubscribe confirmation shows, undoes that action. Without one, puts back the open notification once it is archived, or undoes what **Inbox cleared** names. See [Inbox](/inbox#when-a-notification-leaves-the-inbox). || Send | `⌘↵` | `Ctrl+Enter` | Sends comments and chat messages, and also submits new issues. || Voice input | Unassigned | Unassigned | Desktop only; turn it on first under Settings → Voice input. See [Voice input](/desktop-app#voice-input). || Go back | `⌘[` | `Ctrl+[` | |diff --git a/apps/docs/content/docs/shortcuts.zh.mdx b/apps/docs/content/docs/shortcuts.zh.mdxindex 443a7ef7d8..73dbf97695 100644--- a/apps/docs/content/docs/shortcuts.zh.mdx+++ b/apps/docs/content/docs/shortcuts.zh.mdx@@ -38,7 +38,7 @@ import { Step, Steps } from "fumadocs-ui/components/steps";| 在任务中查找 | `⌘F` | `Ctrl+F` | 见下文。 || 归档通知 | `E` | `E` | 在从收件箱打开的任务上,归档它的通知并打开下一条;查看已归档时则取消归档当前打开的通知。见[收件箱](/inbox#处理通知)。 || 延后通知 | `H` | `H` | 在从收件箱打开的任务上,延后它并打开下一条;已延后的任务则让它现在回来。 |-| 撤销收件箱操作 | `Z` | `Z` | 归档、延后或取消订阅的提示还在时,撤销这次操作;没有提示时,把已归档的当前通知放回收件箱。 |+| 撤销收件箱操作 | `Z` | `Z` | 归档、延后或取消订阅的提示还在时,撤销这次操作;没有提示时,把已归档的当前通知放回收件箱,或撤销**收件箱已清空**页面上写明的操作。 || 发送 | `⌘↵` | `Ctrl+Enter` | 发送评论和聊天消息,也用于提交新任务。 || 语音输入 | 未设置 | 未设置 | 仅 Desktop;先在设置 → 语音输入中开启。见[语音输入](/desktop-app#语音输入)。 || 后退 | `⌘[` | `Ctrl+[` | |diff --git a/packages/views/inbox/components/inbox-empty-state.test.tsx b/packages/views/inbox/components/inbox-empty-state.test.tsxindex d65e65b144..a1eaf5fa06 100644--- a/packages/views/inbox/components/inbox-empty-state.test.tsx+++ b/packages/views/inbox/components/inbox-empty-state.test.tsx@@ -8,6 +8,7 @@ import type { SnoozedInboxIssue, WorkspaceWorkingAgent } from "@multica/core/typimport { renderWithI18n } from "../../test/i18n";import { NavigationProvider, type NavigationAdapter } from "../../navigation";import { InboxEmptyState } from "./inbox-empty-state";+import { hasInboxUndo, takeInboxUndo, toastInboxUndo } from "./inbox-undo-toast";const spies = vi.hoisted(() => ({restoreInbox: vi.fn((..._args: unknown[]) => Promise.resolve(true)),@@ -32,6 +33,20 @@ vi.mock("@multica/core/inbox/mutations", async (importOriginal) => ({vi.mock("./use-leave-inbox-row", () => ({useRestoreInbox: () => spies.restoreInbox,}));+vi.mock("sonner", () => {+ let next = 0;+ return { toast: { success: vi.fn(() => ++next), dismiss: vi.fn(), error: vi.fn() } };+});++const archivedEntry = {+ kind: "archived" as const,+ itemId: "n-1",+ key: "issue-1",+ label: "MUL-9790",+ href: "/acme/issues/MUL-9790",+ clearedAt: Date.now(),+};+const pressZ = (target: Element = document.body) => fireEvent.keyDown(target, { key: "z", code: "KeyZ" });function renderEmpty({isArchivedView = false,@@ -97,7 +112,10 @@ beforeEach(() => {sidebarIssueByWorkspace: {},});});-afterEach(cleanup);+afterEach(() => {+ cleanup();+ takeInboxUndo();+});describe("InboxEmptyState", () => {it("shows calm Inbox Zero with My work, working agents, snoozed summary, and View archived", () => {@@ -207,6 +225,80 @@ describe("InboxEmptyState", () => {expect(screen.getByRole("button", { name: "Undo" })).toBeEnabled();});+ it("undoes with Z once the toast is gone, and shows the shortcut beside the undo", async () => {+ useInboxSelectionStore.setState({ lastClearedByWorkspace: { ws: archivedEntry } });+ const { nav } = renderEmpty();+ expect(+ screen.getByRole("button", { name: "Undo" }).querySelector('[data-slot="shortcut-keycaps"]'),+ ).not.toBeNull();++ await act(async () => pressZ());+ expect(spies.restoreInbox).toHaveBeenCalledWith("n-1", { quiet: true });+ expect(nav.push).toHaveBeenCalledWith("/acme/issues/MUL-9790");+ expect(useInboxSelectionStore.getState().lastClearedByWorkspace.ws).toBeUndefined();+ });++ it("leaves Z to a showing undo toast", async () => {+ useInboxSelectionStore.setState({ lastClearedByWorkspace: { ws: archivedEntry } });+ const { nav } = renderEmpty();+ const toastUndo = vi.fn();+ toastInboxUndo("Notification archived", { label: "Undo", undo: toastUndo });++ await act(async () => pressZ());+ expect(toastUndo).toHaveBeenCalledOnce();+ expect(spies.restoreInbox).not.toHaveBeenCalled();+ expect(nav.push).not.toHaveBeenCalled();+ expect(hasInboxUndo()).toBe(false);+ });++ it("sends one undo when Z is pressed again while it is in flight", async () => {+ useInboxSelectionStore.setState({ lastClearedByWorkspace: { ws: archivedEntry } });+ let finish!: (ok: boolean) => void;+ spies.restoreInbox.mockReturnValueOnce(new Promise<boolean>((resolve) => (finish = resolve)));+ const { nav } = renderEmpty();++ pressZ();+ pressZ();+ expect(spies.restoreInbox).toHaveBeenCalledTimes(1);+ expect(nav.push).not.toHaveBeenCalled();++ await act(async () => finish(true));+ expect(nav.push).toHaveBeenCalledTimes(1);+ });++ it("ignores Z typed into a text field or held down", async () => {+ useInboxSelectionStore.setState({ lastClearedByWorkspace: { ws: archivedEntry } });+ renderEmpty();+ const input = document.createElement("input");+ document.body.appendChild(input);++ await act(async () => {+ pressZ(input);+ fireEvent.keyDown(document.body, { key: "z", code: "KeyZ", repeat: true });+ });+ input.remove();+ expect(spies.restoreInbox).not.toHaveBeenCalled();+ });++ it("undoes with Z from the filtered-empty state", async () => {+ useInboxSelectionStore.setState({ lastClearedByWorkspace: { ws: archivedEntry } });+ const { nav } = renderEmpty({ totalActiveCount: 3, hasActiveFilters: true });+ expect(+ screen.getByRole("button", { name: "Undo MUL-9790" }).querySelector('[data-slot="shortcut-keycaps"]'),+ ).not.toBeNull();++ await act(async () => pressZ());+ expect(spies.restoreInbox).toHaveBeenCalledWith("n-1", { quiet: true });+ expect(nav.push).toHaveBeenCalledWith("/acme/issues/MUL-9790");+ });++ it("does not answer Z in the archived view", async () => {+ useInboxSelectionStore.setState({ lastClearedByWorkspace: { ws: archivedEntry } });+ renderEmpty({ isArchivedView: true });+ await act(async () => pressZ());+ expect(spies.restoreInbox).not.toHaveBeenCalled();+ });+it("shows filtered-empty state with remaining count and Clear filters CTA instead of Inbox Zero", () => {const { container, onClearFiltersAndContinue } = renderEmpty({visibleCount: 0,diff --git a/packages/views/inbox/components/inbox-empty-state.tsx b/packages/views/inbox/components/inbox-empty-state.tsxindex 2f7665640f..04d90a807e 100644--- a/packages/views/inbox/components/inbox-empty-state.tsx+++ b/packages/views/inbox/components/inbox-empty-state.tsx@@ -1,6 +1,6 @@"use client";-import { useMemo, useState } from "react";+import { useEffect, useMemo, useRef, useState } from "react";import { useQuery, useQueryClient } from "@tanstack/react-query";import { toast } from "sonner";import {@@ -28,13 +28,22 @@ import {type LastInboxCleared,} from "@multica/core/inbox/selection-store";import { openCreateIssueWithPreference } from "@multica/core/issues/stores";+import { useModalStore } from "@multica/core/modals";import { useIsGuest } from "@multica/core/permissions";+import {+ getShortcut,+ isEditableShortcutTarget,+ isPortalLayerShortcutTarget,+ shortcutMatchesEvent,+} from "@multica/core/shortcuts";import type { SnoozedInboxIssue, WorkspaceWorkingAgent } from "@multica/core/types";+import { isImeComposing } from "@multica/core/utils";import { ActionShortcutKeycaps } from "../../common/shortcut-keycaps";import { useLocale, useT } from "../../i18n";import { useBuiltinViewNavigation } from "../../issue-views/builtin-views";import { useNavigation } from "../../navigation";import { formatSnoozeTime } from "./inbox-snooze-time";+import { hasInboxUndo } from "./inbox-undo-toast";import { useRestoreInbox } from "./use-leave-inbox-row";const NO_SNOOZED: SnoozedInboxIssue[] = [];@@ -179,6 +188,31 @@ export function InboxEmptyState({const canUndoCleared = (entry: LastInboxCleared) => entry.kind !== "unsubscribed" || entry.undoable;+ // Z undoes what the inline undo shows, once its toast is gone.+ const showsUndo = !isArchivedView && visibleCount === 0 && !!lastCleared && canUndoCleared(lastCleared);+ const undoShortcutRef = useRef<(() => void) | null>(null);+ useEffect(() => {+ undoShortcutRef.current = showsUndo && lastCleared ? () => void handleUndoCleared(lastCleared) : null;+ });+ useEffect(() => {+ const onKeyDown = (event: KeyboardEvent) => {+ // A showing undo toast is the latest action, and the shortcut is its.+ if (hasInboxUndo()) return;+ if (event.defaultPrevented || event.repeat || isImeComposing(event)) return;+ if (isEditableShortcutTarget(event.target)) return;+ if (isPortalLayerShortcutTarget(event.target)) return;+ if (useModalStore.getState().modal) return;+ if (!shortcutMatchesEvent(getShortcut("undoInboxAction"), event)) return;+ const undo = undoShortcutRef.current;+ if (!undo) return;+ event.preventDefault();+ undo();+ };+ document.addEventListener("keydown", onKeyDown);+ return () => document.removeEventListener("keydown", onKeyDown);+ }, []);+ const undoKeycaps = !isCompact && <ActionShortcutKeycaps action="undoInboxAction" />;+// Desktop prompt when active notifications exist in the Work panel.if (visibleCount > 0) {return (@@ -222,6 +256,7 @@ export function InboxEmptyState({{lastCleared.kind === "batch_archived"? t(($) => $.toasts.undo): t(($) => $.zero.undo_item, { label: lastCleared.label })}+ {undoKeycaps}</Button>)}</div>@@ -264,6 +299,7 @@ export function InboxEmptyState({><Undo2 className="size-3" />{t(($) => $.toasts.undo)}+ {undoKeycaps}</button></>)}diff --git a/packages/views/locales/en/settings.json b/packages/views/locales/en/settings.jsonindex 0108a26a51..ed81a6d3c0 100644--- a/packages/views/locales/en/settings.json+++ b/packages/views/locales/en/settings.json@@ -441,7 +441,7 @@},"undoInboxAction": {"label": "Undo inbox action",- "description": "Undo the last archive, snooze or unsubscribe while its toast shows, or put the open notification back once it is archived."+ "description": "Undo the last archive, snooze or unsubscribe while its toast shows; after that, put back the open notification once it is archived, or what Inbox cleared names."},"send": {"label": "Send",diff --git a/packages/views/locales/es/settings.json b/packages/views/locales/es/settings.jsonindex e5e43a94e3..61de3b00f2 100644--- a/packages/views/locales/es/settings.json+++ b/packages/views/locales/es/settings.json@@ -441,7 +441,7 @@},"undoInboxAction": {"label": "Deshacer acción de la bandeja",- "description": "Deshace el último archivado, posposición o baja mientras se ve su aviso, o restaura la notificación abierta una vez archivada."+ "description": "Deshace el último archivado, posposición o baja mientras se ve su aviso; después, restaura la notificación abierta una vez archivada o lo que indica Bandeja de entrada vacía."},"send": {"label": "Enviar",diff --git a/packages/views/locales/fr/settings.json b/packages/views/locales/fr/settings.jsonindex f82dee6c9b..bf64bd905b 100644--- a/packages/views/locales/fr/settings.json+++ b/packages/views/locales/fr/settings.json@@ -441,7 +441,7 @@},"undoInboxAction": {"label": "Annuler l'action de la boîte de réception",- "description": "Annule le dernier archivage, report ou désabonnement tant que son message s'affiche, ou restaure la notification ouverte une fois archivée."+ "description": "Annule le dernier archivage, report ou désabonnement tant que son message s'affiche ; ensuite, restaure la notification ouverte une fois archivée ou ce qu'indique Boîte de réception vide."},"send": {"label": "Envoyer",diff --git a/packages/views/locales/ja/settings.json b/packages/views/locales/ja/settings.jsonindex ad884a4ebf..31ce87d5e9 100644--- a/packages/views/locales/ja/settings.json+++ b/packages/views/locales/ja/settings.json@@ -435,7 +435,7 @@},"undoInboxAction": {"label": "インボックスの操作を取り消す",- "description": "トーストが表示されている間は直前のアーカイブ・スヌーズ・購読解除を取り消します。開いている通知がアーカイブ済みならインボックスに戻します。"+ "description": "トーストが表示されている間は直前のアーカイブ・スヌーズ・購読解除を取り消します。トーストが消えた後は、開いている通知がアーカイブ済みならインボックスに戻し、「インボックスは空です」画面ではそこに表示された操作を取り消します。"},"send": {"label": "送信",diff --git a/packages/views/locales/ko/settings.json b/packages/views/locales/ko/settings.jsonindex 0218c75fa0..29cd8668a9 100644--- a/packages/views/locales/ko/settings.json+++ b/packages/views/locales/ko/settings.json@@ -435,7 +435,7 @@},"undoInboxAction": {"label": "인박스 작업 실행 취소",- "description": "토스트가 보이는 동안 마지막 보관, 미루기, 구독 해제를 취소합니다. 열린 알림이 보관되었다면 인박스로 되돌립니다."+ "description": "토스트가 보이는 동안 마지막 보관, 미루기, 구독 해제를 취소합니다. 토스트가 사라진 뒤에는 열린 알림이 보관되었다면 인박스로 되돌리고, '인박스가 비었습니다' 화면에서는 그곳에 표시된 작업을 취소합니다."},"send": {"label": "보내기",diff --git a/packages/views/locales/ru/settings.json b/packages/views/locales/ru/settings.jsonindex 20c2725281..31c9893f77 100644--- a/packages/views/locales/ru/settings.json+++ b/packages/views/locales/ru/settings.json@@ -453,7 +453,7 @@},"undoInboxAction": {"label": "Отменить действие во входящих",- "description": "Отменяет последнее архивирование, откладывание или отписку, пока видно уведомление, или возвращает открытое уведомление во входящие после архивирования."+ "description": "Отменяет последнее архивирование, откладывание или отписку, пока видно уведомление; после этого возвращает открытое уведомление во входящие после архивирования или отменяет действие, указанное на экране «Входящие разобраны»."},"send": {"label": "Отправить",diff --git a/packages/views/locales/zh-Hans/settings.json b/packages/views/locales/zh-Hans/settings.jsonindex 5367c82b4e..9b2dd7525a 100644--- a/packages/views/locales/zh-Hans/settings.json+++ b/packages/views/locales/zh-Hans/settings.json@@ -435,7 +435,7 @@},"undoInboxAction": {"label": "撤销收件箱操作",- "description": "提示还在时,撤销上一次归档、延后或取消订阅;打开的通知已归档时,把它放回收件箱。"+ "description": "提示还在时,撤销上一次归档、延后或取消订阅;提示消失后,打开的通知已归档时把它放回收件箱,在\"收件箱已清空\"页撤销页面上写明的操作。"},"send": {"label": "发送",diff --git a/packages/views/locales/zh-Hant/settings.json b/packages/views/locales/zh-Hant/settings.jsonindex 5bc8b2d542..8a11b1f42b 100644--- a/packages/views/locales/zh-Hant/settings.json+++ b/packages/views/locales/zh-Hant/settings.json@@ -435,7 +435,7 @@},"undoInboxAction": {"label": "復原收件箱操作",- "description": "提示還在時,復原上一次歸檔、延後或取消訂閱;開啟的通知已歸檔時,把它放回收件箱。"+ "description": "提示還在時,復原上一次歸檔、延後或取消訂閱;提示消失後,開啟的通知已歸檔時把它放回收件箱,在「收件箱已清空」頁復原頁面上寫明的操作。"},"send": {"label": "傳送",