Skip to content

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

Go

fix(inbox): keep the Work panel's Inbox tabs readable at the default width (MUL-9926) (#11268)

Jiayuan Zhang409155a995b7
diff --git a/apps/docs/content/docs/inbox.fr.mdx b/apps/docs/content/docs/inbox.fr.mdx
index a7b065872d..c64315eb27 100644
--- a/apps/docs/content/docs/inbox.fr.mdx
+++ b/apps/docs/content/docs/inbox.fr.mdx
@@ -10,7 +10,7 @@ La boîte de réception rassemble l'activité de travail qui vous concerne et si
## Où la trouver
-La boîte de réception est une section du panneau **Travail**, sous les épingles et au-dessus des vues et des projets ; sans épingle, c'est la première section. Son en-tête porte trois onglets : **Boîte de réception**, **Reportés** et **Archivées**. Le nombre de non-lus s'affiche à côté de **Boîte de réception** et en badge sur **Travail** dans la barre d'applications ; un clic droit sur **Travail** propose **Tout marquer comme lu**.
+La boîte de réception est une section du panneau **Travail**, sous les épingles et au-dessus des vues et des projets ; sans épingle, c'est la première section. Son en-tête porte trois onglets : **Boîte de réception**, **Reportés** et **Archivées**. Seul l'onglet ouvert affiche son nom ; les deux autres sont des icônes, nommées au survol. Sélectionner à nouveau l'onglet ouvert replie la section. Le nombre de non-lus s'affiche à côté de **Boîte de réception** et en badge sur **Travail** dans la barre d'applications ; un clic droit sur **Travail** propose **Tout marquer comme lu**.
L'onglet **Boîte de réception** affiche une ligne par tâche, de la plus récente à la plus ancienne, lues et non lues confondues. Une ligne montre le statut de la tâche, son titre et l'heure, et qui a fait quoi sur une deuxième ligne ; un point signale une ligne non lue. Activez **Lignes compactes** dans les réglages d'affichage pour garder chaque ligne sur une seule ligne. Survolez une ligne pour ouvrir une carte avec le titre complet, le commentaire, et **Ouvrir**, **Marquer comme lu** et **Archiver**.
@@ -149,7 +149,7 @@ Une notification ultérieure sur la tâche revient dans la boîte de réception.
## Affichage et types de notification
-Le bouton de réglages dans l'en-tête de la section Boîte de réception ouvre ses réglages d'affichage, enregistrés sur cet appareil :
+**Affichage de la boîte de réception**, dans le menu ⋯ de l'en-tête de la section (présent sur chaque onglet), ouvre ses réglages d'affichage, enregistrés sur cet appareil :
- **Lignes affichées** : 5, 10 ou 20 ; une ligne « Afficher N de plus » donne accès au reste.
- **Lignes compactes** : une seule ligne par notification, sans qui a fait quoi. Désactivé par défaut.
diff --git a/apps/docs/content/docs/inbox.ja.mdx b/apps/docs/content/docs/inbox.ja.mdx
index 7b09fd23a7..4b9f175c01 100644
--- a/apps/docs/content/docs/inbox.ja.mdx
+++ b/apps/docs/content/docs/inbox.ja.mdx
@@ -10,7 +10,7 @@ import { InboxDemo } from "@/components/demos/inbox-demo";
## インボックスの場所
-インボックスは **作業** パネルのセクションで、ピン留め済みの下、ビューとプロジェクトの上にあります。ピン留めがないときは最初のセクションになります。見出しには **インボックス**、**スヌーズ中**、**アーカイブ済み** の 3 つのタブがあります。未読数は **インボックス** の横と、アプリレールの **作業** のバッジに表示されます。**作業** を右クリックすると **すべて既読にする** を使えます。
+インボックスは **作業** パネルのセクションで、ピン留め済みの下、ビューとプロジェクトの上にあります。ピン留めがないときは最初のセクションになります。見出しには **インボックス**、**スヌーズ中**、**アーカイブ済み** の 3 つのタブがあります。名前が表示されるのは開いているタブだけで、ほかの 2 つはアイコンになり、ポインタを合わせると名前が出ます。開いているタブをもう一度選ぶとセクションを折りたためます。未読数は **インボックス** の横と、アプリレールの **作業** のバッジに表示されます。**作業** を右クリックすると **すべて既読にする** を使えます。
**インボックス** タブにはタスクごとに 1 行ずつ、新しい順に、既読・未読を問わず並びます。行にはタスクのステータス、タイトルと時刻、2 行目に誰が何をしたかが表示され、未読の行にはドットが付きます。表示設定で **コンパクト表示** をオンにすると、各行が 1 行になります。行にカーソルを合わせると、タイトル全文とコメントを表示するカードが開き、**開く**、**既読にする**、**アーカイブ** を使えます。
@@ -149,7 +149,7 @@ multica inbox snooze <id>... --until tomorrow # RFC 3339、30m、3h、1d、1w
## 表示と通知タイプ
-インボックスセクションの見出しにある設定ボタンで表示設定を開けます。この設定はこのデバイスにだけ保存されます。
+インボックスセクションの見出しにある ⋯ メニュー(どのタブにもあります)の **インボックスの表示** で表示設定を開けます。この設定はこのデバイスにだけ保存されます。
- **表示件数**:5、10、20 件。残りは「さらに N 件を表示」の行にまとまります。
- **コンパクト表示**:1 件を 1 行で表示し、誰が何をしたかは表示しません。既定ではオフです。
diff --git a/apps/docs/content/docs/inbox.ko.mdx b/apps/docs/content/docs/inbox.ko.mdx
index 34e81e9458..964fe37802 100644
--- a/apps/docs/content/docs/inbox.ko.mdx
+++ b/apps/docs/content/docs/inbox.ko.mdx
@@ -10,7 +10,7 @@ import { InboxDemo } from "@/components/demos/inbox-demo";
## 인박스 위치
-인박스는 **작업** 패널의 섹션으로, 고정됨 아래, 뷰와 프로젝트 위에 있습니다. 고정한 항목이 없으면 첫 번째 섹션이 됩니다. 섹션 제목에는 **인박스**, **미뤄둔 항목**, **보관됨** 세 개의 탭이 있습니다. 읽지 않은 수는 **인박스** 옆과 앱 레일의 **작업** 배지에 표시됩니다. **작업**을 오른쪽 클릭하면 **모두 읽음으로 표시**를 쓸 수 있습니다.
+인박스는 **작업** 패널의 섹션으로, 고정됨 아래, 뷰와 프로젝트 위에 있습니다. 고정한 항목이 없으면 첫 번째 섹션이 됩니다. 섹션 제목에는 **인박스**, **미뤄둔 항목**, **보관됨** 세 개의 탭이 있습니다. 열린 탭만 이름이 보이고 나머지 두 탭은 아이콘으로 표시되며, 마우스를 올리면 이름이 나타납니다. 열린 탭을 다시 선택하면 섹션이 접힙니다. 읽지 않은 수는 **인박스** 옆과 앱 레일의 **작업** 배지에 표시됩니다. **작업**을 오른쪽 클릭하면 **모두 읽음으로 표시**를 쓸 수 있습니다.
**인박스** 탭에는 태스크마다 한 행씩, 최신순으로, 읽음 여부와 관계없이 표시됩니다. 행에는 태스크 상태, 제목과 시간, 그리고 두 번째 줄에 누가 무엇을 했는지가 보이고, 읽지 않은 행에는 점이 붙습니다. 표시 설정에서 **간결하게 표시**를 켜면 각 행이 한 줄로 줄어듭니다. 행 위에 마우스를 올리면 전체 제목과 댓글이 담긴 카드가 열리고, **열기**, **읽음으로 표시**, **보관**을 쓸 수 있습니다.
@@ -149,7 +149,7 @@ multica inbox snooze <id>... --until tomorrow # RFC 3339, 30m, 3h, 1d, 1w; uns
## 표시와 알림 유형
-인박스 섹션 제목 줄의 설정 버튼을 누르면 표시 설정이 열립니다. 이 설정은 현재 기기에만 저장됩니다.
+인박스 섹션 제목 줄의 ⋯ 메뉴(모든 탭에 있음)에서 **인박스 표시**를 누르면 표시 설정이 열립니다. 이 설정은 현재 기기에만 저장됩니다.
- **표시 개수**: 5, 10, 20개. 나머지는 "N개 더 보기" 행에 모입니다.
- **간결하게 표시**: 한 항목을 한 줄로 표시하고, 누가 무엇을 했는지는 표시하지 않습니다. 기본으로 꺼져 있습니다.
diff --git a/apps/docs/content/docs/inbox.mdx b/apps/docs/content/docs/inbox.mdx
index 2b6a74562a..d9cdd18d8f 100644
--- a/apps/docs/content/docs/inbox.mdx
+++ b/apps/docs/content/docs/inbox.mdx
@@ -10,7 +10,7 @@ The inbox collects the work activity that concerns you and flags where something
## Where to find it
-The inbox is a section of the **Work** panel, below Pinned and above Views and Projects; with nothing pinned, it is the first section. Its header holds three tabs: **Inbox**, **Snoozed** and **Archived**. The unread count shows next to **Inbox** and as a badge on **Work** in the app rail; right-click **Work** for **Mark all as read**.
+The inbox is a section of the **Work** panel, below Pinned and above Views and Projects; with nothing pinned, it is the first section. Its header holds three tabs: **Inbox**, **Snoozed** and **Archived**. Only the open tab shows its name; the other two are icons, named when you hover them. Select the open tab again to collapse the section. The unread count shows next to **Inbox** and as a badge on **Work** in the app rail; right-click **Work** for **Mark all as read**.
The **Inbox** tab lists one row per issue, newest first, read and unread alike. A row shows the issue's status, its title and time, and who did what on a second line; a dot marks it unread. Turn on **Compact rows** in the display settings to keep each row to one line. Hover a row for a card with the full title, the comment, and **Open**, **Mark as read**, and **Archive**.
@@ -149,7 +149,7 @@ A later notification on the issue lands in the inbox again.
## Display and notification types
-The sliders button in the Inbox section header opens its display settings, which are saved on this device:
+**Inbox display**, in the ⋯ menu of the Inbox section header on every tab, opens its display settings, which are saved on this device:
- **Rows shown**: 5, 10, or 20; a **Show more** row lists the rest.
- **Compact rows**: one line per row, without who did what. Off by default.
diff --git a/apps/docs/content/docs/inbox.zh-Hant.mdx b/apps/docs/content/docs/inbox.zh-Hant.mdx
index 07ad8317ec..1a0963c5d9 100644
--- a/apps/docs/content/docs/inbox.zh-Hant.mdx
+++ b/apps/docs/content/docs/inbox.zh-Hant.mdx
@@ -10,7 +10,7 @@ import { InboxDemo } from "@/components/demos/inbox-demo";
## 在哪裡找到收件箱
-收件箱是**工作**面板裡的一個分區,排在固定之後、檢視和專案之前;沒有固定項時,它就是第一個分區。分區標題列有三個分頁:**收件箱**、**已延後**和**已歸檔**。未讀數顯示在**收件箱**旁,也會以角標顯示在應用側欄的**工作**上;右鍵點選**工作**可以**全部標為已讀**。
+收件箱是**工作**面板裡的一個分區,排在固定之後、檢視和專案之前;沒有固定項時,它就是第一個分區。分區標題列有三個分頁:**收件箱**、**已延後**和**已歸檔**。只有目前的分頁顯示名稱,另外兩個顯示為圖示,懸停可看到名稱。再次點選目前的分頁可以收合這個分區。未讀數顯示在**收件箱**旁,也會以角標顯示在應用側欄的**工作**上;右鍵點選**工作**可以**全部標為已讀**。
**收件箱**分頁每個任務佔一列,最新的在前,已讀和未讀都在。每列顯示任務狀態、標題和時間,第二行顯示誰做了什麼;未讀的列帶一個圓點。在顯示設定裡打開**緊湊顯示**,每列只保留一行。滑鼠懸停在某列上會彈出卡片,顯示完整標題和評論內容,並提供**開啟**、**標為已讀**和**歸檔**。
@@ -149,7 +149,7 @@ multica inbox snooze <id>... --until tomorrow # RFC 3339、30m、3h、1d、1w
## 顯示與通知類型
-收件箱分區標題列的設定按鈕會開啟它的顯示設定,只儲存在目前裝置上:
+收件箱分區標題列的 ⋯ 選單裡(每個分頁下都有)的**收件箱顯示**會開啟它的顯示設定,只儲存在目前裝置上:
- **顯示筆數**:5、10 或 20 筆;其餘的收在"再顯示 N 項"裡。
- **緊湊顯示**:每列只佔一行高度,不顯示誰做了什麼。預設關閉。
diff --git a/apps/docs/content/docs/inbox.zh.mdx b/apps/docs/content/docs/inbox.zh.mdx
index 6ff86ebb4f..c0c55ae4e2 100644
--- a/apps/docs/content/docs/inbox.zh.mdx
+++ b/apps/docs/content/docs/inbox.zh.mdx
@@ -10,7 +10,7 @@ import { InboxDemo } from "@/components/demos/inbox-demo";
## 在哪里找到收件箱
-收件箱是**工作**面板里的一个分区,排在固定之后、视图和项目之前;没有固定项时,它就是第一个分区。分区标题栏有三个标签:**收件箱**、**已延后**和**已归档**。未读数显示在**收件箱**旁,也会以角标显示在应用侧栏的**工作**上;右键点击**工作**可以**全部标为已读**。
+收件箱是**工作**面板里的一个分区,排在固定之后、视图和项目之前;没有固定项时,它就是第一个分区。分区标题栏有三个标签:**收件箱**、**已延后**和**已归档**。只有当前标签显示名称,另外两个显示为图标,悬停可看到名称。再次点击当前标签可以折叠这个分区。未读数显示在**收件箱**旁,也会以角标显示在应用侧栏的**工作**上;右键点击**工作**可以**全部标为已读**。
**收件箱**标签每个任务占一行,最新的在前,已读和未读都在。每行显示任务状态、标题和时间,第二行显示谁做了什么;未读的行带一个圆点。在显示设置里打开**紧凑显示**,每行只保留一行。鼠标悬停在某行上会弹出卡片,显示完整标题和评论内容,并提供**打开**、**标为已读**和**归档**。
@@ -149,7 +149,7 @@ multica inbox snooze <id>... --until tomorrow # RFC 3339、30m、3h、1d、1w
## 显示与通知类型
-收件箱分区标题栏的设置按钮会打开它的显示设置,只保存在当前设备上:
+收件箱分区标题栏的 ⋯ 菜单里(每个标签下都有)的**收件箱显示**会打开它的显示设置,只保存在当前设备上:
- **显示条数**:5、10 或 20 条;其余的收在"再显示 N 项"里。
- **紧凑显示**:每行只占一行高度,不显示谁做了什么。默认关闭。
diff --git a/packages/views/inbox/components/inbox-tabs.tsx b/packages/views/inbox/components/inbox-tabs.tsx
index 30f7e086f5..fa6b49d54d 100644
--- a/packages/views/inbox/components/inbox-tabs.tsx
+++ b/packages/views/inbox/components/inbox-tabs.tsx
@@ -1,22 +1,36 @@
"use client";
import type { KeyboardEvent } from "react";
+import { AlarmClock, Archive, Inbox } from "@multica/ui/icons";
+import { Tooltip, TooltipContent, TooltipTrigger } from "@multica/ui/components/ui/tooltip";
import { cn } from "@multica/ui/lib/utils";
import { useT } from "../../i18n";
import type { InboxTab } from "./inbox-view";
const TABS: readonly InboxTab[] = ["inbox", "snoozed", "archived"];
+const TAB_ICONS: Record<InboxTab, typeof Inbox> = {
+ inbox: Inbox,
+ snoozed: AlarmClock,
+ archived: Archive,
+};
+
/**
* The Inbox's three lists as tabs: the live Inbox with its unread count, the
* issues snoozed out of it with theirs, and the archive. The Work panel's
* Inbox section shows them in its header; a phone's Inbox page, in its own.
+ *
+ * In the section header only the open tab carries its name: the other two are
+ * icons named by a tooltip, so at the panel's default width no label is cut
+ * down to its first letter. The unread count stays on the Inbox
+ * icon; the snoozed count moves into its tooltip.
*/
export function InboxTabs({
tab,
onSelect,
unread,
snoozed,
+ expanded,
size = "section",
className,
}: {
@@ -25,6 +39,8 @@ export function InboxTabs({
/** Left out (or 0) to show no count. */
unread?: number;
snoozed?: number;
+ /** Set when selecting the open tab again collapses the list it heads. */
+ expanded?: boolean;
/** `section` for the Work panel's header, `page` for a page header. */
size?: "section" | "page";
className?: string;
@@ -56,31 +72,49 @@ export function InboxTabs({
{TABS.map((id) => {
const active = id === tab;
const count = counts[id] ?? 0;
- return (
+ const iconOnly = size === "section" && !active;
+ const countClass = cn("shrink-0 tabular-nums", id === "inbox" ? "text-brand" : "text-faint-foreground");
+ const Icon = TAB_ICONS[id];
+ const button = (
<button
- key={id}
type="button"
role="tab"
data-inbox-tab={id}
aria-selected={active}
+ aria-expanded={active ? expanded : undefined}
tabIndex={active ? 0 : -1}
onClick={() => onSelect(id)}
className={cn(
- // Long labels (French, Russian) truncate rather than push the
- // section's actions out of the header.
- "flex min-w-0 items-center gap-1 rounded-md outline-none transition-colors focus-visible:outline-2 focus-visible:outline-ring",
- size === "section" ? "h-5 px-1.5" : "h-7 px-2",
+ "flex items-center gap-1 rounded-md outline-none transition-colors focus-visible:outline-2 focus-visible:outline-ring",
+ size === "section" ? "h-5" : "h-7 px-2",
+ // The open tab gives up width before the icons do; a label
+ // still too long for the panel (Spanish, French) truncates.
+ iconOnly ? "shrink-0 px-1" : size === "section" ? "min-w-0 px-1.5" : "min-w-0",
active ? "bg-surface-selected text-foreground" : "text-muted-foreground hover:text-foreground",
)}
>
- <span className="truncate">{labels[id]}</span>
- {count > 0 && (
- <span className={cn("shrink-0 tabular-nums", id === "inbox" ? "text-brand" : "text-faint-foreground")}>
- {count}
- </span>
+ {iconOnly ? (
+ <>
+ <Icon aria-hidden className="size-3.5" />
+ <span className="sr-only">{labels[id]}</span>
+ {count > 0 && <span className={cn(countClass, id !== "inbox" && "sr-only")}>{count}</span>}
+ </>
+ ) : (
+ <>
+ <span className="truncate">{labels[id]}</span>
+ {count > 0 && <span className={countClass}>{count}</span>}
+ </>
)}
</button>
);
+ // Every tab keeps the same element as it opens and closes, so arrow
+ // keys keep focus on it; only the icons' tooltips are enabled.
+ return (
+ <Tooltip key={id} disabled={!iconOnly}>
+ <TooltipTrigger render={button} />
+ <TooltipContent side="bottom">{count > 0 ? `${labels[id]} · ${count}` : labels[id]}</TooltipContent>
+ </Tooltip>
+ );
})}
</div>
);
diff --git a/packages/views/layout/panel-nav.tsx b/packages/views/layout/panel-nav.tsx
index 5ed2702b57..427f0ba5ab 100644
--- a/packages/views/layout/panel-nav.tsx
+++ b/packages/views/layout/panel-nav.tsx
@@ -115,7 +115,8 @@ export function PanelSection({
/**
* Shown in place of the label (the Inbox's tabs), which then only names the
* section for assistive tech. With `onCollapsedChange`, a chevron after it
- * toggles the section.
+ * toggles the section; it takes room only while the section is collapsed,
+ * so the heading must collapse it too.
*/
heading?: React.ReactNode;
/** Rendered at the end of the label row (e.g. a create button). */
@@ -156,7 +157,12 @@ export function PanelSection({
aria-expanded={!collapsed}
aria-controls={collapsed ? undefined : contentId}
onClick={() => onCollapsedChange(!collapsed)}
- className="flex size-5 shrink-0 items-center justify-center rounded-md outline-none hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring"
+ className={cn(
+ "flex size-5 shrink-0 items-center justify-center rounded-md outline-none hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring",
+ // An open section leaves the row to its heading; the
+ // heading itself collapses it (the Inbox's open tab).
+ !collapsed && "sr-only focus-visible:not-sr-only",
+ )}
>
{chevron}
</button>
diff --git a/packages/views/layout/panels/inbox-section.test.tsx b/packages/views/layout/panels/inbox-section.test.tsx
index 1c2ab8be97..24d7a282fb 100644
--- a/packages/views/layout/panels/inbox-section.test.tsx
+++ b/packages/views/layout/panels/inbox-section.test.tsx
@@ -77,6 +77,9 @@ vi.mock("@multica/core/hooks", async (importOriginal) => ({
...(await importOriginal<typeof import("@multica/core/hooks")>()),
useWorkspaceId: () => "ws-1",
}));
+vi.mock("@multica/core/notification-preferences/mutations", () => ({
+ useUpdateNotificationPreferences: () => ({ mutate: vi.fn() }),
+}));
vi.mock("@multica/core/workspace/hooks", () => ({
useActorName: () => ({ getActorName: () => "Leo Park", getActorInitials: () => "LP", getActorAvatarUrl: () => null }),
}));
@@ -470,6 +473,42 @@ describe("InboxSection", () => {
expect(rows()).toHaveLength(0);
});
+ it("collapses from its open tab, and a closed tab opens the section on that list", () => {
+ renderSection([item({ id: "n1", issue_id: "issue-a" })]);
+ const inbox = screen.getByRole("tab", { name: /^Inbox/ });
+ expect(inbox).toHaveAttribute("aria-expanded", "true");
+ fireEvent.click(inbox);
+ expect(useSidebarTreeStore.getState().inboxCollapsed).toBe(true);
+ expect(inbox).toHaveAttribute("aria-expanded", "false");
+
+ fireEvent.click(screen.getByRole("tab", { name: /^Snoozed/ }));
+ expect(useSidebarTreeStore.getState().inboxCollapsed).toBe(false);
+ expect(screen.getByRole("tab", { name: /^Snoozed/ })).toHaveAttribute("aria-selected", "true");
+ });
+
+ it("names only the open tab on screen, and keeps focus on the tab the arrow keys move to", () => {
+ renderSection([item({ id: "n1", issue_id: "issue-a" })]);
+ const tablist = screen.getByRole("tablist");
+ expect(within(tablist).getByText("Inbox")).not.toHaveClass("sr-only");
+ expect(within(tablist).getByText("Snoozed")).toHaveClass("sr-only");
+
+ const inbox = screen.getByRole("tab", { name: /^Inbox/ });
+ inbox.focus();
+ fireEvent.keyDown(inbox, { key: "ArrowRight" });
+ const snoozed = screen.getByRole("tab", { name: /^Snoozed/ });
+ expect(snoozed).toHaveAttribute("aria-selected", "true");
+ expect(snoozed).toHaveFocus();
+ expect(within(tablist).getByText("Snoozed")).not.toHaveClass("sr-only");
+ });
+
+ it("opens the display settings from the actions menu", async () => {
+ renderSection([item({ id: "n1", issue_id: "issue-a" })]);
+ expect(screen.queryByRole("button", { name: "Inbox display" })).toBeNull();
+ fireEvent.click(screen.getByRole("button", { name: "Inbox actions" }));
+ fireEvent.click(within(await screen.findByRole("menu")).getByRole("menuitem", { name: "Inbox display" }));
+ expect(await screen.findByRole("dialog", { name: "Inbox display" })).toBeInTheDocument();
+ });
+
it("is the whole list on a wide screen: no link out to another one, and a plain line when empty", () => {
const { unmount } = renderSection([item({ id: "n1", issue_id: "issue-a", title: "Only one" })]);
expect(screen.queryByRole("link", { name: "All notifications" })).toBeNull();
@@ -602,7 +641,11 @@ describe("InboxSection", () => {
expect(tab).toHaveAttribute("aria-selected", "true");
expect(rows()).toHaveLength(0);
expect(screen.getByRole("link", { name: /^MUL-26/ })).toHaveAttribute("href", "/acme/inbox?view=snoozed&issue=issue-z");
- expect(screen.queryByRole("button", { name: "Inbox actions" })).toBeNull();
+ // The bulk actions act on the live Inbox; the menu keeps only the display settings here.
+ fireEvent.click(screen.getByRole("button", { name: "Inbox actions" }));
+ expect(within(await screen.findByRole("menu")).getAllByRole("menuitem").map((el) => el.textContent)).toEqual([
+ "Inbox display",
+ ]);
fireEvent.click(screen.getByRole("button", { name: "Bring back now" }));
expect(state.unsnooze).toHaveBeenCalledWith(expect.objectContaining({ id: "z1" }));
diff --git a/packages/views/layout/panels/inbox-section.tsx b/packages/views/layout/panels/inbox-section.tsx
index fffe7f7f09..34f80e045a 100644
--- a/packages/views/layout/panels/inbox-section.tsx
+++ b/packages/views/layout/panels/inbox-section.tsx
@@ -6,7 +6,7 @@ import { useVirtualizer } from "@tanstack/react-virtual";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { toast } from "sonner";
import { useReducedMotion } from "@multica/core/appearance";
-import { AlarmClock, Archive, ArchiveRestore, BellOff, BookCheck, CheckCheck, ListChecks, MoreHorizontal } from "@multica/ui/icons";
+import { AlarmClock, Archive, ArchiveRestore, BellOff, BookCheck, CheckCheck, ListChecks, MoreHorizontal, SlidersHorizontal } from "@multica/ui/icons";
import { IconButton } from "@multica/ui/components/common/icon-button";
import { UI_EASE_OUT, UI_MOTION_DURATION } from "@multica/ui/lib/motion";
import { cn } from "@multica/ui/lib/utils";
@@ -167,6 +167,12 @@ export function InboxSection({
if (onInboxPage) setSectionTab(wsId, pageTab);
}, [onInboxPage, pageTab, setSectionTab, wsId]);
const selectTab = (next: InboxTab) => {
+ // The open tab is the section's title: selecting it again folds the
+ // section, as a click on another section's title does.
+ if (next === tab) {
+ setCollapsed(!collapsed);
+ return;
+ }
setSectionTab(wsId, next);
if (collapsed) setCollapsed(false);
if (onInboxPage && next !== pageTab) replace(inboxTabHref(p, next));
@@ -192,6 +198,9 @@ export function InboxSection({
return counts;
}, [list.notifications]);
+ const actionsRef = useRef<HTMLButtonElement>(null);
+ const [settingsOpen, setSettingsOpen] = useState(false);
+
const scrollRef = usePanelScrollRef();
// Rows are memoized and re-render only when their own props change, not on
// every navigation that re-renders this section (MUL-9609); the handlers
@@ -277,6 +286,7 @@ export function InboxSection({
onSelect={selectTab}
unread={showCount ? unread : undefined}
snoozed={snoozed.rows.length}
+ expanded={!collapsed}
/>
}
collapsed={collapsed}
@@ -298,15 +308,17 @@ export function InboxSection({
}}
/>
)}
- <InboxSectionSettings className={SECTION_SETTINGS_REVEAL_CLASS} />
- {tab === "inbox" && (
- <InboxSectionActions
- wsId={wsId}
- rows={all}
- openRowKey={openRowKey}
- className={SECTION_SETTINGS_REVEAL_CLASS}
- />
- )}
+ <InboxSectionActions
+ wsId={wsId}
+ rows={all}
+ openRowKey={openRowKey}
+ bulk={tab === "inbox"}
+ triggerRef={actionsRef}
+ settingsOpen={settingsOpen}
+ onOpenSettings={() => setSettingsOpen(true)}
+ className={SECTION_SETTINGS_REVEAL_CLASS}
+ />
+ <InboxSectionSettings opener={{ open: settingsOpen, onOpenChange: setSettingsOpen, anchor: actionsRef }} />
</div>
}
>
@@ -480,15 +492,29 @@ function VirtualInboxList({
);
}
+/**
+ * The section's ⋯ menu: the bulk actions on the Inbox tab, and on every tab
+ * the section's display settings.
+ */
function InboxSectionActions({
wsId,
rows,
openRowKey,
+ bulk,
+ triggerRef,
+ settingsOpen,
+ onOpenSettings,
className,
}: {
wsId: string;
rows: readonly InboxItem[];
openRowKey: string | null;
+ /** Offers the bulk actions, which act on the live Inbox. */
+ bulk: boolean;
+ triggerRef: Ref<HTMLButtonElement>;
+ /** The settings hang from this menu's button, which stays shown meanwhile. */
+ settingsOpen: boolean;
+ onOpenSettings: () => void;
className?: string;
}) {
const { t } = useT("layout");
@@ -542,6 +568,7 @@ function InboxSectionActions({
<DropdownMenuTrigger
render={
<button
+ ref={triggerRef}
type="button"
aria-label={label}
className={cn(
@@ -550,6 +577,7 @@ function InboxSectionActions({
"size-[var(--button-height-xs)]",
"text-muted-foreground data-popup-open:bg-surface-selected data-popup-open:text-foreground data-popup-open:opacity-100",
className,
+ settingsOpen && "bg-surface-selected text-foreground opacity-100",
)}
/>
}
@@ -557,50 +585,59 @@ function InboxSectionActions({
<MoreHorizontal className="size-3.5" />
</DropdownMenuTrigger>
<DropdownMenuContent side="right" align="start" className="w-auto min-w-48">
- <DropdownMenuItem
- onClick={() =>
- markAllRead.mutate(undefined, { onError: onError(tInbox(($) => $.errors.mark_all_read_failed)) })
- }
- >
- <CheckCheck className="size-4" />
- {tInbox(($) => $.menu.mark_all_read)}
- </DropdownMenuItem>
- <DropdownMenuSeparator />
- <DropdownMenuItem
- onClick={() =>
- archiveBatch(
- () => archiveAllRead.mutateAsync(),
- isRead,
- tInbox(($) => $.errors.archive_all_read_failed),
- )
- }
- >
- <BookCheck className="size-4" />
- {tInbox(($) => $.menu.archive_all_read)}
- </DropdownMenuItem>
- <DropdownMenuItem
- onClick={() =>
- archiveBatch(
- () => archiveCompleted.mutateAsync(),
- isFinished,
- tInbox(($) => $.errors.archive_completed_failed),
- )
- }
- >
- <ListChecks className="size-4" />
- {tInbox(($) => $.menu.archive_completed)}
- </DropdownMenuItem>
- <DropdownMenuItem
- onClick={() =>
- archiveBatch(
- () => archiveAll.mutateAsync(),
- () => true,
- tInbox(($) => $.errors.archive_all_failed),
- )
- }
- >
- <Archive className="size-4" />
- {tInbox(($) => $.menu.archive_all)}
+ {bulk && (
+ <>
+ <DropdownMenuItem
+ onClick={() =>
+ markAllRead.mutate(undefined, { onError: onError(tInbox(($) => $.errors.mark_all_read_failed)) })
+ }
+ >
+ <CheckCheck className="size-4" />
+ {tInbox(($) => $.menu.mark_all_read)}
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem
+ onClick={() =>
+ archiveBatch(
+ () => archiveAllRead.mutateAsync(),
+ isRead,
+ tInbox(($) => $.errors.archive_all_read_failed),
+ )
+ }
+ >
+ <BookCheck className="size-4" />
+ {tInbox(($) => $.menu.archive_all_read)}
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onClick={() =>
+ archiveBatch(
+ () => archiveCompleted.mutateAsync(),
+ isFinished,
+ tInbox(($) => $.errors.archive_completed_failed),
+ )
+ }
+ >
+ <ListChecks className="size-4" />
+ {tInbox(($) => $.menu.archive_completed)}
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onClick={() =>
+ archiveBatch(
+ () => archiveAll.mutateAsync(),
+ () => true,
+ tInbox(($) => $.errors.archive_all_failed),
+ )
+ }
+ >
+ <Archive className="size-4" />
+ {tInbox(($) => $.menu.archive_all)}
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ </>
+ )}
+ <DropdownMenuItem onClick={onOpenSettings}>
+ <SlidersHorizontal className="size-4" />
+ {t(($) => $.panels.work.inbox_settings)}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
diff --git a/packages/views/layout/panels/sidebar-settings.tsx b/packages/views/layout/panels/sidebar-settings.tsx
index a374aae7bf..ba7717551e 100644
--- a/packages/views/layout/panels/sidebar-settings.tsx
+++ b/packages/views/layout/panels/sidebar-settings.tsx
@@ -320,41 +320,59 @@ export function ProjectsSectionSettings({ wsId, className }: { wsId: string; cla
);
}
-/** The sliders button at the end of a section's label row, and its popover. */
+/** Opens a section's settings from another control, such as a menu item. */
+export interface SectionSettingsAnchor {
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+ /** The control the popover hangs from and hands focus back to. */
+ anchor: React.RefObject<HTMLElement | null>;
+}
+
+/**
+ * The sliders button at the end of a section's label row, and its popover.
+ * With `opener`, there is no button: the popover opens from that control.
+ */
function SectionSettingsPopover({
label,
className,
onReset,
+ opener,
children,
}: {
label: string;
className?: string;
/** Offered while the section's settings differ from the defaults. */
onReset?: () => void;
+ opener?: SectionSettingsAnchor;
children: React.ReactNode;
}) {
const { t } = useT("layout");
return (
- <Popover>
- <PopoverTrigger
- render={
- <button
- type="button"
- aria-label={label}
- className={cn(
- TREE_ROW_BUTTON_CLASS,
- "text-muted-foreground data-popup-open:bg-surface-selected data-popup-open:text-foreground data-popup-open:opacity-100",
- className,
- )}
- />
- }
- >
- <SlidersHorizontal className="size-3.5" />
- </PopoverTrigger>
+ <Popover {...(opener && { open: opener.open, onOpenChange: opener.onOpenChange })}>
+ {!opener && (
+ <PopoverTrigger
+ render={
+ <button
+ type="button"
+ aria-label={label}
+ className={cn(
+ TREE_ROW_BUTTON_CLASS,
+ "text-muted-foreground data-popup-open:bg-surface-selected data-popup-open:text-foreground data-popup-open:opacity-100",
+ className,
+ )}
+ />
+ }
+ >
+ <SlidersHorizontal className="size-3.5" />
+ </PopoverTrigger>
+ )}
<PopoverContent
side="right"
align="start"
sideOffset={8}
+ anchor={opener?.anchor}
+ finalFocus={opener?.anchor}
+ aria-label={opener ? label : undefined}
className="max-h-(--available-height) w-80 gap-0 overflow-y-auto p-3"
>
{/* Spacing separates sections — no dividers, as in the Display panel. */}
@@ -432,8 +450,12 @@ function InboxNotificationTypes() {
);
}
-/** The Inbox section's display, and which notifications reach the inbox. */
-export function InboxSectionSettings({ className }: { className?: string }) {
+/**
+ * The Inbox section's display, and which notifications reach the inbox. The
+ * section opens it from its actions menu, to keep the header's width for the
+ * tabs.
+ */
+export function InboxSectionSettings({ className, opener }: { className?: string; opener?: SectionSettingsAnchor }) {
const { t } = useT("layout");
const settings = useSidebarTreeStore((s) => s.inboxSettings);
const update = useSidebarTreeStore((s) => s.setInboxSettings);
@@ -442,6 +464,7 @@ export function InboxSectionSettings({ className }: { className?: string }) {
<SectionSettingsPopover
label={t(($) => $.panels.work.inbox_settings)}
className={className}
+ opener={opener}
onReset={sameSettings(settings, DEFAULT_SIDEBAR_INBOX_SETTINGS) ? undefined : () => update(DEFAULT_SIDEBAR_INBOX_SETTINGS)}
>
<section className="space-y-3">