Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-8074: feat(issues): fold resolved threads in the comment outline by default (#9325)
Jiayuan Zhangf896cc483379
diff --git a/packages/views/issues/components/issue-detail.test.tsx b/packages/views/issues/components/issue-detail.test.tsxindex 91123c36bf..26f505b304 100644--- a/packages/views/issues/components/issue-detail.test.tsx+++ b/packages/views/issues/components/issue-detail.test.tsx@@ -2579,6 +2579,12 @@ describe("IssueDetail (shared)", () => {const nav = await screen.findByRole("navigation", { name: "Jump to comment thread" });expect(document.getElementById("comment-reply-1")).toBeNull();+ expect(within(nav).queryByRole("button", { name: /: Reply inside resolved thread$/ })).toBeNull();+ act(() => within(nav).getByRole("button", { name: "Resolved root (resolved)" }).focus());+ fireEvent.click(+ within(nav.parentElement!).getByRole("button", { name: "Show 1 reply" }),+ { detail: 0 },+ );fireEvent.click(within(nav).getByRole("button", { name: /: Reply inside resolved thread$/ }));await waitFor(() => {diff --git a/packages/views/issues/components/thread-minimap.test.tsx b/packages/views/issues/components/thread-minimap.test.tsxindex 36d89251a5..3c340f038a 100644--- a/packages/views/issues/components/thread-minimap.test.tsx+++ b/packages/views/issues/components/thread-minimap.test.tsx@@ -388,31 +388,79 @@ describe("ThreadMinimap", () => {expect(onJump).toHaveBeenCalledWith("r2");});- it("lists replies under their thread in the outline and marks the resolution", () => {- const onJump = vi.fn();+ const resolvedWithReplies = () => [+ {+ ...thread(comment("c1", "First thread opener"), [+ reply("r1", "Looking into it", "Alice"),+ reply("r2", "Fixed in the latest build", "Lambda"),+ ]),+ resolved: true,+ resolutionReplyId: "r2",+ },+ ...threads.slice(1),+ ];++ it("folds resolved threads to their root on the rail and in the outline by default", () => {+ renderWithI18n(+ <ThreadMinimap threads={resolvedWithReplies()} scrollContainerEl={null} onJump={vi.fn()} />,+ );++ const nav = screen.getByRole("navigation");+ expect(within(nav).getAllByRole("button").map((tick) => tick.getAttribute("aria-label"))).toEqual([+ "First thread opener (resolved)",+ "Second thread opener",+ "member:author-c3",+ ]);++ act(() => within(nav).getByRole("button", { name: "First thread opener (resolved)" }).focus());+ const list = screen.getByRole("list");+ expect(within(list).queryByRole("button", { name: "Alice: Looking into it" })).not.toBeInTheDocument();+ const toggle = within(list).getByRole("button", { name: "Show 2 replies" });+ expect(toggle).toHaveAttribute("aria-expanded", "false");+ expect(toggle).toHaveTextContent("2");++ fireEvent.click(toggle, { detail: 0 });+ expect(within(list).getByRole("button", { name: "Hide replies" })).toHaveAttribute("aria-expanded", "true");+ expect(within(list).getByRole("button", { name: "Alice: Looking into it" })).toBeInTheDocument();+ expect(within(nav).getAllByRole("button")).toHaveLength(5);++ fireEvent.click(within(list).getByRole("button", { name: "Hide replies" }), { detail: 0 });+ expect(within(list).queryByRole("button", { name: "Alice: Looking into it" })).not.toBeInTheDocument();+ expect(within(nav).getAllByRole("button")).toHaveLength(3);+ });++ it("offers no fold toggle on open threads or resolved threads without replies", () => {renderWithI18n(<ThreadMinimapthreads={[- {- ...thread(comment("c1", "First thread opener"), [- reply("r1", "Looking into it", "Alice"),- reply("r2", "Fixed in the latest build", "Lambda"),- ]),- resolved: true,- resolutionReplyId: "r2",- },- ...threads.slice(1),+ thread(comment("c1", "First thread opener"), [reply("r1", "Looking into it", "Alice")]),+ { ...threads[1]!, resolved: true },+ threads[2]!,]}scrollContainerEl={null}- onJump={onJump}+ onJump={vi.fn()}/>,);+ act(() => screen.getByRole("button", { name: "First thread opener" }).focus());+ const list = screen.getByRole("list");+ expect(within(list).getByRole("button", { name: "Alice: Looking into it" })).toBeInTheDocument();+ expect(within(list).queryByRole("button", { expanded: false })).not.toBeInTheDocument();+ expect(within(list).queryByRole("button", { expanded: true })).not.toBeInTheDocument();+ });++ it("lists replies under an expanded resolved thread and marks the resolution", () => {+ const onJump = vi.fn();+ renderWithI18n(+ <ThreadMinimap threads={resolvedWithReplies()} scrollContainerEl={null} onJump={onJump} />,+ );act(() => screen.getByRole("button", { name: "First thread opener (resolved)" }).focus());const list = screen.getByRole("list");+ fireEvent.click(within(list).getByRole("button", { name: "Show 2 replies" }), { detail: 0 });const rows = within(list).getAllByRole("button");expect(rows.map((row) => row.getAttribute("aria-label"))).toEqual(["First thread opener (resolved)",+ "Hide replies","Alice: Looking into it","Lambda: Fixed in the latest build","Second thread opener",diff --git a/packages/views/issues/components/thread-minimap.tsx b/packages/views/issues/components/thread-minimap.tsxindex 1b52b7da0e..2ea1b05cff 100644--- a/packages/views/issues/components/thread-minimap.tsx+++ b/packages/views/issues/components/thread-minimap.tsx@@ -1,5 +1,5 @@import { useCallback, useEffect, useMemo, useRef, useState } from "react";-import { CheckCircle2 } from "lucide-react";+import { CheckCircle2, ChevronRight } from "lucide-react";import type { TimelineEntry } from "@multica/core/types";import { isDeletedComment } from "@multica/core/issues/comment-deletion";import { useActorName } from "@multica/core/workspace/hooks";@@ -14,6 +14,8 @@ import { useT, useTimeAgo } from "../../i18n";// focusing any tick opens one stationary, scrollable outline of every thread// with its replies listed under it. Rows jump to the same timeline anchors as// the ticks, including replies inside collapsed or resolved threads.+// Resolved threads start folded to their root row, on the rail and in the+// outline alike, until the reader expands them from the outline./** Minimum number of threads before the rail is worth its pixels. */const MIN_THREADS = 2;@@ -108,8 +110,9 @@ export interface ThreadMinimapThread {participants: TimelineEntry[];/*** Live (non-deleted) replies in timeline order. Each gets a short tick and an- * outline row; its `comment-${id}` anchor exists only once the thread is- * expanded, which the caller's `onJump` takes care of.+ * outline row unless its resolved thread is folded in the outline; its+ * `comment-${id}` anchor exists only once the thread is expanded in the+ * timeline, which the caller's `onJump` takes care of.*/replies: TimelineEntry[];/** The reply that resolved the thread ("Resolve thread with comment"), if any. */@@ -137,11 +140,19 @@ interface MinimapItem {threadIndex: number;}-function flattenThreads(threads: readonly ThreadMinimapThread[]): MinimapItem[] {+function isThreadFolded(thread: ThreadMinimapThread, expandedResolvedIds: ReadonlySet<string>) {+ return thread.resolved && thread.replies.length > 0 && !expandedResolvedIds.has(thread.id);+}++function flattenThreads(+ threads: readonly ThreadMinimapThread[],+ expandedResolvedIds: ReadonlySet<string>,+): MinimapItem[] {const items: MinimapItem[] = [];for (const thread of threads) {const threadIndex = items.length;items.push({ kind: "thread", id: thread.id, entry: thread.entry, thread, threadIndex });+ if (isThreadFolded(thread, expandedResolvedIds)) continue;for (const reply of thread.replies) {items.push({ kind: "reply", id: reply.id, entry: reply, thread, threadIndex });}@@ -293,7 +304,20 @@ export function ThreadMinimap({const { t } = useT("issues");const timeAgo = useTimeAgo();const { getActorName, getActorInitials, getActorAvatarUrl } = useActorName();- const items = useMemo(() => flattenThreads(threads), [threads]);+ const [expandedResolvedIds, setExpandedResolvedIds] = useState<ReadonlySet<string>>(+ () => new Set(),+ );+ const toggleThreadReplies = useCallback((threadId: string) => {+ setExpandedResolvedIds((prev) => {+ const next = new Set(prev);+ if (!next.delete(threadId)) next.add(threadId);+ return next;+ });+ }, []);+ const items = useMemo(+ () => flattenThreads(threads, expandedResolvedIds),+ [threads, expandedResolvedIds],+ );// Item indexes that get a rail tick: every comment while they fit, one per// thread beyond MAX_RAIL_TICKS.const railIndexes = useMemo(@@ -627,12 +651,14 @@ export function ThreadMinimap({const thread = item.thread;const participantNames = thread.participants.map(actorName);+ const canFold = thread.resolved && thread.replies.length > 0;+ const folded = isThreadFolded(thread, expandedResolvedIds);return (- <li key={item.id}>+ <li key={item.id} className="flex items-center gap-0.5"><button{...rowProps}aria-description={participantNames.join(", ") || undefined}- className="flex w-full items-center gap-3 rounded-md px-3 py-2 text-left text-body text-muted-foreground transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring data-active:font-medium data-active:text-brand"+ className="flex min-w-0 flex-1 items-center gap-3 rounded-md px-3 py-2 text-left text-body text-muted-foreground transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring data-active:font-medium data-active:text-brand"><span className="flex min-w-0 flex-1 items-center gap-1.5"><span className="truncate">{title}</span>@@ -663,6 +689,36 @@ export function ThreadMinimap({)}</span></button>+ {canFold && (+ <button+ type="button"+ aria-expanded={!folded}+ aria-label={+ folded+ ? t(($) => $.detail.thread_nav_show_replies, { count: thread.replies.length })+ : t(($) => $.detail.thread_nav_hide_replies)+ }+ onPointerEnter={() => showPreview({ index })}+ onFocus={() => showPreview({ index })}+ onClick={(event) => {+ if (event.detail > 0) {+ event.currentTarget.blur();+ cancelClose();+ }+ toggleThreadReplies(thread.id);+ }}+ className="flex h-7 shrink-0 items-center gap-0.5 rounded-md pl-1.5 pr-1 text-micro tabular-nums text-muted-foreground transition-colors hover:bg-surface-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"+ >+ {thread.replies.length}+ <ChevronRight+ aria-hidden="true"+ className={cn(+ "size-3.5 transition-transform duration-150 ease-out motion-reduce:transition-none",+ !folded && "rotate-90",+ )}+ />+ </button>+ )}</li>);})}diff --git a/packages/views/locales/en/issues.json b/packages/views/locales/en/issues.jsonindex 7ae6b301fc..48f80793fd 100644--- a/packages/views/locales/en/issues.json+++ b/packages/views/locales/en/issues.json@@ -470,6 +470,9 @@"thread_nav_label": "Jump to comment thread","thread_nav_resolved_label": "{{title}} (resolved)","thread_nav_reply_label": "{{author}}: {{title}}",+ "thread_nav_show_replies_one": "Show {{count}} reply",+ "thread_nav_show_replies_other": "Show {{count}} replies",+ "thread_nav_hide_replies": "Hide replies","sidebar_tooltip": "Toggle right sidebar","find": {"placeholder": "Find in issue...",diff --git a/packages/views/locales/fr/issues.json b/packages/views/locales/fr/issues.jsonindex 0c9567879e..3f67e79f02 100644--- a/packages/views/locales/fr/issues.json+++ b/packages/views/locales/fr/issues.json@@ -470,6 +470,9 @@"thread_nav_label": "Aller au fil de commentaires","thread_nav_resolved_label": "{{title}} (résolu)","thread_nav_reply_label": "{{author}} : {{title}}",+ "thread_nav_show_replies_one": "Afficher {{count}} réponse",+ "thread_nav_show_replies_other": "Afficher {{count}} réponses",+ "thread_nav_hide_replies": "Masquer les réponses","sidebar_tooltip": "Afficher ou masquer la barre latérale droite","find": {"placeholder": "Rechercher dans la tâche...",diff --git a/packages/views/locales/ja/issues.json b/packages/views/locales/ja/issues.jsonindex ae345273ad..81a7b3657b 100644--- a/packages/views/locales/ja/issues.json+++ b/packages/views/locales/ja/issues.json@@ -465,6 +465,8 @@"thread_nav_label": "スレッドへ移動","thread_nav_resolved_label": "{{title}}(解決済み)","thread_nav_reply_label": "{{author}}:{{title}}",+ "thread_nav_show_replies_other": "{{count}} 件の返信を表示",+ "thread_nav_hide_replies": "返信を折りたたむ","sidebar_tooltip": "右サイドバーの開閉","find": {"placeholder": "タスク内を検索...",diff --git a/packages/views/locales/ko/issues.json b/packages/views/locales/ko/issues.jsonindex c69b496c07..7d1f031824 100644--- a/packages/views/locales/ko/issues.json+++ b/packages/views/locales/ko/issues.json@@ -465,6 +465,8 @@"thread_nav_label": "스레드로 이동","thread_nav_resolved_label": "{{title}} (해결됨)","thread_nav_reply_label": "{{author}}: {{title}}",+ "thread_nav_show_replies_other": "답글 {{count}}개 펼치기",+ "thread_nav_hide_replies": "답글 접기","sidebar_tooltip": "오른쪽 사이드바 열기/닫기","find": {"placeholder": "태스크에서 찾기...",diff --git a/packages/views/locales/zh-Hans/issues.json b/packages/views/locales/zh-Hans/issues.jsonindex 1598cee72d..d236b33bff 100644--- a/packages/views/locales/zh-Hans/issues.json+++ b/packages/views/locales/zh-Hans/issues.json@@ -463,6 +463,8 @@"thread_nav_label": "快速跳转到讨论","thread_nav_resolved_label": "{{title}}(已解决)","thread_nav_reply_label": "{{author}}:{{title}}",+ "thread_nav_show_replies_other": "展开 {{count}} 条回复",+ "thread_nav_hide_replies": "收起回复","sidebar_tooltip": "切换右侧边栏","find": {"placeholder": "在任务中查找...",