Repository navigation
feat: play agent-attached MP4s inline and serve chat files with byte ranges - #60
Conversation
…nt-attached MP4s inline Behind the fork-chat-todos experiment, a video/mp4 file block in an assistant message (an attach_file result) renders a native video player with the hover download button instead of the generic download card. Expired files and files the browser cannot play keep the download card.
… for MP4s serveChatFile now uses http.ServeContent so media requests get 206 partial responses; Safari needs them to play a video, including computer-use recordings. ForkAttachmentPreview reuses RecordingPreview instead of its own video element, keeps AttachmentBlocks.tsx unchanged, and gains a story.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6b5c5f39e9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…MP4 preview and keep its download The preview is a figure captioned with the file name and a download link, so attached videos stay distinguishable and downloadable from the message. Adds an experiment-off story.
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
The subtests shared the parent's context, whose deadline could pass while they waited for a parallel slot in CI. Also explains why only stored MP4s get the preview.
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…-9-attachment-video
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 05d8e96157
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…MP4 preview at its own size
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d038d87fd6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…expired card for an evicted MP4
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8792fb5482
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…r the expired MP4 in a story
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…lt and the expired MP4 fallback
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9806c043d8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
frontend-deep-review resultReviewed head: Roles (8): simplicity-and-dead-code, comments-and-docs, tests-and-stories, react-patterns, reuse-and-organization, styling-and-accessibility, types-and-naming, data-flow. Plus the Counts
Role verdicts: SD, RP and DF had no findings. FE2 to FE10 pass. Fixed
Round 4 fixes (in Not changed, with reasons
Nits
Outside-role notes, dropped
ValidationOn |
…he redundant play label doc
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7984b00826
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Merge evidence for head
|
Part of #10 (PRD R12.3: inline playback of attached MP4 files).
An MP4 that the agent attaches with
attach_file(for example a review video) is stored asvideo/mp4and showed as a generic download card. Behindfork-chat-todos, a storedvideo/mp4file block in an assistant message now renders the existingRecordingPreview(an inline frame with a play button, named "Play ", that opensVideoLightboxplayback, with the expired and playback-error states it already has) in a figure captioned with the file name and a download link. With the experiment off, or when the file has expired, the block is the upstream card.ForkAttachmentPreview.tsx; upstream'sMessageBlocks.tsxonly wraps its file block in it. It readsDashboardContextwithuseContext, because the timeline stories and tests render without aDashboardProvider(useDashboardthrows there); no provider means every fork experiment is off.serveChatFilenow useshttp.ServeContent, so aRangerequest gets206withContent-Rangeand a plainGETstill gets200with the full body. Content-Type is set before the call so it never sniffs, and the callers' Cache-Control and the Content-Disposition logic are unchanged. Safari needs range responses before it plays a video, so this also fixes Safari playback of computer-use recordings. This part has no experiment gate.chatprompt.ConvertMessagesWithFilesresolves file data only for user messages, so assistant file parts fromattach_fileare dropped from later model turns, and the tool result itself is JSON metadata. User-uploaded MP4s stay out of scope (they remain workspace file references).Validation:
ForkAttachmentPreview.test.tsxdrives the play button in thereview.mp4figure withuserEventand the playback dialog opens with the experiment on; with it off there is no play control and the download link targets the file URL. TheExpiredVideostory covers an evicted MP4, which falls back to the upstream expired card. Breaking the experiment gate in either direction or the media type check fails a test.TestGetChatFileByteRangepasses against Postgres 17 and fails on the oldserveChatFile.TestGetChatFileandTestChatFileDownloadURLpass.pnpm lint(biome, oxlint, tsc, circular deps, compiler check, knip) and theChatConversationandChatElementsVitest suites pass.UAT on a dev server built from
9806c043d8(./scripts/develop.sh, member user): the MP4 was stored as avideo/mp4chat file and linked to an assistant file part in the database, because the upload endpoint does not accept video and the agent path needs the shared local model, which was busy. Withfork-chat-todoson, Chromium (Playwright) showed theopen-in-coder.mp4figure as a 16:9 frame at the player's own width with its download link, opened "Recording playback" from the "Play open-in-coder.mp4" button, and played the 35 s, 1920x1224 H.264 file (readyState4, no media error). The browser fetched it withRange: bytes=0-and two seek ranges, and each got206with a matchingContent-Range. A seek to 60% landed at 23 s. curl against the same file:bytes=0-1023gives206withContent-Length: 1024,bytes=-100gives206, an out-of-range start gives416withbytes */1580565, and a plainGETgives200with identical bytes. With the experiment off, the same message shows the upstream MP4 download card and no<video>element.