Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
perf(hud): reserve the overlay's space instead of discovering it
Etienne Lescot7f166c0fee75
diff --git a/docs/architecture/openscreen-inventory.md b/docs/architecture/openscreen-inventory.mdindex 9056f83d3..cc1db3e30 100644--- a/docs/architecture/openscreen-inventory.md+++ b/docs/architecture/openscreen-inventory.md@@ -308,7 +308,7 @@ The renderer client (Zustand-free) is `nativeBridgeClient.system|project|cursor`### Full IPC channel list (from `electron/ipc/handlers.ts` grep + `electron/preload.ts`)- **HUD / window controls** (`windows.ts`, `main.ts`):- - `hud-overlay-hide`, `hud-overlay-close`, `hud-overlay-ignore-mouse-events`, `hud-overlay-move-by`, `hud-overlay-set-size` (one-way `ipcMain.on`).+ - `hud-overlay-hide`, `hud-overlay-close`, `hud-overlay-ignore-mouse-events`, `hud-overlay-drag-start`, `hud-overlay-drag-to`, `hud-overlay-drag-end`, `hud-overlay-set-size` (one-way `ipcMain.on`).- `menu-new-project`, `menu-load-project`, `menu-save-project`, `menu-save-project-as`, `menu-import-video` (`preload.ts:202-225`, renderer listeners via `onMenu*`).- `hud:setMicrophoneExpanded` (one-way).- `set-has-unsaved-changes` (one-way).diff --git a/docs/openscreen-ux-ui-spec.md b/docs/openscreen-ux-ui-spec.mdindex 47c2c3f59..ba32d5da6 100644--- a/docs/openscreen-ux-ui-spec.md+++ b/docs/openscreen-ux-ui-spec.md@@ -33,49 +33,78 @@ A draggable, mouse-passthrough glassmorphic pill that lives on top of the deskto### 2.1 Top-level layout-The HUD mounts inside a div with `min-w-0 max-w-full overflow-hidden` and a `body { background: transparent }` override. The bar itself is `fixed bottom-5 left-1/2 -translate-x-1/2`, drag handle to the left, controls in the centre, window controls to the right. The window is mouse-ignored by default (`setHudOverlayIgnoreMouseEvents(true)`); it only becomes interactive when the user hovers a button or opens a popup.+The HUD mounts inside a div with `min-w-0 max-w-full overflow-hidden` and a `body { background: transparent }` override. Everything sits in one bottom-anchored, upward-growing stack (`fixed bottom-5 left-1/2 -translate-x-1/2`): the bar at the bottom, then any popover, then any notice, laid out by flexbox relative to the bar rather than positioned from measured rects. Drag handle to the left, controls in the centre, window controls to the right. The window is mouse-ignored by default (`setHudOverlayIgnoreMouseEvents(true)`); it only becomes interactive when the user hovers a button or opens a popup.-The window auto-resizes to fit content via a `ResizeObserver` and `window.electronAPI.setHudOverlaySize(w, h)`. Padding ensures the shadow isn't clipped and a system-language prompt can pop up above the bar without overlap.+The overlay window's size is driven from the renderer via `setHudOverlaySize(w, h)`, but on a **reserve, don't discover** basis — see `src/components/launch/hudGeometry.ts`. Only the bar is measured; every floating panel has a fixed width and a capped, internally-scrolling height whose space is reserved in the window from the first frame. Consequences worth knowing:++- Opening or closing any floating surface — popover, device-settings panel, notice — or a device list changing length, costs **zero** native resizes. The reserve is sized against the tallest of them, not against whichever is open.+- No measured box may be sized in `vh`/`vw`. A viewport-relative size makes the box depend on the window, and those boxes feed the sizing measurement — which closes a resize → re-layout → re-measure loop. Screen-derived caps (`screen.availHeight`) arrive as `--hud-*` custom properties instead.+- Resizes are applied in one shot, not tweened: they only ever accompany a discrete content change (orientation flip) that snaps anyway.+- Allocation is asymmetric — grow as soon as the content stops fitting, shrink only once it has fallen a whole reserve below what was granted. So the bar can grow into its reserve (recording controls, a longer source name) and back out without any resize at all.### 2.2 Controls (left → right, horizontal mode is default)Every control is also vertically stackable — the layout toggle is the first button in the bar (Columns3 / Rows3 icons). The choice is persisted in `localStorage` as `userPreferences.trayLayout`.-1. **Drag handle** — six-dot grip, pointer-captured. Drag moves the HUD overlay (`moveHudOverlayBy`); releases re-ignore mouse events.+1. **Drag handle** — six-dot grip, pointer-captured. Pointerdown pins the window's origin in the main process (`beginHudOverlayDrag`); each move sends the pointer's *total* travel since then (`dragHudOverlayTo`), so nothing accumulates or drifts; release ends the gesture and re-measures the content.2. **Layout toggle** — swaps between horizontal (`Columns3` icon, default) and vertical (`Rows3` icon, `aria-pressed=true` when vertical). Tooltip "Use vertical tray" / "Use horizontal tray".-3. **Source picker button** — screen icon + truncated source name (e.g. "Entire Screen"). Disabled during recording. Opens `<SourceSelector>` window. Selection is mirrored in the bar every 500ms and whenever the source changes (so the label updates without polling the user).-4. **Audio group** — three buttons in a single rounded container:- - System audio (`MdVolumeUp` / `MdVolumeOff`). Disabled during recording.- - Microphone (`MdMic` / `MdMicOff`). When enabled and not recording, an **Audio Level Meter** + mic picker pop-up appears above the bar: shows the current mic name (truncated), a `<select>` of all `getUserMedia` microphones, and a 5-bar level meter driven by `useAudioLevelMeter` (FFT analyser, smoothing 0.8). Pop-up collapses on mouse leave / blur.- - Webcam (`MdVideocam` / `MdVideocamOff`). When enabled and not recording, a webcam pop-up shows the camera label + `<select>` and gracefully handles `Searching…`, `Camera unavailable`, `No camera found` states.-5. **Cursor mode** (only on macOS / Windows, hidden on Linux) — toggles between `editable-overlay` (default, OpenScreen draws a stylised cursor you can theme/edit) and `system` (record OS cursor as-is).-6. **Record/Stop button**:+3. **Source picker button** — screen icon + truncated source name (e.g. "Entire Screen"). Disabled during recording. Opens `<SourceSelector>` window. The label is seeded once on mount and then kept in sync by the `onSelectedSourceChanged` event (plus a refresh on window focus) — there is no polling.+4. **Capture group** — system audio, microphone and webcam, each a standalone icon button, and all three **plain on/off toggles**. One click switches the device on using whatever is currently selected (the system default until the user says otherwise); one click switches it off. Disabled during recording. Choosing *which* device is a separate concern and lives in the settings panel below — overloading one button with both jobs is what made turning a camera on take two clicks.+5. **Device settings** (gear) — opens the device panel in the stack above the bar (§2.3). Disabled during recording, when devices can't be changed anyway. It sits with the mic and camera toggles it configures inside a hairline-outlined group, tighter than the bar's normal spacing: a fill light enough to read on `#14171c` would land brighter than the buttons' own hover colour and invert the hover affordance, so the grouping is marked with an inset outline instead.+6. **Cursor mode** (only on macOS / Windows, hidden on Linux) — toggles between `editable-overlay` (default, OpenScreen draws a stylised cursor you can theme/edit) and `system` (record OS cursor as-is).+7. **Record/Stop button**:- When idle and a source is selected: pill with the red **record** icon, plus the source name on hover.- When idle and no source: same pill but greyed, clicking it opens the Source Selector first and then auto-starts recording once a source is picked (`recordAfterSourceSelectionRef`).- When recording: red/amber pill with the **stop** icon plus a `mm:ss` elapsed timer (`formatTimePadded`) that ticks up live. Background turns red while running, amber when paused.-7. **Recording-state auxiliary buttons** (only while recording):+8. **Recording-state auxiliary buttons** (only while recording):- **Pause/Resume** (`BsPauseCircle` ↔ `BsPlayCircle`) — only shown if `canPauseRecording`.- **Restart** (`MdRestartAlt`) — throws away current take and starts fresh.- **Cancel** (`MdCancel`) — discards the current take without saving.-8. **Open Studio** (`Clapperboard` icon, hidden during recording) — switches to the editor window via `window.electronAPI.switchToEditor()`.-9. **Language button** (right sidebar) — pill labelled with the current locale short name (e.g. "EN"), opens a portal-rendered language menu above the bar. Each item shows the localized language name with a check next to the current one. Click-outside and `Esc` close it. Width is constrained so it doesn't overflow the desktop. The list of locales is pulled from `getAvailableLocales()`.-10. **Window controls** (far right) — `−` (hide HUD, keeps app running) and `×` (close app).--### 2.3 Hover behaviour+9. **Open Studio** (`Clapperboard` icon, hidden during recording) — switches to the editor window via `window.electronAPI.switchToEditor()`.+10. **Language button** (right sidebar) — pill labelled with the current locale short name (e.g. "EN"), opens the language menu in the stack above the bar. Each item shows the localized language name with a check next to the current one. Click-outside and `Esc` close it. Its height is a plain CSS cap (320px, scrolls past that) rather than a value measured against the overlay window — that measurement is what used to truncate the list to a couple of entries and then let it grow whenever the window happened to grow. The list of locales is pulled from `getAvailableLocales()`.+11. **Window controls** (far right) — `−` (hide HUD, keeps app running) and `×` (close app).++### 2.3 Device settings panel++Opened from the gear button, and the only place devices are chosen. It lists the+microphone and camera inputs with the active one checked, and lets the user+*verify* each before recording:++- A live segmented **input-level meter** under the microphone list, fed by+ `useAudioLevelMeter` on the selected device.+- A live mirrored **camera preview** under the camera list, fed by+ `useCameraPreviewStream` on the selected device.++Both streams belong to the panel, are torn down when it closes, and are entirely+separate from the recorder's own capture streams. Neither is opened when the+corresponding hardware is absent. **Selecting a device never switches it on** —+if the device is already live the recorder re-acquires it on the id change,+otherwise the choice simply applies to the next toggle.++It is the tallest floating surface, so it is what the window's vertical reserve+is sized against (see §2.1) — permanently, open or not. Opening it therefore+costs **zero** resizes, like every other surface: sizing the reserve to whatever+happens to be open would grow the window on open, and since the stack is+bottom-anchored, growing upward shifts all the content down in window+coordinates a frame or two before the renderer repaints it — which is visible as+position judder. Click-outside, `Esc` and its own Done control all close it, and+it is mutually exclusive with the language menu.++### 2.4 Hover behaviour- Hover/pointer-enter on the bar enables mouse events on the overlay (`setHudOverlayIgnoreMouseEvents(false)`).-- Pointer-leave disables them again, except while a popup is open.-- The selected source name refreshes every 500 ms plus on `onSelectedSourceChanged`, so the bar stays in sync if a non-OpenScreen app pops a system picker.+- Pointer-leave disables them again, except while a popup is open (a popup reaches beyond the bar, and the gap between the two would otherwise flip the overlay back to click-through mid-travel).+- The selected source name is seeded once on mount and then follows `onSelectedSourceChanged`, with a refresh on window focus to cover anything missed while the window was gone.-### 2.4 System-language prompt+### 2.5 System-language prompt-If the OS locale differs from the current UI locale and hasn't been resolved, a glassy card slides in at `top-8 center`:+If the OS locale differs from the current UI locale and hasn't been resolved, a glassy card fades in at the top of the HUD stack, above the bar and above any open popover (a fixed 360px wide, so it can't resize the overlay horizontally):- Title: "Use your system language?"- Body: "We detected X as your system language. Do you want to switch OpenScreen to X?"- Two buttons: **Keep current language** / **Switch to X**. Both resolve the prompt so it never reappears.-### 2.5 Loading and error states+### 2.6 Loading and error statesThe HUD itself doesn't have an explicit "loading" state — `useScreenRecorder` handles all of that internally. Errors surface via Sonner toasts triggered from the recorder hook:@@ -87,7 +116,7 @@ The HUD itself doesn't have an explicit "loading" state — `useScreenRecorder`- "Recording permission denied. Please allow screen recording."- "Allow Accessibility access for OpenScreen, then press record again to start the countdown." (macOS)-### 2.6 Countdown integration+### 2.7 Countdown integrationWhen the user hits Record, the recorder calls `window.electronAPI.showCountdownOverlay(value, runId)` to spawn the `<CountdownOverlay>` window. The HUD doesn't itself render numbers — it just waits for the recorder to flip into the recording state.@@ -571,7 +600,7 @@ The renderer also calls into the main process for:- `showCountdownOverlay` / `hideCountdownOverlay` / `onCountdownOverlayValue` — countdown window.- `startNativeWindowsRecording` / `pauseNativeWindowsRecording` / `resumeNativeWindowsRecording` / `stopNativeWindowsRecording` / `startNativeMacRecording` / `pauseNativeMacRecording` / `resumeNativeMacRecording` / `stopNativeMacRecording` / `isNativeWindowsCaptureAvailable` / `isNativeMacCaptureAvailable` / `requestNativeMacCursorAccess` / `attachNativeMacWebcamRecording` — native recorder pipeline.- `getCurrentRecordingSession` / `setCurrentRecordingSession` / `setHasUnsavedChanges` / `onRequestSaveBeforeClose` / `onRequestCloseConfirm` — session handoff between recorder and editor.-- `setHudOverlaySize` / `moveHudOverlayBy` / `setHudOverlayIgnoreMouseEvents` — HUD geometry.+- `setHudOverlaySize` / `beginHudOverlayDrag` + `dragHudOverlayTo` + `endHudOverlayDrag` / `setHudOverlayIgnoreMouseEvents` — HUD geometry.- `requestScreenAccess`, `requestCameraAccess`, `openExternalUrl`, `openVideoFilePicker`, `readBinaryFile`, `saveDiagnostic` — utilities.---diff --git a/electron/electron-env.d.ts b/electron/electron-env.d.tsindex 8c55cc5e4..2c14fd619 100644--- a/electron/electron-env.d.ts+++ b/electron/electron-env.d.ts@@ -331,7 +331,11 @@ interface Window {hudOverlayHide: () => void;hudOverlayClose: () => void;setHudOverlayIgnoreMouseEvents: (ignore: boolean) => void;- moveHudOverlayBy: (deltaX: number, deltaY: number) => void;+ /** Pins the overlay's current position as the origin for `dragHudOverlayTo`. */+ beginHudOverlayDrag: () => void;+ /** Total pointer travel since `beginHudOverlayDrag`, not a per-frame delta. */+ dragHudOverlayTo: (deltaX: number, deltaY: number) => void;+ endHudOverlayDrag: () => void;setHudOverlaySize: (width: number, height: number) => void;showCountdownOverlay: (value: number, runId: number) => Promise<void>;setCountdownOverlayValue: (value: number, runId: number) => Promise<void>;diff --git a/electron/preload.ts b/electron/preload.tsindex 6137d3a24..47acee6f2 100644--- a/electron/preload.ts+++ b/electron/preload.ts@@ -75,8 +75,14 @@ contextBridge.exposeInMainWorld("electronAPI", {setHudOverlayIgnoreMouseEvents: (ignore: boolean) => {ipcRenderer.send("hud-overlay-ignore-mouse-events", ignore);},- moveHudOverlayBy: (deltaX: number, deltaY: number) => {- ipcRenderer.send("hud-overlay-move-by", deltaX, deltaY);+ beginHudOverlayDrag: () => {+ ipcRenderer.send("hud-overlay-drag-start");+ },+ dragHudOverlayTo: (deltaX: number, deltaY: number) => {+ ipcRenderer.send("hud-overlay-drag-to", deltaX, deltaY);+ },+ endHudOverlayDrag: () => {+ ipcRenderer.send("hud-overlay-drag-end");},setHudOverlaySize: (width: number, height: number) => {ipcRenderer.send("hud-overlay-set-size", width, height);diff --git a/electron/windows.ts b/electron/windows.tsindex 26eeeade7..ca6713627 100644--- a/electron/windows.ts+++ b/electron/windows.ts@@ -40,50 +40,11 @@ const ASSET_BASE_URL_ARG = `--asset-base-url=${pathToFileURL(`${ASSET_BASE_DIR}$let hudOverlayWindow: BrowserWindow | null = null;-interface HudBounds {- x: number;- y: number;- width: number;- height: number;-}--// Smoothly tweens the HUD's bounds instead of snapping, so every content-driven-// resize (recording state changing which controls are shown, a device popover-// opening, etc.) reads as a fluid grow/shrink rather than a jarring jump.-let hudResizeAnimationTimer: NodeJS.Timeout | null = null;-const HUD_RESIZE_DURATION_MS = 160;-const HUD_RESIZE_FRAME_MS = 1000 / 60;-const easeOutCubic = (t: number) => 1 - (1 - t) ** 3;--function animateHudBounds(win: BrowserWindow, from: HudBounds, to: HudBounds) {- if (hudResizeAnimationTimer) {- clearInterval(hudResizeAnimationTimer);- hudResizeAnimationTimer = null;- }-- const start = Date.now();- hudResizeAnimationTimer = setInterval(() => {- if (win.isDestroyed()) {- if (hudResizeAnimationTimer) clearInterval(hudResizeAnimationTimer);- hudResizeAnimationTimer = null;- return;- }-- const t = Math.min(1, (Date.now() - start) / HUD_RESIZE_DURATION_MS);- const e = easeOutCubic(t);- win.setBounds({- x: Math.round(from.x + (to.x - from.x) * e),- y: Math.round(from.y + (to.y - from.y) * e),- width: Math.round(from.width + (to.width - from.width) * e),- height: Math.round(from.height + (to.height - from.height) * e),- });-- if (t >= 1) {- if (hudResizeAnimationTimer) clearInterval(hudResizeAnimationTimer);- hudResizeAnimationTimer = null;- }- }, HUD_RESIZE_FRAME_MS);-}+// Origin the current drag gesture started from. The renderer sends the pointer's+// *total* travel since pointerdown rather than per-frame deltas, so every move is+// an absolute `origin + delta` — no rounding to accumulate, and a dropped message+// self-corrects on the next one instead of leaving the window permanently offset.+let hudDragOrigin: { x: number; y: number } | null = null;ipcMain.on("hud-overlay-hide", () => {if (hudOverlayWindow && !hudOverlayWindow.isDestroyed()) {@@ -97,23 +58,46 @@ ipcMain.on("hud-overlay-ignore-mouse-events", (_event, ignore: boolean) => {}});-ipcMain.on("hud-overlay-move-by", (_event, deltaX: number, deltaY: number) => {+ipcMain.on("hud-overlay-drag-start", () => {+ if (!hudOverlayWindow || hudOverlayWindow.isDestroyed()) {+ return;+ }++ const [x, y] = hudOverlayWindow.getPosition();+ hudDragOrigin = { x, y };+});++ipcMain.on("hud-overlay-drag-to", (_event, deltaX: number, deltaY: number) => {if (!hudOverlayWindow ||hudOverlayWindow.isDestroyed() ||+ !hudDragOrigin ||!Number.isFinite(deltaX) ||!Number.isFinite(deltaY)) {return;}- const [x, y] = hudOverlayWindow.getPosition();- hudOverlayWindow.setPosition(Math.round(x + deltaX), Math.round(y + deltaY), false);+ hudOverlayWindow.setPosition(+ Math.round(hudDragOrigin.x + deltaX),+ Math.round(hudDragOrigin.y + deltaY),+ false,+ );+});++ipcMain.on("hud-overlay-drag-end", () => {+ hudDragOrigin = null;});// Resize the HUD to fit its rendered content. Anchored by its bottom-centre so it// stays where the user dragged it while only growing/shrinking, which lets the// vertical tray layout grow tall instead of scrolling inside a fixed window.+//+// Applied in one shot rather than tweened. The renderer now reserves space for+// everything that can float above the bar, so a resize only ever accompanies a+// discrete content change (orientation flip, recording controls appearing) that+// snaps anyway — tweening the window across 10 frames just meant 10 frames of the+// bar sitting at an offset that didn't match the content it was drawn with.ipcMain.on("hud-overlay-set-size", (_event, width: number, height: number) => {if (!hudOverlayWindow ||@@ -124,6 +108,12 @@ ipcMain.on("hud-overlay-set-size", (_event, width: number, height: number) => {return;}+ // A resize re-anchors from the window's current bounds, which would fight the+ // position an in-flight drag is applying. The renderer re-measures on release.+ if (hudDragOrigin) {+ return;+ }+const bounds = hudOverlayWindow.getBounds();// Clamp to the work area of the display the HUD sits on; on a short screen the@@ -155,7 +145,7 @@ ipcMain.on("hud-overlay-set-size", (_event, width: number, height: number) => {workArea.y + workArea.height - nextHeight,);- animateHudBounds(hudOverlayWindow, bounds, {+ hudOverlayWindow.setBounds({x: nextX,y: nextY,width: nextWidth,@@ -171,8 +161,11 @@ export function createHudOverlayWindow(): BrowserWindow {const primaryDisplay = screen.getPrimaryDisplay();const { workArea } = primaryDisplay;- const windowWidth = 600;- const windowHeight = 160;+ // Close to what the renderer asks for on its very first measurement (bar plus+ // the reserved space above it), so the HUD doesn't visibly resize itself the+ // instant it becomes visible. See src/components/launch/hudGeometry.ts.+ const windowWidth = 820;+ const windowHeight = 560;const x = Math.floor(workArea.x + (workArea.width - windowWidth) / 2);const y = Math.floor(workArea.y + workArea.height - windowHeight - 5);@@ -234,6 +227,7 @@ export function createHudOverlayWindow(): BrowserWindow {win.on("closed", () => {if (hudOverlayWindow === win) {hudOverlayWindow = null;+ hudDragOrigin = null;}});diff --git a/src/components/launch/HudControls.tsx b/src/components/launch/HudControls.tsxnew file mode 100644index 000000000..788328059--- /dev/null+++ b/src/components/launch/HudControls.tsx@@ -0,0 +1,578 @@+import { Check, Languages, NotepadText, Settings } from "lucide-react";+import { memo } from "react";+import { formatTimePadded } from "../../utils/timeUtils";+import { Button } from "../ui/button";+import { Tooltip } from "../ui/tooltip";+import {+ CameraIcon,+ CursorIcon,+ getIcon,+ ICON_SIZE,+ MicIcon,+ OpenInEditorIcon,+ OrientationIcon,+ RecordGlyph,+ SourceIcon,+ VolumeIcon,+} from "./HudIcons";+import styles from "./LaunchWindow.module.css";++// Every control below is a `memo` boundary on purpose. The HUD's root re-renders+// once a second for the whole duration of a recording (the elapsed-time counter),+// and without these boundaries each of those ticks rebuilt ~10 Radix tooltip trees+// and ~60 host elements. Props are kept primitive (or stable refs/callbacks from+// the parent) so the boundaries actually hold.++const hudDisabledClasses =+ "disabled:opacity-30 disabled:cursor-not-allowed disabled:pointer-events-none";++// Exact values from the design's renderVals() (comfortable density, rounded+// shape, #10b981 accent) — btnSize 34 / btnRadius 10 / containerRadius 17+// (btnRadius + padY) / dividerLen 22. Every control is its own standalone+// transparent icon button (no shared "group" pill background) — grouping+// reads purely from proximity + the divider spans between logical sections.+const hudIconBtnClasses = `flex h-[34px] w-[34px] shrink-0 items-center justify-center rounded-[10px] border-0 bg-transparent cursor-pointer text-[#828c99] transition-all duration-150 hover:bg-[#1a1e25] hover:text-[#f5f7fa] active:scale-95 ${hudDisabledClasses} ${styles.electronNoDrag}`;++const hudAuxIconBtnClasses = `flex h-7 w-7 shrink-0 items-center justify-center rounded-[10px] border-0 bg-transparent cursor-pointer text-[#828c99] transition-colors duration-150 hover:bg-[#1a1e25] hover:text-[#f5f7fa] ${hudDisabledClasses}`;++const windowBtnClasses = `flex h-[30px] w-[30px] shrink-0 items-center justify-center rounded-[9px] border-0 bg-transparent cursor-pointer text-[#828c99] transition-all duration-150 hover:bg-[#1a1e25] hover:text-[#e9edf3] ${hudDisabledClasses}`;++const closeBtnClasses = `flex h-[30px] w-[30px] shrink-0 items-center justify-center rounded-[9px] border-0 bg-transparent cursor-pointer text-[#828c99] transition-all duration-150 hover:bg-[rgba(248,113,113,0.16)] hover:text-[#f87171] ${hudDisabledClasses}`;++export const HudDivider = memo(function HudDivider({ vertical }: { vertical: boolean }) {+ return (+ <span+ className={`${styles.hudDivider} ${vertical ? styles.hudDividerVertical : styles.hudDividerHorizontal}`}+ aria-hidden+ />+ );+});++export const HudDragHandle = memo(function HudDragHandle({+ vertical,+ onPointerDown,+ onPointerMove,+ onPointerEnd,+}: {+ vertical: boolean;+ onPointerDown: (event: React.PointerEvent<HTMLDivElement>) => void;+ onPointerMove: (event: React.PointerEvent<HTMLDivElement>) => void;+ onPointerEnd: (event: React.PointerEvent<HTMLDivElement>) => void;+}) {+ return (+ <div+ data-testid="hud-drag-handle"+ className={`flex ${vertical ? "h-6 w-8" : "h-8 w-7"} shrink-0 cursor-grab items-center justify-center active:cursor-grabbing ${styles.electronNoDrag}`}+ onPointerDown={onPointerDown}+ onPointerMove={onPointerMove}+ onPointerUp={onPointerEnd}+ onPointerCancel={onPointerEnd}+ >+ {getIcon("drag", "text-[#333a45]")}+ </div>+ );+});++export const HudTrayLayoutButton = memo(function HudTrayLayoutButton({+ vertical,+ label,+ onClick,+}: {+ vertical: boolean;+ label: string;+ onClick: () => void;+}) {+ return (+ <Tooltip content={label}>+ <button+ data-testid="launch-tray-layout-button"+ type="button"+ aria-label={label}+ aria-pressed={vertical}+ className={hudIconBtnClasses}+ onClick={onClick}+ >+ <OrientationIcon vertical={vertical} />+ </button>+ </Tooltip>+ );+});++export const HudSourceButton = memo(function HudSourceButton({+ vertical,+ label,+ disabled,+ onClick,+}: {+ vertical: boolean;+ label: string;+ disabled: boolean;+ onClick: () => void;+}) {+ return (+ <button+ data-testid="launch-source-selector-button"+ className={`flex h-[34px] shrink-0 items-center gap-[7px] rounded-[10px] border-0 bg-transparent text-[#f5f7fa] transition-all duration-150 hover:bg-[#1a1e25] active:scale-[0.97] ${hudDisabledClasses} ${+ vertical ? "w-[34px] justify-center px-0" : "pr-3 pl-2.5"+ } ${styles.electronNoDrag}`}+ onClick={onClick}+ disabled={disabled}+ title={label}+ aria-label={label}+ >+ <SourceIcon className="shrink-0" />+ <span className={`${vertical ? "sr-only" : "max-w-[86px]"} truncate text-[13px] font-medium`}>+ {label}+ </span>+ </button>+ );+});++export const HudSystemAudioButton = memo(function HudSystemAudioButton({+ enabled,+ disabled,+ label,+ onClick,+}: {+ enabled: boolean;+ disabled: boolean;+ label: string;+ onClick: () => void;+}) {+ return (+ <button+ data-testid="launch-system-audio-button"+ className={hudIconBtnClasses}+ onClick={onClick}+ disabled={disabled}+ title={label}+ >+ <VolumeIcon muted={!enabled} className={enabled ? "text-[#10b981]" : ""} />+ </button>+ );+});++export const HudMicButton = memo(function HudMicButton({+ enabled,+ disabled,+ label,+ onClick,+}: {+ enabled: boolean;+ disabled: boolean;+ label: string;+ onClick: () => void;+}) {+ return (+ <button+ data-testid="launch-microphone-button"+ className={hudIconBtnClasses}+ aria-pressed={enabled}+ onClick={onClick}+ disabled={disabled}+ title={label}+ >+ <MicIcon muted={!enabled} className={enabled ? "text-[#10b981]" : ""} />+ </button>+ );+});++export const HudCameraButton = memo(function HudCameraButton({+ enabled,+ disabled,+ label,+ onClick,+}: {+ enabled: boolean;+ disabled: boolean;+ label: string;+ onClick: () => void;+}) {+ return (+ <button+ data-testid="launch-webcam-button"+ className={hudIconBtnClasses}+ aria-pressed={enabled}+ onClick={onClick}+ disabled={disabled}+ title={label}+ >+ <CameraIcon off={!enabled} className={enabled ? "text-[#10b981]" : ""} />+ </button>+ );+});++export const HudSettingsButton = memo(function HudSettingsButton({+ disabled,+ expanded,+ label,+ onClick,+ buttonRef,+}: {+ disabled: boolean;+ expanded: boolean;+ label: string;+ onClick: () => void;+ buttonRef: React.MutableRefObject<HTMLButtonElement | null>;+}) {+ return (+ <Tooltip content={label}>+ <button+ ref={buttonRef}+ type="button"+ data-testid="launch-device-settings-button"+ aria-label={label}+ aria-expanded={expanded}+ aria-haspopup="dialog"+ // Dimmer at rest than the toggles it configures, so it reads as their+ // accessory rather than a fourth peer control.+ className={`${hudIconBtnClasses} text-[#5c6672] ${disabled ? "opacity-30 cursor-not-allowed pointer-events-none" : ""}`}+ onClick={onClick}+ disabled={disabled}+ >+ <Settings size={17} />+ </button>+ </Tooltip>+ );+});++export const HudCursorButton = memo(function HudCursorButton({+ editableOverlay,+ disabled,+ label,+ onClick,+}: {+ editableOverlay: boolean;+ disabled: boolean;+ label: string;+ onClick: () => void;+}) {+ return (+ <button+ data-testid="launch-cursor-mode-button"+ className={`flex h-[34px] w-[34px] shrink-0 items-center justify-center rounded-[10px] border-0 cursor-pointer transition-all duration-150 active:scale-95 ${hudDisabledClasses} ${styles.electronNoDrag} ${+ editableOverlay+ ? "bg-[#10b981] text-[#08090d] hover:bg-[#0e9e6e]"+ : "bg-transparent text-[#828c99] hover:bg-[#1a1e25] hover:text-[#f5f7fa]"+ }`}+ onClick={onClick}+ disabled={disabled}+ title={label}+ >+ <CursorIcon />+ </button>+ );+});++export const HudRecordButton = memo(function HudRecordButton({+ recording,+ paused,+ saving,+ elapsedSeconds,+ label,+ savingLabel,+ onClick,+}: {+ recording: boolean;+ paused: boolean;+ saving: boolean;+ elapsedSeconds: number;+ label: string;+ savingLabel: string;+ onClick: () => void;+}) {+ return (+ <Tooltip content={label}>+ <button+ data-testid="launch-record-button"+ disabled={saving}+ className={`flex h-[34px] shrink-0 items-center justify-center rounded-[17px] border-0 transition-all duration-150 ${recording || saving ? "min-w-[78px] px-3" : "w-[34px]"} ${styles.electronNoDrag} ${+ saving+ ? "bg-transparent opacity-60 cursor-not-allowed"+ : "bg-transparent hover:bg-[rgba(248,113,113,0.16)]"+ }`}+ onClick={onClick}+ title={label}+ aria-label={label}+ style={{ flex: "0 0 auto" }}+ >+ <div className={`flex items-center justify-center ${recording || saving ? "gap-1.5" : ""}`}>+ {saving ? (+ <div className="animate-spin flex items-center justify-center">+ {getIcon("spinner", "text-[#f87171]")}+ </div>+ ) : (+ <RecordGlyph+ recording={recording}+ className={paused ? "text-amber-400" : "text-[#f87171]"}+ />+ )}+ {saving && (+ <span className="text-[#f87171] text-xs font-semibold select-none">{savingLabel}</span>+ )}+ {recording && (+ <span+ className={`${paused ? "text-amber-400" : "text-[#f87171]"} inline-block w-[34px] text-left text-xs font-semibold tabular-nums`}+ >+ {formatTimePadded(elapsedSeconds)}+ </span>+ )}+ </div>+ </button>+ </Tooltip>+ );+});++export const HudStudioButton = memo(function HudStudioButton({+ disabled,+ label,+ onClick,+}: {+ disabled: boolean;+ label: string;+ onClick: () => void;+}) {+ return (+ <Tooltip content={label}>+ <button+ data-testid="launch-open-studio-button"+ disabled={disabled}+ className={`${hudIconBtnClasses} ${disabled ? "opacity-30 cursor-not-allowed pointer-events-none" : ""}`}+ onClick={onClick}+ >+ <OpenInEditorIcon />+ </button>+ </Tooltip>+ );+});++export const HudNotesButton = memo(function HudNotesButton({+ disabled,+ label,+ onClick,+}: {+ disabled: boolean;+ label: string;+ onClick: () => void;+}) {+ return (+ <Tooltip content={label}>+ <button+ type="button"+ aria-label={label}+ disabled={disabled}+ className={`${hudIconBtnClasses} ${disabled ? "opacity-30 cursor-not-allowed pointer-events-none" : ""}`}+ onClick={onClick}+ >+ <NotepadText size={ICON_SIZE} />+ </button>+ </Tooltip>+ );+});++export const HudRecordingControls = memo(function HudRecordingControls({+ vertical,+ paused,+ saving,+ canPause,+ pauseLabel,+ restartLabel,+ cancelLabel,+ onTogglePause,+ onRestart,+ onCancel,+}: {+ vertical: boolean;+ paused: boolean;+ saving: boolean;+ canPause: boolean;+ pauseLabel: string;+ restartLabel: string;+ cancelLabel: string;+ onTogglePause: () => void;+ onRestart: () => void;+ onCancel: () => void;+}) {+ return (+ <div+ className={`flex items-center gap-0.5 ${vertical ? "flex-col" : ""} ${styles.electronNoDrag}`}+ >+ {canPause && (+ <Tooltip content={pauseLabel}>+ <button className={hudAuxIconBtnClasses} onClick={onTogglePause} disabled={saving}>+ {getIcon(paused ? "resume" : "pause", paused ? "text-amber-400" : "text-white/60")}+ </button>+ </Tooltip>+ )}+ <Tooltip content={restartLabel}>+ <button className={hudAuxIconBtnClasses} onClick={onRestart} disabled={saving}>+ {getIcon("restart", "text-white/60")}+ </button>+ </Tooltip>+ <Tooltip content={cancelLabel}>+ <button className={hudAuxIconBtnClasses} onClick={onCancel} disabled={saving}>+ {getIcon("cancel", "text-white/60")}+ </button>+ </Tooltip>+ </div>+ );+});++export const HudLanguageButton = memo(function HudLanguageButton({+ vertical,+ code,+ label,+ disabled,+ expanded,+ onClick,+ buttonRef,+}: {+ vertical: boolean;+ code: string;+ label: string;+ disabled: boolean;+ expanded: boolean;+ onClick: () => void;+ buttonRef: React.MutableRefObject<HTMLButtonElement | null>;+}) {+ return (+ <button+ ref={buttonRef}+ type="button"+ aria-label={label}+ aria-expanded={expanded}+ aria-haspopup="menu"+ disabled={disabled}+ onClick={onClick}+ title={label}+ className={`flex h-[34px] items-center rounded-[10px] border-0 bg-transparent text-[#828c99] transition-all duration-150 hover:bg-[#1a1e25] hover:text-[#e9edf3] ${+ vertical ? "w-[34px] justify-center px-0" : "gap-1.5 px-2.5"+ } ${styles.electronNoDrag} ${disabled ? "opacity-30 cursor-not-allowed pointer-events-none" : ""}`}+ >+ <Languages size={16} className="shrink-0" />+ <span+ className={`${vertical ? "sr-only" : ""} font-mono text-[11px] font-semibold tracking-wide text-[#f5f7fa]`}+ >+ {code}+ </span>+ </button>+ );+});++export const HudWindowControls = memo(function HudWindowControls({+ vertical,+ disabled,+ hideLabel,+ closeLabel,+ onHide,+ onClose,+}: {+ vertical: boolean;+ disabled: boolean;+ hideLabel: string;+ closeLabel: string;+ onHide: () => void;+ onClose: () => void;+}) {+ return (+ <div className={`flex items-center gap-[5px] ${vertical ? "flex-col" : ""}`}>+ <button className={windowBtnClasses} title={hideLabel} onClick={onHide} disabled={disabled}>+ {getIcon("minimize")}+ </button>+ <button className={closeBtnClasses} title={closeLabel} onClick={onClose} disabled={disabled}>+ {getIcon("close")}+ </button>+ </div>+ );+});++export const HudLanguageMenu = memo(function HudLanguageMenu({+ locales,+ activeLocale,+ getName,+ onSelect,+ panelRef,+ onEnsureInteractive,+}: {+ locales: readonly string[];+ activeLocale: string;+ getName: (locale: string) => string;+ onSelect: (locale: string) => void;+ panelRef: (el: HTMLDivElement | null) => void;+ onEnsureInteractive: () => void;+}) {+ return (+ <div+ ref={panelRef}+ data-hud-interactive="true"+ data-testid="hud-language-menu"+ role="menu"+ className={`${styles.hudPopover} ${styles.hudPopoverScroll} ${styles.hudScrollbar} animate-mic-panel-in ${styles.electronNoDrag}`}+ onPointerDown={(event) => event.stopPropagation()}+ onPointerEnter={onEnsureInteractive}+ onWheel={(event) => {+ onEnsureInteractive();+ event.stopPropagation();+ }}+ >+ {locales.map((loc) => (+ <button+ key={loc}+ type="button"+ role="menuitemradio"+ aria-checked={loc === activeLocale}+ onClick={() => onSelect(loc)}+ className={`${styles.languageMenuItem} ${loc === activeLocale ? styles.languageMenuItemActive : ""}`}+ >+ <span className="truncate">{getName(loc)}</span>+ {loc === activeLocale ? <Check size={11} className="text-white/85" /> : null}+ </button>+ ))}+ </div>+ );+});++export const HudNotice = memo(function HudNotice({+ title,+ description,+ dismissLabel,+ confirmLabel,+ onDismiss,+ onConfirm,+}: {+ title: string;+ description: string;+ dismissLabel: string;+ confirmLabel: string;+ onDismiss: () => void;+ onConfirm: () => void;+}) {+ return (+ <div+ data-hud-interactive="true"+ className={`w-full rounded-xl border border-white/15 bg-[rgba(20,20,28,0.95)] p-3 shadow-2xl backdrop-blur-xl text-white animate-in fade-in-0 zoom-in-95 duration-200 ${styles.electronNoDrag}`}+ >+ <div className="text-[13px] font-semibold text-white">{title}</div>+ <div className="mt-1 text-[11px] leading-relaxed text-white/75">{description}</div>+ <div className="mt-3 flex items-center justify-end gap-2">+ <Button+ type="button"+ variant="ghost"+ size="sm"+ onClick={onDismiss}+ className="h-7 text-xs text-white/80 hover:bg-white/10 hover:text-white"+ >+ {dismissLabel}+ </Button>+ <Button+ type="button"+ size="sm"+ onClick={onConfirm}+ className="h-7 text-xs bg-white text-[#10121b] hover:bg-white/90"+ >+ {confirmLabel}+ </Button>+ </div>+ </div>+ );+});diff --git a/src/components/launch/HudDeviceSettings.tsx b/src/components/launch/HudDeviceSettings.tsxnew file mode 100644index 000000000..dcd44fb86--- /dev/null+++ b/src/components/launch/HudDeviceSettings.tsx@@ -0,0 +1,209 @@+import { Check, X } from "lucide-react";+import { memo, useEffect, useRef } from "react";+import { useAudioLevelMeter } from "../../hooks/useAudioLevelMeter";+import type { CameraDevice } from "../../hooks/useCameraDevices";+import { useCameraPreviewStream } from "../../hooks/useCameraPreviewStream";+import type { MicrophoneDevice } from "../../hooks/useMicrophoneDevices";+import styles from "./LaunchWindow.module.css";++const LEVEL_SEGMENTS = 12;+const LEVEL_SEGMENT_KEYS = Array.from({ length: LEVEL_SEGMENTS }, (_, i) => `segment-${i}`);++export interface HudDeviceSettingsLabels {+ title: string;+ done: string;+ microphone: string;+ camera: string;+ micLevel: string;+ micHint: string;+ noMicrophones: string;+ searching: string;+ noCameras: string;+ cameraUnavailable: string;+ preview: string;+ previewUnavailable: string;+}++/** Segmented input-level bar, driven by the live analyser. */+const LevelMeter = memo(function LevelMeter({ level }: { level: number }) {+ const lit = Math.round((Math.min(100, Math.max(0, level)) / 100) * LEVEL_SEGMENTS);+ return (+ <div className={styles.levelMeter} role="meter" aria-valuenow={Math.round(level)}>+ {LEVEL_SEGMENT_KEYS.map((key, index) => (+ <span+ key={key}+ className={`${styles.levelSegment} ${index < lit ? styles.levelSegmentOn : ""}`}+ />+ ))}+ </div>+ );+});++function CameraPreview({+ stream,+ error,+ unavailableLabel,+}: {+ stream: MediaStream | null;+ error: string | null;+ unavailableLabel: string;+}) {+ const videoRef = useRef<HTMLVideoElement | null>(null);++ useEffect(() => {+ const video = videoRef.current;+ if (!video) return;+ video.srcObject = stream;+ return () => {+ video.srcObject = null;+ };+ }, [stream]);++ if (error || !stream) {+ return (+ <div className={styles.cameraPreview}>+ <span className={styles.cameraPreviewFallback}>{error ? unavailableLabel : ""}</span>+ </div>+ );+ }++ // No <track>: this is a live self-view with no audio and nothing to caption.+ return <video ref={videoRef} className={styles.cameraPreview} autoPlay muted playsInline />;+}++/**+ * Device selection *and* verification in one place.+ *+ * Picking a device here never turns anything on: the HUD's mic and camera+ * buttons are plain on/off toggles that use whatever is selected here, which is+ * what separates "choose my hardware" from "start capturing it". While this+ * panel is open it holds its own preview stream and analyser so the user can+ * confirm the device actually works before recording — those are torn down with+ * the panel and are entirely separate from the recorder's capture streams.+ */+export const HudDeviceSettings = memo(function HudDeviceSettings({+ micDevices,+ cameraDevices,+ activeMicId,+ activeCameraId,+ cameraLoading,+ cameraError,+ labels,+ onSelectMic,+ onSelectCamera,+ onClose,+ panelRef,+}: {+ micDevices: MicrophoneDevice[];+ cameraDevices: CameraDevice[];+ activeMicId: string | undefined;+ activeCameraId: string | undefined;+ cameraLoading: boolean;+ cameraError: string | null;+ labels: HudDeviceSettingsLabels;+ onSelectMic: (device: MicrophoneDevice) => void;+ onSelectCamera: (device: CameraDevice) => void;+ onClose: () => void;+ panelRef: (el: HTMLDivElement | null) => void;+}) {+ // Only reach for hardware that is actually there — otherwise opening the panel+ // on a machine with no webcam fires a getUserMedia that can only fail.+ const hasCamera = cameraDevices.length > 0 && !cameraError && !cameraLoading;+ const { level } = useAudioLevelMeter({+ enabled: micDevices.length > 0,+ deviceId: activeMicId,+ });+ const { stream, error: previewError } = useCameraPreviewStream({+ enabled: hasCamera,+ deviceId: activeCameraId,+ });++ return (+ <div+ ref={panelRef}+ data-hud-interactive="true"+ data-testid="hud-device-settings"+ role="dialog"+ aria-label={labels.title}+ className={`${styles.hudModal} ${styles.hudScrollbar} animate-mic-panel-in ${styles.electronNoDrag}`}+ >+ <div className={styles.hudModalHeader}>+ <span className={styles.hudModalTitle}>{labels.title}</span>+ <button+ type="button"+ aria-label={labels.done}+ title={labels.done}+ onClick={onClose}+ className={styles.hudModalClose}+ >+ <X size={14} />+ </button>+ </div>++ <div className={styles.hudMenuSectionLabel}>{labels.microphone}</div>+ {micDevices.length === 0 ? (+ <div className={styles.hudModalEmpty}>{labels.noMicrophones}</div>+ ) : (+ micDevices.map((device) => {+ const isActive = device.deviceId === activeMicId;+ return (+ <button+ key={device.deviceId}+ type="button"+ role="menuitemradio"+ aria-checked={isActive}+ onClick={() => onSelectMic(device)}+ className={`${styles.languageMenuItem} ${isActive ? styles.languageMenuItemActive : ""}`}+ >+ <span className="truncate">{device.label}</span>+ {isActive ? <Check size={11} className="text-white/85" /> : null}+ </button>+ );+ })+ )}+ <div className={styles.hudModalMeterRow}>+ <span className={styles.hudModalMeterLabel}>{labels.micLevel}</span>+ <LevelMeter level={level} />+ </div>+ <div className={styles.hudModalHint}>{labels.micHint}</div>++ <div className={styles.hudMenuSectionLabel}>{labels.camera}</div>+ {cameraLoading ? (+ <div className={styles.hudModalEmpty}>{labels.searching}</div>+ ) : cameraError ? (+ <div className={styles.hudModalEmpty}>{labels.cameraUnavailable}</div>+ ) : cameraDevices.length === 0 ? (+ <div className={styles.hudModalEmpty}>{labels.noCameras}</div>+ ) : (+ cameraDevices.map((device) => {+ const isActive = device.deviceId === activeCameraId;+ return (+ <button+ key={device.deviceId}+ type="button"+ role="menuitemradio"+ aria-checked={isActive}+ onClick={() => onSelectCamera(device)}+ className={`${styles.languageMenuItem} ${isActive ? styles.languageMenuItemActive : ""}`}+ >+ <span className="truncate">{device.label}</span>+ {isActive ? <Check size={11} className="text-white/85" /> : null}+ </button>+ );+ })+ )}+ {hasCamera ? (+ <>+ <div className={styles.hudModalMeterRow}>+ <span className={styles.hudModalMeterLabel}>{labels.preview}</span>+ </div>+ <CameraPreview+ stream={stream}+ error={previewError}+ unavailableLabel={labels.previewUnavailable}+ />+ </>+ ) : null}+ </div>+ );+});diff --git a/src/components/launch/HudIcons.tsx b/src/components/launch/HudIcons.tsxnew file mode 100644index 000000000..0ec73bdff--- /dev/null+++ b/src/components/launch/HudIcons.tsx@@ -0,0 +1,163 @@+import { Loader2 } from "lucide-react";+import { BsPauseCircle, BsPlayCircle } from "react-icons/bs";+import { FaFolderOpen } from "react-icons/fa6";+import { FiMinus, FiX } from "react-icons/fi";+import { MdCancel, MdRestartAlt, MdVideoFile } from "react-icons/md";+import { RxDragHandleDots2 } from "react-icons/rx";++export const ICON_SIZE = 20;++const ICON_CONFIG = {+ drag: { icon: RxDragHandleDots2, size: ICON_SIZE },+ pause: { icon: BsPauseCircle, size: ICON_SIZE },+ resume: { icon: BsPlayCircle, size: ICON_SIZE },+ restart: { icon: MdRestartAlt, size: ICON_SIZE },+ cancel: { icon: MdCancel, size: ICON_SIZE },+ videoFile: { icon: MdVideoFile, size: ICON_SIZE },+ folder: { icon: FaFolderOpen, size: ICON_SIZE },+ minimize: { icon: FiMinus, size: ICON_SIZE },+ close: { icon: FiX, size: ICON_SIZE },+ spinner: { icon: Loader2, size: ICON_SIZE },+} as const;++export type IconName = keyof typeof ICON_CONFIG;++/** Renders the configured icon for a HUD control. */+export function getIcon(name: IconName, className?: string) {+ const { icon: Icon, size } = ICON_CONFIG[name];+ return <Icon size={size} className={className} />;+}++// Custom glyphs matching the Claude Design "OpenScreen Recording Widget"+// spec exactly (source/audio/mic/camera/cursor/record) — these are the+// controls most visible in the collapsed toolbar, so the design's own paths+// are used verbatim rather than the closest lucide/react-icons stand-in.+const HUD_SVG_PROPS = {+ width: ICON_SIZE,+ height: ICON_SIZE,+ viewBox: "0 0 24 24",+ fill: "none",+ stroke: "currentColor",+ strokeWidth: 1.6,+ strokeLinecap: "round",+ strokeLinejoin: "round",+} as const;++export function OrientationIcon({+ vertical,+ className,+}: {+ vertical: boolean;+ className?: string;+}) {+ return (+ <svg {...HUD_SVG_PROPS} className={className} aria-hidden="true">+ {vertical ? (+ <>+ <rect x="3" y="7" width="18" height="10" rx="3" />+ <path d="M12 7v10" />+ </>+ ) : (+ <>+ <rect x="7" y="3" width="10" height="18" rx="3" />+ <path d="M7 12h10" />+ </>+ )}+ </svg>+ );+}++export function SourceIcon({ className }: { className?: string }) {+ return (+ <svg {...HUD_SVG_PROPS} className={className} aria-hidden="true">+ <rect x="2.5" y="4.5" width="19" height="13" rx="2.2" />+ <path d="M8.5 21h7M12 17.5v3.3" />+ </svg>+ );+}++export function VolumeIcon({ muted, className }: { muted: boolean; className?: string }) {+ return (+ <svg {...HUD_SVG_PROPS} className={className} aria-hidden="true">+ <path+ d="M10.2 5.6 5.6 9H3a1 1 0 0 0-1 1v4a1 1 0 0 0 1 1h2.6l4.6 3.4a.6.6 0 0 0 1-.48V6.08a.6.6 0 0 0-1-.48Z"+ fill="currentColor"+ stroke="none"+ />+ {muted ? (+ <path d="M15.2 9.3 19.4 14.7M19.4 9.3l-4.2 5.4" />+ ) : (+ <>+ <path d="M15.5 8.5a5 5 0 0 1 0 7" />+ <path d="M18 6a9 9 0 0 1 0 12" />+ </>+ )}+ </svg>+ );+}++export function MicIcon({ muted, className }: { muted: boolean; className?: string }) {+ return (+ <svg {...HUD_SVG_PROPS} className={className} aria-hidden="true">+ <rect x="9" y="3" width="6" height="11" rx="3" />+ <path d="M18.5 11a6.5 6.5 0 0 1-13 0" />+ <path d="M12 17.5v3" />+ {muted ? <path d="M4 4l16 16" /> : null}+ </svg>+ );+}++export function CameraIcon({ off, className }: { off: boolean; className?: string }) {+ return (+ <svg {...HUD_SVG_PROPS} className={className} aria-hidden="true">+ <rect x="3" y="6.5" width="13" height="11" rx="2.4" />+ <path d="M16 10.3 21 7v10l-5-3.3" />+ {off ? <path d="M4 4l16 16" /> : null}+ </svg>+ );+}++export function CursorIcon({ className }: { className?: string }) {+ return (+ <svg+ width={ICON_SIZE}+ height={ICON_SIZE}+ viewBox="0 0 24 24"+ fill="currentColor"+ stroke="none"+ className={className}+ aria-hidden="true"+ >+ <path d="M6.7 3.3 6.7 18.3 10.3 14.8 12.7 20.7 15.1 19.7 12.7 13.8 17.3 13.8Z" />+ </svg>+ );+}++export function RecordGlyph({ recording, className }: { recording: boolean; className?: string }) {+ return (+ <svg+ width={ICON_SIZE}+ height={ICON_SIZE}+ viewBox="0 0 24 24"+ className={className}+ aria-hidden="true"+ >+ {recording ? (+ <rect x="6.5" y="6.5" width="11" height="11" rx="2.5" fill="currentColor" />+ ) : (+ <circle cx="12" cy="12" r="7.5" fill="currentColor" />+ )}+ </svg>+ );+}++export function OpenInEditorIcon({ className }: { className?: string }) {+ return (+ <svg {...HUD_SVG_PROPS} className={className} aria-hidden="true">+ <path d="M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z" />+ <path d="m6.2 5.3 3.1 5.4" />+ <path d="m12.4 3.4 3.1 5.4" />+ <path d="M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z" />+ </svg>+ );+}diff --git a/src/components/launch/LaunchWindow.module.css b/src/components/launch/LaunchWindow.module.cssindex 6fc40ac5f..6756e3764 100644--- a/src/components/launch/LaunchWindow.module.css+++ b/src/components/launch/LaunchWindow.module.css@@ -1,113 +1,314 @@-/* Electron-specific: no Tailwind equivalent for -webkit-app-region */-.electronDrag {- -webkit-app-region: drag;-}--.electronNoDrag {- -webkit-app-region: no-drag;-}--.languageMenuScroll {- max-height: 20rem;- overflow-y: auto;- overflow-x: hidden;- overscroll-behavior: contain;- touch-action: pan-y;- -webkit-overflow-scrolling: touch;-}--.languageMenuScroll::-webkit-scrollbar {- width: 8px;-}--.languageMenuScroll::-webkit-scrollbar-track {- background: rgba(255, 255, 255, 0.04);- border-radius: 999px;-}--.languageMenuScroll::-webkit-scrollbar-thumb {- background: linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.2));- border-radius: 999px;- border: 1px solid rgba(255, 255, 255, 0.15);-}--.languageMenuScroll::-webkit-scrollbar-thumb:hover {- background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.3));-}--.languageMenuContainer {- position: relative;- z-index: 20;-}--/* Matches the mic/camera device-picker popovers' visual language (see the- activeDeviceMenu panel in LaunchWindow.tsx) so every HUD popover reads as- one coherent design. Anchored with `bottom` (set inline) instead of `top`- so it opens upward, above the widget, sized to its own content. */-.languageMenuPanel {- position: fixed;- right: 0;- width: 220px;- padding: 6px;- border-radius: 15px;- border: 1px solid rgba(255, 255, 255, 0.1);- background: #1a1e25;- box-shadow: 0 20px 44px -14px rgba(0, 0, 0, 0.6), 0 4px 12px rgba(0, 0, 0, 0.4);- pointer-events: auto;- box-sizing: border-box;-}--.languageMenuItem {- width: 100%;- display: flex;- align-items: center;- justify-content: space-between;- padding: 0.425rem 0.5rem;- border-radius: 0.45rem;- font-size: 11px;- color: rgba(255, 255, 255, 0.72);- background: transparent;- border: 0;- cursor: pointer;- transition: background-color 120ms ease, color 120ms ease;-}--.languageMenuItem:hover,-.languageMenuItem:focus-visible {- background: rgba(255, 255, 255, 0.075);- color: #ffffff;- outline: none;-}--.languageMenuItemActive {- background: rgba(52, 178, 123, 0.14);- color: #ffffff;-}--/* Device-picker popovers (microphone / camera) — reuse the language menu's- panel/item/checkmark shell (same floating-menu shape), just add the- section-label piece the language menu doesn't need since it has no- device grouping. These only ever open while the device is off, so there's- no on/off header toggle — the device list is the whole popover body. */-.hudMenuSectionLabel {- padding: 6px 10px 4px;- font-family: var(--font-mono, ui-monospace, monospace);- font-size: 9.5px;- letter-spacing: 0.08em;- text-transform: uppercase;- color: rgba(255, 255, 255, 0.4);-}--/* Thin separators between HUD toolbar control groups. */-.hudDivider {- flex-shrink: 0;- background: rgba(255, 255, 255, 0.1);-}-.hudDividerHorizontal {- width: 1px;- height: 22px;-}-.hudDividerVertical {- width: 22px;- height: 1px;-}+/* Electron-specific: no Tailwind equivalent for -webkit-app-region */+.electronDrag {+ -webkit-app-region: drag;+}++.electronNoDrag {+ -webkit-app-region: no-drag;+}++/*+ * The HUD is one bottom-anchored, upward-growing stack: the bar sits at the+ * bottom, popovers and notices float above it in DOM order. Everything that+ * floats is a sibling laid out by flexbox rather than a `fixed` element placed+ * from a measured getBoundingClientRect(), which is what removes the whole+ * measure -> setState -> re-measure round trip the popovers used to need.+ *+ * Nothing in here may be sized in vh/vw: a viewport-relative size makes the+ * element's box depend on the overlay window's size, and since these boxes feed+ * the window-sizing measurement that closes a feedback loop (see hudGeometry.ts).+ * Screen-derived caps arrive as the --hud-* custom properties instead.+ */+.hudAnchor {+ position: fixed;+ bottom: var(--hud-bar-bottom, 20px);+ left: 50%;+ transform: translateX(-50%);+ display: flex;+ flex-direction: column-reverse;+ align-items: center;+ gap: var(--hud-popover-gap, 8px);+ /* The stack containers are only layout boxes; the gaps between and around+ their children must stay click-through, or the overlay would swallow clicks+ meant for whatever is behind it. Only the painted surfaces opt back in. */+ pointer-events: none;+}++.hudAbove {+ display: flex;+ flex-direction: column-reverse;+ align-items: center;+ gap: var(--hud-stack-gap, 10px);+ pointer-events: none;+}++.hudBar {+ pointer-events: auto;+ display: flex;+ border-radius: 17px;+ border: 1px solid #242932;+ background: #14171c;+ box-shadow: 0 2px 6px -2px rgba(0, 0, 0, 0.35);+ backdrop-filter: blur(24px) saturate(140%);+}++.hudBarHorizontal {+ align-items: center;+ gap: 5px;+ padding: 7px 9px;+}++.hudBarVertical {+ flex-direction: column;+ align-items: center;+ gap: 5px;+ padding: 9px 7px;+ /* Screen-derived, set once at mount — never the window's own height. */+ max-height: var(--hud-bar-max-h, 900px);+ overflow-y: auto;+ overflow-x: hidden;+}++/* Shared shell for every floating HUD menu (language list, device pickers), so+ they all read as one design and all reserve the same space in the window. */+.hudPopover {+ pointer-events: auto;+ width: 220px;+ box-sizing: border-box;+ padding: 6px;+ border-radius: 15px;+ border: 1px solid rgba(255, 255, 255, 0.1);+ background: #1a1e25;+ box-shadow: 0 20px 44px -14px rgba(0, 0, 0, 0.6), 0 4px 12px rgba(0, 0, 0, 0.4);+}++.hudPopoverScroll {+ /* Capped, and the cap is reserved in the overlay window up front, so a list+ growing or shrinking never resizes the native window. */+ max-height: var(--hud-popover-max-h, 320px);+ overflow-y: auto;+ overflow-x: hidden;+ overscroll-behavior: contain;+ touch-action: pan-y;+}++/* Scrollbar skin only — kept separate from the height caps so a surface can pick+ up the look without also inheriting the popover's (smaller) max-height. */+.hudScrollbar::-webkit-scrollbar {+ width: 8px;+}++.hudScrollbar::-webkit-scrollbar-track {+ background: rgba(255, 255, 255, 0.04);+ border-radius: 999px;+}++.hudScrollbar::-webkit-scrollbar-thumb {+ background: linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.2));+ border-radius: 999px;+ border: 1px solid rgba(255, 255, 255, 0.15);+}++.hudScrollbar::-webkit-scrollbar-thumb:hover {+ background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.3));+}++/* The mic and camera toggles plus the gear that configures them read as one+ unit: tighter spacing than the bar's 5px, inside a hairline outline.+ Deliberately an outline rather than the tinted pill the design rules out —+ a fill that reads at all on #14171c lands brighter than the buttons' own+ hover colour, which would invert the hover affordance. */+.hudControlGroup {+ display: flex;+ align-items: center;+ gap: 2px;+ margin: 0 1px;+ padding: 2px;+ border-radius: 12px;+ box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);+}++.hudControlGroupVertical {+ flex-direction: column;+ margin: 1px 0;+}++/* Device settings. Same shell as the popovers, and deliberately the same width+ as the notice column (HUD_STACK_WIDTH) so opening it only ever changes the+ overlay window's height, never its width. */+.hudModal {+ pointer-events: auto;+ width: 360px;+ /* Its own cap, larger than a popover's — but the window reserves this room+ whether the panel is open or not, so opening it never resizes anything. */+ max-height: var(--hud-modal-max-h, 470px);+ overflow-y: auto;+ overflow-x: hidden;+ overscroll-behavior: contain;+ box-sizing: border-box;+ padding: 6px;+ border-radius: 15px;+ border: 1px solid rgba(255, 255, 255, 0.1);+ background: #1a1e25;+ box-shadow: 0 20px 44px -14px rgba(0, 0, 0, 0.6), 0 4px 12px rgba(0, 0, 0, 0.4);+}++.hudModalHeader {+ display: flex;+ align-items: center;+ justify-content: space-between;+ padding: 4px 4px 6px 10px;+}++.hudModalTitle {+ font-size: 12px;+ font-weight: 600;+ color: #f5f7fa;+}++.hudModalClose {+ display: flex;+ height: 24px;+ width: 24px;+ align-items: center;+ justify-content: center;+ border: 0;+ border-radius: 8px;+ background: transparent;+ color: rgba(255, 255, 255, 0.55);+ cursor: pointer;+ transition: background-color 120ms ease, color 120ms ease;+}++.hudModalClose:hover {+ background: rgba(255, 255, 255, 0.08);+ color: #ffffff;+}++.hudModalEmpty {+ padding: 8px 10px;+ font-size: 11px;+ font-style: italic;+ color: rgba(255, 255, 255, 0.4);+}++.hudModalMeterRow {+ display: flex;+ align-items: center;+ gap: 8px;+ padding: 8px 10px 2px;+}++.hudModalMeterLabel {+ font-size: 10px;+ color: rgba(255, 255, 255, 0.45);+ white-space: nowrap;+}++.hudModalHint {+ padding: 0 10px 6px;+ font-size: 10px;+ color: rgba(255, 255, 255, 0.35);+}++.levelMeter {+ display: flex;+ flex: 1;+ align-items: center;+ gap: 2px;+ height: 10px;+}++.levelSegment {+ flex: 1;+ height: 100%;+ border-radius: 1px;+ background: rgba(255, 255, 255, 0.1);+ transition: background-color 60ms linear;+}++.levelSegmentOn {+ background: #10b981;+}++.cameraPreview {+ display: flex;+ width: 100%;+ aspect-ratio: 16 / 9;+ margin-top: 6px;+ align-items: center;+ justify-content: center;+ border-radius: 10px;+ background: #0d1014;+ object-fit: cover;+ /* The preview is a mirror of the user, so flip it like every other self-view. */+ transform: scaleX(-1);+}++.cameraPreviewFallback {+ font-size: 11px;+ font-style: italic;+ color: rgba(255, 255, 255, 0.4);+ transform: scaleX(-1);+}++/* Fixed width (not `100vw - 1rem`) for the same no-viewport-dependency reason. */+.hudNoticeColumn {+ pointer-events: auto;+ display: flex;+ width: 360px;+ flex-direction: column;+ gap: 8px;+}++.languageMenuItem {+ width: 100%;+ display: flex;+ align-items: center;+ justify-content: space-between;+ padding: 0.425rem 0.5rem;+ border-radius: 0.45rem;+ font-size: 11px;+ color: rgba(255, 255, 255, 0.72);+ background: transparent;+ border: 0;+ cursor: pointer;+ transition: background-color 120ms ease, color 120ms ease;+}++.languageMenuItem:hover,+.languageMenuItem:focus-visible {+ background: rgba(255, 255, 255, 0.075);+ color: #ffffff;+ outline: none;+}++.languageMenuItemActive {+ background: rgba(52, 178, 123, 0.14);+ color: #ffffff;+}++/* Device-picker popovers (microphone / camera) reuse the language menu's+ panel/item/checkmark shell; this is the one extra piece they need. */+.hudMenuSectionLabel {+ padding: 6px 10px 4px;+ font-family: var(--font-mono, ui-monospace, monospace);+ font-size: 9.5px;+ letter-spacing: 0.08em;+ text-transform: uppercase;+ color: rgba(255, 255, 255, 0.4);+}++/* Thin separators between HUD toolbar control groups. */+.hudDivider {+ flex-shrink: 0;+ background: rgba(255, 255, 255, 0.1);+}+.hudDividerHorizontal {+ width: 1px;+ height: 22px;+}+.hudDividerVertical {+ width: 22px;+ height: 1px;+}diff --git a/src/components/launch/LaunchWindow.test.tsx b/src/components/launch/LaunchWindow.test.tsxindex 0b745c80c..ce4f7e93e 100644--- a/src/components/launch/LaunchWindow.test.tsx+++ b/src/components/launch/LaunchWindow.test.tsx@@ -1,7 +1,8 @@import "@testing-library/jest-dom";-import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";+import { act, cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { TooltipProvider } from "../ui/tooltip";+import { HUD_BAR_BOTTOM, HUD_POPOVER_GAP, HUD_POPOVER_MAX_HEIGHT } from "./hudGeometry";import { LaunchWindow } from "./LaunchWindow";type SelectedSourceChangedListener = Parameters<@@ -67,9 +68,13 @@ vi.mock("../../hooks/useScreenRecorder", () => ({useScreenRecorder: () => recorderState.value,}));+const micDevicesState = vi.hoisted(() => ({+ value: [] as Array<{ deviceId: string; label: string; groupId: string }>,+}));+vi.mock("../../hooks/useMicrophoneDevices", () => ({useMicrophoneDevices: () => ({- devices: [],+ devices: micDevicesState.value,selectedDeviceId: "default",setSelectedDeviceId: vi.fn(),}),@@ -89,6 +94,10 @@ vi.mock("../../hooks/useAudioLevelMeter", () => ({useAudioLevelMeter: () => ({ level: 0 }),}));+vi.mock("../../hooks/useCameraPreviewStream", () => ({+ useCameraPreviewStream: () => ({ stream: null, error: null }),+}));+vi.mock("../../lib/requestCameraAccess", () => ({requestCameraAccess: vi.fn(async () => ({ success: true, granted: true, status: "granted" })),}));@@ -136,6 +145,15 @@ vi.mock("@/contexts/I18nContext", () => ({"webcam.searching": "Searching...","webcam.noneFound": "No camera found","webcam.unavailable": "Camera unavailable",+ "deviceSettings.title": "Device settings",+ "deviceSettings.done": "Done",+ "deviceSettings.micLevel": "Input level",+ "deviceSettings.micHint": "Speak to check your microphone",+ "deviceSettings.noMicrophones": "No microphone found",+ "deviceSettings.preview": "Preview",+ "deviceSettings.previewUnavailable": "Preview unavailable",+ "audio.inputDevice": "Input device",+ "webcam.cameraDevice": "Camera device","cursor.useEditableCursor": "Use editable cursor","cursor.useSystemCursor": "Use system cursor","tooltips.openStudio": "Open Studio",@@ -178,9 +196,12 @@ function stubElectronAPI(getSelectedSource: Window["electronAPI"]["getSelectedSogetPlatform: vi.fn(async () => "darwin"),setHudOverlaySize: vi.fn(),setHudOverlayIgnoreMouseEvents: vi.fn(),- moveHudOverlayBy: vi.fn(),+ beginHudOverlayDrag: vi.fn(),+ dragHudOverlayTo: vi.fn(),+ endHudOverlayDrag: vi.fn(),hudOverlayHide: vi.fn(),hudOverlayClose: vi.fn(),+ openNotes: vi.fn(),switchToEditor: vi.fn(async () => undefined),onSelectedSourceChanged: vi.fn((callback) => {selectedSourceChangedListeners.push(callback);@@ -232,6 +253,13 @@ function resetLaunchMocks() {recorderState.value.toggleRecording.mockClear();recorderState.value.softwareEncoderFallbackNoticeVisible = false;recorderState.value.dismissSoftwareEncoderFallbackNotice.mockClear();+ recorderState.value.recording = false;+ recorderState.value.microphoneEnabled = false;+ recorderState.value.setMicrophoneEnabled.mockClear();+ recorderState.value.setMicrophoneDeviceId.mockClear();+ recorderState.value.webcamEnabled = false;+ recorderState.value.setWebcamEnabled.mockClear();+ micDevicesState.value = [];selectedSourceChangedListeners = [];sourceSelectorClosedListeners = [];i18nState.value.systemLocaleSuggestion = null;@@ -378,7 +406,39 @@ describe("LaunchWindow record button", () => {});});-describe("LaunchWindow system language prompt", () => {+/** jsdom reports zero layout, so fake a rendered box for the elements we measure. */+function stubBox(element: HTMLElement, width: number, height: number) {+ vi.spyOn(element, "getBoundingClientRect").mockReturnValue({+ top: 0,+ left: 0,+ right: width,+ bottom: height,+ width,+ height,+ x: 0,+ y: 0,+ toJSON: () => ({}),+ });+ Object.defineProperty(element, "scrollWidth", { value: width, configurable: true });+ Object.defineProperty(element, "scrollHeight", { value: height, configurable: true });+}++async function flushResizeObservers() {+ await act(async () => {+ for (const callback of resizeCallbacks) {+ callback([], {} as ResizeObserver);+ }+ });+}++function lastRequestedHudSize(): [number, number] {+ const sizeMock = window.electronAPI.setHudOverlaySize as unknown as {+ mock: { calls: Array<[number, number]> };+ };+ return sizeMock.mock.calls[sizeMock.mock.calls.length - 1];+}++describe("LaunchWindow overlay sizing", () => {beforeEach(() => {platformState.value = "darwin";resetLaunchMocks();@@ -391,72 +451,261 @@ describe("LaunchWindow system language prompt", () => {vi.unstubAllGlobals();});- it("grows the HUD overlay tall enough to fit the prompt so its buttons stay clickable", async () => {+ it("reserves room for a popover before one is ever opened", async () => {+ renderLaunchWindow();++ const bar = (await screen.findByTestId("hud-drag-handle")).closest(+ "[data-tray-layout]",+ ) as HTMLElement;+ stubBox(bar, 400, 56);+ await flushResizeObservers();++ await waitFor(() => {+ expect(window.electronAPI.setHudOverlaySize).toHaveBeenCalled();+ });++ const [, height] = lastRequestedHudSize();+ // The window is already tall enough for a full-height popover, so opening one+ // costs no native resize -- that is what stops the HUD jumping on first open.+ expect(height).toBeGreaterThanOrEqual(+ HUD_BAR_BOTTOM + 56 + HUD_POPOVER_GAP + HUD_POPOVER_MAX_HEIGHT,+ );+ });++ it("reclaims the overlay once the content drops well below what was granted", async () => {+ renderLaunchWindow();++ const bar = (await screen.findByTestId("hud-drag-handle")).closest(+ "[data-tray-layout]",+ ) as HTMLElement;+ // A bogus oversized reading (e.g. an unstyled first paint in dev) must not+ // leave the overlay permanently inflated.+ stubBox(bar, 1400, 700);+ await flushResizeObservers();+ const [inflatedWidth, inflatedHeight] = lastRequestedHudSize();++ stubBox(bar, 400, 56);+ await flushResizeObservers();++ const [width, height] = lastRequestedHudSize();+ expect(width).toBeLessThan(inflatedWidth);+ expect(height).toBeLessThan(inflatedHeight);+ });++ it("does not resize the overlay when a popover opens", async () => {+ renderLaunchWindow();++ const bar = (await screen.findByTestId("hud-drag-handle")).closest(+ "[data-tray-layout]",+ ) as HTMLElement;+ stubBox(bar, 400, 56);+ await flushResizeObservers();++ const sizeMock = window.electronAPI.setHudOverlaySize as unknown as {+ mockClear: () => void;+ };+ sizeMock.mockClear();++ fireEvent.click(screen.getByRole("button", { name: "English" }));+ await screen.findByTestId("hud-language-menu");+ await flushResizeObservers();++ expect(window.electronAPI.setHudOverlaySize).not.toHaveBeenCalled();+ });++ it("does not resize the overlay when the device-settings panel opens", async () => {+ renderLaunchWindow();++ const bar = (await screen.findByTestId("hud-drag-handle")).closest(+ "[data-tray-layout]",+ ) as HTMLElement;+ stubBox(bar, 400, 56);+ await flushResizeObservers();++ const sizeMock = window.electronAPI.setHudOverlaySize as unknown as {+ mockClear: () => void;+ };+ sizeMock.mockClear();++ // The panel is the tallest floating surface, so the window reserves room for+ // it up front. Growing on open would shift the bottom-anchored stack and+ // show up as position judder — the exact thing the reserve model prevents.+ fireEvent.click(screen.getByTestId("launch-device-settings-button"));+ await screen.findByTestId("hud-device-settings");+ await flushResizeObservers();++ expect(window.electronAPI.setHudOverlaySize).not.toHaveBeenCalled();++ fireEvent.click(screen.getByTestId("launch-device-settings-button"));+ await waitFor(() => {+ expect(screen.queryByTestId("hud-device-settings")).not.toBeInTheDocument();+ });+ await flushResizeObservers();++ expect(window.electronAPI.setHudOverlaySize).not.toHaveBeenCalled();+ });++ it("grows the HUD overlay tall enough to fit the system language prompt", async () => {i18nState.value.systemLocaleSuggestion = "zh-CN";renderLaunchWindow();- const prompt = await screen.findByText("Use your system language?");- expect(prompt).toBeInTheDocument();+ expect(await screen.findByText("Use your system language?")).toBeInTheDocument();- // jsdom reports zero layout, so stub both the bar and the prompt to mimic a real HUD.- const viewportHeight = 800;- const barHeight = 56;- const bottomMargin = 20;- const barBottom = viewportHeight - bottomMargin;- const bar = prompt.parentElement?.parentElement?.querySelector(+ const bar = (await screen.findByTestId("hud-drag-handle")).closest("[data-tray-layout]",- ) as HTMLElement | null;- if (bar) {- vi.spyOn(bar, "getBoundingClientRect").mockReturnValue({- top: barBottom - barHeight,- left: 200,- right: 600,- bottom: barBottom,- width: 400,- height: barHeight,- x: 200,- y: barBottom - barHeight,- toJSON: () => ({}),- });- Object.defineProperty(bar, "scrollHeight", { value: barHeight, configurable: true });- Object.defineProperty(bar, "scrollWidth", { value: 400, configurable: true });- }+ ) as HTMLElement;+ stubBox(bar, 400, 56);+ const noticeHeight = 130;+ stubBox(screen.getByTestId("hud-notice-column"), 360, noticeHeight);+ await flushResizeObservers();- const promptBox = { width: 480, height: 130 };- const promptPanel = prompt.parentElement as HTMLElement;- vi.spyOn(promptPanel, "getBoundingClientRect").mockReturnValue({- top: 32,- left: 60,- right: 60 + promptBox.width,- bottom: 32 + promptBox.height,- width: promptBox.width,- height: promptBox.height,- x: 60,- y: 32,- toJSON: () => ({}),+ await waitFor(() => {+ expect(window.electronAPI.setHudOverlaySize).toHaveBeenCalled();});- // Fire any observers attached during render so the spied rect is actually consumed.- await act(async () => {- for (const callback of resizeCallbacks) {- callback([], {} as ResizeObserver);- }+ const [, height] = lastRequestedHudSize();+ // Bar + popover reserve + the notice stacked above it, all of it on screen.+ expect(height).toBeGreaterThanOrEqual(+ HUD_BAR_BOTTOM + 56 + HUD_POPOVER_GAP + HUD_POPOVER_MAX_HEIGHT + noticeHeight,+ );+ });+});++describe("LaunchWindow language menu", () => {+ beforeEach(() => {+ platformState.value = "darwin";+ resetLaunchMocks();+ });++ afterEach(() => {+ cleanup();+ vi.unstubAllGlobals();+ });++ it("sizes the menu from CSS instead of the overlay window's own height", async () => {+ renderLaunchWindow();++ fireEvent.click(await screen.findByRole("button", { name: "English" }));++ const menu = await screen.findByTestId("hud-language-menu");+ // A measured maxHeight/bottom is what used to truncate the list to whatever+ // the (initially tiny) overlay window could fit, then let it grow later when+ // the window grew for an unrelated reason -- e.g. after dragging the HUD.+ expect(menu.style.maxHeight).toBe("");+ expect(menu.style.bottom).toBe("");+ // And it lives inside the HUD stack, not portaled out to the document body.+ expect(menu.closest("[data-tray-layout]")).toBeNull();+ expect(menu.parentElement?.parentElement).toContainElement(+ screen.getByTestId("hud-drag-handle"),+ );+ });+});++describe("LaunchWindow device buttons", () => {+ beforeEach(() => {+ platformState.value = "darwin";+ resetLaunchMocks();+ });++ afterEach(() => {+ cleanup();+ vi.unstubAllGlobals();+ });++ it("turns the microphone on with a single click, without opening anything", async () => {+ renderLaunchWindow();++ fireEvent.click(await screen.findByTestId("launch-microphone-button"));++ expect(recorderState.value.setMicrophoneEnabled).toHaveBeenCalledWith(true);+ expect(screen.queryByTestId("hud-device-settings")).not.toBeInTheDocument();+ });++ it("turns the microphone off with a single click when it is already on", async () => {+ recorderState.value.microphoneEnabled = true;++ renderLaunchWindow();++ fireEvent.click(await screen.findByTestId("launch-microphone-button"));++ expect(recorderState.value.setMicrophoneEnabled).toHaveBeenCalledWith(false);+ });++ it("turns the camera on with a single click, without opening anything", async () => {+ renderLaunchWindow();++ fireEvent.click(await screen.findByTestId("launch-webcam-button"));++ await waitFor(() => {+ expect(recorderState.value.setWebcamEnabled).toHaveBeenCalledWith(true);});+ expect(screen.queryByTestId("hud-device-settings")).not.toBeInTheDocument();+ });++ it("turns the camera off with a single click when it is already on", async () => {+ recorderState.value.webcamEnabled = true;++ renderLaunchWindow();++ fireEvent.click(await screen.findByTestId("launch-webcam-button"));await waitFor(() => {- expect(window.electronAPI.setHudOverlaySize).toHaveBeenCalled();+ expect(recorderState.value.setWebcamEnabled).toHaveBeenCalledWith(false);});+ });+});- const sizeMock = window.electronAPI.setHudOverlaySize as unknown as {- mock: { calls: Array<[number, number]> };- };- const [, height] = sizeMock.mock.calls[sizeMock.mock.calls.length - 1];- // Must at least cover the prompt plus the TOP_MARGIN slack (24).- expect(height).toBeGreaterThanOrEqual(32 + promptBox.height + 24);- // And must be less than the full viewport — guards against regressions that always- // grow to the full viewport because of a missed bottom anchor.- expect(height).toBeLessThan(viewportHeight + 24);+describe("LaunchWindow device settings", () => {+ beforeEach(() => {+ platformState.value = "darwin";+ resetLaunchMocks();+ });++ afterEach(() => {+ cleanup();+ vi.unstubAllGlobals();+ });++ it("opens from the settings button and closes again from its own Done control", async () => {+ renderLaunchWindow();++ fireEvent.click(await screen.findByTestId("launch-device-settings-button"));+ const panel = await screen.findByTestId("hud-device-settings");+ expect(panel).toBeInTheDocument();++ fireEvent.click(within(panel).getByRole("button", { name: "Done" }));++ await waitFor(() => {+ expect(screen.queryByTestId("hud-device-settings")).not.toBeInTheDocument();+ });+ });++ it("selects a device without switching it on", async () => {+ micDevicesState.value = [+ { deviceId: "mic-a", label: "Mic A", groupId: "g" },+ { deviceId: "mic-b", label: "Mic B", groupId: "g" },+ ];++ renderLaunchWindow();++ fireEvent.click(await screen.findByTestId("launch-device-settings-button"));+ const panel = await screen.findByTestId("hud-device-settings");++ fireEvent.click(within(panel).getByRole("menuitemradio", { name: /Mic B/ }));++ // Selection is a preference, not an activation — that separation is the+ // whole reason the picker moved out of the mic button.+ expect(recorderState.value.setMicrophoneDeviceId).toHaveBeenCalledWith("mic-b");+ expect(recorderState.value.setMicrophoneEnabled).not.toHaveBeenCalled();+ });++ it("is unavailable while recording, when devices can't be changed anyway", async () => {+ recorderState.value.recording = true;++ renderLaunchWindow();++ expect(await screen.findByTestId("launch-device-settings-button")).toBeDisabled();});});@@ -478,29 +727,35 @@ describe("LaunchWindow HUD drag", () => {vi.unstubAllGlobals();});+ it("sends the pointer's total travel, not per-frame deltas", async () => {+ renderLaunchWindow();++ const dragHandle = await screen.findByTestId("hud-drag-handle");++ fireEvent.pointerDown(dragHandle, { screenX: 100, screenY: 100 });+ expect(window.electronAPI.beginHudOverlayDrag).toHaveBeenCalledTimes(1);++ fireEvent.pointerMove(dragHandle, { screenX: 140, screenY: 130 });+ fireEvent.pointerMove(dragHandle, { screenX: 150, screenY: 140 });++ // Absolute offsets from the drag origin: the main process applies them to the+ // position it pinned at pointerdown, so nothing accumulates or drifts.+ expect(window.electronAPI.dragHudOverlayTo).toHaveBeenNthCalledWith(1, 40, 30);+ expect(window.electronAPI.dragHudOverlayTo).toHaveBeenNthCalledWith(2, 50, 40);++ fireEvent.pointerUp(dragHandle, { screenX: 150, screenY: 140 });+ expect(window.electronAPI.endHudOverlayDrag).toHaveBeenCalledTimes(1);+ });+it("suppresses ResizeObserver-driven measurement while dragging, and measures once on release", async () => {renderLaunchWindow();const dragHandle = await screen.findByTestId("hud-drag-handle");- // Give the bar a non-zero, changing size so a resize observation would actually- // trigger a `setHudOverlaySize` call if it weren't suppressed during the drag.- const bar = dragHandle.closest("[data-tray-layout]") as HTMLElement | null;- if (bar) {- vi.spyOn(bar, "getBoundingClientRect").mockReturnValue({- top: 700,- left: 200,- right: 600,- bottom: 756,- width: 400,- height: 56,- x: 200,- y: 700,- toJSON: () => ({}),- });- Object.defineProperty(bar, "scrollHeight", { value: 56, configurable: true });- Object.defineProperty(bar, "scrollWidth", { value: 400, configurable: true });- }+ // A bar wide enough that it genuinely outgrows the reserved window width, so a+ // measurement would produce a `setHudOverlaySize` call if it weren't suppressed.+ const bar = dragHandle.closest("[data-tray-layout]") as HTMLElement;+ stubBox(bar, 900, 56);const sizeMock = window.electronAPI.setHudOverlaySize as unknown as {mockClear: () => void;@@ -509,13 +764,7 @@ describe("LaunchWindow HUD drag", () => {fireEvent.pointerDown(dragHandle, { screenX: 100, screenY: 100 });- // Simulate a ResizeObserver firing mid-drag (e.g. transient reflow) -- this must- // NOT reposition/resize the HUD while the user's pointer is still down.- await act(async () => {- for (const callback of resizeCallbacks) {- callback([], {} as ResizeObserver);- }- });+ await flushResizeObservers();expect(window.electronAPI.setHudOverlaySize).not.toHaveBeenCalled();fireEvent.pointerMove(dragHandle, { screenX: 140, screenY: 130 });diff --git a/src/components/launch/LaunchWindow.tsx b/src/components/launch/LaunchWindow.tsxindex 9f8f164c9..722939ac5 100644--- a/src/components/launch/LaunchWindow.tsx+++ b/src/components/launch/LaunchWindow.tsx@@ -1,207 +1,66 @@-import { Check, Languages, Loader2, NotepadText } from "lucide-react";-import { useCallback, useEffect, useRef, useState } from "react";-import { createPortal } from "react-dom";-import { BsPauseCircle, BsPlayCircle } from "react-icons/bs";-import { FaFolderOpen } from "react-icons/fa6";-import { FiMinus, FiX } from "react-icons/fi";-import { MdCancel, MdRestartAlt, MdVideoFile } from "react-icons/md";-import { RxDragHandleDots2 } from "react-icons/rx";+import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";import { useI18n, useScopedT } from "@/contexts/I18nContext";import { getAvailableLocales, getLocaleName } from "@/i18n/loader";import { loadUserPreferences, saveUserPreferences } from "@/lib/userPreferences";import { nativeBridgeClient } from "@/native";-import { useCameraDevices } from "../../hooks/useCameraDevices";-import { useMicrophoneDevices } from "../../hooks/useMicrophoneDevices";+import { type CameraDevice, useCameraDevices } from "../../hooks/useCameraDevices";+import { type MicrophoneDevice, useMicrophoneDevices } from "../../hooks/useMicrophoneDevices";import { useScreenRecorder } from "../../hooks/useScreenRecorder";import { requestCameraAccess } from "../../lib/requestCameraAccess";-import { formatTimePadded } from "../../utils/timeUtils";-import { Button } from "../ui/button";-import { Tooltip } from "../ui/tooltip";+import {+ HudCameraButton,+ HudCursorButton,+ HudDivider,+ HudDragHandle,+ HudLanguageButton,+ HudLanguageMenu,+ HudMicButton,+ HudNotesButton,+ HudNotice,+ HudRecordButton,+ HudRecordingControls,+ HudSettingsButton,+ HudSourceButton,+ HudStudioButton,+ HudSystemAudioButton,+ HudTrayLayoutButton,+ HudWindowControls,+} from "./HudControls";+import { HudDeviceSettings, type HudDeviceSettingsLabels } from "./HudDeviceSettings";+import {+ computeHudBarMaxHeight,+ computeHudModalMaxHeight,+ computeHudPopoverMaxHeight,+ computeHudWindowSize,+ HUD_BAR_BOTTOM,+ HUD_GROWTH_RESERVE,+ HUD_POPOVER_GAP,+ HUD_STACK_GAP,+} from "./hudGeometry";import styles from "./LaunchWindow.module.css";import { openSourceSelectorWithPermissionRetry } from "./openSourceSelectorFlow";-const ICON_SIZE = 20;--// Vertical tray gap (px): bar's `bottom-5` (20px) plus an 8px gap.-const HUD_DEVICE_POPUP_GAP = 28;-// Horizontal layout: mirrors the `bottom-[68px]` class on the popup element.-const HUD_DEVICE_POPUP_HORIZONTAL_BOTTOM = 68;-// Cap on the language list's own height so it doesn't stretch to fill the whole-// screen above the widget -- it should size to its content, like the other popovers.-const LANGUAGE_MENU_MAX_HEIGHT = 320;--const ICON_CONFIG = {- drag: { icon: RxDragHandleDots2, size: ICON_SIZE },- pause: { icon: BsPauseCircle, size: ICON_SIZE },- resume: { icon: BsPlayCircle, size: ICON_SIZE },- restart: { icon: MdRestartAlt, size: ICON_SIZE },- cancel: { icon: MdCancel, size: ICON_SIZE },- videoFile: { icon: MdVideoFile, size: ICON_SIZE },- folder: { icon: FaFolderOpen, size: ICON_SIZE },- minimize: { icon: FiMinus, size: ICON_SIZE },- close: { icon: FiX, size: ICON_SIZE },- spinner: { icon: Loader2, size: ICON_SIZE },-} as const;--type IconName = keyof typeof ICON_CONFIG;--/** Renders the configured icon for a HUD control. */-function getIcon(name: IconName, className?: string) {- const { icon: Icon, size } = ICON_CONFIG[name];- return <Icon size={size} className={className} />;+// Locale list is computed once at module load; keeping the reference stable lets+// the language menu sit behind a memo boundary.+const AVAILABLE_LOCALES = getAvailableLocales();++// Used only when the renderer can't see a real display (tests, headless).+const FALLBACK_SCREEN_HEIGHT = 1080;++/**+ * Work-area height of the display, which is what the HUD's vertical budget is+ * really bounded by. Deliberately NOT `window.innerHeight`: the overlay window's+ * own height is the value this measurement feeds back into, and reading it here+ * is exactly what used to close the resize feedback loop.+ */+function getAvailableScreenHeight(): number {+ const available = typeof window === "undefined" ? 0 : window.screen?.availHeight;+ return available && available > 0 ? available : FALLBACK_SCREEN_HEIGHT;}-// Custom glyphs matching the Claude Design "OpenScreen Recording Widget"-// spec exactly (source/audio/mic/camera/cursor/record) — these are the-// controls most visible in the collapsed toolbar, so the design's own paths-// are used verbatim rather than the closest lucide/react-icons stand-in.-const HUD_SVG_PROPS = {- width: ICON_SIZE,- height: ICON_SIZE,- viewBox: "0 0 24 24",- fill: "none",- stroke: "currentColor",- strokeWidth: 1.6,- strokeLinecap: "round",- strokeLinejoin: "round",-} as const;--function OrientationIcon({ vertical, className }: { vertical: boolean; className?: string }) {- return (- <svg {...HUD_SVG_PROPS} className={className} aria-hidden="true">- {vertical ? (- <>- <rect x="3" y="7" width="18" height="10" rx="3" />- <path d="M12 7v10" />- </>- ) : (- <>- <rect x="7" y="3" width="10" height="18" rx="3" />- <path d="M7 12h10" />- </>- )}- </svg>- );-}--function SourceIcon({ className }: { className?: string }) {- return (- <svg {...HUD_SVG_PROPS} className={className} aria-hidden="true">- <rect x="2.5" y="4.5" width="19" height="13" rx="2.2" />- <path d="M8.5 21h7M12 17.5v3.3" />- </svg>- );-}--function VolumeIcon({ muted, className }: { muted: boolean; className?: string }) {- return (- <svg {...HUD_SVG_PROPS} className={className} aria-hidden="true">- <path- d="M10.2 5.6 5.6 9H3a1 1 0 0 0-1 1v4a1 1 0 0 0 1 1h2.6l4.6 3.4a.6.6 0 0 0 1-.48V6.08a.6.6 0 0 0-1-.48Z"- fill="currentColor"- stroke="none"- />- {muted ? (- <path d="M15.2 9.3 19.4 14.7M19.4 9.3l-4.2 5.4" />- ) : (- <>- <path d="M15.5 8.5a5 5 0 0 1 0 7" />- <path d="M18 6a9 9 0 0 1 0 12" />- </>- )}- </svg>- );-}--function MicIcon({ muted, className }: { muted: boolean; className?: string }) {- return (- <svg {...HUD_SVG_PROPS} className={className} aria-hidden="true">- <rect x="9" y="3" width="6" height="11" rx="3" />- <path d="M18.5 11a6.5 6.5 0 0 1-13 0" />- <path d="M12 17.5v3" />- {muted ? <path d="M4 4l16 16" /> : null}- </svg>- );-}--function CameraIcon({ off, className }: { off: boolean; className?: string }) {- return (- <svg {...HUD_SVG_PROPS} className={className} aria-hidden="true">- <rect x="3" y="6.5" width="13" height="11" rx="2.4" />- <path d="M16 10.3 21 7v10l-5-3.3" />- {off ? <path d="M4 4l16 16" /> : null}- </svg>- );-}--function CursorIcon({ className }: { className?: string }) {- return (- <svg- width={ICON_SIZE}- height={ICON_SIZE}- viewBox="0 0 24 24"- fill="currentColor"- stroke="none"- className={className}- aria-hidden="true"- >- <path d="M6.7 3.3 6.7 18.3 10.3 14.8 12.7 20.7 15.1 19.7 12.7 13.8 17.3 13.8Z" />- </svg>- );-}--function RecordGlyph({ recording, className }: { recording: boolean; className?: string }) {- return (- <svg- width={ICON_SIZE}- height={ICON_SIZE}- viewBox="0 0 24 24"- className={className}- aria-hidden="true"- >- {recording ? (- <rect x="6.5" y="6.5" width="11" height="11" rx="2.5" fill="currentColor" />- ) : (- <circle cx="12" cy="12" r="7.5" fill="currentColor" />- )}- </svg>- );-}--function OpenInEditorIcon({ className }: { className?: string }) {- return (- <svg {...HUD_SVG_PROPS} className={className} aria-hidden="true">- <path d="M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z" />- <path d="m6.2 5.3 3.1 5.4" />- <path d="m12.4 3.4 3.1 5.4" />- <path d="M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z" />- </svg>- );-}--const hudDisabledClasses =- "disabled:opacity-30 disabled:cursor-not-allowed disabled:pointer-events-none";--// Exact values from the design's renderVals() (comfortable density, rounded-// shape, #10b981 accent) — btnSize 34 / btnRadius 10 / containerRadius 17-// (btnRadius + padY) / dividerLen 22. Every control is its own standalone-// transparent icon button (no shared "group" pill background) — grouping-// reads purely from proximity + the divider spans between logical sections.-const hudIconBtnClasses = `flex h-[34px] w-[34px] shrink-0 items-center justify-center rounded-[10px] border-0 bg-transparent cursor-pointer text-[#828c99] transition-all duration-150 hover:bg-[#1a1e25] hover:text-[#f5f7fa] active:scale-95 ${hudDisabledClasses}`;--const hudAuxIconBtnClasses = `flex h-7 w-7 shrink-0 items-center justify-center rounded-[10px] border-0 bg-transparent cursor-pointer text-[#828c99] transition-colors duration-150 hover:bg-[#1a1e25] hover:text-[#f5f7fa] ${hudDisabledClasses}`;--const windowBtnClasses = `flex h-[30px] w-[30px] shrink-0 items-center justify-center rounded-[9px] border-0 bg-transparent cursor-pointer text-[#828c99] transition-all duration-150 hover:bg-[#1a1e25] hover:text-[#e9edf3] ${hudDisabledClasses}`;--const closeBtnClasses = `flex h-[30px] w-[30px] shrink-0 items-center justify-center rounded-[9px] border-0 bg-transparent cursor-pointer text-[#828c99] transition-all duration-150 hover:bg-[rgba(248,113,113,0.16)] hover:text-[#f87171] ${hudDisabledClasses}`;--const hudSidebarClasses = "flex items-center gap-[5px]";-const hudSidebarVerticalClasses = "flex flex-col items-center gap-[5px]";-/** Launches the floating recording HUD and its recorder controls. */export function LaunchWindow() {const t = useScopedT("launch");- const availableLocales = getAvailableLocales();const {locale,setLocale,@@ -245,60 +104,50 @@ export function LaunchWindow() {dismissSoftwareEncoderFallbackNotice,} = useScreenRecorder();- // Device-picker popovers (mic / camera only — system audio has no device- // list to pick from, so it's a plain direct toggle) are click-to-open,- // mutually exclusive with each other and with the language menu. Unlike- // the design's mockup, picking a device IS the activation step and- // re-clicking an already-enabled icon disables it directly — no separate- // "turn on" popover step, since that was a redundant extra click.- const [activeDeviceMenu, setActiveDeviceMenu] = useState<"mic" | "camera" | null>(null);- const micTriggerRef = useRef<HTMLButtonElement | null>(null);- const camTriggerRef = useRef<HTMLButtonElement | null>(null);- const deviceMenuTriggerRefsRef = useRef({- mic: micTriggerRef,- camera: camTriggerRef,- });- const deviceMenuTriggerRefs = deviceMenuTriggerRefsRef.current;+ // Choosing a device and switching one on are deliberately separate concerns.+ // The mic and camera buttons are plain on/off toggles that use whatever device+ // is currently selected (the system default until the user says otherwise);+ // picking a different device — and checking it actually works — happens in the+ // settings panel. Overloading one button with both jobs is what made turning a+ // camera on take two clicks.+ const [isDeviceSettingsOpen, setIsDeviceSettingsOpen] = useState(false);const [isLanguageMenuOpen, setIsLanguageMenuOpen] = useState(false);const [trayLayout, setTrayLayout] = useState<"horizontal" | "vertical">(() => loadUserPreferences().trayLayout,);const [supportsCursorModeToggle, setSupportsCursorModeToggle] = useState(false);const [isLinuxHud, setIsLinuxHud] = useState(false);++ const isVertical = trayLayout === "vertical";+ const isPopoverOpen = isLanguageMenuOpen || isDeviceSettingsOpen;+ const controlsLocked = recording || saving;++ const settingsTriggerRef = useRef<HTMLButtonElement | null>(null);const languageTriggerRef = useRef<HTMLButtonElement | null>(null);- const languageMenuPanelRef = useRef<HTMLDivElement | null>(null);+ const hudAnchorRef = useRef<HTMLDivElement | null>(null);const hudBarRef = useRef<HTMLDivElement | null>(null);- const deviceSelectorRef = useRef<HTMLDivElement | null>(null);- const systemLocalePromptRef = useRef<HTMLDivElement | null>(null);- const softwareFallbackNoticeRef = useRef<HTMLDivElement | null>(null);- // Measured bar height, anchors the popups above the tall vertical tray so they don't overlap it.- const [hudBarHeight, setHudBarHeight] = useState(0);- const [languageMenuStyle, setLanguageMenuStyle] = useState<{- right: number;- bottom: number;- maxHeight: number;- }>({- right: 12,- bottom: 12,- maxHeight: LANGUAGE_MENU_MAX_HEIGHT,- });-- // These hooks only enumerate devices while their `enabled` arg is true, but the- // device-picker popover now opens precisely while the mic/camera is OFF (picking- // a device is what turns it on) -- so it must also enumerate while its own menu- // is open, or the picker would always render empty.- const {- devices: micDevices,- selectedDeviceId: selectedMicId,- setSelectedDeviceId: setSelectedMicId,- } = useMicrophoneDevices(microphoneEnabled || activeDeviceMenu === "mic");+ const popoverRef = useRef<HTMLDivElement | null>(null);+ const hudNoticesRef = useRef<HTMLDivElement | null>(null);++ // The camera list is enumerated from mount rather than on first open. It costs+ // one enumerateDevices() call and means the picker renders its final content+ // on its very first frame, and that `webcamDeviceId` is already the default+ // device when the button is clicked — so enabling the camera acquires the+ // right stream once instead of acquiring the default and then re-acquiring.const {devices: cameraDevices,selectedDeviceId: selectedCameraId,setSelectedDeviceId: setSelectedCameraId,isLoading: isCameraDevicesLoading,error: cameraDevicesError,- } = useCameraDevices(webcamEnabled || activeDeviceMenu === "camera");+ } = useCameraDevices(true);+ // The microphone list stays lazy: enumerating it asks for mic permission,+ // which would light the OS "in use" indicator just for opening the HUD.+ const {+ devices: micDevices,+ selectedDeviceId: selectedMicId,+ setSelectedDeviceId: setSelectedMicId,+ } = useMicrophoneDevices(microphoneEnabled || isDeviceSettingsOpen);useEffect(() => {if (selectedMicId && selectedMicId !== "default") {@@ -346,48 +195,29 @@ export function LaunchWindow() {});}, []);- useEffect(() => {- if (!isLanguageMenuOpen) return;-- const handlePointerDown = (event: PointerEvent) => {- const target = event.target as Node;- const clickedTrigger = languageTriggerRef.current?.contains(target);- const clickedMenu = languageMenuPanelRef.current?.contains(target);- if (!clickedTrigger && !clickedMenu) {- setIsLanguageMenuOpen(false);- }- };-- const handleEscape = (event: KeyboardEvent) => {- if (event.key === "Escape") {- setIsLanguageMenuOpen(false);- }- };-- window.addEventListener("pointerdown", handlePointerDown);- window.addEventListener("keydown", handleEscape);-- return () => {- window.removeEventListener("pointerdown", handlePointerDown);- window.removeEventListener("keydown", handleEscape);- };- }, [isLanguageMenuOpen]);+ // One dismiss handler for both floating surfaces — they're mutually exclusive,+ // so a single pointerdown/Escape listener covers the pair instead of two.+ const closePopovers = useCallback(() => {+ setIsDeviceSettingsOpen(false);+ setIsLanguageMenuOpen(false);+ }, []);useEffect(() => {- if (!activeDeviceMenu) return;+ if (!isPopoverOpen) return;const handlePointerDown = (event: PointerEvent) => {const target = event.target as Node;- const clickedTrigger = deviceMenuTriggerRefs[activeDeviceMenu].current?.contains(target);- const clickedMenu = deviceSelectorRef.current?.contains(target);- if (!clickedTrigger && !clickedMenu) {- setActiveDeviceMenu(null);+ const insideTrigger =+ settingsTriggerRef.current?.contains(target) ||+ languageTriggerRef.current?.contains(target);+ if (!insideTrigger && !popoverRef.current?.contains(target)) {+ closePopovers();}};const handleEscape = (event: KeyboardEvent) => {if (event.key === "Escape") {- setActiveDeviceMenu(null);+ closePopovers();}};@@ -398,173 +228,113 @@ export function LaunchWindow() {window.removeEventListener("pointerdown", handlePointerDown);window.removeEventListener("keydown", handleEscape);};- }, [activeDeviceMenu, deviceMenuTriggerRefs]);-- useEffect(() => {- if (!isLanguageMenuOpen || !languageTriggerRef.current) return;-- const updatePosition = () => {- if (!languageTriggerRef.current) return;- const rect = languageTriggerRef.current.getBoundingClientRect();- const gap = 8;- const viewportPadding = 8;- // Space between the viewport top and the trigger, in case the screen is too- // short for the full LANGUAGE_MENU_MAX_HEIGHT -- clamp to whatever fits.- const availableHeight = Math.max(80, rect.top - viewportPadding - gap);-- setLanguageMenuStyle({- right: Math.max(viewportPadding, window.innerWidth - rect.right),- bottom: Math.max(viewportPadding, window.innerHeight - rect.top + gap),- maxHeight: Math.min(LANGUAGE_MENU_MAX_HEIGHT, availableHeight),- });- };-- updatePosition();- window.addEventListener("resize", updatePosition);- window.addEventListener("scroll", updatePosition, true);-- return () => {- window.removeEventListener("resize", updatePosition);- window.removeEventListener("scroll", updatePosition, true);- };- }, [isLanguageMenuOpen]);-- useEffect(() => {- if (!isLanguageMenuOpen || !languageMenuPanelRef.current) return;- const id = requestAnimationFrame(() => {- if (languageMenuPanelRef.current) {- languageMenuPanelRef.current.scrollTop = 0;- }- });- return () => cancelAnimationFrame(id);- }, [isLanguageMenuOpen]);+ }, [closePopovers, isPopoverOpen]);- // Resize the overlay window to fit content, else the taller vertical tray gets clipped- // and scrolls. Measure from the window's bottom-centre (the anchor the main process- // preserves) so fixed bottom/centre offsets keep this stable and it doesn't oscillate.+ // ---------------------------------------------------------------------------+ // Overlay window sizing//- // Only ever GROWS the window (a high-water mark), reset when the orientation changes.- // Even with an eased tween, a native OS window resize on every content change (record- // starting/stopping, a device popover opening, mic/cam toggling) reads as constant- // jitter -- there's no way to make that many resizes-per-minute look smooth. Since the- // window is transparent and the bar is centred within it, an oversized window is- // invisible: once the widest/tallest state for this orientation has been seen, later- // content changes just reflow inside the already-big-enough window via ordinary CSS- // (instant, GPU-composited, no native resize at all), and only a genuinely new maximum- // triggers the animated resize -- rare enough that its motion is acceptable.+ // The renderer owns the overlay window's size, so a naive "measure what's on+ // screen and grow to fit" is a feedback loop: the resize changes the viewport,+ // viewport-sized boxes re-layout, the observer fires again. That loop is what+ // made the HUD flicker and jump the first few times each popover was opened.+ //+ // Two rules break it, and both live here:+ // 1. Only the bar is measured. Everything floating above it has a fixed+ // width and a capped height, so its space is *reserved* from the first+ // frame — opening a popover costs zero native resizes.+ // 2. No measured box may be sized against the viewport. Caps come from+ // screen.availHeight (which a window resize can't change) and are pushed+ // down as CSS custom properties.+ // ---------------------------------------------------------------------------const hudAllocatedSizeRef = useRef({ width: 0, height: 0, orientation: trayLayout });const isDraggingHudRef = useRef(false);++ useLayoutEffect(() => {+ const anchor = hudAnchorRef.current;+ if (!anchor) return;+ anchor.style.setProperty("--hud-bar-bottom", `${HUD_BAR_BOTTOM}px`);+ anchor.style.setProperty("--hud-popover-gap", `${HUD_POPOVER_GAP}px`);+ anchor.style.setProperty("--hud-stack-gap", `${HUD_STACK_GAP}px`);+ anchor.style.setProperty(+ "--hud-bar-max-h",+ `${computeHudBarMaxHeight(getAvailableScreenHeight())}px`,+ );+ }, []);+const measureHudSize = useCallback(() => {const barEl = hudBarRef.current;if (!barEl || !window.electronAPI?.setHudOverlaySize) return;- // While the user is dragging the HUD, ignore content-size measurements. A- // ResizeObserver-driven resize (hud-overlay-set-size) re-centres the window from- // its own bottom-centre anchor, which fights the position "hud-overlay-move-by" is- // actively applying frame-by-frame -- the two IPC channels racing is what produces- // the reported drift. Content size is re-measured once the drag ends instead.+ // While the user is dragging, a resize would re-anchor the window from its+ // own bounds and fight the position the drag is applying frame by frame.+ // Content is re-measured once the drag ends instead.if (isDraggingHudRef.current) return;- // Breathing room so the drop shadow isn't clipped. TOP_MARGIN must also exceed the- // slack in the bar's `max-h: calc(100vh - 2.5rem)` cap (40px reserved - 20px bottom- // gap = 20px) so the window stays tall enough that the cap never engages and adds a scrollbar.- const SIDE_MARGIN = 24;- const TOP_MARGIN = 24;- // Wide enough that the language menu (11rem) never clips, even when the bar is narrow.- const MIN_WIDTH = 220;-- const viewportHeight = window.innerHeight;- const centerX = window.innerWidth / 2;-- // Use natural (scroll) size, not the clipped box: vertical mode's max-h cap is a- // small-screen fallback, and reading clipped height would pin the window to it.- // scrollHeight gives full content height; the cap only engages when the main process clamps to screen.- let topFromBottom = viewportHeight - barEl.getBoundingClientRect().bottom + barEl.scrollHeight;- let halfWidth = barEl.scrollWidth / 2;-- // Popups drive both dimensions too. Their vertical anchor depends on bar height,- // which is fed back through React state and lags by a frame, so derive their top- // edge from the bar's natural height instead of the stale rendered position. Keeps- // one measurement pass authoritative and avoids a feedback re-measure.- if (deviceSelectorRef.current) {- const rect = deviceSelectorRef.current.getBoundingClientRect();- if (rect.width !== 0 || rect.height !== 0) {- const popupBottomOffset =- trayLayout === "vertical"- ? barEl.scrollHeight + HUD_DEVICE_POPUP_GAP- : HUD_DEVICE_POPUP_HORIZONTAL_BOTTOM;- topFromBottom = Math.max(topFromBottom, popupBottomOffset + rect.height);- halfWidth = Math.max(halfWidth, rect.width / 2);- }- }-- // The language menu scrolls within available height, so it only influences width.- // Its presence in the DOM means it's open.- if (languageMenuPanelRef.current) {- const rect = languageMenuPanelRef.current.getBoundingClientRect();- halfWidth = Math.max(halfWidth, centerX - rect.left, rect.right - centerX);- }-- // Prompt sits at `fixed top-8`; grow the window to fit it so its buttons don't clip (issue #30).- if (systemLocalePromptRef.current) {- const rect = systemLocalePromptRef.current.getBoundingClientRect();- const promptHeight = rect.height || systemLocalePromptRef.current.scrollHeight;- if (promptHeight > 0) {- topFromBottom = Math.max(topFromBottom, rect.top + promptHeight);- }- halfWidth = Math.max(halfWidth, centerX - rect.left, rect.right - centerX);- }-- // The software-encoder fallback notice shares the prompt's fixed top-8 slot and needs- // the same treatment so its buttons stay clickable.- if (softwareFallbackNoticeRef.current) {- const rect = softwareFallbackNoticeRef.current.getBoundingClientRect();- const noticeHeight = rect.height || softwareFallbackNoticeRef.current.scrollHeight;- if (noticeHeight > 0) {- topFromBottom = Math.max(topFromBottom, rect.top + noticeHeight);- }- halfWidth = Math.max(halfWidth, centerX - rect.left, rect.right - centerX);- }-- setHudBarHeight((prev) => {- const next = Math.round(barEl.scrollHeight);- return Math.abs(prev - next) > 1 ? next : prev;+ const availableHeight = getAvailableScreenHeight();+ const barRect = barEl.getBoundingClientRect();+ const barWidth = barRect.width || barEl.scrollWidth;+ const barHeight = barRect.height || barEl.scrollHeight;+ const noticeEl = hudNoticesRef.current;+ const noticeHeight = noticeEl+ ? noticeEl.getBoundingClientRect().height || noticeEl.scrollHeight+ : 0;++ // The two floating surfaces get their own CSS caps (a 470px-tall language+ // list would look absurd), but the *window* always reserves room for the+ // taller of them. Sizing the reserve to whichever happens to be open would+ // mean the window grows when the panel opens — and since the stack is+ // bottom-anchored, growing upward moves every bit of content down in window+ // coordinates, which the renderer repaints a frame or two after the native+ // resize lands. That gap is visible as exactly the position judder this+ // whole architecture exists to remove. So: reserve the maximum, always.+ const popoverMaxHeight = computeHudPopoverMaxHeight(barHeight, availableHeight);+ const modalMaxHeight = computeHudModalMaxHeight(barHeight, availableHeight);+ const anchorEl = hudAnchorRef.current;+ anchorEl?.style.setProperty("--hud-popover-max-h", `${popoverMaxHeight}px`);+ anchorEl?.style.setProperty("--hud-modal-max-h", `${modalMaxHeight}px`);++ const { required, granted } = computeHudWindowSize({+ barWidth,+ barHeight,+ noticeHeight,+ availableHeight,+ stackMaxHeight: Math.max(popoverMaxHeight, modalMaxHeight),});- const requiredWidth = Math.max(MIN_WIDTH, Math.ceil(halfWidth * 2) + SIDE_MARGIN);- const requiredHeight = Math.ceil(topFromBottom) + TOP_MARGIN;-const allocated = hudAllocatedSizeRef.current;- if (allocated.orientation !== trayLayout) {- // Different shape entirely (wide-short vs narrow-tall) -- the old high-water- // mark doesn't apply, start fresh so we don't carry a stale huge footprint- // from the other orientation.- allocated.width = 0;- allocated.height = 0;- allocated.orientation = trayLayout;- }-- const width = Math.max(requiredWidth, allocated.width);- const height = Math.max(requiredHeight, allocated.height);- if (width === allocated.width && height === allocated.height) {+ // A different orientation is a different shape entirely (wide-short vs+ // narrow-tall), so the previous allocation says nothing useful.+ const orientationChanged = allocated.orientation !== trayLayout;+ // Grow the moment the content stops fitting. Shrink only once the content+ // has fallen a whole reserve below what was granted — that asymmetry is the+ // hysteresis: the bar can grow into its reserve (recording controls, a+ // longer source name) and back out again without a single native resize,+ // while a one-off bad reading (an unstyled first paint in dev, say) can't+ // leave the overlay permanently oversized.+ const needsResize =+ orientationChanged ||+ required.width > allocated.width ||+ required.height > allocated.height ||+ granted.width + HUD_GROWTH_RESERVE < allocated.width ||+ granted.height + HUD_GROWTH_RESERVE < allocated.height;+ if (!needsResize) {return;}- allocated.width = width;- allocated.height = height;- window.electronAPI.setHudOverlaySize(width, height);++ allocated.orientation = trayLayout;+ allocated.width = granted.width;+ allocated.height = granted.height;+ window.electronAPI.setHudOverlaySize(granted.width, granted.height);}, [trayLayout]);- // One persistent observer; elements wire themselves up via callback refs as they- // mount/unmount so measurement re-runs without recreating it or threading mount state through deps.+ // One persistent observer; elements wire themselves up via callback refs as+ // they mount/unmount. Only the bar and the notice column are observed — the+ // popovers deliberately are not, since their space is already reserved.const hudResizeObserverRef = useRef<ResizeObserver | null>(null);useEffect(() => {const observer = new ResizeObserver(() => measureHudSize());hudResizeObserverRef.current = observer;if (hudBarRef.current) observer.observe(hudBarRef.current);- if (deviceSelectorRef.current) observer.observe(deviceSelectorRef.current);- // Backfill refs set before the observer existed (e.g. the prompt or language menu).- if (systemLocalePromptRef.current) observer.observe(systemLocalePromptRef.current);- if (softwareFallbackNoticeRef.current) observer.observe(softwareFallbackNoticeRef.current);- if (languageMenuPanelRef.current) observer.observe(languageMenuPanelRef.current);+ if (hudNoticesRef.current) observer.observe(hudNoticesRef.current);measureHudSize();return () => {observer.disconnect();@@ -586,22 +356,13 @@ export function LaunchWindow() {(el: HTMLDivElement | null) => observeHudElement(el, hudBarRef),[observeHudElement],);- const setDeviceSelectorEl = useCallback(- (el: HTMLDivElement | null) => observeHudElement(el, deviceSelectorRef),- [observeHudElement],- );- const setLanguageMenuPanelEl = useCallback(- (el: HTMLDivElement | null) => observeHudElement(el, languageMenuPanelRef),- [observeHudElement],- );- const setSystemLocalePromptEl = useCallback(- (el: HTMLDivElement | null) => observeHudElement(el, systemLocalePromptRef),- [observeHudElement],- );- const setSoftwareFallbackNoticeEl = useCallback(- (el: HTMLDivElement | null) => observeHudElement(el, softwareFallbackNoticeRef),+ const setHudNoticesEl = useCallback(+ (el: HTMLDivElement | null) => observeHudElement(el, hudNoticesRef),[observeHudElement],);+ const setPopoverEl = useCallback((el: HTMLDivElement | null) => {+ popoverRef.current = el;+ }, []);const hudIgnoreMouseEventsRef = useRef<boolean | undefined>(undefined);const setHudMouseEventsEnabled = useCallback(@@ -623,14 +384,17 @@ export function LaunchWindow() {};}, [setHudMouseEventsEnabled]);+ // A popover reaches beyond the bar, and the gap between the two would otherwise+ // flip the window back to click-through mid-travel — so hold the overlay+ // interactive for as long as one is open, and hand control back to the+ // pointer-move tracking once it closes.useEffect(() => {- setHudMouseEventsEnabled(isLanguageMenuOpen);- }, [isLanguageMenuOpen, setHudMouseEventsEnabled]);+ setHudMouseEventsEnabled(isPopoverOpen);+ }, [isPopoverOpen, setHudMouseEventsEnabled]);const defaultSourceName = t("sourceSelector.defaultSourceName");const [selectedSource, setSelectedSource] = useState(defaultSourceName);const [hasSelectedSource, setHasSelectedSource] = useState(false);- const [, setRecordPointerDownCount] = useState(0);const recordAfterSourceSelectionRef = useRef(false);const applySelectedSource = useCallback(@@ -647,24 +411,35 @@ export function LaunchWindow() {[defaultSourceName],);+ // The main process pushes every change through `onSelectedSourceChanged`, so+ // this only needs one read to seed the initial value (plus one on focus, in+ // case a change was missed while this window was gone). The old 500ms poll ran+ // two IPC round-trips a second, forever, for a value that is event-driven.useEffect(() => {- const checkSelectedSource = async () => {+ let cancelled = false;++ const refreshSelectedSource = async () => {if (!window.electronAPI) {return;}try {const source = await window.electronAPI.getSelectedSource();- applySelectedSource(source);+ if (!cancelled) {+ applySelectedSource(source);+ }} catch (error) {console.warn("Failed to refresh selected source:", error);}};- checkSelectedSource();+ void refreshSelectedSource();+ window.addEventListener("focus", refreshSelectedSource);- const interval = setInterval(checkSelectedSource, 500);- return () => clearInterval(interval);+ return () => {+ cancelled = true;+ window.removeEventListener("focus", refreshSelectedSource);+ };}, [applySelectedSource]);useEffect(() => {@@ -687,7 +462,7 @@ export function LaunchWindow() {};}, [applySelectedSource, recording, toggleRecording]);- const openSourceSelector = async () => {+ const openSourceSelector = useCallback(async () => {if (window.electronAPI) {return await openSourceSelectorWithPermissionRetry({openSourceSelector: () => window.electronAPI.openSourceSelector(),@@ -696,38 +471,41 @@ export function LaunchWindow() {}return { opened: false, reason: "electron-api-unavailable" };- };+ }, []);- const handleRecordButtonClick = (sourceSelectedOverride?: boolean) => {- if (saving) {- return;- }- const sourceSelected = sourceSelectedOverride ?? hasSelectedSource;- if (!sourceSelected && !recording) {- recordAfterSourceSelectionRef.current = true;- void openSourceSelector()- .then((result) => {- if (!result.opened) {+ const handleRecordButtonClick = useCallback(+ (sourceSelectedOverride?: boolean) => {+ if (saving) {+ return;+ }+ const sourceSelected = sourceSelectedOverride ?? hasSelectedSource;+ if (!sourceSelected && !recording) {+ recordAfterSourceSelectionRef.current = true;+ void openSourceSelector()+ .then((result) => {+ if (!result.opened) {+ recordAfterSourceSelectionRef.current = false;+ }+ })+ .catch(() => {recordAfterSourceSelectionRef.current = false;- }- })- .catch(() => {- recordAfterSourceSelectionRef.current = false;- });- return;- }+ });+ return;+ }- toggleRecording();- };+ toggleRecording();+ },+ [hasSelectedSource, openSourceSelector, recording, saving, toggleRecording],+ );+ const handleRecordClick = useCallback(() => handleRecordButtonClick(), [handleRecordButtonClick]);// The editor's Rec-mode stage sends this once it hands off to the HUD// (source + prefs already persisted via IPC), so the user doesn't have to// click Record a second time after "Start recording" reopens this window.- // The auto-start signal can arrive before this window's own- // `checkSelectedSource` poll (above) has resolved its first round-trip, so- // `hasSelectedSource` may still be stale — fetch a fresh value here instead- // of trusting it, otherwise auto-start can wrongly fall through to opening- // the source selector instead of actually starting the recording.+ // The auto-start signal can arrive before this window's own initial+ // `getSelectedSource` round-trip has resolved, so `hasSelectedSource` may+ // still be stale — fetch a fresh value here instead of trusting it, otherwise+ // auto-start can wrongly fall through to opening the source selector.const handleRecordButtonClickRef = useRef(handleRecordButtonClick);handleRecordButtonClickRef.current = handleRecordButtonClick;const hasSelectedSourceRef = useRef(hasSelectedSource);@@ -748,704 +526,438 @@ export function LaunchWindow() {});}, [applySelectedSource]);- const sendHudOverlayHide = () => {- if (window.electronAPI && window.electronAPI.hudOverlayHide) {- window.electronAPI.hudOverlayHide();- }- };- const sendHudOverlayClose = () => {- if (window.electronAPI && window.electronAPI.hudOverlayClose) {- window.electronAPI.hudOverlayClose();- }- };+ const sendHudOverlayHide = useCallback(() => {+ window.electronAPI?.hudOverlayHide?.();+ }, []);+ const sendHudOverlayClose = useCallback(() => {+ window.electronAPI?.hudOverlayClose?.();+ }, []);+ const openStudio = useCallback(() => {+ if (!saving) window.electronAPI.switchToEditor();+ }, [saving]);+ const openNotes = useCallback(() => {+ if (!saving) window.electronAPI.openNotes();+ }, [saving]);+/** Switches the HUD between horizontal and vertical tray layouts. */- const toggleTrayLayout = () => {- const nextLayout = trayLayout === "horizontal" ? "vertical" : "horizontal";- setTrayLayout(nextLayout);- saveUserPreferences({ trayLayout: nextLayout });- };-- const toggleMicrophone = () => {- if (!recording && !saving) {- setMicrophoneEnabled(!microphoneEnabled);- }- };- const dragLastPositionRef = useRef<{ x: number; y: number } | null>(null);- const dragAnimationFrameRef = useRef<number | null>(null);- const pendingDragDeltaRef = useRef({ x: 0, y: 0 });- const flushHudDragMove = useCallback(() => {- dragAnimationFrameRef.current = null;- const { x, y } = pendingDragDeltaRef.current;- pendingDragDeltaRef.current = { x: 0, y: 0 };- if (x === 0 && y === 0) return;- window.electronAPI?.moveHudOverlayBy?.(x, y);+ const toggleTrayLayout = useCallback(() => {+ // Popovers are laid out relative to the bar, so leaving one open across an+ // orientation flip means resizing and re-flowing in the same frame. Closing+ // first keeps the flip to a single, clean size change.+ closePopovers();+ setTrayLayout((previous) => {+ const nextLayout = previous === "horizontal" ? "vertical" : "horizontal";+ saveUserPreferences({ trayLayout: nextLayout });+ return nextLayout;+ });+ }, [closePopovers]);++ const toggleSystemAudio = useCallback(() => {+ if (controlsLocked) return;+ setSystemAudioEnabled(!systemAudioEnabled);+ }, [controlsLocked, setSystemAudioEnabled, systemAudioEnabled]);++ const toggleCursorMode = useCallback(() => {+ if (controlsLocked) return;+ setCursorCaptureMode(cursorCaptureMode === "editable-overlay" ? "system" : "editable-overlay");+ }, [controlsLocked, cursorCaptureMode, setCursorCaptureMode]);++ const toggleMicrophone = useCallback(() => {+ if (controlsLocked) return;+ setMicrophoneEnabled(!microphoneEnabled);+ }, [controlsLocked, microphoneEnabled, setMicrophoneEnabled]);++ const toggleWebcam = useCallback(() => {+ if (controlsLocked) return;+ void setWebcamEnabled(!webcamEnabled);+ }, [controlsLocked, setWebcamEnabled, webcamEnabled]);++ // Selecting a device never switches it on. If the device is already live the+ // recorder re-acquires on the id change; if it isn't, this just records which+ // one the next toggle should use.+ const handleSelectMicDevice = useCallback(+ (device: MicrophoneDevice) => {+ setSelectedMicId(device.deviceId);+ setMicrophoneDeviceId(device.deviceId);+ setMicrophoneDeviceName(device.label);+ },+ [setMicrophoneDeviceId, setMicrophoneDeviceName, setSelectedMicId],+ );++ const handleSelectCameraDevice = useCallback(+ (device: CameraDevice) => {+ setSelectedCameraId(device.deviceId);+ setWebcamDeviceId(device.deviceId);+ setWebcamDeviceName(device.label);+ },+ [setSelectedCameraId, setWebcamDeviceId, setWebcamDeviceName],+ );++ const toggleDeviceSettings = useCallback(() => {+ if (controlsLocked) return;+ setIsLanguageMenuOpen(false);+ setIsDeviceSettingsOpen((open) => !open);+ }, [controlsLocked]);++ const closeDeviceSettings = useCallback(() => {+ setIsDeviceSettingsOpen(false);}, []);- const scheduleHudDragMove = useCallback(- (deltaX: number, deltaY: number) => {- pendingDragDeltaRef.current = {- x: pendingDragDeltaRef.current.x + deltaX,- y: pendingDragDeltaRef.current.y + deltaY,- };-- if (dragAnimationFrameRef.current === null) {- dragAnimationFrameRef.current = window.requestAnimationFrame(flushHudDragMove);- }++ const toggleLanguageMenu = useCallback(() => {+ if (saving) return;+ setIsDeviceSettingsOpen(false);+ setIsLanguageMenuOpen((open) => !open);+ }, [saving]);++ const handleSelectLocale = useCallback(+ (nextLocale: string) => {+ setLocale(nextLocale as Parameters<typeof setLocale>[0]);+ resolveSystemLocaleSuggestion();+ setIsLanguageMenuOpen(false);},- [flushHudDragMove],+ [resolveSystemLocaleSuggestion, setLocale],);- const flushPendingHudDragMove = useCallback(() => {- if (dragAnimationFrameRef.current !== null) {- window.cancelAnimationFrame(dragAnimationFrameRef.current);- dragAnimationFrameRef.current = null;- }- const { x, y } = pendingDragDeltaRef.current;- pendingDragDeltaRef.current = { x: 0, y: 0 };- if (x === 0 && y === 0) return;- window.electronAPI?.moveHudOverlayBy?.(x, y);++ const enableHudMouseEvents = useCallback(() => {+ setHudMouseEventsEnabled(true);+ }, [setHudMouseEventsEnabled]);++ // ---------------------------------------------------------------------------+ // Dragging+ //+ // Deltas are absolute (total travel since pointerdown), not incremental: the+ // main process pins the window's origin at drag start and every move is+ // `origin + delta`. Accumulating per-frame deltas instead meant every rounded+ // setPosition compounded, and a dropped message drifted permanently. Absolute+ // deltas are self-correcting, and there's no requestAnimationFrame in the path+ // — pointermove is already delivered at most once per frame, so the rAF only+ // ever added a frame of latency to a gesture the user is watching.+ // ---------------------------------------------------------------------------+ const dragOriginRef = useRef<{ x: number; y: number } | null>(null);+ const lastDragDeltaRef = useRef<{ x: number; y: number }>({ x: 0, y: 0 });++ const handleHudDragPointerDown = useCallback(+ (event: React.PointerEvent<HTMLDivElement>) => {+ event.preventDefault();+ event.stopPropagation();+ setHudMouseEventsEnabled(true);+ event.currentTarget.setPointerCapture(event.pointerId);+ dragOriginRef.current = { x: event.screenX, y: event.screenY };+ lastDragDeltaRef.current = { x: 0, y: 0 };+ isDraggingHudRef.current = true;+ window.electronAPI?.beginHudOverlayDrag?.();+ },+ [setHudMouseEventsEnabled],+ );++ const handleHudDragPointerMove = useCallback((event: React.PointerEvent<HTMLDivElement>) => {+ const origin = dragOriginRef.current;+ if (!origin) return;+ const deltaX = event.screenX - origin.x;+ const deltaY = event.screenY - origin.y;+ const last = lastDragDeltaRef.current;+ if (last.x === deltaX && last.y === deltaY) return;+ lastDragDeltaRef.current = { x: deltaX, y: deltaY };+ window.electronAPI?.dragHudOverlayTo?.(deltaX, deltaY);}, []);- useEffect(() => {- return () => {- if (dragAnimationFrameRef.current !== null) {- window.cancelAnimationFrame(dragAnimationFrameRef.current);++ const handleHudDragPointerEnd = useCallback(+ (event: React.PointerEvent<HTMLDivElement>) => {+ if (!dragOriginRef.current) return;+ dragOriginRef.current = null;+ if (event.currentTarget.hasPointerCapture(event.pointerId)) {+ event.currentTarget.releasePointerCapture(event.pointerId);}- };- }, []);- const handleHudDragPointerDown = (event: React.PointerEvent<HTMLDivElement>) => {- event.preventDefault();- event.stopPropagation();- setHudMouseEventsEnabled(true);- event.currentTarget.setPointerCapture(event.pointerId);- dragLastPositionRef.current = { x: event.screenX, y: event.screenY };- isDraggingHudRef.current = true;- };- const handleHudDragPointerMove = (event: React.PointerEvent<HTMLDivElement>) => {- const lastPosition = dragLastPositionRef.current;- if (!lastPosition) return;- const deltaX = event.screenX - lastPosition.x;- const deltaY = event.screenY - lastPosition.y;- dragLastPositionRef.current = { x: event.screenX, y: event.screenY };- scheduleHudDragMove(deltaX, deltaY);- };- const handleHudDragPointerEnd = (event: React.PointerEvent<HTMLDivElement>) => {- dragLastPositionRef.current = null;- flushPendingHudDragMove();- if (event.currentTarget.hasPointerCapture(event.pointerId)) {- event.currentTarget.releasePointerCapture(event.pointerId);+ isDraggingHudRef.current = false;+ window.electronAPI?.endHudOverlayDrag?.();+ measureHudSize();+ },+ [measureHudSize],+ );++ const handleRootPointerMove = useCallback(+ (event: React.PointerEvent<HTMLDivElement>) => {+ // The pointer is captured by the drag handle anyway; skip the DOM walk.+ if (isDraggingHudRef.current) return;+ const target = event.target as HTMLElement | null;+ setHudMouseEventsEnabled(+ isPopoverOpen || Boolean(target?.closest("[data-hud-interactive='true']")),+ );+ },+ [isPopoverOpen, setHudMouseEventsEnabled],+ );++ const handlePointerLeave = useCallback(() => {+ if (!isPopoverOpen) {+ setHudMouseEventsEnabled(false);}- setHudMouseEventsEnabled(false);- isDraggingHudRef.current = false;- measureHudSize();- };+ }, [isPopoverOpen, setHudMouseEventsEnabled]);++ const dismissSoftwareFallbackForever = useCallback(() => {+ dismissSoftwareEncoderFallbackNotice(true);+ }, [dismissSoftwareEncoderFallbackNotice]);+ const dismissSoftwareFallbackOnce = useCallback(() => {+ dismissSoftwareEncoderFallbackNotice();+ }, [dismissSoftwareEncoderFallbackNotice]);++ const recordLabel = saving+ ? t("recording.saving")+ : hasSelectedSource || recording+ ? selectedSource+ : t("recording.selectSource");++ // Stable identity, or the panel's memo boundary would break on every parent+ // render — including the once-a-second one during a recording.+ const deviceSettingsLabels = useMemo<HudDeviceSettingsLabels>(+ () => ({+ title: t("deviceSettings.title"),+ done: t("deviceSettings.done"),+ microphone: t("audio.inputDevice"),+ camera: t("webcam.cameraDevice"),+ micLevel: t("deviceSettings.micLevel"),+ micHint: t("deviceSettings.micHint"),+ noMicrophones: t("deviceSettings.noMicrophones"),+ searching: t("webcam.searching"),+ noCameras: t("webcam.noneFound"),+ cameraUnavailable: t("webcam.unavailable"),+ preview: t("deviceSettings.preview"),+ previewUnavailable: t("deviceSettings.previewUnavailable"),+ }),+ [t],+ );++ const hasNotices = Boolean(systemLocaleSuggestion) || softwareEncoderFallbackNoticeVisible;return (// Avoid w-screen/h-screen: 100vw can exceed the inner layout width when scrollbars// affect the viewport (Windows), causing a horizontal scrollbar (issue #305).<divclassName={`h-full w-full min-w-0 max-w-full overflow-x-hidden overflow-y-hidden bg-transparent ${styles.electronDrag}`}- onPointerMove={(event) => {- const target = event.target as HTMLElement | null;- const shouldCapture =- isLanguageMenuOpen || Boolean(target?.closest("[data-hud-interactive='true']"));- setHudMouseEventsEnabled(shouldCapture);- }}- onPointerLeave={() => {- if (!isLanguageMenuOpen) {- setHudMouseEventsEnabled(false);- }- }}+ onPointerMove={handleRootPointerMove}+ onPointerLeave={handlePointerLeave}>- {/* Top-center notices share one fixed column so they stack instead of overlapping */}- {(systemLocaleSuggestion || softwareEncoderFallbackNoticeVisible) && (- <div className="fixed top-8 left-1/2 z-30 flex w-[calc(100vw-1rem)] max-w-[520px] -translate-x-1/2 flex-col gap-2">- {systemLocaleSuggestion && (- <div- ref={setSystemLocalePromptEl}- data-hud-interactive="true"- className={`w-full rounded-xl border border-white/15 bg-[rgba(20,20,28,0.95)] p-3 shadow-2xl backdrop-blur-xl text-white animate-in fade-in-0 zoom-in-95 duration-200 ${styles.electronNoDrag}`}- >- <div className="text-[13px] font-semibold text-white">- {t("systemLanguagePrompt.title")}- </div>- <div className="mt-1 text-[11px] leading-relaxed text-white/75">- {t("systemLanguagePrompt.description", {- language: suggestedLanguageName,- })}- </div>- <div className="mt-3 flex items-center justify-end gap-2">- <Button- type="button"- variant="ghost"- size="sm"- onClick={dismissSystemLocaleSuggestion}- className="h-7 text-xs text-white/80 hover:bg-white/10 hover:text-white"- >- {t("systemLanguagePrompt.keepDefault")}- </Button>- <Button- type="button"- size="sm"- onClick={acceptSystemLocaleSuggestion}- className="h-7 text-xs bg-white text-[#10121b] hover:bg-white/90"- >- {t("systemLanguagePrompt.switch", {- language: suggestedLanguageName,- })}- </Button>- </div>- </div>- )}-- {softwareEncoderFallbackNoticeVisible && (- <div- ref={setSoftwareFallbackNoticeEl}- data-hud-interactive="true"- className={`w-full rounded-xl border border-white/15 bg-[rgba(20,20,28,0.95)] p-3 shadow-2xl backdrop-blur-xl text-white animate-in fade-in-0 zoom-in-95 duration-200 ${styles.electronNoDrag}`}- >- <div className="text-[13px] font-semibold text-white">- {t("softwareEncoderFallback.title")}- </div>- <div className="mt-1 text-[11px] leading-relaxed text-white/75">- {t("softwareEncoderFallback.description")}- </div>- <div className="mt-3 flex items-center justify-end gap-2">- <Button- type="button"- variant="ghost"- size="sm"- onClick={() => dismissSoftwareEncoderFallbackNotice(true)}- className="h-7 text-xs text-white/80 hover:bg-white/10 hover:text-white"- >- {t("softwareEncoderFallback.dontShowAgain")}- </Button>- <Button- type="button"- size="sm"- onClick={() => dismissSoftwareEncoderFallbackNotice()}- className="h-7 text-xs bg-white text-[#10121b] hover:bg-white/90"- >- {t("softwareEncoderFallback.dismiss")}- </Button>- </div>- </div>- )}- </div>- )}-- {/* Device pickers: mic / camera only (system audio has no device list,- it's a plain toggle). This popover ONLY ever opens while the device- is disabled — picking a device turns it on and closes the popover- immediately; toggling off happens with a single click on the icon- itself (see the trigger buttons below), no popover involved. Fixed- above the HUD bar (or beside it in vertical layout), viewport-- relative, never clipped -- reuses the same measured-position wiring- the old combined mic/webcam panel used (deviceSelectorRef feeds- measureHudSize so the overlay window grows to fit whichever popover- is open). Only one popover is open at a time (see activeDeviceMenu). */}- {activeDeviceMenu && (+ {/* One bottom-anchored stack: the bar, then whatever floats above it.+ Everything is laid out by flexbox relative to the bar, so no popover+ needs a measured position and none of them can move the window. */}+ <div ref={hudAnchorRef} className={styles.hudAnchor}><div- ref={setDeviceSelectorEl}+ ref={setHudBarEl}data-hud-interactive="true"- className={`fixed left-1/2 w-[220px] -translate-x-1/2 rounded-[15px] border border-white/10 bg-[#1a1e25] p-1.5 shadow-[0_20px_44px_-14px_rgba(0,0,0,0.6),0_4px_12px_rgba(0,0,0,0.4)] backdrop-blur-2xl animate-mic-panel-in ${trayLayout === "vertical" ? "" : "bottom-[68px]"} ${styles.electronNoDrag}`}- style={- trayLayout === "vertical"- ? // Sit above the tall vertical tray, anchored to the measured bar- // height. Matches the offset in measureHudSize.- { bottom: hudBarHeight + HUD_DEVICE_POPUP_GAP }- : undefined- }+ data-tray-layout={trayLayout}+ className={`${styles.hudBar} ${isVertical ? styles.hudBarVertical : styles.hudBarHorizontal}`}+ onPointerEnter={enableHudMouseEvents}+ onPointerDown={enableHudMouseEvents}+ onMouseEnter={enableHudMouseEvents}+ onMouseLeave={handlePointerLeave}>- {activeDeviceMenu === "mic" && (- <>- <div className={styles.hudMenuSectionLabel}>{t("audio.inputDevice")}</div>- {micDevices.map((device) => {- const isActive = device.deviceId === (microphoneDeviceId || selectedMicId);- return (- <button- key={device.deviceId}- type="button"- role="menuitemradio"- aria-checked={isActive}- onClick={() => {- setSelectedMicId(device.deviceId);- setMicrophoneDeviceId(device.deviceId);- setMicrophoneDeviceName(device.label);- setMicrophoneEnabled(true);- setActiveDeviceMenu(null);- }}- className={`${styles.languageMenuItem} ${isActive ? styles.languageMenuItemActive : ""}`}- >- <span className="truncate">{device.label}</span>- {isActive ? <Check size={11} className="text-white/85" /> : null}- </button>- );- })}- </>- )}+ <HudDragHandle+ vertical={isVertical}+ onPointerDown={handleHudDragPointerDown}+ onPointerMove={handleHudDragPointerMove}+ onPointerEnd={handleHudDragPointerEnd}+ />- {activeDeviceMenu === "camera" && (- <>- <div className={styles.hudMenuSectionLabel}>{t("webcam.cameraDevice")}</div>- {isCameraDevicesLoading ? (- <div className="px-2.5 py-2 text-[11px] italic text-white/40">- {t("webcam.searching")}- </div>- ) : cameraDevicesError ? (- <div className="px-2.5 py-2 text-[11px] italic text-white/40">- {t("webcam.unavailable")}- </div>- ) : cameraDevices.length === 0 ? (- <div className="px-2.5 py-2 text-[11px] italic text-white/40">- {t("webcam.noneFound")}- </div>- ) : (- cameraDevices.map((device) => {- const isActive = device.deviceId === (webcamDeviceId || selectedCameraId);- return (- <button- key={device.deviceId}- type="button"- role="menuitemradio"- aria-checked={isActive}- onClick={async () => {- setSelectedCameraId(device.deviceId);- setWebcamDeviceId(device.deviceId);- setWebcamDeviceName(device.label);- await setWebcamEnabled(true);- setActiveDeviceMenu(null);- }}- className={`${styles.languageMenuItem} ${isActive ? styles.languageMenuItemActive : ""}`}- >- <span className="truncate">{device.label}</span>- {isActive ? <Check size={11} className="text-white/85" /> : null}- </button>- );- })- )}- </>- )}- </div>- )}-- {/* HUD bar, fixed at bottom center, viewport-relative, never moves */}- <div- ref={setHudBarEl}- data-hud-interactive="true"- data-tray-layout={trayLayout}- className={`fixed bottom-5 left-1/2 -translate-x-1/2 flex rounded-[17px] border border-[#242932] bg-[#14171c] shadow-[0_2px_6px_-2px_rgba(0,0,0,0.35)] backdrop-blur-2xl backdrop-saturate-[140%] ${- trayLayout === "vertical"- ? "max-h-[calc(100vh-2.5rem)] flex-col items-center gap-[5px] overflow-y-auto px-[7px] py-[9px]"- : "items-center gap-[5px] px-[9px] py-[7px]"- }`}- onPointerEnter={() => setHudMouseEventsEnabled(true)}- onPointerDown={() => setHudMouseEventsEnabled(true)}- onMouseEnter={() => setHudMouseEventsEnabled(true)}- onMouseLeave={() => {- if (!isLanguageMenuOpen) {- setHudMouseEventsEnabled(false);- }- }}- >- {/* Drag handle */}- <div- data-testid="hud-drag-handle"- className={`flex ${trayLayout === "vertical" ? "h-6 w-8" : "h-8 w-7"} shrink-0 cursor-grab items-center justify-center active:cursor-grabbing ${styles.electronNoDrag}`}- onPointerDown={handleHudDragPointerDown}- onPointerMove={handleHudDragPointerMove}- onPointerUp={handleHudDragPointerEnd}- onPointerCancel={handleHudDragPointerEnd}- >- {getIcon("drag", "text-[#333a45]")}- </div>+ <HudDivider vertical={isVertical} />- <span- className={`${styles.hudDivider} ${trayLayout === "vertical" ? styles.hudDividerVertical : styles.hudDividerHorizontal}`}- aria-hidden- />-- <Tooltip- content={- trayLayout === "horizontal"- ? t("tooltips.useVerticalTray")- : t("tooltips.useHorizontalTray")- }- >- <button- data-testid="launch-tray-layout-button"- type="button"- aria-label={- trayLayout === "horizontal"- ? t("tooltips.useVerticalTray")- : t("tooltips.useHorizontalTray")- }- aria-pressed={trayLayout === "vertical"}- className={`${hudIconBtnClasses} ${styles.electronNoDrag}`}+ <HudTrayLayoutButton+ vertical={isVertical}+ label={isVertical ? t("tooltips.useHorizontalTray") : t("tooltips.useVerticalTray")}onClick={toggleTrayLayout}- >- <OrientationIcon vertical={trayLayout === "vertical"} />- </button>- </Tooltip>-- {/* Source selector — transparent at rest, same hover treatment- (background only, no border) as every other toolbar button. */}- <button- data-testid="launch-source-selector-button"- className={`flex h-[34px] shrink-0 items-center gap-[7px] rounded-[10px] border-0 bg-transparent text-[#f5f7fa] transition-all duration-150 hover:bg-[#1a1e25] active:scale-[0.97] ${hudDisabledClasses} ${- trayLayout === "vertical" ? "w-[34px] justify-center px-0" : "pr-3 pl-2.5"- } ${styles.electronNoDrag}`}- onClick={openSourceSelector}- disabled={recording || saving}- title={selectedSource}- aria-label={selectedSource}- >- <SourceIcon className="shrink-0" />- <span- className={`${trayLayout === "vertical" ? "sr-only" : "max-w-[86px]"} truncate text-[13px] font-medium`}- >- {selectedSource}- </span>- </button>-- <span- className={`${styles.hudDivider} ${trayLayout === "vertical" ? styles.hudDividerVertical : styles.hudDividerHorizontal}`}- aria-hidden- />-- {/* System audio / mic / camera / cursor — each its own standalone- transparent icon button (no shared group pill), matching the- design exactly: rest color is muted gray, active/enabled color- is the accent green. */}- <button- data-testid="launch-system-audio-button"- className={`${hudIconBtnClasses} ${styles.electronNoDrag}`}- onClick={() => !(recording || saving) && setSystemAudioEnabled(!systemAudioEnabled)}- disabled={recording || saving}- title={systemAudioEnabled ? t("audio.disableSystemAudio") : t("audio.enableSystemAudio")}- >- <VolumeIcon- muted={!systemAudioEnabled}- className={systemAudioEnabled ? "text-[#10b981]" : ""}/>- </button>- <button- ref={micTriggerRef}- data-testid="launch-microphone-button"- className={`${hudIconBtnClasses} ${styles.electronNoDrag}`}- aria-expanded={activeDeviceMenu === "mic"}- aria-haspopup={microphoneEnabled ? undefined : "menu"}- onClick={() => {- if (recording || saving) return;- // Already on: a single click just turns it off, no popover.- // Already off: open the device picker — selecting a device- // (or the mic already having one) is what turns it on.- if (microphoneEnabled) {- toggleMicrophone();- return;- }- setIsLanguageMenuOpen(false);- setActiveDeviceMenu((prev) => (prev === "mic" ? null : "mic"));- }}- disabled={recording || saving}- title={microphoneEnabled ? t("audio.disableMicrophone") : t("audio.enableMicrophone")}- onPointerDown={() => {- setRecordPointerDownCount((count) => count + 1);- }}- >- <MicIcon- muted={!microphoneEnabled}- className={microphoneEnabled ? "text-[#10b981]" : ""}++ <HudSourceButton+ vertical={isVertical}+ label={selectedSource}+ disabled={controlsLocked}+ onClick={openSourceSelector}/>- </button>- <button- ref={camTriggerRef}- data-testid="launch-webcam-button"- className={`${hudIconBtnClasses} ${styles.electronNoDrag}`}- aria-expanded={activeDeviceMenu === "camera"}- aria-haspopup={webcamEnabled ? undefined : "menu"}- onClick={() => {- if (recording || saving) return;- if (webcamEnabled) {- void setWebcamEnabled(false);- return;- }- setIsLanguageMenuOpen(false);- setActiveDeviceMenu((prev) => (prev === "camera" ? null : "camera"));- }}- disabled={recording || saving}- title={webcamEnabled ? t("webcam.disableWebcam") : t("webcam.enableWebcam")}- >- <CameraIcon off={!webcamEnabled} className={webcamEnabled ? "text-[#10b981]" : ""} />- </button>- {supportsCursorModeToggle && (- <button- data-testid="launch-cursor-mode-button"- className={`flex h-[34px] w-[34px] shrink-0 items-center justify-center rounded-[10px] border-0 cursor-pointer transition-all duration-150 active:scale-95 ${hudDisabledClasses} ${styles.electronNoDrag} ${- cursorCaptureMode === "editable-overlay"- ? "bg-[#10b981] text-[#08090d] hover:bg-[#0e9e6e]"- : "bg-transparent text-[#828c99] hover:bg-[#1a1e25] hover:text-[#f5f7fa]"- }`}- onClick={() =>- !(recording || saving) &&- setCursorCaptureMode(- cursorCaptureMode === "editable-overlay" ? "system" : "editable-overlay",- )- }- disabled={recording || saving}- title={- cursorCaptureMode === "editable-overlay"- ? t("cursor.useSystemCursor")- : t("cursor.useEditableCursor")- }- >- <CursorIcon />- </button>- )}- <span- className={`${styles.hudDivider} ${trayLayout === "vertical" ? styles.hudDividerVertical : styles.hudDividerHorizontal}`}- aria-hidden- />-- {/* Record/Stop group */}- <Tooltip- content={- saving- ? t("recording.saving")- : hasSelectedSource || recording- ? selectedSource- : t("recording.selectSource")- }- >- <button- data-testid="launch-record-button"- disabled={saving}- className={`flex h-[34px] shrink-0 items-center justify-center rounded-[17px] border-0 transition-all duration-150 ${recording || saving ? "min-w-[78px] px-3" : "w-[34px]"} ${styles.electronNoDrag} ${- saving- ? "bg-transparent opacity-60 cursor-not-allowed"- : "bg-transparent hover:bg-[rgba(248,113,113,0.16)]"- }`}- onClick={() => handleRecordButtonClick()}- title={- saving- ? t("recording.saving")- : hasSelectedSource || recording- ? selectedSource- : t("recording.selectSource")+ <HudDivider vertical={isVertical} />++ {/* System audio / mic / camera / cursor — each its own standalone+ transparent icon button (no shared group pill), matching the+ design exactly: rest color is muted gray, active/enabled color+ is the accent green. */}+ <HudSystemAudioButton+ enabled={systemAudioEnabled}+ disabled={controlsLocked}+ label={+ systemAudioEnabled ? t("audio.disableSystemAudio") : t("audio.enableSystemAudio")}- aria-label={- saving- ? t("recording.saving")- : hasSelectedSource || recording- ? selectedSource- : t("recording.selectSource")- }- style={{ flex: "0 0 auto" }}- >- <div- className={`flex items-center justify-center ${recording || saving ? "gap-1.5" : ""}`}- >- {saving ? (- <div className="animate-spin flex items-center justify-center">- {getIcon("spinner", "text-[#f87171]")}- </div>- ) : (- <RecordGlyph- recording={recording}- className={paused ? "text-amber-400" : "text-[#f87171]"}- />- )}- {saving && (- <span className="text-[#f87171] text-xs font-semibold select-none">- {t("recording.saving")}- </span>- )}- {recording && (- <span- className={`${paused ? "text-amber-400" : "text-[#f87171]"} inline-block w-[34px] text-left text-xs font-semibold tabular-nums`}- >- {formatTimePadded(elapsedSeconds)}- </span>- )}- </div>- </button>- </Tooltip>-- {!recording && (- <Tooltip content={t("tooltips.openStudio")}>- <button- data-testid="launch-open-studio-button"- disabled={saving}- className={`${hudIconBtnClasses} ${styles.electronNoDrag} ${saving ? "opacity-30 cursor-not-allowed pointer-events-none" : ""}`}- onClick={() => !saving && window.electronAPI.switchToEditor()}- >- <OpenInEditorIcon />- </button>- </Tooltip>- )}-- {recording && (+ onClick={toggleSystemAudio}+ />+ {/* The gear configures the two toggles beside it, so the three sit+ closer together than the bar's normal control spacing — proximity+ is the design's own grouping device, no extra furniture needed. */}<div- className={`flex items-center gap-0.5 ${trayLayout === "vertical" ? "flex-col" : ""} ${styles.electronNoDrag}`}+ className={`${styles.hudControlGroup} ${isVertical ? styles.hudControlGroupVertical : ""}`}>- {canPauseRecording && (- <Tooltip- content={paused ? t("tooltips.resumeRecording") : t("tooltips.pauseRecording")}- >- <button- className={hudAuxIconBtnClasses}- onClick={() => !saving && togglePaused()}- disabled={saving}- >- {getIcon(- paused ? "resume" : "pause",- paused ? "text-amber-400" : "text-white/60",- )}- </button>- </Tooltip>- )}- <Tooltip content={t("tooltips.restartRecording")}>- <button- className={hudAuxIconBtnClasses}- onClick={() => !saving && restartRecording()}- disabled={saving}- >- {getIcon("restart", "text-white/60")}- </button>- </Tooltip>- <Tooltip content={t("tooltips.cancelRecording")}>- <button- className={hudAuxIconBtnClasses}- onClick={() => !saving && cancelRecording()}- disabled={saving}- >- {getIcon("cancel", "text-white/60")}- </button>- </Tooltip>+ <HudMicButton+ enabled={microphoneEnabled}+ disabled={controlsLocked}+ label={microphoneEnabled ? t("audio.disableMicrophone") : t("audio.enableMicrophone")}+ onClick={toggleMicrophone}+ />+ <HudCameraButton+ enabled={webcamEnabled}+ disabled={controlsLocked}+ label={webcamEnabled ? t("webcam.disableWebcam") : t("webcam.enableWebcam")}+ onClick={toggleWebcam}+ />+ <HudSettingsButton+ buttonRef={settingsTriggerRef}+ disabled={controlsLocked}+ expanded={isDeviceSettingsOpen}+ label={t("deviceSettings.title")}+ onClick={toggleDeviceSettings}+ /></div>- )}+ {supportsCursorModeToggle && (+ <HudCursorButton+ editableOverlay={cursorCaptureMode === "editable-overlay"}+ disabled={controlsLocked}+ label={+ cursorCaptureMode === "editable-overlay"+ ? t("cursor.useSystemCursor")+ : t("cursor.useEditableCursor")+ }+ onClick={toggleCursorMode}+ />+ )}- {!isLinuxHud && (- <Tooltip content={t("tooltips.openNotes")}>- <button- type="button"- aria-label={t("tooltips.openNotes")}- disabled={saving}- className={`${hudIconBtnClasses} ${styles.electronNoDrag} ${saving ? "opacity-30 cursor-not-allowed pointer-events-none" : ""}`}- onClick={() => !saving && window.electronAPI.openNotes()}- >- <NotepadText size={ICON_SIZE} />- </button>- </Tooltip>- )}+ <HudDivider vertical={isVertical} />- <span- className={`${styles.hudDivider} ${trayLayout === "vertical" ? styles.hudDividerVertical : styles.hudDividerHorizontal}`}- aria-hidden- />+ <HudRecordButton+ recording={recording}+ paused={paused}+ saving={saving}+ elapsedSeconds={elapsedSeconds}+ label={recordLabel}+ savingLabel={t("recording.saving")}+ onClick={handleRecordClick}+ />- {/* Right sidebar controls */}- <div- className={`${trayLayout === "vertical" ? hudSidebarVerticalClasses : hudSidebarClasses} ${styles.electronNoDrag}`}- >- <div className={`${styles.languageMenuContainer} ${styles.electronNoDrag}`}>- <button- ref={languageTriggerRef}- type="button"- aria-label={activeLanguageLabel}- aria-expanded={isLanguageMenuOpen}- aria-haspopup="menu"+ {!recording && (+ <HudStudioButtondisabled={saving}- onClick={() => {- if (saving) return;- setActiveDeviceMenu(null);- setIsLanguageMenuOpen((open) => !open);- }}- title={activeLanguageLabel}- className={`flex h-[34px] items-center rounded-[10px] border-0 bg-transparent text-[#828c99] transition-all duration-150 hover:bg-[#1a1e25] hover:text-[#e9edf3] ${- trayLayout === "vertical" ? "w-[34px] justify-center px-0" : "gap-1.5 px-2.5"- } ${styles.electronNoDrag} ${saving ? "opacity-30 cursor-not-allowed pointer-events-none" : ""}`}- >- <Languages size={16} className="shrink-0" />- <span- className={`${trayLayout === "vertical" ? "sr-only" : ""} font-mono text-[11px] font-semibold tracking-wide text-[#f5f7fa]`}- >- {languageCode}- </span>- </button>- </div>+ label={t("tooltips.openStudio")}+ onClick={openStudio}+ />+ )}- {isLanguageMenuOpen- ? createPortal(- <div- ref={setLanguageMenuPanelEl}- data-hud-interactive="true"- role="menu"- className={`${styles.languageMenuPanel} ${styles.languageMenuScroll} ${styles.electronNoDrag}`}- style={- {- WebkitAppRegion: "no-drag",- pointerEvents: "auto",- right: `${languageMenuStyle.right}px`,- bottom: `${languageMenuStyle.bottom}px`,- maxHeight: `${languageMenuStyle.maxHeight}px`,- } as React.CSSProperties- }- onPointerDown={(event) => event.stopPropagation()}- onPointerEnter={() => setHudMouseEventsEnabled(true)}- onPointerMove={() => setHudMouseEventsEnabled(true)}- onWheel={(event) => {- setHudMouseEventsEnabled(true);- event.stopPropagation();- }}- >- {availableLocales.map((loc) => (- <button- key={loc}- type="button"- role="menuitemradio"- aria-checked={loc === locale}- onClick={() => {- setLocale(loc);- resolveSystemLocaleSuggestion();- setIsLanguageMenuOpen(false);- }}- className={`${styles.languageMenuItem} ${loc === locale ? styles.languageMenuItemActive : ""}`}- >- <span className="truncate">{getLocaleName(loc)}</span>- {loc === locale ? <Check size={11} className="text-white/85" /> : null}- </button>- ))}- </div>,- document.body,- )- : null}-- <span- className={`${styles.hudDivider} ${trayLayout === "vertical" ? styles.hudDividerVertical : styles.hudDividerHorizontal}`}- aria-hidden- />+ {recording && (+ <HudRecordingControls+ vertical={isVertical}+ paused={paused}+ saving={saving}+ canPause={canPauseRecording}+ pauseLabel={paused ? t("tooltips.resumeRecording") : t("tooltips.pauseRecording")}+ restartLabel={t("tooltips.restartRecording")}+ cancelLabel={t("tooltips.cancelRecording")}+ onTogglePause={togglePaused}+ onRestart={restartRecording}+ onCancel={cancelRecording}+ />+ )}- {/* Window controls */}+ {!isLinuxHud && (+ <HudNotesButton disabled={saving} label={t("tooltips.openNotes")} onClick={openNotes} />+ )}++ <HudDivider vertical={isVertical} />++ {/* Right sidebar controls */}<div- className={`flex items-center gap-[5px] ${trayLayout === "vertical" ? "flex-col" : ""}`}+ className={`flex items-center gap-[5px] ${isVertical ? "flex-col" : ""} ${styles.electronNoDrag}`}>- <button- className={windowBtnClasses}- title={t("tooltips.hideHUD")}- onClick={sendHudOverlayHide}+ <HudLanguageButton+ buttonRef={languageTriggerRef}+ vertical={isVertical}+ code={languageCode}+ label={activeLanguageLabel}disabled={saving}- >- {getIcon("minimize")}- </button>- <button- className={closeBtnClasses}- title={t("tooltips.closeApp")}- onClick={sendHudOverlayClose}+ expanded={isLanguageMenuOpen}+ onClick={toggleLanguageMenu}+ />++ <HudDivider vertical={isVertical} />++ <HudWindowControls+ vertical={isVertical}disabled={saving}- >- {getIcon("close")}- </button>+ hideLabel={t("tooltips.hideHUD")}+ closeLabel={t("tooltips.closeApp")}+ onHide={sendHudOverlayHide}+ onClose={sendHudOverlayClose}+ /></div></div>++ {(isPopoverOpen || hasNotices) && (+ // column-reverse: first child sits closest to the bar.+ <div className={styles.hudAbove}>+ {isDeviceSettingsOpen && (+ <HudDeviceSettings+ micDevices={micDevices}+ cameraDevices={cameraDevices}+ activeMicId={microphoneDeviceId || selectedMicId}+ activeCameraId={webcamDeviceId || selectedCameraId}+ cameraLoading={isCameraDevicesLoading}+ cameraError={cameraDevicesError}+ labels={deviceSettingsLabels}+ onSelectMic={handleSelectMicDevice}+ onSelectCamera={handleSelectCameraDevice}+ onClose={closeDeviceSettings}+ panelRef={setPopoverEl}+ />+ )}++ {isLanguageMenuOpen && (+ <HudLanguageMenu+ locales={AVAILABLE_LOCALES}+ activeLocale={locale}+ getName={getLocaleName as (loc: string) => string}+ onSelect={handleSelectLocale}+ panelRef={setPopoverEl}+ onEnsureInteractive={enableHudMouseEvents}+ />+ )}++ {hasNotices && (+ <div+ ref={setHudNoticesEl}+ data-testid="hud-notice-column"+ className={styles.hudNoticeColumn}+ >+ {systemLocaleSuggestion && (+ <HudNotice+ title={t("systemLanguagePrompt.title")}+ description={t("systemLanguagePrompt.description", {+ language: suggestedLanguageName,+ })}+ dismissLabel={t("systemLanguagePrompt.keepDefault")}+ confirmLabel={t("systemLanguagePrompt.switch", {+ language: suggestedLanguageName,+ })}+ onDismiss={dismissSystemLocaleSuggestion}+ onConfirm={acceptSystemLocaleSuggestion}+ />+ )}++ {softwareEncoderFallbackNoticeVisible && (+ <HudNotice+ title={t("softwareEncoderFallback.title")}+ description={t("softwareEncoderFallback.description")}+ dismissLabel={t("softwareEncoderFallback.dontShowAgain")}+ confirmLabel={t("softwareEncoderFallback.dismiss")}+ onDismiss={dismissSoftwareFallbackForever}+ onConfirm={dismissSoftwareFallbackOnce}+ />+ )}+ </div>+ )}+ </div>+ )}</div></div>);diff --git a/src/components/launch/hudGeometry.test.ts b/src/components/launch/hudGeometry.test.tsnew file mode 100644index 000000000..167ad7f13--- /dev/null+++ b/src/components/launch/hudGeometry.test.ts@@ -0,0 +1,106 @@+import { describe, expect, it } from "vitest";+import {+ computeHudBarMaxHeight,+ computeHudModalMaxHeight,+ computeHudPopoverMaxHeight,+ computeHudWindowSize,+ HUD_BAR_BOTTOM,+ HUD_EDGE_SLACK,+ HUD_MODAL_MAX_HEIGHT,+ HUD_POPOVER_GAP,+ HUD_POPOVER_MAX_HEIGHT,+ HUD_POPOVER_MIN_HEIGHT,+ HUD_STACK_WIDTH,+} from "./hudGeometry";++const SCREEN = 1080;++function size(barWidth: number, barHeight: number, noticeHeight = 0, availableHeight = SCREEN) {+ return computeHudWindowSize({+ barWidth,+ barHeight,+ noticeHeight,+ availableHeight,+ // What LaunchWindow reserves: the tallest surface that can float above the+ // bar, regardless of which one is currently open.+ stackMaxHeight: Math.max(+ computeHudPopoverMaxHeight(barHeight, availableHeight),+ computeHudModalMaxHeight(barHeight, availableHeight),+ ),+ });+}++describe("computeHudWindowSize", () => {+ it("reserves the popover's full height whether or not one is open", () => {+ // The whole point of reserving: the window is already big enough for a+ // popover before the first one is ever opened, so opening one can't resize+ // (and therefore can't move or flicker) the overlay.+ const { required } = size(520, 48);+ expect(required.height).toBeGreaterThanOrEqual(+ HUD_BAR_BOTTOM + 48 + HUD_POPOVER_GAP + HUD_POPOVER_MAX_HEIGHT,+ );+ });++ it("reserves enough for the tallest surface, the device-settings panel", () => {+ // The panel is taller than a popover. If the reserve only covered popovers,+ // opening it would grow the window — and because the stack is bottom+ // anchored, that shifts the content and shows up as position judder.+ const { required } = size(520, 48);+ expect(required.height).toBeGreaterThanOrEqual(+ HUD_BAR_BOTTOM + 48 + HUD_POPOVER_GAP + HUD_MODAL_MAX_HEIGHT,+ );+ });++ it("reserves room for the widest floating panel even when the bar is narrow", () => {+ const { required } = size(48, 520);+ expect(required.width).toBeGreaterThanOrEqual(HUD_STACK_WIDTH + HUD_EDGE_SLACK * 2);+ });++ it("absorbs bar growth without needing a bigger window", () => {+ // Recording adds a timer and three aux buttons to the bar. That must fit in+ // the already-granted window, otherwise every record start is a resize.+ const idle = size(520, 48);+ const recording = size(640, 48);+ expect(recording.required.width).toBeLessThanOrEqual(idle.granted.width);+ expect(recording.required.height).toBeLessThanOrEqual(idle.granted.height);+ });++ it("grows for a notice and shrinks back once it is gone", () => {+ const withNotice = size(520, 48, 140);+ const without = size(520, 48, 0);+ expect(withNotice.required.height).toBeGreaterThan(without.required.height);+ });++ it("never asks for more height than the display's work area", () => {+ const shortScreen = 700;+ const { required, granted } = size(48, 560, 0, shortScreen);+ expect(required.height).toBeLessThanOrEqual(shortScreen);+ expect(granted.height).toBeLessThanOrEqual(shortScreen);+ });+});++describe("computeHudPopoverMaxHeight", () => {+ it("caps at the design height when there is plenty of room", () => {+ expect(computeHudPopoverMaxHeight(48, SCREEN)).toBe(HUD_POPOVER_MAX_HEIGHT);+ });++ it("gives way to a tall vertical tray rather than pushing off screen", () => {+ const tall = computeHudPopoverMaxHeight(620, 800);+ expect(tall).toBeLessThan(HUD_POPOVER_MAX_HEIGHT);+ expect(tall).toBeGreaterThanOrEqual(HUD_POPOVER_MIN_HEIGHT);+ });++ it("never returns a height a popover couldn't be usable at", () => {+ expect(computeHudPopoverMaxHeight(2000, 800)).toBe(HUD_POPOVER_MIN_HEIGHT);+ });+});++describe("computeHudBarMaxHeight", () => {+ it("leaves room below the screen height for a popover", () => {+ const max = computeHudBarMaxHeight(SCREEN);+ expect(max).toBeLessThan(SCREEN);+ expect(max + HUD_BAR_BOTTOM + HUD_POPOVER_GAP + HUD_POPOVER_MIN_HEIGHT).toBeLessThanOrEqual(+ SCREEN,+ );+ });+});diff --git a/src/components/launch/hudGeometry.ts b/src/components/launch/hudGeometry.tsnew file mode 100644index 000000000..e59c3cd1c--- /dev/null+++ b/src/components/launch/hudGeometry.ts@@ -0,0 +1,151 @@+/**+ * Geometry for the HUD overlay window.+ *+ * The HUD lives in a transparent, click-through BrowserWindow whose size the+ * renderer drives over IPC. The old approach *discovered* the size it needed by+ * measuring whatever happened to be on screen and growing to fit, which closed a+ * feedback loop: a native resize changes the viewport, viewport-sized elements+ * re-layout, the ResizeObserver fires again, and another resize goes out. Ten+ * animation frames per resize turned that into visible flicker, and the first+ * open of every popover was a jump because its space had never been seen before.+ *+ * So: reserve instead of discover. The bar is the only thing whose size can't be+ * predicted (localized labels, source names), so it alone is measured. Everything+ * that floats above it has a fixed width and a capped, internally-scrolling+ * height, and that space is reserved in the window from the very first frame.+ * Opening or closing a popover, or a device list changing length, then costs+ * exactly zero native resizes.+ *+ * Nothing here may depend on `window.innerWidth/innerHeight`: that is the edge+ * the loop used to close on. Screen-derived values (`screen.availHeight`) are+ * fine — they don't change when the window does.+ */++/** Gap between the window's bottom edge and the bar's bottom edge. */+export const HUD_BAR_BOTTOM = 20;+/** Hard minimum breathing room on every edge, so drop shadows aren't clipped. */+export const HUD_EDGE_SLACK = 24;+/** Vertical gap between the bar and the popover stack floating above it. */+export const HUD_POPOVER_GAP = 8;+/** Gap between stacked floating elements (popover, notices). */+export const HUD_STACK_GAP = 10;+/** Width of the device / language popovers. */+export const HUD_POPOVER_WIDTH = 220;+/** Width of the top notices (locale suggestion, software-encoder fallback). */+export const HUD_NOTICE_WIDTH = 360;+/**+ * Widest thing that can ever float above the bar. Always reserved, so a popover+ * or a notice appearing never changes the window's width.+ */+export const HUD_STACK_WIDTH = Math.max(HUD_POPOVER_WIDTH, HUD_NOTICE_WIDTH);+/** Cap on any popover's height; past this it scrolls internally. */+export const HUD_POPOVER_MAX_HEIGHT = 320;+/** Floor for the popover cap on very short screens. */+export const HUD_POPOVER_MIN_HEIGHT = 140;+/**+ * The device-settings panel is the tallest floating surface, so it is what the+ * window reserves room for — permanently, whether or not it happens to be open.+ * Sizing the reserve to what is currently open would mean the window grows on+ * open, and because the stack is bottom-anchored, growing upward shifts all the+ * content down in window coordinates; the renderer repaints that a frame behind+ * the native resize, which reads as position judder. Its width matches+ * HUD_STACK_WIDTH so it never affects the window's width either.+ */+export const HUD_MODAL_MAX_HEIGHT = 470;+export const HUD_MODAL_MIN_HEIGHT = 200;+/**+ * Slack granted *beyond* what is strictly required, on each axis. This is pure+ * hysteresis: the bar can grow by this much (recording controls appearing, a+ * longer source name) before the window has to resize at all, which is what+ * keeps the common interactions completely free of native window churn.+ */+export const HUD_GROWTH_RESERVE = 120;+/** Floor for the window itself, in case the bar measures as ~nothing. */+export const HUD_MIN_WINDOW_WIDTH = 220;++export interface HudSize {+ width: number;+ height: number;+}++export interface HudSizeInput {+ barWidth: number;+ barHeight: number;+ /** 0 when no notice is on screen. */+ noticeHeight: number;+ /** Work-area height of the display, NOT the window height. */+ availableHeight: number;+ /** Room reserved above the bar: the tallest surface that can float there. */+ stackMaxHeight: number;+}++/** Room left above the bar for whatever is floating there. */+function stackRoom(barHeight: number, availableHeight: number): number {+ return availableHeight - HUD_BAR_BOTTOM - barHeight - HUD_POPOVER_GAP - HUD_EDGE_SLACK * 2;+}++/**+ * How tall a popover may be given the room left above the bar. The vertical tray+ * can be several hundred pixels tall, so on a short screen the popover has to+ * give way rather than push the window off the top of the display.+ */+export function computeHudPopoverMaxHeight(barHeight: number, availableHeight: number): number {+ const room = stackRoom(barHeight, availableHeight);+ return Math.round(Math.min(HUD_POPOVER_MAX_HEIGHT, Math.max(HUD_POPOVER_MIN_HEIGHT, room)));+}++/** Same, for the taller device-settings panel. */+export function computeHudModalMaxHeight(barHeight: number, availableHeight: number): number {+ const room = stackRoom(barHeight, availableHeight);+ return Math.round(Math.min(HUD_MODAL_MAX_HEIGHT, Math.max(HUD_MODAL_MIN_HEIGHT, room)));+}++/** Tallest the bar itself is allowed to get before it scrolls internally. */+export function computeHudBarMaxHeight(availableHeight: number): number {+ return Math.round(+ Math.max(+ HUD_POPOVER_MIN_HEIGHT,+ availableHeight -+ HUD_BAR_BOTTOM -+ HUD_POPOVER_GAP -+ HUD_POPOVER_MIN_HEIGHT -+ HUD_EDGE_SLACK * 2,+ ),+ );+}++/**+ * `required` is the smallest window that shows everything without clipping;+ * `granted` is what we actually ask for. The gap between them is the hysteresis+ * that stops small content changes from resizing the window.+ */+export function computeHudWindowSize(input: HudSizeInput): {+ required: HudSize;+ granted: HudSize;+} {+ const stackWidth = Math.max(Math.ceil(input.barWidth), HUD_STACK_WIDTH);+ const requiredWidth = Math.max(HUD_MIN_WINDOW_WIDTH, stackWidth + HUD_EDGE_SLACK * 2);++ const noticeBlock = input.noticeHeight > 0 ? HUD_STACK_GAP + Math.ceil(input.noticeHeight) : 0;+ const rawHeight =+ HUD_BAR_BOTTOM ++ Math.ceil(input.barHeight) ++ HUD_POPOVER_GAP ++ Math.ceil(input.stackMaxHeight) ++ noticeBlock ++ HUD_EDGE_SLACK;++ // The main process clamps to the display's work area, so clamp here too:+ // otherwise the caller would record an allocation the window never actually+ // got, then skip a resize it genuinely needs later on.+ const ceiling = input.availableHeight > 0 ? input.availableHeight : Number.POSITIVE_INFINITY;+ const requiredHeight = Math.min(rawHeight, ceiling);++ return {+ required: { width: requiredWidth, height: requiredHeight },+ granted: {+ width: requiredWidth + HUD_GROWTH_RESERVE * 2,+ height: Math.min(rawHeight + HUD_GROWTH_RESERVE, ceiling),+ },+ };+}diff --git a/src/hooks/useMicrophoneDevices.ts b/src/hooks/useMicrophoneDevices.tsindex 4f40faca9..37591e669 100644--- a/src/hooks/useMicrophoneDevices.ts+++ b/src/hooks/useMicrophoneDevices.ts@@ -1,4 +1,4 @@-import { useEffect, useState } from "react";+import { useEffect, useRef, useState } from "react";export interface MicrophoneDevice {deviceId: string;@@ -11,6 +11,11 @@ export function useMicrophoneDevices(enabled: boolean = true) {const [selectedDeviceId, setSelectedDeviceId] = useState<string>("default");const [isLoading, setIsLoading] = useState(false);const [error, setError] = useState<string | null>(null);+ // Read through a ref rather than a dependency: `selectedDeviceId` is written by+ // this very effect, so depending on it re-ran the whole load — a second+ // getUserMedia() permission stream acquired and torn down on every open.+ const selectedDeviceIdRef = useRef(selectedDeviceId);+ selectedDeviceIdRef.current = selectedDeviceId;useEffect(() => {if (!enabled) {@@ -41,7 +46,9 @@ export function useMicrophoneDevices(enabled: boolean = true) {if (mounted) {setDevices(audioInputs);- if (selectedDeviceId === "default" && audioInputs.length > 0) {+ const currentId = selectedDeviceIdRef.current;+ const stillAvailable = audioInputs.some((d) => d.deviceId === currentId);+ if ((currentId === "default" || !stillAvailable) && audioInputs.length > 0) {setSelectedDeviceId(audioInputs[0].deviceId);}setIsLoading(false);@@ -69,7 +76,7 @@ export function useMicrophoneDevices(enabled: boolean = true) {mounted = false;navigator.mediaDevices.removeEventListener("devicechange", handleDeviceChange);};- }, [enabled, selectedDeviceId]);+ }, [enabled]);return {devices,diff --git a/src/i18n/locales/ar/launch.json b/src/i18n/locales/ar/launch.jsonindex 64c0fa750..37b1a4fb5 100644--- a/src/i18n/locales/ar/launch.json+++ b/src/i18n/locales/ar/launch.json@@ -74,5 +74,14 @@"description": "تعذّر تشغيل مرمّز GPU الافتراضي، لذا تحوّل OpenScreen إلى ترميز H.264 البرمجي. سيستمر التسجيل كالمعتاد، لكن استخدام المعالج قد يكون أعلى.","dismiss": "حسنًا","dontShowAgain": "عدم الإظهار مرة أخرى"+ },+ "deviceSettings": {+ "title": "إعدادات الأجهزة",+ "done": "تم",+ "micLevel": "مستوى الإدخال",+ "micHint": "تحدّث لاختبار الميكروفون",+ "noMicrophones": "لم يتم العثور على ميكروفون",+ "preview": "معاينة",+ "previewUnavailable": "المعاينة غير متاحة"}}diff --git a/src/i18n/locales/en/launch.json b/src/i18n/locales/en/launch.jsonindex 8175470f1..95039a859 100644--- a/src/i18n/locales/en/launch.json+++ b/src/i18n/locales/en/launch.json@@ -74,5 +74,14 @@"description": "The default GPU encoder failed to start, so OpenScreen fell back to software H.264 encoding. Recording should continue as normal, but CPU usage may be higher.","dismiss": "Got it","dontShowAgain": "Don't show again"+ },+ "deviceSettings": {+ "title": "Device settings",+ "done": "Done",+ "micLevel": "Input level",+ "micHint": "Speak to check your microphone",+ "noMicrophones": "No microphone found",+ "preview": "Preview",+ "previewUnavailable": "Preview unavailable"}}diff --git a/src/i18n/locales/es/launch.json b/src/i18n/locales/es/launch.jsonindex d1a48e262..a37123894 100644--- a/src/i18n/locales/es/launch.json+++ b/src/i18n/locales/es/launch.json@@ -74,5 +74,14 @@"description": "El codificador GPU predeterminado no pudo iniciarse, por lo que OpenScreen pasó a la codificación H.264 por software. La grabación debería continuar con normalidad, pero el uso de CPU puede ser mayor.","dismiss": "Entendido","dontShowAgain": "No volver a mostrar"+ },+ "deviceSettings": {+ "title": "Ajustes de dispositivos",+ "done": "Listo",+ "micLevel": "Nivel de entrada",+ "micHint": "Habla para probar tu micrófono",+ "noMicrophones": "No se encontró ningún micrófono",+ "preview": "Vista previa",+ "previewUnavailable": "Vista previa no disponible"}}diff --git a/src/i18n/locales/fr/launch.json b/src/i18n/locales/fr/launch.jsonindex 76204a319..929a8c8db 100644--- a/src/i18n/locales/fr/launch.json+++ b/src/i18n/locales/fr/launch.json@@ -74,5 +74,14 @@"description": "L'encodeur GPU par défaut n'a pas pu démarrer, OpenScreen est donc passé à l'encodage H.264 logiciel. L'enregistrement devrait continuer normalement, mais l'utilisation du processeur peut être plus élevée.","dismiss": "Compris","dontShowAgain": "Ne plus afficher"+ },+ "deviceSettings": {+ "title": "Paramètres des périphériques",+ "done": "Terminé",+ "micLevel": "Niveau d'entrée",+ "micHint": "Parlez pour tester votre microphone",+ "noMicrophones": "Aucun microphone détecté",+ "preview": "Aperçu",+ "previewUnavailable": "Aperçu indisponible"}}diff --git a/src/i18n/locales/it/launch.json b/src/i18n/locales/it/launch.jsonindex e6b190cf1..89eb8c9e5 100644--- a/src/i18n/locales/it/launch.json+++ b/src/i18n/locales/it/launch.json@@ -74,5 +74,14 @@"description": "L'encoder GPU predefinito non si è avviato, quindi OpenScreen è passato alla codifica H.264 software. La registrazione dovrebbe continuare normalmente, ma l'uso della CPU potrebbe essere più alto.","dismiss": "Ho capito","dontShowAgain": "Non mostrare più"+ },+ "deviceSettings": {+ "title": "Impostazioni dispositivi",+ "done": "Fatto",+ "micLevel": "Livello di ingresso",+ "micHint": "Parla per testare il microfono",+ "noMicrophones": "Nessun microfono trovato",+ "preview": "Anteprima",+ "previewUnavailable": "Anteprima non disponibile"}}diff --git a/src/i18n/locales/ja-JP/launch.json b/src/i18n/locales/ja-JP/launch.jsonindex 313af1e66..08d4b2349 100644--- a/src/i18n/locales/ja-JP/launch.json+++ b/src/i18n/locales/ja-JP/launch.json@@ -74,5 +74,14 @@"description": "既定のGPUエンコーダーを開始できなかったため、OpenScreenはソフトウェアH.264エンコードに切り替えました。録画はそのまま続行されますが、CPU使用率が高くなる場合があります。","dismiss": "OK","dontShowAgain": "今後表示しない"+ },+ "deviceSettings": {+ "title": "デバイス設定",+ "done": "完了",+ "micLevel": "入力レベル",+ "micHint": "マイクをテストするには話してください",+ "noMicrophones": "マイクが見つかりません",+ "preview": "プレビュー",+ "previewUnavailable": "プレビューを利用できません"}}diff --git a/src/i18n/locales/ko-KR/launch.json b/src/i18n/locales/ko-KR/launch.jsonindex de214c4d0..00c0c3625 100644--- a/src/i18n/locales/ko-KR/launch.json+++ b/src/i18n/locales/ko-KR/launch.json@@ -74,5 +74,14 @@"description": "기본 GPU 인코더를 시작할 수 없어 OpenScreen이 소프트웨어 H.264 인코딩으로 전환했습니다. 녹화는 정상적으로 계속되지만 CPU 사용량이 높아질 수 있습니다.","dismiss": "확인","dontShowAgain": "다시 표시하지 않음"+ },+ "deviceSettings": {+ "title": "장치 설정",+ "done": "완료",+ "micLevel": "입력 레벨",+ "micHint": "마이크를 테스트하려면 말해 보세요",+ "noMicrophones": "마이크를 찾을 수 없습니다",+ "preview": "미리 보기",+ "previewUnavailable": "미리 보기를 사용할 수 없습니다"}}diff --git a/src/i18n/locales/pt-BR/launch.json b/src/i18n/locales/pt-BR/launch.jsonindex 59bb77265..97733fb6e 100644--- a/src/i18n/locales/pt-BR/launch.json+++ b/src/i18n/locales/pt-BR/launch.json@@ -74,5 +74,14 @@"description": "O codificador de GPU padrão não pôde ser iniciado, então o OpenScreen passou a usar a codificação H.264 por software. A gravação deve continuar normalmente, mas o uso da CPU pode ser maior.","dismiss": "Entendi","dontShowAgain": "Não mostrar novamente"+ },+ "deviceSettings": {+ "title": "Configurações de dispositivos",+ "done": "Concluído",+ "micLevel": "Nível de entrada",+ "micHint": "Fale para testar seu microfone",+ "noMicrophones": "Nenhum microfone encontrado",+ "preview": "Pré-visualização",+ "previewUnavailable": "Pré-visualização indisponível"}}diff --git a/src/i18n/locales/ru/launch.json b/src/i18n/locales/ru/launch.jsonindex 0302fb8f1..d9cddeaf1 100644--- a/src/i18n/locales/ru/launch.json+++ b/src/i18n/locales/ru/launch.json@@ -74,5 +74,14 @@"description": "Стандартный GPU-кодировщик не запустился, поэтому OpenScreen перешёл на программное кодирование H.264. Запись продолжится как обычно, но нагрузка на процессор может быть выше.","dismiss": "Понятно","dontShowAgain": "Больше не показывать"+ },+ "deviceSettings": {+ "title": "Настройки устройств",+ "done": "Готово",+ "micLevel": "Уровень входа",+ "micHint": "Скажите что-нибудь, чтобы проверить микрофон",+ "noMicrophones": "Микрофон не найден",+ "preview": "Предпросмотр",+ "previewUnavailable": "Предпросмотр недоступен"}}diff --git a/src/i18n/locales/tr/launch.json b/src/i18n/locales/tr/launch.jsonindex ad6431e39..e1d6593a3 100644--- a/src/i18n/locales/tr/launch.json+++ b/src/i18n/locales/tr/launch.json@@ -74,5 +74,14 @@"description": "Varsayılan GPU kodlayıcı başlatılamadığı için OpenScreen yazılım tabanlı H.264 kodlamasına geçti. Kayıt normal şekilde devam eder, ancak CPU kullanımı daha yüksek olabilir.","dismiss": "Anladım","dontShowAgain": "Bir daha gösterme"+ },+ "deviceSettings": {+ "title": "Cihaz ayarları",+ "done": "Tamam",+ "micLevel": "Giriş seviyesi",+ "micHint": "Mikrofonunuzu test etmek için konuşun",+ "noMicrophones": "Mikrofon bulunamadı",+ "preview": "Önizleme",+ "previewUnavailable": "Önizleme kullanılamıyor"}}diff --git a/src/i18n/locales/vi/launch.json b/src/i18n/locales/vi/launch.jsonindex 04c41a8ff..70bbdd42c 100644--- a/src/i18n/locales/vi/launch.json+++ b/src/i18n/locales/vi/launch.json@@ -74,5 +74,14 @@"description": "Bộ mã hóa GPU mặc định không khởi động được, nên OpenScreen đã chuyển sang mã hóa H.264 bằng phần mềm. Quá trình ghi vẫn tiếp tục bình thường, nhưng mức sử dụng CPU có thể cao hơn.","dismiss": "Đã hiểu","dontShowAgain": "Không hiển thị lại"+ },+ "deviceSettings": {+ "title": "Cài đặt thiết bị",+ "done": "Xong",+ "micLevel": "Mức đầu vào",+ "micHint": "Hãy nói để kiểm tra micrô",+ "noMicrophones": "Không tìm thấy micrô",+ "preview": "Xem trước",+ "previewUnavailable": "Không thể xem trước"}}diff --git a/src/i18n/locales/zh-CN/launch.json b/src/i18n/locales/zh-CN/launch.jsonindex 416e50892..232c3568e 100644--- a/src/i18n/locales/zh-CN/launch.json+++ b/src/i18n/locales/zh-CN/launch.json@@ -74,5 +74,14 @@"description": "默认 GPU 编码器启动失败,OpenScreen 已改用软件 H.264 编码。录制会正常继续,但 CPU 占用可能更高。","dismiss": "知道了","dontShowAgain": "不再提示"+ },+ "deviceSettings": {+ "title": "设备设置",+ "done": "完成",+ "micLevel": "输入音量",+ "micHint": "说话以测试麦克风",+ "noMicrophones": "未找到麦克风",+ "preview": "预览",+ "previewUnavailable": "预览不可用"}}diff --git a/src/i18n/locales/zh-TW/launch.json b/src/i18n/locales/zh-TW/launch.jsonindex 099324a34..73d8a99c5 100644--- a/src/i18n/locales/zh-TW/launch.json+++ b/src/i18n/locales/zh-TW/launch.json@@ -74,5 +74,14 @@"description": "預設 GPU 編碼器啟動失敗,OpenScreen 已改用軟體 H.264 編碼。錄製會照常繼續,但 CPU 使用率可能較高。","dismiss": "知道了","dontShowAgain": "不再顯示"+ },+ "deviceSettings": {+ "title": "裝置設定",+ "done": "完成",+ "micLevel": "輸入音量",+ "micHint": "說話以測試麥克風",+ "noMicrophones": "找不到麥克風",+ "preview": "預覽",+ "previewUnavailable": "預覽無法使用"}}