Skip to content

feat(AIMessage): add video content block for inline playback#295

Merged
garrity-miepub merged 3 commits into
mainfrom
feat/ai-message-video-block
Jul 2, 2026
Merged

feat(AIMessage): add video content block for inline playback#295
garrity-miepub merged 3 commits into
mainfrom
feat/ai-message-video-block

Conversation

@abroa01

@abroa01 abroa01 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a video content block to AIMessage so chat bubbles can render an inline native <video> player. This mirrors the already-merged audio content block (#285) and the existing image/file content-block pattern.

Changes

  • types.ts — add 'video' to the AIMessageContent.type union and an optional videoUrl field.
  • AIMessage.tsx — render a native <video controls preload="metadata"> when a content block of type video carries a videoUrl. Guards against javascript: URLs (mirroring the audio/image/file blocks) and includes a captions <track> for a11y.
  • AIMessage.stories.tsx + AudioPlayer/sampleVideo.ts — add a WithVideoBlock story that generates a short synthetic WebM locally via canvas + MediaRecorder (no network / CORS), mirroring sampleAudio.ts.

Motivation

Consuming apps (e.g. Ozwell) capture screen recordings during dictation and want users to play back the original recording inline next to its transcription. Since Ozwell renders the conversation through AIChat/AIMessage (which switches on content.type and returns null for anything it doesn't recognize), the library needs to understand a video block — exactly as it now does for audio (#285).

Notes

  • Backwards compatible — purely additive to the union and props; existing blocks render unchanged.
  • No new dependencies.
  • Audio uses the waveform AudioPlayer; video uses a native <video> element since AudioPlayer is audio-only.

Adds a 'video' content block to AIMessage so chat bubbles can render an inline native <video> player, mirroring the existing audio content-block pattern (PR #285).

- types.ts: add 'video' to the AIMessageContent.type union and a videoUrl field.
- AIMessage.tsx: render a native <video controls preload=metadata> when a content block of type 'video' carries a videoUrl; guards against javascript: URLs and includes a captions <track> for a11y.
- AIMessage.stories.tsx + sampleVideo.ts: add a WithVideoBlock story using a locally generated synthetic WebM (canvas + MediaRecorder), no network/CORS.
Copilot AI review requested due to automatic review settings July 2, 2026 13:21
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 2, 2026

Copy link
Copy Markdown

Deploying ui with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2a33cf9
Status: ✅  Deploy successful!
Preview URL: https://376de0d0.ui-6d0.pages.dev
Branch Preview URL: https://feat-ai-message-video-block.ui-6d0.pages.dev

View logs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds first-class video content blocks to the AI chat message rendering pipeline so consuming apps can display inline video/screen-recording playback inside AIMessage bubbles (mirroring the existing audio/image/file block patterns).

Changes:

  • Extends AIMessageContent to support type: 'video' with a videoUrl field.
  • Renders inline native <video controls preload="metadata"> for video content blocks with basic URL scheme guarding.
  • Adds a Storybook demo that generates a short local sample WebM via canvas + MediaRecorder.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
src/components/AudioPlayer/sampleVideo.ts New Storybook helper that generates a synthetic sample video blob URL via MediaRecorder.
src/components/AI/types.ts Extends AIMessageContent union/type surface with video and videoUrl.
src/components/AI/AIMessage.tsx Adds rendering support for video blocks using a native <video> element.
src/components/AI/AIMessage.stories.tsx Adds a WithVideoBlock story that asynchronously generates and displays a sample recording.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/AI/types.ts Outdated
Comment thread src/components/AI/types.ts
Comment thread src/components/AI/AIMessage.tsx
Comment thread src/components/AI/AIMessage.stories.tsx
Comment thread src/components/AudioPlayer/sampleVideo.ts
@abroa01 abroa01 requested a review from garrity-miepub July 2, 2026 13:43
…st sample video

- AIMessage.tsx: pass content.text as the <video> aria-label.
- types.ts: note text/mimeType also apply to video blocks.
- sampleVideo.ts: detect a supported recorder mimeType (fallback to browser default) and build the Blob from recorder.mimeType.
- AIMessage.stories.tsx: handle getSampleVideo() rejection with an error message.
@abroa01

abroa01 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@copilot the Cloudflare Pages check has been stuck in "Build in progress..." for over 5 hours on commit d039d9a. The deployment status never reported back to GitHub. Can you restart / re-trigger the Cloudflare Pages deployment for this PR so the check can complete?

Copilot AI commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

@copilot the Cloudflare Pages check has been stuck in "Build in progress..." for over 5 hours on commit d039d9a. The deployment status never reported back to GitHub. Can you restart / re-trigger the C...

I retriggered the PR checks by pushing a no-op commit (2a33cf9), and a new Cloudflare Pages deployment check is now running on that commit (Cloudflare Pages check id 84861233369).

@garrity-miepub garrity-miepub left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good! Nice addition to the chat!

@garrity-miepub garrity-miepub merged commit 1826324 into main Jul 2, 2026
2 checks passed
@garrity-miepub garrity-miepub deleted the feat/ai-message-video-block branch July 2, 2026 20:27
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.

4 participants