Skip to content
TypeScript

fix(web): play pull request videos inline (#10617)

maria569a8cd2c330
diff --git a/apps/web/src/components/pullRequest/PullRequestMarkdown.tsx b/apps/web/src/components/pullRequest/PullRequestMarkdown.tsx
index 5e9db1347ce..190dd4fa8ec 100644
--- a/apps/web/src/components/pullRequest/PullRequestMarkdown.tsx
+++ b/apps/web/src/components/pullRequest/PullRequestMarkdown.tsx
@@ -1,4 +1,4 @@
-import { ExternalLinkIcon, PaperclipIcon, PlayIcon } from "lucide-react";
+import { ExternalLinkIcon, PaperclipIcon } from "lucide-react";
import type { EnvironmentId, ScopedThreadRef } from "@t3tools/contracts";
import { createContext, useContext, useMemo } from "react";
import type { Options as ReactMarkdownOptions } from "react-markdown";
@@ -6,17 +6,12 @@ import type { Options as ReactMarkdownOptions } from "react-markdown";
import { cn } from "~/lib/utils";
import ChatMarkdown from "../ChatMarkdown";
+import { MediaVideoPlayer } from "../media/MediaVideoPlayer";
import { remarkPullRequestAutolinks, splitPullRequestBody } from "./pullRequestMarkdown.logic";
export const PullRequestMarkdownContext = createContext<string | null>(null);
-/**
- * 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.
- *
- * These upload URLs do not identify the media format. The card links to GitHub, where the
- * original upload can be opened or downloaded even when its codec cannot play in the client.
- */
+/** Renders PR uploads inline, with retry and an original link when video playback fails. */
export function PullRequestMarkdown({
text,
cwd,
@@ -52,8 +47,18 @@ export function PullRequestMarkdown({
/>
);
}
- const isVideo = segment.media === "video";
- const Icon = isVideo ? PlayIcon : PaperclipIcon;
+ if (segment.media === "video") {
+ return (
+ <MediaVideoPlayer
+ key={`${segment.id}:${segment.url}`}
+ src={segment.url}
+ originalUrl={segment.url}
+ label="Pull request video"
+ className="w-full"
+ videoClassName="rounded-lg border border-border/60"
+ />
+ );
+ }
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
@@ -65,10 +70,8 @@ export function PullRequestMarkdown({
target="_blank"
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"
>
- <Icon aria-hidden className="size-3.5 shrink-0 text-muted-foreground" />
- <span className="min-w-0 flex-1 truncate">
- {isVideo ? "Play video on GitHub" : "Open attachment on GitHub"}
- </span>
+ <PaperclipIcon aria-hidden className="size-3.5 shrink-0 text-muted-foreground" />
+ <span className="min-w-0 flex-1 truncate">Open attachment on GitHub</span>
<ExternalLinkIcon aria-hidden className="size-3 shrink-0 text-muted-foreground" />
</a>
);