@devries-cameron20 / t3code-1 / commits / 378584a760
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

feat(web): hovering an issue link shows its preview card (#38294)

Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: shivam <91240327+shivamhwp@users.noreply.github.com>

Bilal Bakr committed Nov 19, 2026 at 00:57 UTC 378584a7606cd0d1c1defddcb322efd77c822a3c
4 files changed +218 -4
apps/web/src/components/ChatMarkdown.browser.test.tsx
+1 -1
@@ -47,7 +47,7 @@ vi.mock(import("../state/server"), async (original) => {
47 const { Atom } = await import("effect/reactivity");
48 const noConfig = Atom.make(null);
49 const modelsConfig = Atom.make({
50 - environment: { platform: { os: "darwin" } },
50 + environment: { platform: { os: "darwin" }, capabilities: {} },
51 availableEditors: [],
52 settings: { providerInstances: {} },
53 providers: [
apps/web/src/components/ChatMarkdown.tsx
+30 -3
@@ -188,6 +188,7 @@ import {
188 workspaceLinkLookupQuery,
189 } from "@t3tools/client-runtime/workspace-basename-lookup";
190 import { resolvePullRequestPreviewTarget } from "@t3tools/client-runtime/change-request-links";
191 +import { resolveIssueLinkTarget } from "@t3tools/client-runtime/issue-links";
192 import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
193 import { useOpenChangeRequestLink } from "~/lib/openPullRequestLink";
194 import { textDirection } from "~/textDirection";
@@ -203,6 +204,7 @@ import {
204 } from "../browser/openFileInPreview";
205 import { resolveLinkTarget } from "../browser/browserLinkTarget";
206 import { PullRequestLinkPreview } from "./pullRequest/PullRequestLinkPreview";
207 +import { IssueLinkPreview, IssueLinkPreviewFallback } from "./issue/IssueLinkPreview";
208 import { MarkdownCodeBlock, SuspenseShikiCodeBlock } from "./chat/MarkdownCodeBlock";
209 import { createMarkdownRenderer } from "./chat/markdownRenderer";
210 import { splitMarkdownBlocks } from "./chat/markdownStreamBlocks";
@@ -444,6 +446,7 @@ type MarkdownServerConfigFields = ReturnType<typeof markdownServerConfigFields>;
446 function markdownServerConfigFields(config: ServerConfig | null) {
447 return {
448 pullRequestsEnabled: config !== null,
449 + issuesEnabled: config?.environment.capabilities.issues === true,
450 isMacOS: config?.environment.platform.os === "darwin",
451 availableEditors: config?.availableEditors ?? NO_MARKDOWN_EDITORS,
452 revealInFileManager:
@@ -459,6 +462,7 @@ function markdownServerConfigFieldsEqual(
462 ): boolean {
463 return (
464 previous.pullRequestsEnabled === next.pullRequestsEnabled &&
465 + previous.issuesEnabled === next.issuesEnabled &&
466 previous.isMacOS === next.isMacOS &&
467 previous.revealInFileManager === next.revealInFileManager &&
468 previous.availableEditors.length === next.availableEditors.length &&
@@ -662,9 +666,8 @@ function useChatMarkdownState({
666 },
667 );
668 };
665 - const { pullRequestsEnabled, availableEditors, revealInFileManager, isMacOS } = useAtomValue(
666 - markdownServerConfigFieldsAtom(environmentId),
667 - );
669 + const { pullRequestsEnabled, issuesEnabled, availableEditors, revealInFileManager, isMacOS } =
670 + useAtomValue(markdownServerConfigFieldsAtom(environmentId));
671 const revealInFileManagerLabel =
672 revealInFileManager === undefined
673 ? undefined
@@ -674,6 +677,7 @@ function useChatMarkdownState({
677 ? revealInFileExplorerLabelForKind(revealInFileManager, messages)
678 : revealInFileExplorerLabelForOs(revealInFileManager, messages);
679 const projects = useProjects();
680 + const issueProjects = projects.filter((project) => project.environmentId === environmentId);
681 const [preferredEditor] = usePreferredEditor(availableEditors);
682 const preferredEditorMenuLabel = openInEditorMenuLabel(preferredEditor, messages);
683 const openInPreferredEditor = useOpenInPreferredEditor(environmentId, availableEditors, cwd);
@@ -1022,10 +1026,12 @@ function useChatMarkdownState({
1026 openExternalLinkInPreview,
1027 openMarkdownMedia,
1028 projects,
1029 + issueProjects,
1030 linkedThreadPullRequestFor,
1031 resolveThreadPullRequest,
1032 resolvedTheme,
1033 pullRequestsEnabled,
1034 + issuesEnabled,
1035 skills,
1036 threadRef,
1037 updateThreadPullRequestLink,
@@ -1191,9 +1197,11 @@ const CHAT_MARKDOWN_COMPONENTS = {
1197 linkTargetPreference,
1198 openExternalLinkInPreview,
1199 projects,
1200 + issueProjects,
1201 linkedThreadPullRequestFor,
1202 resolveThreadPullRequest,
1203 pullRequestsEnabled,
1204 + issuesEnabled,
1205 updateThreadPullRequestLink,
1206 fileLinkChip,
1207 renderContextReference,
@@ -1258,6 +1266,17 @@ const CHAT_MARKDOWN_COMPONENTS = {
1266 url: pullRequestCandidateUrl,
1267 })
1268 : null;
1269 + const issueTarget =
1270 + issuesEnabled && environmentId !== null && href
1271 + ? resolveIssueLinkTarget({
1272 + url: href,
1273 + projects: issueProjects,
1274 + })
1275 + : null;
1276 + const issuePreviewTarget =
1277 + issueTarget === null || environmentId === null
1278 + ? null
1279 + : { environmentId, input: issueTarget.ref };
1280 const isSameDocumentLink = href?.startsWith("#") ?? false;
1281 const onClick = props.onClick;
1282 const canOpenInPreview =
@@ -1447,9 +1466,17 @@ const CHAT_MARKDOWN_COMPONENTS = {
1466 );
1467 if (!opened) await openDeferredMarkdownLink(url);
1468 }}
1469 + fallback={
1470 + issuePreviewTarget === null ? undefined : (
1471 + <IssueLinkPreviewFallback originalUrl={href} target={issuePreviewTarget} />
1472 + )
1473 + }
1474 />
1475 );
1476 }
1477 + if (issuePreviewTarget !== null) {
1478 + return <IssueLinkPreview link={link} originalUrl={href} target={issuePreviewTarget} />;
1479 + }
1480 return (
1481 <Tooltip>
1482 <TooltipTrigger render={link} />
apps/web/src/components/issue/IssueLinkPreview.browser.test.tsx new
+74
@@ -0,0 +1,74 @@
1 +import { EnvironmentId, IssueTrackerKind, ProjectId } from "@t3tools/contracts";
2 +import { expect, it, vi } from "vite-plus/test";
3 +import { page, userEvent } from "vite-plus/test/browser";
4 +
5 +const state = vi.hoisted(() => ({ detail: null as unknown, error: null as unknown }));
6 +vi.mock(import("~/state/query"), async (original) => ({
7 + ...(await original()),
8 + useEnvironmentQuery: ((atom: unknown) => ({
9 + data: atom === null ? null : state.detail,
10 + dataUpdatedAt: 0,
11 + error: atom === null ? null : state.error,
12 + failure: null,
13 + isPending: false,
14 + isSuccess: state.detail !== null,
15 + refresh: () => undefined,
16 + })) as never,
17 +}));
18 +
19 +import { render } from "../../../test/render";
20 +import { IssueLinkPreview } from "./IssueLinkPreview";
21 +
22 +const url = "https://github.com/owner/repo/issues/7";
23 +
24 +function setup({ detail = null as unknown, error = null as unknown } = {}) {
25 + state.detail = detail;
26 + state.error = error;
27 +}
28 +
29 +function renderPreview() {
30 + return render(
31 + <IssueLinkPreview
32 + link={<a href={url}>#7</a>}
33 + originalUrl={url}
34 + target={{
35 + environmentId: EnvironmentId.make("environment"),
36 + input: {
37 + projectId: ProjectId.make("project"),
38 + tracker: IssueTrackerKind.make("github"),
39 + scope: "owner/repo",
40 + key: "7",
41 + },
42 + }}
43 + />,
44 + );
45 +}
46 +
47 +it("shows the issue's title, state and author on hover", async () => {
48 + setup({
49 + detail: {
50 + scope: "owner/repo",
51 + displayKey: "#7",
52 + title: "Hover cards for issues",
53 + state: { category: "closed", name: "Closed", closeReason: "completed" },
54 + author: { login: "octocat" },
55 + createdAt: "2026-08-01T00:00:00Z",
56 + },
57 + });
58 + await using screen = await renderPreview();
59 +
60 + await userEvent.hover(screen.getByRole("link"));
61 +
62 + await expect.element(page.getByText("Hover cards for issues")).toBeVisible();
63 + await expect.element(page.getByText("Closed", { exact: true })).toBeVisible();
64 + await expect.element(page.getByText("octocat")).toBeVisible();
65 +});
66 +
67 +it("falls back to the link's URL when the issue cannot be read", async () => {
68 + setup({ error: new Error("unavailable") });
69 + await using screen = await renderPreview();
70 +
71 + await userEvent.hover(screen.getByRole("link"));
72 +
73 + await expect.element(page.getByText(url)).toBeVisible();
74 +});
apps/web/src/components/issue/IssueLinkPreview.tsx new
+113
@@ -0,0 +1,113 @@
1 +import type { PreviewCard as PreviewCardPrimitive } from "@base-ui/react/preview-card";
2 +import type { EnvironmentId, IssueDetail, IssueRef } from "@t3tools/contracts";
3 +import { T, Var } from "gt-react";
4 +import { useRef, useState, type ComponentPropsWithoutRef, type ReactElement } from "react";
5 +
6 +import { RelativeTime } from "~/components/RelativeTime";
7 +import { issueEnvironment } from "~/state/issues";
8 +import { useEnvironmentQuery } from "~/state/query";
9 +
10 +import { PullRequestActorAvatar } from "../pullRequest/pullRequestPresentation";
11 +import { PreviewCard, PreviewCardPopup, PreviewCardTrigger } from "../ui/preview-card";
12 +import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
13 +import { issueStatePresentation } from "./issuePresentation";
14 +
15 +export interface IssueLinkPreviewTarget {
16 + readonly environmentId: EnvironmentId;
17 + readonly input: IssueRef;
18 +}
19 +
20 +export function IssueLinkPreview({
21 + link,
22 + originalUrl,
23 + target,
24 +}: {
25 + link: ReactElement<ComponentPropsWithoutRef<"a">>;
26 + originalUrl: string;
27 + target: IssueLinkPreviewTarget;
28 +}) {
29 + const [open, setOpen] = useState(false);
30 + const previewActionsRef = useRef<PreviewCardPrimitive.Root.Actions | null>(null);
31 + const detailQuery = useEnvironmentQuery(open ? issueEnvironment.detail(target) : null);
32 + const detail = detailQuery.data;
33 + const showUrlTooltip = open && detailQuery.error !== null && detail === null;
34 +
35 + return (
36 + <PreviewCard open={open} onOpenChange={setOpen} actionsRef={previewActionsRef}>
37 + <Tooltip
38 + open={showUrlTooltip}
39 + onOpenChange={(nextOpen) => {
40 + if (!nextOpen && detail === null) previewActionsRef.current?.close();
41 + }}
42 + >
43 + <PreviewCardTrigger
44 + render={<TooltipTrigger render={link} />}
45 + delay={350}
46 + closeDelay={120}
47 + />
48 + <TooltipPopup side="top">{originalUrl}</TooltipPopup>
49 + </Tooltip>
50 + {detail === null ? null : (
51 + <PreviewCardPopup align="center" className="w-80 max-w-[calc(100vw-2rem)]">
52 + <div className="p-3">
53 + <IssuePreviewCardBody detail={detail} />
54 + </div>
55 + </PreviewCardPopup>
56 + )}
57 + </PreviewCard>
58 + );
59 +}
60 +
61 +/** A pull request card's fallback when its reference turns out to be an issue. */
62 +export function IssueLinkPreviewFallback({
63 + originalUrl,
64 + target,
65 +}: {
66 + originalUrl: string;
67 + target: IssueLinkPreviewTarget;
68 +}) {
69 + const detail = useEnvironmentQuery(issueEnvironment.detail(target)).data;
70 + return detail === null ? (
71 + <p className="break-all text-xs text-muted-foreground">{originalUrl}</p>
72 + ) : (
73 + <IssuePreviewCardBody detail={detail} />
74 + );
75 +}
76 +
77 +function IssuePreviewCardBody({ detail }: { detail: IssueDetail }) {
78 + const state = issueStatePresentation(detail.state);
79 + const createdAt = <RelativeTime timestamp={detail.createdAt} />;
80 + const author = detail.author;
81 + const authorLabel =
82 + author === null
83 + ? "ghost"
84 + : author.name && author.name !== author.login
85 + ? `${author.name} (@${author.login})`
86 + : author.login;
87 + return (
88 + <div className="min-w-0">
89 + <div className="flex min-w-0 items-center gap-1.5 text-2xs text-muted-foreground">
90 + <span className="min-w-0 truncate">{detail.scope}</span>
91 + <span className="shrink-0">{detail.displayKey}</span>
92 + <span aria-hidden>·</span>
93 + <span className="inline-flex shrink-0 items-center gap-1">
94 + <state.Icon aria-hidden className={`size-3 ${state.toneClassName}`} />
95 + {state.label}
96 + </span>
97 + </div>
98 + <p className="mt-1 text-sm font-medium leading-snug text-foreground text-pretty">
99 + {detail.title}
100 + </p>
101 + <div className="mt-2 flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground">
102 + <PullRequestActorAvatar actor={author} className="size-4" />
103 + <span className="min-w-0 truncate">{authorLabel}</span>
104 + <span aria-hidden>·</span>
105 + <span className="shrink-0">
106 + <T>
107 + opened <Var>{createdAt}</Var>
108 + </T>
109 + </span>
110 + </div>
111 + </div>
112 + );
113 +}