Skip to content

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

Go

MUL-7339: fix(comments): stop rendering a placeholder for a deleted reply (#8371)

Bohan Jiang49cd223046a0
diff --git a/apps/docs/content/docs/comments.ja.mdx b/apps/docs/content/docs/comments.ja.mdx
index f61609d73a..9ac92f12c4 100644
--- a/apps/docs/content/docs/comments.ja.mdx
+++ b/apps/docs/content/docs/comments.ja.mdx
@@ -60,7 +60,7 @@ Web と Desktop では、自分を含む誰のコメントでも選択して選
コメントを編集すると、Multica は新しい内容でトリガーを再計算します。編集で追加した @メンションも同様に実行を作成します。保存前に、入力欄の下にトリガープレビューが表示されます。
<Callout type="warning">
-コメントの削除は元に戻せません。削除されるのはそのコメントだけです。返信がある場合、返信はスレッドに残り、元の位置には「このコメントは削除されました」と表示されます。内容が間違っている場合は編集してください。
+コメントの削除は元に戻せません。削除されるのはそのコメントだけです。返信がある場合、返信はスレッドに残り、削除されたコメントは跡を残しません。例外はスレッドの最初のコメントで、返信がぶら下がるため、元の位置に「このコメントは削除されました」と表示されます。内容が間違っている場合は編集してください。
</Callout>
## 次のステップ
diff --git a/apps/docs/content/docs/comments.ko.mdx b/apps/docs/content/docs/comments.ko.mdx
index ac18e83a91..7fb9896a89 100644
--- a/apps/docs/content/docs/comments.ko.mdx
+++ b/apps/docs/content/docs/comments.ko.mdx
@@ -60,7 +60,7 @@ Web과 Desktop에서 본인 댓글을 포함한 모든 댓글의 텍스트를
댓글을 수정하면 Multica가 새 내용을 기준으로 트리거를 다시 계산합니다. 수정하면서 새로 추가한 @멘션도 실행을 생성하며, 저장하기 전에 입력란 아래에 트리거 미리보기가 표시됩니다.
<Callout type="warning">
-댓글 삭제는 취소할 수 없습니다. 해당 댓글만 삭제되며, 답글이 있으면 답글은 스레드에 남고 원래 자리에는 "삭제된 댓글입니다"가 표시됩니다. 내용이 잘못되었다면 수정하세요.
+댓글 삭제는 취소할 수 없습니다. 해당 댓글만 삭제되며, 답글이 있으면 답글은 스레드에 남고 삭제된 댓글은 흔적을 남기지 않습니다. 예외는 스레드를 시작한 댓글로, 답글이 그 아래에 달리므로 원래 자리에 "삭제된 댓글입니다"가 표시됩니다. 내용이 잘못되었다면 수정하세요.
</Callout>
## 다음 단계
diff --git a/apps/docs/content/docs/comments.mdx b/apps/docs/content/docs/comments.mdx
index fec87bbf50..1037ba3492 100644
--- a/apps/docs/content/docs/comments.mdx
+++ b/apps/docs/content/docs/comments.mdx
@@ -60,7 +60,7 @@ Comment authors can edit or delete their own comments; workspace `owner`s and `a
After a comment is edited, Multica recalculates triggers from the new content. @-mentions added during the edit create runs too; the trigger preview shows under the input before you save.
<Callout type="warning">
-Deleting a comment cannot be undone. Only that comment is deleted: if it has replies, they stay in the thread under a "This comment was deleted" placeholder. If the content is wrong, edit it instead.
+Deleting a comment cannot be undone. Only that comment is deleted: if it has replies, they stay in the thread and the deleted comment leaves no trace. The exception is the comment that starts a thread — it keeps a "This comment was deleted" placeholder, since its replies hang off it. If the content is wrong, edit it instead.
</Callout>
## Next steps
diff --git a/apps/docs/content/docs/comments.zh.mdx b/apps/docs/content/docs/comments.zh.mdx
index ee778eac63..5de638ee65 100644
--- a/apps/docs/content/docs/comments.zh.mdx
+++ b/apps/docs/content/docs/comments.zh.mdx
@@ -60,7 +60,7 @@ import { Callout } from "fumadocs-ui/components/callout";
编辑评论后,Multica 会按新内容重新计算触发。编辑时新增的 @提及同样会创建运行;保存前输入框下方会显示触发预览。
<Callout type="warning">
-删除评论无法撤销。删除只作用于这一条评论:如果它有回复,回复会保留在讨论中,原位置显示“评论已删除”。内容有误时编辑即可。
+删除评论无法撤销。删除只作用于这一条评论:如果它有回复,回复会保留在讨论中,被删除的评论不留痕迹。例外是讨论的第一条评论,它的回复挂在它下面,因此原位置保留“评论已删除”。内容有误时编辑即可。
</Callout>
## 接下来
diff --git a/apps/mobile/components/issue/comment-card.tsx b/apps/mobile/components/issue/comment-card.tsx
index 77cb335a03..cec46c737d 100644
--- a/apps/mobile/components/issue/comment-card.tsx
+++ b/apps/mobile/components/issue/comment-card.tsx
@@ -33,7 +33,10 @@ import Animated, {
} from "react-native-reanimated";
import { Ionicons } from "@expo/vector-icons";
import type { Reaction, TimelineEntry } from "@multica/core/types";
-import { isDeletedComment } from "@multica/core/issues/comment-deletion";
+import {
+ commentLandingTarget,
+ isDeletedComment,
+} from "@multica/core/issues/comment-deletion";
import { Text } from "@/components/ui/text";
import { ActorAvatar } from "@/components/ui/actor-avatar";
import { useActorLookup } from "@/data/use-actor-name";
@@ -127,6 +130,16 @@ export function CommentCard({
}
}, [resolved, highlightedCommentId, entry.id, replies]);
+ const visibleReplies = replies.filter((reply) => !isDeletedComment(reply));
+ // A deleted reply renders nothing, so a notification pointing at one has no
+ // row to flash. Flash the comment just above where it was instead — the
+ // expansion above still keys off the original id, which is in this thread
+ // either way. Web does the same in its deep-link effect
+ // (packages/views/issues/components/issue-detail.tsx).
+ const highlightId = highlightedCommentId
+ ? commentLandingTarget(highlightedCommentId, entry.id, replies)
+ : highlightedCommentId;
+
if (resolved && !expanded) {
return (
<ResolvedThreadBar
@@ -174,7 +187,12 @@ export function CommentCard({
issueIdentifier={issueIdentifier}
onPressChange={handlePressChange}
/>
- {replies.map((reply) => (
+ {/* A deleted reply renders nothing: its row is kept only so its own
+ * replies keep a direct parent (#8296), and this list is flat, so
+ * they already render in its place. Mirrors the reply list in
+ * packages/views/issues/components/comment-card.tsx. A deleted ROOT
+ * still renders its placeholder — it heads the thread. */}
+ {visibleReplies.map((reply) => (
<View key={reply.id} className="border-t border-border/60 pt-3">
<CommentBody
entry={reply}
@@ -183,12 +201,12 @@ export function CommentCard({
onPressChange={handlePressChange}
/>
<ReplyHighlightOverlay
- active={highlightedCommentId === reply.id}
+ active={highlightId === reply.id}
/>
</View>
))}
</View>
- <RootHighlightOverlay active={highlightedCommentId === entry.id} />
+ <RootHighlightOverlay active={highlightId === entry.id} />
</View>
</View>
);
@@ -244,7 +262,9 @@ function ResolvedThreadBar({
return remaining > 0 ? `${named} +${remaining}` : named;
}, [entry, replies, getName]);
- const total = 1 + replies.length;
+ // Deleted replies render nothing when the thread expands, so the folded
+ // count must not promise them either.
+ const total = 1 + replies.filter((reply) => !isDeletedComment(reply)).length;
return (
<View className="px-4">
@@ -488,9 +508,10 @@ function CommentBody({
}, [longPress.isPressed, entry.id, isSelecting, onPressChange]);
if (isDeletedComment(entry)) {
- // Kept only so the replies to it stay attached (#8296): no author, body
- // or long-press actions. Mirrors CommentRow's placeholder in
- // packages/views/issues/components/comment-card.tsx.
+ // Only a deleted thread ROOT reaches this — the card filters deleted
+ // replies out. The root keeps a placeholder because its replies hang off
+ // it and the thread would otherwise have no head. Mirrors the root
+ // placeholder in packages/views/issues/components/comment-card.tsx.
return (
<Text className="text-sm italic text-muted-foreground">
This comment was deleted
diff --git a/packages/core/issues/comment-deletion.test.ts b/packages/core/issues/comment-deletion.test.ts
index a7ff4a06af..9b57a7e4f0 100644
--- a/packages/core/issues/comment-deletion.test.ts
+++ b/packages/core/issues/comment-deletion.test.ts
@@ -1,7 +1,12 @@
// @vitest-environment node
import { describe, expect, it } from "vitest";
import type { TimelineEntry } from "../types";
-import { applyCommentDeletion, isDeletedComment, removeCommentSubtree } from "./comment-deletion";
+import {
+ applyCommentDeletion,
+ commentLandingTarget,
+ isDeletedComment,
+ removeCommentSubtree,
+} from "./comment-deletion";
const DELETED_AT = "2026-09-11T08:00:00Z";
@@ -95,3 +100,29 @@ describe("removeCommentSubtree", () => {
expect(ids(removeCommentSubtree(timeline, "a"))).toEqual(["d"]);
});
});
+
+describe("commentLandingTarget", () => {
+ const tombstone = (id: string) => comment(id, "root", { content: "", deleted_at: DELETED_AT });
+ const live = (id: string) => comment(id, "root");
+
+ it("lands on the visible reply above a tombstone", () => {
+ const replies = [live("r1"), tombstone("r2"), live("r3")];
+ expect(commentLandingTarget("r2", "root", replies)).toBe("r1");
+ });
+
+ it("skips back over consecutive tombstones", () => {
+ const replies = [live("r1"), tombstone("r2"), tombstone("r3")];
+ expect(commentLandingTarget("r3", "root", replies)).toBe("r1");
+ });
+
+ it("falls back to the thread root when nothing visible precedes the tombstone", () => {
+ expect(commentLandingTarget("r1", "root", [tombstone("r1"), live("r2")])).toBe("root");
+ });
+
+ it.each([
+ ["a live reply", "r2", [live("r1"), live("r2")]],
+ ["an id the thread does not hold — a root, or a comment outside the cache", "root", [live("r1")]],
+ ])("leaves %s as its own target", (_case, target, replies: TimelineEntry[]) => {
+ expect(commentLandingTarget(target, "root", replies)).toBe(target);
+ });
+});
diff --git a/packages/core/issues/comment-deletion.ts b/packages/core/issues/comment-deletion.ts
index 58b9eeb98f..5e3fd60b1f 100644
--- a/packages/core/issues/comment-deletion.ts
+++ b/packages/core/issues/comment-deletion.ts
@@ -3,13 +3,38 @@ import type { TimelineEntry } from "@multica/core/types";
/**
* True for a comment deleted while it still had replies (#8296). The server
* keeps its row as a tombstone — empty content, no attachments, reactions or
- * resolution — so every reply keeps its direct parent. Clients render a
- * placeholder in its place and offer no actions on it.
+ * resolution — so every reply keeps its direct parent. Clients render nothing
+ * in its place: the replies it held render flat, where it was. The one
+ * exception is a thread ROOT, which keeps a placeholder as the thread's head.
*/
export function isDeletedComment(entry: { deleted_at?: string | null }): boolean {
return typeof entry.deleted_at === "string" && entry.deleted_at !== "";
}
+/**
+ * The comment a deep link should land on. A deleted REPLY renders nothing, so
+ * an inbox notification or a share link that names one has no anchor to scroll
+ * to and no row to flash: land on the comment just above where it was — the
+ * nearest visible reply before it, or the thread root when it had none. The
+ * original id stays the notification's identity; only the landing moves.
+ *
+ * Any other id is its own target, including a deleted ROOT — that one still
+ * renders. `replies` must be the thread's replies in render order.
+ */
+export function commentLandingTarget(
+ commentId: string,
+ rootId: string,
+ replies: readonly TimelineEntry[],
+): string {
+ const index = replies.findIndex((reply) => reply.id === commentId);
+ if (index < 0 || !isDeletedComment(replies[index]!)) return commentId;
+ for (let i = index - 1; i >= 0; i--) {
+ const previous = replies[i]!;
+ if (!isDeletedComment(previous)) return previous.id;
+ }
+ return rootId;
+}
+
function hasReplies(entries: readonly TimelineEntry[], commentId: string): boolean {
return entries.some((e) => e.type === "comment" && e.parent_id === commentId);
}
diff --git a/packages/views/issues/components/comment-card-deleted.test.tsx b/packages/views/issues/components/comment-card-deleted.test.tsx
index 5463f27920..77a02910b0 100644
--- a/packages/views/issues/components/comment-card-deleted.test.tsx
+++ b/packages/views/issues/components/comment-card-deleted.test.tsx
@@ -6,9 +6,10 @@ import type { TimelineEntry } from "@multica/core/types";
import { renderWithI18n } from "../../test/i18n";
// #8296: deleting a comment keeps its replies. A comment deleted while it had
-// replies arrives as a tombstone (`deleted_at` set, empty body) and renders as
-// a placeholder with no actions. The cache rules live in
-// packages/core/issues/comment-deletion.test.ts.
+// replies arrives as a tombstone (`deleted_at` set, empty body). A tombstoned
+// REPLY renders nothing — the replies it held already render in its place; a
+// tombstoned ROOT keeps a placeholder, since it heads the thread. The cache
+// rules live in packages/core/issues/comment-deletion.test.ts.
vi.mock("@multica/core/api", () => ({
api: { uploadFile: vi.fn() },
@@ -98,15 +99,27 @@ function renderThread(root: TimelineEntry, replies: TimelineEntry[]) {
const actionMenus = () => screen.queryAllByRole("button", { name: "Comment actions" });
describe("CommentCard — deleted comments", () => {
- it("renders a deleted reply as a placeholder and keeps the replies to it", () => {
- renderThread(comment("a", null), [tombstone("bb", "a"), comment("ccc", "bb")]);
+ it("renders no row for a deleted reply and keeps the replies to it", () => {
+ const { container } = renderThread(comment("a", null), [tombstone("bb", "a"), comment("ccc", "bb")]);
- expect(screen.getByText("This comment was deleted")).toBeTruthy();
+ expect(screen.queryByText("This comment was deleted")).toBeNull();
expect(screen.getByText("body ccc")).toBeTruthy();
- // Root and the live reply keep their actions; the placeholder has none.
+ // No leftover chrome either: the root and the live reply are the only rows.
+ expect(container.querySelectorAll("[data-comment-block]")).toHaveLength(2);
expect(actionMenus()).toHaveLength(2);
});
+ it("leaves a deleted reply out of the folded count", () => {
+ renderThread(comment("a", null), [
+ tombstone("bb", "a"),
+ comment("ccc", "bb"),
+ comment("dddd", "a", { resolved_at: "2026-09-11T09:00:00Z" }),
+ ]);
+
+ // "ccc" folds behind the bar; the tombstone is not a comment to count.
+ expect(screen.getByText("1 comment from Ada")).toBeTruthy();
+ });
+
it("renders a deleted root as a placeholder and keeps the thread open for replies", () => {
renderThread(tombstone("a", null), [comment("bb", "a")]);
diff --git a/packages/views/issues/components/comment-card.tsx b/packages/views/issues/components/comment-card.tsx
index 69824e5575..484f6c730a 100644
--- a/packages/views/issues/components/comment-card.tsx
+++ b/packages/views/issues/components/comment-card.tsx
@@ -651,15 +651,12 @@ function CommentRow({
const reactions = entry.reactions ?? [];
- if (isDeletedComment(entry)) {
- // Kept only so the replies to it stay attached (#8296): nothing is left
- // to show or act on.
- return (
- <div data-comment-block className="py-3 pl-12 pr-4 max-md:pl-3 max-md:pr-3 text-body italic text-muted-foreground">
- {t(($) => $.comment.deleted_placeholder)}
- </div>
- );
- }
+ // A deleted reply renders nothing at all. Its row is kept only so the
+ // replies to it keep a direct parent (#8296), and the thread renders those
+ // replies flat, in its place — a placeholder row would say nothing they do
+ // not already say. Callers drop this row's chrome too, so the thread shows
+ // no empty divider where it was.
+ if (isDeletedComment(entry)) return null;
return (
<div data-comment-block className="pb-3">
@@ -902,14 +899,20 @@ export function AgentRunComment({ run, standalone = false, commentProps, enterin
commentProps?: CommentCardProps;
}) {
const viewState = useInlineCommentRunState();
- const reply = commentProps?.entry;
+ const replyEntry = commentProps?.entry;
+ // A deleted reply renders nothing in a run slot either (see CommentRow), so
+ // the slot falls back to the run's own activity block: the run happened, and
+ // it still carries `hasReply`, so it never prints the deleted body as its
+ // output. A deleted thread ROOT keeps rendering — it heads its own thread.
+ const replyHidden = !standalone && !!replyEntry && isDeletedComment(replyEntry);
+ const reply = replyHidden ? undefined : replyEntry;
const motionRef = useRunCommentMotion(entering, reply?.id, run.task.status);
return (
<div ref={motionRef} data-run-slot-id={run.task.id}
data-run-comment-id={!reply ? run.task.id : undefined}
id={!standalone && reply ? `comment-${reply.id}` : undefined}
className={cn(standalone ? !reply && "rounded-xl border bg-card" : "border-t border-border/50", !reply && "py-1.5", reply && commentProps?.highlightedCommentId === reply.id && highlightedCommentBackgroundClass)}>
- {commentProps ? standalone ? (
+ {commentProps && reply ? standalone ? (
<CommentCard {...commentProps} runs={commentProps.runs ?? [run]} runViewState={viewState} />
) : (
<CommentRow {...commentProps}
@@ -990,6 +993,11 @@ function CommentCardImpl({
const [confirmDelete, setConfirmDelete] = useState(false);
const allNestedReplies = replies;
+ // What the thread shows. Tombstones are excluded from display and counts but
+ // stay in `allNestedReplies`, which run anchoring and "has replies" reason
+ // over. Every tombstone has at least one live descendant (the server prunes
+ // one that loses its last reply), so no content hides behind this.
+ const visibleReplies = allNestedReplies.filter((reply) => !isDeletedComment(reply));
const slottedReplyIds = new Set(runs.filter((run) => run.hasReply && run.anchorCommentId && run.commentId !== entry.id)
.map((run) => run.commentId));
const renderRuns = (commentId: string, presentation: "inline" | "header" = "inline") => runs.filter((run) => run.commentId === commentId && run.hasReply
@@ -1007,7 +1015,7 @@ function CommentCardImpl({
} : undefined} />{reply && reply.id !== commentId && renderAnchoredRuns(reply.id)}</Fragment>;
});
- const replyCount = allNestedReplies.length;
+ const replyCount = visibleReplies.length;
const repliedToIds = new Set(allNestedReplies.map((reply) => reply.parent_id));
const deleted = isDeletedComment(entry);
const contentPreview = (entry.content ?? "").replace(/\n/g, " ").slice(0, 80);
@@ -1024,8 +1032,8 @@ function CommentCardImpl({
const threadExpanded = !!expandedResolvedIds?.has(entry.id);
const replyFolded = replyResolutionId != null && !threadExpanded;
const foldedReplies = replyResolutionId
- ? allNestedReplies.filter((r) => r.id !== replyResolutionId)
- : allNestedReplies;
+ ? visibleReplies.filter((r) => r.id !== replyResolutionId)
+ : visibleReplies;
const resolutionReply = replyResolutionId
? allNestedReplies.find((r) => r.id === replyResolutionId) ?? null
: null;
@@ -1397,30 +1405,34 @@ function CommentCardImpl({
{/* Replies — chronological; the resolution keeps its place with a badge */}
{allNestedReplies.filter((reply) => !slottedReplyIds.has(reply.id)).map((reply) => (
<Fragment key={reply.id}>
- <div
- id={`comment-${reply.id}`}
- className={cn(
- "border-t border-border/50 transition-colors duration-700",
- highlightedCommentId === reply.id && highlightedCommentBackgroundClass,
- )}
- >
- <CommentRow
- issueId={issueId}
- entry={reply}
- runHeader={renderRuns(reply.id, "header")}
- runMetadata={renderRuns(reply.id)}
- currentUserId={currentUserId}
- canModerate={canModerate}
- isResolution={reply.id === replyResolutionId}
- isHighlighted={highlightedCommentId === reply.id}
- hasReplies={repliedToIds.has(reply.id)}
- onEdit={onEdit}
- onDelete={onDelete}
- onToggleReaction={onToggleReaction}
- onCreateSubIssue={onCreateSubIssue}
- onResolveToggle={onResolveToggle}
- />
- </div>
+ {/* A tombstone keeps its place in the walk — runs anchored to
+ it still render — but contributes no row of its own. */}
+ {!isDeletedComment(reply) && (
+ <div
+ id={`comment-${reply.id}`}
+ className={cn(
+ "border-t border-border/50 transition-colors duration-700",
+ highlightedCommentId === reply.id && highlightedCommentBackgroundClass,
+ )}
+ >
+ <CommentRow
+ issueId={issueId}
+ entry={reply}
+ runHeader={renderRuns(reply.id, "header")}
+ runMetadata={renderRuns(reply.id)}
+ currentUserId={currentUserId}
+ canModerate={canModerate}
+ isResolution={reply.id === replyResolutionId}
+ isHighlighted={highlightedCommentId === reply.id}
+ hasReplies={repliedToIds.has(reply.id)}
+ onEdit={onEdit}
+ onDelete={onDelete}
+ onToggleReaction={onToggleReaction}
+ onCreateSubIssue={onCreateSubIssue}
+ onResolveToggle={onResolveToggle}
+ />
+ </div>
+ )}
{renderAnchoredRuns(reply.id)}
</Fragment>
))}
diff --git a/packages/views/issues/components/issue-detail.test.tsx b/packages/views/issues/components/issue-detail.test.tsx
index 758b6bf16a..4537cd3e30 100644
--- a/packages/views/issues/components/issue-detail.test.tsx
+++ b/packages/views/issues/components/issue-detail.test.tsx
@@ -1986,6 +1986,29 @@ describe("IssueDetail (shared)", () => {
await waitFor(() => expect(document.getElementById(`comment-${target.id}`)).not.toBeNull());
await waitFor(() => expect(document.getElementById(`comment-${target.id}`)).toHaveClass(highlightedCommentBackgroundClass));
});
+ it("lands on the reply above a deleted one when a notification targets it", async () => {
+ // A deleted reply renders nothing (#8296 keeps its row only so its own
+ // replies keep a parent), so the id the notification carries has no
+ // anchor left. The landing rule's matrix lives in
+ // packages/core/issues/comment-deletion.test.ts.
+ const root = { ...mockTimeline[0]!, id: "thread-root", parent_id: null };
+ const previous = { ...mockTimeline[1]!, id: "reply-before", parent_id: root.id,
+ content: "Still here", created_at: "2026-01-18T00:00:00Z" };
+ const target = { ...mockTimeline[1]!, id: "deleted-reply", parent_id: root.id,
+ content: "", deleted_at: "2026-01-19T00:00:00Z", created_at: "2026-01-19T00:00:00Z" };
+ const kept = { ...mockTimeline[1]!, id: "reply-under-deleted", parent_id: target.id,
+ content: "Kept below it", created_at: "2026-01-20T00:00:00Z" };
+ mockApiObj.listTimeline.mockResolvedValue([root, previous, target, kept]);
+ mockApiObj.listTasksByIssue.mockResolvedValue([]);
+ renderIssueDetailWithHighlight(target.id);
+
+ await waitFor(() => expect(
+ hasHighlightedCommentBackground(document.getElementById(`comment-${previous.id}`)),
+ ).toBe(true));
+ // The tombstone itself never renders, so nothing waits on its anchor.
+ expect(document.getElementById(`comment-${target.id}`)).toBeNull();
+ });
+
it("scrolls to the highlighted comment after both issue and timeline finish loading", async () => {
renderIssueDetailWithHighlight("comment-2");
diff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsx
index c5b7bf9a37..62c8802984 100644
--- a/packages/views/issues/components/issue-detail.tsx
+++ b/packages/views/issues/components/issue-detail.tsx
@@ -63,6 +63,7 @@ import { PropertyIcon } from "../../common/property-icon";
import type { Attachment, Issue, IssueProperty, IssueStatus, IssueStatusCategory, IssuePriority, TimelineEntry, UpdateIssueRequest } from "@multica/core/types";
import { contentReferencesAttachment } from "@multica/core/types";
import { isBuiltInIssueStatus } from "@multica/core/issue-statuses";
+import { commentLandingTarget } from "@multica/core/issues/comment-deletion";
import { formatDateOnly, isPastDateOnly } from "@multica/core/issues/date";
import { useUpdateIssue } from "@multica/core/issues/mutations";
import { toast } from "sonner";
@@ -1931,7 +1932,17 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
}
}
- const el = document.getElementById(`comment-${highlightCommentId}`);
+ // A deleted reply renders nothing, so the id a notification or share link
+ // carries has no anchor to scroll to and no row to flash. Land on the
+ // comment above where it was; the id itself stays this landing's identity
+ // for the guards and the memento below.
+ const threadRootId = rootId ?? highlightCommentId;
+ const landingId = commentLandingTarget(
+ highlightCommentId,
+ threadRootId,
+ timelineView.threadReplies.get(threadRootId) ?? EMPTY_REPLIES,
+ );
+ const el = document.getElementById(`comment-${landingId}`);
const container = scrollContainerEl;
if (!el || !container) return;
@@ -1972,7 +1983,7 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
};
rafId = requestAnimationFrame(center);
- setHighlightedId(highlightCommentId);
+ setHighlightedId(landingId);
const fade = window.setTimeout(() => setHighlightedId(null), 2500);
return () => {
cancelAnimationFrame(rafId);
diff --git a/packages/views/issues/components/resolved-thread-bar.tsx b/packages/views/issues/components/resolved-thread-bar.tsx
index 1f33ac38bb..41bfec1dfe 100644
--- a/packages/views/issues/components/resolved-thread-bar.tsx
+++ b/packages/views/issues/components/resolved-thread-bar.tsx
@@ -57,7 +57,9 @@ function useAuthorsLabel(entries: TimelineEntry[]): string {
export function ResolvedThreadBar({ entry, replies, onExpand }: ResolvedThreadBarProps) {
const { t } = useT("issues");
const authorsLabel = useAuthorsLabel([entry, ...replies]);
- const count = 1 + replies.length;
+ // Deleted replies render nothing when the thread is expanded, so the folded
+ // count must not promise them either.
+ const count = 1 + replies.filter((reply) => !isDeletedComment(reply)).length;
return (
<Card className="!py-0 !gap-0 overflow-hidden">