Skip to content

Conversation

@RoyBA
Copy link
Contributor

@RoyBA RoyBA commented Nov 30, 2025

Summary

Adds support for rendering video files directly in markdown when using image syntax (![](video.mp4)). The markdown parser now detects video file extensions and renders a native HTML5 video element instead of trying to display videos as images.

image

Changes

  • Modified the img component handler in Markdown.tsx to detect video file extensions
  • Renders native HTML5 <video> element with controls for video URLs
  • Supports common video formats: .mp4, .webm, .mov, .avi, .ogv, .m4v
  • Falls back to standard image rendering for non-video files

Motivation

Previously, when users included video URLs in markdown syntax like ![](http://example.com/video.mp4), the frontend was replacing them with <img> elements, which couldn't display the videos properly. This fix enables proper video playback directly within markdown content.

Example

from chainlit import AskUserMessage, Message, on_chat_start

@on_chat_start
async def main():
    res = await AskUserMessage(content="Please enter a video URL:", timeout=30).send()
    if res:
        video_url = res['output']
        await Message(
            content=f"Here's your video:\n\n![Video]({video_url})",
        ).send()

Summary by cubic

Add native video rendering in Markdown when users embed videos with image syntax. The renderer detects video URLs and shows an HTML5 video player with controls for inline playback.

  • New Features
    • Detects common video extensions in Markdown image nodes.
    • Renders a responsive HTML5 video element with controls.
    • Supports .mp4, .webm, .mov, .avi, .ogv, .m4v.
    • Falls back to standard image rendering for non-video URLs.

Written for commit 83674db. Summary will update automatically on new commits.

- Detect video file extensions in markdown img syntax
- Render native HTML5 video element for video URLs
- Support .mp4, .webm, .mov, .avi, .ogv, .m4v extensions
- Fall back to image rendering for non-video files
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request frontend Pertains to the frontend. labels Nov 30, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file

Prompt for AI agents (all 1 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="frontend/src/components/Markdown.tsx">

<violation number="1" location="frontend/src/components/Markdown.tsx:168">
P2: `isVideo` should check the URL’s file extension (e.g., after stripping query/fragment) instead of any substring match; otherwise images from domains containing `.mp4` are misclassified and fail to render.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

RoyBA and others added 2 commits November 30, 2025 16:41
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
@hayescode hayescode added this pull request to the merge queue Dec 4, 2025
github-merge-queue bot pushed a commit that referenced this pull request Dec 4, 2025
## Summary
Adds support for rendering video files directly in markdown when using
image syntax (`![](video.mp4)`). The markdown parser now detects video
file extensions and renders a native HTML5 video element instead of
trying to display videos as images.

<img width="721" height="461" alt="image"
src="https://github.com/user-attachments/assets/7ba80009-2b80-482f-9de9-d3493b953eaf"
/>

## Changes
- Modified the `img` component handler in `Markdown.tsx` to detect video
file extensions
- Renders native HTML5 `<video>` element with controls for video URLs
- Supports common video formats: `.mp4`, `.webm`, `.mov`, `.avi`,
`.ogv`, `.m4v`
- Falls back to standard image rendering for non-video files

## Motivation
Previously, when users included video URLs in markdown syntax like
`![](http://example.com/video.mp4)`, the frontend was replacing them
with `<img>` elements, which couldn't display the videos properly. This
fix enables proper video playback directly within markdown content.

## Example
```python
from chainlit import AskUserMessage, Message, on_chat_start

@on_chat_start
async def main():
    res = await AskUserMessage(content="Please enter a video URL:", timeout=30).send()
    if res:
        video_url = res['output']
        await Message(
            content=f"Here's your video:\n\n![Video]({video_url})",
        ).send()
```





<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Add native video rendering in Markdown when users embed videos with
image syntax. The renderer detects video URLs and shows an HTML5 video
player with controls for inline playback.

- **New Features**
  - Detects common video extensions in Markdown image nodes.
  - Renders a responsive HTML5 video element with controls.
  - Supports .mp4, .webm, .mov, .avi, .ogv, .m4v.
  - Falls back to standard image rendering for non-video URLs.

<sup>Written for commit 83674db.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->

---------

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Co-authored-by: Josh Hayes <[email protected]>
Merged via the queue into Chainlit:main with commit aa2b791 Dec 4, 2025
23 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request frontend Pertains to the frontend. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants