OpenReel Video - Professional browser-based video editor. Open source CapCut alternative. 100% browser-based, no installation, no cloud uploads, no watermarks.
TypeScript
fix: improve device detection and add time estimates to export dropdown
Augustus Otu79b86812048e
diff --git a/apps/web/src/components/editor/ExportDialog.tsx b/apps/web/src/components/editor/ExportDialog.tsxindex 637cf8a0..7c106fb1 100644--- a/apps/web/src/components/editor/ExportDialog.tsx+++ b/apps/web/src/components/editor/ExportDialog.tsx@@ -760,23 +760,22 @@ export const ExportDialog: React.FC<ExportDialogProps> = ({</div>{showDeviceInfo && (- <div className="mt-3 pt-3 border-t border-border/50 grid grid-cols-4 gap-4 text-[10px]">+ <div className="mt-3 pt-3 border-t border-border/50 grid grid-cols-3 gap-4 text-[10px]"><div><span className="text-text-muted">CPU</span><p className="text-text-primary font-medium">- {deviceProfile.cpu.cores} cores ({deviceProfile.cpu.tier})- </p>- </div>- <div>- <span className="text-text-muted">Memory</span>- <p className="text-text-primary font-medium">- {deviceProfile.memory.gb}GB ({deviceProfile.memory.tier})+ {deviceProfile.cpu.cores} cores</p></div><div><span className="text-text-muted">GPU</span><p className="text-text-primary font-medium truncate" title={deviceProfile.gpu.renderer}>- {deviceProfile.gpu.hasHardwareEncoding ? "HW Encode ✓" : "Software only"}+ {deviceProfile.gpu.renderer !== "Unknown"+ ? deviceProfile.gpu.renderer.replace(/ANGLE \(|, .*\)/g, "").replace(/Direct3D11.*$/g, "").trim()+ : "Unknown"}+ </p>+ <p className="text-[9px] text-text-muted">+ {deviceProfile.gpu.hasHardwareEncoding ? "HW Encode" : "Software only"}</p></div><div>diff --git a/apps/web/src/components/editor/Toolbar.tsx b/apps/web/src/components/editor/Toolbar.tsxindex a65765f9..8d73c752 100644--- a/apps/web/src/components/editor/Toolbar.tsx+++ b/apps/web/src/components/editor/Toolbar.tsx@@ -24,9 +24,13 @@ import { useThemeStore } from "../../stores/theme-store";import {getExportEngine,downloadBlob,+ getDeviceProfile,+ estimateExportTime,type VideoExportSettings,type AudioExportSettings,type ExportResult,+ type DeviceProfile,+ type TimeEstimate,} from "@openreel/core";import { ExportDialog } from "./ExportDialog";import { ScreenRecorder } from "./ScreenRecorder";@@ -79,6 +83,8 @@ export const Toolbar: React.FC = () => {error: null,complete: false,});+ const [deviceProfile, setDeviceProfile] = useState<DeviceProfile | null>(null);+ const [exportEstimates, setExportEstimates] = useState<Map<string, TimeEstimate>>(new Map());useEffect(() => {setGlobalExportState({@@ -87,6 +93,45 @@ export const Toolbar: React.FC = () => {phase: exportState.phase,});}, [exportState.isExporting, exportState.progress, exportState.phase, setGlobalExportState]);++ useEffect(() => {+ if (isExportOpen && !deviceProfile) {+ getDeviceProfile().then(setDeviceProfile);+ }+ }, [isExportOpen, deviceProfile]);++ useEffect(() => {+ if (!deviceProfile || !project.timeline?.duration) {+ return;+ }++ const duration = project.timeline.duration;+ const estimates = new Map<string, TimeEstimate>();++ const configs: Array<{ key: string; width: number; height: number; frameRate: number; codec: "h264" | "h265" | "vp9" | "av1" }> = [+ { key: "mp4", width: project.settings.width, height: project.settings.height, frameRate: 30, codec: "h264" },+ { key: "4k", width: 3840, height: 2160, frameRate: 30, codec: "h264" },+ { key: "4k-60-master", width: 3840, height: 2160, frameRate: 60, codec: "h264" },+ { key: "4k-master", width: 3840, height: 2160, frameRate: 30, codec: "h264" },+ { key: "1080p-high", width: 1920, height: 1080, frameRate: 30, codec: "h264" },+ { key: "1080p-60", width: 1920, height: 1080, frameRate: 60, codec: "h264" },+ { key: "prores", width: project.settings.width, height: project.settings.height, frameRate: 30, codec: "h264" },+ ];++ for (const config of configs) {+ const estimate = estimateExportTime(deviceProfile, {+ width: config.width,+ height: config.height,+ frameRate: config.frameRate,+ duration,+ codec: config.codec,+ });+ estimates.set(config.key, estimate);+ }++ setExportEstimates(estimates);+ }, [deviceProfile, project.timeline?.duration, project.settings.width, project.settings.height]);+const exportMenuRef = useRef<HTMLDivElement>(null);const handleSearch = useCallback(() => {@@ -939,6 +984,11 @@ export const Toolbar: React.FC = () => {<div className="text-xs text-text-muted mt-0.5">{option.desc}</div>+ {exportEstimates.get(option.type) && (+ <div className="text-[10px] text-text-secondary mt-1">+ Est. {exportEstimates.get(option.type)?.formatted}+ </div>+ )}</div></button>),diff --git a/packages/core/src/device/device-capabilities.test.ts b/packages/core/src/device/device-capabilities.test.tsindex a7b03560..7c059cfe 100644--- a/packages/core/src/device/device-capabilities.test.ts+++ b/packages/core/src/device/device-capabilities.test.ts@@ -193,12 +193,11 @@ describe("DeviceCapabilities", () => {});describe("formatDeviceSummary", () => {- it("should format device summary with GPU, cores, and RAM", () => {+ it("should format device summary with GPU and cores", () => {const profile = createMockProfile();const summary = formatDeviceSummary(profile);expect(summary).toContain("8 cores");- expect(summary).toContain("16GB RAM");});it("should include GPU name when available", () => {diff --git a/packages/core/src/device/device-capabilities.ts b/packages/core/src/device/device-capabilities.tsindex 5fd1fba7..2337405c 100644--- a/packages/core/src/device/device-capabilities.ts+++ b/packages/core/src/device/device-capabilities.ts@@ -242,8 +242,7 @@ function calculateOverallTier(export async function detectDeviceCapabilities(): Promise<DeviceProfile> {const cores = navigator.hardwareConcurrency || 4;- const memory = (navigator as unknown as { deviceMemory?: number })- .deviceMemory || 4;+ const memory = (navigator as unknown as { deviceMemory?: number }).deviceMemory || 4;const cpu: CpuInfo = { cores, tier: getCpuTier(cores) };const memoryInfo: MemoryInfo = { gb: memory, tier: getMemoryTier(memory) };@@ -440,7 +439,6 @@ export function formatDeviceSummary(profile: DeviceProfile): string {}parts.push(`${profile.cpu.cores} cores`);- parts.push(`${profile.memory.gb}GB RAM`);return parts.join(" · ");}