| ... | @@ -1,4 +1,4 @@ | ... | @@ -1,4 +1,4 @@ |
| 1 | import { ExternalLinkIcon, PaperclipIcon, PlayIcon } from "lucide-react"; | 1 | import { ExternalLinkIcon, PaperclipIcon } from "lucide-react"; |
| 2 | import type { EnvironmentId, ScopedThreadRef } from "@t3tools/contracts"; | 2 | import type { EnvironmentId, ScopedThreadRef } from "@t3tools/contracts"; |
| 3 | import { createContext, useContext, useMemo } from "react"; | 3 | import { createContext, useContext, useMemo } from "react"; |
| 4 | import type { Options as ReactMarkdownOptions } from "react-markdown"; | 4 | import type { Options as ReactMarkdownOptions } from "react-markdown"; |
| ... | @@ -6,17 +6,12 @@ import type { Options as ReactMarkdownOptions } from "react-markdown"; | ... | @@ -6,17 +6,12 @@ import type { Options as ReactMarkdownOptions } from "react-markdown"; |
| 6 | import { cn } from "~/lib/utils"; | 6 | import { cn } from "~/lib/utils"; |
| 7 | | 7 | |
| 8 | import ChatMarkdown from "../ChatMarkdown"; | 8 | import ChatMarkdown from "../ChatMarkdown"; |
| | 9 | import { MediaVideoPlayer } from "../media/MediaVideoPlayer"; |
| 9 | import { remarkPullRequestAutolinks, splitPullRequestBody } from "./pullRequestMarkdown.logic"; | 10 | import { remarkPullRequestAutolinks, splitPullRequestBody } from "./pullRequestMarkdown.logic"; |
| 10 | | 11 | |
| 11 | export const PullRequestMarkdownContext = createContext<string | null>(null); | 12 | export const PullRequestMarkdownContext = createContext<string | null>(null); |
| 12 | | 13 | |
| 13 | /** | 14 | /** Renders PR uploads inline, with retry and an original link when video playback fails. */ |
| 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 | */ | | |
| 20 | export function PullRequestMarkdown({ | 15 | export function PullRequestMarkdown({ |
| 21 | text, | 16 | text, |
| 22 | cwd, | 17 | cwd, |
| ... | @@ -52,8 +47,18 @@ export function PullRequestMarkdown({ | ... | @@ -52,8 +47,18 @@ export function PullRequestMarkdown({ |
| 52 | /> | 47 | /> |
| 53 | ); | 48 | ); |
| 54 | } | 49 | } |
| 55 | const isVideo = segment.media === "video"; | 50 | if (segment.media === "video") { |
| 56 | const Icon = isVideo ? PlayIcon : PaperclipIcon; | 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 | return ( | 62 | return ( |
| 58 | // A plain anchor rather than the page's openExternal button: the desktop window | 63 | // A plain anchor rather than the page's openExternal button: the desktop window |
| 59 | // turns a blocked _blank into openExternal itself, and in a browser tab — where | 64 | // turns a blocked _blank into openExternal itself, and in a browser tab — where |
| ... | @@ -65,10 +70,8 @@ export function PullRequestMarkdown({ | ... | @@ -65,10 +70,8 @@ export function PullRequestMarkdown({ |
| 65 | target="_blank" | 70 | target="_blank" |
| 66 | 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" | 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" /> | 73 | <PaperclipIcon aria-hidden className="size-3.5 shrink-0 text-muted-foreground" /> |
| 69 | <span className="min-w-0 flex-1 truncate"> | 74 | <span className="min-w-0 flex-1 truncate">Open attachment on GitHub</span> |
| 70 | {isVideo ? "Play video on GitHub" : "Open attachment on GitHub"} | | |
| 71 | </span> | | |
| 72 | <ExternalLinkIcon aria-hidden className="size-3 shrink-0 text-muted-foreground" /> | 75 | <ExternalLinkIcon aria-hidden className="size-3 shrink-0 text-muted-foreground" /> |
| 73 | </a> | 76 | </a> |
| 74 | ); | 77 | ); |