Open History to see the last commit
1import { ExternalLinkIcon, PaperclipIcon, PlayIcon } from "lucide-react";
2import type { EnvironmentId } from "@t3tools/contracts";
3
4import { cn } from "~/lib/utils";
5
6import ChatMarkdown from "../ChatMarkdown";
7import { splitPullRequestBody } from "./pullRequestMarkdown.logic";
8
9/**
10 * A pull request body, rendered with the app's markdown renderer plus a card for each upload
11 * embedded in it, which that renderer drops on the floor.
12 *
13 * The card links out instead of playing in place. GitHub serves the file as uploaded — Mac
14 * recordings are `video/quicktime`, which no Chromium decodes — and the desktop window's
15 * `media-src` allows only `'self'`, the app scheme and `blob:`, so a remote source is refused
16 * before a byte is fetched. Opening the host works for every format.
17 */
18export function PullRequestMarkdown({
19 text,
20 cwd,
21 environmentId,
22 className,
23}: {
24 text: string;
25 cwd: string;
26 environmentId: EnvironmentId;
27 className?: string;
28}) {
29 const segments = splitPullRequestBody(text);
30 return (
31 <div className={cn("space-y-3", className)}>
32 {segments.map((segment) => {
33 if (segment.kind === "markdown") {
34 return (
35 <ChatMarkdown
36 key={segment.id}
37 text={segment.text}
38 cwd={cwd}
39 environmentId={environmentId}
40 />
41 );
42 }
43 const isVideo = segment.media === "video";
44 const Icon = isVideo ? PlayIcon : PaperclipIcon;
45 return (
46 // A plain anchor rather than the page's openExternal button: the desktop window
47 // turns a blocked _blank into openExternal itself, and in a browser tab — where
48 // there is no shell to call — this is the only one of the two that goes anywhere.
49 <a
50 key={segment.id}
51 href={segment.url}
52 rel="noreferrer noopener"
53 target="_blank"
54 className="flex items-center gap-2 rounded-lg border border-border/60 bg-muted/30 px-3 py-2 text-sm hover:bg-muted/60"
55 >
56 <Icon aria-hidden className="size-3.5 shrink-0 text-muted-foreground" />
57 <span className="min-w-0 flex-1 truncate">
58 {isVideo ? "Play video on GitHub" : "Open attachment on GitHub"}
59 </span>
60 <ExternalLinkIcon aria-hidden className="size-3 shrink-0 text-muted-foreground" />
61 </a>
62 );
63 })}
64 </div>
65 );
66}