| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | | import { ExternalLinkIcon, PaperclipIcon, PlayIcon } from "lucide-react"; |
| 1 | import { ExternalLinkIcon, PaperclipIcon } from "lucide-react"; |
| 2 | 2 | import type { EnvironmentId, ScopedThreadRef } from "@t3tools/contracts"; |
| 3 | 3 | import { createContext, useContext, useMemo } from "react"; |
| 4 | 4 | import type { Options as ReactMarkdownOptions } from "react-markdown"; |
| ... | ... | @@ -6,17 +6,12 @@ import type { Options as ReactMarkdownOptions } from "react-markdown"; |
| 6 | 6 | import { cn } from "~/lib/utils"; |
| 7 | 7 | |
| 8 | 8 | import ChatMarkdown from "../ChatMarkdown"; |
| 9 | import { MediaVideoPlayer } from "../media/MediaVideoPlayer"; |
| 9 | 10 | import { remarkPullRequestAutolinks, splitPullRequestBody } from "./pullRequestMarkdown.logic"; |
| 10 | 11 | |
| 11 | 12 | export const PullRequestMarkdownContext = createContext<string | null>(null); |
| 12 | 13 | |
| 13 | | /** |
| 14 | | * A pull request body, rendered with the app's markdown renderer plus a card for each upload |
| 15 | | * embedded in it, which that renderer drops on the floor. |
| 16 | | * |
| 17 | | * These upload URLs do not identify the media format. The card links to GitHub, where the |
| 18 | | * original upload can be opened or downloaded even when its codec cannot play in the client. |
| 19 | | */ |
| 14 | /** Renders PR uploads inline, with retry and an original link when video playback fails. */ |
| 20 | 15 | export function PullRequestMarkdown({ |
| 21 | 16 | text, |
| 22 | 17 | cwd, |
| ... | ... | @@ -52,8 +47,18 @@ export function PullRequestMarkdown({ |
| 52 | 47 | /> |
| 53 | 48 | ); |
| 54 | 49 | } |
| 55 | | const isVideo = segment.media === "video"; |
| 56 | | const Icon = isVideo ? PlayIcon : PaperclipIcon; |
| 50 | if (segment.media === "video") { |
| 51 | return ( |
| 52 | <MediaVideoPlayer |
| 53 | key={`${segment.id}:${segment.url}`} |
| 54 | src={segment.url} |
| 55 | originalUrl={segment.url} |
| 56 | label="Pull request video" |
| 57 | className="w-full" |
| 58 | videoClassName="rounded-lg border border-border/60" |
| 59 | /> |
| 60 | ); |
| 61 | } |
| 57 | 62 | return ( |
| 58 | 63 | // A plain anchor rather than the page's openExternal button: the desktop window |
| 59 | 64 | // turns a blocked _blank into openExternal itself, and in a browser tab — where |
| ... | ... | @@ -65,10 +70,8 @@ export function PullRequestMarkdown({ |
| 65 | 70 | target="_blank" |
| 66 | 71 | 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" |
| 67 | 72 | > |
| 68 | | <Icon aria-hidden className="size-3.5 shrink-0 text-muted-foreground" /> |
| 69 | | <span className="min-w-0 flex-1 truncate"> |
| 70 | | {isVideo ? "Play video on GitHub" : "Open attachment on GitHub"} |
| 71 | | </span> |
| 73 | <PaperclipIcon aria-hidden className="size-3.5 shrink-0 text-muted-foreground" /> |
| 74 | <span className="min-w-0 flex-1 truncate">Open attachment on GitHub</span> |
| 72 | 75 | <ExternalLinkIcon aria-hidden className="size-3 shrink-0 text-muted-foreground" /> |
| 73 | 76 | </a> |
| 74 | 77 | ); |