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
fix(renderer): identify control panel by query (#1563)
Gabriel Stein1a03f8dbadfe
diff --git a/src/AppRouter.jsx b/src/AppRouter.jsxindex 7a0fbca95..a3ed6b338 100644--- a/src/AppRouter.jsx+++ b/src/AppRouter.jsx@@ -10,6 +10,7 @@ import { Card, CardContent } from "./components/ui/card.tsx";import { useAuth } from "./hooks/useAuth";import { useTheme } from "./hooks/useTheme";import { usePolicyStore } from "./stores/policyStore";+import { isControlPanelWindow } from "./utils/windowContext.ts";const ControlPanel = React.lazy(() => import("./components/ControlPanel.tsx"));const OnboardingFlow = React.lazy(() => import("./components/OnboardingFlow.tsx"));@@ -51,9 +52,7 @@ function MainApp() {const [postOnboardingSettingsSection, setPostOnboardingSettingsSection] = useState(undefined);const isAgentPanel = window.location.search.includes("agent=true");- const isControlPanel =- !isAgentPanel &&- (window.location.pathname.includes("control") || window.location.search.includes("panel=true"));+ const isControlPanel = !isAgentPanel && isControlPanelWindow();const isDictationPanel = !isControlPanel && !isAgentPanel;useEffect(() => {diff --git a/src/utils/windowContext.ts b/src/utils/windowContext.tsindex 79cbd090f..91c60582c 100644--- a/src/utils/windowContext.ts+++ b/src/utils/windowContext.ts@@ -1,9 +1,8 @@-// The control panel loads with "control" in the path (packaged) or ?panel=true-// (dev server); the dictation panel is the plain URL.+// Window creation tags the control panel with ?panel=true in both development+// and packaged builds; the dictation panel is the plain URL.export const isControlPanelWindow = (): boolean => {if (typeof window === "undefined") return false;- const { search, pathname } = window.location;- return pathname.includes("control") || search.includes("panel=true");+ return new URLSearchParams(window.location.search).get("panel") === "true";};export const isDictationPanelWindow = (): boolean =>diff --git a/test/helpers/windowContext.test.js b/test/helpers/windowContext.test.jsnew file mode 100644index 000000000..679fb2235--- /dev/null+++ b/test/helpers/windowContext.test.js@@ -0,0 +1,46 @@+const test = require("node:test");+const assert = require("node:assert/strict");++const load = () => import("../../src/utils/windowContext.ts");++test("a packaged dictation window ignores control in its install path", async (t) => {+ const originalWindow = globalThis.window;+ t.after(() => {+ globalThis.window = originalWindow;+ });+ globalThis.window = {+ location: {+ pathname:+ "/Users/controller/Applications/OpenWhispr.app/Contents/Resources/app.asar/src/dist/index.html",+ search: "",+ },+ };++ const { isControlPanelWindow, isDictationPanelWindow } = await load();++ assert.equal(isControlPanelWindow(), false);+ assert.equal(isDictationPanelWindow(), true);+});++test("only the explicit panel=true query selects the control panel", async (t) => {+ const originalWindow = globalThis.window;+ t.after(() => {+ globalThis.window = originalWindow;+ });+ globalThis.window = {+ location: {+ pathname: "/Applications/OpenWhispr.app/Contents/Resources/app.asar/src/dist/index.html",+ search: "?panel=true",+ },+ };++ const { isControlPanelWindow } = await load();++ assert.equal(isControlPanelWindow(), true);++ globalThis.window.location.search = "?notpanel=true";+ assert.equal(isControlPanelWindow(), false);++ globalThis.window.location.search = "?panel=trueish";+ assert.equal(isControlPanelWindow(), false);+});