Skip to content

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

Go

MUL-7130: feat(issues): add overview and sub-issues to the outline (#8135)

Sodab8306f975c47
diff --git a/packages/views/issues/components/issue-detail.test.tsx b/packages/views/issues/components/issue-detail.test.tsx
index dab58306d6..dd3771879f 100644
--- a/packages/views/issues/components/issue-detail.test.tsx
+++ b/packages/views/issues/components/issue-detail.test.tsx
@@ -2671,7 +2671,7 @@ describe("IssueDetail (shared)", () => {
renderIssueDetail();
- const nav = await screen.findByRole("navigation", { name: "Jump to comment thread" });
+ const nav = await screen.findByRole("navigation", { name: "Quick navigation" });
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());
@@ -2805,7 +2805,7 @@ describe("IssueDetail (shared)", () => {
renderIssueDetail();
- const nav = await screen.findByRole("navigation", { name: "Jump to comment thread" });
+ const nav = await screen.findByRole("navigation", { name: "Quick navigation" });
expect(document.getElementById("comment-reply-2")).toBeNull();
fireEvent.click(within(nav).getByRole("button", { name: /: Pushed a fix$/ }));
@@ -3031,6 +3031,17 @@ describe("IssueDetail (shared)", () => {
expect(mockApiObj.updateIssue).toHaveBeenCalledTimes(callsBeforeDiscard);
});
+ it("returns to the issue title and description from the outline", async () => {
+ // Destination behavior is covered by thread-minimap.test.tsx; this tests the scroller wiring.
+ mockApiObj.listTimeline.mockResolvedValue([mockTimeline.find((entry) => entry.type === "comment")!]);
+ const { container } = renderIssueDetail();
+ const tick = await screen.findByRole("button", { name: "Issue description" });
+ const scroller = container.querySelector<HTMLDivElement>("[data-tab-scroll-root]")!;
+ scroller.scrollTop = 800;
+ fireEvent.click(tick);
+ expect(scroller.scrollTop).toBe(0);
+ });
+
describe("sub-issues list", () => {
beforeEach(() => {
useSubIssueDisplayStore.setState({
@@ -3059,6 +3070,29 @@ describe("IssueDetail (shared)", () => {
...overrides,
});
+ it("jumps from the outline to the expanded sub-issues section without comments", async () => {
+ // Preview/order behavior lives in thread-minimap.test.tsx; this tests the real section.
+ mockApiObj.listTimeline.mockResolvedValue([]);
+ mockApiObj.listChildIssues.mockResolvedValue({
+ issues: [subIssue({ id: "child-1", title: "Child destination" })],
+ });
+ const { container } = renderIssueDetail();
+ await screen.findByText("Child destination");
+ const section = container.querySelector<HTMLDivElement>(".group\\/sub-issues")!;
+ fireEvent.click(within(section).getByRole("button", { name: "Sub-issues" }));
+ expect(screen.queryByText("Child destination")).not.toBeInTheDocument();
+
+ const scroller = container.querySelector<HTMLDivElement>("[data-tab-scroll-root]")!;
+ scroller.scrollTop = 600;
+ vi.spyOn(scroller, "getBoundingClientRect").mockReturnValue({ top: 100 } as DOMRect);
+ vi.spyOn(section, "getBoundingClientRect").mockReturnValue({ top: -200 } as DOMRect);
+ fireEvent.click(within(screen.getByRole("navigation", { name: "Quick navigation" }))
+ .getByRole("button", { name: "Sub-issues" }));
+
+ expect(await screen.findByText("Child destination")).toBeInTheDocument();
+ await waitFor(() => expect(scroller.scrollTop).toBe(284));
+ });
+
it("renders priority, labels, due date and nested progress on rows", async () => {
mockApiObj.listChildIssues.mockResolvedValue({
issues: [
diff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsx
index 492d8502f7..44eb9b1223 100644
--- a/packages/views/issues/components/issue-detail.tsx
+++ b/packages/views/issues/components/issue-detail.tsx
@@ -9,7 +9,7 @@ import { IssueFlowCard } from "../../workflows/issue-flow-card";
import { useStatusLabel } from "../utils/status-label";
import { priorityLabel } from "../utils/priority-label";
import { useIssueStatuses } from "@multica/core/issue-statuses/hooks";
-import { useState, useEffect, useCallback, useMemo, useRef, Fragment, type ReactNode } from "react";
+import { useState, useEffect, useCallback, useMemo, useRef, useId, Fragment, type ReactNode } from "react";
import { Virtuoso, type VirtuosoHandle } from "react-virtuoso";
import { useDefaultLayout, usePanelRef } from "react-resizable-panels";
import { AppLink, useBackOrReplace } from "../../navigation";
@@ -2176,6 +2176,26 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
[issueId, setSubIssuesCollapsedFor],
);
+ const descriptionSectionId = useId();
+ const subIssuesSectionId = useId();
+ const subIssuesSectionRef = useRef<HTMLDivElement>(null);
+ const subIssuesJumpFrame = useRef(0);
+ useEffect(() => () => cancelAnimationFrame(subIssuesJumpFrame.current), [issueId]);
+ const jumpToSubIssues = useCallback(() => {
+ setSubIssuesCollapsed(false);
+ cancelAnimationFrame(subIssuesJumpFrame.current);
+ // Wait for expansion so the section can be reached even when a collapsed
+ // list left too little scrollable content below it.
+ subIssuesJumpFrame.current = requestAnimationFrame(() => {
+ const section = subIssuesSectionRef.current;
+ const container = scrollContainerEl;
+ if (!section || !container) return;
+ container.scrollTop = Math.max(0, container.scrollTop +
+ section.getBoundingClientRect().top - container.getBoundingClientRect().top - 16);
+ });
+ }, [setSubIssuesCollapsed, scrollContainerEl]);
+ const doneChildCount = childIssues.filter((child) => issueBehavesAs(child, "done")).length;
+
// The sub-issue list owns its selection, reset per issue. Rows, select-all
// and the inline batch toolbar must read the same one: a peek renders this
// inside a surface whose own selection provider would otherwise win for the
@@ -3293,6 +3313,7 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
)
}
/>
+ <div id={descriptionSectionId}>
{titleLazy.active && (
<div className={titleLazy.ready ? undefined : "hidden"}>
<TitleEditor
@@ -3534,6 +3555,8 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
{descDragOver && <FileDropOverlay />}
</div>
+ </div>
+
{/* Sub-issues — Linear-style */}
{childIssues.length === 0 && (
<div className="mt-6">
@@ -3548,13 +3571,12 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
</div>
)}
{childIssues.length > 0 && (() => {
- const doneCount = childIssues.filter((c) => issueBehavesAs(c, "done")).length;
return (
// Provider hosts the shared right-click actions menu the rows
// delegate to (one singleton menu, not one per row).
<IssueContextMenuProvider>
<IssueSurfaceSelectionProvider selection={subIssueSelection}>
- <div className="mt-10 group/sub-issues">
+ <div ref={subIssuesSectionRef} id={subIssuesSectionId} className="mt-10 group/sub-issues">
{/* Header */}
<div className="flex items-center gap-2 mb-2">
<button
@@ -3571,9 +3593,9 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr
<span>{t(($) => $.detail.sub_issues_label)}</span>
</button>
<div className="inline-flex items-center gap-1.5 rounded-full bg-muted/60 px-2 py-0.5">
- <ProgressRing done={doneCount} total={childIssues.length} size={11} />
+ <ProgressRing done={doneChildCount} total={childIssues.length} size={11} />
<span className="text-micro text-muted-foreground tabular-nums font-medium">
- {doneCount}/{childIssues.length}
+ {doneChildCount}/{childIssues.length}
</span>
</div>
{/* issue.id, not the route param — the endpoint takes a
@@ -3909,11 +3931,24 @@ 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 comment, click jumps to it. Hidden on mobile: no
+ opens the outline; clicking jumps to a section or comment. Hidden on mobile: no
hover, and the gutter is too tight. */}
{!isMobile && !isPeek && (
<ThreadMinimap
threads={minimapThreads}
+ description={{
+ targetId: descriptionSectionId,
+ title: issue.title,
+ onJump: () => {
+ if (scrollContainerEl) scrollContainerEl.scrollTop = 0;
+ },
+ }}
+ subIssues={childIssues.length > 0 ? {
+ targetId: subIssuesSectionId,
+ done: doneChildCount,
+ total: childIssues.length,
+ onJump: jumpToSubIssues,
+ } : undefined}
scrollContainerEl={scrollContainerEl}
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 3c340f038a..846cb88ea3 100644
--- a/packages/views/issues/components/thread-minimap.test.tsx
+++ b/packages/views/issues/components/thread-minimap.test.tsx
@@ -74,6 +74,12 @@ describe("waveScale", () => {
});
});
+const description = {
+ targetId: "issue-description",
+ title: "Issue title",
+ onJump: vi.fn(),
+};
+
describe("ThreadMinimap", () => {
const thread = (entry: TimelineEntry, replies: TimelineEntry[] = []) => ({
id: entry.id,
@@ -94,21 +100,123 @@ describe("ThreadMinimap", () => {
created_at: new Date(Date.now() - 5 * 60 * 1000).toISOString(),
});
- it("renders nothing below the thread threshold", () => {
+ it("renders nothing when only the description exists", () => {
const { container } = renderWithI18n(
- <ThreadMinimap threads={threads.slice(0, 1)} scrollContainerEl={null} onJump={vi.fn()} />,
+ <ThreadMinimap description={description} threads={[]} scrollContainerEl={null} onJump={vi.fn()} />,
);
expect(container).toBeEmptyDOMElement();
});
+ it("offers a return to the description with just one thread", () => {
+ const onDescriptionJump = vi.fn();
+ renderWithI18n(
+ <ThreadMinimap
+ description={{ ...description, onJump: onDescriptionJump }}
+ threads={threads.slice(0, 1)} scrollContainerEl={null} onJump={vi.fn()}
+ />,
+ );
+ const nav = screen.getByRole("navigation", { name: "Quick navigation" });
+ expect(within(nav).getAllByRole("button").map((button) => button.getAttribute("aria-label")))
+ .toEqual(["Issue description", "First thread opener"]);
+ const tick = within(nav).getByRole("button", { name: "Issue description" });
+ fireEvent.focus(tick);
+ const row = within(screen.getByRole("list")).getByRole("button", { name: "Issue description" });
+ expect(row).toHaveTextContent(/^Issue title$/);
+ fireEvent.click(row);
+ expect(onDescriptionJump).toHaveBeenCalledOnce();
+ });
+
+ it("shows the sub-issues overview and its progress even before any discussion", () => {
+ const onSubIssuesJump = vi.fn();
+ renderWithI18n(
+ <ThreadMinimap description={description} threads={[]} scrollContainerEl={null} onJump={vi.fn()}
+ subIssues={{ targetId: "children", done: 12, total: 100, onJump: onSubIssuesJump }} />,
+ );
+ const tick = screen.getByRole("button", { name: "Sub-issues" });
+ expect(screen.getAllByRole("button")).toHaveLength(2);
+ fireEvent.focus(tick);
+ const outline = within(screen.getByRole("list"));
+ expect(outline.getAllByRole("button").map((button) => button.getAttribute("aria-label")))
+ .toEqual(["Issue description", "Sub-issues"]);
+ const progress = outline.getByRole("progressbar", { name: "Sub-issues" });
+ expect(progress).toHaveAttribute("aria-valuenow", "12");
+ expect(progress).toHaveAttribute("aria-valuemax", "100");
+ expect(progress).toHaveAttribute("aria-valuetext", "12/100 completed");
+ expect(progress.querySelector("svg")).toBeInTheDocument();
+ expect(outline.getByText("12/100")).toBeInTheDocument();
+ expect(outline.getByRole("button", { name: "Sub-issues" }))
+ .toHaveAccessibleDescription("12/100 completed");
+ fireEvent.click(tick);
+ fireEvent.click(outline.getByRole("button", { name: "Sub-issues" }));
+ expect(onSubIssuesJump).toHaveBeenCalledTimes(2);
+ });
+
+ it("preserves the active discussion when sub-issues appear and disappear", () => {
+ const onJump = vi.fn();
+ const props = { description, threads, scrollContainerEl: null, onJump };
+ const { rerender } = renderWithI18n(<ThreadMinimap {...props} />);
+ const nav = screen.getByRole("navigation");
+ act(() => within(nav).getByRole("button", { name: "First thread opener" }).focus());
+ rerender(<ThreadMinimap {...props}
+ subIssues={{ targetId: "children", done: 1, total: 2, onJump: vi.fn() }} />);
+ expect(within(screen.getByRole("list")).getAllByRole("button").map((button) => button.getAttribute("aria-label")))
+ .toEqual(["Issue description", "Sub-issues", "First thread opener", "Second thread opener", "member:author-c3"]);
+ expect(within(screen.getByRole("list")).getByRole("button", { name: "First thread opener" }))
+ .toHaveAttribute("data-active");
+ rerender(<ThreadMinimap {...props} />);
+ const row = within(screen.getByRole("list")).getByRole("button", { name: "First thread opener" });
+ expect(row).toHaveAttribute("data-active");
+ act(() => row.focus());
+ fireEvent.click(row);
+ expect(onJump).toHaveBeenCalledWith("c1");
+ fireEvent.keyDown(row, { key: "Escape" });
+ expect(screen.queryByRole("list")).not.toBeInTheDocument();
+ expect(within(nav).getByRole("button", { name: "First thread opener" })).toHaveFocus();
+
+ rerender(<ThreadMinimap {...props}
+ subIssues={{ targetId: "children", done: 1, total: 2, onJump: vi.fn() }} />);
+ act(() => within(nav).getByRole("button", { name: "Sub-issues" }).focus());
+ act(() => within(screen.getByRole("list")).getByRole("button", { name: "Sub-issues" }).focus());
+ rerender(<ThreadMinimap {...props} />);
+ expect(screen.queryByRole("list")).not.toBeInTheDocument();
+ });
+
+ it("marks visible description, sub-issues, and discussion anchors on the rail", () => {
+ const scrollContainer = document.createElement("div");
+ const targets = [description.targetId, "children", "comment-c1"].map((id) => {
+ const element = document.createElement("section");
+ element.id = id;
+ scrollContainer.append(element);
+ return element;
+ });
+ document.body.append(scrollContainer);
+ vi.spyOn(scrollContainer, "getBoundingClientRect").mockReturnValue({ top: 0, bottom: 200 } as DOMRect);
+ targets.forEach((element) => {
+ vi.spyOn(element, "getBoundingClientRect").mockReturnValue({ top: 20, bottom: 100 } as DOMRect);
+ });
+ try {
+ renderWithI18n(
+ <ThreadMinimap description={description} threads={threads} scrollContainerEl={scrollContainer} onJump={vi.fn()}
+ subIssues={{ targetId: "children", done: 0, total: 2, onJump: vi.fn() }} />,
+ );
+ for (const label of ["Issue description", "Sub-issues", "First thread opener"]) {
+ expect(screen.getByRole("button", { name: label }).firstElementChild).toHaveClass("bg-foreground/70");
+ }
+ expect(screen.getByRole("button", { name: "Second thread opener" }).firstElementChild)
+ .toHaveClass("bg-muted-foreground/30");
+ } finally {
+ scrollContainer.remove();
+ }
+ });
+
it("renders one labelled tick per thread, falling back to the author for empty content", () => {
renderWithI18n(
- <ThreadMinimap threads={threads} scrollContainerEl={null} onJump={vi.fn()} />,
+ <ThreadMinimap description={description} threads={threads} scrollContainerEl={null} onJump={vi.fn()} />,
);
- const nav = screen.getByRole("navigation", { name: "Jump to comment thread" });
+ const nav = screen.getByRole("navigation", { name: "Quick navigation" });
expect(nav).toBeInTheDocument();
- expect(screen.getAllByRole("button")).toHaveLength(3);
+ expect(screen.getAllByRole("button")).toHaveLength(4);
expect(screen.getByRole("button", { name: "First thread opener" })).toBeInTheDocument();
expect(screen.getByRole("button", { name: "Second thread opener" })).toBeInTheDocument();
// Attachment-only comment: accessible name falls back to the actor.
@@ -121,18 +229,18 @@ describe("ThreadMinimap", () => {
});
try {
renderWithI18n(
- <ThreadMinimap threads={threads} scrollContainerEl={null} onJump={vi.fn()} />,
+ <ThreadMinimap description={description} threads={threads} scrollContainerEl={null} onJump={vi.fn()} />,
);
- const nav = screen.getByRole("navigation", { name: "Jump to comment thread" });
+ const nav = screen.getByRole("navigation", { name: "Quick navigation" });
- // jsdom rects are all zero → the nearest tick resolves to index 0.
+ // jsdom rects are all zero, so the description tick opens the outline.
fireEvent.pointerMove(nav, { clientY: 0 });
act(() => vi.advanceTimersByTime(30)); // rAF flush — arms the intent timer
expect(screen.queryByRole("list")).not.toBeInTheDocument();
act(() => vi.advanceTimersByTime(150)); // intent delay elapses → card opens
const list = screen.getByRole("list");
- expect(within(list).getAllByRole("button")).toHaveLength(3);
+ expect(within(list).getAllByRole("button")).toHaveLength(4);
expect(within(list).getByText("First thread opener")).toBeInTheDocument();
expect(within(list).getByText("Second thread opener")).toBeInTheDocument();
expect(within(list).getByText("member:author-c3")).toBeInTheDocument();
@@ -154,7 +262,7 @@ describe("ThreadMinimap", () => {
});
try {
renderWithI18n(
- <ThreadMinimap threads={threads} scrollContainerEl={null} onJump={vi.fn()} />,
+ <ThreadMinimap description={description} threads={threads} scrollContainerEl={null} onJump={vi.fn()} />,
);
// The rail sits in the right gutter, so ticks flush right and the wave
@@ -163,7 +271,7 @@ describe("ThreadMinimap", () => {
expect(tick).toHaveClass("justify-end");
expect(tick.firstElementChild).toHaveClass("origin-right");
- const nav = screen.getByRole("navigation", { name: "Jump to comment thread" });
+ const nav = screen.getByRole("navigation", { name: "Quick navigation" });
fireEvent.pointerMove(nav, { clientY: 0 });
act(() => vi.advanceTimersByTime(30 + 150)); // rAF flush + intent delay
@@ -181,16 +289,15 @@ describe("ThreadMinimap", () => {
});
try {
renderWithI18n(
- <ThreadMinimap
+ <ThreadMinimap description={description}
threads={[{ ...threads[0]!, resolved: true }, threads[1]!, threads[2]!]}
scrollContainerEl={null}
onJump={vi.fn()}
/>,
);
- const nav = screen.getByRole("navigation", { name: "Jump to comment thread" });
+ const nav = screen.getByRole("navigation", { name: "Quick navigation" });
- // jsdom rects are all zero → the nearest tick resolves to index 0, the
- // resolved thread.
+ // The complete outline includes resolution even when the description opens it.
fireEvent.pointerMove(nav, { clientY: 0 });
act(() => vi.advanceTimersByTime(30 + 150)); // rAF flush + intent delay
expect(screen.getByLabelText("Resolved")).toBeInTheDocument();
@@ -211,7 +318,7 @@ describe("ThreadMinimap", () => {
try {
const onJump = vi.fn();
renderWithI18n(
- <ThreadMinimap threads={threads} scrollContainerEl={null} onJump={onJump} />,
+ <ThreadMinimap description={description} threads={threads} scrollContainerEl={null} onJump={onJump} />,
);
const nav = screen.getByRole("navigation");
fireEvent.pointerMove(nav, { clientY: 0 });
@@ -238,7 +345,7 @@ describe("ThreadMinimap", () => {
try {
const onJump = vi.fn();
renderWithI18n(
- <ThreadMinimap threads={threads} scrollContainerEl={null} onJump={onJump} />,
+ <ThreadMinimap description={description} threads={threads} scrollContainerEl={null} onJump={onJump} />,
);
const nav = screen.getByRole("navigation");
fireEvent.pointerMove(nav, { clientY: 0 });
@@ -269,7 +376,7 @@ describe("ThreadMinimap", () => {
try {
const onJump = vi.fn();
renderWithI18n(
- <ThreadMinimap threads={threads} scrollContainerEl={null} onJump={onJump} />,
+ <ThreadMinimap description={description} threads={threads} scrollContainerEl={null} onJump={onJump} />,
);
act(() => screen.getByRole("button", { name: "First thread opener" }).focus());
const card = screen.getByRole("list").parentElement!;
@@ -288,7 +395,7 @@ describe("ThreadMinimap", () => {
it("opens on keyboard focus and dismisses with Escape, returning focus to the matching tick", () => {
renderWithI18n(
- <ThreadMinimap threads={threads} scrollContainerEl={null} onJump={vi.fn()} />,
+ <ThreadMinimap description={description} threads={threads} scrollContainerEl={null} onJump={vi.fn()} />,
);
const nav = screen.getByRole("navigation");
act(() => within(nav).getByRole("button", { name: "First thread opener" }).focus());
@@ -308,7 +415,7 @@ describe("ThreadMinimap", () => {
{ ...comment("carol", ""), actor_name: "Carol" },
];
renderWithI18n(
- <ThreadMinimap
+ <ThreadMinimap description={description}
threads={[{ ...threads[0]!, resolved: true, participants }, ...threads.slice(1)]}
scrollContainerEl={null}
onJump={vi.fn()}
@@ -328,7 +435,7 @@ describe("ThreadMinimap", () => {
it("carries the resolved state in the tick's accessible name", () => {
renderWithI18n(
- <ThreadMinimap
+ <ThreadMinimap description={description}
threads={[{ ...threads[0]!, resolved: true }, threads[1]!, threads[2]!]}
scrollContainerEl={null}
onJump={vi.fn()}
@@ -345,7 +452,7 @@ describe("ThreadMinimap", () => {
it("jumps to the clicked thread", () => {
const onJump = vi.fn();
renderWithI18n(
- <ThreadMinimap threads={threads} scrollContainerEl={null} onJump={onJump} />,
+ <ThreadMinimap description={description} threads={threads} scrollContainerEl={null} onJump={onJump} />,
);
fireEvent.click(screen.getByRole("button", { name: "Second thread opener" }));
@@ -357,6 +464,7 @@ describe("ThreadMinimap", () => {
const onJump = vi.fn();
renderWithI18n(
<ThreadMinimap
+ description={description}
threads={[
thread(comment("c1", "First thread opener"), [
reply("r1", "Looking into it", "Alice"),
@@ -369,9 +477,10 @@ describe("ThreadMinimap", () => {
/>,
);
- const nav = screen.getByRole("navigation", { name: "Jump to comment thread" });
+ const nav = screen.getByRole("navigation", { name: "Quick navigation" });
const ticks = within(nav).getAllByRole("button");
expect(ticks.map((tick) => tick.getAttribute("aria-label"))).toEqual([
+ "Issue description",
"First thread opener",
"Alice: Looking into it",
"Lambda: Fixed in the latest build",
@@ -379,12 +488,12 @@ describe("ThreadMinimap", () => {
"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");
+ expect(ticks[2]!.firstElementChild).toHaveClass("w-1.5");
+ expect(ticks[1]!.firstElementChild).toHaveClass("w-3");
+ expect(ticks[2]).toHaveAttribute("tabindex", "-1");
+ expect(ticks[1]).not.toHaveAttribute("tabindex");
- fireEvent.click(ticks[2]!);
+ fireEvent.click(ticks[3]!);
expect(onJump).toHaveBeenCalledWith("r2");
});
@@ -402,11 +511,12 @@ describe("ThreadMinimap", () => {
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()} />,
+ <ThreadMinimap description={description} threads={resolvedWithReplies()} scrollContainerEl={null} onJump={vi.fn()} />,
);
const nav = screen.getByRole("navigation");
expect(within(nav).getAllByRole("button").map((tick) => tick.getAttribute("aria-label"))).toEqual([
+ "Issue description",
"First thread opener (resolved)",
"Second thread opener",
"member:author-c3",
@@ -422,16 +532,17 @@ describe("ThreadMinimap", () => {
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);
+ expect(within(nav).getAllByRole("button")).toHaveLength(6);
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);
+ expect(within(nav).getAllByRole("button")).toHaveLength(4);
});
it("offers no fold toggle on open threads or resolved threads without replies", () => {
renderWithI18n(
<ThreadMinimap
+ description={description}
threads={[
thread(comment("c1", "First thread opener"), [reply("r1", "Looking into it", "Alice")]),
{ ...threads[1]!, resolved: true },
@@ -451,7 +562,7 @@ describe("ThreadMinimap", () => {
it("lists replies under an expanded resolved thread and marks the resolution", () => {
const onJump = vi.fn();
renderWithI18n(
- <ThreadMinimap threads={resolvedWithReplies()} scrollContainerEl={null} onJump={onJump} />,
+ <ThreadMinimap description={description} threads={resolvedWithReplies()} scrollContainerEl={null} onJump={onJump} />,
);
act(() => screen.getByRole("button", { name: "First thread opener (resolved)" }).focus());
@@ -459,6 +570,7 @@ describe("ThreadMinimap", () => {
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([
+ "Issue description",
"First thread opener (resolved)",
"Hide replies",
"Alice: Looking into it",
@@ -482,6 +594,7 @@ describe("ThreadMinimap", () => {
it("returns focus to the reply's own tick on Escape", () => {
renderWithI18n(
<ThreadMinimap
+ description={description}
threads={[
thread(comment("c1", "First thread opener"), [reply("r1", "Looking into it", "Alice")]),
...threads.slice(1),
@@ -506,6 +619,7 @@ describe("ThreadMinimap", () => {
const onJump = vi.fn();
renderWithI18n(
<ThreadMinimap
+ description={description}
threads={[thread(comment("c1", "First thread opener"), manyReplies), ...threads.slice(1)]}
scrollContainerEl={null}
onJump={onJump}
@@ -513,11 +627,11 @@ describe("ThreadMinimap", () => {
);
const nav = screen.getByRole("navigation");
- expect(within(nav).getAllByRole("button")).toHaveLength(3);
+ expect(within(nav).getAllByRole("button")).toHaveLength(4);
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);
+ expect(within(list).getAllByRole("button")).toHaveLength(4 + 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.
@@ -531,4 +645,35 @@ describe("ThreadMinimap", () => {
fireEvent.keyDown(row, { key: "Escape" });
expect(within(nav).getByRole("button", { name: "First thread opener" })).toHaveFocus();
});
+
+ it("keeps section ticks past the rail budget and the highlight on the same reply as sub-issues appear", () => {
+ const manyReplies = Array.from({ length: MAX_RAIL_TICKS }, (_, i) =>
+ reply(`r${i}`, `Reply number ${i}`, "Alice"),
+ );
+ const props = {
+ description,
+ threads: [thread(comment("c1", "First thread opener"), manyReplies), ...threads.slice(1)],
+ scrollContainerEl: null,
+ onJump: vi.fn(),
+ };
+ const subIssues = { targetId: "children", done: 1, total: 3, onJump: vi.fn() };
+ const { rerender } = renderWithI18n(<ThreadMinimap {...props} subIssues={subIssues} />);
+
+ const nav = screen.getByRole("navigation", { name: "Quick navigation" });
+ expect(within(nav).getAllByRole("button").map((tick) => tick.getAttribute("aria-label"))).toEqual([
+ "Issue description",
+ "Sub-issues",
+ "First thread opener",
+ "Second thread opener",
+ "member:author-c3",
+ ]);
+
+ act(() => within(nav).getByRole("button", { name: "First thread opener" }).focus());
+ act(() => within(screen.getByRole("list")).getByRole("button", { name: "Alice: Reply number 7" }).focus());
+ rerender(<ThreadMinimap {...props} />);
+ expect(within(screen.getByRole("list")).getByRole("button", { name: "Alice: Reply number 7" }))
+ .toHaveAttribute("data-active");
+ expect(within(nav).getByRole("button", { name: "First thread opener" }).firstElementChild)
+ .toHaveClass("bg-brand");
+ });
});
diff --git a/packages/views/issues/components/thread-minimap.tsx b/packages/views/issues/components/thread-minimap.tsx
index 2ea1b05cff..a5a7975175 100644
--- a/packages/views/issues/components/thread-minimap.tsx
+++ b/packages/views/issues/components/thread-minimap.tsx
@@ -7,19 +7,18 @@ 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, useTimeAgo } from "../../i18n";
-
-// 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.
+import { ProgressRing } from "./progress-ring";
+
+// ThreadMinimap — quick-jump rail with a complete issue outline.
+// The outline opens with the issue itself (title + description) and, when the
+// issue has children, its sub-issues overview; every thread follows as a long
+// tick with each 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 those destinations. Rows jump to the same
+// 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;
-
/**
* 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
@@ -120,6 +119,10 @@ export interface ThreadMinimapThread {
}
interface ThreadMinimapProps {
+ /** The issue title + description section; always the first destination. */
+ description: { targetId: string; title: string; onJump: () => void };
+ /** The sub-issues overview; omitted when the issue has no children. */
+ subIssues?: { targetId: string; done: number; total: number; onJump: () => void };
threads: ThreadMinimapThread[];
/** The issue detail scroll container; null until its callback ref populates. */
scrollContainerEl: HTMLElement | null;
@@ -129,10 +132,20 @@ interface ThreadMinimapProps {
className?: string;
}
-/** One rail tick / outline row: a thread root or one of its replies. */
-interface MinimapItem {
- kind: "thread" | "reply";
+/** An issue section ahead of the discussion: the description or the sub-issues overview. */
+interface MinimapSectionItem<K extends "description" | "subIssues"> {
+ kind: K;
+ /** The section's DOM id — both its item identity and its scroll anchor. */
+ id: string;
+ anchorId: string;
+}
+
+/** A thread root or one of its replies. */
+interface MinimapCommentItem<K extends "thread" | "reply"> {
+ kind: K;
+ /** Comment id; its DOM anchor is `comment-${id}`. */
id: string;
+ anchorId: string;
entry: TimelineEntry;
/** The thread itself for a root, the enclosing thread for a reply. */
thread: ThreadMinimapThread;
@@ -140,32 +153,53 @@ interface MinimapItem {
threadIndex: number;
}
+/** One rail tick / outline row. */
+type MinimapItem =
+ | MinimapSectionItem<"description">
+ | MinimapSectionItem<"subIssues">
+ | MinimapCommentItem<"thread">
+ | MinimapCommentItem<"reply">;
+
function isThreadFolded(thread: ThreadMinimapThread, expandedResolvedIds: ReadonlySet<string>) {
return thread.resolved && thread.replies.length > 0 && !expandedResolvedIds.has(thread.id);
}
-function flattenThreads(
+function buildItems(
+ descriptionId: string,
+ subIssuesId: string | undefined,
threads: readonly ThreadMinimapThread[],
expandedResolvedIds: ReadonlySet<string>,
): MinimapItem[] {
- const items: MinimapItem[] = [];
+ const items: MinimapItem[] = [
+ { kind: "description", id: descriptionId, anchorId: descriptionId },
+ ];
+ if (subIssuesId) items.push({ kind: "subIssues", id: subIssuesId, anchorId: subIssuesId });
for (const thread of threads) {
const threadIndex = items.length;
- items.push({ kind: "thread", id: thread.id, entry: thread.entry, thread, threadIndex });
+ items.push({
+ kind: "thread", id: thread.id, anchorId: `comment-${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 });
+ items.push({
+ kind: "reply", id: reply.id, anchorId: `comment-${reply.id}`,
+ entry: reply, thread, threadIndex,
+ });
}
}
return items;
}
-// useVisibleCommentIds — "which rail comments are on screen right now"
+const EMPTY_PREVIEW = { title: "", body: "" };
+
+// useVisibleAnchorIds — "which rail destinations are on screen right now"
//
-// 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
+// Which ticked destinations 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; the description and sub-issues anchors wrap their sections.
+// 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
@@ -180,8 +214,8 @@ function sameIdSet(a: Set<string>, b: Set<string>): boolean {
return true;
}
-function useVisibleCommentIds(
- commentIds: readonly string[],
+function useVisibleAnchorIds(
+ anchorIds: readonly string[],
scrollContainerEl: HTMLElement | null,
): Set<string> {
const [visibleIds, setVisibleIds] = useState<Set<string>>(() => new Set());
@@ -195,8 +229,8 @@ function useVisibleCommentIds(
raf = 0;
const rect = container.getBoundingClientRect();
const next = new Set<string>();
- for (const id of commentIds) {
- const el = document.getElementById(`comment-${id}`);
+ for (const id of anchorIds) {
+ const el = document.getElementById(id);
if (!el) continue;
const r = el.getBoundingClientRect();
if (r.bottom > rect.top && r.top < rect.bottom) next.add(id);
@@ -219,28 +253,31 @@ function useVisibleCommentIds(
ro.disconnect();
if (raf) cancelAnimationFrame(raf);
};
- }, [commentIds, scrollContainerEl]);
+ }, [anchorIds, scrollContainerEl]);
return visibleIds;
}
-/** The item currently highlighted in the outline and rail. */
+/**
+ * The item currently highlighted in the outline and rail. Keyed by item id, not
+ * position, so sub-issues appearing or a thread folding doesn't shift the
+ * highlight onto a different row.
+ */
interface PreviewAnchor {
- /** Index into the flattened items (threads and replies). */
- index: number;
+ id: string;
}
function MinimapTick({
kind,
- index,
+ itemId,
label,
inViewport,
isHighlighted,
onClick,
}: {
kind: MinimapItem["kind"];
- /** Item index — how pointer and focus handlers map a tick back to its row. */
- index: number;
+ /** Item id — how pointer and focus handlers map a tick back to its row. */
+ itemId: string;
label: string;
inViewport: boolean;
/** The corresponding outline row is active. */
@@ -252,7 +289,7 @@ function MinimapTick({
<button
type="button"
aria-label={label}
- data-index={index}
+ data-item-id={itemId}
// 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.
@@ -296,6 +333,8 @@ function MinimapTick({
}
export function ThreadMinimap({
+ description,
+ subIssues,
threads,
scrollContainerEl,
onJump,
@@ -314,28 +353,39 @@ export function ThreadMinimap({
return next;
});
}, []);
+ const descriptionId = description.targetId;
+ const subIssuesId = subIssues?.targetId;
const items = useMemo(
- () => flattenThreads(threads, expandedResolvedIds),
- [threads, expandedResolvedIds],
+ () => buildItems(descriptionId, subIssuesId, threads, expandedResolvedIds),
+ [descriptionId, subIssuesId, threads, expandedResolvedIds],
);
- // Item indexes that get a rail tick: every comment while they fit, one per
- // thread beyond MAX_RAIL_TICKS.
+ const indexById = useMemo(
+ () => new Map(items.map((item, i) => [item.id, i] as const)),
+ [items],
+ );
+ // Item indexes that get a rail tick: every destination while they fit;
+ // beyond MAX_RAIL_TICKS the reply ticks drop and sections + threads remain.
const railIndexes = useMemo(
() =>
items.length <= MAX_RAIL_TICKS
? items.map((_, i) => i)
- : items.flatMap((item, i) => (item.kind === "thread" ? [i] : [])),
+ : items.flatMap((item, i) => (item.kind === "reply" ? [] : [i])),
[items],
);
- const railIds = useMemo(() => railIndexes.map((i) => items[i]!.id), [items, railIndexes]);
- const visibleIds = useVisibleCommentIds(railIds, scrollContainerEl);
+ const railAnchorIds = useMemo(
+ () => railIndexes.map((i) => items[i]!.anchorId),
+ [items, railIndexes],
+ );
+ const visibleIds = useVisibleAnchorIds(railAnchorIds, scrollContainerEl);
// Flattened previews, cached per comment by content so an unrelated timeline
// update (reaction, new reply elsewhere) doesn't re-flatten every comment.
+ // Section items have no comment body; their titles come from props.
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 = items.map((item) => {
+ if (item.kind === "description" || item.kind === "subIssues") return EMPTY_PREVIEW;
const cached = prevPreviewsRef.current.get(item.id);
const preview =
cached && cached.content === item.entry.content
@@ -369,7 +419,7 @@ export function ThreadMinimap({
const showPreview = useCallback((anchor: PreviewAnchor | null) => {
previewRef.current = anchor;
setPreview((prev) =>
- prev?.index === anchor?.index ? prev : anchor,
+ prev?.id === anchor?.id ? prev : anchor,
);
}, []);
@@ -388,6 +438,22 @@ export function ThreadMinimap({
closeTimerRef.current = null;
}
}, []);
+
+ // The active row can disappear under the reader: sub-issues all removed, a
+ // reply deleted, a thread folded. Removing a focused row does not reliably
+ // emit blur, so close the outline explicitly instead of highlighting nothing.
+ const previewIndex = preview ? indexById.get(preview.id) : undefined;
+ useEffect(() => {
+ if (!preview || previewIndex !== undefined) return;
+ cancelClose();
+ if (openTimerRef.current !== null) {
+ window.clearTimeout(openTimerRef.current);
+ openTimerRef.current = null;
+ }
+ pendingAnchorRef.current = null;
+ showPreview(null);
+ }, [preview, previewIndex, cancelClose, showPreview]);
+
const scheduleClose = useCallback(() => {
cancelClose();
if (openTimerRef.current !== null) {
@@ -400,7 +466,9 @@ export function ThreadMinimap({
}, PREVIEW_CLOSE_DELAY_MS);
}, [cancelClose, showPreview]);
- const handleJump = useCallback((commentId: string, event: React.MouseEvent<HTMLButtonElement>) => {
+ const descriptionJump = description.onJump;
+ const subIssuesJump = subIssues?.onJump;
+ const handleJump = useCallback((item: MinimapItem, 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) {
@@ -408,8 +476,10 @@ export function ThreadMinimap({
// Blur schedules a close; keep the card until the pointer actually leaves.
cancelClose();
}
- onJump(commentId);
- }, [cancelClose, onJump]);
+ if (item.kind === "description") descriptionJump();
+ else if (item.kind === "subIssues") subIssuesJump?.();
+ else onJump(item.id);
+ }, [cancelClose, descriptionJump, subIssuesJump, onJump]);
const runWave = useCallback(() => {
waveRafRef.current = 0;
@@ -420,7 +490,7 @@ export function ThreadMinimap({
const buttons = nav.querySelectorAll<HTMLButtonElement>("button");
// Read pass, then write pass — never interleaved, one reflow at most.
const scales: string[] = [];
- let nearest: { index: number; dist: number } | null = null;
+ let nearest: { id: string; dist: number } | null = null;
buttons.forEach((b) => {
if (y === null) {
scales.push("");
@@ -431,7 +501,8 @@ 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: Number(b.dataset.index), dist };
+ const id = b.dataset.itemId;
+ if (id && (!nearest || dist < nearest.dist)) nearest = { id, dist };
});
buttons.forEach((b, i) => {
const tick = b.firstElementChild as HTMLElement | null;
@@ -444,8 +515,8 @@ export function ThreadMinimap({
});
if (y === null || !nearest) return;
- const { index } = nearest as { index: number };
- const anchor: PreviewAnchor = { index };
+ const { id } = nearest as { id: string };
+ const anchor: PreviewAnchor = { id };
pendingAnchorRef.current = anchor;
if (previewRef.current) {
// Already open: gliding highlights the matching row without moving the card.
@@ -481,39 +552,47 @@ export function ThreadMinimap({
const btn = (e.target as HTMLElement).closest("button");
if (!btn) return;
cancelClose();
- const index = Number(btn.dataset.index);
- if (Number.isNaN(index)) return;
- showPreview({ index });
+ const id = btn.dataset.itemId;
+ if (!id) return;
+ showPreview({ id });
},
[cancelClose, showPreview],
);
useEffect(() => {
const card = cardRef.current;
- if (!card || !preview) return;
+ if (!card || previewIndex === undefined) return;
// Rail navigation should reveal its row in a long outline. Moving within
// the list itself must leave its scroll position under the reader's control.
if (pointerYRef.current === null && !navRef.current?.contains(document.activeElement)) return;
- const row = card.querySelectorAll("li")[preview.index];
+ const row = card.querySelectorAll("li")[previewIndex];
if (!row) return;
if (row.offsetTop < card.scrollTop) card.scrollTop = row.offsetTop;
else if (row.offsetTop + row.offsetHeight > card.scrollTop + card.clientHeight) {
card.scrollTop = row.offsetTop + row.offsetHeight - card.clientHeight;
}
- }, [preview]);
+ }, [previewIndex]);
- if (threads.length < MIN_THREADS) return null;
+ // The description is always present, so it alone is no reason to draw a
+ // rail; one more destination (a thread or the sub-issues) makes it useful.
+ if (threads.length === 0 && !subIssues) 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)
+ const itemTitle = (item: MinimapItem, index: number) => {
+ if (item.kind === "description") return description.title.slice(0, PREVIEW_TITLE_MAX);
+ if (item.kind === "subIssues") return t(($) => $.detail.sub_issues_label);
+ return 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.
+ };
+ // Accessible name shared by a tick and its outline row: the description row
+ // shows the issue title but is announced as the description, resolution is
+ // announced on thread ticks, and a reply names its author up front.
const itemLabel = (item: MinimapItem, index: number) => {
+ if (item.kind === "description") return t(($) => $.detail.description_nav_label);
const title = itemTitle(item, index);
+ if (item.kind === "subIssues") return title;
if (item.kind === "reply") {
return t(($) => $.detail.thread_nav_reply_label, { author: actorName(item.entry), title });
}
@@ -535,11 +614,15 @@ export function ThreadMinimap({
);
};
// 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;
+ const previewItem = previewIndex === undefined ? undefined : items[previewIndex];
+ const highlightedTick =
+ previewItem === undefined
+ ? undefined
+ : items.length > MAX_RAIL_TICKS && previewItem.kind === "reply"
+ ? previewItem.threadIndex
+ : previewIndex;
+ const rowClassName =
+ "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";
return (
// Positioning shim; only the nav and the card take pointer events so the
@@ -550,12 +633,16 @@ export function ThreadMinimap({
if (event.key !== "Escape") return;
event.preventDefault();
event.stopPropagation();
- const activeIndex = previewRef.current?.index;
+ const activeId = previewRef.current?.id;
+ const activeIndex = activeId === undefined ? undefined : indexById.get(activeId);
if (cardRef.current?.contains(document.activeElement) && activeIndex !== undefined) {
- const nav = navRef.current;
+ // A reply whose tick was dropped returns focus to its thread's tick.
+ const active = items[activeIndex]!;
+ const fallbackId = active.kind === "reply" ? active.thread.id : undefined;
+ const ticks = [...(navRef.current?.querySelectorAll<HTMLButtonElement>("button") ?? [])];
const tick =
- nav?.querySelector<HTMLButtonElement>(`button[data-index="${activeIndex}"]`) ??
- nav?.querySelector<HTMLButtonElement>(`button[data-index="${items[activeIndex]?.threadIndex}"]`);
+ ticks.find((b) => b.dataset.itemId === active.id) ??
+ ticks.find((b) => b.dataset.itemId === fallbackId);
tick?.focus();
}
cancelClose();
@@ -572,7 +659,7 @@ export function ThreadMinimap({
>
<nav
ref={navRef}
- aria-label={t(($) => $.detail.thread_nav_label)}
+ aria-label={t(($) => $.detail.quick_jump_label)}
onPointerMove={handleWaveMove}
onPointerLeave={handleWaveLeave}
onFocusCapture={handleFocus}
@@ -587,17 +674,17 @@ export function ThreadMinimap({
<MinimapTick
key={item.id}
kind={item.kind}
- index={i}
+ itemId={item.id}
label={itemLabel(item, i)}
- inViewport={visibleIds.has(item.id)}
+ inViewport={visibleIds.has(item.anchorId)}
isHighlighted={highlightedTick === i}
- onClick={(event) => handleJump(item.id, event)}
+ onClick={(event) => handleJump(item, event)}
/>
);
})}
</nav>
- {preview && (
+ {previewIndex !== undefined && (
<div
ref={cardRef}
onPointerEnter={cancelClose}
@@ -606,19 +693,56 @@ 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. */}
+ {/* One <li> per item, sections and replies included, so row index === item index. */}
<ul>
{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,
+ onPointerEnter: () => showPreview({ id: item.id }),
+ onFocus: () => showPreview({ id: item.id }),
+ onClick: (event: React.MouseEvent<HTMLButtonElement>) => handleJump(item, event),
+ "data-active": previewIndex === index || undefined,
"aria-label": itemLabel(item, index),
};
+ if (item.kind === "description") {
+ return (
+ <li key={item.id} className="flex items-center">
+ <button {...rowProps} className={rowClassName}>
+ <span className="min-w-0 flex-1 truncate">{title}</span>
+ </button>
+ </li>
+ );
+ }
+
+ if (item.kind === "subIssues") {
+ const progress = subIssues
+ ? t(($) => $.detail.sub_issues_nav_progress, { done: subIssues.done, total: subIssues.total })
+ : undefined;
+ return (
+ <li key={item.id} className="flex items-center">
+ <button {...rowProps} aria-description={progress} className={rowClassName}>
+ <span className="min-w-0 flex-1 truncate">{title}</span>
+ {subIssues && (
+ <span
+ role="progressbar"
+ aria-label={title}
+ aria-valuemin={0}
+ aria-valuemax={subIssues.total}
+ aria-valuenow={subIssues.done}
+ aria-valuetext={progress}
+ className="inline-flex shrink-0 items-center gap-1.5 text-caption tabular-nums text-muted-foreground"
+ >
+ <ProgressRing done={subIssues.done} total={subIssues.total} />
+ <span>{subIssues.done}/{subIssues.total}</span>
+ </span>
+ )}
+ </button>
+ </li>
+ );
+ }
+
if (item.kind === "reply") {
return (
// The guide line runs down the left of consecutive reply rows,
@@ -658,7 +782,7 @@ export function ThreadMinimap({
<button
{...rowProps}
aria-description={participantNames.join(", ") || undefined}
- 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"
+ className={rowClassName}
>
<span className="flex min-w-0 flex-1 items-center gap-1.5">
<span className="truncate">{title}</span>
@@ -698,8 +822,8 @@ export function ThreadMinimap({
? t(($) => $.detail.thread_nav_show_replies, { count: thread.replies.length })
: t(($) => $.detail.thread_nav_hide_replies)
}
- onPointerEnter={() => showPreview({ index })}
- onFocus={() => showPreview({ index })}
+ onPointerEnter={() => showPreview({ id: item.id })}
+ onFocus={() => showPreview({ id: item.id })}
onClick={(event) => {
if (event.detail > 0) {
event.currentTarget.blur();
diff --git a/packages/views/locales/en/issues.json b/packages/views/locales/en/issues.json
index b11a1ea23f..e6f1ead39a 100644
--- a/packages/views/locales/en/issues.json
+++ b/packages/views/locales/en/issues.json
@@ -473,6 +473,9 @@
"archive_tooltip": "Archive",
"pin_tooltip": "Pin to sidebar",
"unpin_tooltip": "Unpin from sidebar",
+ "quick_jump_label": "Quick navigation",
+ "description_nav_label": "Issue description",
+ "sub_issues_nav_progress": "{{done}}/{{total}} completed",
"thread_nav_label": "Jump to comment thread",
"thread_nav_resolved_label": "{{title}} (resolved)",
"thread_nav_reply_label": "{{author}}: {{title}}",
diff --git a/packages/views/locales/fr/issues.json b/packages/views/locales/fr/issues.json
index 2a196dc8a6..5736941adc 100644
--- a/packages/views/locales/fr/issues.json
+++ b/packages/views/locales/fr/issues.json
@@ -472,6 +472,9 @@
"archive_tooltip": "Archiver",
"pin_tooltip": "Épingler à la barre latérale",
"unpin_tooltip": "Détacher de la barre latérale",
+ "quick_jump_label": "Navigation rapide",
+ "description_nav_label": "Description de la tâche",
+ "sub_issues_nav_progress": "{{done}}/{{total}} terminées",
"thread_nav_label": "Aller au fil de commentaires",
"thread_nav_resolved_label": "{{title}} (résolu)",
"thread_nav_reply_label": "{{author}} : {{title}}",
diff --git a/packages/views/locales/ja/issues.json b/packages/views/locales/ja/issues.json
index 5e00acf803..c49521b003 100644
--- a/packages/views/locales/ja/issues.json
+++ b/packages/views/locales/ja/issues.json
@@ -468,6 +468,9 @@
"archive_tooltip": "アーカイブ",
"pin_tooltip": "サイドバーにピン留め",
"unpin_tooltip": "サイドバーのピン留めを解除",
+ "quick_jump_label": "クイックナビゲーション",
+ "description_nav_label": "タスクの説明",
+ "sub_issues_nav_progress": "{{done}}/{{total}} 完了",
"thread_nav_label": "スレッドへ移動",
"thread_nav_resolved_label": "{{title}}(解決済み)",
"thread_nav_reply_label": "{{author}}:{{title}}",
diff --git a/packages/views/locales/ko/issues.json b/packages/views/locales/ko/issues.json
index 627367ed55..628c0a6a91 100644
--- a/packages/views/locales/ko/issues.json
+++ b/packages/views/locales/ko/issues.json
@@ -468,6 +468,9 @@
"archive_tooltip": "보관",
"pin_tooltip": "사이드바에 고정",
"unpin_tooltip": "사이드바 고정 해제",
+ "quick_jump_label": "빠른 탐색",
+ "description_nav_label": "태스크 설명",
+ "sub_issues_nav_progress": "{{done}}/{{total}} 완료",
"thread_nav_label": "스레드로 이동",
"thread_nav_resolved_label": "{{title}} (해결됨)",
"thread_nav_reply_label": "{{author}}: {{title}}",
diff --git a/packages/views/locales/zh-Hans/issues.json b/packages/views/locales/zh-Hans/issues.json
index 7800b26d8e..e077c849ed 100644
--- a/packages/views/locales/zh-Hans/issues.json
+++ b/packages/views/locales/zh-Hans/issues.json
@@ -466,6 +466,9 @@
"archive_tooltip": "归档",
"pin_tooltip": "固定到侧边栏",
"unpin_tooltip": "从侧边栏取消固定",
+ "quick_jump_label": "快捷跳转",
+ "description_nav_label": "任务描述",
+ "sub_issues_nav_progress": "已完成 {{done}}/{{total}}",
"thread_nav_label": "快速跳转到讨论",
"thread_nav_resolved_label": "{{title}}(已解决)",
"thread_nav_reply_label": "{{author}}:{{title}}",
diff --git a/packages/views/locales/zh-Hant/issues.json b/packages/views/locales/zh-Hant/issues.json
index 28ef3c374a..1dbd9f5917 100644
--- a/packages/views/locales/zh-Hant/issues.json
+++ b/packages/views/locales/zh-Hant/issues.json
@@ -465,6 +465,9 @@
"archive_tooltip": "歸檔",
"pin_tooltip": "固定到側邊欄",
"unpin_tooltip": "從側邊欄取消固定",
+ "quick_jump_label": "快捷跳轉",
+ "description_nav_label": "任務描述",
+ "sub_issues_nav_progress": "已完成 {{done}}/{{total}}",
"thread_nav_label": "快速跳轉到討論",
"thread_nav_resolved_label": "{{title}}(已解決)",
"thread_nav_reply_label": "{{author}}:{{title}}",