Skip to content

Commit 661c8f9

Browse files
authored
fix(desktop): keep drafts out of the Inbox All view (#3217)
## Summary Drafts were showing up in the Home Inbox **All** view, mixed in with messages and reminders (reported in `#buzz-bugs`). Drafts are private composer state, not inbox activity — they now appear only under the dedicated **Drafts** filter. ## Changes - **`inboxListRows.ts`** — drop the `draft` row variant from `buildInboxListRows`; the mixed view builds only `inbox` + `reminder` rows. - **`InboxListPane.tsx`** — remove the draft branch of the All-view render path; `PersonalItemRow` now renders reminders only. - **`useHomePersonalInbox.ts`** — stop enabling draft selection (and its root-status relay probing) for the mixed view; draft selection is scoped to the Drafts filter. - Drafts filter behavior is unchanged: the filter badge count, `DraftsPanel` list, and `DraftDetailPane` all still work. ## Testing - `pnpm test` (desktop unit suite): 3697 passed, 0 failed. - `pnpm exec biome check src/features/home tests`: clean. - Updated `inboxListRows.test.mjs` for the two-variant row model. - Updated the e2e test (`channels.spec.ts`) to assert All never lists drafts and that the draft is still reachable under the Drafts filter. - Added `drafts-all-fix-screenshots.spec.ts` capturing both states (screenshots below). ### All view — draft is gone, messages/reminders unaffected ![01-all-view-no-drafts](https://raw.githubusercontent.com/block/buzz/12c97624832cef40df951c403982994fea58dd80/pr-3217--01-all-view-no-drafts.png) ### Drafts filter — the draft is still listed and editable ![02-drafts-filter-still-lists](https://raw.githubusercontent.com/block/buzz/12c97624832cef40df951c403982994fea58dd80/pr-3217--02-drafts-filter-still-lists.png) Signed-off-by: Thomas Petersen <[email protected]>
1 parent 0e022cc commit 661c8f9

7 files changed

Lines changed: 138 additions & 110 deletions

File tree

‎desktop/playwright.config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export default defineConfig({
103103
"**/project-pr-review.spec.ts",
104104
"**/persona-model-combobox-screenshots.spec.ts",
105105
"**/drafts-screenshots.spec.ts",
106+
"**/drafts-all-fix-screenshots.spec.ts",
106107
"**/inbox-refactor-screenshots.spec.ts",
107108
"**/buzz-theme-screenshots.spec.ts",
108109
"**/channel-sort.spec.ts",

‎desktop/src/features/home/lib/inboxListRows.test.mjs‎

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@ function inboxItem(
1717
};
1818
}
1919

20-
function draftItem(key, updatedAt, rootStatus = "available") {
21-
return {
22-
entry: {
23-
key,
24-
draft: { createdAt: updatedAt, updatedAt },
25-
},
26-
rootStatus,
27-
};
28-
}
29-
3020
function reminder(
3121
id,
3222
createdAt,
@@ -46,20 +36,18 @@ function reminder(
4636

4737
test("Inbox All combines rows in latest-first order", () => {
4838
const rows = buildInboxListRows({
49-
drafts: [draftItem("draft", "2026-07-21T12:00:00.000Z")],
5039
items: [inboxItem("message", 1_753_099_300)],
5140
reminders: [reminder("reminder", 1_753_099_100)],
5241
});
5342

5443
assert.deepEqual(
5544
rows.map((row) => row.kind),
56-
["draft", "inbox", "reminder"],
45+
["inbox", "reminder"],
5746
);
5847
});
5948

60-
test("Inbox All excludes completed reminders and deleted-root drafts", () => {
49+
test("Inbox All excludes completed reminders", () => {
6150
const rows = buildInboxListRows({
62-
drafts: [draftItem("deleted", "2026-07-21T12:00:00.000Z", "deleted")],
6351
items: [],
6452
reminders: [reminder("done", 1_753_099_100, "done")],
6553
});
@@ -69,12 +57,10 @@ test("Inbox All excludes completed reminders and deleted-root drafts", () => {
6957

7058
test("Inbox conversation keys stay stable when the representative changes", () => {
7159
const first = buildInboxListRows({
72-
drafts: [],
7360
items: [inboxItem("reply-1", 1, "thread-root")],
7461
reminders: [],
7562
});
7663
const second = buildInboxListRows({
77-
drafts: [],
7864
items: [inboxItem("reply-2", 2, "thread-root")],
7965
reminders: [],
8066
});
@@ -87,7 +73,6 @@ test("due reminder enriches its existing conversation instead of duplicating it"
8773
const item = inboxItem("message", 100);
8874
item.groupItems = [{ id: "reminded-reply" }];
8975
const rows = buildInboxListRows({
90-
drafts: [],
9176
items: [item],
9277
reminders: [
9378
reminder("reminder", 50, "pending", {
@@ -105,7 +90,6 @@ test("due reminder enriches its existing conversation instead of duplicating it"
10590

10691
test("due reminder without a represented conversation sorts at trigger time", () => {
10792
const rows = buildInboxListRows({
108-
drafts: [],
10993
items: [inboxItem("newer-than-creation", 150)],
11094
reminders: [
11195
reminder("reminder", 50, "pending", {

‎desktop/src/features/home/lib/inboxListRows.ts‎

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { InboxItem } from "@/features/home/lib/inbox";
2-
import type { DraftViewItem } from "@/features/messages/ui/DraftsPanel";
32
import type { Reminder } from "@/features/reminders/lib/reminderTypes";
43

54
export type InboxListRow =
@@ -15,31 +14,12 @@ export type InboxListRow =
1514
kind: "reminder";
1615
reminder: Reminder;
1716
sortAt: number;
18-
}
19-
| {
20-
key: string;
21-
kind: "draft";
22-
item: DraftViewItem;
23-
sortAt: number;
2417
};
2518

26-
function draftActivityAt(item: DraftViewItem): number {
27-
for (const value of [
28-
item.entry.draft.updatedAt,
29-
item.entry.draft.createdAt,
30-
]) {
31-
const timestamp = Date.parse(value);
32-
if (Number.isFinite(timestamp)) return timestamp / 1_000;
33-
}
34-
return 0;
35-
}
36-
3719
export function buildInboxListRows({
38-
drafts,
3920
items,
4021
reminders,
4122
}: {
42-
drafts: readonly DraftViewItem[];
4323
items: readonly InboxItem[];
4424
reminders: readonly Reminder[];
4525
}): InboxListRow[] {
@@ -98,15 +78,5 @@ export function buildInboxListRows({
9878
sortAt: reminder.notBefore ?? reminder.createdAt,
9979
}),
10080
),
101-
...drafts
102-
.filter((item) => item.rootStatus !== "deleted")
103-
.map(
104-
(item): InboxListRow => ({
105-
key: `draft:${item.entry.key}`,
106-
kind: "draft",
107-
item,
108-
sortAt: draftActivityAt(item),
109-
}),
110-
),
11181
].sort((left, right) => right.sortAt - left.sortAt);
11282
}

‎desktop/src/features/home/ui/InboxListPane.tsx‎

Lines changed: 18 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import {
2-
Bell,
3-
Clock,
4-
Ellipsis,
5-
ExternalLink,
6-
FileText,
7-
MailOpen,
8-
} from "lucide-react";
1+
import { Bell, Clock, Ellipsis, ExternalLink, MailOpen } from "lucide-react";
92
import * as React from "react";
103

114
import {
@@ -18,7 +11,6 @@ import { buildInboxListRows } from "@/features/home/lib/inboxListRows";
1811
import { InboxFilterMenu } from "@/features/home/ui/InboxFilterMenu";
1912
import {
2013
DraftsPanel,
21-
getDraftPreview,
2214
type DraftViewItem,
2315
} from "@/features/messages/ui/DraftsPanel";
2416
import { UserProfilePopover } from "@/features/profile/ui/UserProfilePopover";
@@ -130,41 +122,36 @@ function formatReminderStatus(notBefore: number | undefined) {
130122

131123
function PersonalItemRow({
132124
id,
133-
kind,
134125
location,
135126
onClick,
136127
preview,
137128
selected,
138129
status,
139130
}: {
140131
id: string;
141-
kind: "drafts" | "reminders";
142132
location: InboxTypeLabel | null;
143133
onClick: () => void;
144134
preview: string;
145135
selected: boolean;
146136
status: string;
147137
}) {
148-
const isDraft = kind === "drafts";
149-
const Icon = isDraft ? FileText : Bell;
150-
151138
return (
152139
<button
153140
aria-current={selected ? "true" : undefined}
154141
className={cn(
155142
"flex w-full items-center gap-3 border-b border-border/45 px-4 py-3 text-left transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:outline-hidden",
156143
selected && "bg-muted/40",
157144
)}
158-
data-testid={`home-all-${kind}-${id}`}
145+
data-testid={`home-all-reminders-${id}`}
159146
onClick={onClick}
160147
type="button"
161148
>
162149
<span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground">
163-
<Icon className="h-4 w-4" />
150+
<Bell className="h-4 w-4" />
164151
</span>
165152
<span className="min-w-0 flex-1">
166153
<span className="block text-sm font-semibold text-foreground">
167-
{isDraft ? "Draft" : "Reminder"}
154+
Reminder
168155
</span>
169156
{location ? (
170157
<InboxLabel
@@ -246,15 +233,14 @@ export function InboxListPane({
246233
const inboxRows = React.useMemo(
247234
() =>
248235
buildInboxListRows({
249-
drafts: unreadOnly || !isMixedInboxView ? [] : draftItems,
250236
items,
251237
reminders: unreadOnly
252238
? []
253239
: reminders.filter((reminder) =>
254240
isDue(reminder, Math.floor(Date.now() / 1_000)),
255241
),
256242
}),
257-
[draftItems, isMixedInboxView, items, reminders, unreadOnly],
243+
[items, reminders, unreadOnly],
258244
);
259245
const visibleInboxRows = React.useMemo(
260246
() =>
@@ -632,57 +618,30 @@ export function InboxListPane({
632618
return renderItem(row.item, row.dueReminder);
633619
}
634620

635-
if (row.kind === "reminder") {
636-
const source = reminderSources.get(row.reminder.id);
637-
return (
638-
<PersonalItemRow
639-
id={row.reminder.id}
640-
kind="reminders"
641-
location={
642-
source?.channel
643-
? source.channel.channelType === "dm"
644-
? {
645-
text: `In DM with ${source.channelLabel}`,
646-
channelLabel: null,
647-
}
648-
: { text: "In", channelLabel: source.channelLabel }
649-
: null
650-
}
651-
onClick={() => {
652-
onSelectReminder(row.reminder.id);
653-
}}
654-
preview={
655-
row.reminder.content.target?.preview ||
656-
row.reminder.content.note ||
657-
"Reminder"
658-
}
659-
selected={selectedReminderId === row.reminder.id}
660-
status={formatReminderStatus(row.reminder.notBefore)}
661-
/>
662-
);
663-
}
664-
665-
const { entry, source } = row.item;
621+
const source = reminderSources.get(row.reminder.id);
666622
return (
667623
<PersonalItemRow
668-
id={entry.key}
669-
kind="drafts"
624+
id={row.reminder.id}
670625
location={
671-
source.channel
626+
source?.channel
672627
? source.channel.channelType === "dm"
673628
? {
674-
text: `In DM with ${source.label}`,
629+
text: `In DM with ${source.channelLabel}`,
675630
channelLabel: null,
676631
}
677-
: { text: "In", channelLabel: source.label }
632+
: { text: "In", channelLabel: source.channelLabel }
678633
: null
679634
}
680635
onClick={() => {
681-
onSelectDraft(entry.key);
636+
onSelectReminder(row.reminder.id);
682637
}}
683-
preview={getDraftPreview(entry.draft)}
684-
selected={selectedDraftKey === entry.key}
685-
status="Draft saved"
638+
preview={
639+
row.reminder.content.target?.preview ||
640+
row.reminder.content.note ||
641+
"Reminder"
642+
}
643+
selected={selectedReminderId === row.reminder.id}
644+
status={formatReminderStatus(row.reminder.notBefore)}
686645
/>
687646
);
688647
}}

‎desktop/src/features/home/useHomePersonalInbox.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@ export function useHomePersonalInbox({
6868
viewportWidthPx,
6969
]);
7070

71+
// Drafts are only listed (and selectable) under the dedicated Drafts
72+
// filter — they never appear in the mixed All view.
7173
const drafts = useHomeDrafts({
7274
autoSelect: isDrafts,
7375
isNarrowHomeViewport,
74-
selectionEnabled: isDrafts || allowMixedSelection,
76+
selectionEnabled: isDrafts,
7577
viewportWidthPx,
7678
});
7779

‎desktop/tests/e2e/channels.spec.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2632,7 +2632,7 @@ test("Inbox All excludes generic channel traffic", async ({ page }) => {
26322632
).toHaveCount(0);
26332633
});
26342634

2635-
test("Inbox unread-only hides reminders and drafts from mixed All", async ({
2635+
test("Inbox All never lists drafts and unread-only hides reminders", async ({
26362636
page,
26372637
}) => {
26382638
const draftKey = `channel:${GENERAL_CHANNEL_ID}`;
@@ -2737,14 +2737,21 @@ test("Inbox unread-only hides reminders and drafts from mixed All", async ({
27372737
const draftRow = page.getByTestId(`home-all-drafts-${draftKey}`);
27382738
await expect(messageRow).toBeVisible();
27392739
await expect(reminderRow).toBeVisible();
2740-
await expect(draftRow).toBeVisible();
2740+
// Drafts belong to the dedicated Drafts filter — never the mixed All view.
2741+
await expect(draftRow).toHaveCount(0);
27412742

27422743
await page.getByTestId("inbox-options-trigger").click();
27432744
await page.getByRole("switch", { name: "Show unread only" }).click();
27442745

27452746
await expect(messageRow).toBeVisible();
27462747
await expect(reminderRow).toHaveCount(0);
27472748
await expect(draftRow).toHaveCount(0);
2749+
2750+
// The draft is still reachable under the Drafts filter.
2751+
await page.keyboard.press("Escape");
2752+
await page.getByTestId("inbox-filter-trigger").click();
2753+
await page.getByRole("menuitemradio", { name: "Drafts" }).click();
2754+
await expect(page.getByTestId("home-inbox-drafts")).toBeVisible();
27482755
});
27492756

27502757
test("Inbox merges a due reminder into its represented conversation", async ({

0 commit comments

Comments
 (0)