import { ExternalLinkIcon, PaperclipIcon, PlayIcon } from "lucide-react"; import type { EnvironmentId } from "@t3tools/contracts"; import { cn } from "~/lib/utils"; import ChatMarkdown from "../ChatMarkdown"; import { splitPullRequestBody } from "./pullRequestMarkdown.logic"; /** * A pull request body, rendered with the app's markdown renderer plus a card for each upload * embedded in it, which that renderer drops on the floor. * * The card links out instead of playing in place. GitHub serves the file as uploaded — Mac * recordings are `video/quicktime`, which no Chromium decodes — and the desktop window's * `media-src` allows only `'self'`, the app scheme and `blob:`, so a remote source is refused * before a byte is fetched. Opening the host works for every format. */ export function PullRequestMarkdown({ text, cwd, environmentId, className, }: { text: string; cwd: string; environmentId: EnvironmentId; className?: string; }) { const segments = splitPullRequestBody(text); return (
{segments.map((segment) => { if (segment.kind === "markdown") { return ( ); } const isVideo = segment.media === "video"; const Icon = isVideo ? PlayIcon : PaperclipIcon; return ( // A plain anchor rather than the page's openExternal button: the desktop window // turns a blocked _blank into openExternal itself, and in a browser tab — where // there is no shell to call — this is the only one of the two that goes anywhere. {isVideo ? "Play video on GitHub" : "Open attachment on GitHub"} ); })}
); }