Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(inbox): triage moves on, side effects stay in place (MUL-9372) (#10711)
Jiayuan Zhanga36b99db93b0
diff --git a/apps/docs/content/docs/inbox.fr.mdx b/apps/docs/content/docs/inbox.fr.mdxindex 65c1e64a46..d020795453 100644--- a/apps/docs/content/docs/inbox.fr.mdx+++ b/apps/docs/content/docs/inbox.fr.mdx@@ -107,7 +107,11 @@ Lire une notification ne la retire pas. Une ligne quitte la boîte de réception- quand vous passez vous-même sa tâche à n'importe quel statut des catégories `done` ou `closed`, tant que **Archiver les tâches que vous terminez** est activé (c'est le cas par défaut). Seules vos propres notifications sur cette tâche sont archivées, lues ou non. Quand quelqu'un d'autre ou un agent termine une tâche, ses notifications restent dans votre boîte de réception, pour que vous voyiez la nouvelle ;- quand c'est une notification **Exécution en échec** et que sa tâche passe à un statut qui la rend à une personne : `in_review`, un statut personnalisé de la catégorie `started`, ou n'importe quel statut des catégories `done` ou `closed`. Les notifications Exécution en échec de tout le monde sur cette tâche sont alors archivées, quelle que soit la personne qui a changé le statut, et indépendamment du réglage ci-dessus. `blocked` fait exception : il rend aussi la tâche, mais le travail reste bloqué, donc les échecs précédents méritent encore d'être lus.-Les fenêtres ouvertes retirent aussitôt une ligne archivée. Une notification ultérieure sur la tâche revient dans la boîte de réception.+Les fenêtres ouvertes retirent aussitôt une ligne archivée, sauf celle que vous avez ouverte. Quand sa notification quitte la boîte de réception autrement (vous passez la tâche à `done` depuis son statut, une autre fenêtre l'archive, ou une modification la sort des filtres de la section), la ligne reste en surbrillance à sa place et l'en-tête de la tâche indique ce qui s'est passé. **Annuler** fait revenir la notification, et **Suivante** (ou `E`) ouvre la ligne suivante. La ligne disparaît dès que vous passez à autre chose.++Quand vous retirez vous-même la ligne ouverte, depuis l'en-tête de la tâche, sa ligne, la carte de survol ou une action groupée qui l'inclut, c'est la ligne suivante qui s'ouvre. S'il n'en reste aucune, la tâche reste ouverte. L'archivage, le passage à terminé et les actions groupées proposent **Annuler**, qui fait revenir les notifications sans changer le statut de la tâche.++Une notification ultérieure sur la tâche revient dans la boîte de réception.**Paramètres → Notifications → Sortir de la boîte de réception** contient l'interrupteur **Archiver les tâches que vous terminez** et renvoie vers les notifications archivées.diff --git a/apps/docs/content/docs/inbox.ja.mdx b/apps/docs/content/docs/inbox.ja.mdxindex 4dccc97abd..a7956ac2a0 100644--- a/apps/docs/content/docs/inbox.ja.mdx+++ b/apps/docs/content/docs/inbox.ja.mdx@@ -107,7 +107,11 @@ import { InboxDemo } from "@/components/demos/inbox-demo";- **自分が完了したタスクをアーカイブ** がオン(既定でオン)の状態で、あなた自身がタスクを `done` または `closed` カテゴリのいずれかのステータスにしたとき。アーカイブされるのは、そのタスクに届いたあなた自身の通知だけで、既読かどうかは問いません。ほかの人やエージェントがタスクを完了した場合、その通知はあなたのインボックスに残るので、変化を見逃しません。- 「実行失敗」の通知で、タスクが人に引き継がれるステータスになったとき。対象は `in_review`、`started` カテゴリのカスタムステータス、`done`・`closed` カテゴリのすべてのステータスです。誰がステータスを変えたかにかかわらず、そのタスクの全員分の「実行失敗」の通知がアーカイブされ、上の設定には左右されません。`blocked` は例外です。人に引き継がれはしますが作業は止まったままなので、それまでの失敗の記録はまだ確認する必要があります。-アーカイブされた行は、開いているウィンドウからもすぐに消えます。その後に届いた通知は、再びインボックスに入ります。+アーカイブされた行は、開いているウィンドウからもすぐに消えます。ただし、いま開いている行は別です。その通知がほかの理由でインボックスから外れたとき(ステータスからタスクを `done` にした、別のウィンドウでアーカイブされた、編集でセクションのフィルターに合わなくなった)、行は元の位置でハイライトされたまま残り、タスクのヘッダーに何が起きたかが表示されます。**元に戻す** で通知が戻り、**次へ**(または `E`)で次の行が開きます。行が消えるのは、ほかへ移ったときです。++開いている行を自分で処理したとき(タスクのヘッダー、その行、ホバーカード、その行を含む一括操作)は、代わりに次の行が開きます。残りがなければ、タスクは開いたままです。アーカイブ、完了にする、一括操作の確認には **元に戻す** があり、通知は戻りますが、タスクのステータスはそのままです。++その後に届いた通知は、再びインボックスに入ります。**設定 → 通知 → インボックスから外れるとき** には、**自分が完了したタスクをアーカイブ** のスイッチと、アーカイブ済みの通知へのリンクがあります。diff --git a/apps/docs/content/docs/inbox.ko.mdx b/apps/docs/content/docs/inbox.ko.mdxindex fff44712a5..a1db174936 100644--- a/apps/docs/content/docs/inbox.ko.mdx+++ b/apps/docs/content/docs/inbox.ko.mdx@@ -107,7 +107,11 @@ import { InboxDemo } from "@/components/demos/inbox-demo";- **내가 완료한 태스크 보관**이 켜져 있는 상태(기본값)에서 내가 직접 태스크를 `done` 또는 `closed` 카테고리의 어떤 상태로 바꿀 때. 그 태스크에 온 내 알림만 읽음 여부와 관계없이 보관됩니다. 다른 사람이나 에이전트가 태스크를 완료하면 그 알림은 내 인박스에 남으므로 변화를 놓치지 않습니다.- "실행 실패함" 알림이고, 태스크가 사람에게 넘어가는 상태가 될 때. 해당 상태는 `in_review`, `started` 카테고리의 사용자 지정 상태, `done`·`closed` 카테고리의 모든 상태입니다. 누가 상태를 바꿨는지와 관계없이 그 태스크의 모든 사람의 "실행 실패함" 알림이 보관되며, 위 설정의 영향을 받지 않습니다. `blocked`는 예외입니다. 사람에게 넘어가기는 하지만 작업이 여전히 막혀 있으므로 지난 실패 기록을 계속 확인해야 합니다.-보관된 행은 열려 있는 창에서도 바로 사라집니다. 이후 그 태스크에 새 알림이 오면 다시 인박스에 들어옵니다.+보관된 행은 열려 있는 창에서도 바로 사라집니다. 단, 지금 열어 둔 행은 예외입니다. 그 알림이 다른 이유로 인박스에서 빠지면(상태에서 태스크를 `done`으로 바꿨거나, 다른 창에서 보관했거나, 편집으로 섹션 필터에 더 이상 맞지 않게 된 경우) 행은 제자리에서 강조된 채 남고, 태스크 헤더에 무슨 일이 있었는지 표시됩니다. **실행 취소**로 알림을 되돌리고, **다음**(또는 `E`)으로 다음 행을 엽니다. 행은 다른 곳으로 이동할 때 사라집니다.++열어 둔 행을 직접 처리하면(태스크 헤더, 그 행, 호버 카드, 그 행을 포함한 일괄 작업) 대신 다음 행이 열립니다. 남은 행이 없으면 태스크는 열린 채로 있습니다. 보관, 완료로 표시, 일괄 작업의 확인에는 **실행 취소**가 있으며, 알림은 돌아오고 태스크 상태는 그대로 유지됩니다.++이후 그 태스크에 새 알림이 오면 다시 인박스에 들어옵니다.**설정 → 알림 → 인박스에서 빠지는 경우**에 **내가 완료한 태스크 보관** 스위치와 보관된 알림으로 가는 링크가 있습니다.diff --git a/apps/docs/content/docs/inbox.mdx b/apps/docs/content/docs/inbox.mdxindex a0daf04c07..99932562af 100644--- a/apps/docs/content/docs/inbox.mdx+++ b/apps/docs/content/docs/inbox.mdx@@ -107,7 +107,11 @@ Reading a notification doesn't remove it. A row leaves the inbox only when:- you move its issue to any status in the `done` or `closed` category yourself, while **Archive issues you complete** is on (it is by default). Only your own notifications on that issue are archived, read or not. When someone else or an agent completes an issue, its notifications stay in your inbox, so you still see the news;- it's a **Run failed** notification and its issue moves to a status that hands it back to a person: `in_review`, a custom status in the `started` category, or any status in the `done` or `closed` category. This archives everyone's Run failed notifications on the issue, whoever moved it, and doesn't depend on the setting above. `blocked` is the exception: it hands the issue over too, but the work is still stuck, so the earlier failures are still worth reading.-Open windows drop an archived row right away. A later notification on the issue lands in the inbox again.+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 issue header says what happened. **Undo** brings the notification back, and **Next** (or `E`) opens the next row. The row leaves once you move on.++When you take the open row out yourself, from the issue header, its row, the hover card, or a bulk action that includes it, the next row opens instead. With nothing left to open, the issue stays open. Archiving, marking as done and the bulk actions confirm with **Undo**, which brings the notifications back and leaves the issue's status as it is.++A later notification on the issue lands in the inbox again.**Settings → Notifications → Leaving the Inbox** has the **Archive issues you complete** switch and links to the archived notifications.diff --git a/apps/docs/content/docs/inbox.zh-Hant.mdx b/apps/docs/content/docs/inbox.zh-Hant.mdxindex 9878c06f20..fa0864c3d5 100644--- a/apps/docs/content/docs/inbox.zh-Hant.mdx+++ b/apps/docs/content/docs/inbox.zh-Hant.mdx@@ -107,7 +107,11 @@ import { InboxDemo } from "@/components/demos/inbox-demo";- 你親自把它的任務改為 `done` 或 `closed` 分類下的任一狀態,且**自動歸檔我完成的任務**處於開啟狀態(預設開啟)。只歸檔你自己在該任務上的通知,無論是否已讀。別人或 AI 代理完成的任務,通知會留在你的收件箱裡,你仍能看到這個變化;- 它是"執行失敗"通知,且任務進入交回給人的狀態:`in_review`、`started` 分類下的自定義狀態,或 `done`、`closed` 分類下的任一狀態。這會歸檔所有人在該任務上的"執行失敗"通知,不論是誰改的狀態,也不受上面的開關影響。`blocked` 例外:它同樣交回給人,但工作還卡著,之前的失敗記錄還要看。-開著的視窗會立即移除已歸檔的列。之後該任務再有新通知,會重新進入收件箱。+開著的視窗會立即移除已歸檔的列,但你正開著的那一列除外。它的通知因為其他原因離開收件箱時(你在狀態裡把任務改為 `done`、別的視窗歸檔了它,或修改後不再符合分區的篩選),這一列會在原位保持高亮,任務頁首會說明發生了什麼:**復原**讓通知回來,**下一條**(或按 `E`)開啟下一列。你離開之後,這一列才會移出。++如果是你自己把正開著的這一列處理掉(在任務頁首、它所在的列、懸停卡片,或包含它的批次操作裡),會直接開啟下一列;沒有剩下的列時,任務保持開啟。歸檔、標記為已完成和批次操作的提示裡都可以**復原**:通知會回來,任務的狀態保持不變。++之後該任務再有新通知,會重新進入收件箱。**設定 → 通知 → 移出收件箱**裡有**自動歸檔我完成的任務**開關,並提供已歸檔通知的入口。diff --git a/apps/docs/content/docs/inbox.zh.mdx b/apps/docs/content/docs/inbox.zh.mdxindex 790dcd5b6b..28c7f40bfe 100644--- a/apps/docs/content/docs/inbox.zh.mdx+++ b/apps/docs/content/docs/inbox.zh.mdx@@ -107,7 +107,11 @@ import { InboxDemo } from "@/components/demos/inbox-demo";- 你亲自把它的任务改为 `done` 或 `closed` 分类下的任一状态,且**自动归档我完成的任务**处于开启状态(默认开启)。只归档你自己在该任务上的通知,无论是否已读。别人或智能体完成的任务,通知会留在你的收件箱里,你仍能看到这个变化;- 它是"运行失败"通知,且任务进入交回给人的状态:`in_review`、`started` 分类下的自定义状态,或 `done`、`closed` 分类下的任一状态。这会归档所有人在该任务上的"运行失败"通知,不论是谁改的状态,也不受上面的开关影响。`blocked` 例外:它同样交回给人,但工作还卡着,之前的失败记录还要看。-打开着的窗口会立即移除已归档的行。之后该任务再有新通知,会重新进入收件箱。+打开着的窗口会立即移除已归档的行,但你正打开的那一行除外。它的通知因为其他原因离开收件箱时(你在状态里把任务改为 `done`、别的窗口归档了它,或修改后不再符合分区的筛选),这一行会在原位保持高亮,任务页头会说明发生了什么:**撤销**让通知回来,**下一条**(或按 `E`)打开下一行。你离开之后,这一行才会移出。++如果是你自己把正打开的这一行处理掉(在任务页头、它所在的行、悬停卡片,或包含它的批量操作里),会直接打开下一行;没有剩下的行时,任务保持打开。归档、标记为已完成和批量操作的提示里都可以**撤销**:通知会回来,任务的状态保持不变。++之后该任务再有新通知,会重新进入收件箱。**设置 → 通知 → 移出收件箱**里有**自动归档我完成的任务**开关,并提供已归档通知的入口。diff --git a/packages/core/inbox/mutations.ts b/packages/core/inbox/mutations.tsindex e1724b6e69..fc791039db 100644--- a/packages/core/inbox/mutations.ts+++ b/packages/core/inbox/mutations.ts@@ -364,6 +364,24 @@ export function useArchiveCompletedInbox() {});}+/**+ * Undo for a batch archive: restore the notifications it took, one request+ * per row, since a restore brings back the whole issue's group. A plain+ * function rather than a hook, because it runs from a toast that outlives the+ * page that showed it.+ */+export async function undoArchiveInboxBatch(+ qc: QueryClient,+ wsId: string,+ ids: readonly string[],+): Promise<void> {+ try {+ await Promise.all(ids.map((id) => api.unarchiveInbox(id)));+ } finally {+ refreshInboxAfterWrite(qc, wsId);+ }+}+/*** When the issue of an inbox item is snoozed until, as far as the cache knows;* null when it isn't snoozed or its time has passed.diff --git a/packages/core/inbox/open-row.test.ts b/packages/core/inbox/open-row.test.tsnew file mode 100644index 0000000000..d7f0b9f7de--- /dev/null+++ b/packages/core/inbox/open-row.test.ts@@ -0,0 +1,172 @@+import { beforeEach, describe, expect, it } from "vitest";+import { QueryClient } from "@tanstack/react-query";+import type { InboxItem } from "../types";+import { keepOpenInboxRow, nextInboxRow, type HeldInboxRow } from "./open-row";+import { useInboxSelectionStore } from "./selection-store";+import { onInboxIssueDeleted, onInboxIssuesDeleted } from "./ws-updaters";++function item(id: string, overrides: Partial<InboxItem> = {}): InboxItem {+ return {+ id: `n-${id}`,+ workspace_id: "ws",+ recipient_type: "member",+ recipient_id: "member-1",+ actor_type: "agent",+ actor_id: "agent-1",+ type: "new_comment",+ severity: "info",+ issue_id: id,+ title: id,+ body: null,+ issue_status: "in_progress",+ issue_priority: "none",+ read: true,+ archived: false,+ created_at: "2026-11-10T08:00:00Z",+ details: null,+ ...overrides,+ };+}++const NOW = new Date("2026-11-16T08:00:00Z").getTime();+const FILTERS = {};+const [A, B, C] = [item("a"), item("b"), item("c")];+const held = (row: InboxItem, index: number, filters: unknown = FILTERS): HeldInboxRow => ({+ key: row.issue_id!,+ item: row,+ index,+ filters,+});++describe("keepOpenInboxRow", () => {+ it("leaves a list that still shows the open row as it is", () => {+ const rows = [A, B, C];+ expect(keepOpenInboxRow(rows, rows, held(B, 1), "b", FILTERS, { now: NOW })).toEqual({ rows, kept: null });+ });++ it("keeps an archived open row where it was", () => {+ const { rows, kept } = keepOpenInboxRow([A, C], [A, C], held(B, 1), "b", FILTERS, { now: NOW });+ expect(rows).toEqual([A, B, C]);+ expect(kept).toEqual({ key: "b", item: B, reason: "archived" });+ });++ it("says a row snoozed elsewhere is snoozed, as it is now", () => {+ const snoozed = { ...B, snoozed_until: "2026-11-17T09:00:00Z" };+ const { kept } = keepOpenInboxRow([A, C], [A, snoozed, C], held(B, 1), "b", FILTERS, { now: NOW });+ expect(kept).toEqual({ key: "b", item: snoozed, reason: "snoozed" });+ });++ it("says a row snoozed in another window is snoozed, though the list leaves it out", () => {+ const until = "2026-11-17T09:00:00Z";+ const snoozed = [{ issue_id: "b", item_id: "n-b2", snoozed_until: until, snoozed_at: "2026-11-16T07:00:00Z", updates: 0 }];+ const { rows, kept } = keepOpenInboxRow([A, C], [A, C], held(B, 1), "b", FILTERS, { snoozed, now: NOW });+ expect(kept).toEqual({ key: "b", item: { ...B, id: "n-b2", snoozed_until: until }, reason: "snoozed" });+ expect(rows[1]).toBe(kept?.item);+ });++ it("says a row whose snooze has passed was archived", () => {+ const snoozed = [{ issue_id: "b", item_id: "n-b", snoozed_until: "2026-11-15T09:00:00Z", snoozed_at: "2026-11-14T07:00:00Z", updates: 0 }];+ expect(keepOpenInboxRow([A, C], [A, C], held(B, 1), "b", FILTERS, { snoozed, now: NOW }).kept?.reason).toBe("archived");+ });++ it("keeps a row an edit took out of the filters, as it is now", () => {+ const edited = { ...B, issue_status: "todo" };+ const { rows, kept } = keepOpenInboxRow([A, C], [A, edited, C], held(B, 1), "b", FILTERS, { now: NOW });+ expect(rows).toEqual([A, edited, C]);+ expect(kept?.reason).toBe("filtered");+ });++ it("lets a changed filter drop the open row", () => {+ const rows = [A, C];+ expect(keepOpenInboxRow(rows, [A, B, C], held(B, 1), "b", { ...FILTERS }, { now: NOW })).toEqual({ rows, kept: null });+ });++ it("keeps an archived row even under changed filters", () => {+ expect(keepOpenInboxRow([A], [A], held(B, 1), "b", { ...FILTERS }, { now: NOW }).kept?.reason).toBe("archived");+ });++ it("keeps nothing for another notification, or with none open", () => {+ expect(keepOpenInboxRow([A, C], [A, C], held(B, 1), "c", FILTERS, { now: NOW }).kept).toBeNull();+ expect(keepOpenInboxRow([A, C], [A, C], held(B, 1), null, FILTERS, { now: NOW }).kept).toBeNull();+ expect(keepOpenInboxRow([A, C], [A, C], undefined, "b", FILTERS, { now: NOW }).kept).toBeNull();+ });++ it("puts the row at the end of a list that got shorter", () => {+ expect(keepOpenInboxRow([A], [A], held(C, 2), "c", FILTERS, { now: NOW }).rows).toEqual([A, C]);+ });+});++describe("nextInboxRow", () => {+ it("opens the older row below, else the newer one above", () => {+ expect(nextInboxRow([A, B, C], "b")).toBe(C);+ expect(nextInboxRow([A, B, C], "c")).toBe(B);+ expect(nextInboxRow([A], "a")).toBeNull();+ expect(nextInboxRow([A, B], "x")).toBeNull();+ });++ it("skips rows leaving with it", () => {+ const unread = item("d", { read: false });+ const isRead = (row: InboxItem) => row.read === true;+ expect(nextInboxRow([unread, A, B, C], "b", isRead)).toBe(unread);+ expect(nextInboxRow([A, B, C], "b", isRead)).toBeNull();+ });+});++describe("held and left rows", () => {+ beforeEach(() => useInboxSelectionStore.setState({ heldRows: {}, leftRowKeyByWorkspace: {} }));+ const store = () => useInboxSelectionStore.getState();++ it("holds a row per list until the user leaves it", () => {+ store().holdRow("ws", "section", held(B, 1));+ store().holdRow("ws", "page", held(B, 3));+ expect(store().heldRows["ws:section"]?.index).toBe(1);+ expect(store().heldRows["ws:page"]?.index).toBe(3);++ store().leaveRow("ws", "b");+ expect(store().heldRows).toEqual({});+ store().holdRow("ws", "section", held(B, 1));+ expect(store().heldRows).toEqual({});+ });++ it("forgets rows once their notification is no longer open", () => {+ store().holdRow("ws", "section", held(B, 1));+ store().holdRow("other", "section", held(C, 0));+ store().leaveRow("ws", "a");+ store().releaseRows("ws", ["b"]);+ expect(Object.keys(store().heldRows)).toEqual(["ws:section", "other:section"]);+ expect(store().leftRowKeyByWorkspace).toEqual({});++ store().releaseRows("ws", []);+ expect(Object.keys(store().heldRows)).toEqual(["other:section"]);+ });++ it("lets a row be kept again once the action that left it is undone", () => {+ store().leaveRow("ws", "b");+ store().returnRow("ws", "c");+ expect(store().leftRowKeyByWorkspace).toEqual({ ws: "b" });+ store().returnRow("ws", "b");+ expect(store().leftRowKeyByWorkspace).toEqual({});+ store().holdRow("ws", "section", held(B, 1));+ expect(store().heldRows["ws:section"]?.key).toBe("b");+ });++ it("forgets every row of an issue that was deleted", async () => {+ store().holdRow("ws", "section", held(B, 1));+ store().holdRow("ws", "page", held(B, 1));+ store().holdRow("other", "section", held(B, 1));+ const qc = new QueryClient();+ await onInboxIssueDeleted(qc, "ws", "b");+ expect(Object.keys(store().heldRows)).toEqual(["other:section"]);++ store().leaveRow("ws", "c");+ await onInboxIssuesDeleted(qc, "ws", ["c"]);+ expect(store().leftRowKeyByWorkspace).toEqual({});+ });++ it("drops the row of a list that goes away", () => {+ store().holdRow("ws", "section", held(B, 1));+ store().holdRow("ws", "page", held(B, 1));+ store().dropRow("ws", "page");+ expect(Object.keys(store().heldRows)).toEqual(["ws:section"]);+ });+});diff --git a/packages/core/inbox/open-row.ts b/packages/core/inbox/open-row.tsnew file mode 100644index 0000000000..6e65a2b2b8--- /dev/null+++ b/packages/core/inbox/open-row.ts@@ -0,0 +1,98 @@+import type { InboxItem, SnoozedInboxIssue } from "../types";+import { isInboxItemSnoozed } from "./snooze";++/** A row's group key: its issue, or the notification itself when it has none. */+export function inboxRowKey(item: Pick<InboxItem, "issue_id" | "id">): string {+ return item.issue_id ?? item.id;+}++/** The open notification's row as a list last showed it, and its place there. */+export interface HeldInboxRow {+ key: string;+ item: InboxItem;+ index: number;+ /** The filters the list showed it under. */+ filters: unknown;+}++/**+ * Why the open row is kept although the list no longer has it: its+ * notification was archived or snoozed, or it no longer matches the filters.+ */+export type KeptInboxRowReason = "archived" | "snoozed" | "filtered";++export interface KeptInboxRow {+ key: string;+ item: InboxItem;+ reason: KeptInboxRowReason;+}++/**+ * The list with the open row kept where it was. Something other than the+ * user's own Inbox action can take the open row out: its issue reaching+ * Done or Cancelled archives it, an edit can stop it matching the filters,+ * another window can archive or snooze it. Pulling the row out from under+ * the issue the user is reading would leave the detail with no row and the+ * highlight with nowhere to go, so the row stays, marked as settled, until+ * the user moves on. The Inbox's own actions move on first and never reach+ * here (see `leaveInboxRow`).+ *+ * `notifications` is every active notification, unfiltered, which tells an+ * archived row from a filtered-out one. The active list leaves snoozed+ * notifications out, so `snoozed`, the viewer's snoozed issues, tells a+ * snoozed row from an archived one. Changing the filters is itself a request+ * to filter rows out, so a row they drop is kept only under the `filters` it+ * was shown with.+ */+export function keepOpenInboxRow(+ rows: InboxItem[],+ notifications: readonly InboxItem[],+ held: HeldInboxRow | undefined,+ openKey: string | null,+ filters: unknown,+ { snoozed = [], now = Date.now() }: { snoozed?: readonly SnoozedInboxIssue[]; now?: number } = {},+): { rows: InboxItem[]; kept: KeptInboxRow | null } {+ if (!openKey || !held || held.key !== openKey) return { rows, kept: null };+ if (rows.some((row) => inboxRowKey(row) === openKey)) return { rows, kept: null };+ const group = notifications.filter((item) => inboxRowKey(item) === openKey);+ const snooze =+ group.length === 0+ ? snoozed.find((entry) => entry.issue_id === openKey && new Date(entry.snoozed_until).getTime() > now)+ : undefined;+ const reason: KeptInboxRowReason = snooze+ ? "snoozed"+ : group.length === 0+ ? "archived"+ : group.some((item) => isInboxItemSnoozed(item, now))+ ? "snoozed"+ : "filtered";+ if (reason === "filtered" && held.filters !== filters) return { rows, kept: null };+ // Not archived: show it as it is now. A snoozed issue's notification is the+ // one its snooze entry names, which the snooze endpoints take.+ const item = snooze+ ? { ...held.item, id: snooze.item_id, snoozed_until: snooze.snoozed_until }+ : reason === "archived"+ ? held.item+ : (group.find((other) => other.id === held.item.id) ?? group[0]!);+ const at = Math.min(held.index, rows.length);+ return {+ rows: [...rows.slice(0, at), item, ...rows.slice(at)],+ kept: { key: openKey, item, reason },+ };+}++/**+ * The row to open once `key` leaves: rows run newest first, so the older one+ * below it, else the newer one above. `leaving` names other rows going at the+ * same time, as a batch archive does.+ */+export function nextInboxRow(+ rows: readonly InboxItem[],+ key: string,+ leaving: (item: InboxItem) => boolean = () => false,+): InboxItem | null {+ const index = rows.findIndex((row) => inboxRowKey(row) === key);+ if (index === -1) return null;+ const stays = (row: InboxItem) => inboxRowKey(row) !== key && !leaving(row);+ return rows.slice(index + 1).find(stays) ?? rows.slice(0, index).findLast(stays) ?? null;+}diff --git a/packages/core/inbox/selection-store.ts b/packages/core/inbox/selection-store.tsindex 2736f0b14e..1667ab2e60 100644--- a/packages/core/inbox/selection-store.ts+++ b/packages/core/inbox/selection-store.ts@@ -1,6 +1,7 @@"use client";import { create } from "zustand";+import type { HeldInboxRow } from "./open-row";interface InboxSelectionState {lastResolvedKeyByWorkspace: Record<string, string>;@@ -24,8 +25,31 @@ interface InboxSelectionState {*/landing: { issueId: string; token: number } | null;requestLanding: (issueId: string) => void;+ /**+ * The open notification's row as each list last showed it, by+ * `${wsId}:${list}`, so the list can keep it in place (`keepOpenInboxRow`).+ */+ heldRows: Record<string, HeldInboxRow>;+ holdRow: (wsId: string, list: string, row: HeldInboxRow) => void;+ /**+ * The open notification an Inbox action left, by workspace. It leaves its+ * lists for good, even while it stays open because nothing was left to+ * move on to.+ */+ leftRowKeyByWorkspace: Record<string, string>;+ leaveRow: (wsId: string, key: string) => void;+ /** Undoes `leaveRow` for an action that was undone or failed, so the row can be kept again. */+ returnRow: (wsId: string, key: string) => void;+ /** Forgets every row held or left for these notifications, whose issues are gone. */+ forgetRows: (wsId: string, keys: readonly string[]) => void;+ /** Forgets the rows held or left for notifications that are no longer open. */+ releaseRows: (wsId: string, openKeys: readonly string[]) => void;+ /** Forgets the row one list holds, for a list that is going away. */+ dropRow: (wsId: string, list: string) => void;}+const heldRowId = (wsId: string, list: string) => `${wsId}:${list}`;+// Keep only the last resolved pointer per workspace, for this client run.// Notification data and its cache lifetime remain owned by TanStack Query.export const useInboxSelectionStore = create<InboxSelectionState>()((set) => ({@@ -60,4 +84,69 @@ export const useInboxSelectionStore = create<InboxSelectionState>()((set) => ({landing: null,requestLanding: (issueId) =>set((state) => ({ landing: { issueId, token: (state.landing?.token ?? 0) + 1 } })),+ heldRows: {},+ holdRow: (wsId, list, row) =>+ set((state) => {+ if (state.leftRowKeyByWorkspace[wsId] === row.key) return state;+ const id = heldRowId(wsId, list);+ const current = state.heldRows[id];+ if (+ current?.key === row.key &&+ current.item === row.item &&+ current.index === row.index &&+ current.filters === row.filters+ ) {+ return state;+ }+ return { heldRows: { ...state.heldRows, [id]: row } };+ }),+ leftRowKeyByWorkspace: {},+ leaveRow: (wsId, key) =>+ set((state) => ({+ leftRowKeyByWorkspace: { ...state.leftRowKeyByWorkspace, [wsId]: key },+ heldRows: Object.fromEntries(+ Object.entries(state.heldRows).filter(([id, row]) => !(id.startsWith(`${wsId}:`) && row.key === key)),+ ),+ })),+ returnRow: (wsId, key) =>+ set((state) => {+ if (state.leftRowKeyByWorkspace[wsId] !== key) return state;+ const { [wsId]: _returned, ...leftRowKeyByWorkspace } = state.leftRowKeyByWorkspace;+ return { leftRowKeyByWorkspace };+ }),+ forgetRows: (wsId, keys) =>+ set((state) => {+ const held = Object.entries(state.heldRows).filter(+ ([id, row]) => !(id.startsWith(`${wsId}:`) && keys.includes(row.key)),+ );+ const left = state.leftRowKeyByWorkspace[wsId];+ const leftGoes = left !== undefined && keys.includes(left);+ if (!leftGoes && held.length === Object.keys(state.heldRows).length) return state;+ const { [wsId]: _forgotten, ...otherLeft } = state.leftRowKeyByWorkspace;+ return {+ heldRows: Object.fromEntries(held),+ leftRowKeyByWorkspace: leftGoes ? otherLeft : state.leftRowKeyByWorkspace,+ };+ }),+ releaseRows: (wsId, openKeys) =>+ set((state) => {+ const left = state.leftRowKeyByWorkspace[wsId];+ const leftStays = left === undefined || openKeys.includes(left);+ const held = Object.entries(state.heldRows).filter(+ ([id, row]) => !id.startsWith(`${wsId}:`) || openKeys.includes(row.key),+ );+ if (leftStays && held.length === Object.keys(state.heldRows).length) return state;+ const { [wsId]: _released, ...otherLeft } = state.leftRowKeyByWorkspace;+ return {+ heldRows: Object.fromEntries(held),+ leftRowKeyByWorkspace: leftStays ? state.leftRowKeyByWorkspace : otherLeft,+ };+ }),+ dropRow: (wsId, list) =>+ set((state) => {+ const id = heldRowId(wsId, list);+ if (!(id in state.heldRows)) return state;+ const { [id]: _dropped, ...heldRows } = state.heldRows;+ return { heldRows };+ }),}));diff --git a/packages/core/inbox/ws-updaters.ts b/packages/core/inbox/ws-updaters.tsindex d74647cb9f..cd963b3840 100644--- a/packages/core/inbox/ws-updaters.ts+++ b/packages/core/inbox/ws-updaters.ts@@ -1,5 +1,6 @@import type { QueryClient, QueryKey } from "@tanstack/react-query";import { inboxKeys, mapArchivedInboxCache, type ArchivedInboxCache } from "./queries";+import { useInboxSelectionStore } from "./selection-store";import type { InboxItem, IssueAssigneeType, IssuePriority, IssueStatus } from "../types";// Re-read a query because the server changed — in a way that is never answered@@ -161,6 +162,8 @@ export async function onInboxIssueDeleted(patchInboxLists(qc, wsId, (items) =>items.filter((i) => i.issue_id !== issueId),);+ // A row kept in place for the open issue must not bring a deleted issue back.+ useInboxSelectionStore.getState().forgetRows(wsId, [issueId]);await Promise.all([onInboxSummaryInvalidate(qc),refreshInboxQuery(qc, inboxKeys.pages(wsId)),@@ -190,6 +193,7 @@ export async function onInboxIssuesDeleted(const next = items.filter((i) => i.issue_id === null || !deleted.has(i.issue_id));return next.length === items.length ? items : next;});+ useInboxSelectionStore.getState().forgetRows(wsId, issueIds);const refreshes: Promise<unknown>[] = [onInboxSummaryInvalidate(qc),refreshInboxQuery(qc, inboxKeys.pages(wsId)),diff --git a/packages/core/package.json b/packages/core/package.jsonindex 1517941556..87df9550b1 100644--- a/packages/core/package.json+++ b/packages/core/package.json@@ -74,6 +74,7 @@"./inbox/mutations": "./inbox/mutations.ts","./inbox/filter-store": "./inbox/filter-store.ts","./inbox/selection-store": "./inbox/selection-store.ts",+ "./inbox/open-row": "./inbox/open-row.ts","./inbox/ws-updaters": "./inbox/ws-updaters.ts","./inbox/snooze": "./inbox/snooze.ts","./inbox/use-snooze-wake": "./inbox/use-snooze-wake.ts",diff --git a/packages/views/inbox/components/inbox-kept-actions.tsx b/packages/views/inbox/components/inbox-kept-actions.tsxnew file mode 100644index 0000000000..bc5c8f5280--- /dev/null+++ b/packages/views/inbox/components/inbox-kept-actions.tsx@@ -0,0 +1,134 @@+"use client";++import type { ReactNode } from "react";+import { Archive, ArrowDown, Undo2 } from "@multica/ui/icons";+import { Button } from "@multica/ui/components/ui/button";+import { TooltipHint } from "@multica/ui/components/common/tooltip-hint";+import { cn } from "@multica/ui/lib/utils";+import { useIssueStatuses } from "@multica/core/issue-statuses/hooks";+import type { KeptInboxRow } from "@multica/core/inbox/open-row";+import type { InboxItem } from "@multica/core/types";+import { useLocale, useT } from "../../i18n";+import { ActionShortcutKeycaps } from "../../common/shortcut-keycaps";+import { PAGE_GUTTER } from "../../layout/page-header";+import { useStatusLabel } from "../../issues/utils/status-label";+import { formatSnoozeTime } from "./inbox-snooze-time";+import { getInboxDisplayTitle, isAutopilotQuotaNotice } from "./inbox-display";++/**+ * How a kept row (`keepOpenInboxRow`) says why it is settled: `line` in its+ * place in the list, `notice` beside the open notification.+ */+export function useKeptInboxRowText(wsId: string) {+ const { t } = useT("inbox");+ const locale = useLocale();+ const { categoryOf } = useIssueStatuses(wsId);+ const statusLabelOf = useStatusLabel(wsId);+ // Finishing the issue is what archives its notifications on its own, so the+ // status says why where it can.+ const finished = (item: InboxItem) => {+ const status = item.issue_status;+ if (!status) return null;+ const category = categoryOf(status);+ return category === "done" || category === "closed" ? statusLabelOf(status) : null;+ };+ const backAt = (item: InboxItem) =>+ item.snoozed_until+ ? t(($) => $.snooze.back_at, { time: formatSnoozeTime(new Date(item.snoozed_until), new Date(), locale) })+ : t(($) => $.kept.archived);+ return {+ line: (kept: KeptInboxRow) => {+ if (kept.reason === "filtered") return t(($) => $.kept.filtered);+ const why = kept.reason === "snoozed" ? backAt(kept.item) : (finished(kept.item) ?? t(($) => $.kept.archived));+ return `${why} · ${t(($) => $.kept.leaves)}`;+ },+ notice: (kept: KeptInboxRow) => {+ if (kept.reason === "snoozed") return backAt(kept.item);+ const status = finished(kept.item);+ return status ? `${status} · ${t(($) => $.kept.notification_archived)}` : t(($) => $.kept.notification_archived);+ },+ };+}++/**+ * What the open notification offers once it has left the Inbox on its own+ * (its issue reached Done, another window archived it) and stays on screen+ * until the user moves on: what happened, the way to undo it, and the next+ * notification. `header` sits in the issue header's actions; `strip` is a bar+ * under it, for a phone, whose header has no room.+ */+export function InboxKeptActions({+ label,+ icon,+ onUndo,+ next,+ onNext,+ layout,+}: {+ label: ReactNode;+ /** Defaults to the archive icon. */+ icon?: ReactNode;+ onUndo?: () => void;+ /** The notification `onNext` opens; without one there is nothing to move on to. */+ next: InboxItem | null;+ onNext: () => void;+ layout: "header" | "strip";+}) {+ const { t } = useT("inbox");+ const undo = onUndo && (+ <Button size="sm" variant="ghost" className="text-muted-foreground" onClick={onUndo}>+ <Undo2 />+ {t(($) => $.toasts.undo)}+ </Button>+ );+ const nextButton = next && <InboxNextButton next={next} onNext={onNext} />;+ const status = (+ <span className="flex min-w-0 items-center gap-1 text-caption text-muted-foreground">+ <span aria-hidden className="flex shrink-0 [&_svg]:size-3.5">+ {icon ?? <Archive />}+ </span>+ <span className="truncate">{label}</span>+ </span>+ );++ if (layout === "strip") {+ return (+ <div+ role="status"+ className={cn("flex h-10 shrink-0 items-center gap-2 border-b bg-muted/40", PAGE_GUTTER)}+ >+ <span className="flex min-w-0 flex-1">{status}</span>+ {undo}+ {nextButton}+ </div>+ );+ }+ return (+ <>+ <span role="status" className="mr-1 flex min-w-0">+ {status}+ </span>+ {undo}+ {nextButton}+ <span aria-hidden className="mx-1 h-4 w-px shrink-0 bg-border" />+ </>+ );+}++/** Opens the next notification, named in its tooltip; E does the same. */+export function InboxNextButton({ next, onNext }: { next: InboxItem; onNext: () => void }) {+ const { t } = useT("inbox");+ const title = isAutopilotQuotaNotice(next.type) ? t(($) => $.types[next.type]) : getInboxDisplayTitle(next);+ return (+ <TooltipHint+ label={t(($) => $.kept.next_tooltip, { title })}+ shortcut={<ActionShortcutKeycaps action="archiveInboxItem" />}+ side="bottom"+ >+ <Button size="sm" variant="outline" onClick={onNext}>+ {t(($) => $.kept.next)}+ <ArrowDown />+ </Button>+ </TooltipHint>+ );+}diff --git a/packages/views/inbox/components/inbox-page-query.test.tsx b/packages/views/inbox/components/inbox-page-query.test.tsxindex b4f4b54b66..8416c6bda9 100644--- a/packages/views/inbox/components/inbox-page-query.test.tsx+++ b/packages/views/inbox/components/inbox-page-query.test.tsx@@ -1,5 +1,5 @@import { useEffect, type ReactNode } from "react";-import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";+import { act, cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";import { afterEach, beforeEach, expect, it, vi } from "vitest";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { setApiInstance } from "@multica/core/api";@@ -7,7 +7,7 @@ import type { ApiClient } from "@multica/core/api/client";import { EMPTY_INBOX_FILTERS, filterInboxItems, useInboxFilterStore, type InboxFilters } from "@multica/core/inbox/filter-store";import { archivedInboxLookupOptions, inboxKeys } from "@multica/core/inbox/queries";import { useInboxSelectionStore } from "@multica/core/inbox/selection-store";-import { onInboxIssueDeleted, patchInboxIssueProjection } from "@multica/core/inbox/ws-updaters";+import { onInboxInvalidate, onInboxIssueDeleted, patchInboxIssueProjection } from "@multica/core/inbox/ws-updaters";import type { ArchivedInboxPage } from "@multica/core/types/inbox";import type { InboxItem } from "@multica/core/types";import { InboxPage } from "./inbox-page";@@ -27,9 +27,9 @@ vi.mock("../../modals/use-issue-limit-upgrade-prompt", () => ({const detailUnmounted = vi.hoisted(() => vi.fn());vi.mock("../../issues/components/issue-detail", () => ({- IssueDetail: ({ issueId }: { issueId: string }) => {+ IssueDetail: ({ issueId, notice }: { issueId: string; notice?: ReactNode }) => {useEffect(() => () => detailUnmounted(issueId), [issueId]);- return <div data-testid="detail">{issueId}</div>;+ return <div data-testid="detail">{issueId}<div data-testid="notice">{notice}</div></div>;},issueHighlightMementoKey: (issueId: string) => `highlight:${issueId}`,}));@@ -61,7 +61,7 @@ vi.mock("./inbox-context-menu", () => ({vi.mock("./inbox-detail-label", () => ({ useTypeLabels: () => ({}) }));vi.mock("../../i18n", () => {const t = () => "Inbox";- return { useT: () => ({ t }) };+ return { useT: () => ({ t }), useLocale: () => "en" };});function item(overrides: Partial<InboxItem> = {}): InboxItem {@@ -401,3 +401,52 @@ it("keeps the archived list and its filter menu mounted while a new filter loadsexpect(screen.getByTestId("filter-menu")).toBe(menu);expect(filterMenuUnmounted).not.toHaveBeenCalled();});++it("lets the open notification go once its issue is deleted, rather than keep it in place", async () => {+ useInboxFilterStore.setState({ filtersByWorkspace: {} });+ useInboxSelectionStore.setState({ heldRows: {}, leftRowKeyByWorkspace: {} });+ searchParams = new URLSearchParams("issue=issue-a");+ let rows = [item({ read: true })];+ setApiInstance({ listInbox: async () => rows, getInboxUnreadSummary: async () => [] } as unknown as ApiClient);+ renderPage();+ expect(await screen.findByTestId("detail")).toHaveTextContent("issue-a");+ rows = [];+ await act(async () => { await onInboxIssueDeleted(qc, "workspace-1", "issue-a"); });+ await waitFor(() => expect(screen.queryByTestId("detail")).not.toBeInTheDocument());+ expect(replace).toHaveBeenLastCalledWith("/acme/inbox");+});++it("undoes a remote snooze from the phone kept-row notice by ending the snooze", async () => {+ useInboxFilterStore.setState({ filtersByWorkspace: {} });+ useInboxSelectionStore.setState({ heldRows: {}, leftRowKeyByWorkspace: {} });+ searchParams = new URLSearchParams("issue=issue-a");+ let rows = [item({ read: true })];+ const until = new Date(Date.now() + 3600000).toISOString();+ const snoozed = [{ issue_id: "issue-a", item_id: "inbox-a", snoozed_until: until, snoozed_at: new Date().toISOString(), updates: 0 }];+ let isSnoozed = false;+ const unarchiveInbox = vi.fn(async () => item({ read: true, snoozed_until: until }));+ const unsnoozeInbox = vi.fn(async () => {+ rows = [item({ read: true })];+ isSnoozed = false;+ return { issue_id: "issue-a" };+ });+ setApiInstance({+ listInbox: async () => rows,+ listSnoozedInbox: async () => isSnoozed ? snoozed : [],+ getInboxUnreadSummary: async () => [],+ unarchiveInbox,+ unsnoozeInbox,+ } as unknown as ApiClient);+ renderPage();+ expect(await screen.findByTestId("detail")).toHaveTextContent("issue-a");++ // ListInboxItems excludes snoozed notifications; the separate Snoozed query knows why.+ rows = [];+ isSnoozed = true;+ qc.setQueryData(inboxKeys.snoozed("workspace-1"), snoozed);+ await act(async () => { await onInboxInvalidate(qc, "workspace-1"); });+ fireEvent.click(await within(screen.getByTestId("notice")).findByRole("button", { name: "Inbox" }));+ await waitFor(() => expect(unsnoozeInbox.mock.calls.length + unarchiveInbox.mock.calls.length).toBe(1));+ expect(unarchiveInbox).not.toHaveBeenCalled();+ expect(unsnoozeInbox).toHaveBeenCalledWith("inbox-a", { read: undefined });+});diff --git a/packages/views/inbox/components/inbox-page.test.tsx b/packages/views/inbox/components/inbox-page.test.tsxindex 9b639ee2e0..e85ecce1ef 100644--- a/packages/views/inbox/components/inbox-page.test.tsx+++ b/packages/views/inbox/components/inbox-page.test.tsx@@ -22,6 +22,7 @@ const listData: { active: InboxItem[]; archived: InboxItem[]; lookup?: InboxItemtasks: [],};+const NO_SNOOZED: never[] = [];const queryCalls: Array<{ queryKey: readonly unknown[]; enabled?: boolean }> = [];const lookupState = { isLoading: false, isError: false, refetch: vi.fn() };const queryClient = vi.hoisted(() => ({ setQueryData: vi.fn() }));@@ -33,7 +34,8 @@ vi.mock("@tanstack/react-query", () => ({return ({data: options.queryKey.includes("archived")? { items: listData.lookup ?? listData.archived, hasMore: false, nextCursor: null }- : options.queryKey.includes("agent-task-snapshot") ? listData.tasks : listData.active,+ : options.queryKey.includes("agent-task-snapshot") ? listData.tasks+ : options.queryKey.includes("snoozed") ? NO_SNOOZED : listData.active,isLoading: false,isError: false,refetch: vi.fn(),@@ -76,6 +78,7 @@ vi.mock("@multica/core/inbox/queries", () => ({inboxListOptions: () => ({ queryKey: ["inbox", "workspace-1", "list"] }),archivedInboxPagesOptions: () => ({ queryKey: ["inbox", "workspace-1", "archived", "pages"] }),archivedInboxLookupOptions: () => ({ queryKey: ["inbox", "workspace-1", "archived", "lookup"] }),+ snoozedInboxOptions: () => ({ queryKey: ["inbox", "workspace-1", "snoozed"] }),deduplicateInboxItems: (items: InboxItem[]) => items.filter((i) => !i.archived),deduplicateArchivedInboxItems: (items: InboxItem[]) => items.filter((i) => i.archived),useInboxUnreadCount: () => 2,@@ -99,12 +102,18 @@ vi.mock("../../modals/use-issue-limit-upgrade-prompt", () => ({}));vi.mock("@multica/core/inbox/mutations", () => {- const mutation = () => ({ mutate: vi.fn() });+ const mutation = () => ({ mutate: vi.fn(), mutateAsync: vi.fn(() => Promise.resolve()) });+ // The shared archive handlers await the request; settle it through the spy's callbacks.+ const settled = (spy: typeof archiveMutate) => (id: string) =>+ new Promise<void>((resolve, reject) => spy(id, { onSuccess: resolve, onError: reject }));return {useMarkInboxRead: () => ({ mutate: markReadMutate }),useMarkInboxUnread: () => ({ mutate: markUnreadMutate }),- useArchiveInbox: () => ({ mutate: archiveMutate }),- useUnarchiveInbox: () => ({ mutate: unarchiveMutate }),+ useArchiveInbox: () => ({ mutate: archiveMutate, mutateAsync: settled(archiveMutate) }),+ useUnarchiveInbox: () => ({ mutate: unarchiveMutate, mutateAsync: settled(unarchiveMutate) }),+ useSnoozeInbox: mutation,+ useUnsnoozeInbox: mutation,+ cachedInboxSnoozedUntil: () => null,useMarkAllInboxRead: mutation,useArchiveAllInbox: mutation,useArchiveAllReadInbox: mutation,@@ -228,7 +237,7 @@ vi.mock("./autopilot-quota-notice", () => ({</button>),}));-vi.mock("../../i18n", () => ({ useT: () => ({ t: () => "Inbox" }) }));+vi.mock("../../i18n", () => ({ useT: () => ({ t: () => "Inbox" }), useLocale: () => "en" }));function item(overrides: Partial<InboxItem> = {}): InboxItem {return {@@ -254,7 +263,7 @@ function item(overrides: Partial<InboxItem> = {}): InboxItem {}function reset() {- useInboxSelectionStore.setState({ lastResolvedKeyByWorkspace: {} });+ useInboxSelectionStore.setState({ lastResolvedKeyByWorkspace: {}, heldRows: {}, leftRowKeyByWorkspace: {} });listData.active = [];listData.archived = [];listData.lookup = undefined;@@ -968,6 +977,24 @@ describe("InboxPage", () => {expect(replace).not.toHaveBeenCalledWith("/acme/inbox");});+ it("keeps a phone's open notification in place once it is archived some other way", () => {+ reset();+ searchParams = new URLSearchParams("issue=issue-a");+ listData.active = [+ item({ id: "inbox-a", issue_id: "issue-a" }),+ item({ id: "inbox-b", issue_id: "issue-b" }),+ ];+ const { rerender } = render(<InboxPage />);+ expect(issueDetailProps.at(-1)?.notice).toBeFalsy();++ listData.active = [item({ id: "inbox-b", issue_id: "issue-b" })];+ rerender(<InboxPage />);++ expect(screen.getByTestId("issue-detail")).toHaveTextContent("issue-a");+ expect(issueDetailProps.at(-1)?.notice).toBeTruthy();+ expect(replace).not.toHaveBeenCalledWith("/acme/inbox");+ });+it("keeps an explicitly unread row unread while it stays open", () => {// Without the guard the auto-read effect fires on the very next commit and// silently undoes the user's "mark as unread" — the action looks like a@@ -1190,35 +1217,36 @@ describe("InboxPage", () => {onError?: (err: unknown) => void;};- function settle(+ async function settle(spy: typeof archiveMutate,outcome: "success" | "error",err: unknown = new Error("boom"),) {const options = spy.mock.calls.at(-1)?.[1] as MutateOptions | undefined;- act(() => {+ await act(async () => {if (outcome === "success") options?.onSuccess?.();else options?.onError?.(err);});}- it("confirms an archive from the row action", () => {+ it("confirms an archive from the row action, with an undo", async () => {renderWithActiveItem();act(() => rowActions?.onAction("inbox-a"));- settle(archiveMutate, "success");+ await settle(archiveMutate, "success");+ expect(toast.success).toHaveBeenCalledWith("Inbox", { action: { label: "Inbox", onClick: expect.any(Function) } });expect(toast.success).toHaveBeenCalledTimes(1);});- it("confirms an archive driven by the shortcut", () => {+ it("confirms an archive driven by the shortcut", async () => {renderWithOpenItem();fireEvent.keyDown(document, { key: "e" });- settle(archiveMutate, "success");+ await settle(archiveMutate, "success");expect(toast.success).toHaveBeenCalledTimes(1);});- it("confirms a restore", () => {+ it("confirms a restore", async () => {reset();searchParams = new URLSearchParams("view=archived");listData.archived = [@@ -1227,15 +1255,15 @@ describe("InboxPage", () => {render(<InboxPage />);act(() => rowActions?.onAction("archived-1"));- settle(unarchiveMutate, "success");+ await settle(unarchiveMutate, "success");expect(toast.success).toHaveBeenCalledTimes(1);});- it("reports a failed archive as a failure only", () => {+ it("reports a failed archive as a failure only", async () => {renderWithActiveItem();act(() => rowActions?.onAction("inbox-a"));- settle(archiveMutate, "error");+ await settle(archiveMutate, "error");expect(toast.error).toHaveBeenCalledTimes(1);expect(toast.success).not.toHaveBeenCalled();diff --git a/packages/views/inbox/components/inbox-page.tsx b/packages/views/inbox/components/inbox-page.tsxindex f294f644a1..9239f0e274 100644--- a/packages/views/inbox/components/inbox-page.tsx+++ b/packages/views/inbox/components/inbox-page.tsx@@ -23,6 +23,8 @@ import {import { isImeComposing } from "@multica/core/utils";import { useIssueDraftStore } from "@multica/core/issues/stores/draft-store";import { useInboxSelectionStore } from "@multica/core/inbox/selection-store";+import { inboxRowKey, nextInboxRow } from "@multica/core/inbox/open-row";+import { useIssueStatuses } from "@multica/core/issue-statuses/hooks";import {inboxListOptions,archivedInboxPagesOptions,@@ -34,7 +36,6 @@ import {import {useMarkInboxRead,useMarkInboxUnread,- useArchiveInbox,useUnarchiveInbox,useMarkAllInboxRead,useArchiveAllInbox,@@ -74,6 +75,7 @@ import {ChevronDown,ListChecks,ArrowLeft,+ AlarmClock,} from "@multica/ui/icons";import type { InboxItem } from "@multica/core/types";import { Button } from "@multica/ui/components/ui/button";@@ -116,11 +118,19 @@ import {resolveDetailItem,} from "./inbox-display";import { AutopilotQuotaNotice } from "./autopilot-quota-notice";+import { InboxKeptActions, useKeptInboxRowText } from "./inbox-kept-actions";+import { useFilteredInboxRows } from "./use-filtered-inbox-rows";+import { useKeptOpenInboxRow } from "./use-kept-open-inbox-row";+import { useArchiveInboxBatchWithUndo, useArchiveInboxWithUndo, useRestoreInbox } from "./use-leave-inbox-row";+import { useInboxSnooze } from "./use-inbox-snooze";import { InboxAppRequest } from "../../common/app-requests";import { useT } from "../../i18n";import { useIssueLimitUpgradePrompt } from "../../modals/use-issue-limit-upgrade-prompt";+/** The phone's Inbox list, apart from the Work panel section's. */+const INBOX_PAGE_LIST = "page";+export function InboxPage() {const queryClient = useQueryClient();const { t } = useT("inbox");@@ -258,15 +268,35 @@ export function InboxPage() {// as the issue page does for an issue notification, so a filter can never// refuse to open a row the section offered.const opensAnyLiveRow = !isCompact && !isArchivedView;+ // The open notification stays in place when something other than an Inbox+ // action takes it out of the live list (`keepOpenInboxRow`). On desktop+ // that list is the Work panel section's; a phone keeps it in the page's own.+ const sectionList = useFilteredInboxRows(wsId, selectedKey || null, opensAnyLiveRow);+ const pageList = useKeptOpenInboxRow(+ wsId,+ INBOX_PAGE_LIST,+ filteredItems,+ activeRows,+ selectedKey || null,+ effectiveFilters,+ isCompact && !isArchivedView,+ );+ // Leaving the page leaves its open row.+ useEffect(() => () => useInboxSelectionStore.getState().dropRow(wsId, INBOX_PAGE_LIST), [wsId]);+ const keptRow = isArchivedView ? null : opensAnyLiveRow ? sectionList.kept : pageList.kept;+ // Left the Inbox rather than only the filters, so there is nothing left to act on.+ const settledRow = keptRow && keptRow.reason !== "filtered" ? keptRow : null;const selectionItems = useMemo(() => {- if (opensAnyLiveRow) return items;- if (!isArchivedView || selectedOnPage) return filteredItems;+ if (opensAnyLiveRow) return settledRow ? [...items, settledRow.item] : items;+ if (!isArchivedView) return pageList.rows;+ if (selectedOnPage) return filteredItems;return deduplicateArchivedInboxItems([...filteredItems,...filterInboxItems(lookupItems, effectiveFilters, filterContext),]);- }, [opensAnyLiveRow, items, isArchivedView, selectedOnPage, filteredItems, lookupItems, effectiveFilters, filterContext]);- const visibleItems = isArchivedView && pinnedKey ? selectionItems : filteredItems;+ }, [opensAnyLiveRow, settledRow, items, isArchivedView, pageList.rows, selectedOnPage, filteredItems, lookupItems, effectiveFilters, filterContext]);+ const visibleItems =+ isArchivedView && pinnedKey ? selectionItems : isArchivedView || opensAnyLiveRow ? filteredItems : pageList.rows;// Inbox zero: the bleeding m rises once, at the moment the last notification// leaves; opening an already-empty inbox shows it at rest. Archived and@@ -392,7 +422,12 @@ export function InboxPage() {const markReadMutation = useMarkInboxRead();const [deleteTarget, setDeleteTarget] = useState<InboxItem | null>(null);const markUnreadMutation = useMarkInboxUnread();- const archiveMutation = useArchiveInbox();+ const archiveWithUndo = useArchiveInboxWithUndo();+ const archiveBatchWithUndo = useArchiveInboxBatchWithUndo();+ const restoreInbox = useRestoreInbox();+ const { unsnooze } = useInboxSnooze();+ const keptText = useKeptInboxRowText(wsId);+ const { categoryOf } = useIssueStatuses(wsId);const unarchiveMutation = useUnarchiveInbox();const markAllReadMutation = useMarkAllInboxRead();const archiveAllMutation = useArchiveAllInbox();@@ -551,31 +586,41 @@ export function InboxPage() {// unarchive.// The rows in the order the user sees them: on desktop the Work panel// section's, which applies the same filters.- const listedItems = opensAnyLiveRow ? filteredItems : selectionItems;+ const listedItems = opensAnyLiveRow ? sectionList.rows : selectionItems;+ const leaveRow = useInboxSelectionStore((s) => s.leaveRow);+ // Moving the selection off a row (an Inbox action on it) lets it go rather+ // than keep it in place.const advanceSelectionPast = (id: string, list: InboxItem[]) => {- const idx = list.findIndex((i) => i.id === id);- const target = idx >= 0 ? list[idx] : null;- const wasSelected = !!target && (target.issue_id ?? target.id) === selectedKey;+ const target = list.find((i) => i.id === id);+ const wasSelected = !!target && inboxRowKey(target) === selectedKey;if (!wasSelected) return;- // List is sorted newest-first; prefer the next (older) item, fall back- // to the previous (newer) one when actioning at the bottom, and only- // clear the selection when nothing else is left.- const next = list[idx + 1] ?? list[idx - 1] ?? null;- setSelectedKey(next ? (next.issue_id ?? next.id) : "");+ leaveRow(wsId, selectedKey);+ // Only clear the selection when nothing else is left.+ const next = nextInboxRow(list, selectedKey);+ setSelectedKey(next ? inboxRowKey(next) : "");+ };+ // A batch archive that takes the open row moves on to the next one it leaves.+ const archiveBatch = (+ archive: () => Promise<{ count: number }>,+ archives: (item: InboxItem) => boolean,+ failed: string,+ ) => {+ const open = listedItems.find((i) => inboxRowKey(i) === selectedKey);+ const takesOpen = !!open && archives(open);+ void archiveBatchWithUndo(archive, archives, failed, takesOpen ? selectedKey : null);+ if (!takesOpen) return;+ leaveRow(wsId, selectedKey);+ const next = nextInboxRow(listedItems, selectedKey, archives);+ setSelectedKey(next ? inboxRowKey(next) : "");};// Toasts live in these shared handlers so every archive surface confirms alike.const handleArchive = (id: string) => {advanceSelectionPast(id, listedItems);- archiveMutation.mutate(id, {- onSuccess: () => toast.success(t(($) => $.toasts.archived)),- onError: (err) =>- toast.error(- err instanceof Error && err.message- ? err.message- : t(($) => $.errors.archive_failed),- ),- });+ // Archived already: moving on is all that is left.+ if (settledRow?.item.id === id) return;+ const target = listedItems.find((i) => i.id === id);+ archiveWithUndo(id, target ? inboxRowKey(target) : id);};const handleUnarchive = (id: string) => {@@ -636,30 +681,15 @@ export function InboxPage() {});};- const handleArchiveAll = () => {- setSelectedKey("");- archiveAllMutation.mutate(undefined, {- onError: (err) =>- toast.error(- err instanceof Error && err.message- ? err.message- : t(($) => $.errors.archive_all_failed),- ),- });- };+ const handleArchiveAll = () =>+ archiveBatch(() => archiveAllMutation.mutateAsync(), () => true, t(($) => $.errors.archive_all_failed));- const handleArchiveAllRead = () => {- const readKeys = items.filter((i) => i.read).map((i) => i.issue_id ?? i.id);- if (readKeys.includes(selectedKey)) setSelectedKey("");- archiveAllReadMutation.mutate(undefined, {- onError: (err) =>- toast.error(- err instanceof Error && err.message- ? err.message- : t(($) => $.errors.archive_all_read_failed),- ),- });- };+ const handleArchiveAllRead = () =>+ archiveBatch(+ () => archiveAllReadMutation.mutateAsync(),+ (item) => item.read === true,+ t(($) => $.errors.archive_all_read_failed),+ );// The command bar calls the page's own handlers, so archiving from it moves// the selection and toasts exactly like the row actions do.@@ -692,17 +722,15 @@ export function InboxPage() {),);- const handleArchiveCompleted = () => {- setSelectedKey("");- archiveCompletedMutation.mutate(undefined, {- onError: (err) =>- toast.error(- err instanceof Error && err.message- ? err.message- : t(($) => $.errors.archive_completed_failed),- ),- });- };+ const handleArchiveCompleted = () =>+ archiveBatch(+ () => archiveCompletedMutation.mutateAsync(),+ (item) => {+ const category = item.issue_status ? categoryOf(item.issue_status) : null;+ return category === "done" || category === "closed";+ },+ t(($) => $.errors.archive_completed_failed),+ );// -- Shared sub-components --------------------------------------------------@@ -915,6 +943,24 @@ export function InboxPage() {</div>) : null;+ // The open notification left the Inbox on its own: say so above it, with+ // the way back and the way on.+ const keptNotice =+ settledRow && detailItem && inboxRowKey(detailItem) === settledRow.key ? (+ <InboxKeptActions+ layout="strip"+ label={keptText.notice(settledRow)}+ icon={settledRow.reason === "snoozed" ? <AlarmClock /> : undefined}+ onUndo={() =>+ settledRow.reason === "snoozed"+ ? unsnooze(settledRow.item.id, settledRow.key)+ : void restoreInbox(settledRow.item.id, { quiet: true })+ }+ next={nextInboxRow(listedItems, settledRow.key)}+ onNext={() => advanceSelectionPast(settledRow.item.id, listedItems)}+ />+ ) : null;+const detailContent = detailItem?.issue_id ? (// Key by issue_id (not inbox-item id): a new comment/reaction generates a// new inbox notification for the same issue, and the dedup helper picks the@@ -953,6 +999,7 @@ export function InboxPage() {// false suppresses the detail header's fallback trigger, which is// the way back once the list column is collapsed.leadingAction={compactBackAction ?? (archiveSplit && !listCollapsed ? false : undefined)}+ notice={keptNotice}onDelete={() => {// Issue deletion CASCADE-deletes the inbox item server-side, and the// issue:deleted WS event prunes it from the inbox cache. Just clear@@ -970,6 +1017,8 @@ export function InboxPage() {</IssuePeekHost></ErrorBoundary>) : detailItem ? (+ <>+ {keptNotice}<div className="p-6"><h2 className="text-title font-semibold">{isAutopilotQuotaNotice(detailItem.type)@@ -1104,6 +1153,7 @@ export function InboxPage() {</Tooltip></div></div>+ </>) : null;// -- Compact layout: list / detail toggle -----------------------------------diff --git a/packages/views/inbox/components/snoozed-inbox-page.tsx b/packages/views/inbox/components/snoozed-inbox-page.tsxindex 63dbc6755e..7d282b33db 100644--- a/packages/views/inbox/components/snoozed-inbox-page.tsx+++ b/packages/views/inbox/components/snoozed-inbox-page.tsx@@ -114,7 +114,7 @@ export function SnoozedInboxPage() {interactive: true,cell: (row) => (<SnoozedRowActions- onUnsnooze={() => unsnooze(row.item_id)}+ onUnsnooze={() => unsnooze(row.item_id, row.issue_id)}onSnooze={(until) => snooze({ id: row.item_id }, until)}/>),diff --git a/packages/views/inbox/components/use-filtered-inbox-rows.ts b/packages/views/inbox/components/use-filtered-inbox-rows.tsindex 3a97fabe82..1302999384 100644--- a/packages/views/inbox/components/use-filtered-inbox-rows.ts+++ b/packages/views/inbox/components/use-filtered-inbox-rows.ts@@ -14,6 +14,10 @@ import {} from "@multica/core/inbox/filter-store";import type { AgentTask, InboxItem } from "@multica/core/types";import { deriveIssueSurfaceActivity } from "../../issues/surface/activity";+import { useKeptOpenInboxRow } from "./use-kept-open-inbox-row";++/** The Work panel's Inbox section, and the issue header that works through it. */+export const INBOX_SECTION_LIST = "section";const EMPTY_INBOX: InboxItem[] = [];const EMPTY_TASKS: AgentTask[] = [];@@ -26,7 +30,8 @@ const EMPTY_TASKS: AgentTask[] = [];* `openKey` is the notification open beside the list (`issue_id ?? id`). As* on the Inbox page, it survives the unread and agent filters: opening it* reads it, and replying can start or stop an agent, and neither should take- * the row the user is working in out of the list.+ * the row the user is working in out of the list. Anything else that takes+ * it out leaves it in place as `kept` (`keepOpenInboxRow`).** `enabled: false` reads nothing, for a caller that may not need the list.*/@@ -50,7 +55,7 @@ export function useFilteredInboxRows(wsId: string, openKey: string | null, enabl);// Only an agent filter reads the snapshot, so task churn leaves the list alone while it is off.const agentIssueIds = filters.agent ? activeIssueIds : undefined;- const rows = useMemo(+ const filtered = useMemo(() =>filterInboxItems(notifications, filters, {activeIssueIds: agentIssueIds,@@ -59,9 +64,19 @@ export function useFilteredInboxRows(wsId: string, openKey: string | null, enabl}),[notifications, filters, agentIssueIds, openKey],);+ const { rows, kept } = useKeptOpenInboxRow(+ wsId,+ INBOX_SECTION_LIST,+ filtered,+ notifications,+ openKey,+ filters,+ enabled,+ );return {rows,+ kept,notifications,filtered: inboxFilterCount(filters) > 0,priorityFilterSupport,diff --git a/packages/views/inbox/components/use-inbox-snooze.ts b/packages/views/inbox/components/use-inbox-snooze.tsindex cfcbd15592..6a62ec67d8 100644--- a/packages/views/inbox/components/use-inbox-snooze.ts+++ b/packages/views/inbox/components/use-inbox-snooze.ts@@ -5,6 +5,7 @@ import { useQueryClient } from "@tanstack/react-query";import { toast } from "sonner";import { useWorkspaceId } from "@multica/core/hooks";import { cachedInboxSnoozedUntil, useSnoozeInbox, useUnsnoozeInbox } from "@multica/core/inbox/mutations";+import { useInboxSelectionStore } from "@multica/core/inbox/selection-store";import { useLocale, useT } from "../../i18n";import { formatSnoozeTime } from "./inbox-snooze-time";@@ -13,6 +14,10 @@ import { formatSnoozeTime } from "./inbox-snooze-time";* can be undone from its toast: a first snooze returns the issue as read or* unread as it was before, a change of time puts back the previous time.*+ * Snoozing the open notification leaves its row (`useLeaveInboxRow`); an+ * undo, a failed snooze or bringing it back returns the row, so a row the user+ * stayed on can be kept in place again.+ ** The toasts follow the request's promise rather than per-call mutation* callbacks, which React Query drops once the calling component unmounts, as* it does when snoozing opens the next issue.@@ -25,6 +30,11 @@ export function useInboxSnooze() {const { mutateAsync: snoozeAsync } = useSnoozeInbox();const { mutateAsync: unsnoozeAsync } = useUnsnoozeInbox();+ const returnRow = useCallback(+ (key: string) => useInboxSelectionStore.getState().returnRow(wsId, key),+ [wsId],+ );+const failed = useCallback((fallback: string) => (err: unknown) => {toast.error(err instanceof Error && err.message ? err.message : fallback);@@ -33,10 +43,12 @@ export function useInboxSnooze() {);const snooze = useCallback(- (item: { id: string; read?: boolean }, until: Date) => {+ (item: { id: string; issue_id?: string | null; read?: boolean }, until: Date) => {const wasRead = item.read === true;const previous = cachedInboxSnoozedUntil(qc, wsId, item.id);+ const key = item.issue_id ?? item.id;const undo = () => {+ returnRow(key);if (previous && previous.getTime() > Date.now()) {snoozeAsync({ id: item.id, until: previous }).catch(failed(t(($) => $.snooze.failed)));} else {@@ -48,20 +60,25 @@ export function useInboxSnooze() {toast.success(t(($) => $.snooze.toast_snoozed, { time: formatSnoozeTime(until, new Date(), locale) }), {action: { label: t(($) => $.snooze.undo), onClick: undo },}),- failed(t(($) => $.snooze.failed)),+ (err: unknown) => {+ returnRow(key);+ failed(t(($) => $.snooze.failed))(err);+ },);},- [qc, wsId, snoozeAsync, unsnoozeAsync, failed, t, locale],+ [qc, wsId, snoozeAsync, unsnoozeAsync, returnRow, failed, t, locale],);+ /** `key` is the row of the issue coming back, which snoozing it may have left. */const unsnooze = useCallback(- (itemId: string) => {+ (itemId: string, key: string) => {+ returnRow(key);unsnoozeAsync({ id: itemId }).then(() => toast.success(t(($) => $.snooze.toast_unsnoozed)),failed(t(($) => $.snooze.unsnooze_failed)),);},- [unsnoozeAsync, failed, t],+ [unsnoozeAsync, returnRow, failed, t],);return { snooze, unsnooze };diff --git a/packages/views/inbox/components/use-kept-open-inbox-row.ts b/packages/views/inbox/components/use-kept-open-inbox-row.tsnew file mode 100644index 0000000000..c1844032d0--- /dev/null+++ b/packages/views/inbox/components/use-kept-open-inbox-row.ts@@ -0,0 +1,43 @@+"use client";++import { useLayoutEffect, useMemo } from "react";+import { useQuery } from "@tanstack/react-query";+import { inboxRowKey, keepOpenInboxRow } from "@multica/core/inbox/open-row";+import { snoozedInboxOptions } from "@multica/core/inbox/queries";+import { useInboxSelectionStore } from "@multica/core/inbox/selection-store";+import type { InboxItem, SnoozedInboxIssue } from "@multica/core/types";++const NO_SNOOZED: SnoozedInboxIssue[] = [];++/**+ * `rows` with the open notification's row kept in place once something other+ * than the user's own Inbox action takes it out (`keepOpenInboxRow`). `list`+ * names the list the place is kept in; lists that show the same rows share it.+ * `filters` are the ones `rows` were filtered with, compared by identity.+ *+ * `enabled: false` neither holds nor keeps, for a caller whose open issue was+ * not opened from this list.+ */+export function useKeptOpenInboxRow(+ wsId: string,+ list: string,+ rows: InboxItem[],+ notifications: readonly InboxItem[],+ openKey: string | null,+ filters: object,+ enabled = true,+) {+ const index = enabled && openKey ? rows.findIndex((row) => inboxRowKey(row) === openKey) : -1;+ const item = index >= 0 ? rows[index] : undefined;+ const held = useInboxSelectionStore((s) => (enabled ? s.heldRows[`${wsId}:${list}`] : undefined));+ const left = useInboxSelectionStore((s) => !!openKey && s.leftRowKeyByWorkspace[wsId] === openKey);+ const holdRow = useInboxSelectionStore((s) => s.holdRow);+ const { data: snoozed = NO_SNOOZED } = useQuery({ ...snoozedInboxOptions(wsId), enabled: enabled && !!wsId });+ useLayoutEffect(() => {+ if (wsId && openKey && item && !left) holdRow(wsId, list, { key: openKey, item, index, filters });+ }, [wsId, list, openKey, item, index, filters, left, holdRow]);+ return useMemo(+ () => (left ? { rows, kept: null } : keepOpenInboxRow(rows, notifications, held, openKey, filters, { snoozed })),+ [left, rows, notifications, held, openKey, filters, snoozed],+ );+}diff --git a/packages/views/inbox/components/use-leave-inbox-row.test.tsx b/packages/views/inbox/components/use-leave-inbox-row.test.tsxnew file mode 100644index 0000000000..98351a0ba7--- /dev/null+++ b/packages/views/inbox/components/use-leave-inbox-row.test.tsx@@ -0,0 +1,124 @@+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { act, cleanup, renderHook } from "@testing-library/react";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import type { ReactNode } from "react";+import { toast } from "sonner";+import { setApiInstance } from "@multica/core/api";+import type { ApiClient } from "@multica/core/api/client";+import { I18nProvider } from "@multica/core/i18n/react";+import { inboxListOptions } from "@multica/core/inbox/queries";+import { useInboxSelectionStore } from "@multica/core/inbox/selection-store";+import type { InboxItem } from "@multica/core/types";+import { getTestResources } from "../../test/i18n";+import { useArchiveInboxBatchWithUndo, useArchiveInboxWithUndo } from "./use-leave-inbox-row";++vi.mock("sonner", () => ({ toast: { success: vi.fn(), error: vi.fn() } }));+vi.mock("@multica/core/hooks", () => ({ useWorkspaceId: () => "ws" }));++const api = {+ archiveInbox: vi.fn(async (id: string) => ({ id })),+ unarchiveInbox: vi.fn(async (id: string) => ({ id })),+ listInbox: vi.fn(async () => []),+ getInboxUnreadSummary: vi.fn(async () => []),+};++function item(id: string, overrides: Partial<InboxItem> = {}): InboxItem {+ return {+ id,+ workspace_id: "ws",+ recipient_type: "member",+ recipient_id: "member-1",+ actor_type: "agent",+ actor_id: "agent-1",+ type: "new_comment",+ severity: "info",+ issue_id: null,+ title: id,+ body: null,+ issue_status: "in_progress",+ issue_priority: "none",+ read: true,+ archived: false,+ created_at: "2026-11-10T08:00:00Z",+ details: null,+ ...overrides,+ };+}++function setup<T>(hook: () => T, items: InboxItem[] = []) {+ const qc = new QueryClient({ defaultOptions: { queries: { retry: false, staleTime: Infinity } } });+ qc.setQueryData(inboxListOptions("ws").queryKey, items);+ const resources = getTestResources();+ const wrapper = ({ children }: { children: ReactNode }) => (+ <I18nProvider locale="en" resources={resources}>+ <QueryClientProvider client={qc}>{children}</QueryClientProvider>+ </I18nProvider>+ );+ return renderHook(hook, { wrapper }).result;+}++const undoOf = () =>+ (vi.mocked(toast.success).mock.calls.at(-1)?.[1] as unknown as { action: { onClick: () => void } }).action;+const left = () => useInboxSelectionStore.getState().leftRowKeyByWorkspace.ws;++beforeEach(() => {+ vi.clearAllMocks();+ setApiInstance(api as unknown as ApiClient);+ useInboxSelectionStore.setState({ heldRows: {}, leftRowKeyByWorkspace: { ws: "issue-a" } });+});+afterEach(cleanup);++describe("useArchiveInboxWithUndo", () => {+ it("returns the row it left when undone, so it can be kept in place again", async () => {+ const archive = setup(useArchiveInboxWithUndo);+ await act(() => archive.current("n-a", "issue-a"));+ expect(left()).toBe("issue-a");++ await act(async () => undoOf().onClick());+ expect(left()).toBeUndefined();+ expect(api.unarchiveInbox).toHaveBeenCalledWith("n-a");+ });++ it("returns the row when the archive fails", async () => {+ api.archiveInbox.mockRejectedValueOnce(new Error("Offline"));+ const archive = setup(useArchiveInboxWithUndo);+ await act(() => archive.current("n-a", "issue-a"));+ expect(toast.error).toHaveBeenCalledWith("Offline");+ expect(left()).toBeUndefined();+ });+});++describe("useArchiveInboxBatchWithUndo", () => {+ const items = [+ item("n-a1", { issue_id: "issue-a" }),+ item("n-a2", { issue_id: "issue-a" }),+ item("n-b", { issue_id: "issue-b", read: false }),+ item("n-notice"),+ ];+ const isRead = (row: InboxItem) => row.read === true;++ it("says how many it archived, and its undo restores each row it took", async () => {+ const archiveBatch = setup(useArchiveInboxBatchWithUndo, items);+ await act(() => archiveBatch.current(async () => ({ count: 3 }), isRead, "Failed", "issue-a"));+ expect(toast.success).toHaveBeenCalledWith("3 notifications archived", {+ action: { label: "Undo", onClick: expect.any(Function) },+ });++ await act(async () => undoOf().onClick());+ expect(api.unarchiveInbox.mock.calls.map(([id]) => id)).toEqual(["n-a1", "n-notice"]);+ expect(left()).toBeUndefined();+ });++ it("stays quiet when there was nothing to archive", async () => {+ const archiveBatch = setup(useArchiveInboxBatchWithUndo, items);+ await act(() => archiveBatch.current(async () => ({ count: 0 }), isRead, "Failed", null));+ expect(toast.success).not.toHaveBeenCalled();+ });++ it("reports a failure and returns the open row it left", async () => {+ const archiveBatch = setup(useArchiveInboxBatchWithUndo, items);+ await act(() => archiveBatch.current(() => Promise.reject(new Error("")), isRead, "Failed", "issue-a"));+ expect(toast.error).toHaveBeenCalledWith("Failed");+ expect(left()).toBeUndefined();+ });+});diff --git a/packages/views/inbox/components/use-leave-inbox-row.ts b/packages/views/inbox/components/use-leave-inbox-row.tsnew file mode 100644index 0000000000..cc896bdb71--- /dev/null+++ b/packages/views/inbox/components/use-leave-inbox-row.ts@@ -0,0 +1,148 @@+"use client";++import { useCallback } from "react";+import { useQueryClient } from "@tanstack/react-query";+import { toast } from "sonner";+import { useWorkspaceId } from "@multica/core/hooks";+import { undoArchiveInboxBatch, useArchiveInbox, useUnarchiveInbox } from "@multica/core/inbox/mutations";+import { inboxRowKey } from "@multica/core/inbox/open-row";+import { inboxKeys } from "@multica/core/inbox/queries";+import { useInboxSelectionStore } from "@multica/core/inbox/selection-store";+import { useWorkspacePaths } from "@multica/core/paths";+import type { InboxItem } from "@multica/core/types";+import { useNavigation } from "../../navigation";+import { useT } from "../../i18n";+import { inboxRowHref } from "./inbox-display";++/**+ * Leave the open notification for `next`, as every Inbox action on it does:+ * marking it done, archiving, snoozing or unsubscribing it from the issue+ * header, its sidebar row or that row's card, or a batch archive that takes+ * it. The row leaves its lists for good rather than staying in place+ * (`keepOpenInboxRow`), and with nothing left to open the issue stays, lit+ * nowhere.+ */+export function useLeaveInboxRow() {+ const wsId = useWorkspaceId();+ const p = useWorkspacePaths();+ const { push } = useNavigation();+ const leaveRow = useInboxSelectionStore((s) => s.leaveRow);+ const rememberSidebarIssue = useInboxSelectionStore((s) => s.rememberSidebarIssue);+ return useCallback(+ (key: string, next: InboxItem | null) => {+ leaveRow(wsId, key);+ if (!next) return;+ rememberSidebarIssue(wsId, next.issue_id ?? null);+ push(inboxRowHref(p, next));+ },+ [wsId, p, push, leaveRow, rememberSidebarIssue],+ );+}++const errorMessage = (err: unknown, fallback: string) =>+ err instanceof Error && err.message ? err.message : fallback;++/**+ * Archive a notification and confirm it with a toast that can undo it, the+ * same on every surface. `key` is its row's, which the archive may have left+ * (`useLeaveInboxRow`): undoing or failing returns it, so a row the user+ * stayed on can be kept in place again. The toasts follow the request's+ * promise rather than per-call mutation callbacks, which React Query drops+ * once the calling component unmounts, as it does when archiving opens the+ * next issue.+ */+export function useArchiveInboxWithUndo() {+ const { t } = useT("inbox");+ const wsId = useWorkspaceId();+ const { mutateAsync: archiveAsync } = useArchiveInbox();+ const restore = useRestoreInbox();+ return useCallback(+ (id: string, key: string) => {+ const returnRow = () => useInboxSelectionStore.getState().returnRow(wsId, key);+ return archiveAsync(id).then(+ () =>+ toast.success(t(($) => $.toasts.archived), {+ action: {+ label: t(($) => $.toasts.undo),+ onClick: () => {+ returnRow();+ void restore(id, { quiet: true });+ },+ },+ }),+ (err: unknown) => {+ returnRow();+ toast.error(errorMessage(err, t(($) => $.errors.archive_failed)));+ },+ );+ },+ [wsId, archiveAsync, restore, t],+ );+}++/**+ * Run a batch archive and confirm it with a toast that can undo it. `archives`+ * names the notifications the batch takes, read from the Inbox as it is when+ * the batch starts, since the server reports only how many it took. `openKey`+ * is the open row's, which the batch may have left; undoing or failing+ * returns it.+ */+export function useArchiveInboxBatchWithUndo() {+ const { t } = useT("inbox");+ const wsId = useWorkspaceId();+ const qc = useQueryClient();+ return useCallback(+ (+ archive: () => Promise<{ count: number }>,+ archives: (item: InboxItem) => boolean,+ failed: string,+ openKey: string | null,+ ) => {+ const taken = new Map<string, string>();+ for (const item of qc.getQueryData<InboxItem[]>(inboxKeys.list(wsId)) ?? []) {+ if (!item.archived && archives(item) && !taken.has(inboxRowKey(item))) taken.set(inboxRowKey(item), item.id);+ }+ const returnRow = () => {+ if (openKey) useInboxSelectionStore.getState().returnRow(wsId, openKey);+ };+ return archive().then(+ ({ count }) => {+ if (count === 0) return;+ toast.success(t(($) => $.toasts.archived_many, { count }), {+ action: {+ label: t(($) => $.toasts.undo),+ onClick: () => {+ returnRow();+ undoArchiveInboxBatch(qc, wsId, [...taken.values()]).catch((err: unknown) =>+ toast.error(errorMessage(err, t(($) => $.errors.unarchive_failed))),+ );+ },+ },+ });+ },+ (err: unknown) => {+ returnRow();+ toast.error(errorMessage(err, failed));+ },+ );+ },+ [wsId, qc, t],+ );+}++/** Put an archived notification back in the Inbox. `quiet` skips the toast, for an undo. */+export function useRestoreInbox() {+ const { t } = useT("inbox");+ const { mutateAsync: unarchiveAsync } = useUnarchiveInbox();+ return useCallback(+ (id: string, { quiet = false }: { quiet?: boolean } = {}) =>+ unarchiveAsync(id).then(+ () => {+ if (!quiet) toast.success(t(($) => $.toasts.unarchived));+ },+ (err: unknown) =>+ toast.error(errorMessage(err, t(($) => $.errors.unarchive_failed))),+ ),+ [unarchiveAsync, t],+ );+}diff --git a/packages/views/inbox/components/use-unsubscribe-archive.test.tsx b/packages/views/inbox/components/use-unsubscribe-archive.test.tsxindex 32454d3957..a674ebb69f 100644--- a/packages/views/inbox/components/use-unsubscribe-archive.test.tsx+++ b/packages/views/inbox/components/use-unsubscribe-archive.test.tsx@@ -8,11 +8,57 @@ import { I18nProvider } from "@multica/core/i18n/react";import { toast } from "sonner";import enInbox from "../../locales/en/inbox.json";import { useUnsubscribeArchive } from "./use-unsubscribe-archive";+import { useKeptOpenInboxRow } from "./use-kept-open-inbox-row";+import { useInboxSelectionStore } from "@multica/core/inbox/selection-store";+import type { InboxItem } from "@multica/core/types";vi.mock("@multica/core/hooks", () => ({ useWorkspaceId: () => "ws-review" }));vi.mock("sonner", () => ({ toast: { success: vi.fn(), error: vi.fn() } }));afterEach(() => { cleanup(); vi.clearAllMocks(); });+it.each(["failure", "undo"])("keeps the last row on a later side-effect archive after unsubscribe %s", async (outcome) => {+ useInboxSelectionStore.setState({ heldRows: {}, leftRowKeyByWorkspace: {} });+ const qc = createQueryClient();+ const row = { id: "notification-review", issue_id: "issue-review", archived: false } as InboxItem;+ const filters = {};+ const unarchiveInbox = vi.fn(async () => ({}));+ setApiInstance({+ unsubscribeFromIssue: vi.fn(async () => {+ if (outcome === "failure") throw new Error("unsubscribe failed");+ }),+ archiveInbox: vi.fn(async () => ({})),+ undoUnsubscribeFromIssue: vi.fn(async () => {}),+ unarchiveInbox,+ listSubscribedIssueIds: vi.fn(async () => []),+ } as unknown as ApiClient);+ const { result, rerender } = renderHook(({ rows }: { rows: InboxItem[] }) => ({+ unsubscribe: useUnsubscribeArchive(),+ list: useKeptOpenInboxRow("ws-review", "section", rows, rows, "issue-review", filters),+ }), {+ initialProps: { rows: [row] },+ wrapper: ({ children }) => <QueryClientProvider client={qc}>+ <I18nProvider locale="en" resources={{ en: { inbox: enInbox } }}>{children}</I18nProvider>+ </QueryClientProvider>,+ });+ act(() => {+ result.current.unsubscribe({ id: row.id, issueId: row.issue_id! });+ useInboxSelectionStore.getState().leaveRow("ws-review", row.issue_id!);+ });+ if (outcome === "failure") {+ await waitFor(() => expect(toast.error).toHaveBeenCalledWith("unsubscribe failed"));+ } else {+ await waitFor(() => expect(toast.success).toHaveBeenCalledOnce());+ rerender({ rows: [] });+ const options = vi.mocked(toast.success).mock.calls[0]![1] as unknown as { action: { onClick: () => void } };+ await act(async () => options.action.onClick());+ await waitFor(() => expect(unarchiveInbox).toHaveBeenCalledWith(row.id));+ rerender({ rows: [row] });+ }+ rerender({ rows: [] });+ expect(result.current.list.kept?.reason).toBe("archived");+ expect(result.current.list.rows).toEqual([row]);+});+it.each([[false, false], [false, true], [true, false], [true, true]])("reports completion (navigation=%s, failure=%s)", async (navigate, fail) => {const qc = createQueryClient();let finish!: () => void;diff --git a/packages/views/inbox/components/use-unsubscribe-archive.ts b/packages/views/inbox/components/use-unsubscribe-archive.tsindex aaed5cf6f6..fa766674e4 100644--- a/packages/views/inbox/components/use-unsubscribe-archive.ts+++ b/packages/views/inbox/components/use-unsubscribe-archive.ts@@ -7,6 +7,7 @@ import { useWorkspaceId } from "@multica/core/hooks";import { isOwnIssue } from "@multica/core/issues/ownership";import type { InboxItem } from "@multica/core/types";import { agentListOptions } from "@multica/core/workspace/queries";+import { useInboxSelectionStore } from "@multica/core/inbox/selection-store";import {undoUnsubscribeArchiveInbox,useUnsubscribeArchiveInbox,@@ -49,6 +50,10 @@ export interface UnsubscribeArchiveTarget {* offered for a single issue only: a subtree opt-out tombstones every* descendant, and one issue's undo would not bring those back.*+ * Its row is the issue's, which the surface leaves (`useLeaveInboxRow`); an+ * undo or a failure returns it, so a row the user stayed on can be kept in+ * place again.+ ** The toasts hang off the mutation itself, not the `mutate` call: every* surface moves on to the next notification straight away, which unmounts the* caller before the request settles.@@ -59,6 +64,7 @@ export function useUnsubscribeArchive() {const wsId = useWorkspaceId();const failed = (fallback: string) => (err: unknown) =>toast.error(err instanceof Error && err.message ? err.message : fallback);+ const returnRow = (issueId: string) => useInboxSelectionStore.getState().returnRow(wsId, issueId);const { mutate } = useUnsubscribeArchiveInbox({onSuccess: ({ id, issueId, scope }) =>toast.success(@@ -72,6 +78,7 @@ export function useUnsubscribeArchive() {? {label: t(($) => $.toasts.undo),onClick: () => {+ returnRow(issueId);undoUnsubscribeArchiveInbox(qc, wsId, { id, issueId }).catch(failed(t(($) => $.errors.undo_unsubscribe_failed)),);@@ -80,7 +87,10 @@ export function useUnsubscribeArchive() {: undefined,},),- onError: failed(t(($) => $.errors.unsubscribe_archive_failed)),+ onError: (err, { issueId }) => {+ returnRow(issueId);+ failed(t(($) => $.errors.unsubscribe_archive_failed))(err);+ },});return useCallback((target: UnsubscribeArchiveTarget, scope: InboxUnsubscribeScope = "issue") =>diff --git a/packages/views/issues/actions/__tests__/issue-inbox-actions.test.tsx b/packages/views/issues/actions/__tests__/issue-inbox-actions.test.tsxindex d66d859f03..9616b76f63 100644--- a/packages/views/issues/actions/__tests__/issue-inbox-actions.test.tsx+++ b/packages/views/issues/actions/__tests__/issue-inbox-actions.test.tsx@@ -17,6 +17,7 @@ import { IssueInboxActions } from "../issue-inbox-actions";const state = vi.hoisted(() => ({archiveInbox: vi.fn(),+ unarchiveInbox: vi.fn(() => Promise.resolve()),unsubscribeArchive: vi.fn(),snooze: vi.fn(() => Promise.resolve()),unsnooze: vi.fn(() => Promise.resolve()),@@ -93,6 +94,7 @@ function setup({};setApiInstance({archiveInbox: state.archiveInbox,+ unarchiveInbox: state.unarchiveInbox,listInbox: async () => rows,listSnoozedInbox: async () => snoozed,getInboxUnreadSummary: async () => [],@@ -130,7 +132,7 @@ function setup({const arrive = (id: string) => rerender(page(id));/** The next page replacing this one, taking the header with it. */const leave = () => rerender(page(null));- return Object.assign(nav, { arrive, leave });+ return Object.assign(nav, { arrive, leave, qc });}/** An archive request the test settles by hand, after the header is gone. */@@ -148,12 +150,48 @@ function pendingArchive() {beforeEach(() => {vi.clearAllMocks();state.archiveInbox.mockImplementation(async (id: string) => item({ id, archived: true }));- useInboxSelectionStore.setState({ sidebarIssueByWorkspace: { ws: "issue-1" }, sidebarTabIssuesByWorkspace: {} });+ useInboxSelectionStore.setState({+ sidebarIssueByWorkspace: { ws: "issue-1" },+ sidebarTabIssuesByWorkspace: {},+ heldRows: {},+ leftRowKeyByWorkspace: {},+ });useInboxFilterStore.getState().clearFilters("ws");});afterEach(cleanup);describe("IssueInboxActions", () => {+ it("keeps the last row on a later side-effect archive after snooze fails", async () => {+ state.snooze.mockRejectedValueOnce(new Error("snooze failed"));+ const nav = setup({ rows: [ROWS[0]!] });+ fireEvent.keyDown(document, { key: "h", code: "KeyH" });+ fireEvent.click(await screen.findByRole("menuitem", { name: /^1 hour/ }));+ await waitFor(() => expect(toast.error).toHaveBeenCalledWith("snooze failed"));+ expect(nav.push).not.toHaveBeenCalled();++ act(() => nav.qc.setQueryData(inboxListOptions("ws").queryKey, []));+ expect(await screen.findByText("Notification archived")).toBeInTheDocument();+ expect(screen.getByRole("button", { name: "Undo" })).toBeInTheDocument();+ });++ it("keeps the last row on a later side-effect archive after undoing snooze", async () => {+ const nav = setup({ rows: [ROWS[0]!] });+ fireEvent.keyDown(document, { key: "h", code: "KeyH" });+ fireEvent.click(await screen.findByRole("menuitem", { name: /^1 hour/ }));+ await waitFor(() => expect(toast.success).toHaveBeenCalledOnce());+ act(() => nav.qc.setQueryData(inboxListOptions("ws").queryKey, []));++ const options = vi.mocked(toast.success).mock.calls[0]![1] as unknown as { action: { onClick: () => void } };+ await act(async () => options.action.onClick());+ expect(state.unsnooze).toHaveBeenCalledWith({ id: "n-1", read: true });+ act(() => nav.qc.setQueryData(inboxListOptions("ws").queryKey, [ROWS[0]!]));+ expect(await screen.findByRole("button", { name: "Archive" })).toBeInTheDocument();++ act(() => nav.qc.setQueryData(inboxListOptions("ws").queryKey, []));+ expect(await screen.findByText("Notification archived")).toBeInTheDocument();+ expect(screen.getByRole("button", { name: "Undo" })).toBeInTheDocument();+ });+it("stays out of an issue that was not opened from the Inbox", () => {useInboxSelectionStore.setState({ sidebarIssueByWorkspace: { ws: "issue-2" } });setup();@@ -225,6 +263,70 @@ describe("IssueInboxActions", () => {expect(state.unsnooze).toHaveBeenCalledWith({ id: "n-1" });});+ it("stays in place once the notification leaves the Inbox some other way, with undo and the next one", async () => {+ const nav = setup();+ act(() => nav.qc.setQueryData(inboxListOptions("ws").queryKey, [ROWS[1]!]));++ expect(await screen.findByText("Notification archived")).toBeInTheDocument();+ expect(screen.queryByRole("button", { name: "Archive" })).toBeNull();+ expect(nav.push).not.toHaveBeenCalled();++ await act(async () => fireEvent.click(screen.getByRole("button", { name: "Undo" })));+ expect(state.unarchiveInbox).toHaveBeenCalledWith("n-1");+ expect(toast.success).not.toHaveBeenCalled();+ });++ it("names the status that archived it, and opens the next one", async () => {+ const nav = setup({ rows: [{ ...ROWS[0]!, issue_status: "done" }, ROWS[1]!] });+ act(() => nav.qc.setQueryData(inboxListOptions("ws").queryKey, [ROWS[1]!]));++ expect(await screen.findByText("Done · Notification archived")).toBeInTheDocument();+ fireEvent.click(screen.getByRole("button", { name: "Next" }));+ expect(nav.push).toHaveBeenCalledWith("/acme/issues/issue-2#comment-c-9");+ expect(useInboxSelectionStore.getState().sidebarIssueByWorkspace.ws).toBe("issue-2");+ });++ it("moves on with E rather than archiving again", async () => {+ const nav = setup();+ act(() => nav.qc.setQueryData(inboxListOptions("ws").queryKey, [ROWS[1]!]));++ await screen.findByText("Notification archived");+ fireEvent.keyDown(document, { key: "e", code: "KeyE" });+ expect(nav.push).toHaveBeenCalledWith("/acme/issues/issue-2#comment-c-9");+ expect(state.archiveInbox).not.toHaveBeenCalled();+ });++ it("archives once done is saved, with an undo that restores only the notification, and moves on", async () => {+ const archive = pendingArchive();+ const onMarkDone = vi.fn((onSaved: () => void) => onSaved());+ const nav = setup({ onMarkDone });+ fireEvent.click(screen.getByRole("button", { name: "Mark as done" }));+ await waitFor(() => expect(state.archiveInbox).toHaveBeenCalledWith("n-1"));+ expect(nav.push).toHaveBeenCalledWith("/acme/issues/issue-2#comment-c-9");+ nav.leave();+ await archive.resolve();++ expect(toast.success).toHaveBeenCalledWith("Notification archived", {+ action: { label: "Undo", onClick: expect.any(Function) },+ });+ const undo = vi.mocked(toast.success).mock.calls.at(-1)?.[1] as unknown as { action: { onClick: () => void } };+ await act(async () => undo.action.onClick());+ expect(state.unarchiveInbox).toHaveBeenCalledWith("n-1");+ expect(onMarkDone).toHaveBeenCalledTimes(1);+ });++ it("returns the row snoozing left once the issue is brought back early", () => {+ useInboxSelectionStore.setState({ leftRowKeyByWorkspace: { ws: "issue-1" } });+ const until = new Date(Date.now() + 60 * 60 * 1000).toISOString();+ setup({+ rows: [ROWS[1]!],+ snoozed: [{ issue_id: "issue-1", item_id: "n-1", snoozed_until: until, snoozed_at: SNOOZED_AT, updates: 0 }],+ });+ fireEvent.keyDown(document, { key: "h", code: "KeyH" });+ expect(state.unsnooze).toHaveBeenCalledWith({ id: "n-1" });+ expect(useInboxSelectionStore.getState().leftRowKeyByWorkspace.ws).toBeUndefined();+ });+it("archives and moves on to the next notification", async () => {const nav = setup();fireEvent.click(screen.getByRole("button", { name: "Archive" }));@@ -233,7 +335,7 @@ describe("IssueInboxActions", () => {await waitFor(() => expect(state.archiveInbox).toHaveBeenCalledWith("n-1"));});- it("still confirms the archive after the next issue replaces this one", async () => {+ it("still confirms the archive, with an undo, after the next issue replaces this one", async () => {const archive = pendingArchive();const nav = setup();fireEvent.click(screen.getByRole("button", { name: "Archive" }));@@ -241,8 +343,13 @@ describe("IssueInboxActions", () => {nav.leave();await archive.resolve();- expect(toast.success).toHaveBeenCalledWith("Notification archived");+ expect(toast.success).toHaveBeenCalledWith("Notification archived", {+ action: { label: "Undo", onClick: expect.any(Function) },+ });expect(toast.error).not.toHaveBeenCalled();+ const undo = vi.mocked(toast.success).mock.calls.at(-1)?.[1] as unknown as { action: { onClick: () => void } };+ await act(async () => undo.action.onClick());+ expect(state.unarchiveInbox).toHaveBeenCalledWith("n-1");});it("still reports a failed archive after the next issue replaces this one", async () => {@@ -353,3 +460,34 @@ describe("IssueInboxActions", () => {expect(screen.queryByRole("button", { name: "Unsubscribe & archive" })).toBeNull();});});++describe("IssueInboxActions once an action is undone or never saved", () => {+ it("keeps the row again after archiving the last row and undoing", async () => {+ const original = ROWS[0]!;+ const rows = [original];+ state.archiveInbox.mockImplementation(async () => {+ rows.splice(0);+ return { ...original, archived: true };+ });+ state.unarchiveInbox.mockImplementation(async () => { rows.push(original); });+ const nav = setup({ rows });+ fireEvent.click(screen.getByRole("button", { name: "Archive" }));+ await waitFor(() => expect(toast.success).toHaveBeenCalled());+ expect(nav.push).not.toHaveBeenCalled();+ const undo = vi.mocked(toast.success).mock.calls.at(-1)?.[1] as unknown as { action: { onClick: () => void } };+ await act(async () => undo.action.onClick());+ await screen.findByRole("button", { name: "Archive" });+ // The user continues reading the same issue; a later status change archives it.+ act(() => nav.qc.setQueryData(inboxListOptions("ws").queryKey, []));+ expect(await screen.findByText("Notification archived")).toBeInTheDocument();+ });++ it("keeps the row after a failed mark-done followed by a status-side-effect archive", async () => {+ const nav = setup({ rows: [ROWS[0]!], onMarkDone: () => {} });+ // No success callback: the status write failed and the user stayed here.+ fireEvent.click(screen.getByRole("button", { name: "Mark as done" }));+ expect(nav.push).not.toHaveBeenCalled();+ act(() => nav.qc.setQueryData(inboxListOptions("ws").queryKey, []));+ expect(await screen.findByText("Notification archived")).toBeInTheDocument();+ });+});diff --git a/packages/views/issues/actions/issue-inbox-actions.tsx b/packages/views/issues/actions/issue-inbox-actions.tsxindex ce45e24b3e..d1792a450d 100644--- a/packages/views/issues/actions/issue-inbox-actions.tsx+++ b/packages/views/issues/actions/issue-inbox-actions.tsx@@ -1,17 +1,15 @@"use client";-import { useEffect, useRef, useState } from "react";+import { type ReactNode, useEffect, useRef, useState } from "react";import { useQuery } from "@tanstack/react-query";-import { toast } from "sonner";import { AlarmClock, Archive, ChevronDown, CircleCheck } from "@multica/ui/icons";import { IconButton } from "@multica/ui/components/common/icon-button";import { cn } from "@multica/ui/lib/utils";import { useWorkspaceId } from "@multica/core/hooks";-import { useWorkspacePaths } from "@multica/core/paths";import { useModalStore } from "@multica/core/modals";-import { useArchiveInbox, type InboxUnsubscribeScope } from "@multica/core/inbox/mutations";+import type { InboxUnsubscribeScope } from "@multica/core/inbox/mutations";import { findSnoozedInboxIssue, snoozedInboxOptions } from "@multica/core/inbox/queries";-import { useInboxSelectionStore } from "@multica/core/inbox/selection-store";+import { nextInboxRow } from "@multica/core/inbox/open-row";import {getShortcut,isEditableShortcutTarget,@@ -20,7 +18,7 @@ import {} from "@multica/core/shortcuts";import { isImeComposing } from "@multica/core/utils";import { ActionShortcutKeycaps } from "../../common/shortcut-keycaps";-import { inboxRowHref } from "../../inbox/components/inbox-display";+import { InboxKeptActions, InboxNextButton, useKeptInboxRowText } from "../../inbox/components/inbox-kept-actions";import { InboxSnoozeMenu } from "../../inbox/components/inbox-snooze-menu";import { formatSnoozeTime } from "../../inbox/components/inbox-snooze-time";import { useInboxSnooze } from "../../inbox/components/use-inbox-snooze";@@ -28,7 +26,11 @@ import { useFilteredInboxRows } from "../../inbox/components/use-filtered-inbox-import { useSidebarInboxIssue } from "../../inbox/components/use-sidebar-inbox-issue";import { UnsubscribeArchiveButton } from "../../inbox/components/unsubscribe-archive-button";import { useUnsubscribeArchive } from "../../inbox/components/use-unsubscribe-archive";-import { useNavigation } from "../../navigation";+import {+ useArchiveInboxWithUndo,+ useLeaveInboxRow,+ useRestoreInbox,+} from "../../inbox/components/use-leave-inbox-row";import { useLocale, useT } from "../../i18n";/**@@ -37,6 +39,10 @@ import { useLocale, useT } from "../../i18n";* snoozing, archiving or unsubscribing opens the next notification the* section lists, so the Inbox can be worked through without leaving the page.*+ * Once its notification leaves the Inbox on its own (the issue reached Done,+ * another window archived it), the section keeps the row in place and this+ * says so instead, with an undo and the way on to the next notification.+ ** A snoozed issue shows when it comes back instead, wherever it is opened,* with the way to bring it back now or change the time.*@@ -53,75 +59,65 @@ export function IssueInboxActions({const { t } = useT("inbox");const { t: tIssues } = useT("issues");const wsId = useWorkspaceId();- const p = useWorkspacePaths();- const { push } = useNavigation();const { fromInbox } = useSidebarInboxIssue(wsId, issueId);- const rememberSidebarIssue = useInboxSelectionStore((s) => s.rememberSidebarIssue);- const { rows } = useFilteredInboxRows(wsId, issueId, fromInbox);+ const { rows, kept } = useFilteredInboxRows(wsId, issueId, fromInbox);const index = fromInbox ? rows.findIndex((row) => row.issue_id === issueId) : -1;- const item = index >= 0 ? rows[index]! : null;- const { mutateAsync: archiveAsync } = useArchiveInbox();+ const row = index >= 0 ? rows[index]! : null;+ // A row kept after it left the Inbox on its own is no longer there to act on.+ const settled = kept && kept.reason !== "filtered" ? kept : null;+ const item = settled ? null : row;+ const next = row ? nextInboxRow(rows, issueId) : null;+ const leave = useLeaveInboxRow();+ const archiveWithUndo = useArchiveInboxWithUndo();+ const restore = useRestoreInbox();const unsubscribeArchive = useUnsubscribeArchive();const { snooze, unsnooze } = useInboxSnooze();const { data: snoozedList } = useQuery(snoozedInboxOptions(wsId));const snoozed = item ? undefined : findSnoozedInboxIssue(snoozedList, issueId);+ const keptText = useKeptInboxRowText(wsId);const [snoozeOpen, setSnoozeOpen] = useState(false);- const failed = (fallback: string) => (err: unknown) =>- toast.error(err instanceof Error && err.message ? err.message : fallback);-- // Rows run newest first: move on to the older one, else the newer one.- const openNext = (next: (typeof rows)[number] | null) => {- if (!next) return;- rememberSidebarIssue(wsId, next.issue_id ?? null);- push(inboxRowHref(p, next));- };-- // Toasts follow the request's promise: the next issue's page can replace- // this header first, and React Query drops per-call callbacks with it.const archiveItem = () => {if (!item) return;- const next = rows[index + 1] ?? rows[index - 1] ?? null;- archiveAsync(item.id).then(- () => toast.success(t(($) => $.toasts.archived)),- failed(t(($) => $.errors.archive_failed)),- );- openNext(next);+ archiveWithUndo(item.id, issueId);+ leave(issueId, next);};const unsubscribeItem = (scope: InboxUnsubscribeScope) => {if (!item?.issue_id) return;- const next = rows[index + 1] ?? rows[index - 1] ?? null;unsubscribeArchive({ id: item.id, issueId: item.issue_id }, scope);- openNext(next);+ leave(issueId, next);};const snoozeItem = (until: Date) => {if (!item) return;- const next = rows[index + 1] ?? rows[index - 1] ?? null;snooze(item, until);- openNext(next);+ leave(issueId, next);};// Done archives the issue's notifications on the server; archiving here as- // well takes the row out at once instead of when that event arrives.+ // well confirms it with an undo, which restores the notification and leaves+ // the issue done. Until the status is saved the row stays, so a write that+ // fails or never happens leaves it as it was.const markDone = () => {if (!item || !onMarkDone) return;- const next = rows[index + 1] ?? rows[index - 1] ?? null;onMarkDone(() => {- archiveAsync(item.id).catch(failed(t(($) => $.errors.archive_failed)));- openNext(next);+ void archiveWithUndo(item.id, issueId);+ leave(issueId, next);});};+ const moveOn = () => leave(issueId, next);+const archiveRef = useRef<(() => void) | null>(null);const snoozeRef = useRef<(() => void) | null>(null);useEffect(() => {- archiveRef.current = item ? archiveItem : null;+ // Archived already, E moves on as archiving would have.+ archiveRef.current = item ? archiveItem : settled && next ? moveOn : null;snoozeRef.current = item? () => setSnoozeOpen(true): snoozed- ? () => unsnooze(snoozed.item_id)+ ? () => unsnooze(snoozed.item_id, issueId): null;});useEffect(() => {@@ -144,14 +140,27 @@ export function IssueInboxActions({}, []);if (!item) {- if (!snoozed) return null;+ if (snoozed) {+ return (+ <SnoozedChip+ until={new Date(snoozed.snoozed_until)}+ open={snoozeOpen}+ onOpenChange={setSnoozeOpen}+ onSnooze={(until) => snooze({ id: snoozed.item_id }, until)}+ onUnsnooze={() => unsnooze(snoozed.item_id, issueId)}+ >+ {settled && next && <InboxNextButton next={next} onNext={moveOn} />}+ </SnoozedChip>+ );+ }+ if (!settled) return null;return (- <SnoozedChip- until={new Date(snoozed.snoozed_until)}- open={snoozeOpen}- onOpenChange={setSnoozeOpen}- onSnooze={(until) => snooze({ id: snoozed.item_id }, until)}- onUnsnooze={() => unsnooze(snoozed.item_id)}+ <InboxKeptActions+ label={keptText.notice(settled)}+ onUndo={() => restore(settled.item.id, { quiet: true })}+ next={next}+ onNext={moveOn}+ layout="header"/>);}@@ -205,12 +214,15 @@ function SnoozedChip({onOpenChange,onSnooze,onUnsnooze,+ children,}: {until: Date;open: boolean;onOpenChange: (open: boolean) => void;onSnooze: (until: Date) => void;onUnsnooze: () => void;+ /** After the chip, before the separator. */+ children?: ReactNode;}) {const { t } = useT("inbox");const locale = useLocale();@@ -238,6 +250,7 @@ function SnoozedChip({</button>}/>+ {children}<span aria-hidden className="mx-1 h-4 w-px shrink-0 bg-border" /></>);diff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsxindex 17de7833e7..4d6d1bf904 100644--- a/packages/views/issues/components/issue-detail.tsx+++ b/packages/views/issues/components/issue-detail.tsx@@ -1260,6 +1260,8 @@ interface IssueDetailProps {variant?: "page" | "peek";/** Peek only: host controls at the end of the header (open full page, close). */trailingActions?: ReactNode;+ /** A bar the host shows under the header, above the scrolling body. */+ notice?: ReactNode;/*** Read the viewer's inbox notifications on this issue while it is on screen* (MUL-8588). The inbox turns this off for the issue it has open: it reads@@ -1479,7 +1481,7 @@ export function IssueDetailSkeleton({// IssueDetail-export function IssueDetail({ issueId, onDelete, onDone, onUnsubscribeArchive, defaultSidebarOpen = true, layoutId = ISSUE_DETAIL_LAYOUT_ID, highlightCommentId: linkedCommentId, highlightRequestToken: linkedRequestToken, highlightAppRequestId, leadingAction, variant = "page", trailingActions, readsInbox = true, skipInitialRefetch = false, openDeliverable, onDeliverableLinkDone }: IssueDetailProps) {+export function IssueDetail({ issueId, onDelete, onDone, onUnsubscribeArchive, defaultSidebarOpen = true, layoutId = ISSUE_DETAIL_LAYOUT_ID, highlightCommentId: linkedCommentId, highlightRequestToken: linkedRequestToken, highlightAppRequestId, leadingAction, variant = "page", trailingActions, notice, readsInbox = true, skipInitialRefetch = false, openDeliverable, onDeliverableLinkDone }: IssueDetailProps) {const isPeek = variant === "peek";const { t } = useT("issues");const { t: tCommon } = useT("common");@@ -3665,6 +3667,7 @@ export function IssueDetail({ issueId, onDelete, onDone, onUnsubscribeArchive, d</>}/>+ {notice}{/* scrollbar-gutter both-edges: with classic (space-taking) scrollbars —macOS with a mouse or "always show", Windows, Linux — the globaldiff --git a/packages/views/layout/panels/inbox-section.test.tsx b/packages/views/layout/panels/inbox-section.test.tsxindex 355e4a832c..bfdd138dc7 100644--- a/packages/views/layout/panels/inbox-section.test.tsx+++ b/packages/views/layout/panels/inbox-section.test.tsx@@ -1,5 +1,5 @@import type { ReactNode } from "react";-import { fireEvent, screen, waitFor, within } from "@testing-library/react";+import { act, fireEvent, screen, waitFor, within } from "@testing-library/react";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { beforeEach, describe, expect, it, vi } from "vitest";import {@@ -20,6 +20,7 @@ const state = vi.hoisted(() => ({unread: 0,compact: false,archive: vi.fn(),+ unarchive: vi.fn(() => Promise.resolve()),unsubscribeArchive: vi.fn(),markAllRead: vi.fn(),archiveAll: vi.fn(),@@ -40,11 +41,18 @@ vi.mock("@multica/core/inbox/queries", async (importOriginal) => ({useInboxUnreadCount: () => state.unread,}));vi.mock("@multica/core/inbox/mutations", () => ({- useArchiveInbox: () => ({ mutate: state.archive }),+ useArchiveInbox: () => ({+ mutate: state.archive,+ mutateAsync: (id: string) => {+ state.archive(id);+ return Promise.resolve();+ },+ }),+ useUnarchiveInbox: () => ({ mutateAsync: state.unarchive }),useMarkAllInboxRead: () => ({ mutate: state.markAllRead }),- useArchiveAllInbox: () => ({ mutate: state.archiveAll }),- useArchiveAllReadInbox: () => ({ mutate: state.archiveAllRead }),- useArchiveCompletedInbox: () => ({ mutate: state.archiveCompleted }),+ useArchiveAllInbox: () => ({ mutateAsync: async () => (await state.archiveAll()) ?? { count: 1 } }),+ useArchiveAllReadInbox: () => ({ mutateAsync: async () => (await state.archiveAllRead()) ?? { count: 1 } }),+ useArchiveCompletedInbox: () => ({ mutateAsync: async () => (await state.archiveCompleted()) ?? { count: 1 } }),useMarkInboxRead: () => ({ mutate: state.markRead }),useMarkInboxUnread: () => ({ mutate: state.markUnread }),useUnsubscribeArchiveInbox: () => ({ mutate: state.unsubscribeArchive }),@@ -135,7 +143,7 @@ function renderSection(</NavigationProvider></QueryClientProvider>,);- return { ...result, nav };+ return { ...result, nav, client };}const rows = () => Array.from(document.querySelectorAll<HTMLElement>("[data-inbox-row]"));@@ -156,7 +164,7 @@ beforeEach(() => {}useSidebarTreeStore.setState({ inboxCollapsed: false, inboxSettings: DEFAULT_SIDEBAR_INBOX_SETTINGS });useInboxFilterStore.getState().clearFilters("ws-1");- useInboxSelectionStore.setState({ landing: null });+ useInboxSelectionStore.setState({ landing: null, heldRows: {}, leftRowKeyByWorkspace: {} });});describe("InboxSection", () => {@@ -396,6 +404,43 @@ describe("InboxSection", () => {expect(state.archive).toHaveBeenCalledWith("n1");});+ it("opens the next row once the open one is archived from its row, and stays put for any other", () => {+ const { nav } = renderSection(+ [+ item({ id: "n1", issue_id: "issue-a", title: "Open one" }),+ item({ id: "n2", issue_id: "issue-b", title: "Next one", created_at: "2026-11-09T08:00:00Z" }),+ item({ id: "n3", issue_id: "issue-c", title: "Last one", created_at: "2026-11-08T08:00:00Z" }),+ ],+ "issue-a",+ );+ fireEvent.click(within(rows()[2]!).getByRole("button", { name: "Archive" }));+ expect(state.archive).toHaveBeenCalledWith("n3");+ expect(nav.push).not.toHaveBeenCalled();++ fireEvent.click(within(rows()[0]!).getByRole("button", { name: "Archive" }));+ expect(state.archive).toHaveBeenCalledWith("n1");+ expect(nav.push).toHaveBeenCalledWith("/acme/issues/issue-b");+ expect(useInboxSelectionStore.getState().leftRowKeyByWorkspace["ws-1"]).toBe("issue-a");+ });++ it("says when the open row comes back once another window snoozed it, rather than that it was archived", async () => {+ const open = item({ id: "n1", issue_id: "issue-a", title: "Open one" });+ const other = item({ id: "n2", issue_id: "issue-b", title: "Other one", created_at: "2026-11-09T08:00:00Z" });+ const { client } = renderSection([open, other], "issue-a");+ const until = new Date(Date.now() + 26 * 60 * 60 * 1000).toISOString();+ act(() => {+ client.setQueryData(snoozedInboxOptions("ws-1").queryKey, [+ { issue_id: "issue-a", item_id: "n1", snoozed_until: until, snoozed_at: new Date().toISOString(), updates: 0 },+ ]);+ client.setQueryData(["inbox", "ws-1", "list"], [other]);+ });++ const row = screen.getByRole("link", { name: /^Open one/ });+ await waitFor(() => expect(row).toHaveTextContent(/Back .* · Leaves the Inbox when you move on/));+ expect(row).toHaveAttribute("aria-current", "page");+ expect(row).not.toHaveTextContent("Archived");+ });+it("caps the list at the chosen number of rows, with the rest behind Show more", () => {useSidebarTreeStore.setState({ inboxSettings: { ...DEFAULT_SIDEBAR_INBOX_SETTINGS, limit: 5 } });renderSection(@@ -492,6 +537,44 @@ describe("InboxSection", () => {expect(state.archiveAll).toHaveBeenCalledTimes(1);});+ it("opens the next row a bulk archive leaves when it takes the open one", async () => {+ const { nav } = renderSection(+ [+ item({ id: "n1", issue_id: "issue-a", title: "Open one", read: true }),+ item({ id: "n2", issue_id: "issue-b", title: "Read one", read: true, created_at: "2026-11-09T08:00:00Z" }),+ item({ id: "n3", issue_id: "issue-c", title: "Unread one", created_at: "2026-11-08T08:00:00Z" }),+ ],+ "issue-a",+ );+ fireEvent.click(screen.getByRole("button", { name: "Inbox actions" }));+ fireEvent.click(within(await screen.findByRole("menu")).getByRole("menuitem", { name: "Archive all read" }));+ expect(state.archiveAllRead).toHaveBeenCalledTimes(1);+ expect(nav.push).toHaveBeenCalledWith("/acme/issues/issue-c");+ });++ it("keeps the issue open with nothing lit once a bulk archive takes every row", async () => {+ const { nav } = renderSection([item({ id: "n1", issue_id: "issue-a", title: "Open one" })], "issue-a");+ fireEvent.click(screen.getByRole("button", { name: "Inbox actions" }));+ fireEvent.click(within(await screen.findByRole("menu")).getByRole("menuitem", { name: "Archive all" }));+ expect(state.archiveAll).toHaveBeenCalledTimes(1);+ expect(nav.push).not.toHaveBeenCalled();+ expect(useInboxSelectionStore.getState().leftRowKeyByWorkspace["ws-1"]).toBe("issue-a");+ });++ it("keeps a bulk archive that spares the open row from moving it", async () => {+ const { nav } = renderSection(+ [+ item({ id: "n1", issue_id: "issue-a", title: "Open one" }),+ item({ id: "n2", issue_id: "issue-b", title: "Read one", read: true, created_at: "2026-11-09T08:00:00Z" }),+ ],+ "issue-a",+ );+ fireEvent.click(screen.getByRole("button", { name: "Inbox actions" }));+ fireEvent.click(within(await screen.findByRole("menu")).getByRole("menuitem", { name: "Archive all read" }));+ expect(nav.push).not.toHaveBeenCalled();+ expect(useInboxSelectionStore.getState().leftRowKeyByWorkspace["ws-1"]).toBeUndefined();+ });+it("says a row is back from a snooze, with what arrived meanwhile, until it is read", () => {const snooze = { snoozed_until: "2026-11-12T09:00:00Z", snoozed_at: "2026-11-10T09:00:00Z" };const items = [diff --git a/packages/views/layout/panels/inbox-section.tsx b/packages/views/layout/panels/inbox-section.tsxindex 2bb34858fb..b5d69477b8 100644--- a/packages/views/layout/panels/inbox-section.tsx+++ b/packages/views/layout/panels/inbox-section.tsx@@ -24,7 +24,6 @@ import {useArchiveAllInbox,useArchiveAllReadInbox,useArchiveCompletedInbox,- useArchiveInbox,useMarkAllInboxRead,useMarkInboxRead,} from "@multica/core/inbox/mutations";@@ -34,6 +33,7 @@ import { useIssueStatuses } from "@multica/core/issue-statuses/hooks";import { issueDetailOptions } from "@multica/core/issues/queries";import { useSidebarTreeStore } from "@multica/core/issues/stores/sidebar-tree-store";import { useInboxSelectionStore } from "@multica/core/inbox/selection-store";+import { inboxRowKey, nextInboxRow } from "@multica/core/inbox/open-row";import { useWorkspacePaths } from "@multica/core/paths";import type { InboxItem } from "@multica/core/types";import { useActorName } from "@multica/core/workspace/hooks";@@ -53,6 +53,12 @@ import { useBuiltinViewNavigation } from "../../issue-views/builtin-views";import { useFilteredInboxRows } from "../../inbox/components/use-filtered-inbox-rows";import { useTimeAgo } from "../../inbox/components/inbox-list-item";import { useInboxUnsubscribable, useUnsubscribeArchive } from "../../inbox/components/use-unsubscribe-archive";+import {+ useArchiveInboxBatchWithUndo,+ useArchiveInboxWithUndo,+ useLeaveInboxRow,+} from "../../inbox/components/use-leave-inbox-row";+import { useKeptInboxRowText } from "../../inbox/components/inbox-kept-actions";import { StatusIcon } from "../../issues/components";import { useStatusLabel } from "../../issues/utils/status-label";import {@@ -91,7 +97,8 @@ export const INBOX_LIST = "inbox";/*** The Inbox section's rows: one per issue, newest first, read and unread* alike, under the Inbox filters. A row leaves only when archived, by hand or- * by its issue reaching Done. Lifted out of the section so the panel knows+ * by its issue reaching Done; the open one stays in place until the user+ * moves on (`keepOpenInboxRow`). Lifted out of the section so the panel knows* which issues it shows. `openKey`: see `useFilteredInboxRows`.*/export function useInboxSectionRows(wsId: string | undefined, openKey: string | null) {@@ -108,11 +115,6 @@ export function useInboxSectionRows(wsId: string | undefined, openKey: string |const open = openKey ? rows.findIndex((item) => (item.issue_id ?? item.id) === openKey) : -1;return open >= limit ? [...rows.slice(0, limit - 1), rows[open]!] : rows.slice(0, limit);}, [expanded, rows, limit, openKey]);- // A collapsed section shows no rows, so it lights none.- const shownIssueIds = useMemo(- () => new Set(collapsed ? [] : displayed.flatMap((item) => (item.issue_id ? [item.issue_id] : []))),- [collapsed, displayed],- );return {list,@@ -120,7 +122,8 @@ export function useInboxSectionRows(wsId: string | undefined, openKey: string |displayed,expanded,limit,- shownIssueIds,+ /** A collapsed section shows no rows, so it lights none. */+ collapsed,setExpanded: (next: boolean) => setExpandedWsId(next ? (wsId ?? null) : null),};}@@ -147,16 +150,24 @@ export function InboxSection({const showCount = useSidebarTreeStore((s) => s.inboxSettings.showCount);const compact = useSidebarTreeStore((s) => s.inboxSettings.compact);const unread = useInboxUnreadCount(wsId);- const archive = useArchiveInbox();+ const archive = useArchiveInboxWithUndo();+ const leave = useLeaveInboxRow();const unsubscribable = useInboxUnsubscribable(wsId);const unsubscribeArchive = useUnsubscribeArchive();const { snooze } = useInboxSnooze();const { searchParams } = useNavigation();const isCompact = useIsCompact();const { list, rows: all, displayed, expanded, limit, setExpanded } = rows;+ const keptText = useKeptInboxRowText(wsId);const clearFilters = useInboxFilterStore((state) => state.clearFilters);// The notification the Inbox page has open, keyed as it groups rows.const openKey = pathname === p.inbox() ? searchParams.get("issue") : null;+ // The open notification, wherever it is open; acting on its row moves on.+ const openRowKey = activeIssueId ?? openKey;+ const leaveIfOpen = (item: InboxItem) => {+ const key = inboxRowKey(item);+ if (key === openRowKey) leave(key, nextInboxRow(all, key));+ };// What arrived on each issue while it was snoozed, for the rows back from one.const updatesWhileSnoozed = useMemo(() => {const counts = new Map<string, number>();@@ -189,7 +200,12 @@ export function InboxSection({}}/><InboxSectionSettings className={SECTION_SETTINGS_REVEAL_CLASS} />- <InboxSectionActions wsId={wsId} className={SECTION_SETTINGS_REVEAL_CLASS} />+ <InboxSectionActions+ wsId={wsId}+ rows={all}+ openRowKey={openRowKey}+ className={SECTION_SETTINGS_REVEAL_CLASS}+ /></div>}>@@ -205,14 +221,25 @@ export function InboxSection({(!!openKey && (item.issue_id ?? item.id) === openKey)}compact={compact}+ kept={list.kept?.item.id === item.id ? keptText.line(list.kept) : null}+ settled={list.kept?.item.id === item.id && list.kept.reason !== "filtered"}updatesWhileSnoozed={item.issue_id ? (updatesWhileSnoozed.get(item.issue_id) ?? 0) : 0}- onArchive={() => archive.mutate(item.id)}+ onArchive={() => {+ archive(item.id, inboxRowKey(item));+ leaveIfOpen(item);+ }}onUnsubscribe={item.issue_id && unsubscribable(item)- ? () => unsubscribeArchive({ id: item.id, issueId: item.issue_id! })+ ? () => {+ unsubscribeArchive({ id: item.id, issueId: item.issue_id! });+ leaveIfOpen(item);+ }: undefined}- onSnooze={(until) => snooze(item, until)}+ onSnooze={(until) => {+ snooze(item, until);+ leaveIfOpen(item);+ }}/>))}</PanelList>@@ -262,9 +289,39 @@ export function InboxSection({);}-function InboxSectionActions({ wsId, className }: { wsId: string; className?: string }) {+function InboxSectionActions({+ wsId,+ rows,+ openRowKey,+ className,+}: {+ wsId: string;+ rows: readonly InboxItem[];+ openRowKey: string | null;+ className?: string;+}) {const { t } = useT("layout");const { t: tInbox } = useT("inbox");+ const leave = useLeaveInboxRow();+ const archiveWithUndo = useArchiveInboxBatchWithUndo();+ const { categoryOf } = useIssueStatuses(wsId);+ // A batch archive is the user's own Inbox action: when it takes the open+ // notification, that one moves on to the next row the batch leaves.+ const archiveBatch = (+ archive: () => Promise<{ count: number }>,+ archives: (item: InboxItem) => boolean,+ failed: string,+ ) => {+ const open = openRowKey ? rows.find((item) => inboxRowKey(item) === openRowKey) : undefined;+ const takesOpen = !!open && archives(open);+ void archiveWithUndo(archive, archives, failed, takesOpen ? openRowKey : null);+ if (takesOpen) leave(openRowKey!, nextInboxRow(rows, openRowKey!, archives));+ };+ const isRead = (item: InboxItem) => item.read === true;+ const isFinished = (item: InboxItem) => {+ const category = item.issue_status ? categoryOf(item.issue_status) : null;+ return category === "done" || category === "closed";+ };const markAllRead = useMarkAllInboxRead();const archiveAll = useArchiveAllInbox();const archiveAllRead = useArchiveAllReadInbox();@@ -325,7 +382,11 @@ function InboxSectionActions({ wsId, className }: { wsId: string; className?: st<DropdownMenuSeparator /><DropdownMenuItemonClick={() =>- archiveAllRead.mutate(undefined, { onError: onError(tInbox(($) => $.errors.archive_all_read_failed)) })+ archiveBatch(+ () => archiveAllRead.mutateAsync(),+ isRead,+ tInbox(($) => $.errors.archive_all_read_failed),+ )}><BookCheck className="size-4" />@@ -333,7 +394,11 @@ function InboxSectionActions({ wsId, className }: { wsId: string; className?: st</DropdownMenuItem><DropdownMenuItemonClick={() =>- archiveCompleted.mutate(undefined, { onError: onError(tInbox(($) => $.errors.archive_completed_failed)) })+ archiveBatch(+ () => archiveCompleted.mutateAsync(),+ isFinished,+ tInbox(($) => $.errors.archive_completed_failed),+ )}><ListChecks className="size-4" />@@ -341,7 +406,11 @@ function InboxSectionActions({ wsId, className }: { wsId: string; className?: st</DropdownMenuItem><DropdownMenuItemonClick={() =>- archiveAll.mutate(undefined, { onError: onError(tInbox(($) => $.errors.archive_all_failed)) })+ archiveBatch(+ () => archiveAll.mutateAsync(),+ () => true,+ tInbox(($) => $.errors.archive_all_failed),+ )}><Archive className="size-4" />@@ -357,6 +426,8 @@ function InboxRow({href,active,compact,+ kept,+ settled,updatesWhileSnoozed,onArchive,onUnsubscribe,@@ -367,6 +438,10 @@ function InboxRow({active: boolean;/** One line (status, title, agents, dot or time) instead of the actor line under the title. */compact: boolean;+ /** Why the open row is kept in place (`keepOpenInboxRow`), in place of its actor line. */+ kept: string | null;+ /** Kept after it left the Inbox, so there is nothing left to archive or snooze. */+ settled: boolean;/** Notifications that arrived while the issue was snoozed. */updatesWhileSnoozed: number;onArchive: () => void;@@ -403,7 +478,7 @@ function InboxRow({};const agents = useIssueAgentState(item.workspace_id, item.issue_id ?? "");const running = !!agents?.running;- const unread = item.read !== true;+ const unread = item.read !== true && !kept;const archiveLabel = t(($) => $.list.archive_tooltip);const snoozeLabel = t(($) => $.snooze.action);const [snoozeOpen, setSnoozeOpen] = useState(false);@@ -412,7 +487,7 @@ function InboxRow({const at = new Date(inboxRowTime(item)).toISOString();// Hidden while the row's buttons stand in its place.const yields = cn(- "group-hover/inbox:invisible group-focus-within/inbox:invisible",+ !settled && "group-hover/inbox:invisible group-focus-within/inbox:invisible",snoozeOpen && "invisible",);const timeClass = "shrink-0 text-caption tabular-nums text-faint-foreground";@@ -446,6 +521,7 @@ function InboxRow({SIDEBAR_SHIMMER_CLASS,unread && "font-medium",unread && !running && "text-foreground",+ kept && !running && "text-muted-foreground",)}>{title}@@ -495,7 +571,7 @@ function InboxRow({ISSUE_ROW_LINK_CLASS,compact ? "gap-2.5" : "flex-col items-stretch gap-0",// Room for the snooze button beside the archive one.- item.issue_id && "group-focus-within/inbox:pr-5 group-hover/inbox:pr-5",+ item.issue_id && !settled && "group-focus-within/inbox:pr-5 group-hover/inbox:pr-5",snoozeOpen && "pr-5",)}>@@ -504,7 +580,20 @@ function InboxRow({{titleText}{statusText}{agentBadge}- {unread ? <span className={cn("flex shrink-0 items-center", yields)}>{dot}</span> : !agents && time}+ {kept ? (+ <>+ <span className="sr-only">, {kept}</span>+ {settled && !agents && (+ <span title={kept} className={cn("flex shrink-0 items-center text-faint-foreground", yields)}>+ <Archive aria-hidden className="size-3" />+ </span>+ )}+ </>+ ) : unread ? (+ <span className={cn("flex shrink-0 items-center", yields)}>{dot}</span>+ ) : (+ !agents && time+ )}</>) : (<>@@ -518,7 +607,9 @@ function InboxRow({{/* The status took the avatar's column; it stays with the name. */}{statusIcon && <InboxActorAvatar item={item} size="xs" />}<span className="min-w-0 flex-1 truncate">- {returned ? (+ {kept ? (+ kept+ ) : returned ? (<InboxReturnedLine updates={updatesWhileSnoozed} />) : (<InboxActorLine item={item} />@@ -548,10 +639,10 @@ function InboxRow({dismissCard();land();}}- onArchive={onArchive}- onUnsubscribe={onUnsubscribe}+ onArchive={settled ? undefined : onArchive}+ onUnsubscribe={settled ? undefined : onUnsubscribe}onSnooze={- item.issue_id+ item.issue_id && !settled? () => {setCardOpen(false);setSnoozeOpen(true);@@ -561,7 +652,7 @@ function InboxRow({/></HoverCardContent></HoverCard>- {item.issue_id && (+ {item.issue_id && !settled && (<InboxSnoozeMenuopen={snoozeOpen}onOpenChange={setSnoozeOpen}@@ -585,20 +676,22 @@ function InboxRow({}/>)}- <TooltipHint label={archiveLabel}>- <button- type="button"- aria-label={archiveLabel}- className={cn(rowButtonClass(compact), "right-1.5", snoozeOpen && "flex")}- onClick={(event) => {- event.preventDefault();- event.stopPropagation();- onArchive();- }}- >- <Archive className="size-3" />- </button>- </TooltipHint>+ {!settled && (+ <TooltipHint label={archiveLabel}>+ <button+ type="button"+ aria-label={archiveLabel}+ className={cn(rowButtonClass(compact), "right-1.5", snoozeOpen && "flex")}+ onClick={(event) => {+ event.preventDefault();+ event.stopPropagation();+ onArchive();+ }}+ >+ <Archive className="size-3" />+ </button>+ </TooltipHint>+ )}</li>);}@@ -669,7 +762,8 @@ function InboxRowCard({href: string;title: string;onOpen: () => void;- onArchive: () => void;+ /** Left out for a row kept after it left the Inbox. */+ onArchive?: () => void;onUnsubscribe?: () => void;/** Opens the row's snooze menu; issue rows only. */onSnooze?: () => void;@@ -731,9 +825,11 @@ function InboxRowCard({{tInbox(($) => $.snooze.action)}</Button>)}- <Button size="sm" variant="ghost" className="text-muted-foreground" onClick={onArchive}>- {tInbox(($) => $.context_menu.archive)}- </Button>+ {onArchive && (+ <Button size="sm" variant="ghost" className="text-muted-foreground" onClick={onArchive}>+ {tInbox(($) => $.context_menu.archive)}+ </Button>+ )}{onUnsubscribe && (<IconButtonlabel={tInbox(($) => $.context_menu.unsubscribe_archive)}diff --git a/packages/views/layout/panels/work-panel.test.tsx b/packages/views/layout/panels/work-panel.test.tsxindex fd94ae66c1..36d821bb38 100644--- a/packages/views/layout/panels/work-panel.test.tsx+++ b/packages/views/layout/panels/work-panel.test.tsx@@ -262,7 +262,12 @@ beforeEach(() => {});useActiveIssueViewStore.setState({ active: {} });useSidebarKeptStore.setState({ held: {} });- useInboxSelectionStore.setState({ sidebarIssueByWorkspace: {}, sidebarTabIssuesByWorkspace: {} });+ useInboxSelectionStore.setState({+ sidebarIssueByWorkspace: {},+ sidebarTabIssuesByWorkspace: {},+ heldRows: {},+ leftRowKeyByWorkspace: {},+ });apiMock.listIssueTableRows.mockResolvedValue({rows: [ISSUE, OTHER].map((issue) => ({ issue })),total: 2,@@ -336,18 +341,32 @@ describe("WorkPanel Inbox highlight", () => {expect(allIssues()).not.toHaveAttribute("aria-current");});- it("falls back to the other lists once the notification is archived", async () => {+ it("keeps the open row lit in place once its notification is archived some other way", async () => {const qc = renderPanel("/acme/my-issues", [], [], [], [inboxItem(ISSUE)]);await within(await waitFor(inMyIssues)).findByRole("link", { name: ISSUE.title });fireEvent.click(within(inInbox()).getByRole("link", { name: INBOX_ROW_NAME }));act(() => {- qc.setQueryData(inboxListOptions("ws-1").queryKey, [{ ...inboxItem(ISSUE), archived: true }]);+ qc.setQueryData(inboxListOptions("ws-1").queryKey, []);});- await waitFor(() =>- expect(within(inMyIssues()).getByRole("link", { name: ISSUE.title })).toHaveAttribute("aria-current", "page"),- );- expect(inInbox()).toBeNull();+ const row = await within(inInbox()).findByRole("link", { name: /Leaves the Inbox when you move on/ });+ expect(row).toHaveAttribute("aria-current", "page");+ expect(within(inMyIssues()).getByRole("link", { name: ISSUE.title })).not.toHaveAttribute("aria-current");+ expect(allIssues()).not.toHaveAttribute("aria-current");+ });++ it("lights nothing else once an Inbox action took the open row with nothing left to open", async () => {+ const qc = renderPanel("/acme/my-issues", [], [], [], [inboxItem(ISSUE)]);+ await within(await waitFor(inMyIssues)).findByRole("link", { name: ISSUE.title });+ fireEvent.click(within(inInbox()).getByRole("link", { name: INBOX_ROW_NAME }));+ act(() => {+ useInboxSelectionStore.getState().leaveRow("ws-1", ISSUE.id);+ qc.setQueryData(inboxListOptions("ws-1").queryKey, []);+ });++ await waitFor(() => expect(inInbox()).toBeNull());+ expect(within(inMyIssues()).getByRole("link", { name: ISSUE.title })).not.toHaveAttribute("aria-current");+ expect(allIssues()).not.toHaveAttribute("aria-current");});it("lights an issue opened from a row's hover card in the Inbox", async () => {@@ -451,6 +470,7 @@ describe("WorkPanel Inbox highlight while the next page loads", () => {const qc = await openFromInbox([]);act(() => {qc.setQueryData(inboxListOptions("ws-1").queryKey, [{ ...inboxItem(ISSUE), archived: true }, inboxItem(OTHER)]);+ useInboxSelectionStore.getState().leaveRow("ws-1", ISSUE.id);useInboxSelectionStore.getState().rememberSidebarIssue("ws-1", OTHER.id);});diff --git a/packages/views/layout/panels/work-panel.tsx b/packages/views/layout/panels/work-panel.tsxindex 39e610cb1b..931ff4c88e 100644--- a/packages/views/layout/panels/work-panel.tsx+++ b/packages/views/layout/panels/work-panel.tsx@@ -47,14 +47,15 @@ function routeSegment(pathname: string, base: string): string | null {}/**- * Ends the rows the sidebar lists keep (`useKeptActiveItem`) once their issue- * or project is no longer the page. Mounted with the shell rather than the+ * Ends the rows the sidebar lists keep (`useKeptActiveItem`), and the Inbox+ * rows kept in place (`keepOpenInboxRow`), once their issue, project or+ * notification is no longer the page. Mounted with the shell rather than the* Work panel, which unmounts on leaving Work and with every compact sheet* close.*/export function KeptRowsRelease() {const p = useWorkspacePaths();- const { pathname } = useNavigation();+ const { pathname, searchParams } = useNavigation();const wsId = useCurrentWorkspace()?.id ?? "";const issueSegment = routeSegment(pathname, p.issues());const { data: issue } = useQuery({@@ -64,10 +65,13 @@ export function KeptRowsRelease() {// `undefined` while an identifier route waits for the page to load its issue.const issueId = issueSegment ? (issue?.id ?? (isIssueUuid(issueSegment) ? issueSegment : undefined)) : null;const projectId = routeSegment(pathname, p.projects());+ // The notification the Inbox page has open, as its rows are keyed.+ const inboxKey = pathname === p.inbox() ? searchParams.get("issue") : null;useLayoutEffect(() => {if (issueId === undefined) return;useSidebarKeptStore.getState().release([issueId, projectId].filter((id) => id !== null));- }, [issueId, projectId]);+ if (wsId) useInboxSelectionStore.getState().releaseRows(wsId, [issueId, inboxKey].filter((id) => id !== null));+ }, [wsId, issueId, projectId, inboxKey]);return null;}@@ -110,10 +114,11 @@ export function WorkPanel() {!!liveClickedIssue && !isOpenIssue(liveClickedIssue.segment),);// An issue opened from the Inbox, by a row or by the issue header moving on- // to the next notification, lights there while the section still shows it;- // once archived, it falls back to the other lists.+ // to the next notification, belongs to the Inbox until another list is+ // clicked. Its row stays in place while it is open (`keepOpenInboxRow`),+ // and when an Inbox action took it with nothing left to open it lights+ // nowhere: never in another list the user did not open it from.const inbox = useSidebarInboxIssue(wsId, currentIssueId, clicked.movingOn);- const movingOn = clicked.movingOn || inbox.movingOn;const clickedIssue = clicked.value;const clickedList = clickedIssue && isOpenIssue(clickedIssue.segment) ? clickedIssue.list : undefined;// The notification open beside the section: an issue opened from it, or an@@ -128,9 +133,7 @@ export function WorkPanel() {const rememberSidebarIssue = useInboxSelectionStore((s) => s.rememberSidebarIssue);const rememberSidebarTabIssue = useInboxSelectionStore((s) => s.rememberSidebarTabIssue);const forgetSidebarTabIssue = useInboxSelectionStore((s) => s.forgetSidebarTabIssue);- // Moving on from an archived row keeps the issue lit nowhere rather than elsewhere.- const inboxClaimsIssue =- !!currentIssueId && inbox.fromInbox && (movingOn || inboxRows.shownIssueIds.has(currentIssueId));+ const inboxClaimsIssue = !!currentIssueId && inbox.fromInbox && !inboxRows.collapsed;const treeClaimsIssue = inboxClaimsIssue || (clickedList !== undefined && clickedList !== PINS_LIST);const pins = usePanelPins(wsId, userId, pathname, treeClaimsIssue ? null : currentIssueId);const requestLocate = useSidebarTreeStore((s) => s.requestLocate);diff --git a/packages/views/locales/en/inbox.json b/packages/views/locales/en/inbox.jsonindex 8b9c252412..bd894d93a4 100644--- a/packages/views/locales/en/inbox.json+++ b/packages/views/locales/en/inbox.json@@ -125,6 +125,8 @@"toasts": {"source_context_retry_started": "Retry started with the original context","archived": "Notification archived",+ "archived_many_one": "{{count}} notification archived",+ "archived_many_other": "{{count}} notifications archived","unarchived": "Notification restored","deleted": "Notification deleted","unsubscribed_archived": "Unsubscribed and archived",@@ -132,6 +134,14 @@"unsubscribed_hint": "Its updates won't reach your inbox. @mentions still will.","undo": "Undo"},+ "kept": {+ "archived": "Archived",+ "leaves": "Leaves the Inbox when you move on",+ "filtered": "No longer matches your filters",+ "notification_archived": "Notification archived",+ "next": "Next",+ "next_tooltip": "Open next: {{title}}"+ },"errors": {"archived_lookup_failed": "Failed to load the linked notification","source_context_retry_failed": "Could not retry with the original context",diff --git a/packages/views/locales/es/inbox.json b/packages/views/locales/es/inbox.jsonindex dfe7bbf985..7fadfd34dd 100644--- a/packages/views/locales/es/inbox.json+++ b/packages/views/locales/es/inbox.json@@ -125,6 +125,8 @@"toasts": {"source_context_retry_started": "Reintento iniciado con el contexto original","archived": "Notificación archivada",+ "archived_many_one": "{{count}} notificación archivada",+ "archived_many_other": "{{count}} notificaciones archivadas","unarchived": "Notificación restaurada","deleted": "Notificación eliminada","unsubscribed_archived": "Baja y archivo hechos",@@ -132,6 +134,14 @@"unsubscribed_hint": "Sus actualizaciones no llegarán a tu bandeja. Las @menciones sí.","undo": "Deshacer"},+ "kept": {+ "archived": "Archivado",+ "leaves": "Sale de la bandeja al continuar",+ "filtered": "Ya no coincide con tus filtros",+ "notification_archived": "Notificación archivada",+ "next": "Siguiente",+ "next_tooltip": "Abrir la siguiente: {{title}}"+ },"errors": {"archived_lookup_failed": "No se ha podido cargar la notificación enlazada","source_context_retry_failed": "No se ha podido reintentar con el contexto original",diff --git a/packages/views/locales/fr/inbox.json b/packages/views/locales/fr/inbox.jsonindex 30f28648e9..302dcd831a 100644--- a/packages/views/locales/fr/inbox.json+++ b/packages/views/locales/fr/inbox.json@@ -125,6 +125,8 @@"toasts": {"source_context_retry_started": "Nouvelle tentative démarrée avec le contexte d'origine","archived": "Notification archivée",+ "archived_many_one": "{{count}} notification archivée",+ "archived_many_other": "{{count}} notifications archivées","unarchived": "Notification restaurée","deleted": "Notification supprimée","unsubscribed_archived": "Désabonné et archivé",@@ -132,6 +134,14 @@"unsubscribed_hint": "Ses mises à jour n'arriveront plus dans votre boîte de réception. Les @mentions, si.","undo": "Annuler"},+ "kept": {+ "archived": "Archivée",+ "leaves": "Quitte la boîte de réception quand vous passez à la suite",+ "filtered": "Ne correspond plus à vos filtres",+ "notification_archived": "Notification archivée",+ "next": "Suivante",+ "next_tooltip": "Ouvrir la suivante : {{title}}"+ },"errors": {"archived_lookup_failed": "Échec du chargement de la notification liée","source_context_retry_failed": "Impossible de réessayer avec le contexte d'origine",diff --git a/packages/views/locales/ja/inbox.json b/packages/views/locales/ja/inbox.jsonindex 5b61239e73..6ab39b8de1 100644--- a/packages/views/locales/ja/inbox.json+++ b/packages/views/locales/ja/inbox.json@@ -123,6 +123,7 @@"toasts": {"source_context_retry_started": "元のコンテキストで再試行を開始しました","archived": "通知をアーカイブしました",+ "archived_many_other": "{{count}} 件の通知をアーカイブしました","unarchived": "通知を元に戻しました","deleted": "通知を削除しました","unsubscribed_archived": "購読を解除してアーカイブしました",@@ -130,6 +131,14 @@"unsubscribed_hint": "今後の更新はインボックスに届きません。@メンションは引き続き通知されます。","undo": "元に戻す"},+ "kept": {+ "archived": "アーカイブ済み",+ "leaves": "移動するとインボックスから外れます",+ "filtered": "フィルターに一致しなくなりました",+ "notification_archived": "通知をアーカイブしました",+ "next": "次へ",+ "next_tooltip": "次を開く:{{title}}"+ },"errors": {"archived_lookup_failed": "リンク先の通知を読み込めませんでした","source_context_retry_failed": "元のコンテキストで再試行できませんでした",diff --git a/packages/views/locales/ko/inbox.json b/packages/views/locales/ko/inbox.jsonindex 54ee126c4a..bb88537967 100644--- a/packages/views/locales/ko/inbox.json+++ b/packages/views/locales/ko/inbox.json@@ -123,6 +123,7 @@"toasts": {"source_context_retry_started": "원본 컨텍스트로 재시도를 시작했습니다","archived": "알림을 보관했습니다",+ "archived_many_other": "알림 {{count}}개를 보관했습니다","unarchived": "알림을 복원했습니다","deleted": "알림이 삭제되었습니다","unsubscribed_archived": "구독을 해제하고 보관했습니다",@@ -130,6 +131,14 @@"unsubscribed_hint": "이후 업데이트는 인박스에 오지 않습니다. @멘션은 계속 알림을 받습니다.","undo": "실행 취소"},+ "kept": {+ "archived": "보관됨",+ "leaves": "다른 곳으로 이동하면 인박스에서 빠집니다",+ "filtered": "더 이상 필터와 일치하지 않음",+ "notification_archived": "알림이 보관됨",+ "next": "다음",+ "next_tooltip": "다음 열기: {{title}}"+ },"errors": {"archived_lookup_failed": "링크된 알림을 불러오지 못했습니다","source_context_retry_failed": "원본 컨텍스트로 재시도하지 못했습니다",diff --git a/packages/views/locales/ru/inbox.json b/packages/views/locales/ru/inbox.jsonindex f74bec545d..97ce08ac1c 100644--- a/packages/views/locales/ru/inbox.json+++ b/packages/views/locales/ru/inbox.json@@ -129,6 +129,10 @@"toasts": {"source_context_retry_started": "Повтор запущен с исходным контекстом","archived": "Уведомление архивировано",+ "archived_many_one": "{{count}} уведомление архивировано",+ "archived_many_few": "{{count}} уведомления архивированы",+ "archived_many_many": "{{count}} уведомлений архивировано",+ "archived_many_other": "{{count}} уведомления архивированы","unarchived": "Уведомление восстановлено","deleted": "Уведомление удалено","unsubscribed_archived": "Вы отписались, уведомление в архиве",@@ -136,6 +140,14 @@"unsubscribed_hint": "Обновления не попадут во входящие. @упоминания по-прежнему придут.","undo": "Отменить"},+ "kept": {+ "archived": "В архиве",+ "leaves": "Уйдёт из входящих, когда вы перейдёте дальше",+ "filtered": "Больше не подходит под фильтры",+ "notification_archived": "Уведомление в архиве",+ "next": "Следующее",+ "next_tooltip": "Открыть следующее: {{title}}"+ },"errors": {"archived_lookup_failed": "Не удалось загрузить связанное уведомление","source_context_retry_failed": "Не удалось повторить с исходным контекстом",diff --git a/packages/views/locales/zh-Hans/inbox.json b/packages/views/locales/zh-Hans/inbox.jsonindex 1261b33069..b40f3f74de 100644--- a/packages/views/locales/zh-Hans/inbox.json+++ b/packages/views/locales/zh-Hans/inbox.json@@ -123,6 +123,7 @@"toasts": {"source_context_retry_started": "已使用原始上下文开始重试","archived": "已归档通知",+ "archived_many_other": "已归档 {{count}} 条通知","unarchived": "已恢复通知","deleted": "通知已删除","unsubscribed_archived": "已取消订阅并归档",@@ -130,6 +131,14 @@"unsubscribed_hint": "之后的普通动态不会再进收件箱,@你时仍会通知","undo": "撤销"},+ "kept": {+ "archived": "已归档",+ "leaves": "离开后移出收件箱",+ "filtered": "不再符合筛选",+ "notification_archived": "通知已归档",+ "next": "下一条",+ "next_tooltip": "打开下一条:{{title}}"+ },"errors": {"archived_lookup_failed": "无法加载链接指向的通知","source_context_retry_failed": "无法使用原始上下文重试",diff --git a/packages/views/locales/zh-Hant/inbox.json b/packages/views/locales/zh-Hant/inbox.jsonindex 70ea6d3ff0..35ba82f801 100644--- a/packages/views/locales/zh-Hant/inbox.json+++ b/packages/views/locales/zh-Hant/inbox.json@@ -123,6 +123,7 @@"toasts": {"source_context_retry_started": "已使用原始上下文開始重試","archived": "已歸檔通知",+ "archived_many_other": "已歸檔 {{count}} 條通知","unarchived": "已恢復通知","deleted": "通知已刪除","unsubscribed_archived": "已取消訂閱並歸檔",@@ -130,6 +131,14 @@"unsubscribed_hint": "之後的一般動態不會再進收件匣,@你時仍會通知","undo": "復原"},+ "kept": {+ "archived": "已歸檔",+ "leaves": "離開後移出收件箱",+ "filtered": "不再符合篩選",+ "notification_archived": "通知已歸檔",+ "next": "下一條",+ "next_tooltip": "開啟下一條:{{title}}"+ },"errors": {"archived_lookup_failed": "無法載入連結指向的通知","source_context_retry_failed": "無法使用原始上下文重試",