Add support for video references in MiniMax H3 ref2va

This commit is contained in:
Jaret Burkett
2026-08-15 06:18:09 -06:00
parent 4900e5e866
commit 97bf49edad
10 changed files with 668 additions and 74 deletions

View File

@@ -7,6 +7,9 @@ import { FaUpload, FaImage, FaTimes } from 'react-icons/fa';
import { apiClient } from '@/utils/api';
import type { AxiosProgressEvent } from 'axios';
const VIDEO_EXTS = ['.mp4', '.mov', '.webm', '.mkv', '.avi', '.m4v', '.wmv', '.flv'];
const isVideoPath = (p: string) => VIDEO_EXTS.some(ext => p.toLowerCase().endsWith(ext));
interface Props {
src: string | null | undefined;
className?: string;
@@ -27,7 +30,8 @@ export default function SampleControlImage({
const backgroundUrl = useMemo(() => {
if (localPreview) return localPreview;
if (src) return `/api/img/${encodeURIComponent(src)}`;
// videos preview as a server-generated thumbnail
if (src) return `/api/img/${encodeURIComponent(src)}${isVideoPath(src) ? '?thumb=1' : ''}`;
return null;
}, [src, localPreview]);
@@ -37,8 +41,10 @@ export default function SampleControlImage({
setIsUploading(true);
setUploadProgress(0);
const objectUrl = URL.createObjectURL(file);
setLocalPreview(objectUrl);
// an object URL only works as a background preview for images; video
// previews come from the server thumbnail after the upload lands
const objectUrl = file.type.startsWith('image/') ? URL.createObjectURL(file) : null;
if (objectUrl) setLocalPreview(objectUrl);
const formData = new FormData();
formData.append('files', file);
@@ -62,7 +68,7 @@ export default function SampleControlImage({
} finally {
setIsUploading(false);
setUploadProgress(0);
URL.revokeObjectURL(objectUrl);
if (objectUrl) URL.revokeObjectURL(objectUrl);
if (fileInputRef.current) fileInputRef.current.value = '';
}
},
@@ -94,7 +100,10 @@ export default function SampleControlImage({
// Drag & drop only; click handled via our own hidden input
const { getRootProps, isDragActive } = useDropzone({
onDrop,
accept: { 'image/*': ['.png', '.jpg', '.jpeg', '.gif', '.bmp', '.webp'] },
accept: {
'image/*': ['.png', '.jpg', '.jpeg', '.gif', '.bmp', '.webp'],
'video/*': VIDEO_EXTS,
},
multiple: false,
noClick: true,
noKeyboard: true,
@@ -128,7 +137,7 @@ export default function SampleControlImage({
<input
ref={fileInputRef}
type="file"
accept="image/*"
accept="image/*,video/*"
className="hidden"
onChange={e => {
const file = e.currentTarget.files?.[0];