Skip to content

🎥 Make videos programmatically with React

@remotion/convert: Add 1GB file size warning and make contact field mandatory

copilot-swe-agent[bot]f48e5707070e
diff --git a/packages/convert/app/components/DropZone.tsx b/packages/convert/app/components/DropZone.tsx
index 5bdfd9507f..9e910c526c 100644
--- a/packages/convert/app/components/DropZone.tsx
+++ b/packages/convert/app/components/DropZone.tsx
@@ -30,21 +30,42 @@ type State =
export const DropZone: React.FC<{
readonly onUrl: (src: string) => void;
readonly onFilename: (filename: string) => void;
-}> = ({onUrl, onFilename}) => {
+ readonly onError?: (error: string) => void;
+ readonly maxSizeBytes?: number;
+}> = ({onUrl, onFilename, onError, maxSizeBytes}) => {
const [progress, setProgress] = useState<State>({type: 'idle'});
const selectVideo = useCallback(
async (file: File) => {
+ // Clear any previous errors
+ onError?.('');
+
+ // Check file size if maxSizeBytes is provided
+ if (maxSizeBytes && file.size > maxSizeBytes) {
+ const sizeMB = Math.round(file.size / (1024 * 1024));
+ const maxSizeMB = Math.round(maxSizeBytes / (1024 * 1024));
+ const errorMessage = `File size (${sizeMB} MB) exceeds the maximum limit of ${maxSizeMB} MB.`;
+ onError?.(errorMessage);
+ return;
+ }
+
onFilename(file.name);
setProgress({type: 'waiting-for-presign'});
- const url = await handleDrop({
- file,
- onProgress: (p) => setProgress({type: 'progress', progress: p}),
- });
- setProgress({type: 'done', url, filename: file.name, size: file.size});
- onUrl(url);
+ try {
+ const url = await handleDrop({
+ file,
+ onProgress: (p) => setProgress({type: 'progress', progress: p}),
+ });
+ setProgress({type: 'done', url, filename: file.name, size: file.size});
+ onUrl(url);
+ } catch (err) {
+ setProgress({type: 'idle'});
+ onError?.(
+ `Upload failed: ${err instanceof Error ? err.message : 'Unknown error'}`,
+ );
+ }
},
- [onFilename, onUrl],
+ [onFilename, onUrl, onError, maxSizeBytes],
);
const onDrop: React.DragEventHandler = useCallback(
diff --git a/packages/convert/app/components/ui/checkbox.tsx b/packages/convert/app/components/ui/checkbox.tsx
index bc15af2b17..29a5e885d6 100644
--- a/packages/convert/app/components/ui/checkbox.tsx
+++ b/packages/convert/app/components/ui/checkbox.tsx
@@ -1,28 +1,28 @@
-import * as React from "react"
-import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
-import { Check } from "lucide-react"
+import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
+import {Check} from 'lucide-react';
+import * as React from 'react';
-import { cn } from "~/lib/utils"
+import {cn} from '~/lib/utils';
const Checkbox = React.forwardRef<
- React.ElementRef<typeof CheckboxPrimitive.Root>,
- React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
->(({ className, ...props }, ref) => (
- <CheckboxPrimitive.Root
- ref={ref}
- className={cn(
- "peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
- className
- )}
- {...props}
- >
- <CheckboxPrimitive.Indicator
- className={cn("flex items-center justify-center text-current")}
- >
- <Check className="h-4 w-4" />
- </CheckboxPrimitive.Indicator>
- </CheckboxPrimitive.Root>
-))
-Checkbox.displayName = CheckboxPrimitive.Root.displayName
+ React.ElementRef<typeof CheckboxPrimitive.Root>,
+ React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
+>(({className, ...props}, ref) => (
+ <CheckboxPrimitive.Root
+ ref={ref}
+ className={cn(
+ 'peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground',
+ className,
+ )}
+ {...props}
+ >
+ <CheckboxPrimitive.Indicator
+ className={cn('flex items-center justify-center text-current')}
+ >
+ <Check className="h-4 w-4" />
+ </CheckboxPrimitive.Indicator>
+ </CheckboxPrimitive.Root>
+));
+Checkbox.displayName = CheckboxPrimitive.Root.displayName;
-export { Checkbox }
+export {Checkbox};
diff --git a/packages/convert/app/components/ui/label.tsx b/packages/convert/app/components/ui/label.tsx
index dbefb85dd8..c7850a6f52 100644
--- a/packages/convert/app/components/ui/label.tsx
+++ b/packages/convert/app/components/ui/label.tsx
@@ -1,24 +1,24 @@
-import * as React from "react"
-import * as LabelPrimitive from "@radix-ui/react-label"
-import { cva, type VariantProps } from "class-variance-authority"
+import * as LabelPrimitive from '@radix-ui/react-label';
+import {cva, type VariantProps} from 'class-variance-authority';
+import * as React from 'react';
-import { cn } from "~/lib/utils"
+import {cn} from '~/lib/utils';
const labelVariants = cva(
- "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
-)
+ 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',
+);
const Label = React.forwardRef<
- React.ElementRef<typeof LabelPrimitive.Root>,
- React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
- VariantProps<typeof labelVariants>
->(({ className, ...props }, ref) => (
- <LabelPrimitive.Root
- ref={ref}
- className={cn(labelVariants(), className)}
- {...props}
- />
-))
-Label.displayName = LabelPrimitive.Root.displayName
+ React.ElementRef<typeof LabelPrimitive.Root>,
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
+ VariantProps<typeof labelVariants>
+>(({className, ...props}, ref) => (
+ <LabelPrimitive.Root
+ ref={ref}
+ className={cn(labelVariants(), className)}
+ {...props}
+ />
+));
+Label.displayName = LabelPrimitive.Root.displayName;
-export { Label }
+export {Label};
diff --git a/packages/convert/app/lib/utils.ts b/packages/convert/app/lib/utils.ts
index bd0c391ddd..1faa41b439 100644
--- a/packages/convert/app/lib/utils.ts
+++ b/packages/convert/app/lib/utils.ts
@@ -1,6 +1,6 @@
-import { clsx, type ClassValue } from "clsx"
-import { twMerge } from "tailwind-merge"
+import {clsx, type ClassValue} from 'clsx';
+import {twMerge} from 'tailwind-merge';
export function cn(...inputs: ClassValue[]) {
- return twMerge(clsx(inputs))
+ return twMerge(clsx(inputs));
}
diff --git a/packages/convert/app/routes/convert.$action.tsx b/packages/convert/app/routes/convert.$action.tsx
index 25fe3b4505..44945c4adb 100644
--- a/packages/convert/app/routes/convert.$action.tsx
+++ b/packages/convert/app/routes/convert.$action.tsx
@@ -1,7 +1,7 @@
import {useParams} from '@remix-run/react';
import {useMemo} from 'react';
import {Main} from '~/components/Main';
-import type { RouteAction} from '~/seo';
+import type {RouteAction} from '~/seo';
import {parseConvertRouteAction} from '~/seo';
const Index = () => {
diff --git a/packages/convert/app/routes/report._index.tsx b/packages/convert/app/routes/report._index.tsx
index 512abee569..61b086f655 100644
--- a/packages/convert/app/routes/report._index.tsx
+++ b/packages/convert/app/routes/report._index.tsx
@@ -11,6 +11,9 @@ import {Textarea} from '~/components/ui/textarea';
type Product = 'remotion' | 'media-parser' | 'webcodecs';
type Usage = 'public-testset' | 'internally' | 'confidential';
+// 1GB file size limit
+const MAX_FILE_SIZE_BYTES = 1073741824;
+
type SubmitStatus =
| {
type: 'idle';
@@ -30,6 +33,7 @@ const Report: React.FC = () => {
const [product, setProduct] = useState<Product | null>(null);
const [usage, setUsage] = useState<Usage | null>(null);
const [contact, setContact] = useState('');
+ const [fileSizeError, setFileSizeError] = useState<string | null>(null);
const [submitStatus, setSubmitStatus] = useState<SubmitStatus>({
type: 'idle',
@@ -79,11 +83,22 @@ const Report: React.FC = () => {
<DropZone
onFilename={(f) => {
setFilename(f);
+ setFileSizeError(null); // Clear any previous file size errors
}}
onUrl={(u) => {
setUrl(u);
}}
+ onError={(error) => {
+ setFileSizeError(error);
+ }}
+ maxSizeBytes={MAX_FILE_SIZE_BYTES}
/>
+ {fileSizeError && (
+ <p className="text-red-500 mt-2 text-sm">{fileSizeError}</p>
+ )}
+ <p className="text-muted-foreground text-sm mt-2">
+ <strong>Note:</strong> Maximum file size is 1GB.
+ </p>
<br />
<h2 className="font-brand mt-5 font-bold">
Which product has an issue with this video?
@@ -180,17 +195,17 @@ const Report: React.FC = () => {
</div>
</RadioGroup>
<h2 className="font-brand mt-5 font-bold">
- Your email / Discord username
+ Your email / Discord username *
</h2>
<p className="text-muted-foreground text-sm">
- For any follow-up questions, or to notify you when the issue is
- fixed.
+ Required. For any follow-up questions, or to notify you when the
+ issue is fixed.
</p>
<Input
- name="description"
+ name="contact"
className="mt-3"
- placeholder="Your Email"
+ placeholder="Your Email or Discord username (required)"
value={contact}
onChange={(e) => setContact(e.target.value)}
/>
diff --git a/packages/convert/app/tailwind.css b/packages/convert/app/tailwind.css
index 9bee147582..98c57bc75b 100644
--- a/packages/convert/app/tailwind.css
+++ b/packages/convert/app/tailwind.css
@@ -5,49 +5,49 @@
@custom-variant dark (&:is(.dark *));
@theme {
- --font-*: initial;
- --font-brand: GTPlanar;
- --font-brand--font-feature-settings: 'ss03' 1;
+ --font-*: initial;
+ --font-brand: GTPlanar;
+ --font-brand--font-feature-settings: 'ss03' 1;
- --radius-lg: var(--radius);
- --radius-md: calc(var(--radius) - 2px);
- --radius-sm: calc(var(--radius) - 4px);
+ --radius-lg: var(--radius);
+ --radius-md: calc(var(--radius) - 2px);
+ --radius-sm: calc(var(--radius) - 4px);
- --color-background: hsl(var(--background));
- --color-foreground: hsl(var(--foreground));
+ --color-background: hsl(var(--background));
+ --color-foreground: hsl(var(--foreground));
- --color-card: hsl(var(--card));
- --color-card-foreground: hsl(var(--card-foreground));
+ --color-card: hsl(var(--card));
+ --color-card-foreground: hsl(var(--card-foreground));
- --color-popover: hsl(var(--popover));
- --color-popover-foreground: hsl(var(--popover-foreground));
+ --color-popover: hsl(var(--popover));
+ --color-popover-foreground: hsl(var(--popover-foreground));
- --color-primary: hsl(var(--primary));
- --color-primary-foreground: hsl(var(--primary-foreground));
+ --color-primary: hsl(var(--primary));
+ --color-primary-foreground: hsl(var(--primary-foreground));
- --color-secondary: hsl(var(--secondary));
- --color-secondary-foreground: hsl(var(--secondary-foreground));
+ --color-secondary: hsl(var(--secondary));
+ --color-secondary-foreground: hsl(var(--secondary-foreground));
- --color-muted: hsl(var(--muted));
- --color-muted-foreground: hsl(var(--muted-foreground));
+ --color-muted: hsl(var(--muted));
+ --color-muted-foreground: hsl(var(--muted-foreground));
- --color-accent: hsl(var(--accent));
- --color-accent-foreground: hsl(var(--accent-foreground));
+ --color-accent: hsl(var(--accent));
+ --color-accent-foreground: hsl(var(--accent-foreground));
- --color-destructive: hsl(var(--destructive));
- --color-destructive-foreground: hsl(var(--destructive-foreground));
+ --color-destructive: hsl(var(--destructive));
+ --color-destructive-foreground: hsl(var(--destructive-foreground));
- --color-brand: #0b84f3;
+ --color-brand: #0b84f3;
- --color-border: hsl(var(--border));
- --color-input: hsl(var(--input));
- --color-ring: hsl(var(--ring));
+ --color-border: hsl(var(--border));
+ --color-input: hsl(var(--input));
+ --color-ring: hsl(var(--ring));
- --color-chart-1: hsl(var(--chart-1));
- --color-chart-2: hsl(var(--chart-2));
- --color-chart-3: hsl(var(--chart-3));
- --color-chart-4: hsl(var(--chart-4));
- --color-chart-5: hsl(var(--chart-5));
+ --color-chart-1: hsl(var(--chart-1));
+ --color-chart-2: hsl(var(--chart-2));
+ --color-chart-3: hsl(var(--chart-3));
+ --color-chart-4: hsl(var(--chart-4));
+ --color-chart-5: hsl(var(--chart-5));
}
/*
@@ -59,19 +59,19 @@
color utility to any element that depends on these defaults.
*/
@layer base {
- *,
- ::after,
- ::before,
- ::backdrop,
- ::file-selector-button {
- border-color: var(--color-gray-200, currentcolor);
- }
+ *,
+ ::after,
+ ::before,
+ ::backdrop,
+ ::file-selector-button {
+ border-color: var(--color-gray-200, currentcolor);
+ }
}
@layer utilities {
- html {
- background-color: #f8fafc;
- }
+ html {
+ background-color: #f8fafc;
+ }
}
@layer base {
diff --git a/packages/convert/app/tests/TestComponent.tsx b/packages/convert/app/tests/TestComponent.tsx
index c149e85350..c7f429f9f0 100644
--- a/packages/convert/app/tests/TestComponent.tsx
+++ b/packages/convert/app/tests/TestComponent.tsx
@@ -3,7 +3,7 @@ import React from 'react';
import {TestStateDisplay} from '~/components/tests/TestStateDisplay';
import {Button} from '~/components/ui/button';
import type {TestStructure} from './test-structure';
-import { useTest} from './test-structure';
+import {useTest} from './test-structure';
export const TestComponent: React.FC<{
readonly test: TestStructure;