Skip to content

feat: play agent-attached MP4s inline and serve chat files with byte ranges - #60

Merged
ibetitsmike merged 11 commits into
mainfrom
mike/todo-transcripts-9-attachment-video
Nov 9, 2026
Merged

ibetitsmike merged 11 commits into
mainfrom
mike/todo-transcripts-9-attachment-video

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Xum opened this PR on behalf of @ibetitsmike.

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 as video/mp4 and showed as a generic download card. Behind fork-chat-todos, a stored video/mp4 file block in an assistant message now renders the existing RecordingPreview (an inline frame with a play button, named "Play ", that opens VideoLightbox playback, 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.

  • Fork code is in ForkAttachmentPreview.tsx; upstream's MessageBlocks.tsx only wraps its file block in it. It reads DashboardContext with useContext, because the timeline stories and tests render without a DashboardProvider (useDashboard throws there); no provider means every fork experiment is off.
  • serveChatFile now uses http.ServeContent, so a Range request gets 206 with Content-Range and a plain GET still gets 200 with 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.
  • The model never receives the video bytes: chatprompt.ConvertMessagesWithFiles resolves file data only for user messages, so assistant file parts from attach_file are 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.tsx drives the play button in the review.mp4 figure with userEvent and the playback dialog opens with the experiment on; with it off there is no play control and the download link targets the file URL. The ExpiredVideo story 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. TestGetChatFileByteRange passes against Postgres 17 and fails on the old serveChatFile. TestGetChatFile and TestChatFileDownloadURL pass. pnpm lint (biome, oxlint, tsc, circular deps, compiler check, knip) and the ChatConversation and ChatElements Vitest suites pass.

UAT on a dev server built from 9806c043d8 (./scripts/develop.sh, member user): the MP4 was stored as a video/mp4 chat 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. With fork-chat-todos on, Chromium (Playwright) showed the open-in-coder.mp4 figure 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 (readyState 4, no media error). The browser fetched it with Range: bytes=0- and two seek ranges, and each got 206 with a matching Content-Range. A seek to 60% landed at 23 s. curl against the same file: bytes=0-1023 gives 206 with Content-Length: 1024, bytes=-100 gives 206, an out-of-range start gives 416 with bytes */1580565, and a plain GET gives 200 with identical bytes. With the experiment off, the same message shows the upstream MP4 download card and no <video> element.

…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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T19:10:13.272906Z 7984b00 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 13e5708e1a

ℹ️ 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".

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.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 1e733b05e5

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: c41c519845

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@ibetitsmike

ibetitsmike commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

frontend-deep-review result

Reviewed head: 0e0e8d9f8f7fbfeae20f91d408b6a69264be566a (round 5, after the round 4 fixes on c41c519845). Current head: 7984b00826ca9187c911053c8dbc5dd47ad1d587, which is the reviewed head plus the round 5 fixes below (one code comment and the removal of one JSDoc line, no behavior change).

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 frontend-review FE1 to FE10 audit.

Counts

Source Blocking Should-fix Nit
8 roles 0 10 3
FE1 to FE10 audit 1 1 4

Role verdicts: SD, RP and DF had no findings. FE2 to FE10 pass.

Fixed

  • CD1 (should-fix): the playLabel JSDoc only paraphrased the prop. I first made it state the "View recording" default. Codex then pointed out that the parameter list already shows the default, so 7984b00826 removes the JSDoc.
  • Audit nit, hasExpired gate: added a one-line comment in ForkAttachmentPreview.tsx. An expired file must fall back to the upstream card, because the fork caption would still offer a dead download link. RecordingPreview's own expired notice does not cover that link.

Round 4 fixes (in 0e0e8d9f8f): ExperimentOff story params, m-0 on the figure, caption download link classes aligned with MessageAttachmentCard, per-file play label ("Play review.mp4"), and no file_id ?? "" fallback.

Not changed, with reasons

  • FE1 blocking (ForkAttachmentPreview.test.tsx:50, the test ends on the "Recording playback" dialog), TS5, TS2 (both): the lead asked for a Vitest test that drives the play button. A <video> has no ARIA role, and the alternative is to mock useLightbox, which couples the test to the implementation. The experiment-off assertions catch a gate that is stuck on, and the download href does not show in a screenshot. Negative controls: breaking the gate in either direction or the media type check fails the test. I have flagged this conflict with FE1 to the lead.
  • FE1 should-fix (the evicted MP4 is covered only by a story): Codex review asked to move that case from Vitest to the ExpiredVideo story.
  • TS1 (story that opens the player): RecordingPreview.stories.tsx LightboxOpen already covers the open player. In Storybook the chat file URL returns 404, so a new story would capture an error state.
  • CD4 (fork banner names MessageBlocks.tsx): this matches the repository's fork banner convention (forkToolRenderers.ts, ForkComposerSlot.tsx), and round 4 comments-and-docs accepted it.
  • SA1 (w-fit wrapper): needed. A long caption widens the w-fit figure, and without the wrapper align-items: stretch widens the preview with it.
  • SA2 (shared icon download link variant): this needs edits to upstream AttachmentDownloadLink and MessageAttachmentCard. The classes now match MessageAttachmentCard exactly.
  • RO5 (serveChatFile change): the PR title and description state the backend change. The prompt's "(frontend part)" wording was stale.
  • TN5 should-fix (gate on fork-chat-todos): lead and PRD decision, W4 features ship behind fork-chat-todos.

Nits

  • TN5 nit (recordingFileId prop name): kept. The prop is upstream's, and renaming it touches upstream call sites.
  • TN6 nit ("Play Attached file" fallback): kept. It reuses upstream's display name fallback, so the label matches the caption.
  • TN6 nit (recording vocabulary in the player): kept. The player copy ("Recording playback", "Recording unavailable") is upstream's reused component.
  • Audit nit, FE1 experiment-off assertions: the audit graded them justified. They stay, as above.
  • Audit nit, FE3 useContext(DashboardContext): kept and disclosed in the PR description. Timeline stories and tests render without a DashboardProvider, and useDashboard throws there.
  • Audit nit, hasExpired comment: fixed (above).
  • Audit nit, fixture restates file_id: kept. MockChatVideoFilePart is typed ChatFilePart & { file_id: string }, and that type needs the field.

Outside-role notes, dropped

  • Duplicate DashboardContext test value (ForkComposerSlot.test.tsx): two small fork test copies. A shared wrapper is a separate refactor.
  • getChatFileURL next to the wrapped child's getAttachmentHref: both give the same URL. Codex review asked for the call after the guard, which is where it is now.
  • Only assistant messages get the inline player: attach_file MP4s only appear there. User-uploaded MP4s are out of scope (see the PR description).
  • media-has-caption rationale in upstream VideoLightbox.tsx: upstream code, not changed in this PR.

Validation

On 9806c043d8: biome, tsc, and the ChatConversation and ChatElements Vitest suites (1031 tests) pass. UAT re-run on 9806c043d8: the "Play open-in-coder.mp4" button opens playback, and every byte range request gets 206. On 7984b00826 (one JSDoc line removed): biome and tsc pass.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@ibetitsmike
ibetitsmike merged commit 15c1852 into main Nov 9, 2026
9 checks passed
@ibetitsmike
ibetitsmike deleted the mike/todo-transcripts-9-attachment-video branch November 9, 2026 19:20
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) merged this on behalf of @ibetitsmike.

