Create polished demo videos without editing skills. Mac/Windows/Linux
Merge branch 'main' into feature/ui-improvements
Gurpreet Kait697de069d1d5
diff --cc electron/electron-env.d.tsindex cfeef004,2929d39b..07dc0cf8--- a/electron/electron-env.d.ts+++ b/electron/electron-env.d.ts@@@ -1,228 -1,235 +1,236 @@@-/// <reference types="vite-plugin-electron/electron-env" />--declare namespace NodeJS {- interface ProcessEnv {- /**- * The built directory structure- *- * ```tree- * ├─┬─┬ dist- * │ │ └── index.html- * │ │- * │ ├─┬ dist-electron- * │ │ ├── main.js- * │ │ └── preload.js- * │- * ```- */- APP_ROOT: string;- /** /dist/ or /public/ */- VITE_PUBLIC: string;- }-}--// Used in Renderer process, expose in `preload.ts`-interface Window {- electronAPI: {- getSources: (opts: Electron.SourcesOptions) => Promise<ProcessedDesktopSource[]>;- switchToEditor: () => Promise<void>;- openSourceSelector: () => Promise<void>;- selectSource: (source: any) => Promise<any>;- getSelectedSource: () => Promise<any>;- startNativeScreenRecording: (- source: any,- options?: {- capturesSystemAudio?: boolean;- capturesMicrophone?: boolean;- microphoneDeviceId?: string;- microphoneLabel?: string;- },- ) => Promise<{ success: boolean; path?: string; message?: string; error?: string }>;- stopNativeScreenRecording: () => Promise<{- success: boolean;- path?: string;- message?: string;- error?: string;- }>;- startFfmpegRecording: (- source: any,- ) => Promise<{ success: boolean; path?: string; message?: string; error?: string }>;- stopFfmpegRecording: () => Promise<{- success: boolean;- path?: string;- message?: string;- error?: string;- }>;- storeRecordedVideo: (- videoData: ArrayBuffer,- fileName: string,- ) => Promise<{ success: boolean; path?: string; message?: string }>;- getRecordedVideoPath: () => Promise<{ success: boolean; path?: string; message?: string }>;- readLocalFile: (- filePath: string,- ) => Promise<{ success: boolean; data?: Uint8Array; error?: string }>;- setRecordingState: (recording: boolean) => Promise<void>;- getCursorTelemetry: (videoPath?: string) => Promise<{- success: boolean;- samples: CursorTelemetryPoint[];- message?: string;- error?: string;- }>;- getSystemCursorAssets: () => Promise<{- success: boolean;- cursors: Record<string, SystemCursorAsset>;- error?: string;- }>;- onStopRecordingFromTray: (callback: () => void) => () => void;- onRecordingStateChanged: (- callback: (state: { recording: boolean; sourceName: string }) => void,- ) => () => void;- onRecordingInterrupted: (- callback: (state: { reason: string; message: string }) => void,- ) => () => void;- onCursorStateChanged: (- callback: (state: { cursorType: CursorTelemetryPoint["cursorType"] }) => void,- ) => () => void;- openExternalUrl: (url: string) => Promise<{ success: boolean; error?: string }>;- getAccessibilityPermissionStatus: () => Promise<{- success: boolean;- trusted: boolean;- prompted: boolean;- error?: string;- }>;- requestAccessibilityPermission: () => Promise<{- success: boolean;- trusted: boolean;- prompted: boolean;- error?: string;- }>;- getScreenRecordingPermissionStatus: () => Promise<{- success: boolean;- status: string;- error?: string;- }>;- openScreenRecordingPreferences: () => Promise<{ success: boolean; error?: string }>;- openAccessibilityPreferences: () => Promise<{ success: boolean; error?: string }>;- saveExportedVideo: (- videoData: ArrayBuffer,- fileName: string,- ) => Promise<{ success: boolean; path?: string; message?: string; canceled?: boolean }>;- openVideoFilePicker: () => Promise<{ success: boolean; path?: string; canceled?: boolean }>;- openAudioFilePicker: () => Promise<{ success: boolean; path?: string; canceled?: boolean }>;- setCurrentVideoPath: (path: string) => Promise<{ success: boolean }>;- setCurrentRecordingSession: (session: {- videoPath: string;- webcamPath?: string | null;- }) => Promise<{ success: boolean }>;- getCurrentRecordingSession: () => Promise<{- success: boolean;- session?: { videoPath: string; webcamPath?: string | null };- }>;- getCurrentVideoPath: () => Promise<{ success: boolean; path?: string }>;- clearCurrentVideoPath: () => Promise<{ success: boolean }>;- saveProjectFile: (- projectData: unknown,- suggestedName?: string,- existingProjectPath?: string,- ) => Promise<{- success: boolean;- path?: string;- message?: string;- canceled?: boolean;- error?: string;- }>;- loadProjectFile: () => Promise<{- success: boolean;- path?: string;- project?: unknown;- message?: string;- canceled?: boolean;- error?: string;- }>;- loadCurrentProjectFile: () => Promise<{- success: boolean;- path?: string;- project?: unknown;- message?: string;- canceled?: boolean;- error?: string;- }>;- onMenuLoadProject: (callback: () => void) => () => void;- onMenuSaveProject: (callback: () => void) => () => void;- onMenuSaveProjectAs: (callback: () => void) => () => void;- getPlatform: () => Promise<string>;- revealInFolder: (- filePath: string,- ) => Promise<{ success: boolean; error?: string; message?: string }>;- openRecordingsFolder: () => Promise<{ success: boolean; error?: string; message?: string }>;- getRecordingsDirectory: () => Promise<{- success: boolean;- path: string;- isDefault: boolean;- error?: string;- }>;- chooseRecordingsDirectory: () => Promise<{- success: boolean;- canceled?: boolean;- path?: string;- isDefault?: boolean;- message?: string;- error?: string;- }>;- getShortcuts: () => Promise<Record<string, unknown> | null>;- saveShortcuts: (shortcuts: unknown) => Promise<{ success: boolean; error?: string }>;- hudOverlayHide: () => void;- hudOverlayClose: () => void;- getHudOverlayCaptureProtection: () => Promise<{ success: boolean; enabled: boolean }>;- setHudOverlayCaptureProtection: (- enabled: boolean,- ) => Promise<{ success: boolean; enabled: boolean }>;- setHasUnsavedChanges: (hasChanges: boolean) => void;- onRequestSaveBeforeClose: (callback: () => Promise<void>) => () => void;- isWgcAvailable: () => Promise<{ available: boolean }>;- muxWgcRecording: () => Promise<{- success: boolean;- path?: string;- message?: string;- error?: string;- }>;- /** Hide the OS cursor before browser capture starts. */- hideOsCursor: () => Promise<{ success: boolean }>;- /** Countdown timer before recording */- getCountdownDelay: () => Promise<{ success: boolean; delay: number }>;- setCountdownDelay: (delay: number) => Promise<{ success: boolean; error?: string }>;- startCountdown: (seconds: number) => Promise<{ success: boolean; cancelled?: boolean }>;- cancelCountdown: () => Promise<{ success: boolean }>;- onCountdownTick: (callback: (seconds: number) => void) => () => void;- };-}--interface ProcessedDesktopSource {- id: string;- name: string;- display_id: string;- thumbnail: string | null;- appIcon: string | null;- originalName?: string;- sourceType?: "screen" | "window";- appName?: string;- windowTitle?: string;-}--interface CursorTelemetryPoint {- timeMs: number;- cx: number;- cy: number;- interactionType?: "move" | "click" | "double-click" | "right-click" | "middle-click" | "mouseup";- cursorType?:- | "arrow"- | "text"- | "pointer"- | "crosshair"- | "open-hand"- | "closed-hand"- | "resize-ew"- | "resize-ns"- | "not-allowed";-}--interface SystemCursorAsset {- dataUrl: string;- hotspotX: number;- hotspotY: number;- width: number;- height: number;-}+/// <reference types="vite-plugin-electron/electron-env" />++declare namespace NodeJS {+ interface ProcessEnv {+ /**+ * The built directory structure+ *+ * ```tree+ * ├─┬─┬ dist+ * │ │ └── index.html+ * │ │+ * │ ├─┬ dist-electron+ * │ │ ├── main.js+ * │ │ └── preload.js+ * │+ * ```+ */+ APP_ROOT: string;+ /** /dist/ or /public/ */+ VITE_PUBLIC: string;+ }+}++// Used in Renderer process, expose in `preload.ts`+interface Window {+ electronAPI: {+ getSources: (opts: Electron.SourcesOptions) => Promise<ProcessedDesktopSource[]>;+ switchToEditor: () => Promise<void>;+ openSourceSelector: () => Promise<void>;+ selectSource: (source: any) => Promise<any>;+ showSourceHighlight: (source: any) => Promise<{ success: boolean }>;+ getSelectedSource: () => Promise<any>;+ startNativeScreenRecording: (+ source: any,+ options?: {+ capturesSystemAudio?: boolean;+ capturesMicrophone?: boolean;+ microphoneDeviceId?: string;+ microphoneLabel?: string;+ },+ ) => Promise<{ success: boolean; path?: string; message?: string; error?: string }>;+ stopNativeScreenRecording: () => Promise<{+ success: boolean;+ path?: string;+ message?: string;+ error?: string;+ }>;+ startFfmpegRecording: (+ source: any,+ ) => Promise<{ success: boolean; path?: string; message?: string; error?: string }>;+ stopFfmpegRecording: () => Promise<{+ success: boolean;+ path?: string;+ message?: string;+ error?: string;+ }>;+ storeRecordedVideo: (+ videoData: ArrayBuffer,+ fileName: string,+ ) => Promise<{ success: boolean; path?: string; message?: string }>;+ getRecordedVideoPath: () => Promise<{ success: boolean; path?: string; message?: string }>;+ readLocalFile: (+ filePath: string,+ ) => Promise<{ success: boolean; data?: Uint8Array; error?: string }>;+ setRecordingState: (recording: boolean) => Promise<void>;+ getCursorTelemetry: (videoPath?: string) => Promise<{+ success: boolean;+ samples: CursorTelemetryPoint[];+ message?: string;+ error?: string;+ }>;+ getSystemCursorAssets: () => Promise<{+ success: boolean;+ cursors: Record<string, SystemCursorAsset>;+ error?: string;+ }>;+ onStopRecordingFromTray: (callback: () => void) => () => void;+ onRecordingStateChanged: (+ callback: (state: { recording: boolean; sourceName: string }) => void,+ ) => () => void;+ onRecordingInterrupted: (+ callback: (state: { reason: string; message: string }) => void,+ ) => () => void;+ onCursorStateChanged: (+ callback: (state: { cursorType: CursorTelemetryPoint["cursorType"] }) => void,+ ) => () => void;+ openExternalUrl: (url: string) => Promise<{ success: boolean; error?: string }>;+ getAccessibilityPermissionStatus: () => Promise<{+ success: boolean;+ trusted: boolean;+ prompted: boolean;+ error?: string;+ }>;+ requestAccessibilityPermission: () => Promise<{+ success: boolean;+ trusted: boolean;+ prompted: boolean;+ error?: string;+ }>;+ getScreenRecordingPermissionStatus: () => Promise<{+ success: boolean;+ status: string;+ error?: string;+ }>;+ openScreenRecordingPreferences: () => Promise<{ success: boolean; error?: string }>;+ openAccessibilityPreferences: () => Promise<{ success: boolean; error?: string }>;+ saveExportedVideo: (+ videoData: ArrayBuffer,+ fileName: string,+ ) => Promise<{ success: boolean; path?: string; message?: string; canceled?: boolean }>;+ openVideoFilePicker: () => Promise<{ success: boolean; path?: string; canceled?: boolean }>;+ openAudioFilePicker: () => Promise<{ success: boolean; path?: string; canceled?: boolean }>;+ setCurrentVideoPath: (path: string) => Promise<{ success: boolean }>;++ setCurrentRecordingSession: (session: {++ videoPath: string;++ webcamPath?: string | null;++ }) => Promise<{ success: boolean }>;++ getCurrentRecordingSession: () => Promise<{++ success: boolean;++ session?: { videoPath: string; webcamPath?: string | null };++ }>;+ getCurrentVideoPath: () => Promise<{ success: boolean; path?: string }>;+ clearCurrentVideoPath: () => Promise<{ success: boolean }>;+ saveProjectFile: (+ projectData: unknown,+ suggestedName?: string,+ existingProjectPath?: string,+ ) => Promise<{+ success: boolean;+ path?: string;+ message?: string;+ canceled?: boolean;+ error?: string;+ }>;+ loadProjectFile: () => Promise<{+ success: boolean;+ path?: string;+ project?: unknown;+ message?: string;+ canceled?: boolean;+ error?: string;+ }>;+ loadCurrentProjectFile: () => Promise<{+ success: boolean;+ path?: string;+ project?: unknown;+ message?: string;+ canceled?: boolean;+ error?: string;+ }>;+ onMenuLoadProject: (callback: () => void) => () => void;+ onMenuSaveProject: (callback: () => void) => () => void;+ onMenuSaveProjectAs: (callback: () => void) => () => void;+ getPlatform: () => Promise<string>;+ revealInFolder: (+ filePath: string,+ ) => Promise<{ success: boolean; error?: string; message?: string }>;+ openRecordingsFolder: () => Promise<{ success: boolean; error?: string; message?: string }>;+ getRecordingsDirectory: () => Promise<{+ success: boolean;+ path: string;+ isDefault: boolean;+ error?: string;+ }>;+ chooseRecordingsDirectory: () => Promise<{+ success: boolean;+ canceled?: boolean;+ path?: string;+ isDefault?: boolean;+ message?: string;+ error?: string;+ }>;+ getShortcuts: () => Promise<Record<string, unknown> | null>;+ saveShortcuts: (shortcuts: unknown) => Promise<{ success: boolean; error?: string }>;+ hudOverlayHide: () => void;+ hudOverlayClose: () => void;+ getHudOverlayCaptureProtection: () => Promise<{ success: boolean; enabled: boolean }>;+ setHudOverlayCaptureProtection: (+ enabled: boolean,+ ) => Promise<{ success: boolean; enabled: boolean }>;+ setHasUnsavedChanges: (hasChanges: boolean) => void;+ onRequestSaveBeforeClose: (callback: () => Promise<void>) => () => void;+ isWgcAvailable: () => Promise<{ available: boolean }>;+ muxWgcRecording: () => Promise<{+ success: boolean;+ path?: string;+ message?: string;+ error?: string;+ }>;+ /** Hide the OS cursor before browser capture starts. */+ hideOsCursor: () => Promise<{ success: boolean }>;+ /** Countdown timer before recording */+ getCountdownDelay: () => Promise<{ success: boolean; delay: number }>;+ setCountdownDelay: (delay: number) => Promise<{ success: boolean; error?: string }>;+ startCountdown: (seconds: number) => Promise<{ success: boolean; cancelled?: boolean }>;+ cancelCountdown: () => Promise<{ success: boolean }>;+ onCountdownTick: (callback: (seconds: number) => void) => () => void;+ };+}++interface ProcessedDesktopSource {+ id: string;+ name: string;+ display_id: string;+ thumbnail: string | null;+ appIcon: string | null;+ originalName?: string;+ sourceType?: "screen" | "window";+ appName?: string;+ windowTitle?: string;+}++interface CursorTelemetryPoint {+ timeMs: number;+ cx: number;+ cy: number;+ interactionType?: "move" | "click" | "double-click" | "right-click" | "middle-click" | "mouseup";+ cursorType?:+ | "arrow"+ | "text"+ | "pointer"+ | "crosshair"+ | "open-hand"+ | "closed-hand"+ | "resize-ew"+ | "resize-ns"+ | "not-allowed";+}++interface SystemCursorAsset {+ dataUrl: string;+ hotspotX: number;+ hotspotY: number;+ width: number;+ height: number;+}diff --cc electron/windows.tsindex 19f101d4,762f0ae0..81a3d260--- a/electron/windows.ts+++ b/electron/windows.ts@@@ -107,8 -107,8 +107,8 @@@ export function createHudOverlayWindow(const primaryDisplay = getScreen().getPrimaryDisplay();const { workArea } = primaryDisplay;- const windowWidth = 620;- const windowWidth = 660;- const windowHeight = 170;++ const windowWidth = 720;+ const windowHeight = 520;const x = Math.floor(workArea.x + (workArea.width - windowWidth) / 2);const y = Math.floor(workArea.y + workArea.height - windowHeight - 5);@@@ -116,10 -116,10 +116,10 @@@const win = new BrowserWindow({width: windowWidth,height: windowHeight,- minWidth: 620,- maxWidth: 620,- minWidth: windowWidth,- maxWidth: windowWidth,- minHeight: windowHeight,- maxHeight: windowHeight,++ minWidth: 720,++ maxWidth: 720,+ minHeight: 520,+ maxHeight: 520,x: x,y: y,frame: false,diff --cc src/components/launch/LaunchWindow.tsxindex c2d2a30a,d178b4dc..93e77257--- a/src/components/launch/LaunchWindow.tsx+++ b/src/components/launch/LaunchWindow.tsx@@@ -1,137 -1,39 +1,140 @@@-import { Eye, EyeOff, Languages, Timer } from "lucide-react";-import { useEffect, useRef, useState } from "react";-import { BsRecordCircle } from "react-icons/bs";-import { FaRegStopCircle } from "react-icons/fa";-import { FaFolderOpen } from "react-icons/fa6";-import { FiMinus, FiX } from "react-icons/fi";+import type { ReactNode } from "react";+import { useCallback, useEffect, useRef, useState } from "react";import {- MdMic,- MdMicOff,- MdMonitor,- MdOutlineVideocam,- MdOutlineVideocamOff,- MdVideoFile,- MdVolumeOff,- MdVolumeUp,-} from "react-icons/md";+ Monitor,+ Mic,+ MicOff,+ ChevronUp,+ Pause,+ Square,+ X,+ Play,+ Minus,+ MoreVertical,+ FolderOpen,+ VideoIcon,+ Languages,+ Volume2,+ VolumeX,+ AppWindow,+ Eye,+ EyeOff,+ Timer,++ Video,++ VideoOff,+} from "lucide-react";import { RxDragHandleDots2 } from "react-icons/rx";-import { useI18n } from "@/contexts/I18nContext";-import type { AppLocale } from "@/i18n/config";-import { SUPPORTED_LOCALES } from "@/i18n/config";-import { useScopedT } from "../../contexts/I18nContext";import { useAudioLevelMeter } from "../../hooks/useAudioLevelMeter";import { useMicrophoneDevices } from "../../hooks/useMicrophoneDevices";import { useScreenRecorder } from "../../hooks/useScreenRecorder";+import { useScopedT } from "../../contexts/I18nContext";+ import { useVideoDevices } from "../../hooks/useVideoDevices";import { AudioLevelMeter } from "../ui/audio-level-meter";-import { Button } from "../ui/button";import { ContentClamp } from "../ui/content-clamp";-import {- DropdownMenu,- DropdownMenuContent,- DropdownMenuItem,- DropdownMenuTrigger,-} from "../ui/dropdown-menu";+import { useI18n } from "@/contexts/I18nContext";+import { SUPPORTED_LOCALES } from "@/i18n/config";+import type { AppLocale } from "@/i18n/config";import styles from "./LaunchWindow.module.css";+interface DesktopSource {+ id: string;+ name: string;+ thumbnail: string | null;+ display_id: string;+ appIcon: string | null;+ sourceType?: "screen" | "window";+ appName?: string;+ windowTitle?: string;+}++const LOCALE_LABELS: Record<string, string> = {+ en: "EN",+ es: "ES",+ "zh-CN": "中文",+};++const COUNTDOWN_OPTIONS = [0, 3, 5, 10];++function IconButton({+ onClick,+ title,+ className = "",+ children,+}: {+ onClick?: () => void;+ title?: string;+ className?: string;+ children: ReactNode;+}) {+ return (+ <button+ type="button"+ className={`${styles.ib} ${styles.electronNoDrag} ${className}`}+ onClick={onClick}+ title={title}+ >+ {children}+ </button>+ );+}++function DropdownItem({+ onClick,+ selected,+ icon,+ children,+ trailing,+}: {+ onClick: () => void;+ selected?: boolean;+ icon: ReactNode;+ children: ReactNode;+ trailing?: ReactNode;+}) {+ return (+ <button+ type="button"+ className={`${styles.ddItem} ${selected ? styles.ddItemSelected : ""}`}+ onClick={onClick}+ >+ <span className="shrink-0">{icon}</span>+ <span className="truncate">{children}</span>+ {trailing}+ </button>+ );+}++function Separator() {+ return <div className={styles.sep} />;+}++function MicDeviceRow({+ device,+ selected,+ onSelect,+}: {+ device: { deviceId: string; label: string };+ selected: boolean;+ onSelect: () => void;+}) {+ const { level } = useAudioLevelMeter({+ enabled: true,+ deviceId: device.deviceId,+ });++ return (+ <button+ type="button"+ className={`${styles.ddItem} ${selected ? styles.ddItemSelected : ""}`}+ onClick={onSelect}+ >+ <span className="shrink-0">{selected ? <Mic size={16} /> : <MicOff size={16} />}</span>+ <span className="truncate flex-1">{device.label}</span>+ <AudioLevelMeter level={level} className="w-16 shrink-0" />+ </button>+ );+}+export function LaunchWindow() {const { locale, setLocale } = useI18n();const t = useScopedT("launch");@@@ -153,26 -56,22 +160,34 @@@countdownDelay,setCountdownDelay,} = useScreenRecorder();+const [recordingStart, setRecordingStart] = useState<number | null>(null);const [elapsed, setElapsed] = useState(0);+ const [pausedAt, setPausedAt] = useState<number | null>(null);+ const [pausedTotal, setPausedTotal] = useState(0);+ const [selectedSource, setSelectedSource] = useState("Screen");+ const [hasSelectedSource, setHasSelectedSource] = useState(false);+ const [recordingsDirectory, setRecordingsDirectory] = useState<string | null>(null);- const [activeDropdown, setActiveDropdown] = useState<"none" | "sources" | "more" | "mic" | "countdown">("none");++ const [activeDropdown, setActiveDropdown] = useState<"none" | "sources" | "more" | "mic" | "countdown" | "webcam">("none");+ const [sources, setSources] = useState<DesktopSource[]>([]);+ const [sourcesLoading, setSourcesLoading] = useState(false);+ const [hideHudFromCapture, setHideHudFromCapture] = useState(true);+ const [platform, setPlatform] = useState<string | null>(null);+ const dropdownRef = useRef<HTMLDivElement>(null);+ const webcamPreviewRef = useRef<HTMLVideoElement | null>(null);- const showMicControls = microphoneEnabled && !recording;++ const micDropdownOpen = activeDropdown === "mic";++ const webcamDropdownOpen = activeDropdown === "webcam";+ const showWebcamControls = webcamEnabled && !recording;const { devices, selectedDeviceId, setSelectedDeviceId } =- useMicrophoneDevices(microphoneEnabled);+ useMicrophoneDevices(microphoneEnabled || micDropdownOpen);+ const {+ devices: videoDevices,+ selectedDeviceId: selectedVideoDeviceId,+ setSelectedDeviceId: setSelectedVideoDeviceId,- } = useVideoDevices(webcamEnabled);- const { level } = useAudioLevelMeter({- enabled: showMicControls,- deviceId: microphoneDeviceId,- });++ } = useVideoDevices(webcamEnabled || webcamDropdownOpen);++ const supportsHudCaptureProtection = platform !== "linux";useEffect(() => {if (selectedDeviceId && selectedDeviceId !== "default") {@@@ -270,76 -224,16 +344,76 @@@console.error("Failed to load HUD capture protection state:", error);}};-void loadHudCaptureProtection();+ return () => { cancelled = true; };+ }, []);- return () => {- cancelled = true;+ useEffect(() => {+ const handleClick = (e: MouseEvent) => {+ if (dropdownRef.current && !dropdownRef.current.contains(e.target as Node)) {+ setActiveDropdown("none");+ }};+ document.addEventListener("mousedown", handleClick);+ return () => document.removeEventListener("mousedown", handleClick);+ }, []);++ const fetchSources = useCallback(async () => {+ if (!window.electronAPI) return;+ setSourcesLoading(true);+ try {+ const rawSources = await window.electronAPI.getSources({+ types: ["screen", "window"],+ thumbnailSize: { width: 160, height: 90 },+ fetchWindowIcons: true,+ });+ setSources(+ rawSources.map((s) => {+ const isWindow = s.id.startsWith("window:");+ const type = s.sourceType ?? (isWindow ? "window" : "screen");+ let displayName = s.name;+ let appName = s.appName;+ if (isWindow && !appName && s.name.includes(" — ")) {+ const parts = s.name.split(" — ");+ appName = parts[0]?.trim();+ displayName = parts.slice(1).join(" — ").trim() || s.name;+ } else if (isWindow && s.windowTitle) {+ displayName = s.windowTitle;+ }+ return {+ id: s.id,+ name: displayName,+ thumbnail: s.thumbnail,+ display_id: s.display_id,+ appIcon: s.appIcon,+ sourceType: type,+ appName,+ windowTitle: s.windowTitle ?? displayName,+ };+ }),+ );+ } catch (error) {+ console.error("Failed to fetch sources:", error);+ } finally {+ setSourcesLoading(false);+ }}, []);- const toggleDropdown = (which: "sources" | "more" | "mic" | "countdown") => {- const openSourceSelector = () => {- window.electronAPI?.openSourceSelector();++ const toggleDropdown = (which: "sources" | "more" | "mic" | "countdown" | "webcam") => {+ setActiveDropdown(activeDropdown === which ? "none" : which);+ if (activeDropdown !== which && which === "sources") fetchSources();+ };++ const handleSourceSelect = async (source: DesktopSource) => {+ await window.electronAPI.selectSource(source);+ setSelectedSource(source.name);+ setHasSelectedSource(true);+ setActiveDropdown("none");+ window.electronAPI.showSourceHighlight?.({+ ...source,+ name: source.appName ? `${source.appName} — ${source.name}` : source.name,+ appName: source.appName,+ });};const openVideoFile = async () => {@@@ -387,266 -284,346 +461,330 @@@}};- const chooseRecordingsDirectory = async () => {- const result = await window.electronAPI.chooseRecordingsDirectory();- if (result.canceled) {- return;- }- if (result.success && result.path) {- setRecordingsDirectory(result.path);- }- };+ const screenSources = sources.filter((s) => s.sourceType === "screen");+ const windowSources = sources.filter((s) => s.sourceType === "window");- useEffect(() => {- const loadRecordingsDirectory = async () => {- const result = await window.electronAPI.getRecordingsDirectory();- if (result.success) {- setRecordingsDirectory(result.path);- }- };-- void loadRecordingsDirectory();- }, []);-- const recordingsDirectoryName = recordingsDirectory- ? recordingsDirectory.split(/[\\/]/).filter(Boolean).pop() || recordingsDirectory- : "recordings";- const dividerClass = "mx-1 h-5 w-px shrink-0 bg-white/35";- const supportsHudCaptureProtection = platform !== "linux";-- const toggleMicrophone = () => {- if (!recording) {- setMicrophoneEnabled(!microphoneEnabled);- }++ const toggleWebcam = () => {++ if (recording) return;++ toggleDropdown("webcam");+ };+return (- <div className="flex h-full w-full items-end justify-center overflow-hidden bg-transparent px-3 pb-3 pt-2">- <div className={`flex flex-col items-center gap-2 mx-auto ${styles.electronDrag}`}>- {showMicControls && (- <div- className={`flex items-center gap-2 rounded-full border border-white/15 bg-[rgba(18,18,26,0.92)] px-3 py-2 shadow-xl backdrop-blur-xl ${styles.electronNoDrag}`}- >- <select- value={microphoneDeviceId || selectedDeviceId}- onChange={(event) => {- setSelectedDeviceId(event.target.value);- setMicrophoneDeviceId(event.target.value);- }}- className={`max-w-[230px] rounded-full border border-white/15 bg-[#131722] px-3 py-1 text-xs text-slate-100 outline-none ${styles.micSelect}`}- >- {devices.map((device) => (- <option key={device.deviceId} value={device.deviceId}>- {device.label}- </option>- ))}- </select>- <AudioLevelMeter level={level} className="w-24" />- </div>- )}-- {showWebcamControls && (- <div- className={`flex items-center gap-2 rounded-full border border-white/15 bg-[rgba(18,18,26,0.92)] px-3 py-2 shadow-xl backdrop-blur-xl ${styles.electronNoDrag}`}- >- <div className="h-9 w-9 overflow-hidden rounded-2xl bg-white/5 ring-1 ring-white/10">- <video- ref={webcamPreviewRef}- className="h-full w-full object-cover"- muted- playsInline- style={{ transform: "scaleX(-1)" }}- />- </div>- <select- value={webcamDeviceId || selectedVideoDeviceId}- onChange={(event) => {- setSelectedVideoDeviceId(event.target.value);- setWebcamDeviceId(event.target.value);- }}- className="max-w-[230px] rounded-full border border-white/15 bg-white/10 px-3 py-1 text-xs text-white outline-none"- >- {videoDevices.map((device) => (- <option key={device.deviceId} value={device.deviceId}>- {device.label}- </option>- ))}- </select>- </div>- )}-- <div- className={`mx-auto inline-flex max-w-full items-center gap-1.5 px-3 py-2 ${styles.electronDrag} ${styles.hudBar}`}- style={{- borderRadius: 9999,- background: "linear-gradient(135deg, rgba(28,28,36,0.97) 0%, rgba(18,18,26,0.96) 100%)",- backdropFilter: "blur(16px) saturate(140%)",- WebkitBackdropFilter: "blur(16px) saturate(140%)",- border: "1px solid rgba(80,80,120,0.25)",- minHeight: 48,- }}- >- <div className={`flex items-center px-1 ${styles.electronDrag}`}>- <RxDragHandleDots2 size={16} className="text-white/35" />- </div>-- <Button- variant="link"- size="sm"- className={`gap-1 text-white/80 bg-transparent hover:bg-transparent px-0 text-xs ${styles.electronNoDrag}`}- onClick={openSourceSelector}- disabled={recording}- title={selectedSource}- >- <MdMonitor size={14} className="text-white/80" />- <ContentClamp truncateLength={6}>{selectedSource}</ContentClamp>- </Button>-- <div className={dividerClass} />-- <div className={`flex items-center gap-1 ${styles.electronNoDrag}`}>- {supportsHudCaptureProtection && (- <Button- variant="link"- size="icon"- onClick={() => void toggleHudCaptureProtection()}- title={- hideHudFromCapture- ? t("recording.showHudInVideo")- : t("recording.hideHudFromVideo")- }- className="text-white/80 hover:bg-transparent"- >- {hideHudFromCapture ? (- <EyeOff size={16} className="text-white/35" />+ <div- className="w-full flex flex-col bg-transparent"++ className="w-full flex flex-col bg-transparent overflow-hidden"+ style={{ height: "100vh" }}+ ref={dropdownRef}+ >+ {/* Top area — flex:1 reserves space, menu card sits at bottom of this area */}+ <div className={styles.menuArea}>+ {activeDropdown !== "none" && (+ <div className={`${styles.menuCard} ${styles.electronNoDrag}`}>+ {activeDropdown === "sources" && (+ <>+ {sourcesLoading ? (+ <div className="flex items-center justify-center py-6">+ <div className="animate-spin rounded-full h-4 w-4 border-b-2 border-[#6b6b78]" />+ </div>) : (- <Eye size={16} className="text-[#2563EB]" />+ <>+ {screenSources.length > 0 && (+ <>+ <div className={styles.ddLabel}>Screens</div>+ {screenSources.map((source) => (+ <DropdownItem+ key={source.id}+ icon={<Monitor size={16} />}+ selected={selectedSource === source.name}+ onClick={() => handleSourceSelect(source)}+ >+ {source.name}+ </DropdownItem>+ ))}+ </>+ )}+ {windowSources.length > 0 && (+ <>+ <div className={styles.ddLabel} style={screenSources.length > 0 ? { marginTop: 4 } : undefined}>+ Windows+ </div>+ {windowSources.map((source) => (+ <DropdownItem+ key={source.id}+ icon={<AppWindow size={16} />}+ selected={selectedSource === source.name}+ onClick={() => handleSourceSelect(source)}+ >+ {source.appName && source.appName !== source.name+ ? `${source.appName} — ${source.name}`+ : source.name}+ </DropdownItem>+ ))}+ </>+ )}+ {screenSources.length === 0 && windowSources.length === 0 && (+ <div className="text-center text-xs text-[#6b6b78] py-4">+ No sources found+ </div>+ )}+ </>)}- </Button>+ </>)}- <Button- variant="link"- size="icon"- onClick={() => !recording && setSystemAudioEnabled(!systemAudioEnabled)}- disabled={recording}- title={- systemAudioEnabled- ? t("recording.disableSystemAudio")- : t("recording.enableSystemAudio")- }- className="text-white/80 hover:bg-transparent"- >- {systemAudioEnabled ? (- <MdVolumeUp size={16} className="text-[#2563EB]" />- ) : (- <MdVolumeOff size={16} className="text-white/35" />- )}- </Button>- <Button- variant="link"- size="icon"- onClick={() => !recording && setWebcamEnabled(!webcamEnabled)}- disabled={recording}- title={- webcamEnabled- ? t("recording.disableWebcam")- : t("recording.enableWebcam")- }- className="text-white/80 hover:bg-transparent"- >- {webcamEnabled ? (- <MdOutlineVideocam size={16} className="text-[#2563EB]" />- ) : (- <MdOutlineVideocamOff size={16} className="text-white/35" />- )}- </Button>- <Button- variant="link"- size="icon"- onClick={toggleMicrophone}- disabled={recording}- title={- microphoneEnabled- ? t("recording.disableMicrophone")- : t("recording.enableMicrophone")- }- className="text-white/80 hover:bg-transparent"- >- {microphoneEnabled ? (- <MdMic size={16} className="text-[#2563EB]" />- ) : (- <MdMicOff size={16} className="text-white/35" />- )}- </Button>- </div>- <div className={dividerClass} />+ {activeDropdown === "mic" && (+ <>+ <div className={styles.ddLabel}>Microphone</div>+ {microphoneEnabled && (+ <DropdownItem+ icon={<MicOff size={16} />}+ onClick={() => { setMicrophoneEnabled(false); setActiveDropdown("none"); }}+ >+ Turn Off Microphone+ </DropdownItem>+ )}+ {!microphoneEnabled && (+ <div className="px-3 py-2 text-xs text-[#6b6b78]">+ Select a microphone to enable+ </div>+ )}+ {devices.map((device) => (+ <MicDeviceRow+ key={device.deviceId}+ device={device}+ selected={microphoneEnabled && (microphoneDeviceId === device.deviceId || selectedDeviceId === device.deviceId)}+ onSelect={() => {+ setMicrophoneEnabled(true);+ setSelectedDeviceId(device.deviceId);+ setMicrophoneDeviceId(device.deviceId);+ }}+ />+ ))}+ {devices.length === 0 && (+ <div className="text-center text-xs text-[#6b6b78] py-4">+ No microphones found+ </div>+ )}+ </>+ )}- <DropdownMenu>- <DropdownMenuTrigger asChild>- <Button- variant="link"- size="sm"- disabled={recording || countdownActive}- title={t("recording.countdownDelay")}- className={`gap-1 px-1 text-xs text-white/70 hover:bg-transparent ${styles.electronNoDrag}`}- >- <Timer size={14} />- <span>{countdownDelay > 0 ? `${countdownDelay}s` : t("recording.noDelay")}</span>- </Button>- </DropdownMenuTrigger>- <DropdownMenuContent- side="top"- align="center"- className="min-w-[80px] max-h-none overflow-visible border-white/15 bg-[rgba(28,28,36,0.97)] text-white/90 backdrop-blur-xl"- >- {[0, 3, 5, 10].map((delay) => (- <DropdownMenuItem- key={delay}- onSelect={() => setCountdownDelay(delay)}- className={`cursor-pointer text-xs ${- countdownDelay === delay ? "font-medium text-white" : "text-white/60"- }`}- >- {delay === 0 ? t("recording.noDelay") : `${delay}s`}- </DropdownMenuItem>- ))}- </DropdownMenuContent>- </DropdownMenu>-- <Button- variant="link"- size="sm"- onClick={hasSelectedSource ? toggleRecording : openSourceSelector}- disabled={countdownActive || (!hasSelectedSource && !recording)}- className={`gap-1 text-white bg-transparent hover:bg-transparent px-0 text-xs ${styles.electronNoDrag}`}- >- {recording ? (++ {activeDropdown === "webcam" && (+ <>- <FaRegStopCircle size={14} className="text-red-400" />- <span className="text-red-400 font-medium tabular-nums">{formatTime(elapsed)}</span>++ <div className={styles.ddLabel}>Webcam</div>++ {webcamEnabled && (++ <DropdownItem++ icon={<VideoOff size={16} />}++ onClick={() => { setWebcamEnabled(false); setActiveDropdown("none"); }}++ >++ Turn Off Webcam++ </DropdownItem>++ )}++ {!webcamEnabled && (++ <div className="px-3 py-2 text-xs text-[#6b6b78]">++ Select a webcam to enable++ </div>++ )}++ {showWebcamControls && (++ <div className="flex justify-center px-3 py-2">++ <div className="h-24 w-24 overflow-hidden rounded-2xl bg-white/5 ring-1 ring-white/10">++ <video++ ref={webcamPreviewRef}++ className="h-full w-full object-cover"++ muted++ playsInline++ style={{ transform: "scaleX(-1)" }}++ />++ </div>++ </div>++ )}++ {videoDevices.map((device) => (++ <DropdownItem++ key={device.deviceId}++ icon={webcamEnabled && (webcamDeviceId === device.deviceId || selectedVideoDeviceId === device.deviceId) ? <Video size={16} /> : <VideoOff size={16} />}++ selected={webcamEnabled && (webcamDeviceId === device.deviceId || selectedVideoDeviceId === device.deviceId)}++ onClick={() => {++ setWebcamEnabled(true);++ setSelectedVideoDeviceId(device.deviceId);++ setWebcamDeviceId(device.deviceId);++ }}++ >++ {device.label}++ </DropdownItem>++ ))}++ {videoDevices.length === 0 && (++ <div className="text-center text-xs text-[#6b6b78] py-4">++ No webcams found++ </div>++ )}+ </>- ) : (++ )}+++ {activeDropdown === "countdown" && (<>- <BsRecordCircle- size={14}- className={hasSelectedSource ? "text-white/85" : "text-white/35"}- />- <span className={hasSelectedSource ? "text-white/80" : "text-white/35"}>- {t("recording.record")}- </span>+ <div className={styles.ddLabel}>{t("recording.countdownDelay")}</div>+ {COUNTDOWN_OPTIONS.map((delay) => (+ <DropdownItem+ key={delay}+ icon={<Timer size={16} />}+ selected={countdownDelay === delay}+ onClick={() => { setCountdownDelay(delay); setActiveDropdown("none"); }}+ >+ {delay === 0 ? t("recording.noDelay") : `${delay}s`}+ </DropdownItem>+ ))}</>)}- </Button>-- <Button- variant="link"- size="sm"- onClick={chooseRecordingsDirectory}- disabled={recording}- title={- recordingsDirectory- ? t("recording.recordingFolder", undefined, { path: recordingsDirectory })- : t("recording.chooseRecordingsFolder")- }- className={`text-white/75 hover:bg-transparent px-1 text-[11px] underline decoration-white/45 underline-offset-2 ${styles.electronNoDrag}`}- >- <ContentClamp truncateLength={18}>- {t("recording.folderPath", undefined, { name: recordingsDirectoryName })}- </ContentClamp>- </Button>-- <div className="ml-auto flex items-center gap-0.5">- <div className={dividerClass} />- <Button- variant="link"- size="icon"- onClick={openVideoFile}- disabled={recording}- title={t("recording.openVideoFile")}- className={`text-white/70 hover:bg-transparent ${styles.electronNoDrag}`}- >- <MdVideoFile size={15} />- </Button>- <Button- variant="link"- size="icon"- onClick={openProjectFile}- disabled={recording}- title={t("recording.openProject")}- className={`text-white/70 hover:bg-transparent ${styles.electronNoDrag}`}- >- <FaFolderOpen size={14} />- </Button>- <DropdownMenu>- <DropdownMenuTrigger asChild>- <Button- variant="link"- size="icon"- title="Language"- className={`text-white/70 hover:bg-transparent ${styles.electronNoDrag}`}- >- <Languages size={14} />- </Button>- </DropdownMenuTrigger>- <DropdownMenuContent- side="top"- align="end"- className="min-w-[90px] bg-[rgba(28,28,36,0.97)] border-white/15 text-white/90 backdrop-blur-xl"- >++ {activeDropdown === "more" && (+ <>+ <DropdownItem icon={<FolderOpen size={16} />} onClick={chooseRecordingsDirectory}>+ Recordings Folder+ </DropdownItem>+ <DropdownItem icon={<VideoIcon size={16} />} onClick={openVideoFile}>+ {t("recording.openVideoFile")}+ </DropdownItem>+ <DropdownItem icon={<FolderOpen size={16} />} onClick={openProjectFile}>+ {t("recording.openProject")}+ </DropdownItem>+ <div className={styles.ddLabel} style={{ marginTop: 4 }}>Language</div>{SUPPORTED_LOCALES.map((code) => (- <DropdownMenuItem+ <DropdownItemkey={code}- onSelect={() => setLocale(code as AppLocale)}- className={`text-xs cursor-pointer ${- locale === code ? "text-white font-medium" : "text-white/60"- }`}+ icon={<Languages size={16} />}+ selected={locale === code}+ onClick={() => { setLocale(code as AppLocale); setActiveDropdown("none"); }}>{LOCALE_LABELS[code] ?? code}- </DropdownMenuItem>+ </DropdownItem>))}- </DropdownMenuContent>- </DropdownMenu>- <div className={dividerClass} />- <Button- variant="link"- size="icon"- onClick={sendHudOverlayHide}- title={t("recording.hideHud")}- className={`text-white/70 hover:bg-transparent ${styles.electronNoDrag}`}+ </>+ )}+ </div>+ )}+ </div>++ {/* Bottom section — fixed height, bar always stays here */}+ <div className="flex flex-col items-center">+ <div className={`${styles.bar} ${styles.electronDrag} mb-2`}>+ <div className={`flex items-center px-0.5 ${styles.electronDrag}`}>+ <RxDragHandleDots2 size={14} className="text-[#6b6b78]" />+ </div>++ {recording ? (+ <>+ <div className="flex items-center gap-[5px]">+ <div className={`w-[7px] h-[7px] rounded-full ${paused ? "bg-[#fbbf24]" : `bg-[#f43f5e] ${styles.recDotBlink}`}`} />+ <span className={`text-[10px] font-bold tracking-[0.06em] ${paused ? "text-[#fbbf24]" : "text-[#f43f5e]"}`}>+ {paused ? "PAUSED" : "REC"}+ </span>+ </div>++ <span className={`font-mono text-xs font-semibold min-w-[52px] text-center tracking-[0.02em] ${paused ? "text-[#fbbf24]" : "text-[#eeeef2]"}`}>+ {formatTime(elapsed)}+ </span>++ <Separator />++ <IconButton title={microphoneEnabled ? t("recording.disableMicrophone") : t("recording.enableMicrophone")} className={microphoneEnabled ? styles.ibActive : ""}>+ {microphoneEnabled ? <Mic size={18} /> : <MicOff size={18} />}+ </IconButton>++ <Separator />++ <IconButton onClick={paused ? resumeRecording : pauseRecording} title={paused ? "Resume" : "Pause"} className={paused ? styles.ibGreen : ""}>+ {paused ? <Play size={18} fill="currentColor" strokeWidth={0} /> : <Pause size={18} />}+ </IconButton>++ <IconButton onClick={toggleRecording} title="Stop" className={styles.ibRed}>+ <Square size={16} fill="currentColor" strokeWidth={0} />+ </IconButton>++ <IconButton onClick={cancelRecording} title="Cancel">+ <X size={18} />+ </IconButton>+ </>+ ) : (+ <>+ <button+ type="button"+ className={`${styles.screenSel} ${styles.electronNoDrag}`}+ onClick={() => toggleDropdown("sources")}+ title={selectedSource}>- <FiMinus size={16} />- </Button>- <Button- variant="link"- size="icon"- onClick={sendHudOverlayClose}- title={t("recording.closeApp")}- className={`text-white/70 hover:bg-transparent ${styles.electronNoDrag}`}+ <Monitor size={16} />+ <ContentClamp truncateLength={10}>{selectedSource}</ContentClamp>+ <ChevronUp size={10} className={`text-[#6b6b78] ml-0.5 transition-transform duration-200 ${activeDropdown === "sources" ? "" : "rotate-180"}`} />+ </button>++ <Separator />++ <IconButton+ onClick={toggleMicrophone}+ title={microphoneEnabled ? t("recording.disableMicrophone") : t("recording.enableMicrophone")}+ className={microphoneEnabled ? styles.ibActive : ""}>- <FiX size={16} />- </Button>- </div>+ {microphoneEnabled ? <Mic size={18} /> : <MicOff size={18} />}+ </IconButton>++ <IconButton+ onClick={() => setSystemAudioEnabled(!systemAudioEnabled)}+ title={systemAudioEnabled ? t("recording.disableSystemAudio") : t("recording.enableSystemAudio")}+ className={systemAudioEnabled ? styles.ibActive : ""}+ >+ {systemAudioEnabled ? <Volume2 size={18} /> : <VolumeX size={18} />}+ </IconButton>+++ <IconButton++ onClick={toggleWebcam}++ title={webcamEnabled ? t("recording.disableWebcam") : t("recording.enableWebcam")}++ className={webcamEnabled ? styles.ibActive : ""}++ >++ {webcamEnabled ? <Video size={18} /> : <VideoOff size={18} />}++ </IconButton>+++ {supportsHudCaptureProtection && (+ <IconButton+ onClick={() => void toggleHudCaptureProtection()}+ title={hideHudFromCapture ? t("recording.showHudInVideo") : t("recording.hideHudFromVideo")}+ >+ {hideHudFromCapture ? <EyeOff size={18} className="text-[#6b6b78]" /> : <Eye size={18} className="text-[#6360f5]" />}+ </IconButton>+ )}++ <IconButton+ onClick={() => toggleDropdown("countdown")}+ title={t("recording.countdownDelay")}+ className={countdownDelay > 0 ? styles.ibActive : ""}+ >+ <Timer size={18} />+ </IconButton>++ <Separator />++ <button+ type="button"+ className={`${styles.recBtn} ${styles.electronNoDrag}`}+ onClick={hasSelectedSource ? toggleRecording : () => toggleDropdown("sources")}+ disabled={countdownActive}+ title={t("recording.record")}+ >+ <div className={styles.recDot} />+ </button>++ <Separator />++ <IconButton onClick={() => toggleDropdown("more")} title="More">+ <MoreVertical size={18} />+ </IconButton>++ <IconButton onClick={() => window.electronAPI?.hudOverlayHide?.()} title={t("recording.hideHud")}>+ <Minus size={16} />+ </IconButton>++ <IconButton onClick={() => window.electronAPI?.hudOverlayClose?.()} title={t("recording.closeApp")}>+ <X size={16} />+ </IconButton>+ </>+ )}</div></div></div>diff --cc src/components/video-editor/editorPreferences.test.tsindex 4d185696,4d185696..23fa07eb--- a/src/components/video-editor/editorPreferences.test.ts+++ b/src/components/video-editor/editorPreferences.test.ts@@@ -94,6 -94,6 +94,7 @@@ describe("editorPreferences", () =>gifFrameRate: 30,gifLoop: false,gifSizePreset: DEFAULT_EDITOR_PREFERENCES.gifSizePreset,++ webcam: DEFAULT_EDITOR_PREFERENCES.webcam,customAspectWidth: "21",customAspectHeight: "9",customWallpapers: ["data:image/jpeg;base64,abc"],@@@ -134,6 -134,6 +135,7 @@@gifFrameRate: DEFAULT_EDITOR_PREFERENCES.gifFrameRate,gifLoop: DEFAULT_EDITOR_PREFERENCES.gifLoop,gifSizePreset: DEFAULT_EDITOR_PREFERENCES.gifSizePreset,++ webcam: DEFAULT_EDITOR_PREFERENCES.webcam,customAspectWidth: "21",customAspectHeight: "9",customWallpapers: DEFAULT_EDITOR_PREFERENCES.customWallpapers,@@@ -193,6 -193,6 +195,7 @@@gifFrameRate: 20,gifLoop: false,gifSizePreset: "large",++ webcam: DEFAULT_EDITOR_PREFERENCES.webcam,customAspectWidth: "4",customAspectHeight: "5",customWallpapers: ["data:image/jpeg;base64,abc"],diff --cc src/hooks/useScreenRecorder.tsindex 11e3bd11,a49a23c9..2804d0d9--- a/src/hooks/useScreenRecorder.ts+++ b/src/hooks/useScreenRecorder.ts@@@ -162,8 -180,125 +185,126 @@@ export function useScreenRecorder(): Us}}, []);+ const finalizeRecordingSession = useCallback(async (videoPath: string, webcamPath: string | null) => {+ if (webcamPath) {+ await window.electronAPI.setCurrentRecordingSession({+ videoPath,+ webcamPath,+ });+ } else {+ await window.electronAPI.setCurrentVideoPath(videoPath);+ }++ await window.electronAPI.switchToEditor();+ }, []);++ const stopWebcamRecorder = useCallback(async () => {+ const recorder = webcamRecorder.current;+ const pending = webcamStopPromise.current;++ if (!recorder) {+ return null;+ }++ if (recorder.state !== "inactive") {+ recorder.stop();+ }++ const result = pending ? await pending : null;+ pendingWebcamPathPromise.current = null;+ return result;+ }, []);++ const startWebcamRecorder = useCallback(async () => {+ if (!webcamEnabled) {+ pendingWebcamPathPromise.current = Promise.resolve(null);+ return;+ }++ try {+ webcamStream.current = await navigator.mediaDevices.getUserMedia({+ video: webcamDeviceId+ ? {+ deviceId: { exact: webcamDeviceId },+ width: { ideal: WEBCAM_WIDTH },+ height: { ideal: WEBCAM_HEIGHT },+ frameRate: { ideal: WEBCAM_FRAME_RATE, max: WEBCAM_FRAME_RATE },+ }+ : {+ width: { ideal: WEBCAM_WIDTH },+ height: { ideal: WEBCAM_HEIGHT },+ frameRate: { ideal: WEBCAM_FRAME_RATE, max: WEBCAM_FRAME_RATE },+ },+ audio: false,+ });++ const mimeType = selectMimeType();+ webcamChunks.current = [];+ webcamStopPromise.current = new Promise((resolve) => {+ webcamStopResolver.current = resolve;+ });+ pendingWebcamPathPromise.current = webcamStopPromise.current;++ const recorder = new MediaRecorder(webcamStream.current, {+ mimeType,+ videoBitsPerSecond: WEBCAM_BITRATE,+ });++ webcamRecorder.current = recorder;+ recorder.ondataavailable = (event) => {+ if (event.data && event.data.size > 0) {+ webcamChunks.current.push(event.data);+ }+ };+ recorder.onerror = () => {+ webcamStopResolver.current?.(null);+ webcamStopResolver.current = null;+ };+ recorder.onstop = async () => {+ const sessionTimestamp = recordingSessionTimestamp.current ?? Date.now();+ const webcamFileName = `${RECORDING_FILE_PREFIX}${sessionTimestamp}${WEBCAM_SUFFIX}${VIDEO_FILE_EXTENSION}`;++ try {+ if (webcamChunks.current.length === 0) {+ webcamStopResolver.current?.(null);+ return;+ }++ const duration = Date.now() - startTime.current;+ const webcamBlob = new Blob(webcamChunks.current, { type: mimeType });+ webcamChunks.current = [];+ const fixedBlob = await fixWebmDuration(webcamBlob, duration);+ const arrayBuffer = await fixedBlob.arrayBuffer();+ const result = await window.electronAPI.storeRecordedVideo(arrayBuffer, webcamFileName);+ webcamStopResolver.current?.(result.success ? result.path ?? null : null);+ } catch (error) {+ console.error("Error saving webcam recording:", error);+ webcamStopResolver.current?.(null);+ } finally {+ webcamStopResolver.current = null;+ webcamRecorder.current = null;+ if (webcamStream.current) {+ webcamStream.current.getTracks().forEach((track) => track.stop());+ webcamStream.current = null;+ }+ }+ };++ recorder.start(RECORDER_TIMESLICE_MS);+ } catch (error) {+ console.warn("Failed to start webcam recording; continuing without webcam layer:", error);+ pendingWebcamPathPromise.current = Promise.resolve(null);+ webcamStopPromise.current = Promise.resolve(null);+ webcamRecorder.current = null;+ if (webcamStream.current) {+ webcamStream.current.getTracks().forEach((track) => track.stop());+ webcamStream.current = null;+ }+ }+ }, [webcamDeviceId, webcamEnabled]);+const stopRecording = useRef(() => {+ setPaused(false);if (nativeScreenRecording.current) {nativeScreenRecording.current = false;setRecording(false);@@@ -193,14 -328,10 +334,15 @@@return;}- if (mediaRecorder.current?.state === "recording") {+ const recorder = mediaRecorder.current;+ const recorderState = recorder?.state;+ if (recorder && (recorderState === "recording" || recorderState === "paused")) {+ if (recorderState === "paused") {+ recorder.resume();+ }+ pendingWebcamPathPromise.current = stopWebcamRecorder();cleanupCapturedMedia();- mediaRecorder.current.stop();+ recorder.stop();setRecording(false);window.electronAPI?.setRecordingState(false);}