From 8a9ae0102db257af7fa61a69e4e702058d9f4f14 Mon Sep 17 00:00:00 2001 From: Naiyuan Qing <145280634+NevilleQingNY@users.noreply.github.com> Date: Sat, 28 Mar 2026 22:03:46 +0800 Subject: [PATCH] fix(comments): cascade delete replies when parent comment is deleted When a parent comment is deleted, remove all its replies from the timeline instead of promoting them to top-level (orphaned replies have no context). Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/web/features/issues/components/issue-detail.tsx | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/apps/web/features/issues/components/issue-detail.tsx b/apps/web/features/issues/components/issue-detail.tsx index d1df85f5..89b68ed5 100644 --- a/apps/web/features/issues/components/issue-detail.tsx +++ b/apps/web/features/issues/components/issue-detail.tsx @@ -316,11 +316,7 @@ export function IssueDetail({ issueId, onDelete }: IssueDetailProps) { try { await api.deleteComment(commentId); setTimeline((prev) => - prev - // Promote replies of deleted comment to top-level - .map((e) => e.parent_id === commentId ? { ...e, parent_id: null } : e) - // Remove the deleted comment - .filter((e) => e.id !== commentId) + prev.filter((e) => e.id !== commentId && e.parent_id !== commentId) ); } catch { toast.error("Failed to delete comment"); @@ -386,9 +382,7 @@ export function IssueDetail({ issueId, onDelete }: IssueDetailProps) { const { comment_id, issue_id } = payload as CommentDeletedPayload; if (issue_id === id) { setTimeline((prev) => - prev - .map((e) => e.parent_id === comment_id ? { ...e, parent_id: null } : e) - .filter((e) => e.id !== comment_id) + prev.filter((e) => e.id !== comment_id && e.parent_id !== comment_id) ); } }, [id]),