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, because nothing here can play. A
14 * `github.com/user-attachments/assets/…` link is a 302 to a signed S3 URL that serves the file
15 * as uploaded — `video/quicktime` for anything recorded on a Mac, which no Chromium decodes —
16 * and the desktop window's content policy declares no `media-src`, so media falls back to
17 * `default-src 'self'` and every remote source is refused before a byte is fetched. A player
18 * here can only be the box that never fills in; a card that opens the host is a real answer.
19 */
20export function PullRequestMarkdown({
21 text,
22 cwd,
23 environmentId,
24 className,
25}: {
26 text: string;
27 cwd: string;
28 environmentId: EnvironmentId;
29 className?: string;
30}) {
31 const segments = splitPullRequestBody(text);
32 return (
33 <div className={cn("space-y-3", className)}>
34 {segments.map((segment) => {
35 if (segment.kind === "markdown") {
36 return (
37 <ChatMarkdown
38 key={segment.id}
39 text={segment.text}
40 cwd={cwd}
41 environmentId={environmentId}
42 />
43 );
44 }
45 const isVideo = segment.media === "video";
46 const Icon = isVideo ? PlayIcon : PaperclipIcon;
47 return (
48 // A plain anchor rather than the page's openExternal button: the desktop window
49 // turns a blocked _blank into openExternal itself, and in a browser tab — where
50 // there is no shell to call — this is the only one of the two that goes anywhere.
51 <a
52 key={segment.id}
53 href={segment.url}
54 rel="noreferrer noopener"
55 target="_blank"
56 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"
57 >
58 <Icon aria-hidden className="size-3.5 shrink-0 text-muted-foreground" />
59 <span className="min-w-0 flex-1 truncate">
60 {isVideo ? "Play video on GitHub" : "Open attachment on GitHub"}
61 </span>
62 <ExternalLinkIcon aria-hidden className="size-3 shrink-0 text-muted-foreground" />
63 </a>
64 );
65 })}
66 </div>
67 );
68}