Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
Enable full window controls in compact onboarding (#1857)
void3890f0f37b58
diff --git a/src/components/WindowControls.tsx b/src/components/WindowControls.tsxindex da77cbad6..13571467b 100644--- a/src/components/WindowControls.tsx+++ b/src/components/WindowControls.tsx@@ -1,58 +1,24 @@-import { useEffect, useState } from "react";import { useTranslation } from "react-i18next";import { Button } from "./ui/button";import { Minus, Square, X, Copy } from "lucide-react";+import { useWindowControls } from "../hooks/useWindowControls";export default function WindowControls() {const { t } = useTranslation();- const [isMaximized, setIsMaximized] = useState(false);+ const { isMaximized, minimize, toggleMaximize, close } = useWindowControls();- useEffect(() => {- let mounted = true;-- const syncIsMaximized = async () => {- try {- const maximized = await window.electronAPI?.windowIsMaximized?.();- if (mounted) setIsMaximized(!!maximized);- } catch {}- };-- syncIsMaximized();- const intervalId = setInterval(syncIsMaximized, 1000);-- return () => {- mounted = false;- clearInterval(intervalId);- };- }, []);-- const handleMinimize = async () => {- try {- await window.electronAPI?.windowMinimize?.();- } catch {}- };-- const handleMaximize = async () => {- try {- await window.electronAPI?.windowMaximize?.();- const maximized = await window.electronAPI?.windowIsMaximized?.();- setIsMaximized(!!maximized);- } catch {}- };-- const handleClose = async () => {- try {- await window.electronAPI?.windowClose?.();- } catch {}- };+ const minimizeLabel = t("windowControls.minimize");+ const maximizeLabel = t(isMaximized ? "windowControls.restore" : "windowControls.maximize");+ const closeLabel = t("windowControls.close");return (<div className="flex items-center gap-1 pointer-events-auto"><Buttonvariant="ghost"size="icon"- onClick={handleMinimize}- title={t("windowControls.minimize")}+ onClick={minimize}+ title={minimizeLabel}+ aria-label={minimizeLabel}className="h-8 w-8"><Minus size={14} />@@ -60,8 +26,9 @@ export default function WindowControls() {<Buttonvariant="ghost"size="icon"- onClick={handleMaximize}- title={isMaximized ? t("windowControls.restore") : t("windowControls.maximize")}+ onClick={toggleMaximize}+ title={maximizeLabel}+ aria-label={maximizeLabel}className="h-8 w-8">{isMaximized ? <Copy size={14} /> : <Square size={12} />}@@ -69,9 +36,10 @@ export default function WindowControls() {<Buttonvariant="ghost"size="icon"- onClick={handleClose}+ onClick={close}className="h-8 w-8 hover:text-destructive hover:bg-destructive/10"- title={t("windowControls.close")}+ title={closeLabel}+ aria-label={closeLabel}><X size={14} /></Button>diff --git a/src/components/onboarding/OnboardingShell.tsx b/src/components/onboarding/OnboardingShell.tsxindex 57ee457ab..2c703c988 100644--- a/src/components/onboarding/OnboardingShell.tsx+++ b/src/components/onboarding/OnboardingShell.tsx@@ -1,9 +1,10 @@-import { useEffect, useState, type CSSProperties, type ReactNode } from "react";+import type { CSSProperties, ReactNode } from "react";import type { OnboardingProgressState } from "./flow";import { Copy, Minus, Square, Undo2, X } from "lucide-react";import { Button } from "../ui/button";import { useTranslation } from "react-i18next";import { getPlatform } from "../../utils/platform";+import { useWindowControls } from "../../hooks/useWindowControls";// Imported (not referenced by path) so Vite fingerprints it and it resolves// under the packaged app's file:// origin. See .onboarding-compact-hero.import heroDither from "@/assets/onboarding-hero-dither.webp";@@ -42,59 +43,18 @@ interface CompactOnboardingFrameProps {}/**- * Minimise/close for the frameless window on Windows and Linux — macOS shows- * its native traffic lights instead (the window manager keeps them visible on- * the expanded scaffold). Close hides to the tray; the persisted session- * resumes the flow on reopen, so this is never a way to lose progress.- *- * Compact keeps only minimise/close because its fixed card cannot resize.- * Expanded adds maximize/restore alongside them.+ * Window controls for the frameless window on Windows and Linux — macOS uses+ * its native traffic lights, so OnboardingShell skips rendering this there.+ * Close hides to the tray; the persisted session resumes the flow on reopen,+ * so this is never a way to lose progress.*/-function OnboardingWindowControls({ compact }: { compact: boolean }) {+function OnboardingWindowControls() {const { t } = useTranslation();- const [isMaximized, setIsMaximized] = useState(false);- const platform = getPlatform();-- useEffect(() => {- if (compact || platform === "darwin") return;- let mounted = true;- const syncIsMaximized = async (): Promise<void> => {- try {- const maximized = await window.electronAPI?.windowIsMaximized?.();- if (mounted) setIsMaximized(Boolean(maximized));- } catch {}- };-- void syncIsMaximized();- const intervalId = window.setInterval(syncIsMaximized, 1000);- return () => {- mounted = false;- window.clearInterval(intervalId);- };- }, [compact, platform]);-- const handleMinimize = async (): Promise<void> => {- try {- await window.electronAPI?.windowMinimize?.();- } catch {}- };-- const handleMaximize = async (): Promise<void> => {- try {- await window.electronAPI?.windowMaximize?.();- const maximized = await window.electronAPI?.windowIsMaximized?.();- setIsMaximized(Boolean(maximized));- } catch {}- };-- const handleClose = async (): Promise<void> => {- try {- await window.electronAPI?.windowClose?.();- } catch {}- };-- if (platform === "darwin") return null;+ const { isMaximized, minimize, toggleMaximize, close } = useWindowControls();+ const minimizeLabel = t("windowControls.minimize");+ const maximizeLabel = t(isMaximized ? "windowControls.restore" : "windowControls.maximize");+ const closeLabel = t("windowControls.close");const buttonClass ="inline-flex size-8 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 text-[var(--onboarding-text-secondary)] hover:bg-[var(--onboarding-surface-tertiary)] focus-visible:ring-[color-mix(in_srgb,var(--onboarding-accent)_30%,transparent)]";@@ -105,30 +65,31 @@ function OnboardingWindowControls({ compact }: { compact: boolean }) {><buttontype="button"- onClick={handleMinimize}- title={t("windowControls.minimize")}+ onClick={minimize}+ title={minimizeLabel}+ aria-label={minimizeLabel}className={buttonClass}><Minus className="size-4" aria-hidden="true" /></button>- {!compact && (- <button- type="button"- onClick={handleMaximize}- title={t(isMaximized ? "windowControls.restore" : "windowControls.maximize")}- className={buttonClass}- >- {isMaximized ? (- <Copy className="size-4" aria-hidden="true" />- ) : (- <Square className="size-3.5" aria-hidden="true" />- )}- </button>- )}<buttontype="button"- onClick={handleClose}- title={t("windowControls.close")}+ onClick={toggleMaximize}+ title={maximizeLabel}+ aria-label={maximizeLabel}+ className={buttonClass}+ >+ {isMaximized ? (+ <Copy className="size-4" aria-hidden="true" />+ ) : (+ <Square className="size-3.5" aria-hidden="true" />+ )}+ </button>+ <button+ type="button"+ onClick={close}+ title={closeLabel}+ aria-label={closeLabel}className={buttonClass}><X className="size-4" aria-hidden="true" />@@ -250,10 +211,10 @@ export default function OnboardingShell({z-50. */}<divclassName="absolute inset-x-0 top-0 z-50 h-12"- style={{ WebkitAppRegion: "drag" } as React.CSSProperties}+ style={{ WebkitAppRegion: "drag" } as CSSProperties}aria-hidden="true"/>- <OnboardingWindowControls compact={compact} />+ {getPlatform() !== "darwin" && <OnboardingWindowControls />}<div// Normally nothing scrolls here: each step sizes itself to the window and@@ -378,7 +339,7 @@ export function CompactOnboardingFrame({{"--onboarding-hero-dither-light": `url(${heroDither})`,"--onboarding-hero-dither-dark": `url(${heroDitherDark})`,- } as React.CSSProperties+ } as CSSProperties}/>{showBrandMark && (diff --git a/src/helpers/windowManager.js b/src/helpers/windowManager.jsindex 9d479e1fc..72fb4c29f 100644--- a/src/helpers/windowManager.js+++ b/src/helpers/windowManager.js@@ -1434,14 +1434,14 @@ class WindowManager {dockManager.setControlPanelVisible(true);}- // Compact onboarding stays fixed-size; expanded onboarding can resize and- // maximize. Both modes remain minimizable and closable so a frameless window- // never traps the user in setup.+ // Compact onboarding starts at smaller bounds, but both modes expose the+ // complete window-control contract so a frameless window never traps the+ // user in setup._applyOnboardingWindowChrome(win, mode) {const expanded = mode === "expanded";- win.setResizable(expanded);+ win.setResizable(true);win.setMinimizable(true);- win.setMaximizable(expanded);+ win.setMaximizable(true);win.setClosable(true);win.setFullScreenable(false);// Floor at the mode's canonical size so no step renders below the bounds@@ -1454,7 +1454,7 @@ class WindowManager {Math.min(floor.height, workArea.height));if (process.platform === "darwin" && typeof win.setWindowButtonVisibility === "function") {- win.setWindowButtonVisibility(expanded);+ win.setWindowButtonVisibility(true);}}@@ -1464,8 +1464,9 @@ class WindowManager {if (!new Set(["compact", "expanded", "restore"]).has(mode)) return false;if (mode !== "restore" && (win.isFullScreen() || win.isMaximized())) {// Entering onboarding from a maximized/fullscreen control panel must not- // refuse: refusing leaves the native chrome (traffic lights, resize) on a- // window whose flow assumes it is locked to the canonical bounds.+ // refuse: each mode is applied at its canonical centered bounds, which+ // only take effect from a normal window state. Both modes stay+ // maximizable, so the user can simply maximize again afterwards.if (win.isFullScreen()) win.setFullScreen(false);if (win.isMaximized()) win.unmaximize();}diff --git a/src/hooks/useWindowControls.ts b/src/hooks/useWindowControls.tsnew file mode 100644index 000000000..7d0b8076c--- /dev/null+++ b/src/hooks/useWindowControls.ts@@ -0,0 +1,58 @@+import { useEffect, useState } from "react";++export interface UseWindowControlsReturn {+ isMaximized: boolean;+ minimize: () => Promise<void>;+ toggleMaximize: () => Promise<void>;+ close: () => Promise<void>;+}++/**+ * Shared state and handlers for the custom window-control buttons that+ * frameless windows render on Windows and Linux (macOS windows keep their+ * native traffic lights, so callers skip rendering there).+ */+export const useWindowControls = (): UseWindowControlsReturn => {+ const [isMaximized, setIsMaximized] = useState(false);++ useEffect(() => {+ let mounted = true;+ const syncIsMaximized = async (): Promise<void> => {+ try {+ const maximized = await window.electronAPI?.windowIsMaximized?.();+ if (mounted) setIsMaximized(Boolean(maximized));+ } catch {}+ };++ void syncIsMaximized();+ // Polled because maximize can also happen outside these buttons (Windows+ // snap, double-clicking the drag band) and no renderer event reports it.+ const intervalId = window.setInterval(syncIsMaximized, 1000);+ return () => {+ mounted = false;+ window.clearInterval(intervalId);+ };+ }, []);++ const minimize = async (): Promise<void> => {+ try {+ await window.electronAPI?.windowMinimize?.();+ } catch {}+ };++ const toggleMaximize = async (): Promise<void> => {+ try {+ await window.electronAPI?.windowMaximize?.();+ const maximized = await window.electronAPI?.windowIsMaximized?.();+ setIsMaximized(Boolean(maximized));+ } catch {}+ };++ const close = async (): Promise<void> => {+ try {+ await window.electronAPI?.windowClose?.();+ } catch {}+ };++ return { isMaximized, minimize, toggleMaximize, close };+};diff --git a/src/locales/de/translation.json b/src/locales/de/translation.jsonindex 64995a4ac..43d5651e0 100644--- a/src/locales/de/translation.json+++ b/src/locales/de/translation.json@@ -1001,7 +1001,7 @@"emailStep": {"checkingEmail": "E-Mail-Adresse wird überprüft...","continueWithEmail": "Weiter mit E-Mail",- "continueWithoutAccount": "OpenWhispr ohne Konto nutzen",+ "continueWithoutAccount": "Ohne Konto fortfahren","emailLabel": "E-Mail","emailPlaceholder": "[email protected]","useDifferentEmail": "Andere E-Mail-Adresse verwenden"diff --git a/src/locales/en/translation.json b/src/locales/en/translation.jsonindex 8e3940a32..8beff1c0f 100644--- a/src/locales/en/translation.json+++ b/src/locales/en/translation.json@@ -1001,7 +1001,7 @@"emailStep": {"checkingEmail": "Checking your email...","continueWithEmail": "Continue with email",- "continueWithoutAccount": "Use OpenWhispr without an account",+ "continueWithoutAccount": "Continue without an account","emailLabel": "Email","emailPlaceholder": "[email protected]","useDifferentEmail": "Use a different email"diff --git a/src/locales/es/translation.json b/src/locales/es/translation.jsonindex 39582c763..cc3b9ee56 100644--- a/src/locales/es/translation.json+++ b/src/locales/es/translation.json@@ -1001,7 +1001,7 @@"emailStep": {"checkingEmail": "Comprobando tu correo...","continueWithEmail": "Continuar con correo electrónico",- "continueWithoutAccount": "Usar OpenWhispr sin cuenta",+ "continueWithoutAccount": "Continuar sin cuenta","emailLabel": "Correo electrónico","emailPlaceholder": "[email protected]","useDifferentEmail": "Usar otro correo electrónico"diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.jsonindex 61102d779..1d3e8fe65 100644--- a/src/locales/fr/translation.json+++ b/src/locales/fr/translation.json@@ -1001,7 +1001,7 @@"emailStep": {"checkingEmail": "Vérification de votre adresse e-mail...","continueWithEmail": "Continuer avec l'e-mail",- "continueWithoutAccount": "Utiliser OpenWhispr sans compte",+ "continueWithoutAccount": "Continuer sans compte","emailLabel": "Adresse e-mail","emailPlaceholder": "[email protected]","useDifferentEmail": "Utiliser une autre adresse e-mail"diff --git a/src/locales/it/translation.json b/src/locales/it/translation.jsonindex bc512f9b9..66644c32b 100644--- a/src/locales/it/translation.json+++ b/src/locales/it/translation.json@@ -1002,7 +1002,7 @@"emailStep": {"checkingEmail": "Verifica dell'e-mail in corso...","continueWithEmail": "Continua con l'e-mail",- "continueWithoutAccount": "Usa OpenWhispr senza account",+ "continueWithoutAccount": "Continua senza account","emailLabel": "E-mail","emailPlaceholder": "[email protected]","useDifferentEmail": "Usa un'altra e-mail"diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.jsonindex 71a25bd7f..e5a18d670 100644--- a/src/locales/ja/translation.json+++ b/src/locales/ja/translation.json@@ -1002,7 +1002,7 @@"emailStep": {"checkingEmail": "メールアドレスを確認しています...","continueWithEmail": "メールで続ける",- "continueWithoutAccount": "アカウントなしで OpenWhispr を使う",+ "continueWithoutAccount": "アカウントなしで続ける","emailLabel": "メールアドレス","emailPlaceholder": "[email protected]","useDifferentEmail": "別のメールアドレスを使用"diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.jsonindex c29e71f6e..08bc9a90d 100644--- a/src/locales/pt/translation.json+++ b/src/locales/pt/translation.json@@ -981,7 +981,7 @@"emailStep": {"checkingEmail": "Verificando seu e-mail...","continueWithEmail": "Continuar com e-mail",- "continueWithoutAccount": "Usar o OpenWhispr sem conta",+ "continueWithoutAccount": "Continuar sem conta","emailLabel": "E-mail","emailPlaceholder": "[email protected]","useDifferentEmail": "Usar outro e-mail"diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.jsonindex 1c52a94eb..935257172 100644--- a/src/locales/ru/translation.json+++ b/src/locales/ru/translation.json@@ -1001,7 +1001,7 @@"emailStep": {"checkingEmail": "Проверяем адрес электронной почты...","continueWithEmail": "Продолжить с электронной почтой",- "continueWithoutAccount": "Использовать OpenWhispr без аккаунта",+ "continueWithoutAccount": "Продолжить без аккаунта","emailLabel": "Электронная почта","emailPlaceholder": "[email protected]","useDifferentEmail": "Использовать другой адрес"diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.jsonindex 9de63bc53..e470a85bf 100644--- a/src/locales/zh-CN/translation.json+++ b/src/locales/zh-CN/translation.json@@ -1001,7 +1001,7 @@"emailStep": {"checkingEmail": "正在检查您的邮箱...","continueWithEmail": "使用邮箱继续",- "continueWithoutAccount": "无需账户使用 OpenWhispr",+ "continueWithoutAccount": "无需账户,继续使用","emailLabel": "邮箱","emailPlaceholder": "[email protected]","useDifferentEmail": "使用其他邮箱"diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.jsonindex dabc56369..0ecc91c5b 100644--- a/src/locales/zh-TW/translation.json+++ b/src/locales/zh-TW/translation.json@@ -1001,7 +1001,7 @@"emailStep": {"checkingEmail": "正在檢查您的電子郵件...","continueWithEmail": "使用電子郵件繼續",- "continueWithoutAccount": "無需帳號使用 OpenWhispr",+ "continueWithoutAccount": "無需帳號,繼續使用","emailLabel": "電子郵件","emailPlaceholder": "[email protected]","useDifferentEmail": "使用其他電子郵件"diff --git a/test/components/onboardingCompatibility.test.js b/test/components/onboardingCompatibility.test.jsindex ec475c966..bf34f176b 100644--- a/test/components/onboardingCompatibility.test.js+++ b/test/components/onboardingCompatibility.test.js@@ -69,33 +69,31 @@ const screenContext = {request: async () => false,};-test("compact Linux onboarding keeps minimize and close controls", async (t) => {+test("Linux onboarding exposes labelled minimize, maximize, and close controls in both modes", async (t) => {const vite = await createOnboardingRenderer(t);const { default: OnboardingShell } = await vite.ssrLoadModule("/components/onboarding/OnboardingShell.tsx");- const markup = renderToStaticMarkup(- React.createElement(OnboardingShell, { compact: true }, React.createElement("div"))- );-- assert.match(markup, /title="windowControls.minimize"/);- assert.match(markup, /title="windowControls.close"/);-});--test("expanded Linux onboarding keeps maximize alongside minimize and close", async (t) => {- const vite = await createOnboardingRenderer(t);- const { default: OnboardingShell } = await vite.ssrLoadModule(- "/components/onboarding/OnboardingShell.tsx"- );-- const markup = renderToStaticMarkup(- React.createElement(OnboardingShell, null, React.createElement("div"))- );-- assert.match(markup, /title="windowControls.minimize"/);- assert.match(markup, /title="windowControls.maximize"/);- assert.match(markup, /title="windowControls.close"/);+ for (const compact of [true, false]) {+ const mode = compact ? "compact" : "expanded";+ const markup = renderToStaticMarkup(+ React.createElement(OnboardingShell, { compact }, React.createElement("div"))+ );++ for (const control of ["minimize", "maximize", "close"]) {+ assert.match(+ markup,+ new RegExp(`title="windowControls\\.${control}"`),+ `${mode} ${control} title`+ );+ assert.match(+ markup,+ new RegExp(`aria-label="windowControls\\.${control}"`),+ `${mode} ${control} aria-label`+ );+ }+ }});test("a denied microphone exposes the existing Linux settings recovery", async (t) => {diff --git a/test/helpers/windowManagerAssistantPanel.test.js b/test/helpers/windowManagerAssistantPanel.test.jsindex 7493834af..6443f8c28 100644--- a/test/helpers/windowManagerAssistantPanel.test.js+++ b/test/helpers/windowManagerAssistantPanel.test.js@@ -112,7 +112,7 @@ test("hideDictationPanel refuses while an assistant command is busy or the panelassert.deepEqual(calls, ["hide"]);});-test("compact onboarding stays fixed-size but remains minimizable and closable", () => {+test("compact onboarding exposes the complete window-control contract", () => {const manager = new WindowManager();const state = {};const win = {@@ -141,15 +141,43 @@ test("compact onboarding stays fixed-size but remains minimizable and closable",manager._applyOnboardingWindowChrome(win, "compact");assert.deepEqual(state, {- resizable: false,+ resizable: true,minimizable: true,- maximizable: false,+ maximizable: true,closable: true,fullScreenable: false,minimumSize: { width: 480, height: 624 },});});+test("compact macOS onboarding shows the native traffic lights", () => {+ const originalPlatform = Object.getOwnPropertyDescriptor(process, "platform");+ Object.defineProperty(process, "platform", { value: "darwin", configurable: true });++ try {+ const manager = new WindowManager();+ let buttonsVisible = false;+ const win = {+ getBounds: () => ({ x: 0, y: 0, width: 480, height: 624 }),+ setResizable: () => undefined,+ setMinimizable: () => undefined,+ setMaximizable: () => undefined,+ setClosable: () => undefined,+ setFullScreenable: () => undefined,+ setMinimumSize: () => undefined,+ setWindowButtonVisibility: (visible) => {+ buttonsVisible = visible;+ },+ };++ manager._applyOnboardingWindowChrome(win, "compact");++ assert.equal(buttonsVisible, true);+ } finally {+ Object.defineProperty(process, "platform", originalPlatform);+ }+});+test("native Linux push-to-talk keeps only the dictation low-level listener", async () => {const originalPlatform = Object.getOwnPropertyDescriptor(process, "platform");Object.defineProperty(process, "platform", { value: "linux", configurable: true });