Skip to content

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

Go

MUL-6040: feat(issues): preview an issue on mention hover (#6785)

Zain Mehdi05a01f068ada
diff --git a/packages/views/issues/components/board-card-description-preview.test.ts b/packages/views/issues/components/board-card-description-preview.test.ts
deleted file mode 100644
index 901760bfff..0000000000
--- a/packages/views/issues/components/board-card-description-preview.test.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { describe, expect, it } from "vitest";
-
-import { descriptionPreview } from "./board-card";
-
-const ATTACHMENT_ID = "0f8a1b2c-3d4e-4f50-9a6b-7c8d9e0f1a2b";
-const IMAGE = `![](/api/attachments/${ATTACHMENT_ID}/download)`;
-const MARKER = `<!-- multica:channel-media:${ATTACHMENT_ID} -->`;
-
-describe("descriptionPreview", () => {
- // A `/issue` message carrying an image materializes into image Markdown plus
- // an invisible provenance marker. The image pass drops the picture, so the
- // marker must be stripped too or it becomes the card's visible preview text.
- it("hides the channel-media marker that outlives the image it annotates", () => {
- expect(descriptionPreview(`Ordered rich text\n\n${IMAGE}\n\n${MARKER}`)).toBe(
- "Ordered rich text",
- );
- });
-
- it("previews nothing for an image-only channel description", () => {
- expect(descriptionPreview(`${IMAGE}\n\n${MARKER}`)).toBe("");
- });
-
- it("still flattens ordinary markdown to a single line", () => {
- expect(
- descriptionPreview("# Title\n\n**bold** text and [a link](https://example.com)"),
- ).toBe("Title bold text and a link");
- });
-});
diff --git a/packages/views/issues/components/board-card.tsx b/packages/views/issues/components/board-card.tsx
index 458ae4c852..45fe5e8cc0 100644
--- a/packages/views/issues/components/board-card.tsx
+++ b/packages/views/issues/components/board-card.tsx
@@ -6,11 +6,11 @@ import { useSortable, defaultAnimateLayoutChanges } from "@dnd-kit/sortable";
import type { AnimateLayoutChanges } from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities";
import type { Issue, IssueProperty, Project, UpdateIssueRequest } from "@multica/core/types";
-import { stripChannelMediaMarkers } from "@multica/core/types";
import { useQuery } from "@tanstack/react-query";
import { useWorkspaceId } from "@multica/core/hooks";
import { propertyListOptions } from "@multica/core/properties";
import { CustomPropertyValueDisplay } from "./pickers/custom-property-picker";
+import { descriptionPreview } from "./description-preview";
import { formatDateOnly, isPastDateOnly } from "@multica/core/issues/date";
import { CalendarClock, CalendarDays } from "lucide-react";
import { ActorAvatar } from "../../common/actor-avatar";
@@ -34,22 +34,6 @@ function formatDate(date: string): string {
return formatDateOnly(date, { month: "short", day: "numeric" }, "en-US");
}
-// Flatten description Markdown into the card's one-line preview. Channel-media
-// provenance is server-owned merge metadata, not authored content, so it is
-// stripped first: the image Markdown it annotates is removed a line below, and
-// without this the bare HTML comment survives every remaining pass and becomes
-// visible preview text. Exported for tests.
-export function descriptionPreview(markdown: string): string {
- return stripChannelMediaMarkers(markdown)
- .replace(/!file\[[^\]]*\]\([^)]*\)/g, "")
- .replace(/!\[[^\]]*\]\([^)]*\)/g, "")
- .replace(/\[([^\]]+)\]\([^)]+\)/g, "$1")
- .replace(/[*_`~]+/g, "")
- .replace(/^[\s>#]+/gm, "")
- .replace(/\s+/g, " ")
- .trim();
-}
-
/** Stops event from bubbling to Link/drag handlers */
function PickerWrapper({ children, className }: { children: React.ReactNode; className?: string }) {
const stop = (e: React.SyntheticEvent) => {
diff --git a/packages/views/issues/components/description-preview.test.ts b/packages/views/issues/components/description-preview.test.ts
new file mode 100644
index 0000000000..97e37f8ec6
--- /dev/null
+++ b/packages/views/issues/components/description-preview.test.ts
@@ -0,0 +1,72 @@
+import { describe, expect, it } from "vitest";
+
+import { descriptionPreview } from "./description-preview";
+
+const ATTACHMENT_ID = "0f8a1b2c-3d4e-4f50-9a6b-7c8d9e0f1a2b";
+const IMAGE = `![](/api/attachments/${ATTACHMENT_ID}/download)`;
+const MARKER = `<!-- multica:channel-media:${ATTACHMENT_ID} -->`;
+
+describe("descriptionPreview", () => {
+ // A `/issue` message carrying an image materializes into image Markdown plus
+ // an invisible provenance marker. The image pass drops the picture, so the
+ // marker must be stripped too or it becomes the card's visible preview text.
+ it("hides the channel-media marker that outlives the image it annotates", () => {
+ expect(descriptionPreview(`Ordered rich text\n\n${IMAGE}\n\n${MARKER}`)).toBe(
+ "Ordered rich text",
+ );
+ });
+
+ it("previews nothing for an image-only channel description", () => {
+ expect(descriptionPreview(`${IMAGE}\n\n${MARKER}`)).toBe("");
+ });
+
+ it("still flattens ordinary markdown to a single line", () => {
+ expect(
+ descriptionPreview("# Title\n\n**bold** text and [a link](https://example.com)"),
+ ).toBe("Title bold text and a link");
+ });
+
+ // The editor serializes link brackets escaped. Without unescaping first, the
+ // link rule leaves the leading `\` untouched and captures the trailing one,
+ // so the preview reads `\repro script\`.
+ it("unwraps a link whose brackets the editor escaped", () => {
+ expect(descriptionPreview("See \\[repro script\\](https://example.com)")).toBe(
+ "See repro script",
+ );
+ });
+
+ it("still unwraps a link written without escapes", () => {
+ expect(descriptionPreview("See [repro script](https://example.com)")).toBe(
+ "See repro script",
+ );
+ });
+
+ // The editor autolinks a raw URL inside a link label, producing a nested
+ // link destination like `([https://x](https://x))`. A destination pattern
+ // that stops at the first `)` leaves the outer paren stranded in the
+ // preview.
+ it("unwraps a link whose destination is itself a nested link", () => {
+ expect(
+ descriptionPreview(
+ "This is **very** flaky and needs a \\[repro script\\]([https://example.com](https://example.com)) before we fix it.",
+ ),
+ ).toBe("This is very flaky and needs a repro script before we fix it.");
+ });
+
+ it("unwraps a link whose destination legitimately contains parentheses", () => {
+ expect(
+ descriptionPreview("See [wiki](https://en.wikipedia.org/wiki/Foo_(bar)) for details"),
+ ).toBe("See wiki for details");
+ });
+
+ it("drops the backslashes from escaped emphasis and punctuation", () => {
+ expect(descriptionPreview("it costs \\$5 \\*not\\* \\$10")).toBe("it costs $5 not $10");
+ });
+
+ // A backslash before a letter is not a Markdown escape, so prose keeps it.
+ it("leaves a literal backslash in prose alone", () => {
+ expect(descriptionPreview("open C:\\Users\\zain to continue")).toBe(
+ "open C:\\Users\\zain to continue",
+ );
+ });
+});
diff --git a/packages/views/issues/components/description-preview.ts b/packages/views/issues/components/description-preview.ts
new file mode 100644
index 0000000000..a3812729c1
--- /dev/null
+++ b/packages/views/issues/components/description-preview.ts
@@ -0,0 +1,39 @@
+import { stripChannelMediaMarkers } from "@multica/core/types";
+
+/**
+ * Flatten description Markdown into a one-line plain-text preview. Shared by
+ * every surface that shows a description snippet next to an issue.
+ *
+ * Channel-media provenance is server-owned merge metadata, not authored
+ * content, so it is stripped first: the image Markdown it annotates is removed
+ * a line below, and without this the bare HTML comment survives every
+ * remaining pass and becomes visible preview text.
+ */
+export function descriptionPreview(markdown: string): string {
+ return (
+ stripChannelMediaMarkers(markdown)
+ // Backslash-escaped punctuation is unescaped first, and the order is
+ // load-bearing. The editor serializes a link as `\[label\](url)`, so the
+ // link rule below sees `\[label\]` and its `[^\]]+` capture swallows the
+ // trailing backslash while the leading one survives — the preview then
+ // reads `\label\`. Unescaping after any structural rule is too late,
+ // because the escapes are what stop those rules from matching.
+ // The character class is CommonMark's escapable set: all ASCII
+ // punctuation. A backslash before anything else (a letter, a space) is a
+ // literal backslash in prose and is left alone.
+ .replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g, "$1")
+ // The destination group tolerates one level of balanced parentheses,
+ // e.g. `(https://en.wikipedia.org/wiki/Foo_(bar))` or a nested link
+ // produced when a URL inside a link label gets autolinked, which
+ // serializes as `[label]([https://x](https://x))`. A naive `[^)]+`
+ // stops at the first `)` and leaves the outer one stranded in the
+ // preview text — do not simplify this back to `[^)]+`.
+ .replace(/!file\[[^\]]*\]\((?:[^()]|\([^()]*\))*\)/g, "")
+ .replace(/!\[[^\]]*\]\((?:[^()]|\([^()]*\))*\)/g, "")
+ .replace(/\[([^\]]+)\]\((?:[^()]|\([^()]*\))*\)/g, "$1")
+ .replace(/[*_`~]+/g, "")
+ .replace(/^[\s>#]+/gm, "")
+ .replace(/\s+/g, " ")
+ .trim()
+ );
+}
diff --git a/packages/views/issues/components/issue-hover-card.test.tsx b/packages/views/issues/components/issue-hover-card.test.tsx
new file mode 100644
index 0000000000..9a5724e552
--- /dev/null
+++ b/packages/views/issues/components/issue-hover-card.test.tsx
@@ -0,0 +1,355 @@
+import { screen } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import { describe, expect, it, vi, beforeEach } from "vitest";
+import { useQuery } from "@tanstack/react-query";
+import { renderWithI18n } from "../../test/i18n";
+import { IssueHoverCard } from "./issue-hover-card";
+
+vi.mock("@tanstack/react-query", () => ({
+ useQuery: vi.fn(),
+}));
+
+vi.mock("@multica/core/hooks", () => ({
+ useWorkspaceId: () => "workspace-1",
+}));
+
+vi.mock("@multica/core/issues/queries", () => ({
+ issueDetailOptions: (_workspaceId: string, issueId: string) => ({
+ queryKey: ["issue", issueId],
+ }),
+ childIssueProgressOptions: (workspaceId: string) => ({
+ queryKey: ["child-progress", workspaceId],
+ }),
+}));
+
+// The real ActorAvatar pulls in navigation, presence, and four profile cards.
+// The card only needs to know it rendered for the right actor.
+vi.mock("../../common/actor-avatar", () => ({
+ ActorAvatar: ({
+ actorType,
+ actorId,
+ enableHoverCard,
+ profileLink,
+ }: {
+ actorType: string;
+ actorId: string;
+ enableHoverCard?: boolean;
+ profileLink?: boolean;
+ }) => (
+ <span
+ data-testid="actor-avatar"
+ data-actor-type={actorType}
+ data-actor-id={actorId}
+ data-hover-card={String(enableHoverCard)}
+ data-profile-link={String(profileLink)}
+ />
+ ),
+}));
+
+// A spy, not a stub: `useActorName` subscribes to the workspace member list,
+// so "was this hook mounted at all" is the assertion that keeps the assignee
+// row from being inlined back into the card body.
+const mockUseActorName = vi.hoisted(() => vi.fn(() => ({ getActorName: () => "zain" })));
+
+vi.mock("@multica/core/workspace/hooks", () => ({
+ useActorName: mockUseActorName,
+}));
+
+vi.mock("./status-icon", () => ({
+ StatusIcon: () => <svg data-testid="status-icon" />,
+}));
+
+vi.mock("./priority-icon", () => ({
+ PriorityIcon: ({ priority }: { priority: string }) => (
+ <svg data-testid="priority-icon" data-priority={priority} />
+ ),
+}));
+
+const mockUseQuery = vi.mocked(useQuery);
+
+type Issue = {
+ id: string;
+ identifier: string;
+ title: string;
+ status: string;
+ priority: string;
+ description?: string | null;
+ assignee_type?: string | null;
+ assignee_id?: string | null;
+};
+
+const BASE_ISSUE: Issue = {
+ id: "issue-1",
+ identifier: "MUL-3405",
+ title: "A very long issue title that the inline chip never shows",
+ status: "todo",
+ priority: "none",
+};
+
+const NOT_FOUND_TEXT = "This issue does not exist or has been deleted in this workspace.";
+
+/** The three query states the card body branches on, as react-query reports them. */
+type DetailState =
+ | { phase: "pending" }
+ | { phase: "error" }
+ | { phase: "success"; issue: Issue | undefined };
+
+/**
+ * Routes each query the card body makes to its own fixture, keyed by the first
+ * segment of the query key the mocked options factories produce. The detail
+ * fixture carries `isPending`/`isError` explicitly because the body branches on
+ * them, not on `data` alone.
+ */
+function mockQueries(
+ detail: DetailState,
+ progress?: Map<string, { done: number; total: number }>,
+): void {
+ mockUseQuery.mockImplementation((options: unknown) => {
+ const [key] = (options as { queryKey: string[] }).queryKey;
+ if (key === "issue") {
+ return {
+ data: detail.phase === "success" ? detail.issue : undefined,
+ isPending: detail.phase === "pending",
+ isError: detail.phase === "error",
+ } as unknown as ReturnType<typeof useQuery>;
+ }
+ if (key === "child-progress") {
+ return { data: progress, isPending: false, isError: false } as unknown as ReturnType<
+ typeof useQuery
+ >;
+ }
+ throw new Error(`Unexpected query key: ${String(key)}`);
+ });
+}
+
+/** Shorthand for the common case: the detail query settled with an issue. */
+function mockIssue(
+ issue: Issue,
+ progress?: Map<string, { done: number; total: number }>,
+): void {
+ mockQueries({ phase: "success", issue }, progress);
+}
+
+function renderCard(fallbackLabel?: string): void {
+ renderWithI18n(
+ <IssueHoverCard issueId="issue-1" delay={0} fallbackLabel={fallbackLabel}>
+ <span>MUL-3405</span>
+ </IssueHoverCard>,
+ );
+}
+
+async function openCard(): Promise<void> {
+ const user = userEvent.setup();
+ renderCard();
+ await user.hover(screen.getByText("MUL-3405"));
+ await screen.findByTestId("status-icon");
+}
+
+/** Opens a card whose detail query never resolves into an issue. */
+async function openFailedCard(fallbackLabel = "MUL-7"): Promise<void> {
+ const user = userEvent.setup();
+ renderCard(fallbackLabel);
+ await user.hover(screen.getByText("MUL-3405"));
+ await screen.findByText(NOT_FOUND_TEXT);
+}
+
+/** Paragraphs inside the open card: the title, plus the snippet when shown. */
+function paragraphCount(): number {
+ const title = screen.getByText(BASE_ISSUE.title);
+ return title.parentElement?.querySelectorAll("p").length ?? 0;
+}
+
+describe("IssueHoverCard", () => {
+ beforeEach(() => {
+ mockUseQuery.mockReset();
+ mockUseActorName.mockClear();
+ mockIssue(BASE_ISSUE);
+ });
+
+ it("does not fetch issue detail until the card opens", () => {
+ renderCard();
+
+ // Assert the trigger actually rendered BEFORE asserting the absent fetch.
+ // Without this, a component that throws or renders nothing would satisfy
+ // the deferred-fetch assertion and the guarantee would be untested.
+ expect(screen.getByText("MUL-3405")).toBeInTheDocument();
+ expect(mockUseQuery).not.toHaveBeenCalled();
+ });
+
+ it("reveals the full title on hover", async () => {
+ const user = userEvent.setup();
+ renderCard();
+
+ await user.hover(screen.getByText("MUL-3405"));
+
+ expect(
+ await screen.findByText("A very long issue title that the inline chip never shows"),
+ ).toBeInTheDocument();
+ expect(mockUseQuery).toHaveBeenCalled();
+ });
+
+ it("shows the priority glyph ahead of the status icon", async () => {
+ mockIssue({ ...BASE_ISSUE, priority: "high" });
+
+ await openCard();
+
+ const priority = screen.getByTestId("priority-icon");
+ expect(priority).toHaveAttribute("data-priority", "high");
+ // Ordering: priority leads the header, the status icon follows it. Both
+ // glyphs sit inside their own naming wrapper, so compare the wrappers.
+ expect(priority.parentElement?.nextElementSibling).toContainElement(
+ screen.getByTestId("status-icon"),
+ );
+ });
+
+ it("names the status and priority glyphs for assistive tech", async () => {
+ mockIssue({ ...BASE_ISSUE, status: "in_progress", priority: "high" });
+
+ await openCard();
+
+ // Localized names from the shipped issues namespace — no key of this
+ // card's own. Removing either aria-label drops the element from the query.
+ expect(screen.getByLabelText("In Progress")).toContainElement(
+ screen.getByTestId("status-icon"),
+ );
+ expect(screen.getByLabelText("High")).toContainElement(
+ screen.getByTestId("priority-icon"),
+ );
+ });
+
+ it("omits the priority glyph when the issue has no priority", async () => {
+ mockIssue({ ...BASE_ISSUE, priority: "none" });
+
+ await openCard();
+
+ expect(screen.getByTestId("status-icon")).toBeInTheDocument();
+ expect(screen.queryByTestId("priority-icon")).not.toBeInTheDocument();
+ });
+
+ it("shows the assignee avatar and name, without nesting another hover card", async () => {
+ mockIssue({ ...BASE_ISSUE, assignee_type: "member", assignee_id: "user-9" });
+
+ await openCard();
+
+ const avatar = screen.getByTestId("actor-avatar");
+ expect(avatar).toHaveAttribute("data-actor-type", "member");
+ expect(avatar).toHaveAttribute("data-actor-id", "user-9");
+ expect(avatar).toHaveAttribute("data-hover-card", "false");
+ expect(avatar).toHaveAttribute("data-profile-link", "false");
+ expect(screen.getByText("zain")).toBeInTheDocument();
+ expect(mockUseActorName).toHaveBeenCalled();
+ });
+
+ it("omits the assignee when the issue is unassigned", async () => {
+ mockIssue({ ...BASE_ISSUE, assignee_type: null, assignee_id: null });
+
+ await openCard();
+
+ expect(screen.queryByTestId("actor-avatar")).not.toBeInTheDocument();
+ expect(screen.queryByText("zain")).not.toBeInTheDocument();
+ // The member directory stays unfetched: the row that reads it never mounts.
+ expect(mockUseActorName).not.toHaveBeenCalled();
+ });
+
+ it("shows sub-issue progress when the workspace map has an entry", async () => {
+ mockIssue(BASE_ISSUE, new Map([["issue-1", { done: 2, total: 5 }]]));
+
+ await openCard();
+
+ expect(screen.getByText("2/5")).toBeInTheDocument();
+ });
+
+ it("omits progress when the issue has no children", async () => {
+ mockIssue(BASE_ISSUE, new Map([["other-issue", { done: 1, total: 3 }]]));
+
+ await openCard();
+
+ expect(screen.queryByText(/\d+\/\d+/)).not.toBeInTheDocument();
+ });
+
+ it("omits progress when the issue has an entry with no children counted", async () => {
+ mockIssue(BASE_ISSUE, new Map([["issue-1", { done: 0, total: 0 }]]));
+
+ await openCard();
+
+ expect(screen.queryByText(/\d+\/\d+/)).not.toBeInTheDocument();
+ });
+
+ it("shows a flattened description snippet clamped to two lines", async () => {
+ mockIssue({
+ ...BASE_ISSUE,
+ description: "**Set up** your first runtime so [Mika](/agents/mika) can pick up work",
+ });
+
+ await openCard();
+
+ const snippet = screen.getByText("Set up your first runtime so Mika can pick up work");
+ expect(snippet).toHaveClass("line-clamp-2");
+ });
+
+ // Both no-description cases count paragraphs rather than probing for absent
+ // text: an always-rendered block would emit an empty <p>, which no text query
+ // can see. The title is the only paragraph a description-less card may have.
+ it("omits the description block when there is no description", async () => {
+ mockIssue({ ...BASE_ISSUE, description: null });
+
+ await openCard();
+
+ expect(screen.getByText(BASE_ISSUE.title)).toBeInTheDocument();
+ expect(paragraphCount()).toBe(1);
+ });
+
+ it("omits the description block when the description flattens to nothing", async () => {
+ // An image-only description: every visible token is stripped by the
+ // preview, so rendering it would leave an empty paragraph.
+ mockIssue({
+ ...BASE_ISSUE,
+ description: "![](/api/attachments/abc/download)",
+ });
+
+ await openCard();
+
+ expect(screen.getByText(BASE_ISSUE.title)).toBeInTheDocument();
+ expect(paragraphCount()).toBe(1);
+ });
+
+ it("breaks a long unbroken title instead of overflowing the card", async () => {
+ const title = "https://example.com/a/very/long/path/that/never/offers/a/break/opportunity";
+ mockIssue({ ...BASE_ISSUE, title });
+
+ await openCard();
+
+ const titleEl = screen.getByText(title);
+ expect(titleEl).toHaveClass("break-words");
+ expect(titleEl).not.toHaveClass("truncate");
+ });
+
+ it("keeps the skeleton while the detail query is pending", async () => {
+ mockQueries({ phase: "pending" });
+ const user = userEvent.setup();
+ renderCard("MUL-7");
+
+ await user.hover(screen.getByText("MUL-3405"));
+
+ expect(await screen.findByTestId("issue-hover-card-skeleton")).toBeInTheDocument();
+ expect(screen.queryByText(NOT_FOUND_TEXT)).not.toBeInTheDocument();
+ });
+
+ it("replaces the skeleton with the not-found state when the detail query fails", async () => {
+ mockQueries({ phase: "error" });
+
+ await openFailedCard();
+
+ expect(screen.queryByTestId("issue-hover-card-skeleton")).not.toBeInTheDocument();
+ expect(screen.getByText("MUL-7")).toBeInTheDocument();
+ });
+
+ it("replaces the skeleton with the not-found state when the query settles with no issue", async () => {
+ mockQueries({ phase: "success", issue: undefined });
+
+ await openFailedCard();
+
+ expect(screen.queryByTestId("issue-hover-card-skeleton")).not.toBeInTheDocument();
+ expect(screen.getByText("MUL-7")).toBeInTheDocument();
+ });
+});
diff --git a/packages/views/issues/components/issue-hover-card.tsx b/packages/views/issues/components/issue-hover-card.tsx
new file mode 100644
index 0000000000..054008332e
--- /dev/null
+++ b/packages/views/issues/components/issue-hover-card.tsx
@@ -0,0 +1,220 @@
+"use client";
+
+import type { ReactNode } from "react";
+import { useQuery } from "@tanstack/react-query";
+import { childIssueProgressOptions, issueDetailOptions } from "@multica/core/issues/queries";
+import { useWorkspaceId } from "@multica/core/hooks";
+import { useActorName } from "@multica/core/workspace/hooks";
+import {
+ HoverCard,
+ HoverCardTrigger,
+ HoverCardContent,
+} from "@multica/ui/components/ui/hover-card";
+import { Skeleton } from "@multica/ui/components/ui/skeleton";
+import { useT } from "../../i18n";
+import { ActorAvatar } from "../../common/actor-avatar";
+import { descriptionPreview } from "./description-preview";
+import { PriorityIcon } from "./priority-icon";
+import { ProgressRing } from "./progress-ring";
+import { StatusIcon } from "./status-icon";
+
+interface IssueHoverCardProps {
+ issueId: string;
+ children: ReactNode;
+ /**
+ * Identifier to name the issue with when the detail fetch fails (e.g.
+ * "MUL-7"). The same label the chip degrades to, so a card that cannot load
+ * still says which issue it is about.
+ */
+ fallbackLabel?: string;
+ /**
+ * Open delay override, in milliseconds. Exists for tests only — production
+ * passes nothing, so the card uses Base UI's default of 600ms. Tests pass 0
+ * so hover assertions don't need to wait out the real delay.
+ */
+ delay?: number;
+}
+
+/**
+ * Detail for an issue mention, on hover.
+ *
+ * The inline chip shows status, identifier, and as much title as fits inside
+ * its `min(18rem, 100%)` cap — so a long title arrives truncated. The card
+ * carries what the chip cannot: the full untruncated title, priority, a
+ * description snippet, the assignee, and sub-issue progress. Member and agent
+ * mentions already preview this way via MentionHoverCard
+ * (packages/ui/components/common/mention-hover-card.tsx); this is the issue
+ * equivalent, and lives here rather than in packages/ui because it reads
+ * workspace queries.
+ *
+ * Every query lives in IssueHoverCardBody rather than here on purpose: Base UI
+ * mounts the popup only while the card is open, so this component adds no
+ * request of its own until a card opens. Moving a query up into IssueHoverCard
+ * would fire one per mention on render. (The chip inside the trigger has its
+ * own unresolved-issue fetch; that is independent of this.)
+ */
+export function IssueHoverCard({
+ issueId,
+ children,
+ fallbackLabel,
+ delay,
+}: IssueHoverCardProps) {
+ return (
+ <HoverCard>
+ {/* Rendered as a span, not the trigger's default anchor: the children are
+ already an AppLink, and an anchor inside an anchor is invalid. */}
+ <HoverCardTrigger delay={delay} render={<span />}>
+ {children}
+ </HoverCardTrigger>
+ <HoverCardContent align="start" className="w-auto min-w-56 max-w-80">
+ <IssueHoverCardBody issueId={issueId} fallbackLabel={fallbackLabel} />
+ </HoverCardContent>
+ </HoverCard>
+ );
+}
+
+/**
+ * Assignee row of the card.
+ *
+ * Its own component so `useActorName` — which subscribes to the workspace
+ * member list, a query nothing else on this path warms — mounts only for cards
+ * that actually have an assignee to name. Inlining it back into the body would
+ * make the first hover on any mention pull the member directory.
+ */
+function IssueHoverCardAssignee({
+ actorType,
+ actorId,
+}: {
+ actorType: string;
+ actorId: string;
+}) {
+ const { getActorName } = useActorName();
+ return (
+ <span className="flex min-w-0 items-center gap-1.5">
+ {/* This is already a hover card, and the agent live-peek variant would
+ fire its own request — so no nested card, no link. */}
+ <ActorAvatar
+ actorType={actorType}
+ actorId={actorId}
+ size="sm"
+ enableHoverCard={false}
+ profileLink={false}
+ className="shrink-0"
+ />
+ <span className="min-w-0 truncate text-caption text-foreground">
+ {getActorName(actorType, actorId)}
+ </span>
+ </span>
+ );
+}
+
+function IssueHoverCardBody({
+ issueId,
+ fallbackLabel,
+}: {
+ issueId: string;
+ fallbackLabel?: string;
+}) {
+ const wsId = useWorkspaceId();
+ const detail = useQuery(issueDetailOptions(wsId, issueId));
+ // One workspace-wide progress snapshot shared with the issues list and issue
+ // detail, not a per-issue children fetch: opening a card reuses the cache.
+ const { data: childProgress } = useQuery(childIssueProgressOptions(wsId));
+ const { t } = useT("issues");
+
+ // A skeleton rather than localized loading text: only the pending phase gets
+ // it, so a settled query never animates forever.
+ if (detail.isPending) {
+ return (
+ <div data-testid="issue-hover-card-skeleton" className="flex flex-col gap-1.5">
+ <Skeleton className="h-3 w-20" />
+ <Skeleton className="h-4 w-48" />
+ <Skeleton className="mt-1.5 h-3 w-44" />
+ <Skeleton className="mt-1.5 h-4 w-24" />
+ </div>
+ );
+ }
+
+ const issue = detail.data;
+
+ // Terminal state for every way the detail can fail to arrive: an error after
+ // retries, a deleted issue, or a mention the viewer cannot read. Named with
+ // the identifier the way the chip degrades, so the card still says which
+ // issue it is about.
+ if (detail.isError || !issue) {
+ return (
+ <div className="flex flex-col gap-1.5">
+ {fallbackLabel && (
+ <span className="text-caption font-medium text-muted-foreground">
+ {fallbackLabel}
+ </span>
+ )}
+ <p className="text-caption text-muted-foreground">{t(($) => $.detail.not_found)}</p>
+ </div>
+ );
+ }
+
+ const preview = issue.description ? descriptionPreview(issue.description) : "";
+ const assigneeType = issue.assignee_type;
+ const assigneeId = issue.assignee_id;
+ const hasAssignee = !!assigneeType && !!assigneeId;
+ const progress = childProgress?.get(issue.id);
+ const hasProgress = !!progress && progress.total > 0;
+ // Board cards and list rows render the glyph into a fixed grid slot, so the
+ // "none" dash holds a column there. This card has no column to hold, leaving
+ // the dash a mark carrying no information in an already dense popup.
+ const hasPriority = !!issue.priority && issue.priority !== "none";
+
+ return (
+ <div className="flex flex-col gap-1.5">
+ {/* Priority, status, identifier — the same lead-with-priority order as
+ BoardCardContent, at the icon size the status glyph already uses.
+ StatusIcon and PriorityIcon both render a bare <svg> that forwards no
+ aria props, so each glyph is named by an `role="img"` wrapper: on a
+ role-less span an aria-label is dropped by assistive tech. */}
+ <div className="flex items-center gap-1.5">
+ {hasPriority && (
+ <span role="img" aria-label={t(($) => $.priority[issue.priority])} className="flex">
+ <PriorityIcon priority={issue.priority} />
+ </span>
+ )}
+ <span
+ role="img"
+ aria-label={t(($) => $.status[issue.status])}
+ className="flex shrink-0"
+ >
+ <StatusIcon status={issue.status} className="h-3.5 w-3.5 shrink-0" />
+ </span>
+ <span className="text-caption font-medium text-muted-foreground">
+ {issue.identifier}
+ </span>
+ </div>
+ {/* The full title is the point of the card, so it never truncates — but
+ an unbroken token (a pasted URL) would blow past the max-w-80 cap
+ without a break opportunity. */}
+ <p className="text-body text-foreground break-words">{issue.title}</p>
+
+ {preview && (
+ <p className="mt-1 text-caption text-muted-foreground line-clamp-2">{preview}</p>
+ )}
+
+ {(hasAssignee || hasProgress) && (
+ <div className="mt-1 flex items-center justify-between gap-3">
+ {hasAssignee ? (
+ <IssueHoverCardAssignee actorType={assigneeType} actorId={assigneeId} />
+ ) : (
+ <span />
+ )}
+ {hasProgress && (
+ <span className="inline-flex shrink-0 items-center gap-1">
+ <ProgressRing done={progress.done} total={progress.total} size={12} />
+ <span className="text-caption font-medium tabular-nums text-muted-foreground">
+ {progress.done}/{progress.total}
+ </span>
+ </span>
+ )}
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/packages/views/issues/components/issue-mention-card.test.tsx b/packages/views/issues/components/issue-mention-card.test.tsx
index ea51605587..efa06d740d 100644
--- a/packages/views/issues/components/issue-mention-card.test.tsx
+++ b/packages/views/issues/components/issue-mention-card.test.tsx
@@ -66,6 +66,37 @@ describe("IssueMentionCard", () => {
expect(push).not.toHaveBeenCalled();
});
+ // The real IssueHoverCard is deliberately not mocked: the point of these two
+ // is that mentions get the card for real, and that wrapping the link in a
+ // trigger did not cost the link anything. Neither opens the card — the card's
+ // own contents are covered in issue-hover-card.test.tsx, and hovering here
+ // would only duplicate that file's query and avatar mocks.
+ it("wraps the mention in a real hover-card trigger", () => {
+ renderCard(makeAdapter());
+
+ const trigger = screen
+ .getByTestId("issue-chip")
+ .closest('[data-slot="hover-card-trigger"]');
+ expect(trigger).toBeInTheDocument();
+ // A span, not the trigger's default anchor: the link is inside it, and
+ // nested anchors would break both the DOM and the assertions above.
+ expect(trigger?.tagName).toBe("SPAN");
+ });
+
+ it("keeps the chip a navigable link inside the trigger", () => {
+ const push = vi.fn();
+ renderCard(makeAdapter({ push }));
+
+ const anchor = screen.getByTestId("issue-chip").closest("a");
+ expect(anchor).toHaveAttribute("href", "/acme/issues/issue-1");
+ expect(
+ anchor?.closest('[data-slot="hover-card-trigger"]'),
+ ).toBeInTheDocument();
+
+ fireEvent.click(screen.getByTestId("issue-chip"));
+ expect(push).toHaveBeenCalledWith("/acme/issues/issue-1");
+ });
+
it("cmd-click without an adapter (web) is left to the browser's native background-tab handling", () => {
const push = vi.fn();
renderCard(makeAdapter({ push }));
diff --git a/packages/views/issues/components/issue-mention-card.tsx b/packages/views/issues/components/issue-mention-card.tsx
index 1fab876e60..36bf1fcbef 100644
--- a/packages/views/issues/components/issue-mention-card.tsx
+++ b/packages/views/issues/components/issue-mention-card.tsx
@@ -3,6 +3,7 @@
import { AppLink } from "../../navigation";
import { useWorkspacePaths } from "@multica/core/paths";
import { IssueChip } from "./issue-chip";
+import { IssueHoverCard } from "./issue-hover-card";
interface IssueMentionCardProps {
issueId: string;
@@ -18,20 +19,27 @@ interface IssueMentionCardProps {
* AppLink owns the click semantics: plain click navigates in place, modifier
* and middle clicks open tabs. There is deliberately no per-surface or
* per-preference override.
+ *
+ * Hovering opens IssueHoverCard, which shows the detail the chip has no room
+ * for. No `delay` is passed, so it opens on Base UI's default dwell. The same
+ * `fallbackLabel` the chip degrades to names the card when the detail fetch
+ * fails.
*/
export function IssueMentionCard({ issueId, fallbackLabel }: IssueMentionCardProps) {
const p = useWorkspacePaths();
return (
- <AppLink
- href={p.issueDetail(issueId)}
- newTabTitle={fallbackLabel}
- className="issue-mention align-middle"
- >
- <IssueChip
- issueId={issueId}
- fallbackLabel={fallbackLabel}
- className="cursor-pointer hover:bg-accent transition-colors"
- />
- </AppLink>
+ <IssueHoverCard issueId={issueId} fallbackLabel={fallbackLabel}>
+ <AppLink
+ href={p.issueDetail(issueId)}
+ newTabTitle={fallbackLabel}
+ className="issue-mention align-middle"
+ >
+ <IssueChip
+ issueId={issueId}
+ fallbackLabel={fallbackLabel}
+ className="cursor-pointer hover:bg-accent transition-colors"
+ />
+ </AppLink>
+ </IssueHoverCard>
);
}