Skip to content

⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.

fix: clear completed-issue inbox notifications including unread (#660)

Karthik Kulkarnic323853d6ef0
diff --git a/apps/api/src/modules/notifications/__tests__/integration/notifications.test.ts b/apps/api/src/modules/notifications/__tests__/integration/notifications.test.ts
index 91513f96..8baff0d4 100644
--- a/apps/api/src/modules/notifications/__tests__/integration/notifications.test.ts
+++ b/apps/api/src/modules/notifications/__tests__/integration/notifications.test.ts
@@ -83,6 +83,54 @@ describe('notifications', () => {
expect(remaining.every((item) => item.readAt != null)).toBe(true);
});
+ it('completed deletes unread and read notifications, and leaves active issues alone', async () => {
+ const { owner, columnId, doneColumnId } = await setup();
+ const member = await addMember(owner);
+ const active = (await createIssue(owner.api, columnId, { assigneeUserId: member.userId }))
+ .data!;
+ const completed = (
+ await createIssue(owner.api, doneColumnId, { assigneeUserId: member.userId })
+ ).data!;
+ await owner.api.issues({ issueId: completed.id }).comments.post({ body: 'Done' } as never);
+
+ const before = (await member.api.notifications.get({ query: {} })).data!.items;
+ expect(before).toHaveLength(3);
+ expect(
+ before
+ .filter((item) => item.issueId === completed.id)
+ .map((item) => item.type)
+ .sort(),
+ ).toEqual(['assigned', 'commented']);
+ expect(before.find((item) => item.issueId === active.id)!.type).toBe('assigned');
+ expect(before.every((item) => item.readAt == null)).toBe(true);
+ await member.api.notifications['read-all'].post({ types: ['commented'] });
+
+ const assigned = await member.api.notifications.delete(undefined, {
+ query: {
+ scope: 'completed',
+ types: 'assigned',
+ includeRead: 'false',
+ includeSnoozed: 'false',
+ },
+ });
+ expect(assigned.data!.count).toBe(1);
+ const afterAssigned = (await member.api.notifications.get({ query: {} })).data!.items;
+ expect(afterAssigned.map((item) => item.issueId).sort((a, b) => a - b)).toEqual(
+ [active.id, completed.id].sort((a, b) => a - b),
+ );
+ expect(afterAssigned.find((item) => item.issueId === completed.id)!.readAt).not.toBeNull();
+ expect(afterAssigned.find((item) => item.issueId === active.id)!.readAt).toBeNull();
+
+ const all = await member.api.notifications.delete(undefined, {
+ query: { scope: 'completed', includeRead: 'false', includeSnoozed: 'false' },
+ });
+ expect(all.data!.count).toBe(1);
+ const remaining = (await member.api.notifications.get({ query: {} })).data!.items;
+ expect(remaining).toHaveLength(1);
+ expect(remaining[0].issueId).toBe(active.id);
+ expect(remaining[0].readAt).toBeNull();
+ });
+
it('bulk actions respect actor and snooze filters', async () => {
const { owner, columnId } = await setup();
const member = await addMember(owner);
diff --git a/apps/api/src/modules/notifications/index.ts b/apps/api/src/modules/notifications/index.ts
index c5689012..f1edf896 100644
--- a/apps/api/src/modules/notifications/index.ts
+++ b/apps/api/src/modules/notifications/index.ts
@@ -133,7 +133,13 @@ export const notificationRoutes = new Elysia({
{
query: deleteNotificationsQuery,
response: { 200: AffectedCountResponse, ...errors(400, 401) },
- detail: { summary: 'Delete inbox notifications' },
+ detail: {
+ summary: 'Delete inbox notifications',
+ description:
+ 'Delete the caller’s notifications by scope. completed includes read and unread ' +
+ 'notifications on completed or canceled issues; read-completed keeps only read ones. ' +
+ 'The type, actor and snooze filters narrow either scope.',
+ },
},
)
diff --git a/apps/api/src/modules/notifications/model.ts b/apps/api/src/modules/notifications/model.ts
index fc2b0118..0a38f745 100644
--- a/apps/api/src/modules/notifications/model.ts
+++ b/apps/api/src/modules/notifications/model.ts
@@ -67,9 +67,14 @@ export const markAllReadBody = t.Optional(
export const deleteNotificationsQuery = t.Object({
scope: t.Optional(
- t.Union([t.Literal('all'), t.Literal('read'), t.Literal('read-completed')], {
- description: 'Which notifications to delete. Default read.',
- }),
+ t.Union(
+ [t.Literal('all'), t.Literal('read'), t.Literal('read-completed'), t.Literal('completed')],
+ {
+ description:
+ 'Which notifications to delete. Default read. completed deletes read and unread ' +
+ 'notifications on completed or canceled issues; read-completed keeps only read ones.',
+ },
+ ),
),
projectId: t.Optional(t.String({ description: 'Scope the delete to one project.' })),
types: t.Optional(t.String()),
diff --git a/apps/api/src/modules/notifications/service.ts b/apps/api/src/modules/notifications/service.ts
index 28d3b2f8..49986071 100644
--- a/apps/api/src/modules/notifications/service.ts
+++ b/apps/api/src/modules/notifications/service.ts
@@ -448,21 +448,23 @@ export async function deleteNotification(userId: string, id: number): Promise<bo
return rows.length > 0;
}
-export type DeleteScope = 'all' | 'read' | 'read-completed';
+export type DeleteScope = 'all' | 'read' | 'read-completed' | 'completed';
-// Bulk-deletes matching notifications: all, read, or read on completed/canceled issues.
-// Returns how many were deleted.
+// Bulk-deletes matching notifications: all, read, read on completed/canceled issues,
+// or all on completed/canceled issues. Returns how many were deleted.
export async function deleteNotifications(
userId: string,
scope: DeleteScope,
projectId?: number,
filters: NotificationFilters = { includeSnoozed: true },
): Promise<number> {
- const conds = notificationConditions(userId, { ...filters, projectId });
+ // Completed deletes read and unread by design, so the inbox's show-read
+ // toggle must not narrow it.
+ const bulkFilters = scope === 'completed' ? { ...filters, includeRead: true } : filters;
+ const conds = notificationConditions(userId, { ...bulkFilters, projectId });
if (scope === 'read' || scope === 'read-completed')
conds.push(sql`${notification.readAt} is not null`);
- if (scope === 'read-completed') {
- // read notifications whose issue sits in a completed/canceled column.
+ if (scope === 'read-completed' || scope === 'completed') {
const completedIssues = db
.select({ id: issue.id })
.from(issue)
diff --git a/apps/web/messages/ar/inbox.json b/apps/web/messages/ar/inbox.json
index fdc8b3e6..fbe43633 100644
--- a/apps/web/messages/ar/inbox.json
+++ b/apps/web/messages/ar/inbox.json
@@ -10,7 +10,8 @@
"showSnoozed": "إظهار المؤجّلة",
"markAllRead": "تعليم الكل كمقروء",
"deleteAllRead": "حذف كل المقروءة",
- "deleteAllReadCompleted": "حذف كل المقروءة للمهام المكتملة",
+ "deleteAllCompleted": "حذف إشعارات المهام المكتملة",
+ "deleteAllCompletedDescription": "سيؤدي هذا إلى حذف الإشعارات المطابقة للفلاتر الحالية للمهام المكتملة أو الملغاة، بما في ذلك غير المقروءة. لا يمكن التراجع عن هذا الإجراء.",
"types": {
"assigned": "مُسنَدة",
"mentioned": "إشارة إليك",
diff --git a/apps/web/messages/en/inbox.json b/apps/web/messages/en/inbox.json
index 93db67ba..d7ae2b33 100644
--- a/apps/web/messages/en/inbox.json
+++ b/apps/web/messages/en/inbox.json
@@ -10,7 +10,8 @@
"showSnoozed": "Show snoozed",
"markAllRead": "Mark all as read",
"deleteAllRead": "Delete all read",
- "deleteAllReadCompleted": "Delete all read for completed issues",
+ "deleteAllCompleted": "Delete for completed issues",
+ "deleteAllCompletedDescription": "This deletes the notifications for completed or canceled issues that match the current filters, including unread ones. This cannot be undone.",
"types": {
"assigned": "Assigned",
"mentioned": "Mentioned",
diff --git a/apps/web/messages/es-ES/inbox.json b/apps/web/messages/es-ES/inbox.json
index 4f6759a1..35768058 100644
--- a/apps/web/messages/es-ES/inbox.json
+++ b/apps/web/messages/es-ES/inbox.json
@@ -10,7 +10,8 @@
"showSnoozed": "Mostrar pospuestas",
"markAllRead": "Marcar todas como leídas",
"deleteAllRead": "Eliminar todas las leídas",
- "deleteAllReadCompleted": "Eliminar las leídas de tickets completados",
+ "deleteAllCompleted": "Eliminar notificaciones de tickets completados",
+ "deleteAllCompletedDescription": "Esto elimina las notificaciones de tickets completados o cancelados que coinciden con los filtros actuales, incluidas las no leídas. No se puede deshacer.",
"types": {
"assigned": "Asignación",
"mentioned": "Mención",
diff --git a/apps/web/messages/fa/inbox.json b/apps/web/messages/fa/inbox.json
index abb2ffac..c76be882 100644
--- a/apps/web/messages/fa/inbox.json
+++ b/apps/web/messages/fa/inbox.json
@@ -10,7 +10,8 @@
"showSnoozed": "به‌تعویق‌افتاده‌ها را نشان بده",
"markAllRead": "علامت‌گذاری همه به‌عنوان خوانده‌شده",
"deleteAllRead": "حذف همه موارد خوانده‌شده",
- "deleteAllReadCompleted": "حذف همه موارد خوانده‌شده برای تسک‌های تکمیل‌شده",
+ "deleteAllCompleted": "حذف اعلان‌های تسک‌های تکمیل‌شده",
+ "deleteAllCompletedDescription": "اعلان‌های تسک‌های تکمیل‌شده یا لغوشده که با فیلترهای فعلی مطابقت دارند، از جمله خوانده‌نشده‌ها، حذف می‌شوند. این کار قابل بازگشت نیست.",
"types": {
"assigned": "ارجاع‌شده",
"mentioned": "منشن‌شده",
diff --git a/apps/web/messages/fr/inbox.json b/apps/web/messages/fr/inbox.json
index 81636194..9e521708 100644
--- a/apps/web/messages/fr/inbox.json
+++ b/apps/web/messages/fr/inbox.json
@@ -10,7 +10,8 @@
"showSnoozed": "Afficher les notifications reportées",
"markAllRead": "Tout marquer comme lu",
"deleteAllRead": "Supprimer toutes les notifications lues",
- "deleteAllReadCompleted": "Supprimer les notifications lues des tickets terminés",
+ "deleteAllCompleted": "Supprimer les notifications des tickets terminés",
+ "deleteAllCompletedDescription": "Cela supprime les notifications des tickets terminés ou annulés qui correspondent aux filtres actuels, y compris celles non lues. Cette action est irréversible.",
"types": {
"assigned": "Assigné",
"mentioned": "Mentionné",
diff --git a/apps/web/messages/id/inbox.json b/apps/web/messages/id/inbox.json
index 131cd83b..219e84fb 100644
--- a/apps/web/messages/id/inbox.json
+++ b/apps/web/messages/id/inbox.json
@@ -10,7 +10,8 @@
"showSnoozed": "Tampilkan yang ditunda",
"markAllRead": "Tandai semua sudah dibaca",
"deleteAllRead": "Hapus semua yang sudah dibaca",
- "deleteAllReadCompleted": "Hapus semua yang sudah dibaca untuk issue yang telah selesai",
+ "deleteAllCompleted": "Hapus notifikasi untuk issue yang telah selesai",
+ "deleteAllCompletedDescription": "Notifikasi untuk issue yang selesai atau dibatalkan yang cocok dengan filter saat ini, termasuk yang belum dibaca, akan dihapus. Tindakan ini tidak dapat dibatalkan.",
"types": {
"assigned": "Ditetapkan",
"mentioned": "Disebutkan",
diff --git a/apps/web/messages/ko/inbox.json b/apps/web/messages/ko/inbox.json
index 6f124cc0..314eb34c 100644
--- a/apps/web/messages/ko/inbox.json
+++ b/apps/web/messages/ko/inbox.json
@@ -10,7 +10,8 @@
"showSnoozed": "나중에 알림 표시",
"markAllRead": "모두 읽음으로 표시",
"deleteAllRead": "읽은 알림 모두 삭제",
- "deleteAllReadCompleted": "완료된 이슈의 읽은 알림 모두 삭제",
+ "deleteAllCompleted": "완료된 이슈의 알림 삭제",
+ "deleteAllCompletedDescription": "현재 필터와 일치하는 완료되었거나 취소된 이슈의 알림(읽지 않은 알림 포함)이 삭제됩니다. 이 작업은 되돌릴 수 없습니다.",
"types": {
"assigned": "담당자로 지정됨",
"mentioned": "멘션됨",
diff --git a/apps/web/messages/pt-BR/inbox.json b/apps/web/messages/pt-BR/inbox.json
index 56663fa7..5de0861f 100644
--- a/apps/web/messages/pt-BR/inbox.json
+++ b/apps/web/messages/pt-BR/inbox.json
@@ -10,7 +10,8 @@
"showSnoozed": "Mostrar adiadas",
"markAllRead": "Marcar todas como lidas",
"deleteAllRead": "Excluir todas as lidas",
- "deleteAllReadCompleted": "Excluir todas as lidas de issues concluídas",
+ "deleteAllCompleted": "Excluir notificações de issues concluídas",
+ "deleteAllCompletedDescription": "As notificações de issues concluídas ou canceladas que correspondem aos filtros atuais, incluindo as não lidas, serão excluídas. Esta ação não pode ser desfeita.",
"types": {
"assigned": "Atribuído",
"mentioned": "Mencionado",
diff --git a/apps/web/messages/ru/inbox.json b/apps/web/messages/ru/inbox.json
index 3d235f60..dc658576 100644
--- a/apps/web/messages/ru/inbox.json
+++ b/apps/web/messages/ru/inbox.json
@@ -10,7 +10,8 @@
"showSnoozed": "Показывать отложенные",
"markAllRead": "Отметить все прочитанными",
"deleteAllRead": "Удалить все прочитанные",
- "deleteAllReadCompleted": "Удалить прочитанные для завершённых задач",
+ "deleteAllCompleted": "Удалить уведомления по завершённым задачам",
+ "deleteAllCompletedDescription": "Будут удалены уведомления по завершённым или отменённым задачам, соответствующие текущим фильтрам, включая непрочитанные. Это действие нельзя отменить.",
"types": {
"assigned": "Назначено",
"mentioned": "Упоминание",
diff --git a/apps/web/messages/tr/inbox.json b/apps/web/messages/tr/inbox.json
index e491f5df..ad55c944 100644
--- a/apps/web/messages/tr/inbox.json
+++ b/apps/web/messages/tr/inbox.json
@@ -10,7 +10,8 @@
"showSnoozed": "Ertelenenleri göster",
"markAllRead": "Tümünü okundu olarak işaretle",
"deleteAllRead": "Okunanların tümünü sil",
- "deleteAllReadCompleted": "Tamamlanan işlerin okunan bildirimlerini sil",
+ "deleteAllCompleted": "Tamamlanan işlerin bildirimlerini sil",
+ "deleteAllCompletedDescription": "Mevcut filtrelerle eşleşen tamamlanan veya iptal edilen işlerin okunmamışlar dahil tüm bildirimleri silinir. Bu işlem geri alınamaz.",
"types": {
"assigned": "Atandı",
"mentioned": "Bahsedildi",
diff --git a/apps/web/messages/uk/inbox.json b/apps/web/messages/uk/inbox.json
index eae18961..3b4211b6 100644
--- a/apps/web/messages/uk/inbox.json
+++ b/apps/web/messages/uk/inbox.json
@@ -10,7 +10,8 @@
"showSnoozed": "Показувати відкладені",
"markAllRead": "Позначити всі прочитаними",
"deleteAllRead": "Видалити всі прочитані",
- "deleteAllReadCompleted": "Видалити прочитані для завершених задач",
+ "deleteAllCompleted": "Видалити сповіщення для завершених задач",
+ "deleteAllCompletedDescription": "Буде видалено сповіщення для завершених або скасованих задач, що відповідають поточним фільтрам, зокрема непрочитані. Цю дію не можна скасувати.",
"types": {
"assigned": "Призначено",
"mentioned": "Згадано",
diff --git a/apps/web/messages/zh-CN/inbox.json b/apps/web/messages/zh-CN/inbox.json
index d2e2db16..66e6b7c3 100644
--- a/apps/web/messages/zh-CN/inbox.json
+++ b/apps/web/messages/zh-CN/inbox.json
@@ -10,7 +10,8 @@
"showSnoozed": "显示已稍后提醒的通知",
"markAllRead": "全部标为已读",
"deleteAllRead": "删除所有已读通知",
- "deleteAllReadCompleted": "删除已完成工作项的所有已读通知",
+ "deleteAllCompleted": "删除已完成工作项的通知",
+ "deleteAllCompletedDescription": "这将删除符合当前筛选条件的已完成或已取消工作项的通知,包括未读通知。此操作无法撤销。",
"types": {
"assigned": "已指派",
"mentioned": "已提及",
diff --git a/apps/web/messages/zh-TW/inbox.json b/apps/web/messages/zh-TW/inbox.json
index 27808115..770ac305 100644
--- a/apps/web/messages/zh-TW/inbox.json
+++ b/apps/web/messages/zh-TW/inbox.json
@@ -10,7 +10,8 @@
"showSnoozed": "顯示已稍後提醒的通知",
"markAllRead": "全部標為已讀",
"deleteAllRead": "刪除所有已讀通知",
- "deleteAllReadCompleted": "刪除已完成工作項目的所有已讀通知",
+ "deleteAllCompleted": "刪除已完成工作項目的通知",
+ "deleteAllCompletedDescription": "這會刪除符合目前篩選條件的已完成或已取消工作項目通知,包括未讀通知。此操作無法復原。",
"types": {
"assigned": "已指派",
"mentioned": "已提及",
diff --git a/apps/web/src/features/inbox/components/InboxDeleteCompletedDialog.tsx b/apps/web/src/features/inbox/components/InboxDeleteCompletedDialog.tsx
new file mode 100644
index 00000000..e0e0c36e
--- /dev/null
+++ b/apps/web/src/features/inbox/components/InboxDeleteCompletedDialog.tsx
@@ -0,0 +1,29 @@
+'use client';
+
+import { useTranslations } from 'next-intl';
+import ConfirmDialog from '@/components/common/overlay/ConfirmDialog';
+
+export default function InboxDeleteCompletedDialog({
+ onConfirm,
+ onClose,
+}: {
+ onConfirm: () => Promise<void>;
+ onClose: () => void;
+}) {
+ const t = useTranslations('inbox');
+ const tCommon = useTranslations('common');
+
+ return (
+ <ConfirmDialog
+ title={t('deleteAllCompleted')}
+ confirmLabel={tCommon('delete')}
+ onConfirm={async () => {
+ await onConfirm();
+ onClose();
+ }}
+ onClose={onClose}
+ >
+ <p className="text-sm text-muted-foreground">{t('deleteAllCompletedDescription')}</p>
+ </ConfirmDialog>
+ );
+}
diff --git a/apps/web/src/features/inbox/components/InboxToolbar.tsx b/apps/web/src/features/inbox/components/InboxToolbar.tsx
index 4e23031d..6a81e6a2 100644
--- a/apps/web/src/features/inbox/components/InboxToolbar.tsx
+++ b/apps/web/src/features/inbox/components/InboxToolbar.tsx
@@ -1,9 +1,11 @@
'use client';
+import { useState } from 'react';
import { CheckCheck, ListFilter, MoreHorizontal, SlidersHorizontal, Trash2 } from 'lucide-react';
import { useTranslations } from 'next-intl';
import type { NotificationFilters, NotificationType } from '@/lib/api/endpoints/notifications';
import { Button } from '@/components/ui/button';
+import InboxDeleteCompletedDialog from './InboxDeleteCompletedDialog';
import {
DropdownMenu,
DropdownMenuCheckboxItem,
@@ -24,17 +26,18 @@ export default function InboxToolbar({
onFiltersChange,
onMarkAllRead,
onDeleteRead,
- onDeleteReadCompleted,
+ onDeleteCompleted,
}: {
unread: number;
filters: NotificationFilters;
onFiltersChange: (next: NotificationFilters) => void;
onMarkAllRead: () => void;
onDeleteRead: () => void;
- onDeleteReadCompleted: () => void;
+ onDeleteCompleted: () => Promise<void>;
}) {
const t = useTranslations('inbox');
const tCommon = useTranslations('common');
+ const [confirmingDeleteCompleted, setConfirmingDeleteCompleted] = useState(false);
const selectedTypes = filters.types ?? [];
const toggleType = (type: NotificationType) => {
@@ -112,13 +115,20 @@ export default function InboxToolbar({
<Trash2 />
{t('deleteAllRead')}
</DropdownMenuItem>
- <DropdownMenuItem onSelect={onDeleteReadCompleted}>
+ <DropdownMenuItem onSelect={() => setConfirmingDeleteCompleted(true)}>
<Trash2 />
- {t('deleteAllReadCompleted')}
+ {t('deleteAllCompleted')}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
+
+ {confirmingDeleteCompleted && (
+ <InboxDeleteCompletedDialog
+ onConfirm={onDeleteCompleted}
+ onClose={() => setConfirmingDeleteCompleted(false)}
+ />
+ )}
</div>
);
}
diff --git a/apps/web/src/features/inbox/components/InboxView.tsx b/apps/web/src/features/inbox/components/InboxView.tsx
index f2cf25de..cc933bba 100644
--- a/apps/web/src/features/inbox/components/InboxView.tsx
+++ b/apps/web/src/features/inbox/components/InboxView.tsx
@@ -71,9 +71,9 @@ export default function InboxView({ project }: { project: ProjectDetail }) {
onFiltersChange={changeFilters}
onMarkAllRead={() => markAllRead.mutate(filters)}
onDeleteRead={() => deleteNotifications.mutate({ scope: 'read', filters })}
- onDeleteReadCompleted={() =>
- deleteNotifications.mutate({ scope: 'read-completed', filters })
- }
+ onDeleteCompleted={async () => {
+ await deleteNotifications.mutateAsync({ scope: 'completed', filters });
+ }}
/>
<InboxList
items={items}
diff --git a/apps/web/src/lib/api/endpoints/notifications.ts b/apps/web/src/lib/api/endpoints/notifications.ts
index 7c4204e9..3876fdad 100644
--- a/apps/web/src/lib/api/endpoints/notifications.ts
+++ b/apps/web/src/lib/api/endpoints/notifications.ts
@@ -42,7 +42,7 @@ export interface NotificationFilters {
includeSnoozed?: boolean;
}
-export type NotificationDeleteScope = 'all' | 'read' | 'read-completed';
+export type NotificationDeleteScope = 'all' | 'read' | 'read-completed' | 'completed';
// Inbox notifications. The list is the session user's own; projectId scopes it to
// one project (the per-project inbox). cursor is the JSON-encoded keyset from the