Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(inbox): show calm Inbox Zero screen after clearing the last notification (MUL-9811) (#11157)
Jiayuan Zhang7720f0d597a2
diff --git a/apps/docs/content/docs/inbox.fr.mdx b/apps/docs/content/docs/inbox.fr.mdxindex 1733b0fe3e..01c559bd82 100644--- a/apps/docs/content/docs/inbox.fr.mdx+++ b/apps/docs/content/docs/inbox.fr.mdx@@ -137,9 +137,9 @@ Lire une notification ne la retire pas. Une ligne quitte la boîte de réception- 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.- quand votre boîte de réception dans l'espace de travail dépasse 2 000 notifications. Elle garde les 2 000 plus récentes et archive peu après les plus anciennes, lues ou non. Une notification revenue d'un report ou restaurée depuis l'archive compte à partir de son retour. Les notifications d'une tâche reportée ne comptent pas et restent en place.-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 la barre de la boîte de réception indique ce qui s'est passé. Quand un changement fait depuis la barre archive la notification, la barre le nomme, par exemple *Statut passé à En cours · Notification archivée*, et garde **Statut**, **Assigné à** et **Actions rapides** pour la suite. **Annuler** (ou `Z`) fait revenir la notification, et **Suivante** (ou `E`) ouvre la ligne suivante. La ligne disparaît dès que vous passez à autre chose. C'est le comportement de **Après l'archivage → Rester sur la tâche**, par défaut ; avec **Ouvrir la suivante**, un changement de votre part qui archive la notification ouverte ouvre aussitôt la ligne suivante, et la confirmation propose **Annuler**.+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 la barre de la boîte de réception indique ce qui s'est passé. Quand un changement fait depuis la barre archive la notification, la barre le nomme, par exemple *Statut passé à En cours · Notification archivée*, et garde **Statut**, **Assigné à** et **Actions rapides** pour la suite. **Annuler** (ou `Z`) fait revenir la notification, et **Suivante** (ou `E`) ouvre la ligne suivante. La ligne disparaît dès que vous passez à autre chose. Si c'était la dernière notification de votre boîte de réception, la barre affiche plutôt **Boîte de réception vide** avec le nombre de tâches reportées, et propose **Aller à Mon travail** à la place de **Suivante** ; `E` ouvre la boîte de réception vide. C'est le comportement de **Après l'archivage → Rester sur la tâche**, par défaut ; avec **Ouvrir la suivante**, un changement de votre part qui archive la notification ouverte ouvre aussitôt la ligne suivante, ou la boîte de réception vide, et la confirmation propose **Annuler**.-Quand vous retirez vous-même la ligne ouverte, depuis la barre de la boîte de réception, 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 et les actions groupées proposent **Annuler**, qui fait revenir les notifications sans changer le statut de la tâche. Les confirmations qui proposent **Annuler**, pour l'archivage, le report comme le désabonnement, restent 10 secondes ; tant que l'une d'elles est affichée, `Z` annule cette dernière action.+Quand vous retirez vous-même la ligne ouverte, depuis la barre de la boîte de réception, 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 page de la boîte de réception s'ouvre sur **Boîte de réception vide**. Elle rappelle ce que vous venez de faire, avec **Annuler** pour revenir en arrière, indique combien de tâches sont reportées et quand la prochaine revient, et renvoie vers **Mon travail**, les agents au travail et **Voir les archives**. Quand des filtres masquaient le reste de votre boîte de réception, elle indique plutôt combien de notifications restent et propose **Effacer les filtres et continuer**. Revenir en arrière ramène à la tâche. L'archivage et les actions groupées proposent **Annuler**, qui fait revenir les notifications sans changer le statut de la tâche. Les confirmations qui proposent **Annuler**, pour l'archivage, le report comme le désabonnement, restent 10 secondes ; tant que l'une d'elles est affichée, `Z` annule cette dernière action.Une notification ultérieure sur la tâche revient dans la boîte de réception.diff --git a/apps/docs/content/docs/inbox.ja.mdx b/apps/docs/content/docs/inbox.ja.mdxindex 7310a86d7d..7efe8e1076 100644--- a/apps/docs/content/docs/inbox.ja.mdx+++ b/apps/docs/content/docs/inbox.ja.mdx@@ -137,9 +137,9 @@ multica inbox snooze <id>... --until tomorrow # RFC 3339、30m、3h、1d、1w- 「実行失敗」の通知で、タスクが人に引き継がれるステータスになったとき。対象は `in_review`、`started` カテゴリのカスタムステータス、`done`・`closed` カテゴリのすべてのステータスです。誰がステータスを変えたかにかかわらず、そのタスクの全員分の「実行失敗」の通知がアーカイブされ、上の設定には左右されません。`blocked` は例外です。人に引き継がれはしますが作業は止まったままなので、それまでの失敗の記録はまだ確認する必要があります。- そのワークスペースのインボックスが 2,000 件を超えたとき。新しい 2,000 件を残し、それより古い通知は既読かどうかにかかわらず、少し後に自動でアーカイブされます。スヌーズから戻った通知やアーカイブから戻した通知は、戻った時点の新しさで数えます。スヌーズ中のタスクの通知は数えず、そのまま残ります。-アーカイブされた行は、開いているウィンドウからもすぐに消えます。ただし、いま開いている行は別です。その通知がほかの理由でインボックスから外れたとき(ステータスからタスクを `done` にした、別のウィンドウでアーカイブされた、編集でセクションのフィルターに合わなくなった)、行は元の位置でハイライトされたまま残り、インボックスバーに何が起きたかが表示されます。バーの **ステータス**、**担当者**、**クイックアクション** で変更して通知がアーカイブされたときは、「進行中 に変更 · 通知をアーカイブしました」のようにその操作が示され、これらの操作はバーに残るので続けて変更できます。**元に戻す**(または `Z`)で通知が戻り、**次へ**(または `E`)で次の行が開きます。行が消えるのは、ほかへ移ったときです。これは既定の **アーカイブ後 → このタスクに留まる** の動きです。**次の通知を開く** にすると、あなたの操作で開いている通知がアーカイブされたとき、すぐ次の行が開き、確認メッセージに **元に戻す** が出ます。+アーカイブされた行は、開いているウィンドウからもすぐに消えます。ただし、いま開いている行は別です。その通知がほかの理由でインボックスから外れたとき(ステータスからタスクを `done` にした、別のウィンドウでアーカイブされた、編集でセクションのフィルターに合わなくなった)、行は元の位置でハイライトされたまま残り、インボックスバーに何が起きたかが表示されます。バーの **ステータス**、**担当者**、**クイックアクション** で変更して通知がアーカイブされたときは、「進行中 に変更 · 通知をアーカイブしました」のようにその操作が示され、これらの操作はバーに残るので続けて変更できます。**元に戻す**(または `Z`)で通知が戻り、**次へ**(または `E`)で次の行が開きます。行が消えるのは、ほかへ移ったときです。それがインボックスの最後の通知だった場合、バーには代わりに **インボックスは空です** とスヌーズ中のタスク数が表示され、**次へ** の代わりに **自分の作業へ** が出ます。`E` で空になったインボックスが開きます。これは既定の **アーカイブ後 → このタスクに留まる** の動きです。**次の通知を開く** にすると、あなたの操作で開いている通知がアーカイブされたとき、すぐ次の行(なければ空になったインボックス)が開き、確認メッセージに **元に戻す** が出ます。-開いている行を自分で処理したとき(インボックスバー、その行、ホバーカード、その行を含む一括操作)は、代わりに次の行が開きます。残りがなければ、タスクは開いたままです。アーカイブと一括操作の確認には **元に戻す** があり、通知は戻りますが、タスクのステータスはそのままです。**元に戻す** のある確認メッセージ(アーカイブ、スヌーズ、購読解除のいずれも)は 10 秒間表示され、表示中に `Z` を押すとその操作を取り消せます。+開いている行を自分で処理したとき(インボックスバー、その行、ホバーカード、その行を含む一括操作)は、代わりに次の行が開きます。残りがなければ、インボックスのページが開き、**インボックスは空です** と表示されます。直前の操作が示されて **元に戻す** で取り戻せるほか、スヌーズ中のタスク数と次に戻る時刻、**自分の作業**、作業中のエージェント、**アーカイブを見る** へのリンクがあります。フィルターでほかの通知が隠れているだけのときは、残りの件数と **フィルターを解除して続ける** が代わりに表示されます。戻るとタスクに戻れます。アーカイブと一括操作の確認には **元に戻す** があり、通知は戻りますが、タスクのステータスはそのままです。**元に戻す** のある確認メッセージ(アーカイブ、スヌーズ、購読解除のいずれも)は 10 秒間表示され、表示中に `Z` を押すとその操作を取り消せます。その後に届いた通知は、再びインボックスに入ります。diff --git a/apps/docs/content/docs/inbox.ko.mdx b/apps/docs/content/docs/inbox.ko.mdxindex e61ddfb459..5312ea16cc 100644--- a/apps/docs/content/docs/inbox.ko.mdx+++ b/apps/docs/content/docs/inbox.ko.mdx@@ -137,9 +137,9 @@ multica inbox snooze <id>... --until tomorrow # RFC 3339, 30m, 3h, 1d, 1w; uns- "실행 실패함" 알림이고, 태스크가 사람에게 넘어가는 상태가 될 때. 해당 상태는 `in_review`, `started` 카테고리의 사용자 지정 상태, `done`·`closed` 카테고리의 모든 상태입니다. 누가 상태를 바꿨는지와 관계없이 그 태스크의 모든 사람의 "실행 실패함" 알림이 보관되며, 위 설정의 영향을 받지 않습니다. `blocked`는 예외입니다. 사람에게 넘어가기는 하지만 작업이 여전히 막혀 있으므로 지난 실패 기록을 계속 확인해야 합니다.- 그 워크스페이스의 인박스가 알림 2,000개를 넘을 때. 최신 2,000개를 남기고, 그보다 오래된 알림은 읽음 여부와 관계없이 잠시 후 자동으로 보관됩니다. 미루기에서 돌아온 알림과 보관함에서 복원한 알림은 돌아온 시점을 기준으로 셉니다. 미룬 태스크의 알림은 개수에 포함되지 않으며 그대로 남습니다.-보관된 행은 열려 있는 창에서도 바로 사라집니다. 단, 지금 열어 둔 행은 예외입니다. 그 알림이 다른 이유로 인박스에서 빠지면(상태에서 태스크를 `done`으로 바꿨거나, 다른 창에서 보관했거나, 편집으로 섹션 필터에 더 이상 맞지 않게 된 경우) 행은 제자리에서 강조된 채 남고, 인박스 바에 무슨 일이 있었는지 표시됩니다. 바의 **상태**, **담당자**, **퀵 액션**으로 바꿔서 알림이 보관되면 '상태 변경됨: 진행 중 · 알림이 보관됨'처럼 그 동작이 표시되고, 이 동작들은 바에 그대로 남아 이어서 바꿀 수 있습니다. **실행 취소**(또는 `Z`)로 알림을 되돌리고, **다음**(또는 `E`)으로 다음 행을 엽니다. 행은 다른 곳으로 이동할 때 사라집니다. 이는 기본값인 **보관한 뒤 → 이 태스크에 머무르기**의 동작입니다. **다음 알림 열기**를 고르면 내 동작으로 열어 둔 알림이 보관될 때 바로 다음 행이 열리고, 확인 알림에 **실행 취소**가 나옵니다.+보관된 행은 열려 있는 창에서도 바로 사라집니다. 단, 지금 열어 둔 행은 예외입니다. 그 알림이 다른 이유로 인박스에서 빠지면(상태에서 태스크를 `done`으로 바꿨거나, 다른 창에서 보관했거나, 편집으로 섹션 필터에 더 이상 맞지 않게 된 경우) 행은 제자리에서 강조된 채 남고, 인박스 바에 무슨 일이 있었는지 표시됩니다. 바의 **상태**, **담당자**, **퀵 액션**으로 바꿔서 알림이 보관되면 '상태 변경됨: 진행 중 · 알림이 보관됨'처럼 그 동작이 표시되고, 이 동작들은 바에 그대로 남아 이어서 바꿀 수 있습니다. **실행 취소**(또는 `Z`)로 알림을 되돌리고, **다음**(또는 `E`)으로 다음 행을 엽니다. 행은 다른 곳으로 이동할 때 사라집니다. 그것이 인박스의 마지막 알림이었다면 바에는 대신 **인박스가 비었습니다**와 미뤄 둔 태스크 수가 표시되고, **다음** 대신 **내 작업으로 이동**이 나옵니다. `E`를 누르면 비워진 인박스가 열립니다. 이는 기본값인 **보관한 뒤 → 이 태스크에 머무르기**의 동작입니다. **다음 알림 열기**를 고르면 내 동작으로 열어 둔 알림이 보관될 때 바로 다음 행(없으면 비워진 인박스)이 열리고, 확인 알림에 **실행 취소**가 나옵니다.-열어 둔 행을 직접 처리하면(인박스 바, 그 행, 호버 카드, 그 행을 포함한 일괄 작업) 대신 다음 행이 열립니다. 남은 행이 없으면 태스크는 열린 채로 있습니다. 보관과 일괄 작업의 확인에는 **실행 취소**가 있으며, 알림은 돌아오고 태스크 상태는 그대로 유지됩니다. **실행 취소**가 있는 확인 알림(보관, 미루기, 구독 해제 모두)은 10초 동안 표시되며, 표시되는 동안 `Z`를 누르면 그 동작을 취소합니다.+열어 둔 행을 직접 처리하면(인박스 바, 그 행, 호버 카드, 그 행을 포함한 일괄 작업) 대신 다음 행이 열립니다. 남은 행이 없으면 인박스 페이지가 열리고 **인박스가 비었습니다**가 표시됩니다. 방금 한 동작이 표시되고 **실행 취소**로 되돌릴 수 있으며, 미뤄 둔 태스크 수와 다음으로 돌아오는 시각, **내 작업**, 작업 중인 에이전트, **보관함 보기** 링크가 있습니다. 필터 때문에 나머지 알림이 가려진 경우에는 남은 알림 수와 **필터 지우고 계속하기**가 대신 표시됩니다. 뒤로 가면 태스크로 돌아갑니다. 보관과 일괄 작업의 확인에는 **실행 취소**가 있으며, 알림은 돌아오고 태스크 상태는 그대로 유지됩니다. **실행 취소**가 있는 확인 알림(보관, 미루기, 구독 해제 모두)은 10초 동안 표시되며, 표시되는 동안 `Z`를 누르면 그 동작을 취소합니다.이후 그 태스크에 새 알림이 오면 다시 인박스에 들어옵니다.diff --git a/apps/docs/content/docs/inbox.mdx b/apps/docs/content/docs/inbox.mdxindex fcf5e9df5e..4f1b89fd14 100644--- a/apps/docs/content/docs/inbox.mdx+++ b/apps/docs/content/docs/inbox.mdx@@ -137,9 +137,9 @@ Reading a notification doesn't remove it. A row leaves the inbox only when:- 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.- your inbox in the workspace goes past 2,000 notifications. It keeps the newest 2,000 and shortly afterwards archives the older ones, read or not. A notification that comes back from a snooze or that you restore from the archive counts from when it came back. Notifications on a snoozed issue don't count and are left alone.-Open windows drop an archived row right away, except the one you have open. When its notification leaves the inbox some other way (you set the issue to `done` from its status, another window archived it, or an edit took it out of the section's filters), the row stays lit where it was and the inbox bar says what happened. When a change you make from the bar archives the notification, the bar names it, as in *Changed to In Progress · Notification archived*, and keeps **Status**, **Assignee** and **Quick actions** for the next change. **Undo** (or `Z`) brings the notification back, and **Next** (or `E`) opens the next row. The row leaves once you move on. That is **After archiving → Stay on the issue**, the default; with **Open the next one**, a change you make that archives the open notification opens the next row right away, and the confirmation offers **Undo**.+Open windows drop an archived row right away, except the one you have open. When its notification leaves the inbox some other way (you set the issue to `done` from its status, another window archived it, or an edit took it out of the section's filters), the row stays lit where it was and the inbox bar says what happened. When a change you make from the bar archives the notification, the bar names it, as in *Changed to In Progress · Notification archived*, and keeps **Status**, **Assignee** and **Quick actions** for the next change. **Undo** (or `Z`) brings the notification back, and **Next** (or `E`) opens the next row. The row leaves once you move on. When it was the last notification in your inbox, the bar says **Inbox cleared** instead, with how many issues are snoozed, and offers **Go to My work** in place of **Next**; `E` opens the cleared inbox. That is **After archiving → Stay on the issue**, the default; with **Open the next one**, a change you make that archives the open notification opens the next row, or the cleared inbox, right away, and the confirmation offers **Undo**.-When you take the open row out yourself, from the inbox bar, its row, the hover card, or a bulk action that includes it, the next row opens instead. With nothing left to open, the issue stays open. Archiving and the bulk actions confirm with **Undo**, which brings the notifications back and leaves the issue's status as it is. Confirmations that offer **Undo**, for archiving, snoozing and unsubscribing alike, stay for 10 seconds, and while one shows, `Z` undoes that latest action.+When you take the open row out yourself, from the inbox bar, its row, the hover card, or a bulk action that includes it, the next row opens instead. With nothing left to open, the inbox page opens on **Inbox cleared**. It names what you just did, with **Undo** to bring it back, shows how many issues are snoozed and when the next one returns, and links to **My work**, the agents that are working, and **View archived**. When filters hid the rest of your inbox, it says how many notifications are left and offers **Clear filters and continue** instead. Going back returns to the issue. Archiving and the bulk actions confirm with **Undo**, which brings the notifications back and leaves the issue's status as it is. Confirmations that offer **Undo**, for archiving, snoozing and unsubscribing alike, stay for 10 seconds, and while one shows, `Z` undoes that latest action.A later notification on the issue lands in the inbox again.diff --git a/apps/docs/content/docs/inbox.zh-Hant.mdx b/apps/docs/content/docs/inbox.zh-Hant.mdxindex f533264302..9f30ae77d1 100644--- a/apps/docs/content/docs/inbox.zh-Hant.mdx+++ b/apps/docs/content/docs/inbox.zh-Hant.mdx@@ -137,9 +137,9 @@ multica inbox snooze <id>... --until tomorrow # RFC 3339、30m、3h、1d、1w- 它是"執行失敗"通知,且任務進入交回給人的狀態:`in_review`、`started` 分類下的自定義狀態,或 `done`、`closed` 分類下的任一狀態。這會歸檔所有人在該任務上的"執行失敗"通知,不論是誰改的狀態,也不受上面的開關影響。`blocked` 例外:它同樣交回給人,但工作還卡著,之前的失敗記錄還要看。- 你在該工作區的收件箱超過 2,000 條通知。收件箱保留最新的 2,000 條,隨後自動歸檔更早的通知,無論是否已讀。從延後中回來或從歸檔中還原的通知,按回來的時間算作新通知。已延後任務上的通知不計入,也不會被歸檔。-開著的視窗會立即移除已歸檔的列,但你正開著的那一列除外。它的通知因為其他原因離開收件箱時(你在狀態裡把任務改為 `done`、別的視窗歸檔了它,或修改後不再符合分區的篩選),這一列會在原位保持高亮,收件箱列會說明發生了什麼。在列裡改**狀態**、**負責人**或執行**快捷操作**後通知被歸檔時,列會寫明是哪一項,例如「已改為進行中 · 通知已歸檔」,這幾個操作也留在列裡,可以接著改。**復原**(或按 `Z`)讓通知回來,**下一條**(或按 `E`)開啟下一列。你離開之後,這一列才會移出。這是**歸檔後 → 停在目前任務**(預設)的行為;選**打開下一條**時,你的操作歸檔了正開著的通知後,會直接開啟下一列,提示裡可以**復原**。+開著的視窗會立即移除已歸檔的列,但你正開著的那一列除外。它的通知因為其他原因離開收件箱時(你在狀態裡把任務改為 `done`、別的視窗歸檔了它,或修改後不再符合分區的篩選),這一列會在原位保持高亮,收件箱列會說明發生了什麼。在列裡改**狀態**、**負責人**或執行**快捷操作**後通知被歸檔時,列會寫明是哪一項,例如「已改為進行中 · 通知已歸檔」,這幾個操作也留在列裡,可以接著改。**復原**(或按 `Z`)讓通知回來,**下一條**(或按 `E`)開啟下一列。你離開之後,這一列才會移出。如果這是收件箱裡的最後一條通知,列會改為顯示**收件箱已清空**和延後中的任務數,用**前往我的工作**代替**下一條**;按 `E` 會開啟已清空的收件箱。這是**歸檔後 → 停在目前任務**(預設)的行為;選**打開下一條**時,你的操作歸檔了正開著的通知後,會直接開啟下一列(沒有下一列時開啟已清空的收件箱),提示裡可以**復原**。-如果是你自己把正開著的這一列處理掉(在收件箱列、它所在的列、懸停卡片,或包含它的批次操作裡),會直接開啟下一列;沒有剩下的列時,任務保持開啟。歸檔和批次操作的提示裡都可以**復原**:通知會回來,任務的狀態保持不變。帶**復原**的提示(歸檔、延後、取消訂閱都一樣)會停留 10 秒;提示還在時,按 `Z` 復原這次操作。+如果是你自己把正開著的這一列處理掉(在收件箱列、它所在的列、懸停卡片,或包含它的批次操作裡),會直接開啟下一列;沒有剩下的列時,會開啟收件箱頁面,顯示**收件箱已清空**:寫明你剛才的操作,可以**復原**把它找回,顯示延後中的任務數和下一條回來的時間,並提供**我的工作**、正在工作的代理和**查看已歸檔**入口。如果是篩選隱藏了收件箱裡的其餘通知,會改為說明還剩多少條,並提供**清除篩選,繼續處理**。返回上一頁可以回到任務。歸檔和批次操作的提示裡都可以**復原**:通知會回來,任務的狀態保持不變。帶**復原**的提示(歸檔、延後、取消訂閱都一樣)會停留 10 秒;提示還在時,按 `Z` 復原這次操作。之後該任務再有新通知,會重新進入收件箱。diff --git a/apps/docs/content/docs/inbox.zh.mdx b/apps/docs/content/docs/inbox.zh.mdxindex 374b7a5e17..c5b7f1616c 100644--- a/apps/docs/content/docs/inbox.zh.mdx+++ b/apps/docs/content/docs/inbox.zh.mdx@@ -137,9 +137,9 @@ multica inbox snooze <id>... --until tomorrow # RFC 3339、30m、3h、1d、1w- 它是"运行失败"通知,且任务进入交回给人的状态:`in_review`、`started` 分类下的自定义状态,或 `done`、`closed` 分类下的任一状态。这会归档所有人在该任务上的"运行失败"通知,不论是谁改的状态,也不受上面的开关影响。`blocked` 例外:它同样交回给人,但工作还卡着,之前的失败记录还要看。- 你在该工作区的收件箱超过 2,000 条通知。收件箱保留最新的 2,000 条,随后自动归档更早的通知,无论是否已读。从延后中回来或从归档中还原的通知,按回来的时间算作新通知。已延后任务上的通知不计入,也不会被归档。-打开着的窗口会立即移除已归档的行,但你正打开的那一行除外。它的通知因为其他原因离开收件箱时(你在状态里把任务改为 `done`、别的窗口归档了它,或修改后不再符合分区的筛选),这一行会在原位保持高亮,收件箱栏会说明发生了什么。在栏里改**状态**、**负责人**或运行**快捷操作**后通知被归档时,栏会写明是哪一项,比如“已改为进行中 · 通知已归档”,这几个操作也留在栏里,可以接着改。**撤销**(或按 `Z`)让通知回来,**下一条**(或按 `E`)打开下一行。你离开之后,这一行才会移出。这是**归档后 → 停在当前任务**(默认)的行为;选**打开下一条**时,你的操作归档了正打开的通知后,会直接打开下一行,提示里可以**撤销**。+打开着的窗口会立即移除已归档的行,但你正打开的那一行除外。它的通知因为其他原因离开收件箱时(你在状态里把任务改为 `done`、别的窗口归档了它,或修改后不再符合分区的筛选),这一行会在原位保持高亮,收件箱栏会说明发生了什么。在栏里改**状态**、**负责人**或运行**快捷操作**后通知被归档时,栏会写明是哪一项,比如“已改为进行中 · 通知已归档”,这几个操作也留在栏里,可以接着改。**撤销**(或按 `Z`)让通知回来,**下一条**(或按 `E`)打开下一行。你离开之后,这一行才会移出。如果这是收件箱里的最后一条通知,栏会改为显示**收件箱已清空**和延后中的任务数,用**前往我的工作**代替**下一条**;按 `E` 会打开已清空的收件箱。这是**归档后 → 停在当前任务**(默认)的行为;选**打开下一条**时,你的操作归档了正打开的通知后,会直接打开下一行(没有下一行时打开已清空的收件箱),提示里可以**撤销**。-如果是你自己把正打开的这一行处理掉(在收件箱栏、它所在的行、悬停卡片,或包含它的批量操作里),会直接打开下一行;没有剩下的行时,任务保持打开。归档和批量操作的提示里都可以**撤销**:通知会回来,任务的状态保持不变。带**撤销**的提示(归档、延后、取消订阅都一样)会停留 10 秒;提示还在时,按 `Z` 撤销这次操作。+如果是你自己把正打开的这一行处理掉(在收件箱栏、它所在的行、悬停卡片,或包含它的批量操作里),会直接打开下一行;没有剩下的行时,会打开收件箱页面,显示**收件箱已清空**:写明你刚才的操作,可以**撤销**把它找回,显示延后中的任务数和下一条回来的时间,并提供**我的工作**、正在工作的智能体和**查看已归档**入口。如果是筛选隐藏了收件箱里的其余通知,会改为说明还剩多少条,并提供**清除筛选,继续处理**。返回上一页可以回到任务。归档和批量操作的提示里都可以**撤销**:通知会回来,任务的状态保持不变。带**撤销**的提示(归档、延后、取消订阅都一样)会停留 10 秒;提示还在时,按 `Z` 撤销这次操作。之后该任务再有新通知,会重新进入收件箱。diff --git a/packages/core/inbox/selection-store.ts b/packages/core/inbox/selection-store.tsindex 510710bd20..c4ccc273cb 100644--- a/packages/core/inbox/selection-store.ts+++ b/packages/core/inbox/selection-store.ts@@ -3,6 +3,48 @@import { create } from "zustand";import type { HeldInboxRow } from "./open-row";+/**+ * The notification action that just emptied the Inbox, kept in memory so the+ * Inbox Zero surface can offer a persistent inline undo (and return to that+ * notification) after the transient toast has gone.+ */+export type LastInboxCleared =+ | {+ kind: "archived";+ itemId: string;+ key: string;+ label: string;+ href: string;+ clearedAt: number;+ }+ | {+ kind: "snoozed";+ itemId: string;+ key: string;+ label: string;+ href: string;+ until: string;+ wasRead: boolean;+ clearedAt: number;+ }+ | {+ kind: "unsubscribed";+ itemId: string;+ issueId: string;+ key: string;+ label: string;+ href: string;+ undoable: boolean;+ clearedAt: number;+ }+ | {+ kind: "batch_archived";+ count: number;+ itemIds: string[];+ key: string | null;+ clearedAt: number;+ };+interface InboxSelectionState {lastResolvedKeyByWorkspace: Record<string, string>;rememberResolvedKey: (wsId: string, key: string) => void;@@ -52,6 +94,10 @@ interface InboxSelectionState {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;+ /** The action that just emptied the Inbox, per workspace, for the Inbox Zero screen. */+ lastClearedByWorkspace: Record<string, LastInboxCleared>;+ recordLastCleared: (wsId: string, entry: LastInboxCleared) => void;+ clearLastCleared: (wsId: string, matchKey?: string) => void;}const heldRowId = (wsId: string, list: string) => `${wsId}:${list}`;@@ -131,11 +177,15 @@ export const useInboxSelectionStore = create<InboxSelectionState>()((set) => ({);const left = state.leftRowKeyByWorkspace[wsId];const leftGoes = left !== undefined && keys.includes(left);- if (!leftGoes && held.length === Object.keys(state.heldRows).length) return state;+ const cleared = state.lastClearedByWorkspace[wsId];+ const clearedGoes = !!cleared?.key && keys.includes(cleared.key);+ if (!leftGoes && !clearedGoes && held.length === Object.keys(state.heldRows).length) return state;const { [wsId]: _forgotten, ...otherLeft } = state.leftRowKeyByWorkspace;+ const { [wsId]: _cleared, ...otherCleared } = state.lastClearedByWorkspace;return {heldRows: Object.fromEntries(held),leftRowKeyByWorkspace: leftGoes ? otherLeft : state.leftRowKeyByWorkspace,+ lastClearedByWorkspace: clearedGoes ? otherCleared : state.lastClearedByWorkspace,};}),releaseRows: (wsId, openKeys) =>@@ -159,4 +209,17 @@ export const useInboxSelectionStore = create<InboxSelectionState>()((set) => ({const { [id]: _dropped, ...heldRows } = state.heldRows;return { heldRows };}),+ lastClearedByWorkspace: {},+ recordLastCleared: (wsId, entry) =>+ set((state) => ({+ lastClearedByWorkspace: { ...state.lastClearedByWorkspace, [wsId]: entry },+ })),+ clearLastCleared: (wsId, matchKey) =>+ set((state) => {+ const current = state.lastClearedByWorkspace[wsId];+ if (!current) return state;+ if (matchKey !== undefined && current.key !== matchKey) return state;+ const { [wsId]: _cleared, ...lastClearedByWorkspace } = state.lastClearedByWorkspace;+ return { lastClearedByWorkspace };+ }),}));diff --git a/packages/views/inbox/components/inbox-empty-state.test.tsx b/packages/views/inbox/components/inbox-empty-state.test.tsxnew file mode 100644index 0000000000..d65e65b144--- /dev/null+++ b/packages/views/inbox/components/inbox-empty-state.test.tsx@@ -0,0 +1,245 @@+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { act, cleanup, fireEvent, screen } from "@testing-library/react";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { workspaceWorkingAgentsOptions } from "@multica/core/agents";+import { inboxKeys, snoozedInboxOptions } from "@multica/core/inbox/queries";+import { useInboxSelectionStore } from "@multica/core/inbox/selection-store";+import type { SnoozedInboxIssue, WorkspaceWorkingAgent } from "@multica/core/types";+import { renderWithI18n } from "../../test/i18n";+import { NavigationProvider, type NavigationAdapter } from "../../navigation";+import { InboxEmptyState } from "./inbox-empty-state";++const spies = vi.hoisted(() => ({+ restoreInbox: vi.fn((..._args: unknown[]) => Promise.resolve(true)),+ unsnoozeAsync: vi.fn(() => Promise.resolve()),+ undoUnsubscribe: vi.fn((..._args: unknown[]) => Promise.resolve()),+ undoBatch: vi.fn((..._args: unknown[]) => Promise.resolve()),+ guest: false,+}));++vi.mock("@multica/core/hooks", () => ({ useWorkspaceId: () => "ws" }));+vi.mock("@multica/core/permissions", () => ({ useIsGuest: () => spies.guest }));+vi.mock("@multica/core/paths", async (importOriginal) => {+ const actual = await importOriginal<typeof import("@multica/core/paths")>();+ return { ...actual, useWorkspacePaths: () => actual.paths.workspace("acme") };+});+vi.mock("@multica/core/inbox/mutations", async (importOriginal) => ({+ ...(await importOriginal<typeof import("@multica/core/inbox/mutations")>()),+ useUnsnoozeInbox: () => ({ mutateAsync: spies.unsnoozeAsync }),+ undoUnsubscribeArchiveInbox: (...args: unknown[]) => spies.undoUnsubscribe(...args),+ undoArchiveInboxBatch: (...args: unknown[]) => spies.undoBatch(...args),+}));+vi.mock("./use-leave-inbox-row", () => ({+ useRestoreInbox: () => spies.restoreInbox,+}));++function renderEmpty({+ isArchivedView = false,+ visibleCount = 0,+ totalActiveCount = 0,+ hasActiveFilters = false,+ inboxZeroRises = false,+ isCompact = false,+ snoozed = [],+ workingAgents = [],+ onClearFiltersAndContinue = vi.fn(),+ onViewArchived = vi.fn(),+}: {+ isArchivedView?: boolean;+ visibleCount?: number;+ totalActiveCount?: number;+ hasActiveFilters?: boolean;+ inboxZeroRises?: boolean;+ isCompact?: boolean;+ snoozed?: SnoozedInboxIssue[];+ workingAgents?: WorkspaceWorkingAgent[];+ onClearFiltersAndContinue?: () => void;+ onViewArchived?: () => void;+} = {}) {+ const nav: NavigationAdapter = {+ push: vi.fn(),+ replace: vi.fn(),+ back: vi.fn(),+ pathname: "/acme/inbox",+ searchParams: new URLSearchParams(),+ hash: "",+ getShareableUrl: (path) => path,+ };+ const qc = new QueryClient({ defaultOptions: { queries: { retry: false, staleTime: Infinity } } });+ qc.setQueryData(snoozedInboxOptions("ws").queryKey, snoozed);+ qc.setQueryData(workspaceWorkingAgentsOptions("ws", "issue").queryKey, workingAgents);+ const view = renderWithI18n(+ <QueryClientProvider client={qc}>+ <NavigationProvider value={nav}>+ <InboxEmptyState+ wsId="ws"+ isArchivedView={isArchivedView}+ visibleCount={visibleCount}+ totalActiveCount={totalActiveCount}+ hasActiveFilters={hasActiveFilters}+ inboxZeroRises={inboxZeroRises}+ isCompact={isCompact}+ onClearFiltersAndContinue={onClearFiltersAndContinue}+ onViewArchived={onViewArchived}+ />+ </NavigationProvider>+ </QueryClientProvider>,+ );+ return { ...view, nav, qc, onClearFiltersAndContinue, onViewArchived };+}++beforeEach(() => {+ vi.clearAllMocks();+ spies.guest = false;+ useInboxSelectionStore.setState({+ lastClearedByWorkspace: {},+ leftRowKeyByWorkspace: {},+ sidebarIssueByWorkspace: {},+ });+});+afterEach(cleanup);++describe("InboxEmptyState", () => {+ it("shows calm Inbox Zero with My work, working agents, snoozed summary, and View archived", () => {+ const until = new Date(Date.now() + 2 * 60 * 60 * 1000).toISOString();+ const { nav, onViewArchived } = renderEmpty({+ snoozed: [+ { issue_id: "issue-9", item_id: "n-9", snoozed_until: until, snoozed_at: new Date().toISOString(), updates: 0 },+ ],+ workingAgents: [+ { id: "a-1", name: "Emacs", avatar_url: null, running_task_count: 1, issue_ids: ["issue-1"] },+ { id: "a-2", name: "Codex", avatar_url: null, running_task_count: 1, issue_ids: ["issue-2"] },+ ],+ });++ expect(screen.getByRole("heading", { name: "Inbox cleared" })).toBeInTheDocument();+ expect(screen.getByText(/1 snoozed/)).toBeInTheDocument();+ expect(screen.getByRole("button", { name: "2 agents working" })).toBeInTheDocument();++ fireEvent.click(screen.getByRole("button", { name: "My work" }));+ expect(nav.push).toHaveBeenCalledWith(expect.stringContaining("/acme/issues"));++ fireEvent.click(screen.getByRole("button", { name: "View archived" }));+ expect(onViewArchived).toHaveBeenCalledTimes(1);+ });++ it("offers inline undo for the just-archived notification and navigates back on click", async () => {+ useInboxSelectionStore.setState({+ lastClearedByWorkspace: {+ ws: {+ kind: "archived",+ itemId: "n-1",+ key: "issue-1",+ label: "MUL-9790",+ href: "/acme/issues/MUL-9790",+ clearedAt: Date.now(),+ },+ },+ leftRowKeyByWorkspace: { ws: "issue-1" },+ });++ const { nav } = renderEmpty();+ expect(screen.getByText("Just archived MUL-9790")).toBeInTheDocument();++ await act(async () => {+ fireEvent.click(screen.getByRole("button", { name: "Undo" }));+ });+ expect(spies.restoreInbox).toHaveBeenCalledWith("n-1", { quiet: true });+ expect(nav.push).toHaveBeenCalledWith("/acme/issues/MUL-9790");+ expect(useInboxSelectionStore.getState().lastClearedByWorkspace.ws).toBeUndefined();+ expect(useInboxSelectionStore.getState().sidebarIssueByWorkspace.ws).toBe("issue-1");+ });++ it("opens a restored notification only once it is back in the Inbox list", async () => {+ useInboxSelectionStore.setState({+ lastClearedByWorkspace: {+ ws: {+ kind: "archived",+ itemId: "n-2",+ key: "n-2",+ label: "Automation paused",+ href: "/acme/inbox?issue=n-2",+ clearedAt: Date.now(),+ },+ },+ });+ let finish!: (ok: boolean) => void;+ spies.restoreInbox.mockReturnValueOnce(new Promise<boolean>((resolve) => (finish = resolve)));+ const { nav, qc } = renderEmpty();+ const invalidate = vi.spyOn(qc, "invalidateQueries");++ fireEvent.click(screen.getByRole("button", { name: "Undo" }));+ fireEvent.click(screen.getByRole("button", { name: "Undo" }));+ expect(spies.restoreInbox).toHaveBeenCalledTimes(1);+ expect(nav.push).not.toHaveBeenCalled();+ expect(useInboxSelectionStore.getState().lastClearedByWorkspace.ws).toBeDefined();++ await act(async () => finish(true));+ expect(invalidate).toHaveBeenCalledWith({ queryKey: inboxKeys.list("ws") });+ expect(nav.push).toHaveBeenCalledWith("/acme/inbox?issue=n-2");+ expect(invalidate.mock.invocationCallOrder[0]!).toBeLessThan(+ (nav.push as ReturnType<typeof vi.fn>).mock.invocationCallOrder[0]!,+ );+ expect(useInboxSelectionStore.getState().lastClearedByWorkspace.ws).toBeUndefined();+ });++ it("keeps the undo when it fails, so it can be tried again", async () => {+ useInboxSelectionStore.setState({+ lastClearedByWorkspace: {+ ws: {+ kind: "archived",+ itemId: "n-1",+ key: "issue-1",+ label: "MUL-9790",+ href: "/acme/issues/MUL-9790",+ clearedAt: Date.now(),+ },+ },+ });+ spies.restoreInbox.mockResolvedValueOnce(false);+ const { nav } = renderEmpty();++ await act(async () => {+ fireEvent.click(screen.getByRole("button", { name: "Undo" }));+ });+ expect(nav.push).not.toHaveBeenCalled();+ expect(useInboxSelectionStore.getState().lastClearedByWorkspace.ws).toBeDefined();+ expect(screen.getByRole("button", { name: "Undo" })).toBeEnabled();+ });++ it("shows filtered-empty state with remaining count and Clear filters CTA instead of Inbox Zero", () => {+ const { container, onClearFiltersAndContinue } = renderEmpty({+ visibleCount: 0,+ totalActiveCount: 4,+ hasActiveFilters: true,+ });++ expect(screen.getByRole("heading", { name: "All caught up for this filter" })).toBeInTheDocument();+ expect(screen.getByText("4 other notifications in your inbox")).toBeInTheDocument();+ expect(screen.queryByRole("heading", { name: "Inbox cleared" })).toBeNull();+ // MulticaBleedMark (viewBox 0 0 100 100) must not render in filtered-empty state.+ expect(container.querySelector('svg[viewBox="0 0 100 100"]')).toBeNull();++ fireEvent.click(screen.getByRole("button", { name: /Clear filters and continue/ }));+ expect(onClearFiltersAndContinue).toHaveBeenCalledTimes(1);+ });++ it("hides member-only shortcuts and working agents for guests", () => {+ spies.guest = true;+ renderEmpty({+ workingAgents: [+ { id: "a-1", name: "Emacs", avatar_url: null, running_task_count: 1, issue_ids: ["issue-1"] },+ ],+ });++ expect(screen.queryByRole("button", { name: "My work" })).toBeNull();+ expect(screen.queryByRole("button", { name: /agent/i })).toBeNull();+ expect(screen.getByRole("button", { name: "View archived" })).toBeInTheDocument();+ });++ it("keeps the archived empty state quiet and separate from Inbox Zero", () => {+ renderEmpty({ isArchivedView: true });+ expect(screen.getByText("No archived notifications")).toBeInTheDocument();+ expect(screen.queryByRole("heading", { name: "Inbox cleared" })).toBeNull();+ });+});diff --git a/packages/views/inbox/components/inbox-empty-state.tsx b/packages/views/inbox/components/inbox-empty-state.tsxnew file mode 100644index 0000000000..2f7665640f--- /dev/null+++ b/packages/views/inbox/components/inbox-empty-state.tsx@@ -0,0 +1,357 @@+"use client";++import { useMemo, useState } from "react";+import { useQuery, useQueryClient } from "@tanstack/react-query";+import { toast } from "sonner";+import {+ AlarmClock,+ Archive,+ Check,+ CircleUser,+ Filter,+ History,+ Inbox,+ Undo2,+} from "@multica/ui/icons";+import { Button } from "@multica/ui/components/ui/button";+import { MulticaBleedMark } from "@multica/ui/components/common/multica-graphics";+import { workspaceWorkingAgentsOptions } from "@multica/core/agents";+import { useSearchStore } from "@multica/core/command-bar";+import {+ undoArchiveInboxBatch,+ undoUnsubscribeArchiveInbox,+ useUnsnoozeInbox,+} from "@multica/core/inbox/mutations";+import { inboxKeys, snoozedInboxOptions } from "@multica/core/inbox/queries";+import {+ useInboxSelectionStore,+ type LastInboxCleared,+} from "@multica/core/inbox/selection-store";+import { openCreateIssueWithPreference } from "@multica/core/issues/stores";+import { useIsGuest } from "@multica/core/permissions";+import type { SnoozedInboxIssue, WorkspaceWorkingAgent } from "@multica/core/types";+import { ActionShortcutKeycaps } from "../../common/shortcut-keycaps";+import { useLocale, useT } from "../../i18n";+import { useBuiltinViewNavigation } from "../../issue-views/builtin-views";+import { useNavigation } from "../../navigation";+import { formatSnoozeTime } from "./inbox-snooze-time";+import { useRestoreInbox } from "./use-leave-inbox-row";++const NO_SNOOZED: SnoozedInboxIssue[] = [];+const NO_AGENTS: WorkspaceWorkingAgent[] = [];++/**+ * The empty detail canvas of `/inbox`:+ * - Prompt to pick a row when notifications still exist in the Work panel.+ * - Quiet archived-empty state when browsing Archived.+ * - Filtered-empty state when active filters hid remaining notifications+ * (never confused with true Inbox Zero).+ * - Calm Inbox Zero state with MulticaBleedMark, persistent inline undo for+ * the action that just cleared the Inbox, snoozed summary, and quiet next+ * steps (My work, working agents, Archived, keyboard hints).+ */+export function InboxEmptyState({+ wsId,+ isArchivedView,+ visibleCount,+ totalActiveCount,+ hasActiveFilters,+ inboxZeroRises,+ isCompact = false,+ onClearFiltersAndContinue,+ onViewArchived,+}: {+ wsId: string;+ isArchivedView: boolean;+ visibleCount: number;+ /** Total active (unfiltered, unarchived) notifications in the Inbox. */+ totalActiveCount: number;+ hasActiveFilters: boolean;+ inboxZeroRises: boolean;+ isCompact?: boolean;+ onClearFiltersAndContinue: () => void;+ onViewArchived: () => void;+}) {+ const { t } = useT("inbox");+ const { t: tLayout } = useT("layout");+ const locale = useLocale();+ const qc = useQueryClient();+ const { push } = useNavigation();+ const builtinNav = useBuiltinViewNavigation();+ const guest = useIsGuest(wsId);+ const restoreInbox = useRestoreInbox();+ const { mutateAsync: unsnoozeAsync } = useUnsnoozeInbox();++ const lastCleared = useInboxSelectionStore((s) => s.lastClearedByWorkspace[wsId] ?? null);+ const clearLastCleared = useInboxSelectionStore((s) => s.clearLastCleared);++ const isFilteredEmpty = !isArchivedView && hasActiveFilters && visibleCount === 0 && totalActiveCount > 0;+ const isInboxZero = !isArchivedView && visibleCount === 0 && !isFilteredEmpty;++ const { data: snoozed = NO_SNOOZED } = useQuery({+ ...snoozedInboxOptions(wsId),+ enabled: isInboxZero && !!wsId,+ });+ const { data: workingAgents = NO_AGENTS } = useQuery({+ ...workspaceWorkingAgentsOptions(wsId, "issue"),+ enabled: isInboxZero && !guest && !!wsId,+ });++ const activeSnoozed = useMemo(() => {+ const now = Date.now();+ return snoozed+ .filter((entry) => new Date(entry.snoozed_until).getTime() > now)+ .sort((a, b) => new Date(a.snoozed_until).getTime() - new Date(b.snoozed_until).getTime());+ }, [snoozed]);++ const workingCount = workingAgents.length;++ const [undoing, setUndoing] = useState(false);++ /** Resolves whether the undo went through; a failure is toasted. */+ const requestUndo = (entry: LastInboxCleared): Promise<boolean> => {+ const failed = (fallback: string) => (err: unknown) => {+ toast.error(err instanceof Error && err.message ? err.message : fallback);+ return false;+ };+ switch (entry.kind) {+ case "archived":+ return restoreInbox(entry.itemId, { quiet: true });+ case "snoozed":+ return unsnoozeAsync({ id: entry.itemId, read: entry.wasRead }).then(+ () => true,+ failed(t(($) => $.snooze.unsnooze_failed)),+ );+ case "unsubscribed":+ return undoUnsubscribeArchiveInbox(qc, wsId, { id: entry.itemId, issueId: entry.issueId }).then(+ () => true,+ failed(t(($) => $.errors.undo_unsubscribe_failed)),+ );+ case "batch_archived":+ return undoArchiveInboxBatch(qc, wsId, entry.itemIds).then(+ () => true,+ failed(t(($) => $.errors.unarchive_failed)),+ );+ }+ };++ // The restored row must be in the Inbox list before its link opens: the+ // Inbox page drops a `?issue=` selection it cannot find there. The write+ // refreshes the list without waiting, and that refresh starts first, so this+ // one (cancel, then refetch) is the last and the one awaited.+ const refreshInboxList = async () => {+ await qc.cancelQueries({ queryKey: inboxKeys.list(wsId) });+ await qc.invalidateQueries({ queryKey: inboxKeys.list(wsId) });+ };++ const handleUndoCleared = async (entry: LastInboxCleared) => {+ if (undoing || !canUndoCleared(entry)) return;+ setUndoing(true);+ const undone = await requestUndo(entry);+ if (undone) await refreshInboxList();+ setUndoing(false);+ // A failed undo keeps the entry, so it can be tried again.+ if (!undone) return;++ const store = useInboxSelectionStore.getState();+ clearLastCleared(wsId, entry.key ?? undefined);+ if (entry.kind === "batch_archived") {+ if (entry.key) store.returnRow(wsId, entry.key);+ return;+ }+ store.returnRow(wsId, entry.key);+ if (entry.kind === "unsubscribed") store.rememberSidebarIssue(wsId, entry.issueId);+ else if (entry.href.includes("/issues/")) store.rememberSidebarIssue(wsId, entry.key);+ push?.(entry.href);+ };++ const clearedSummary = (entry: LastInboxCleared): string => {+ if (entry.kind === "archived") return t(($) => $.zero.just_archived, { label: entry.label });+ if (entry.kind === "snoozed") {+ return t(($) => $.zero.just_snoozed, {+ label: entry.label,+ time: formatSnoozeTime(new Date(entry.until), new Date(), locale),+ });+ }+ if (entry.kind === "unsubscribed") return t(($) => $.zero.just_unsubscribed, { label: entry.label });+ return t(($) => $.zero.just_archived_many, { count: entry.count });+ };++ const canUndoCleared = (entry: LastInboxCleared) => entry.kind !== "unsubscribed" || entry.undoable;++ // Desktop prompt when active notifications exist in the Work panel.+ if (visibleCount > 0) {+ return (+ <div className="relative flex min-h-0 flex-1 flex-col items-center justify-center overflow-hidden text-muted-foreground">+ <Inbox className="mb-3 h-10 w-10 text-faint-foreground" />+ <p className="relative text-body">{t(($) => $.detail.select_prompt)}</p>+ </div>+ );+ }++ // Archived view empty state stays quiet and distinct from Inbox Zero.+ if (isArchivedView) {+ return (+ <div className="relative flex min-h-0 flex-1 flex-col items-center justify-center overflow-hidden text-muted-foreground">+ <Archive className="mb-3 h-10 w-10 text-faint-foreground" />+ <p className="relative text-body">{t(($) => $.list.archived_empty)}</p>+ </div>+ );+ }++ // Filtered-empty state: active filters hid other notifications in the Inbox.+ if (isFilteredEmpty) {+ return (+ <div className="relative flex min-h-0 flex-1 flex-col items-center justify-center overflow-hidden px-6 text-center">+ <div className="-mt-8 flex max-w-md flex-col items-center">+ <div className="mb-4 flex size-11 items-center justify-center rounded-xl bg-muted text-muted-foreground">+ <Filter className="size-5" />+ </div>+ <h2 className="text-title font-semibold text-foreground">{t(($) => $.zero.filtered_title)}</h2>+ <p className="mt-1.5 text-label text-muted-foreground">+ {t(($) => $.zero.filtered_remaining, { count: totalActiveCount })}+ </p>+ <div className="mt-6 flex flex-wrap items-center justify-center gap-2">+ <Button size="sm" onClick={onClearFiltersAndContinue}>+ <span>{t(($) => $.zero.clear_and_continue)}</span>+ <span className="tabular-nums opacity-75">{totalActiveCount}</span>+ </Button>+ {lastCleared && canUndoCleared(lastCleared) && (+ <Button size="sm" variant="outline" disabled={undoing} onClick={() => void handleUndoCleared(lastCleared)}>+ <Undo2 />+ {lastCleared.kind === "batch_archived"+ ? t(($) => $.toasts.undo)+ : t(($) => $.zero.undo_item, { label: lastCleared.label })}+ </Button>+ )}+ </div>+ </div>+ </div>+ );+ }++ // True Inbox Zero.+ const rises = inboxZeroRises || lastCleared !== null;+ const bleedKey = lastCleared ? `rise-${lastCleared.clearedAt}` : inboxZeroRises ? "rise" : "rest";+ const earliestSnooze = activeSnoozed[0] ? new Date(activeSnoozed[0].snoozed_until) : null;++ return (+ <div className="relative flex min-h-0 flex-1 flex-col items-center justify-center overflow-hidden px-6 text-center">+ <MulticaBleedMark+ key={bleedKey}+ enterDelay={rises ? 0.2 : undefined}+ className="pointer-events-none absolute -right-[14%] -bottom-[26%] w-[min(560px,58%)] text-muted"+ />+ <div className="relative z-10 -mt-8 flex max-w-md flex-col items-center">+ <div+ aria-hidden+ className="mb-4 flex size-11 items-center justify-center rounded-xl border border-surface-border bg-surface text-success shadow-[var(--surface-shadow)]"+ >+ <Check className="size-5" />+ </div>+ <h2 className="text-title font-semibold text-foreground">{t(($) => $.zero.cleared_title)}</h2>+ {lastCleared ? (+ <p className="mt-1.5 flex flex-wrap items-center justify-center gap-1.5 text-label text-muted-foreground">+ <span>{clearedSummary(lastCleared)}</span>+ {canUndoCleared(lastCleared) && (+ <>+ <span aria-hidden className="text-faint-foreground">·</span>+ <button+ type="button"+ disabled={undoing}+ onClick={() => void handleUndoCleared(lastCleared)}+ className="inline-flex items-center gap-1 rounded-md bg-muted px-2 py-0.5 text-caption font-medium text-foreground transition-colors hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50"+ >+ <Undo2 className="size-3" />+ {t(($) => $.toasts.undo)}+ </button>+ </>+ )}+ </p>+ ) : (+ <p className="mt-1.5 text-label text-muted-foreground">{t(($) => $.detail.empty)}</p>+ )}++ {activeSnoozed.length > 0 && earliestSnooze && (+ <button+ type="button"+ onClick={() => {+ builtinNav.prepare("snoozed");+ push?.(builtinNav.hrefFor("snoozed"));+ }}+ className="mt-2 inline-flex items-center gap-1.5 rounded-md px-1.5 py-0.5 text-caption text-faint-foreground transition-colors hover:text-muted-foreground focus-visible:outline-2 focus-visible:outline-ring"+ >+ <AlarmClock className="size-3.5 shrink-0" />+ <span>+ {t(($) => $.zero.snoozed_summary, {+ count: activeSnoozed.length,+ time: formatSnoozeTime(earliestSnooze, new Date(), locale),+ })}+ </span>+ </button>+ )}++ <div className="mt-6 flex flex-wrap items-center justify-center gap-2">+ {!guest && (+ <Button+ size="sm"+ variant="outline"+ onClick={() => {+ builtinNav.prepare("my_work");+ push?.(builtinNav.hrefFor("my_work"));+ }}+ >+ <CircleUser />+ <span>{t(($) => $.zero.my_work)}</span>+ </Button>+ )}+ {!guest && workingCount > 0 && (+ <Button+ size="sm"+ variant="outline"+ onClick={() => {+ builtinNav.prepare("working");+ push?.(builtinNav.hrefFor("working"));+ }}+ >+ <span aria-hidden className="size-1.5 shrink-0 rounded-full bg-brand ring-3 ring-brand/20" />+ <span>{t(($) => $.zero.agents_working, { count: workingCount })}</span>+ </Button>+ )}+ <Button+ size="sm"+ variant="outline"+ className="text-muted-foreground"+ onClick={onViewArchived}+ >+ <History />+ <span>{t(($) => $.zero.view_archived)}</span>+ </Button>+ </div>++ {!isCompact && (+ <div className="mt-5 flex items-center justify-center gap-4 text-caption text-faint-foreground">+ {!guest && (+ <button+ type="button"+ onClick={() => openCreateIssueWithPreference()}+ className="inline-flex items-center gap-1.5 rounded-md px-1 py-0.5 transition-colors hover:text-muted-foreground focus-visible:outline-2 focus-visible:outline-ring"+ >+ <ActionShortcutKeycaps action="createIssue" />+ <span>{tLayout(($) => $.sidebar.new_issue)}</span>+ </button>+ )}+ <button+ type="button"+ onClick={() => useSearchStore.getState().setOpen(true)}+ className="inline-flex items-center gap-1.5 rounded-md px-1 py-0.5 transition-colors hover:text-muted-foreground focus-visible:outline-2 focus-visible:outline-ring"+ >+ <ActionShortcutKeycaps action="openSearch" />+ <span>{t(($) => $.zero.quick_jump)}</span>+ </button>+ </div>+ )}+ </div>+ </div>+ );+}diff --git a/packages/views/inbox/components/inbox-kept-actions.tsx b/packages/views/inbox/components/inbox-kept-actions.tsxindex b0698de635..c53bb8933d 100644--- a/packages/views/inbox/components/inbox-kept-actions.tsx+++ b/packages/views/inbox/components/inbox-kept-actions.tsx@@ -1,7 +1,7 @@"use client";import { type ReactNode, useEffect, useRef } from "react";-import { Archive, ArrowDown, Undo2 } from "@multica/ui/icons";+import { Archive, ArrowDown, ArrowRight, CheckCircle2, Undo2 } from "@multica/ui/icons";import { Button } from "@multica/ui/components/ui/button";import { TooltipHint } from "@multica/ui/components/common/tooltip-hint";import { useIssueStatuses } from "@multica/core/issue-statuses/hooks";@@ -88,15 +88,24 @@ export function InboxKeptActions({onUndo,next,onNext,+ inboxCleared = false,+ snoozedCount = 0,+ onSnoozedClick,+ onGoToMyWork,}: {label: ReactNode;- /** Defaults to the archive icon. */+ /** Defaults to the archive icon (or a success check when the Inbox is cleared). */icon?: ReactNode;issueActions?: ReactNode;onUndo?: () => void;/** The notification `onNext` opens; without one there is nothing to move on to. */next: InboxItem | null;onNext: () => void;+ /** True when archiving this row emptied the entire unfiltered Inbox (stay-in-place mode). */+ inboxCleared?: boolean;+ snoozedCount?: number;+ onSnoozedClick?: () => void;+ onGoToMyWork?: () => void;}) {const { t } = useT("inbox");const undoRef = useRef(onUndo);@@ -120,11 +129,35 @@ export function InboxKeptActions({document.addEventListener("keydown", onKeyDown);return () => document.removeEventListener("keydown", onKeyDown);}, []);+ const statusIcon =+ icon ?? (inboxCleared ? <CheckCircle2 className="text-success" /> : <Archive />);+ const statusLabel = inboxCleared ? (+ <span className="flex min-w-0 items-center gap-1.5 truncate">+ <span className="font-medium text-foreground">{t(($) => $.zero.cleared_title)}</span>+ <span aria-hidden className="text-faint-foreground">·</span>+ <span className="truncate">{label}</span>+ {snoozedCount > 0 && onSnoozedClick && (+ <>+ <span aria-hidden className="text-faint-foreground @max-[34rem]/inbox-bar:hidden">·</span>+ <button+ type="button"+ onClick={onSnoozedClick}+ className="shrink-0 underline decoration-surface-border underline-offset-2 transition-colors hover:text-foreground @max-[34rem]/inbox-bar:hidden"+ >+ {t(($) => $.zero.bar_snoozed, { count: snoozedCount })}+ </button>+ </>+ )}+ </span>+ ) : (+ label+ );+return (<InboxBar settled>- <InboxBarStatus icon={icon ?? <Archive />} label={label} />+ <InboxBarStatus icon={statusIcon} label={statusLabel} />{issueActions}- {issueActions && (onUndo || next) && <InboxBarSeparator />}+ {issueActions && (onUndo || next || (inboxCleared && onGoToMyWork)) && <InboxBarSeparator />}{onUndo && (<Button size="sm" variant="ghost" className="shrink-0 text-muted-foreground" onClick={onUndo}><Undo2 />@@ -134,7 +167,14 @@ export function InboxKeptActions({</span></Button>)}- {next && <InboxNextButton next={next} onNext={onNext} />}+ {next ? (+ <InboxNextButton next={next} onNext={onNext} />+ ) : inboxCleared && onGoToMyWork ? (+ <Button size="sm" variant="outline" className="shrink-0" onClick={onGoToMyWork}>+ {t(($) => $.zero.go_to_my_work)}+ <ArrowRight />+ </Button>+ ) : null}</InboxBar>);}diff --git a/packages/views/inbox/components/inbox-page.test.tsx b/packages/views/inbox/components/inbox-page.test.tsxindex 091f38cafd..d5e48a89c5 100644--- a/packages/views/inbox/components/inbox-page.test.tsx+++ b/packages/views/inbox/components/inbox-page.test.tsx@@ -38,6 +38,7 @@ vi.mock("@tanstack/react-query", () => ({data: options.queryKey.includes("archived")? { items: listData.lookup ?? listData.archived, hasMore: false, nextCursor: null }: options.queryKey.includes("agent-task-snapshot") ? listData.tasks+ : options.queryKey.includes("working-agents") ? []: options.queryKey.includes("snoozed") ? NO_SNOOZED : listData.active,isLoading: false,isError: false,@@ -63,10 +64,15 @@ vi.mock("@multica/core/hooks", () => ({useWorkspaceId: () => "workspace-1",}));+vi.mock("@multica/core/permissions", () => ({+ useIsGuest: () => false,+}));+vi.mock("@multica/core/paths", () => ({issueRouteRef: (issue: { id: string; identifier?: string | null }) => issue.identifier || issue.id,useWorkspacePaths: () => ({inbox: () => "/acme/inbox",+ issues: () => "/acme/issues",issueDetail: (id: string) => `/acme/issues/${id}`,}),}));@@ -147,10 +153,11 @@ vi.mock("../../issues/components/issue-detail", () => ({}));const replace = vi.fn();+const push = vi.fn();let searchParams = new URLSearchParams();vi.mock("../../navigation", () => ({- useNavigation: () => ({ searchParams, replace }),+ useNavigation: () => ({ searchParams, replace, push }),// Real hook: reports the detail-pane swap to the shell's progress bar.// Nothing here renders that bar, and the page reads nothing back from it.useReportNavigating: () => {},@@ -268,7 +275,12 @@ function item(overrides: Partial<InboxItem> = {}): InboxItem {}function reset() {- useInboxSelectionStore.setState({ lastResolvedKeyByWorkspace: {}, heldRows: {}, leftRowKeyByWorkspace: {} });+ useInboxSelectionStore.setState({+ lastResolvedKeyByWorkspace: {},+ heldRows: {},+ leftRowKeyByWorkspace: {},+ lastClearedByWorkspace: {},+ });listData.active = [];listData.archived = [];listData.lookup = undefined;diff --git a/packages/views/inbox/components/inbox-page.tsx b/packages/views/inbox/components/inbox-page.tsxindex 39a9ea256e..4bdc1436d8 100644--- a/packages/views/inbox/components/inbox-page.tsx+++ b/packages/views/inbox/components/inbox-page.tsx@@ -11,7 +11,6 @@ import {} from "react";import { useInfiniteQuery, useQuery, useQueryClient } from "@tanstack/react-query";import { useWorkspaceId } from "@multica/core/hooks";-import { MulticaBleedMark } from "@multica/ui/components/common/multica-graphics";import { ApiError, errorCode } from "@multica/core/api";import { useWorkspacePaths } from "@multica/core/paths";import { useModalStore } from "@multica/core/modals";@@ -24,7 +23,7 @@ import {import { isImeComposing } from "@multica/core/utils";import { useIssueDraftStore } from "@multica/core/issues/stores/draft-store";import { cachedIssueRouteRef } from "@multica/core/issues/canonical-id";-import { useInboxSelectionStore } from "@multica/core/inbox/selection-store";+import { useInboxSelectionStore, type LastInboxCleared } from "@multica/core/inbox/selection-store";import { inboxRowKey, nextInboxRow } from "@multica/core/inbox/open-row";import { useIssueStatuses } from "@multica/core/issue-statuses/hooks";import {@@ -115,16 +114,24 @@ import { ARCHIVED_VIEW_PARAM, type InboxView } from "./inbox-view";import { useTypeLabels } from "./inbox-detail-label";import {getInboxDisplayTitle,+ inboxRowHref,isAutopilotQuotaNotice,isQuickCreateOutcome,resolveDetailItem,} from "./inbox-display";import { AutopilotQuotaNotice } from "./autopilot-quota-notice";+import { InboxEmptyState } from "./inbox-empty-state";import { InboxKeptActions, useKeptInboxRowText } from "./inbox-kept-actions";import { inboxListLoad, useFilteredInboxRows } from "./use-filtered-inbox-rows";import { useKeptOpenInboxRow } from "./use-kept-open-inbox-row";import { useMoveOnAfterAutoArchive } from "./use-move-on-after-auto-archive";-import { useArchiveInboxBatchWithUndo, useArchiveInboxWithUndo, useRestoreInbox } from "./use-leave-inbox-row";+import {+ clearedLabelForItem,+ collectBatchArchiveIds,+ useArchiveInboxBatchWithUndo,+ useArchiveInboxWithUndo,+ useRestoreInbox,+} from "./use-leave-inbox-row";import { useInboxSnooze } from "./use-inbox-snooze";import { InboxAppRequest } from "../../common/app-requests";import { useT } from "../../i18n";@@ -141,7 +148,7 @@ export function InboxPage() {const showAutopilotQuotaRecoveryPrompt = useLimitRecoveryPrompt("autopilot_quota",);- const { searchParams, replace } = useNavigation();+ const { searchParams, replace, push } = useNavigation();const urlIssue = searchParams.get("issue") ?? "";const urlView: InboxView =searchParams.get("view") === ARCHIVED_VIEW_PARAM ? "archived" : "inbox";@@ -595,15 +602,17 @@ export function InboxPage() {// section's, which applies the same filters.const listedItems = opensAnyLiveRow ? sectionList.rows : selectionItems;const leaveRow = useInboxSelectionStore((s) => s.leaveRow);+ const recordLastCleared = useInboxSelectionStore((s) => s.recordLastCleared);// 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 advanceSelectionPast = (id: string, list: InboxItem[], cleared?: LastInboxCleared) => {const target = list.find((i) => i.id === id);const wasSelected = !!target && inboxRowKey(target) === selectedKey;if (!wasSelected) return;leaveRow(wsId, selectedKey);// Only clear the selection when nothing else is left.const next = nextInboxRow(list, selectedKey);+ if (!next && cleared) recordLastCleared(wsId, cleared);setSelectedKey(next ? inboxRowKey(next) : "");};// A batch archive that takes the open row moves on to the next one it leaves.@@ -614,19 +623,39 @@ export function InboxPage() {) => {const open = listedItems.find((i) => inboxRowKey(i) === selectedKey);const takesOpen = !!open && archives(open);+ const takenIds = takesOpen ? collectBatchArchiveIds(queryClient, wsId, archives) : [];void archiveBatchWithUndo(archive, archives, failed, takesOpen ? selectedKey : null);if (!takesOpen) return;leaveRow(wsId, selectedKey);const next = nextInboxRow(listedItems, selectedKey, archives);+ if (!next && takenIds.length > 0) {+ recordLastCleared(wsId, {+ kind: "batch_archived",+ count: takenIds.length,+ itemIds: takenIds,+ key: selectedKey,+ clearedAt: Date.now(),+ });+ }setSelectedKey(next ? inboxRowKey(next) : "");};// Toasts live in these shared handlers so every archive surface confirms alike.const handleArchive = (id: string) => {- advanceSelectionPast(id, listedItems);+ const target = listedItems.find((i) => i.id === id);+ const cleared: LastInboxCleared | undefined = target+ ? {+ kind: "archived",+ itemId: target.id,+ key: inboxRowKey(target),+ label: clearedLabelForItem(target),+ href: inboxRowHref(wsPaths, target),+ clearedAt: Date.now(),+ }+ : undefined;+ advanceSelectionPast(id, listedItems, cleared);// 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);};@@ -647,7 +676,15 @@ export function InboxPage() {settled: settledRow,next: settledRow ? nextInboxRow(listedItems, settledRow.key) : null,onNext: () => {- if (settledRow) advanceSelectionPast(settledRow.item.id, listedItems);+ if (!settledRow) return;+ advanceSelectionPast(settledRow.item.id, listedItems, {+ kind: "archived",+ itemId: settledRow.item.id,+ key: settledRow.key,+ label: clearedLabelForItem(settledRow.item),+ href: inboxRowHref(wsPaths, settledRow.item),+ clearedAt: Date.now(),+ });},});@@ -656,7 +693,16 @@ export function InboxPage() {const handleUnsubscribeArchive = (id: string, scope: InboxUnsubscribeScope = "issue") => {const item = listedItems.find((i) => i.id === id);if (!item?.issue_id) return;- advanceSelectionPast(id, listedItems);+ advanceSelectionPast(id, listedItems, {+ kind: "unsubscribed",+ itemId: item.id,+ issueId: item.issue_id,+ key: inboxRowKey(item),+ label: clearedLabelForItem(item),+ href: inboxRowHref(wsPaths, item),+ undoable: scope === "issue",+ clearedAt: Date.now(),+ });unsubscribeArchive({ id, issueId: item.issue_id }, scope);};@@ -1256,6 +1302,15 @@ export function InboxPage() {// The live list is the Inbox section of the Work panel beside this page, so// the page shows only the detail. The archive keeps its own list column.+ const handleClearFiltersAndContinue = () => {+ clearFilters(wsId);+ const first = items[0];+ if (!isCompact && first) {+ if (first.issue_id) useInboxSelectionStore.getState().rememberSidebarIssue(wsId, first.issue_id);+ push?.(inboxRowHref(wsPaths, first));+ }+ };+const emptyDetail = (<>{(!archiveSplit || listCollapsed) && (@@ -1268,24 +1323,17 @@ export function InboxPage() {{liveFailed ? (<div className="flex min-h-0 flex-1 flex-col justify-center">{liveLoadFailed}</div>) : (- <div className="relative flex min-h-0 flex-1 flex-col items-center justify-center overflow-hidden text-muted-foreground">- {inboxZeroCount === 0 ? (- <MulticaBleedMark- key={inboxZeroRises ? "rise" : "rest"}- enterDelay={inboxZeroRises ? 0.2 : undefined}- className="pointer-events-none absolute -right-[14%] -bottom-[26%] w-[min(560px,58%)] text-muted"- />- ) : (- <Inbox className="mb-3 h-10 w-10 text-faint-foreground" />- )}- <p className="relative text-body">- {visibleItems.length > 0- ? t(($) => $.detail.select_prompt)- : isArchivedView- ? t(($) => $.list.archived_empty)- : t(($) => $.detail.empty)}- </p>- </div>+ <InboxEmptyState+ wsId={wsId}+ isArchivedView={isArchivedView}+ visibleCount={visibleItems.length}+ totalActiveCount={items.length}+ hasActiveFilters={hasActiveFilters}+ inboxZeroRises={inboxZeroRises}+ isCompact={isCompact}+ onClearFiltersAndContinue={handleClearFiltersAndContinue}+ onViewArchived={() => setView("archived")}+ />)}</>);diff --git a/packages/views/inbox/components/use-inbox-snooze.ts b/packages/views/inbox/components/use-inbox-snooze.tsindex f2779c1f5b..13535d43e6 100644--- a/packages/views/inbox/components/use-inbox-snooze.ts+++ b/packages/views/inbox/components/use-inbox-snooze.ts@@ -32,7 +32,11 @@ export function useInboxSnooze() {const { mutateAsync: unsnoozeAsync } = useUnsnoozeInbox();const returnRow = useCallback(- (key: string) => useInboxSelectionStore.getState().returnRow(wsId, key),+ (key: string) => {+ const store = useInboxSelectionStore.getState();+ store.returnRow(wsId, key);+ store.clearLastCleared(wsId, key);+ },[wsId],);diff --git a/packages/views/inbox/components/use-leave-inbox-row.ts b/packages/views/inbox/components/use-leave-inbox-row.tsindex a1ac9b4dda..7b584c38f9 100644--- a/packages/views/inbox/components/use-leave-inbox-row.ts+++ b/packages/views/inbox/components/use-leave-inbox-row.ts@@ -1,27 +1,46 @@"use client";import { useCallback } from "react";-import { useQueryClient } from "@tanstack/react-query";+import { useQueryClient, type QueryClient } 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 { useInboxSelectionStore, type LastInboxCleared } 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";+import { getInboxDisplayTitle, inboxRowHref } from "./inbox-display";import { toastInboxUndo } from "./inbox-undo-toast";+/** Short label for the Inbox Zero undo line: issue identifier when present, else title. */+export function clearedLabelForItem(item: InboxItem): string {+ return item.issue_identifier || getInboxDisplayTitle(item);+}++/** Collect one notification ID per inbox row matched by a batch archive predicate. */+export function collectBatchArchiveIds(+ qc: QueryClient,+ wsId: string,+ archives: (item: InboxItem) => boolean,+): string[] {+ 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);+ }+ return [...taken.values()];+}+/*** 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.+ * archiving, snoozing or unsubscribing it from the issue Inbox bar, 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`).+ * When nothing is left to open, navigates to the Inbox page to show the+ * Inbox Zero (or filtered-empty) state, carrying the cleared entry for inline+ * undo.*/export function useLeaveInboxRow() {const wsId = useWorkspaceId();@@ -29,14 +48,20 @@ export function useLeaveInboxRow() {const { push } = useNavigation();const leaveRow = useInboxSelectionStore((s) => s.leaveRow);const rememberSidebarIssue = useInboxSelectionStore((s) => s.rememberSidebarIssue);+ const recordLastCleared = useInboxSelectionStore((s) => s.recordLastCleared);return useCallback(- (key: string, next: InboxItem | null) => {+ (key: string, next: InboxItem | null, cleared?: LastInboxCleared) => {leaveRow(wsId, key);- if (!next) return;+ if (!next) {+ rememberSidebarIssue(wsId, null);+ if (cleared) recordLastCleared(wsId, cleared);+ push(p.inbox());+ return;+ }rememberSidebarIssue(wsId, next.issue_id ?? null);push(inboxRowHref(p, next));},- [wsId, p, push, leaveRow, rememberSidebarIssue],+ [wsId, p, push, leaveRow, rememberSidebarIssue, recordLastCleared],);}@@ -59,7 +84,11 @@ export function useArchiveInboxWithUndo() {const restore = useRestoreInbox();return useCallback((id: string, key: string) => {- const returnRow = () => useInboxSelectionStore.getState().returnRow(wsId, key);+ const returnRow = () => {+ const store = useInboxSelectionStore.getState();+ store.returnRow(wsId, key);+ store.clearLastCleared(wsId, key);+ };return archiveAsync(id).then(() =>toastInboxUndo(t(($) => $.toasts.archived), {@@ -97,12 +126,13 @@ export function useArchiveInboxBatchWithUndo() {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 takenIds = collectBatchArchiveIds(qc, wsId, archives);const returnRow = () => {- if (openKey) useInboxSelectionStore.getState().returnRow(wsId, openKey);+ const store = useInboxSelectionStore.getState();+ if (openKey) store.returnRow(wsId, openKey);+ if (store.lastClearedByWorkspace[wsId]?.kind === "batch_archived") {+ store.clearLastCleared(wsId);+ }};return archive().then(({ count }) => {@@ -111,7 +141,7 @@ export function useArchiveInboxBatchWithUndo() {label: t(($) => $.toasts.undo),undo: () => {returnRow();- undoArchiveInboxBatch(qc, wsId, [...taken.values()]).catch((err: unknown) =>+ undoArchiveInboxBatch(qc, wsId, takenIds).catch((err: unknown) =>toast.error(errorMessage(err, t(($) => $.errors.unarchive_failed))),);},@@ -127,18 +157,24 @@ export function useArchiveInboxBatchWithUndo() {);}-/** Put an archived notification back in the Inbox. `quiet` skips the toast, for an undo. */+/**+ * Put an archived notification back in the Inbox. `quiet` skips the toast, for+ * an undo. Resolves whether it went back; a failure is already toasted.+ */export function useRestoreInbox() {const { t } = useT("inbox");const { mutateAsync: unarchiveAsync } = useUnarchiveInbox();return useCallback(- (id: string, { quiet = false }: { quiet?: boolean } = {}) =>+ (id: string, { quiet = false }: { quiet?: boolean } = {}): Promise<boolean> =>unarchiveAsync(id).then(() => {if (!quiet) toast.success(t(($) => $.toasts.unarchived));+ return true;+ },+ (err: unknown) => {+ toast.error(errorMessage(err, t(($) => $.errors.unarchive_failed)));+ return false;},- (err: unknown) =>- toast.error(errorMessage(err, t(($) => $.errors.unarchive_failed))),),[unarchiveAsync, t],);diff --git a/packages/views/inbox/components/use-move-on-after-auto-archive.test.tsx b/packages/views/inbox/components/use-move-on-after-auto-archive.test.tsxindex 66af1b1d5b..21c8942de9 100644--- a/packages/views/inbox/components/use-move-on-after-auto-archive.test.tsx+++ b/packages/views/inbox/components/use-move-on-after-auto-archive.test.tsx@@ -45,7 +45,11 @@ function item(id: string, issueId: string): InboxItem {const archived = (issueId: string): KeptInboxRow => ({ key: issueId, item: item(`n-${issueId}`, issueId), reason: "archived" });const nextRow = item("n-next", "issue-next");-function setup(preferences: Record<string, string>, initial: KeptInboxRow | null = null) {+function setup(+ preferences: Record<string, string>,+ initial: KeptInboxRow | null = null,+ next: InboxItem | null = nextRow,+) {const qc = new QueryClient({ defaultOptions: { queries: { retry: false, staleTime: Infinity } } });qc.setQueryData(notificationPreferenceKeys.all("ws"), { workspace_id: "ws", preferences });const resources = getTestResources();@@ -56,7 +60,7 @@ function setup(preferences: Record<string, string>, initial: KeptInboxRow | null);const onNext = vi.fn();const view = renderHook(- ({ settled }: { settled: KeptInboxRow | null }) => useMoveOnAfterAutoArchive({ settled, next: nextRow, onNext }),+ ({ settled }: { settled: KeptInboxRow | null }) => useMoveOnAfterAutoArchive({ settled, next, onNext }),{ wrapper, initialProps: { settled: initial } },);return {@@ -110,6 +114,14 @@ describe("useMoveOnAfterAutoArchive", () => {expect(onNext).not.toHaveBeenCalled();});+ it("moves on to Inbox Zero when the last notification auto-archives under after_auto_archive=next", () => {+ const { onNext, settle } = setup({ after_auto_archive: "next" }, null, null);+ noteInboxAutoArchive({ issue_id: "issue-last", reason: "actor_acted" });+ settle(archived("issue-last"));+ expect(onNext).toHaveBeenCalledTimes(1);+ expect(toast.success).toHaveBeenCalledWith("Notification archived", expect.anything());+ });+it("stays when the action happened in another window", () => {vi.mocked(document.hasFocus).mockReturnValue(false);const { onNext, settle } = setup({ after_auto_archive: "next" });diff --git a/packages/views/inbox/components/use-move-on-after-auto-archive.ts b/packages/views/inbox/components/use-move-on-after-auto-archive.tsindex 0c68fe2a2e..94afb87d9f 100644--- a/packages/views/inbox/components/use-move-on-after-auto-archive.ts+++ b/packages/views/inbox/components/use-move-on-after-auto-archive.ts@@ -52,17 +52,19 @@ export function useMoveOnAfterAutoArchive({// Before paint, so the settled bar never shows the plain archive first.useLayoutEffect(() => {if (!archivedKey) return;- const { settled: row, next: nextRow, onNext: moveOn, movesOn: moves } = latest.current;+ const { settled: row, onNext: moveOn, movesOn: moves } = latest.current;const own = takeInboxAutoArchive(archivedKey);const action = takeInboxBarAction(archivedKey);const shown = own && action && reflects(qc.getQueryData(issueDetailOptions(wsId, archivedKey).queryKey), action);setCause(shown ? { key: archivedKey, action } : null);- if (!own || !moves || !row || !nextRow || !document.hasFocus()) return;+ if (!own || !moves || !row || !document.hasFocus()) return;moveOn();toastInboxUndo(t(($) => $.toasts.archived), {label: t(($) => $.toasts.undo),undo: () => {- useInboxSelectionStore.getState().returnRow(wsId, archivedKey);+ const store = useInboxSelectionStore.getState();+ store.returnRow(wsId, archivedKey);+ store.clearLastCleared(wsId, archivedKey);void restore(row.item.id, { quiet: true });},});diff --git a/packages/views/inbox/components/use-unsubscribe-archive.ts b/packages/views/inbox/components/use-unsubscribe-archive.tsindex 33881c02b6..c463196fa2 100644--- a/packages/views/inbox/components/use-unsubscribe-archive.ts+++ b/packages/views/inbox/components/use-unsubscribe-archive.ts@@ -65,7 +65,11 @@ 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 returnRow = (issueId: string) => {+ const store = useInboxSelectionStore.getState();+ store.returnRow(wsId, issueId);+ store.clearLastCleared(wsId, issueId);+ };const { mutate } = useUnsubscribeArchiveInbox({onSuccess: ({ id, issueId, scope }) => {const description = t(($) => $.toasts.unsubscribed_hint);diff --git a/packages/views/issues/actions/__tests__/issue-inbox-actions.test.tsx b/packages/views/issues/actions/__tests__/issue-inbox-actions.test.tsxindex e1b82ee086..df35d60b4e 100644--- a/packages/views/issues/actions/__tests__/issue-inbox-actions.test.tsx+++ b/packages/views/issues/actions/__tests__/issue-inbox-actions.test.tsx@@ -28,6 +28,7 @@ const state = vi.hoisted(() => ({vi.mock("sonner", () => ({ toast: { success: vi.fn(), error: vi.fn(), dismiss: vi.fn() } }));vi.mock("@multica/core/hooks", () => ({ useWorkspaceId: () => "ws" }));+vi.mock("@multica/core/permissions", () => ({ useIsGuest: () => false }));vi.mock("@multica/core/paths", async (importOriginal) => {const actual = await importOriginal<typeof import("@multica/core/paths")>();return { ...actual, useWorkspacePaths: () => actual.paths.workspace("acme") };@@ -160,6 +161,7 @@ beforeEach(() => {sidebarTabIssuesByWorkspace: {},heldRows: {},leftRowKeyByWorkspace: {},+ lastClearedByWorkspace: {},});useInboxFilterStore.getState().clearFilters("ws");});@@ -176,8 +178,13 @@ describe("IssueInboxBar", () => {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();+ expect(nav.push).toHaveBeenCalledWith("/acme/inbox");+ expect(useInboxSelectionStore.getState().lastClearedByWorkspace.ws).toBeUndefined();+ // If the user returns to the issue (now still in Inbox), a later side-effect archive keeps it.+ act(() => {+ useInboxSelectionStore.getState().rememberSidebarIssue("ws", "issue-1");+ });act(() => nav.qc.setQueryData(inboxListOptions("ws").queryKey, []));expect(await screen.findByText("Notification archived")).toBeInTheDocument();expect(screen.getByRole("button", { name: "Undo" })).toBeInTheDocument();@@ -193,7 +200,11 @@ describe("IssueInboxBar", () => {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(useInboxSelectionStore.getState().lastClearedByWorkspace.ws).toBeUndefined();+ act(() => {+ useInboxSelectionStore.getState().rememberSidebarIssue("ws", "issue-1");+ nav.qc.setQueryData(inboxListOptions("ws").queryKey, [ROWS[0]!]);+ });expect(await screen.findByRole("button", { name: "Archive" })).toBeInTheDocument();act(() => nav.qc.setQueryData(inboxListOptions("ws").queryKey, []));@@ -427,13 +438,51 @@ describe("IssueInboxBar", () => {expect(toast.success).not.toHaveBeenCalled();});- it("stays on the issue when it was the last notification", async () => {- const nav = setup({ rows: [ROWS[0]!] });+ it("moves to Inbox Zero and records undo context when archiving the last notification", async () => {+ const nav = setup({ rows: [{ ...ROWS[0]!, issue_identifier: "MUL-9790" }] });fireEvent.click(screen.getByRole("button", { name: "Archive" }));- expect(nav.push).not.toHaveBeenCalled();+ expect(nav.push).toHaveBeenCalledWith("/acme/inbox");+ expect(useInboxSelectionStore.getState().lastClearedByWorkspace.ws).toMatchObject({+ kind: "archived",+ itemId: "n-1",+ key: "issue-1",+ label: "MUL-9790",+ });await waitFor(() => expect(state.archiveInbox).toHaveBeenCalledWith("n-1"));});+ it("shows an Inbox cleared bar with My work and moves to Inbox Zero on E when the last row auto-archives in place", async () => {+ const until = new Date(Date.now() + 2 * 60 * 60 * 1000).toISOString();+ const nav = setup({+ rows: [{ ...ROWS[0]!, issue_identifier: "MUL-9790" }],+ snoozed: [{ issue_id: "issue-9", item_id: "n-9", snoozed_until: until, snoozed_at: SNOOZED_AT, updates: 0 }],+ });+ act(() => nav.qc.setQueryData(inboxListOptions("ws").queryKey, []));++ expect(await screen.findByText("Inbox cleared")).toBeInTheDocument();+ expect(screen.getByText("Notification archived")).toBeInTheDocument();+ expect(screen.getByRole("button", { name: "1 snoozed" })).toBeInTheDocument();+ expect(screen.getByRole("button", { name: "Go to My work" })).toBeInTheDocument();++ fireEvent.keyDown(document, { key: "e", code: "KeyE" });+ expect(nav.push).toHaveBeenCalledWith("/acme/inbox");+ expect(useInboxSelectionStore.getState().lastClearedByWorkspace.ws).toMatchObject({+ kind: "archived",+ itemId: "n-1",+ label: "MUL-9790",+ });+ });++ it("does not show Inbox cleared on the settled bar when filters are active", async () => {+ useInboxFilterStore.getState().toggleUnreadOnly("ws");+ const nav = setup({ rows: [{ ...ROWS[0]!, read: false }] });+ act(() => nav.qc.setQueryData(inboxListOptions("ws").queryKey, []));++ expect(await screen.findByText("Notification archived")).toBeInTheDocument();+ expect(screen.queryByText("Inbox cleared")).toBeNull();+ expect(screen.queryByRole("button", { name: "Go to My work" })).toBeNull();+ });+it("moves on to the next notification the Work panel lists under its filters", () => {useInboxFilterStore.getState().toggleUnreadOnly("ws");const nav = setup({@@ -509,9 +558,10 @@ describe("IssueInboxBar once an action is undone", () => {const nav = setup({ rows });fireEvent.click(screen.getByRole("button", { name: "Archive" }));await waitFor(() => expect(toast.success).toHaveBeenCalled());- expect(nav.push).not.toHaveBeenCalled();+ expect(nav.push).toHaveBeenCalledWith("/acme/inbox");const undo = vi.mocked(toast.success).mock.calls.at(-1)?.[1] as unknown as { action: { onClick: () => void } };await act(async () => undo.action.onClick());+ act(() => useInboxSelectionStore.getState().rememberSidebarIssue("ws", "issue-1"));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, []));diff --git a/packages/views/issues/actions/issue-inbox-actions.tsx b/packages/views/issues/actions/issue-inbox-actions.tsxindex c360eb6e7a..5a178a0dd6 100644--- a/packages/views/issues/actions/issue-inbox-actions.tsx+++ b/packages/views/issues/actions/issue-inbox-actions.tsx@@ -1,15 +1,18 @@"use client";-import { type ReactNode, useEffect, useRef, useState } from "react";+import { useMemo, type ReactNode, useEffect, useRef, useState } from "react";import { useQuery } from "@tanstack/react-query";import { AlarmClock, ChevronDown } from "@multica/ui/icons";import { Button } from "@multica/ui/components/ui/button";import { useWorkspaceId } from "@multica/core/hooks";import { useModalStore } from "@multica/core/modals";import type { InboxUnsubscribeScope } from "@multica/core/inbox/mutations";+import type { LastInboxCleared } from "@multica/core/inbox/selection-store";import type { InboxItem } from "@multica/core/types";import { findSnoozedInboxIssue, snoozedInboxOptions } from "@multica/core/inbox/queries";import { nextInboxRow } from "@multica/core/inbox/open-row";+import { useWorkspacePaths } from "@multica/core/paths";+import { useIsGuest } from "@multica/core/permissions";import {getShortcut,isEditableShortcutTarget,@@ -18,6 +21,7 @@ import {} from "@multica/core/shortcuts";import { isImeComposing } from "@multica/core/utils";import { InboxArchiveButton, InboxBar, InboxBarButton, InboxBarStatus, InboxOpenBar } from "../../inbox/components/inbox-bar";+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";@@ -28,10 +32,13 @@ import { UnsubscribeArchiveButton } from "../../inbox/components/unsubscribe-arcimport { useUnsubscribeArchive } from "../../inbox/components/use-unsubscribe-archive";import { useMoveOnAfterAutoArchive } from "../../inbox/components/use-move-on-after-auto-archive";import {+ clearedLabelForItem,useArchiveInboxWithUndo,useLeaveInboxRow,useRestoreInbox,} from "../../inbox/components/use-leave-inbox-row";+import { useBuiltinViewNavigation } from "../../issue-views/builtin-views";+import { useNavigation } from "../../navigation";import { useLocale, useT } from "../../i18n";/**@@ -52,8 +59,12 @@ import { useLocale, useT } from "../../i18n";export function IssueInboxBar({ issueId, issueActions }: { issueId: string; issueActions?: ReactNode }) {const { t } = useT("inbox");const wsId = useWorkspaceId();+ const p = useWorkspacePaths();+ const { push } = useNavigation();+ const builtinNav = useBuiltinViewNavigation();+ const guest = useIsGuest(wsId);const { fromInbox } = useSidebarInboxIssue(wsId, issueId);- const { rows, kept } = useFilteredInboxRows(wsId, issueId, fromInbox);+ const { rows, kept, filtered } = useFilteredInboxRows(wsId, issueId, fromInbox);const index = fromInbox ? rows.findIndex((row) => row.issue_id === issueId) : -1;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.@@ -67,35 +78,87 @@ export function IssueInboxBar({ issueId, issueActions }: { issueId: string; issuconst { snooze, unsnooze } = useInboxSnooze();const { data: snoozedList } = useQuery(snoozedInboxOptions(wsId));const snoozed = item ? undefined : findSnoozedInboxIssue(snoozedList, issueId);+ const activeSnoozedCount = useMemo(() => {+ const now = Date.now();+ return (snoozedList ?? []).filter((entry) => new Date(entry.snoozed_until).getTime() > now).length;+ }, [snoozedList]);const keptText = useKeptInboxRowText(wsId);const [snoozeOpen, setSnoozeOpen] = useState(false);const archiveItem = () => {if (!item) return;archiveWithUndo(item.id, issueId);- leave(issueId, next);+ leave(issueId, next, {+ kind: "archived",+ itemId: item.id,+ key: issueId,+ label: clearedLabelForItem(item),+ href: inboxRowHref(p, item),+ clearedAt: Date.now(),+ });};const unsubscribeItem = (scope: InboxUnsubscribeScope) => {if (!item?.issue_id) return;unsubscribeArchive({ id: item.id, issueId: item.issue_id }, scope);- leave(issueId, next);+ leave(issueId, next, {+ kind: "unsubscribed",+ itemId: item.id,+ issueId: item.issue_id,+ key: issueId,+ label: clearedLabelForItem(item),+ href: inboxRowHref(p, item),+ undoable: scope === "issue",+ clearedAt: Date.now(),+ });};const snoozeItem = (until: Date) => {if (!item) return;snooze(item, until);- leave(issueId, next);+ leave(issueId, next, {+ kind: "snoozed",+ itemId: item.id,+ key: issueId,+ label: clearedLabelForItem(item),+ href: inboxRowHref(p, item),+ until: until.toISOString(),+ wasRead: item.read === true,+ clearedAt: Date.now(),+ });};- const moveOn = () => leave(issueId, next);+ const moveOn = () => {+ const cleared: LastInboxCleared | undefined = settled+ ? settled.reason === "snoozed" && settled.item.snoozed_until+ ? {+ kind: "snoozed",+ itemId: settled.item.id,+ key: issueId,+ label: clearedLabelForItem(settled.item),+ href: inboxRowHref(p, settled.item),+ until: settled.item.snoozed_until,+ wasRead: settled.item.read === true,+ clearedAt: Date.now(),+ }+ : {+ kind: "archived",+ itemId: settled.item.id,+ key: issueId,+ label: clearedLabelForItem(settled.item),+ href: inboxRowHref(p, settled.item),+ clearedAt: Date.now(),+ }+ : undefined;+ leave(issueId, next, cleared);+ };const cause = useMoveOnAfterAutoArchive({ settled, next, onNext: moveOn });const archiveRef = useRef<(() => void) | null>(null);const snoozeRef = useRef<(() => void) | null>(null);useEffect(() => {- // Archived already, E moves on as archiving would have.- archiveRef.current = item ? archiveItem : settled && next ? moveOn : null;+ // Archived already, E moves on (to the next notification or Inbox Zero).+ archiveRef.current = item ? archiveItem : settled ? moveOn : null;snoozeRef.current = item? () => setSnoozeOpen(true): snoozed@@ -136,6 +199,7 @@ export function IssueInboxBar({ issueId, issueActions }: { issueId: string; issu);}if (!settled) return null;+ const inboxCleared = !next && !filtered;return (<InboxKeptActionslabel={keptText.notice(settled, cause)}@@ -143,6 +207,24 @@ export function IssueInboxBar({ issueId, issueActions }: { issueId: string; issuonUndo={() => restore(settled.item.id, { quiet: true })}next={next}onNext={moveOn}+ inboxCleared={inboxCleared}+ snoozedCount={inboxCleared ? activeSnoozedCount : 0}+ onSnoozedClick={+ inboxCleared+ ? () => {+ builtinNav.prepare("snoozed");+ push(builtinNav.hrefFor("snoozed"));+ }+ : undefined+ }+ onGoToMyWork={+ inboxCleared && !guest+ ? () => {+ builtinNav.prepare("my_work");+ push(builtinNav.hrefFor("my_work"));+ }+ : undefined+ }/>);}diff --git a/packages/views/layout/panels/inbox-section.test.tsx b/packages/views/layout/panels/inbox-section.test.tsxindex 3c85bffa1b..dbc85a14ba 100644--- a/packages/views/layout/panels/inbox-section.test.tsx+++ b/packages/views/layout/panels/inbox-section.test.tsx@@ -560,13 +560,18 @@ describe("InboxSection", () => {expect(nav.push).toHaveBeenCalledWith("/acme/issues/issue-c");});- it("keeps the issue open with nothing lit once a bulk archive takes every row", async () => {+ it("moves to Inbox Zero 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(nav.push).toHaveBeenCalledWith("/acme/inbox");expect(useInboxSelectionStore.getState().leftRowKeyByWorkspace["ws-1"]).toBe("issue-a");+ expect(useInboxSelectionStore.getState().lastClearedByWorkspace["ws-1"]).toMatchObject({+ kind: "batch_archived",+ count: 1,+ itemIds: ["n1"],+ });});it("keeps a bulk archive that spares the open row from moving it", async () => {diff --git a/packages/views/layout/panels/inbox-section.tsx b/packages/views/layout/panels/inbox-section.tsxindex bd2925cd2e..aeb41ef805 100644--- a/packages/views/layout/panels/inbox-section.tsx+++ b/packages/views/layout/panels/inbox-section.tsx@@ -2,7 +2,7 @@import { memo, type ReactNode, type Ref, useLayoutEffect, useMemo, useRef, useState } from "react";import { useVirtualizer } from "@tanstack/react-virtual";-import { useQuery } from "@tanstack/react-query";+import { useQuery, useQueryClient } from "@tanstack/react-query";import { toast } from "sonner";import { AlarmClock, Archive, BellOff, BookCheck, CheckCheck, History, ListChecks, MoreHorizontal } from "@multica/ui/icons";import { IconButton } from "@multica/ui/components/common/icon-button";@@ -33,7 +33,7 @@ import { inboxRowTime, inboxSnoozeReturnedAt } from "@multica/core/inbox/snooze"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 { useInboxSelectionStore, type LastInboxCleared } 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";@@ -53,6 +53,8 @@ import { useInboxIssuePrefetch } from "../../inbox/components/use-inbox-issue-primport { useTimeAgo } from "../../inbox/components/inbox-list-item";import { useInboxUnsubscribable, useUnsubscribeArchive } from "../../inbox/components/use-unsubscribe-archive";import {+ clearedLabelForItem,+ collectBatchArchiveIds,useArchiveInboxBatchWithUndo,useArchiveInboxWithUndo,useLeaveInboxRow,@@ -164,9 +166,9 @@ export function InboxSection({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 leaveIfOpen = (item: InboxItem, cleared: LastInboxCleared) => {const key = inboxRowKey(item);- if (key === openRowKey) leave(key, nextInboxRow(all, key));+ if (key === openRowKey) leave(key, nextInboxRow(all, key), cleared);};const prefetchRow = useInboxIssuePrefetch(wsId, collapsed ? [] : displayed, (item) => inboxRowHref(p, item));// What arrived on each issue while it was snoozed, for the rows back from one.@@ -187,16 +189,44 @@ export function InboxSection({const latest = {prefetch: (item: InboxItem) => void prefetchRow(item),archive: (item: InboxItem) => {- archive(item.id, inboxRowKey(item));- leaveIfOpen(item);+ const key = inboxRowKey(item);+ archive(item.id, key);+ leaveIfOpen(item, {+ kind: "archived",+ itemId: item.id,+ key,+ label: clearedLabelForItem(item),+ href: inboxRowHref(p, item),+ clearedAt: Date.now(),+ });},unsubscribe: (item: InboxItem) => {+ const key = inboxRowKey(item);unsubscribeArchive({ id: item.id, issueId: item.issue_id! });- leaveIfOpen(item);+ leaveIfOpen(item, {+ kind: "unsubscribed",+ itemId: item.id,+ issueId: item.issue_id!,+ key,+ label: clearedLabelForItem(item),+ href: inboxRowHref(p, item),+ undoable: true,+ clearedAt: Date.now(),+ });},snooze: (item: InboxItem, until: Date) => {+ const key = inboxRowKey(item);snooze(item, until);- leaveIfOpen(item);+ leaveIfOpen(item, {+ kind: "snoozed",+ itemId: item.id,+ key,+ label: clearedLabelForItem(item),+ href: inboxRowHref(p, item),+ until: until.toISOString(),+ wasRead: item.read === true,+ clearedAt: Date.now(),+ });},};const latestRef = useRef(latest);@@ -431,6 +461,7 @@ function InboxSectionActions({}) {const { t } = useT("layout");const { t: tInbox } = useT("inbox");+ const qc = useQueryClient();const leave = useLeaveInboxRow();const archiveWithUndo = useArchiveInboxBatchWithUndo();const { categoryOf } = useIssueStatuses(wsId);@@ -443,8 +474,23 @@ function InboxSectionActions({) => {const open = openRowKey ? rows.find((item) => inboxRowKey(item) === openRowKey) : undefined;const takesOpen = !!open && archives(open);+ const takenIds = takesOpen ? collectBatchArchiveIds(qc, wsId, archives) : [];void archiveWithUndo(archive, archives, failed, takesOpen ? openRowKey : null);- if (takesOpen) leave(openRowKey!, nextInboxRow(rows, openRowKey!, archives));+ if (takesOpen) {+ leave(+ openRowKey!,+ nextInboxRow(rows, openRowKey!, archives),+ takenIds.length > 0+ ? {+ kind: "batch_archived",+ count: takenIds.length,+ itemIds: takenIds,+ key: openRowKey,+ clearedAt: Date.now(),+ }+ : undefined,+ );+ }};const isRead = (item: InboxItem) => item.read === true;const isFinished = (item: InboxItem) => {diff --git a/packages/views/layout/panels/work-panel.test.tsx b/packages/views/layout/panels/work-panel.test.tsxindex 32fec39dc9..9cad58d23c 100644--- a/packages/views/layout/panels/work-panel.test.tsx+++ b/packages/views/layout/panels/work-panel.test.tsx@@ -870,3 +870,27 @@ describe("WorkPanel and the open issue's project", () => {await waitFor(() => expect(useSidebarTreeStore.getState().locate).toBeNull());});});++describe("KeptRowsRelease Inbox Zero undo", () => {+ const cleared = () => useInboxSelectionStore.getState().lastClearedByWorkspace["ws-1"];+ const recordCleared = () =>+ useInboxSelectionStore.getState().recordLastCleared("ws-1", {+ kind: "archived",+ itemId: `inbox-${ISSUE.id}`,+ key: ISSUE.id,+ label: ISSUE.identifier,+ href: `/acme/issues/${ISSUE.identifier}`,+ clearedAt: 1,+ });++ beforeEach(() => useInboxSelectionStore.setState({ lastClearedByWorkspace: {} }));++ it("forgets it once the Inbox is left, even for the issue it cleared", () => {+ recordCleared();+ renderPanel("/acme/inbox");+ expect(cleared()).toBeDefined();++ fireEvent.click(screen.getByRole("button", { name: "Return to issue" }));+ expect(cleared()).toBeUndefined();+ });+});diff --git a/packages/views/layout/panels/work-panel.tsx b/packages/views/layout/panels/work-panel.tsxindex cc3e48a2b6..ae26eaaff1 100644--- a/packages/views/layout/panels/work-panel.tsx+++ b/packages/views/layout/panels/work-panel.tsx@@ -1,6 +1,6 @@"use client";-import { useEffect, useLayoutEffect, useMemo, useState } from "react";+import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";import { useQuery } from "@tanstack/react-query";import { useAuthStore } from "@multica/core/auth";import { useCurrentWorkspace, useWorkspacePaths } from "@multica/core/paths";@@ -67,12 +67,24 @@ export function KeptRowsRelease() {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;+ const onInbox = pathname === p.inbox();+ const inboxKey = onInbox ? searchParams.get("issue") : null;+ const wasOnInbox = useRef(false);useLayoutEffect(() => {if (issueId === undefined) return;useSidebarKeptStore.getState().release([issueId, projectId].filter((id) => id !== null));- if (wsId) useInboxSelectionStore.getState().releaseRows(wsId, [issueId, inboxKey].filter((id) => id !== null));- }, [wsId, issueId, projectId, inboxKey]);+ if (wsId) {+ const store = useInboxSelectionStore.getState();+ store.releaseRows(wsId, [issueId, inboxKey].filter((id) => id !== null));+ // Keep the Inbox Zero undo context only while on /inbox, or while the+ // just-cleared issue is still handing off its navigation to /inbox.+ const lastCleared = store.lastClearedByWorkspace[wsId];+ if (lastCleared && !onInbox && (wasOnInbox.current || issueId !== lastCleared.key)) {+ store.clearLastCleared(wsId);+ }+ }+ wasOnInbox.current = onInbox;+ }, [wsId, issueId, projectId, inboxKey, onInbox]);return null;}diff --git a/packages/views/locales/en/inbox.json b/packages/views/locales/en/inbox.jsonindex 48bb4a595a..c9c9ff3c97 100644--- a/packages/views/locales/en/inbox.json+++ b/packages/views/locales/en/inbox.json@@ -231,5 +231,28 @@},"hint": "You can change this in Settings › Notifications","confirm": "Done"+ },+ "zero": {+ "cleared_title": "Inbox cleared",+ "just_archived": "Just archived {{label}}",+ "just_snoozed": "Snoozed {{label}} until {{time}}",+ "just_unsubscribed": "Unsubscribed from {{label}}",+ "just_archived_many_one": "Archived {{count}} notification",+ "just_archived_many_other": "Archived {{count}} notifications",+ "snoozed_summary_one": "{{count}} snoozed · returns {{time}}",+ "snoozed_summary_other": "{{count}} snoozed · next returns {{time}}",+ "bar_snoozed_one": "{{count}} snoozed",+ "bar_snoozed_other": "{{count}} snoozed",+ "my_work": "My work",+ "go_to_my_work": "Go to My work",+ "agents_working_one": "{{count}} agent working",+ "agents_working_other": "{{count}} agents working",+ "view_archived": "View archived",+ "quick_jump": "Quick jump",+ "filtered_title": "All caught up for this filter",+ "filtered_remaining_one": "{{count}} other notification in your inbox",+ "filtered_remaining_other": "{{count}} other notifications in your inbox",+ "clear_and_continue": "Clear filters and continue",+ "undo_item": "Undo {{label}}"}}diff --git a/packages/views/locales/es/inbox.json b/packages/views/locales/es/inbox.jsonindex 4b712e1cc0..1ee115ed1e 100644--- a/packages/views/locales/es/inbox.json+++ b/packages/views/locales/es/inbox.json@@ -231,5 +231,28 @@},"hint": "Puedes cambiarlo en Ajustes › Notificaciones","confirm": "Listo"+ },+ "zero": {+ "cleared_title": "Bandeja de entrada vacía",+ "just_archived": "Se archivó {{label}}",+ "just_snoozed": "{{label}} pospuesto hasta {{time}}",+ "just_unsubscribed": "Suscripción cancelada y archivado: {{label}}",+ "just_archived_many_one": "Se archivó {{count}} notificación",+ "just_archived_many_other": "Se archivaron {{count}} notificaciones",+ "snoozed_summary_one": "{{count}} pospuesta · vuelve {{time}}",+ "snoozed_summary_other": "{{count}} pospuestas · la próxima vuelve {{time}}",+ "bar_snoozed_one": "{{count}} pospuesta",+ "bar_snoozed_other": "{{count}} pospuestas",+ "my_work": "Mi trabajo",+ "go_to_my_work": "Ir a Mi trabajo",+ "agents_working_one": "{{count}} agente trabajando",+ "agents_working_other": "{{count}} agentes trabajando",+ "view_archived": "Ver archivadas",+ "quick_jump": "Ir rápido",+ "filtered_title": "Todo al día para este filtro",+ "filtered_remaining_one": "Hay {{count}} otra notificación en tu bandeja",+ "filtered_remaining_other": "Hay {{count}} otras notificaciones en tu bandeja",+ "clear_and_continue": "Limpiar filtros y continuar",+ "undo_item": "Deshacer {{label}}"}}diff --git a/packages/views/locales/fr/inbox.json b/packages/views/locales/fr/inbox.jsonindex 895d0bb179..641914ab1a 100644--- a/packages/views/locales/fr/inbox.json+++ b/packages/views/locales/fr/inbox.json@@ -231,5 +231,28 @@},"hint": "Modifiable dans Paramètres › Notifications","confirm": "Terminé"+ },+ "zero": {+ "cleared_title": "Boîte de réception vide",+ "just_archived": "{{label}} archivé",+ "just_snoozed": "{{label}} reporté jusqu’au {{time}}",+ "just_unsubscribed": "Désabonné et archivé : {{label}}",+ "just_archived_many_one": "{{count}} notification archivée",+ "just_archived_many_other": "{{count}} notifications archivées",+ "snoozed_summary_one": "{{count}} reportée · retour {{time}}",+ "snoozed_summary_other": "{{count}} reportées · prochain retour {{time}}",+ "bar_snoozed_one": "{{count}} reportée",+ "bar_snoozed_other": "{{count}} reportées",+ "my_work": "Mon travail",+ "go_to_my_work": "Aller à Mon travail",+ "agents_working_one": "{{count}} agent en cours",+ "agents_working_other": "{{count}} agents en cours",+ "view_archived": "Voir les archives",+ "quick_jump": "Accès rapide",+ "filtered_title": "Tout est traité pour ce filtre",+ "filtered_remaining_one": "{{count}} autre notification dans votre boîte de réception",+ "filtered_remaining_other": "{{count}} autres notifications dans votre boîte de réception",+ "clear_and_continue": "Effacer les filtres et continuer",+ "undo_item": "Annuler {{label}}"}}diff --git a/packages/views/locales/ja/inbox.json b/packages/views/locales/ja/inbox.jsonindex 6255b2b7f7..eac8e2887d 100644--- a/packages/views/locales/ja/inbox.json+++ b/packages/views/locales/ja/inbox.json@@ -226,5 +226,23 @@},"hint": "あとから 設定 › 通知 で変更できます","confirm": "完了"+ },+ "zero": {+ "cleared_title": "インボックスは空です",+ "just_archived": "{{label}} をアーカイブしました",+ "just_snoozed": "{{label}} を {{time}} までスヌーズしました",+ "just_unsubscribed": "{{label}} の購読を解除してアーカイブしました",+ "just_archived_many_other": "{{count}} 件の通知をアーカイブしました",+ "snoozed_summary_other": "スヌーズ中 {{count}} 件 · 最短 {{time}} に復帰",+ "bar_snoozed_other": "スヌーズ中 {{count}} 件",+ "my_work": "自分の作業",+ "go_to_my_work": "自分の作業へ",+ "agents_working_other": "{{count}} 体のエージェントが稼働中",+ "view_archived": "アーカイブを見る",+ "quick_jump": "クイック移動",+ "filtered_title": "このフィルターの通知はすべて処理済みです",+ "filtered_remaining_other": "インボックスに他の通知が {{count}} 件あります",+ "clear_and_continue": "フィルターを解除して続ける",+ "undo_item": "{{label}} を元に戻す"}}diff --git a/packages/views/locales/ko/inbox.json b/packages/views/locales/ko/inbox.jsonindex 97666646f7..bfb7d65c24 100644--- a/packages/views/locales/ko/inbox.json+++ b/packages/views/locales/ko/inbox.json@@ -226,5 +226,23 @@},"hint": "나중에 설정 › 알림에서 바꿀 수 있습니다","confirm": "완료"+ },+ "zero": {+ "cleared_title": "인박스가 비었습니다",+ "just_archived": "{{label}} 알림을 보관했습니다",+ "just_snoozed": "{{label}} 알림을 {{time}}까지 미뤘습니다",+ "just_unsubscribed": "{{label}} 구독을 취소하고 보관했습니다",+ "just_archived_many_other": "알림 {{count}}개를 보관했습니다",+ "snoozed_summary_other": "미룬 알림 {{count}}개 · 가장 빠른 복귀 {{time}}",+ "bar_snoozed_other": "미룸 {{count}}개",+ "my_work": "내 작업",+ "go_to_my_work": "내 작업으로 이동",+ "agents_working_other": "에이전트 {{count}}개 작업 중",+ "view_archived": "보관함 보기",+ "quick_jump": "빠른 이동",+ "filtered_title": "현재 필터의 알림을 모두 처리했습니다",+ "filtered_remaining_other": "인박스에 다른 알림 {{count}}개가 남아 있습니다",+ "clear_and_continue": "필터 지우고 계속하기",+ "undo_item": "{{label}} 실행 취소"}}diff --git a/packages/views/locales/ru/inbox.json b/packages/views/locales/ru/inbox.jsonindex 410967829b..500467ece3 100644--- a/packages/views/locales/ru/inbox.json+++ b/packages/views/locales/ru/inbox.json@@ -241,5 +241,38 @@},"hint": "Это можно изменить в Настройки › Уведомления","confirm": "Готово"+ },+ "zero": {+ "cleared_title": "Входящие разобраны",+ "just_archived": "В архиве: {{label}}",+ "just_snoozed": "{{label}} отложено до {{time}}",+ "just_unsubscribed": "Подписка отменена и в архиве: {{label}}",+ "just_archived_many_one": "В архиве {{count}} уведомление",+ "just_archived_many_few": "В архиве {{count}} уведомления",+ "just_archived_many_many": "В архиве {{count}} уведомлений",+ "just_archived_many_other": "В архиве {{count}} уведомлений",+ "snoozed_summary_one": "Отложено {{count}} · вернётся {{time}}",+ "snoozed_summary_few": "Отложено {{count}} · ближайшее вернётся {{time}}",+ "snoozed_summary_many": "Отложено {{count}} · ближайшее вернётся {{time}}",+ "snoozed_summary_other": "Отложено {{count}} · ближайшее вернётся {{time}}",+ "bar_snoozed_one": "{{count}} отложено",+ "bar_snoozed_few": "{{count}} отложено",+ "bar_snoozed_many": "{{count}} отложено",+ "bar_snoozed_other": "{{count}} отложено",+ "my_work": "Моя работа",+ "go_to_my_work": "Перейти к «Моей работе»",+ "agents_working_one": "Работает {{count}} агент",+ "agents_working_few": "Работают {{count}} агента",+ "agents_working_many": "Работают {{count}} агентов",+ "agents_working_other": "Работают {{count}} агентов",+ "view_archived": "Открыть архив",+ "quick_jump": "Быстрый переход",+ "filtered_title": "По этому фильтру всё разобрано",+ "filtered_remaining_one": "Во входящих осталось ещё {{count}} уведомление",+ "filtered_remaining_few": "Во входящих осталось ещё {{count}} уведомления",+ "filtered_remaining_many": "Во входящих осталось ещё {{count}} уведомлений",+ "filtered_remaining_other": "Во входящих осталось ещё {{count}} уведомлений",+ "clear_and_continue": "Сбросить фильтры и продолжить",+ "undo_item": "Отменить {{label}}"}}diff --git a/packages/views/locales/zh-Hans/inbox.json b/packages/views/locales/zh-Hans/inbox.jsonindex a1cc64bda6..9e53f4015e 100644--- a/packages/views/locales/zh-Hans/inbox.json+++ b/packages/views/locales/zh-Hans/inbox.json@@ -226,5 +226,23 @@},"hint": "之后可以在 设置 › 通知 里修改","confirm": "确定"+ },+ "zero": {+ "cleared_title": "收件箱已清空",+ "just_archived": "刚归档了 {{label}}",+ "just_snoozed": "已将 {{label}} 延后至 {{time}}",+ "just_unsubscribed": "已取消订阅并归档 {{label}}",+ "just_archived_many_other": "已归档 {{count}} 条通知",+ "snoozed_summary_other": "{{count}} 条延后通知 · 最早 {{time}} 回来",+ "bar_snoozed_other": "{{count}} 条已延后",+ "my_work": "我的工作",+ "go_to_my_work": "前往我的工作",+ "agents_working_other": "{{count}} 个智能体正在工作",+ "view_archived": "查看已归档",+ "quick_jump": "快速跳转",+ "filtered_title": "当前筛选下的通知已处理完",+ "filtered_remaining_other": "收件箱里还有 {{count}} 条其他通知待处理",+ "clear_and_continue": "清除筛选,继续处理",+ "undo_item": "撤销 {{label}}"}}diff --git a/packages/views/locales/zh-Hant/inbox.json b/packages/views/locales/zh-Hant/inbox.jsonindex 9291982dad..b55693a539 100644--- a/packages/views/locales/zh-Hant/inbox.json+++ b/packages/views/locales/zh-Hant/inbox.json@@ -226,5 +226,23 @@},"hint": "之後可以在 設定 › 通知 裡修改","confirm": "確定"+ },+ "zero": {+ "cleared_title": "收件箱已清空",+ "just_archived": "剛歸檔了 {{label}}",+ "just_snoozed": "已將 {{label}} 延後至 {{time}}",+ "just_unsubscribed": "已取消訂閱並歸檔 {{label}}",+ "just_archived_many_other": "已歸檔 {{count}} 則通知",+ "snoozed_summary_other": "{{count}} 則延後通知 · 最早 {{time}} 回來",+ "bar_snoozed_other": "{{count}} 則已延後",+ "my_work": "我的工作",+ "go_to_my_work": "前往我的工作",+ "agents_working_other": "{{count}} 個智能體正在工作",+ "view_archived": "查看已歸檔",+ "quick_jump": "快速跳轉",+ "filtered_title": "目前篩選下的通知已處理完",+ "filtered_remaining_other": "收件箱裡還有 {{count}} 則其他通知待處理",+ "clear_and_continue": "清除篩選,繼續處理",+ "undo_item": "復原 {{label}}"}}