Skip to content

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

Go

MUL-7682 feat(issues): give every reply a tick on the thread rail (#8809)

Jiayuan Zhang07059303f4f1
diff --git a/packages/views/issues/components/comment-card.tsx b/packages/views/issues/components/comment-card.tsx
index fe87583370..2a9410c968 100644
--- a/packages/views/issues/components/comment-card.tsx
+++ b/packages/views/issues/components/comment-card.tsx
@@ -1189,6 +1189,7 @@ function CommentCardImpl({
<button
type="button"
onClick={onCollapseResolved}
+ data-thread-sticky-bar
className="sticky top-0 z-20 flex w-full items-center gap-2.5 border-b border-border/50 bg-muted px-4 max-md:px-3 py-2.5 text-left text-body text-muted-foreground transition-colors cursor-pointer hover:bg-accent hover:text-accent-foreground"
aria-label={t(($) => $.comment.resolve.collapse)}
>
@@ -1500,6 +1501,7 @@ function CommentCardImpl({
<button
type="button"
onClick={() => onResolvedExpandChange(entry.id, false)}
+ data-thread-sticky-bar
className="sticky top-0 z-20 flex w-full items-center gap-2.5 border-t border-border/50 bg-muted px-4 max-md:px-3 py-2.5 text-left text-body text-muted-foreground transition-colors cursor-pointer hover:bg-accent hover:text-accent-foreground"
aria-label={t(($) => $.comment.resolve.collapse)}
>
diff --git a/packages/views/issues/components/issue-detail.test.tsx b/packages/views/issues/components/issue-detail.test.tsx
index 3c8c703698..c73e9b5de7 100644
--- a/packages/views/issues/components/issue-detail.test.tsx
+++ b/packages/views/issues/components/issue-detail.test.tsx
@@ -8,6 +8,7 @@ import { issueStatusKeys } from "@multica/core/issue-statuses";
import { I18nProvider } from "@multica/core/i18n/react";
import { toast } from "sonner";
import { useResolvedExpandStore } from "@multica/core/issues/stores/resolved-expand-store";
+import { useCommentCollapseStore } from "@multica/core/issues/stores";
import {
DEFAULT_SUB_ISSUE_ROW_PROPERTIES,
useSubIssueDisplayStore,
@@ -380,14 +381,28 @@ vi.mock("@multica/core/issues/stores", async () => ({
},
),
selectRecentIssues: () => () => [],
- useCommentCollapseStore: (selector?: any) => {
- const state = {
- collapsedByIssue: {},
- isCollapsed: () => false,
- toggle: () => {},
- };
- return selector ? selector(state) : state;
- },
+ // Reactive in-memory stand-in: a quick-jump to a reply reopens a thread the
+ // reader collapsed, so the card has to re-render when `toggle` runs.
+ useCommentCollapseStore: (await vi.importActual<typeof import("zustand")>("zustand")).create<{
+ collapsedByIssue: Record<string, string[]>;
+ isCollapsed: (issueId: string, commentId: string) => boolean;
+ toggle: (issueId: string, commentId: string) => void;
+ }>()((set, get) => ({
+ collapsedByIssue: {},
+ isCollapsed: (issueId, commentId) => get().collapsedByIssue[issueId]?.includes(commentId) ?? false,
+ toggle: (issueId, commentId) =>
+ set((s) => {
+ const current = s.collapsedByIssue[issueId] ?? [];
+ return {
+ collapsedByIssue: {
+ ...s.collapsedByIssue,
+ [issueId]: current.includes(commentId)
+ ? current.filter((c) => c !== commentId)
+ : [...current, commentId],
+ },
+ };
+ }),
+ })),
useCommentDraftStore: Object.assign(
(selector?: any) => {
const state = {
@@ -493,6 +508,7 @@ beforeEach(() => {
// The resolved-expand store is module-global (not per-mount like the old
// useState); reset so one test's expansions can't leak into the next.
useResolvedExpandStore.setState({ expandedByIssue: {} });
+ useCommentCollapseStore.setState({ collapsedByIssue: {} });
});
// Mock modals
@@ -2351,6 +2367,79 @@ describe("IssueDetail (shared)", () => {
expect(screen.getByRole("button", { name: "I can help with this" })).toBeInTheDocument();
});
+ describe("quick-jump rail replies", () => {
+ const highlightTint = "bg-[color-mix(in_srgb,var(--card)_95%,var(--brand)_5%)]";
+
+ it("unfolds a resolved thread and lands on the reply picked from the rail", async () => {
+ mockApiObj.listTimeline.mockResolvedValue([
+ ...mockTimeline,
+ {
+ type: "comment",
+ id: "comment-3",
+ actor_type: "member",
+ actor_id: "user-1",
+ content: "Resolved root",
+ parent_id: null,
+ created_at: "2026-01-18T00:00:00Z",
+ updated_at: "2026-01-18T00:00:00Z",
+ comment_type: "comment",
+ resolved_at: "2026-01-19T00:00:00Z",
+ } as TimelineEntry,
+ {
+ type: "comment",
+ id: "reply-1",
+ actor_type: "member",
+ actor_id: "user-1",
+ content: "Reply inside resolved thread",
+ parent_id: "comment-3",
+ created_at: "2026-01-18T01:00:00Z",
+ updated_at: "2026-01-18T01:00:00Z",
+ comment_type: "comment",
+ } as TimelineEntry,
+ ]);
+
+ renderIssueDetail();
+
+ const nav = await screen.findByRole("navigation", { name: "Jump to comment thread" });
+ expect(document.getElementById("comment-reply-1")).toBeNull();
+ fireEvent.click(within(nav).getByRole("button", { name: /: Reply inside resolved thread$/ }));
+
+ await waitFor(() => {
+ expect(document.getElementById("comment-reply-1")?.className).toContain(highlightTint);
+ });
+ expect(useResolvedExpandStore.getState().expandedByIssue["issue-1"]?.has("comment-3")).toBe(true);
+ });
+
+ it("reopens a thread the reader collapsed before landing on its reply", async () => {
+ useCommentCollapseStore.setState({ collapsedByIssue: { "issue-1": ["comment-1"] } });
+ mockApiObj.listTimeline.mockResolvedValue([
+ ...mockTimeline,
+ {
+ type: "comment",
+ id: "reply-2",
+ actor_type: "member",
+ actor_id: "user-1",
+ content: "Pushed a fix",
+ parent_id: "comment-1",
+ created_at: "2026-01-16T01:00:00Z",
+ updated_at: "2026-01-16T01:00:00Z",
+ comment_type: "comment",
+ } as TimelineEntry,
+ ]);
+
+ renderIssueDetail();
+
+ const nav = await screen.findByRole("navigation", { name: "Jump to comment thread" });
+ expect(document.getElementById("comment-reply-2")).toBeNull();
+ fireEvent.click(within(nav).getByRole("button", { name: /: Pushed a fix$/ }));
+
+ await waitFor(() => {
+ expect(document.getElementById("comment-reply-2")?.className).toContain(highlightTint);
+ });
+ expect(useCommentCollapseStore.getState().isCollapsed("issue-1", "comment-1")).toBe(false);
+ });
+ });
+
it("sends empty description when editor is cleared", async () => {
renderIssueDetail();
diff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsx
index 0ed4ce85f2..5739a7f2bc 100644
--- a/packages/views/issues/components/issue-detail.tsx
+++ b/packages/views/issues/components/issue-detail.tsx
@@ -64,7 +64,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 { commentLandingTarget, isDeletedComment } 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";
@@ -120,6 +120,7 @@ import { propertyListOptions } from "@multica/core/properties";
import { memberListOptions, agentListOptions } from "@multica/core/workspace/queries";
import {
selectExpandedResolved,
+ useCommentCollapseStore,
useRecentIssuesStore,
useResolvedExpandStore,
useSubIssuesCollapseStore,
@@ -1753,12 +1754,16 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
items.flatMap((it) => {
if (it.kind === "activity-group" || !it.entry) return [];
const replies = timelineView.threadReplies.get(it.id) ?? EMPTY_REPLIES;
+ const resolution = deriveThreadResolution(it.entry, replies);
return [
{
id: it.id,
entry: it.entry,
- resolved: deriveThreadResolution(it.entry, replies).kind !== "none",
+ resolved: resolution.kind !== "none",
participants: collectThreadParticipants(it.entry, replies),
+ // Tombstones render no row, so they get no tick either.
+ replies: replies.filter((reply) => !isDeletedComment(reply)),
+ resolutionReplyId: resolution.kind === "reply" ? resolution.resolutionId : null,
},
];
}),
@@ -1879,6 +1884,78 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
},
[isFlatTimeline, items, jumpToComment, flashJumpTarget],
);
+ // Minimap jump to a reply. A reply's anchor exists only while its thread is
+ // open, so first undo whatever hides it — the reader's own collapse, a root
+ // resolution folding the whole thread into a bar, or a reply resolution
+ // folding the other replies — then mount the thread and let the effect
+ // below align the reply once its row lands.
+ const [pendingReplyJump, setPendingReplyJump] = useState<{ replyId: string; rootId: string } | null>(null);
+ const jumpToReply = useCallback(
+ (replyId: string) => {
+ const rootId = replyToRoot.get(replyId);
+ const index = rootId ? items.findIndex((it) => it.id === rootId) : -1;
+ const rootItem = items[index];
+ const root = rootItem && rootItem.kind !== "activity-group" ? rootItem.entry : undefined;
+ if (!rootId || !root) return;
+ const collapse = useCommentCollapseStore.getState();
+ if (collapse.isCollapsed(id, rootId)) collapse.toggle(id, rootId);
+ if (!expandedResolved.has(rootId)) {
+ const resolution = deriveThreadResolution(root, timelineView.threadReplies.get(rootId) ?? EMPTY_REPLIES);
+ if (resolution.kind === "root" || (resolution.kind === "reply" && resolution.resolutionId !== replyId)) {
+ toggleResolvedExpand(rootId, true);
+ }
+ }
+ if (!isFlatTimeline) virtuosoRef.current?.scrollToIndex({ index, align: "start", offset: -16 });
+ setPendingReplyJump({ replyId, rootId });
+ },
+ [id, items, replyToRoot, expandedResolved, timelineView.threadReplies, toggleResolvedExpand, isFlatTimeline],
+ );
+ // Land the pending reply once its row is in the DOM. The expansion commits
+ // on the next render and Virtuoso mounts the thread a frame or two later, so
+ // wait by frame (~1s cap), then re-align until async layout (markdown, code
+ // highlight, images) settles. Drive scrollTop directly — never native
+ // scrollIntoView (#3929) — and clear any sticky thread bar pinned at the top
+ // of the viewport so it cannot cover the reply's header.
+ useEffect(() => {
+ const container = scrollContainerEl;
+ if (!pendingReplyJump || !container) return;
+ const { replyId, rootId } = pendingReplyJump;
+ let rafId = 0;
+ let frames = 0;
+ let last = -1;
+ const align = () => {
+ const el = document.getElementById(`comment-${replyId}`);
+ if (!el) {
+ if (++frames < 60) rafId = requestAnimationFrame(align);
+ else setPendingReplyJump(null);
+ return;
+ }
+ const stickyBar = document
+ .getElementById(`comment-${rootId}`)
+ ?.querySelector<HTMLElement>("[data-thread-sticky-bar]");
+ const c = container.getBoundingClientRect();
+ const e = el.getBoundingClientRect();
+ const target = Math.max(
+ 0,
+ container.scrollTop + (e.top - c.top) - 16 - (stickyBar?.offsetHeight ?? 0),
+ );
+ container.scrollTop = target;
+ if (Math.abs(target - last) > 1 && ++frames < 90) {
+ last = target;
+ rafId = requestAnimationFrame(align);
+ return;
+ }
+ flashJumpTarget(replyId);
+ setPendingReplyJump(null);
+ };
+ rafId = requestAnimationFrame(align);
+ return () => cancelAnimationFrame(rafId);
+ }, [pendingReplyJump, scrollContainerEl, flashJumpTarget]);
+ const jumpToMinimapTarget = useCallback(
+ (commentId: string) =>
+ replyToRoot.has(commentId) ? jumpToReply(commentId) : jumpToThread(commentId),
+ [replyToRoot, jumpToReply, jumpToThread],
+ );
const {
reactions: issueReactions,
@@ -3624,13 +3701,13 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
column's px-8 padding when the gutter is 0 (overlay scrollbars),
so it covers neither the scrollbar nor body text. It also clears
the resize handle's 4px drag strip at the panel edge. Hover
- previews a thread, click jumps to it. Hidden on mobile: no
+ previews a comment, click jumps to it. Hidden on mobile: no
hover, and the gutter is too tight. */}
{!isMobile && (
<ThreadMinimap
threads={minimapThreads}
scrollContainerEl={scrollContainerEl}
- onJump={jumpToThread}
+ onJump={jumpToMinimapTarget}
className="absolute bottom-0 right-3 top-12"
/>
)}
diff --git a/packages/views/issues/components/thread-minimap.test.tsx b/packages/views/issues/components/thread-minimap.test.tsx
index 5b6399f777..36d89251a5 100644
--- a/packages/views/issues/components/thread-minimap.test.tsx
+++ b/packages/views/issues/components/thread-minimap.test.tsx
@@ -2,7 +2,7 @@ import { describe, expect, it, vi } from "vitest";
import { act, fireEvent, screen, within } from "@testing-library/react";
import type { TimelineEntry } from "@multica/core/types";
import { renderWithI18n } from "../../test/i18n";
-import { ThreadMinimap, commentPreview, waveScale } from "./thread-minimap";
+import { MAX_RAIL_TICKS, ThreadMinimap, commentPreview, waveScale } from "./thread-minimap";
vi.mock("@multica/core/workspace/hooks", () => ({
useActorName: () => ({
@@ -75,11 +75,24 @@ describe("waveScale", () => {
});
describe("ThreadMinimap", () => {
+ const thread = (entry: TimelineEntry, replies: TimelineEntry[] = []) => ({
+ id: entry.id,
+ entry,
+ resolved: false,
+ participants: [],
+ replies,
+ resolutionReplyId: null as string | null,
+ });
const threads = [
- { id: "c1", entry: comment("c1", "First thread opener\nwith details"), resolved: false, participants: [] },
- { id: "c2", entry: comment("c2", "Second thread opener"), resolved: false, participants: [] },
- { id: "c3", entry: comment("c3", ""), resolved: false, participants: [] },
+ thread(comment("c1", "First thread opener\nwith details")),
+ thread(comment("c2", "Second thread opener")),
+ thread(comment("c3", "")),
];
+ const reply = (id: string, content: string, actorName: string): TimelineEntry => ({
+ ...comment(id, content),
+ actor_name: actorName,
+ created_at: new Date(Date.now() - 5 * 60 * 1000).toISOString(),
+ });
it("renders nothing below the thread threshold", () => {
const { container } = renderWithI18n(
@@ -339,4 +352,135 @@ describe("ThreadMinimap", () => {
expect(onJump).toHaveBeenCalledTimes(1);
expect(onJump).toHaveBeenCalledWith("c2");
});
+
+ it("gives every reply a short tick under its thread, out of the tab order", () => {
+ const onJump = vi.fn();
+ renderWithI18n(
+ <ThreadMinimap
+ threads={[
+ thread(comment("c1", "First thread opener"), [
+ reply("r1", "Looking into it", "Alice"),
+ reply("r2", "**Fixed** in the latest build", "Lambda"),
+ ]),
+ ...threads.slice(1),
+ ]}
+ scrollContainerEl={null}
+ onJump={onJump}
+ />,
+ );
+
+ const nav = screen.getByRole("navigation", { name: "Jump to comment thread" });
+ const ticks = within(nav).getAllByRole("button");
+ expect(ticks.map((tick) => tick.getAttribute("aria-label"))).toEqual([
+ "First thread opener",
+ "Alice: Looking into it",
+ "Lambda: Fixed in the latest build",
+ "Second thread opener",
+ "member:author-c3",
+ ]);
+ // Replies sit at half the thread tick's length and pitch.
+ expect(ticks[1]!.firstElementChild).toHaveClass("w-1.5");
+ expect(ticks[0]!.firstElementChild).toHaveClass("w-3");
+ expect(ticks[1]).toHaveAttribute("tabindex", "-1");
+ expect(ticks[0]).not.toHaveAttribute("tabindex");
+
+ fireEvent.click(ticks[2]!);
+ expect(onJump).toHaveBeenCalledWith("r2");
+ });
+
+ it("lists replies under their thread in the outline and marks the resolution", () => {
+ const onJump = vi.fn();
+ renderWithI18n(
+ <ThreadMinimap
+ threads={[
+ {
+ ...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),
+ ]}
+ scrollContainerEl={null}
+ onJump={onJump}
+ />,
+ );
+
+ act(() => screen.getByRole("button", { name: "First thread opener (resolved)" }).focus());
+ const list = screen.getByRole("list");
+ const rows = within(list).getAllByRole("button");
+ expect(rows.map((row) => row.getAttribute("aria-label"))).toEqual([
+ "First thread opener (resolved)",
+ "Alice: Looking into it",
+ "Lambda: Fixed in the latest build",
+ "Second thread opener",
+ "member:author-c3",
+ ]);
+ const resolution = within(list).getByRole("button", { name: "Lambda: Fixed in the latest build" });
+ expect(within(resolution).getByLabelText("Resolution")).toBeInTheDocument();
+ expect(within(resolution).getByText("5m ago")).toBeInTheDocument();
+ expect(
+ within(list).getByRole("button", { name: "Alice: Looking into it" }),
+ ).not.toContainElement(within(list).queryByLabelText("Resolution"));
+
+ fireEvent.pointerEnter(resolution);
+ expect(resolution).toHaveAttribute("data-active");
+ fireEvent.click(resolution);
+ expect(onJump).toHaveBeenCalledWith("r2");
+ });
+
+ it("returns focus to the reply's own tick on Escape", () => {
+ renderWithI18n(
+ <ThreadMinimap
+ threads={[
+ thread(comment("c1", "First thread opener"), [reply("r1", "Looking into it", "Alice")]),
+ ...threads.slice(1),
+ ]}
+ scrollContainerEl={null}
+ onJump={vi.fn()}
+ />,
+ );
+ const nav = screen.getByRole("navigation");
+ act(() => within(nav).getByRole("button", { name: "First thread opener" }).focus());
+ const row = within(screen.getByRole("list")).getByRole("button", { name: "Alice: Looking into it" });
+ act(() => row.focus());
+ fireEvent.keyDown(row, { key: "Escape" });
+ expect(screen.queryByRole("list")).not.toBeInTheDocument();
+ expect(within(nav).getByRole("button", { name: "Alice: Looking into it" })).toHaveFocus();
+ });
+
+ it("keeps one tick per thread past the rail budget but still lists every reply", () => {
+ const manyReplies = Array.from({ length: MAX_RAIL_TICKS }, (_, i) =>
+ reply(`r${i}`, `Reply number ${i}`, "Alice"),
+ );
+ const onJump = vi.fn();
+ renderWithI18n(
+ <ThreadMinimap
+ threads={[thread(comment("c1", "First thread opener"), manyReplies), ...threads.slice(1)]}
+ scrollContainerEl={null}
+ onJump={onJump}
+ />,
+ );
+
+ const nav = screen.getByRole("navigation");
+ expect(within(nav).getAllByRole("button")).toHaveLength(3);
+
+ act(() => within(nav).getByRole("button", { name: "First thread opener" }).focus());
+ const list = screen.getByRole("list");
+ expect(within(list).getAllByRole("button")).toHaveLength(3 + MAX_RAIL_TICKS);
+
+ // A reply row without a tick of its own lights its thread's tick, and
+ // Escape hands focus back to that tick.
+ const row = within(list).getByRole("button", { name: "Alice: Reply number 7" });
+ act(() => row.focus());
+ expect(
+ within(nav).getByRole("button", { name: "First thread opener" }).firstElementChild,
+ ).toHaveClass("bg-brand");
+ fireEvent.click(row, { detail: 0 });
+ expect(onJump).toHaveBeenCalledWith("r7");
+ fireEvent.keyDown(row, { key: "Escape" });
+ expect(within(nav).getByRole("button", { name: "First thread opener" })).toHaveFocus();
+ });
});
diff --git a/packages/views/issues/components/thread-minimap.tsx b/packages/views/issues/components/thread-minimap.tsx
index c5d8b525b6..a41f4797db 100644
--- a/packages/views/issues/components/thread-minimap.tsx
+++ b/packages/views/issues/components/thread-minimap.tsx
@@ -6,17 +6,26 @@ import { useActorName } from "@multica/core/workspace/hooks";
import { cn } from "@multica/ui/lib/utils";
import { ActorAvatar } from "@multica/ui/components/common/actor-avatar";
import { resolvePublicFileUrl } from "@multica/core/workspace/avatar-url";
-import { useT } from "../../i18n";
+import { useT, useTimeAgo } from "../../i18n";
// ---------------------------------------------------------------------------
-// ThreadMinimap — quick-jump rail with a complete thread outline.
-// The rail shows viewport position; hovering or focusing any tick opens one
-// stationary, scrollable list of every thread title. Rows jump to the same
-// timeline anchors as the ticks, including folded resolved threads.
+// ThreadMinimap — quick-jump rail with a complete comment outline.
+// Every thread is a long tick and every reply a short tick beneath it, so the
+// rail doubles as a map of where the conversation runs long. Hovering or
+// 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.
/** Minimum number of threads before the rail is worth its pixels. */
const MIN_THREADS = 2;
+/**
+ * Most ticks the rail draws before it drops the reply ticks and keeps one per
+ * thread. Past this, ticks compressed to their minimum pitch stop being
+ * individually targetable; the outline still lists every reply.
+ */
+export const MAX_RAIL_TICKS = 80;
+
/** Intent delay before the card first appears; gliding afterwards is instant. */
const PREVIEW_OPEN_DELAY_MS = 150;
/** Grace period on leave — long enough to travel from rail onto the card. */
@@ -100,29 +109,64 @@ export interface ThreadMinimapThread {
resolved: boolean;
/** Unique authors across the root and every nested reply, in first-seen order. */
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.
+ */
+ replies: TimelineEntry[];
+ /** The reply that resolved the thread ("Resolve thread with comment"), if any. */
+ resolutionReplyId: string | null;
}
interface ThreadMinimapProps {
threads: ThreadMinimapThread[];
/** The issue detail scroll container; null until its callback ref populates. */
scrollContainerEl: HTMLElement | null;
- onJump: (threadId: string) => void;
+ /** Called with a thread root id or a reply id. */
+ onJump: (commentId: string) => void;
/** Positioning within the page (e.g. `absolute right-3 top-12 bottom-0`) — owned by the caller, like FindBar. */
className?: string;
}
+/** One rail tick / outline row: a thread root or one of its replies. */
+interface MinimapItem {
+ kind: "thread" | "reply";
+ id: string;
+ entry: TimelineEntry;
+ /** The thread itself for a root, the enclosing thread for a reply. */
+ thread: ThreadMinimapThread;
+ /** Index of the enclosing thread's own item. */
+ threadIndex: number;
+}
+
+function flattenThreads(threads: readonly ThreadMinimapThread[]): 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 });
+ for (const reply of thread.replies) {
+ items.push({ kind: "reply", id: reply.id, entry: reply, thread, threadIndex });
+ }
+ }
+ return items;
+}
+
// ---------------------------------------------------------------------------
-// useVisibleThreadIds — "which comment threads are on screen right now"
+// useVisibleCommentIds — "which rail comments are on screen right now"
// ---------------------------------------------------------------------------
//
-// Which threads intersect the scroll viewport, so the rail can darken their
-// ticks. Deliberately the rail's alone: "on screen" is a set, not a point, and
+// Which ticked comments intersect the scroll viewport, so the rail can darken
+// their ticks. A thread root's anchor wraps its whole card, so a thread tick
+// stays dark while any of the thread is on screen; a reply's anchor is its own
+// row. Deliberately the rail's alone: "on screen" is a set, not a point, and
// only a column of ticks can show a span without suggesting multiple selection.
//
// Computed from DOM rects on scroll/resize instead of an IntersectionObserver
// because Virtuoso mounts/unmounts rows while scrolling — an observer would
// lose its targets. Unmounted rows are by definition outside the (overscanned)
-// viewport, so "no element" correctly counts as not visible.
+// viewport, and replies of a folded thread have no row at all, so "no element"
+// correctly counts as not visible.
function sameIdSet(a: Set<string>, b: Set<string>): boolean {
if (a.size !== b.size) return false;
@@ -130,8 +174,8 @@ function sameIdSet(a: Set<string>, b: Set<string>): boolean {
return true;
}
-function useVisibleThreadIds(
- threadIds: readonly string[],
+function useVisibleCommentIds(
+ commentIds: readonly string[],
scrollContainerEl: HTMLElement | null,
): Set<string> {
const [visibleIds, setVisibleIds] = useState<Set<string>>(() => new Set());
@@ -145,7 +189,7 @@ function useVisibleThreadIds(
raf = 0;
const rect = container.getBoundingClientRect();
const next = new Set<string>();
- for (const id of threadIds) {
+ for (const id of commentIds) {
const el = document.getElementById(`comment-${id}`);
if (!el) continue;
const r = el.getBoundingClientRect();
@@ -169,48 +213,66 @@ function useVisibleThreadIds(
ro.disconnect();
if (raf) cancelAnimationFrame(raf);
};
- }, [threadIds, scrollContainerEl]);
+ }, [commentIds, scrollContainerEl]);
return visibleIds;
}
-/** The thread currently highlighted in the outline and rail. */
+/** The item currently highlighted in the outline and rail. */
interface PreviewAnchor {
+ /** Index into the flattened items (threads and replies). */
index: number;
}
function MinimapTick({
+ kind,
+ index,
label,
inViewport,
isHighlighted,
onClick,
}: {
+ kind: MinimapItem["kind"];
+ /** Item index — how pointer and focus handlers map a tick back to its row. */
+ index: number;
label: string;
inViewport: boolean;
/** The corresponding outline row is active. */
isHighlighted: boolean;
onClick: React.MouseEventHandler<HTMLButtonElement>;
}) {
+ const isReply = kind === "reply";
return (
<button
type="button"
aria-label={label}
+ data-index={index}
+ // Reply ticks stay out of the tab order: dozens of stops on a 6px rail
+ // would bury the thread ticks. Keyboard users reach every reply through
+ // the outline, which opens as soon as a thread tick takes focus.
+ tabIndex={isReply ? -1 : undefined}
onClick={onClick}
// 20px wide, tick flushed to the right end: with the rail inset 12px
// (see the caller's className) the strip spans 12–32px from the panel
// edge, which clears a classic scrollbar's ~11px gutter on one side and
// stops exactly at the content column's 32px padding on the other — so
// it never sits on the scrollbar nor on body text, in either scrollbar
- // mode.
- className="group/tick flex min-h-[5px] w-5 flex-[0_1_0.875rem] cursor-pointer items-center justify-end focus-visible:outline-none"
+ // mode. Reply ticks take half the pitch, so a thread's replies pack
+ // tightly under it and each thread reads as one group.
+ className={cn(
+ "group/tick flex w-5 cursor-pointer items-center justify-end focus-visible:outline-none",
+ isReply ? "min-h-1 flex-[0_1_0.4375rem]" : "min-h-[5px] flex-[0_1_0.875rem]",
+ )}
>
<span
className={cn(
// Enlargement is a right-anchored `scale` (compositor-friendly, and
// what the JS wave writes inline), so ticks grow inward, away from
// the scrollbar. The 100ms ease-out doubles as smoothing between
- // pointer samples and as the settle on leave.
- "h-0.5 w-3 origin-right rounded-full transition-[scale,background-color] duration-100 ease-out",
+ // pointer samples and as the settle on leave. Reply ticks are half
+ // the length of thread ticks and share their colors.
+ "h-0.5 origin-right rounded-full transition-[scale,background-color] duration-100 ease-out",
+ isReply ? "w-1.5" : "w-3",
inViewport ? "bg-foreground/70" : "bg-muted-foreground/30",
!isHighlighted && "group-hover/tick:bg-foreground",
// CSS floor states for when no inline wave value is present:
@@ -234,27 +296,38 @@ export function ThreadMinimap({
className,
}: ThreadMinimapProps) {
const { t } = useT("issues");
+ const timeAgo = useTimeAgo();
const { getActorName, getActorInitials, getActorAvatarUrl } = useActorName();
- const threadIds = useMemo(() => threads.map((th) => th.id), [threads]);
- const visibleIds = useVisibleThreadIds(threadIds, scrollContainerEl);
+ const items = useMemo(() => flattenThreads(threads), [threads]);
+ // Item indexes that get a rail tick: every comment while they fit, one per
+ // thread beyond MAX_RAIL_TICKS.
+ const railIndexes = useMemo(
+ () =>
+ items.length <= MAX_RAIL_TICKS
+ ? items.map((_, i) => i)
+ : items.flatMap((item, i) => (item.kind === "thread" ? [i] : [])),
+ [items],
+ );
+ const railIds = useMemo(() => railIndexes.map((i) => items[i]!.id), [items, railIndexes]);
+ const visibleIds = useVisibleCommentIds(railIds, scrollContainerEl);
- // Flattened previews, cached per thread by content so an unrelated timeline
+ // Flattened previews, cached per comment by content so an unrelated timeline
// update (reaction, new reply elsewhere) doesn't re-flatten every comment.
const prevPreviewsRef = useRef<Map<string, { content: string | undefined; preview: { title: string; body: string } }>>(new Map());
const previews = useMemo(() => {
const next = new Map<string, { content: string | undefined; preview: { title: string; body: string } }>();
- const arr = threads.map((th) => {
- const cached = prevPreviewsRef.current.get(th.id);
+ const arr = items.map((item) => {
+ const cached = prevPreviewsRef.current.get(item.id);
const preview =
- cached && cached.content === th.entry.content
+ cached && cached.content === item.entry.content
? cached.preview
- : commentPreview(th.entry.content ?? "");
- next.set(th.id, { content: th.entry.content, preview });
+ : commentPreview(item.entry.content ?? "");
+ next.set(item.id, { content: item.entry.content, preview });
return preview;
});
prevPreviewsRef.current = next;
return arr;
- }, [threads]);
+ }, [items]);
const shimRef = useRef<HTMLDivElement | null>(null);
const navRef = useRef<HTMLElement | null>(null);
@@ -308,7 +381,7 @@ export function ThreadMinimap({
}, PREVIEW_CLOSE_DELAY_MS);
}, [cancelClose, showPreview]);
- const handleJump = useCallback((threadId: string, event: React.MouseEvent<HTMLButtonElement>) => {
+ const handleJump = useCallback((commentId: string, event: React.MouseEvent<HTMLButtonElement>) => {
// Mouse clicks must not pin a hover outline through leftover button focus.
// Keyboard activation keeps focus so the reader can continue navigating.
if (event.detail > 0) {
@@ -316,7 +389,7 @@ export function ThreadMinimap({
// Blur schedules a close; keep the card until the pointer actually leaves.
cancelClose();
}
- onJump(threadId);
+ onJump(commentId);
}, [cancelClose, onJump]);
const runWave = useCallback(() => {
@@ -329,7 +402,7 @@ export function ThreadMinimap({
// Read pass, then write pass — never interleaved, one reflow at most.
const scales: string[] = [];
let nearest: { index: number; dist: number } | null = null;
- buttons.forEach((b, i) => {
+ buttons.forEach((b) => {
if (y === null) {
scales.push("");
return;
@@ -339,7 +412,7 @@ export function ThreadMinimap({
const dist = Math.abs(y - centerY);
const s = reducedMotionRef.current ? 1 : waveScale(y - centerY);
scales.push(s > 1.001 ? `${s.toFixed(3)} 1` : "");
- if (!nearest || dist < nearest.dist) nearest = { index: i, dist };
+ if (!nearest || dist < nearest.dist) nearest = { index: Number(b.dataset.index), dist };
});
buttons.forEach((b, i) => {
const tick = b.firstElementChild as HTMLElement | null;
@@ -386,14 +459,11 @@ export function ThreadMinimap({
// there is no pointer, so there is no accidental-hover to debounce.
const handleFocus = useCallback(
(e: React.FocusEvent) => {
- const nav = navRef.current;
- const shim = shimRef.current;
const btn = (e.target as HTMLElement).closest("button");
- if (!nav || !shim || !btn) return;
+ if (!btn) return;
cancelClose();
- const buttons = [...nav.querySelectorAll<HTMLButtonElement>("button")];
- const index = buttons.indexOf(btn as HTMLButtonElement);
- if (index < 0) return;
+ const index = Number(btn.dataset.index);
+ if (Number.isNaN(index)) return;
showPreview({ index });
},
[cancelClose, showPreview],
@@ -415,6 +485,43 @@ export function ThreadMinimap({
if (threads.length < MIN_THREADS) return null;
+ const actorName = (entry: TimelineEntry) =>
+ entry.actor_name || getActorName(entry.actor_type, entry.actor_id);
+ const itemTitle = (item: MinimapItem, index: number) =>
+ isDeletedComment(item.entry)
+ ? t(($) => $.comment.deleted_placeholder)
+ : previews[index]!.title || actorName(item.entry);
+ // Accessible name shared by a tick and its outline row: resolution is
+ // announced on thread ticks, a reply names its author up front.
+ const itemLabel = (item: MinimapItem, index: number) => {
+ const title = itemTitle(item, index);
+ if (item.kind === "reply") {
+ return t(($) => $.detail.thread_nav_reply_label, { author: actorName(item.entry), title });
+ }
+ return item.thread.resolved ? t(($) => $.detail.thread_nav_resolved_label, { title }) : title;
+ };
+ const avatarFor = (entry: TimelineEntry, size: "xs" | "sm") => {
+ const name = actorName(entry);
+ const avatarUrl = entry.actor_avatar_url?.startsWith("/")
+ ? resolvePublicFileUrl(entry.actor_avatar_url)
+ : entry.actor_avatar_url ?? getActorAvatarUrl(entry.actor_type, entry.actor_id);
+ return (
+ <ActorAvatar
+ name={name}
+ initials={getActorInitials(entry.actor_type, entry.actor_id, name)}
+ avatarUrl={avatarUrl}
+ isAgent={entry.actor_type === "agent"}
+ size={size}
+ />
+ );
+ };
+ // With reply ticks dropped, a highlighted reply row lights its thread's tick.
+ const highlightedTick = preview
+ ? items.length <= MAX_RAIL_TICKS
+ ? preview.index
+ : items[preview.index]?.threadIndex
+ : undefined;
+
return (
// Positioning shim; only the nav and the card take pointer events so the
// strip never blocks content clicks.
@@ -426,7 +533,11 @@ export function ThreadMinimap({
event.stopPropagation();
const activeIndex = previewRef.current?.index;
if (cardRef.current?.contains(document.activeElement) && activeIndex !== undefined) {
- navRef.current?.querySelectorAll("button")[activeIndex]?.focus();
+ const nav = navRef.current;
+ const tick =
+ nav?.querySelector<HTMLButtonElement>(`button[data-index="${activeIndex}"]`) ??
+ nav?.querySelector<HTMLButtonElement>(`button[data-index="${items[activeIndex]?.threadIndex}"]`);
+ tick?.focus();
}
cancelClose();
if (openTimerRef.current !== null) {
@@ -435,7 +546,10 @@ export function ThreadMinimap({
}
showPreview(null);
}}
- className={cn("pointer-events-none z-10 flex flex-col justify-center py-6", className)}
+ // z-30, like the find bar: the outline must paint over every sticky
+ // affordance pinned in the timeline (comment headers z-10, resolve
+ // collapse bars z-20), which jumping into a resolved thread now pins.
+ className={cn("pointer-events-none z-30 flex flex-col justify-center py-6", className)}
>
<nav
ref={navRef}
@@ -444,28 +558,21 @@ export function ThreadMinimap({
onPointerLeave={handleWaveLeave}
onFocusCapture={handleFocus}
onBlurCapture={scheduleClose}
- // Bounded height + shrinkable ticks: when threads outgrow the rail,
+ // Bounded height + shrinkable ticks: when comments outgrow the rail,
// flex compresses the spacing (down to min-h) instead of overflowing.
className="pointer-events-auto flex max-h-full flex-col overflow-hidden"
>
- {threads.map((thread, i) => {
- const title = isDeletedComment(thread.entry)
- ? t(($) => $.comment.deleted_placeholder)
- : previews[i]!.title ||
- thread.entry.actor_name ||
- getActorName(thread.entry.actor_type, thread.entry.actor_id);
+ {railIndexes.map((i) => {
+ const item = items[i]!;
return (
<MinimapTick
- key={thread.id}
- // Announce resolution on the tick as well as in the outline.
- label={
- thread.resolved
- ? t(($) => $.detail.thread_nav_resolved_label, { title })
- : title
- }
- inViewport={visibleIds.has(thread.id)}
- isHighlighted={preview?.index === i}
- onClick={(event) => handleJump(thread.id, event)}
+ key={item.id}
+ kind={item.kind}
+ index={i}
+ label={itemLabel(item, i)}
+ inViewport={visibleIds.has(item.id)}
+ isHighlighted={highlightedTick === i}
+ onClick={(event) => handleJump(item.id, event)}
/>
);
})}
@@ -480,26 +587,55 @@ export function ThreadMinimap({
onBlurCapture={scheduleClose}
className="pointer-events-auto absolute right-8 top-1/2 max-h-[calc(100%-3rem)] w-80 max-w-[calc(100vw-4rem)] -translate-y-1/2 overflow-y-auto overscroll-contain rounded-xl bg-popover p-2 text-body text-popover-foreground shadow-lg ring-1 ring-foreground/10"
>
+ {/* One <li> per item, replies included, so row index === item index. */}
<ul>
- {threads.map((thread, index) => {
- const title = isDeletedComment(thread.entry)
- ? t(($) => $.comment.deleted_placeholder)
- : previews[index]!.title || thread.entry.actor_name ||
- getActorName(thread.entry.actor_type, thread.entry.actor_id);
- const participantNames = thread.participants.map((participant) =>
- participant.actor_name || getActorName(participant.actor_type, participant.actor_id),
- );
+ {items.map((item, index) => {
+ const title = itemTitle(item, index);
+ const rowProps = {
+ type: "button" as const,
+ onPointerEnter: () => showPreview({ index }),
+ onFocus: () => showPreview({ index }),
+ onClick: (event: React.MouseEvent<HTMLButtonElement>) => handleJump(item.id, event),
+ "data-active": preview.index === index || undefined,
+ "aria-label": itemLabel(item, index),
+ };
+
+ if (item.kind === "reply") {
+ return (
+ // The guide line runs down the left of consecutive reply rows,
+ // tying them to the thread row above.
+ <li
+ key={item.id}
+ className="relative ml-3 before:absolute before:inset-y-0 before:left-0 before:w-px before:bg-surface-border"
+ >
+ <button
+ {...rowProps}
+ className="flex w-full items-center gap-2 rounded-md py-1 pl-3 pr-3 text-left text-label 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="inline-flex shrink-0" aria-hidden="true">
+ {avatarFor(item.entry, "xs")}
+ </span>
+ <span className="min-w-0 flex-1 truncate">{title}</span>
+ {item.thread.resolutionReplyId === item.id && (
+ <CheckCircle2
+ className="size-3 shrink-0 text-success"
+ aria-label={t(($) => $.comment.resolve.resolution_badge)}
+ />
+ )}
+ <span className="shrink-0 text-micro font-normal tabular-nums text-muted-foreground">
+ {timeAgo(item.entry.created_at)}
+ </span>
+ </button>
+ </li>
+ );
+ }
+
+ const thread = item.thread;
+ const participantNames = thread.participants.map(actorName);
return (
- <li key={thread.id}>
+ <li key={item.id}>
<button
- type="button"
- onPointerEnter={() => showPreview({ index })}
- onFocus={() => showPreview({ index })}
- onClick={(event) => handleJump(thread.id, event)}
- data-active={preview.index === index || undefined}
- aria-label={thread.resolved
- ? t(($) => $.detail.thread_nav_resolved_label, { title })
- : title}
+ {...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"
>
@@ -513,27 +649,15 @@ export function ThreadMinimap({
)}
</span>
<span className="inline-flex shrink-0 items-center -space-x-1.5" aria-hidden="true">
- {thread.participants.slice(0, 3).map((participant, participantIndex) => {
- const name = participantNames[participantIndex]!;
- const avatarUrl = participant.actor_avatar_url?.startsWith("/")
- ? resolvePublicFileUrl(participant.actor_avatar_url)
- : participant.actor_avatar_url ?? getActorAvatarUrl(participant.actor_type, participant.actor_id);
- return (
- <span
- key={`${participant.actor_type}:${participant.actor_id}`}
- title={name}
- className="inline-flex rounded-full ring-2 ring-popover"
- >
- <ActorAvatar
- name={name}
- initials={getActorInitials(participant.actor_type, participant.actor_id, name)}
- avatarUrl={avatarUrl}
- isAgent={participant.actor_type === "agent"}
- size="sm"
- />
- </span>
- );
- })}
+ {thread.participants.slice(0, 3).map((participant, participantIndex) => (
+ <span
+ key={`${participant.actor_type}:${participant.actor_id}`}
+ title={participantNames[participantIndex]!}
+ className="inline-flex rounded-full ring-2 ring-popover"
+ >
+ {avatarFor(participant, "sm")}
+ </span>
+ ))}
{thread.participants.length > 3 && (
<span
title={participantNames.slice(3).join(", ")}
diff --git a/packages/views/locales/en/issues.json b/packages/views/locales/en/issues.json
index a87ff6499f..0bd4260829 100644
--- a/packages/views/locales/en/issues.json
+++ b/packages/views/locales/en/issues.json
@@ -462,6 +462,7 @@
"unpin_tooltip": "Unpin from sidebar",
"thread_nav_label": "Jump to comment thread",
"thread_nav_resolved_label": "{{title}} (resolved)",
+ "thread_nav_reply_label": "{{author}}: {{title}}",
"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.json
index 88de96bc1a..6a6f687d4d 100644
--- a/packages/views/locales/fr/issues.json
+++ b/packages/views/locales/fr/issues.json
@@ -462,6 +462,7 @@
"unpin_tooltip": "Détacher de la barre latérale",
"thread_nav_label": "Aller au fil de commentaires",
"thread_nav_resolved_label": "{{title}} (résolu)",
+ "thread_nav_reply_label": "{{author}} : {{title}}",
"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.json
index e682050df3..f3ed9e8eae 100644
--- a/packages/views/locales/ja/issues.json
+++ b/packages/views/locales/ja/issues.json
@@ -457,6 +457,7 @@
"unpin_tooltip": "サイドバーのピン留めを解除",
"thread_nav_label": "スレッドへ移動",
"thread_nav_resolved_label": "{{title}}(解決済み)",
+ "thread_nav_reply_label": "{{author}}:{{title}}",
"sidebar_tooltip": "右サイドバーの開閉",
"find": {
"placeholder": "タスク内を検索...",
diff --git a/packages/views/locales/ko/issues.json b/packages/views/locales/ko/issues.json
index f7e39a9173..a373cc74ee 100644
--- a/packages/views/locales/ko/issues.json
+++ b/packages/views/locales/ko/issues.json
@@ -457,6 +457,7 @@
"unpin_tooltip": "사이드바 고정 해제",
"thread_nav_label": "스레드로 이동",
"thread_nav_resolved_label": "{{title}} (해결됨)",
+ "thread_nav_reply_label": "{{author}}: {{title}}",
"sidebar_tooltip": "오른쪽 사이드바 열기/닫기",
"find": {
"placeholder": "태스크에서 찾기...",
diff --git a/packages/views/locales/zh-Hans/issues.json b/packages/views/locales/zh-Hans/issues.json
index 5d72e96201..cc5b4cf8ef 100644
--- a/packages/views/locales/zh-Hans/issues.json
+++ b/packages/views/locales/zh-Hans/issues.json
@@ -455,6 +455,7 @@
"unpin_tooltip": "从侧边栏取消固定",
"thread_nav_label": "快速跳转到讨论",
"thread_nav_resolved_label": "{{title}}(已解决)",
+ "thread_nav_reply_label": "{{author}}:{{title}}",
"sidebar_tooltip": "切换右侧边栏",
"find": {
"placeholder": "在任务中查找...",