Merge evidence for head 7984b00826ca9187c911053c8dbc5dd47ad1d587:

  • fork-ci run 42679471623 (pull_request, started 19:02:16Z, so it tested the merge with main b457b3f1bf): all 7 jobs passed, and all 9 check runs pass.
  • The branch is based on 106a9355f6 and does not contain main's feat(coderd): enforce custom agent tool policy on child chats #58 commit. feat(coderd): enforce custom agent tool policy on child chats #58 and this PR touch no files in common, and git merge-tree against main is clean.
  • Codex reviewed 7984b00826 at 19:10:09Z and raised one P1, to remove the children JSDoc in ForkAttachmentPreview.tsx. It was declined and resolved (r4516831991): the JSDoc states that children is the fallback rendering, not wrapped content. The lead confirmed the decline. The finding before it (r4516734192, a redundant playLabel JSDoc) was fixed in 7984b00826. 0 unresolved threads.
  • frontend-deep-review: feat: play agent-attached MP4s inline and serve chat files with byte ranges #60 (comment). The lead accepted the justification for the FE1 test and every other disposition.
  • Remote UAT passed on 9806c043d8. The one later commit deletes a JSDoc line and changes no code. The play button opens playback, and byte range requests return 206.
  • The feature is behind fork-chat-todos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant