diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 3a7473f4d..aa5f74500 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -89,11 +89,10 @@ reviews: every user-visible failure has an actionable, non-technical error message; loading/disabled states during long operations. Every new user-facing string must be an i18n t('...') key present in ALL 21 - locale files of the catalog the code imports from — - electron/src/shared/i18n/locales/*.json (tests/test_locale_parity.py) - or electron/src/renderer/src/i18n/locales/*.json (electron - locale:check) — flag hardcoded UI strings and keys missing from any - locale. + locale files of the catalog — + electron/src/renderer/src/i18n/locales/*.json (tests/test_locale_parity.py + and electron locale:check) — flag hardcoded UI strings and keys missing + from any locale. - path: "electron/**/*.{ts,tsx}" instructions: >- Electron is the only maintained desktop; Tauri is sunset and archived. @@ -163,8 +162,7 @@ reviews: mode: warning instructions: >- For every new or changed t('...') key in Electron UI code, verify the - key exists in all 21 files of the catalog it uses: - electron/src/shared/i18n/locales/ or + key exists in all 21 files of the catalog: electron/src/renderer/src/i18n/locales/. List any locale files missing the key. Also flag hardcoded user-facing strings that bypass i18n entirely. diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 3b4575ee4..774d9ce68 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -558,10 +558,9 @@ test-only PR. Docker Hub overview edits still publish through the small Platform-only features go behind an explicit opt-in (Settings toggle, env var, or CLI flag). - **i18n — every locale (hard rule):** every user-facing string goes through - `t('...')` and the key must exist in **every** file of the catalog the code - uses: `electron/src/shared/i18n/locales/` (checked by - `tests/test_locale_parity.py`) or `electron/src/renderer/src/i18n/locales/` - (checked by `bun run --cwd electron locale:check`, which also fails on an + `t('...')` and the key must exist in **every** file of the catalog: + `electron/src/renderer/src/i18n/locales/` (checked by + `tests/test_locale_parity.py` and `bun run --cwd electron locale:check`, which also fails on an `en.json` key no code references; delete it from every locale, or add a prefix to `ALLOWED_PREFIXES` in `electron/tests/locale-source-keys.mjs` if code builds it dynamically). Translate; don't copy diff --git a/backend/core/scrub.py b/backend/core/scrub.py index 3447d02bc..8bdf05324 100644 --- a/backend/core/scrub.py +++ b/backend/core/scrub.py @@ -3,7 +3,7 @@ Everything VoiceStudio renders into a bug report or diagnostic dump goes through ``scrub_text()`` before it can reach a prefilled GitHub Issues URL (the only outbound path — see CLAUDE.md Capability 2). The scrubber is the -backend twin of ``electron/src/shared/utils/bugReport.js``'s ``scrubText`` and +backend twin of ``electron/src/shared/utils/scrub.js``'s ``scrubText`` and must stay at least as strict: - home directories → ``~`` (macOS ``/Users/``, Linux ``/home/``, diff --git a/bun.lock b/bun.lock index 9406f8f46..b209e6961 100644 --- a/bun.lock +++ b/bun.lock @@ -19,15 +19,6 @@ "@electron-toolkit/utils": "^4.0.0", "@fontsource-variable/inter": "^5.3.0", "@lobehub/icons-static-svg": "^1.95.0", - "@radix-ui/react-dialog": "^1.1.23", - "@radix-ui/react-dropdown-menu": "^2.1.24", - "@radix-ui/react-progress": "^1.1.16", - "@radix-ui/react-slider": "^1.4.7", - "@radix-ui/react-slot": "^1.3.3", - "@radix-ui/react-tabs": "^1.1.21", - "@radix-ui/react-toggle": "^1.1.18", - "@radix-ui/react-toggle-group": "^1.1.19", - "@radix-ui/react-tooltip": "^1.2.16", "@scalar/api-reference-react": "^0.9.67", "@tanstack/react-form": "^1.33.5", "@tanstack/react-pacer": "^0.23.0", @@ -39,7 +30,6 @@ "@vidstack/react": "1.15.6", "@xyflow/react": "^12.12.0", "class-variance-authority": "^0.7.1", - "clsx": "^2.1.1", "cn": "^0.3.0", "country-flag-icons": "^1.6.20", "dashjs": "^5.2.1", @@ -47,7 +37,6 @@ "hls.js": "^1.7.3", "html-entities": "^2.6.0", "i18next": "^26.4.2", - "i18next-browser-languagedetector": "^8.2.1", "lucide-react": "^1.46.0", "proxy-agent": "6.5.0", "qrcode": "^1.5.4", @@ -57,7 +46,6 @@ "react-i18next": "^17.0.14", "shadcn": "^4.21.0", "sonner": "^2.0.8", - "tailwind-merge": "^3.6.0", "tw-animate-css": "^1.4.0", "wavesurfer.js": "^7.12.12", "word-extractor": "1.0.4", @@ -485,78 +473,6 @@ "@quansync/fs": ["@quansync/fs@1.0.0", "", { "dependencies": { "quansync": "^1.0.0" } }, "sha512-4TJ3DFtlf1L5LDMaM6CanJ/0lckGNtJcMjQ1NAV6zDmA0tEHKZtxNKin8EgPaVX1YzljbxckyT2tJrpQKAtngQ=="], - "@radix-ui/number": ["@radix-ui/number@1.1.3", "", {}, "sha512-Road2bidD0uu/1BGDOWNdPI06g0lIRy6IF9GZcIrDK2KGItfor8IQwQa+yM2ERgHM1MmHxaxpTzk0/Jp42lNfA=="], - - "@radix-ui/primitive": ["@radix-ui/primitive@1.1.7", "", {}, "sha512-rqWnm76nYT8HoNNqEjpgJ7Pw/DrBj5iBTrmEPo6HTX5+VJyBNOqTdv4g89G63HuR5g0AaENoAcH7Is5fF2kZ8Q=="], - - "@radix-ui/react-arrow": ["@radix-ui/react-arrow@1.1.15", "", { "dependencies": { "@radix-ui/react-primitive": "2.1.10" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-v4zggRcjadnI+ClKDuijlQEW4tw3NoaeHc/PwpKnLoLLKNUG4InLegkstooLcRIUWCs+8L22dGURCVuFfOKfnA=="], - - "@radix-ui/react-collection": ["@radix-ui/react-collection@1.1.15", "", { "dependencies": { "@radix-ui/react-compose-refs": "1.1.5", "@radix-ui/react-context": "1.2.2", "@radix-ui/react-primitive": "2.1.10", "@radix-ui/react-slot": "1.3.3" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-9W+B9NPF0NaaPh/1NJd3+KqsnlLqU9H7T2rvww+fp+T/evVXdNAyYcnfRQZFOjkR1ajQp3yORlqnI8soawLvNA=="], - - "@radix-ui/react-compose-refs": ["@radix-ui/react-compose-refs@1.1.5", "", { "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-+48PbAAbq3didjJxa+OaWY2ZwgAKsNiRGyeHKszblZMQ+kcpd9pAaT11cMkGEie0vsOi3QdeTE6d5Fe3Gn61kA=="], - - "@radix-ui/react-context": ["@radix-ui/react-context@1.2.2", "", { "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-RHCUGwKHDr0hDGg4X7ma4JG4/+12qxw8rkh5QKdDldlCvtja6nUx1Ef/8HVrJze81lEsgLQlqjzjGNHantgnQA=="], - - "@radix-ui/react-dialog": ["@radix-ui/react-dialog@1.1.23", "", { "dependencies": { "@radix-ui/primitive": "1.1.7", "@radix-ui/react-compose-refs": "1.1.5", "@radix-ui/react-context": "1.2.2", "@radix-ui/react-dismissable-layer": "1.1.19", "@radix-ui/react-focus-guards": "1.1.6", "@radix-ui/react-focus-scope": "1.1.16", "@radix-ui/react-id": "1.1.4", "@radix-ui/react-portal": "1.1.17", "@radix-ui/react-presence": "1.1.10", "@radix-ui/react-primitive": "2.1.10", "@radix-ui/react-slot": "1.3.3", "@radix-ui/react-use-controllable-state": "1.2.6", "@radix-ui/react-use-layout-effect": "1.1.4", "aria-hidden": "^1.2.4", "react-remove-scroll": "^2.7.2" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-Ksw4WeROkO4rC9k/onilX/Ao2Cr1ku1unMNH+XSCcP4jSXYu7HDsg9n4ojMjVb22XpYjAQ9qfrFlVbru1vXDUA=="], - - "@radix-ui/react-direction": ["@radix-ui/react-direction@1.1.4", "", { "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-5pzg4FGQNpExhnhT2zlrP1wZFaYCd1K0nYWoFAdcYoYK868IEigqMX3B3f8yIoRlAhAeDWciLI6ZdCKHF9P4Vg=="], - - "@radix-ui/react-dismissable-layer": ["@radix-ui/react-dismissable-layer@1.1.19", "", { "dependencies": { "@radix-ui/primitive": "1.1.7", "@radix-ui/react-compose-refs": "1.1.5", "@radix-ui/react-primitive": "2.1.10", "@radix-ui/react-use-callback-ref": "1.1.4", "@radix-ui/react-use-effect-event": "0.0.5" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-8g4pfOL9HoKKLWGiypT+dphVqjFfmcXO5GBnhsG6zI+lxAx/8feQpr+1LSN8Re3hiZ+XkLNS4O9ztK11/LzQ6w=="], - - "@radix-ui/react-dropdown-menu": ["@radix-ui/react-dropdown-menu@2.1.24", "", { "dependencies": { "@radix-ui/primitive": "1.1.7", "@radix-ui/react-compose-refs": "1.1.5", "@radix-ui/react-context": "1.2.2", "@radix-ui/react-id": "1.1.4", "@radix-ui/react-menu": "2.1.24", "@radix-ui/react-primitive": "2.1.10", "@radix-ui/react-use-controllable-state": "1.2.6" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-geq8l2rJkxvkXsT9RMgtUE3P8pITFpTsvYpbySi1IH4fZEABD/Gp85myayFgxk0ktljGMJnCbeFkyTusvSvv7g=="], - - "@radix-ui/react-focus-guards": ["@radix-ui/react-focus-guards@1.1.6", "", { "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-RNOJjfZMTyBM6xYmV3IVGXkPjIhcBAuv48POevAXwrGJhkWZ9p1rFoIS1JFooPuT193AZmRsCPhpoVJxx6OPoQ=="], - - "@radix-ui/react-focus-scope": ["@radix-ui/react-focus-scope@1.1.16", "", { "dependencies": { "@radix-ui/react-compose-refs": "1.1.5", "@radix-ui/react-primitive": "2.1.10", "@radix-ui/react-use-callback-ref": "1.1.4" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-wmRZ2WWLvmt6KHy2rNPOdPUjwq5xOHY02+m+udwJTn0aNIox/rkskAvJTyTLGhPK6KgrUjlJUJpgmx/+wFiFIQ=="], - - "@radix-ui/react-id": ["@radix-ui/react-id@1.1.4", "", { "dependencies": { "@radix-ui/react-use-layout-effect": "1.1.4" }, "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-TMQp2llA+RYn7JcjnrMnz7wN4pcVttPZnRZo52PLQsoLVKzNlVwUeHmfePgTgRluXFvlD3GD5g5MOVVTJCO0qA=="], - - "@radix-ui/react-menu": ["@radix-ui/react-menu@2.1.24", "", { "dependencies": { "@radix-ui/primitive": "1.1.7", "@radix-ui/react-collection": "1.1.15", "@radix-ui/react-compose-refs": "1.1.5", "@radix-ui/react-context": "1.2.2", "@radix-ui/react-direction": "1.1.4", "@radix-ui/react-dismissable-layer": "1.1.19", "@radix-ui/react-focus-guards": "1.1.6", "@radix-ui/react-focus-scope": "1.1.16", "@radix-ui/react-id": "1.1.4", "@radix-ui/react-popper": "1.3.7", "@radix-ui/react-portal": "1.1.17", "@radix-ui/react-presence": "1.1.10", "@radix-ui/react-primitive": "2.1.10", "@radix-ui/react-roving-focus": "1.1.19", "@radix-ui/react-slot": "1.3.3", "@radix-ui/react-use-callback-ref": "1.1.4", "aria-hidden": "^1.2.4", "react-remove-scroll": "^2.7.2" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-uW7RVuU6Lp/ZtfeY4b3kL32zccgEWvPv1+cf17ubYzHa9cL8AHokmk36cG/XEiH/smbQvumnieXX9j/e9RqJWA=="], - - "@radix-ui/react-popper": ["@radix-ui/react-popper@1.3.7", "", { "dependencies": { "@floating-ui/react-dom": "^2.0.0", "@radix-ui/react-arrow": "1.1.15", "@radix-ui/react-compose-refs": "1.1.5", "@radix-ui/react-context": "1.2.2", "@radix-ui/react-primitive": "2.1.10", "@radix-ui/react-use-callback-ref": "1.1.4", "@radix-ui/react-use-layout-effect": "1.1.4", "@radix-ui/react-use-rect": "1.1.4", "@radix-ui/react-use-size": "1.1.4", "@radix-ui/rect": "1.1.3" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-UsJrrd7w4wuKKTdvd/DNERVlwSlUcyXzjhyDwBk+3aPOsCjOY6ZSbxuw8E6lZTjjfP8Cpd0J8VVkrYUWyGYXyg=="], - - "@radix-ui/react-portal": ["@radix-ui/react-portal@1.1.17", "", { "dependencies": { "@radix-ui/react-primitive": "2.1.10", "@radix-ui/react-use-layout-effect": "1.1.4" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-vKQLcWypUnwZVvfV7UkGahH2g6ySe8M8R+zYBwPrv5byZ9QAW6cQVvNKo7GgmD+p8aYb6D9JBuvy8/WhOno2wQ=="], - - "@radix-ui/react-presence": ["@radix-ui/react-presence@1.1.10", "", { "dependencies": { "@radix-ui/react-use-layout-effect": "1.1.4" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-3wyzCQ6+ubRA+D4uv9m95JYLXxmOHp05qjrkjeA7uKHHtjpPggQzc6DAb0URl7j67oR0K2foO4ip27TiX037Bw=="], - - "@radix-ui/react-primitive": ["@radix-ui/react-primitive@2.1.10", "", { "dependencies": { "@radix-ui/react-slot": "1.3.3" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-MucOnzh6hR5mid6VpkbglRAMYMjKLqRnGBbjXkzjK52fuQDd1qbkx78a5P40mkcnVXJdEVxm26E9OPAiUq7nBg=="], - - "@radix-ui/react-progress": ["@radix-ui/react-progress@1.1.16", "", { "dependencies": { "@radix-ui/react-context": "1.2.2", "@radix-ui/react-primitive": "2.1.10" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-5XnomAsoZZCY+KNTxbIghpGqPruZvKFNlvcAljVAOdDRDsH4/OZQxhtwo5wdtoDM5R6MhJBb2sPnDuRFep3lzg=="], - - "@radix-ui/react-roving-focus": ["@radix-ui/react-roving-focus@1.1.19", "", { "dependencies": { "@radix-ui/primitive": "1.1.7", "@radix-ui/react-collection": "1.1.15", "@radix-ui/react-compose-refs": "1.1.5", "@radix-ui/react-context": "1.2.2", "@radix-ui/react-direction": "1.1.4", "@radix-ui/react-id": "1.1.4", "@radix-ui/react-primitive": "2.1.10", "@radix-ui/react-use-callback-ref": "1.1.4", "@radix-ui/react-use-controllable-state": "1.2.6", "@radix-ui/react-use-is-hydrated": "0.1.3", "@radix-ui/react-use-layout-effect": "1.1.4" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-V9jI6hDjT7l3jsCQD9bLNvDLM3tH/gdbOTp7Tefp3hbbgCGQoK7tUvrWiRlcoBHIZ809ElXwNQwVo0B98LuTXQ=="], - - "@radix-ui/react-slider": ["@radix-ui/react-slider@1.4.7", "", { "dependencies": { "@radix-ui/number": "1.1.3", "@radix-ui/primitive": "1.1.7", "@radix-ui/react-collection": "1.1.15", "@radix-ui/react-compose-refs": "1.1.5", "@radix-ui/react-context": "1.2.2", "@radix-ui/react-direction": "1.1.4", "@radix-ui/react-primitive": "2.1.10", "@radix-ui/react-use-controllable-state": "1.2.6", "@radix-ui/react-use-layout-effect": "1.1.4", "@radix-ui/react-use-previous": "1.1.4", "@radix-ui/react-use-size": "1.1.4" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-mTSLf1GC/C0moWjTbvCM6Qn/gBjvlFt1azuWF2v7MN5C3Zq2U2J2lN3ZEYkpujuOU5Ro7A28wkviSxaKnG0BYg=="], - - "@radix-ui/react-slot": ["@radix-ui/react-slot@1.3.3", "", { "dependencies": { "@radix-ui/react-compose-refs": "1.1.5" }, "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-qx7oqnYbxnK9kYI9m317qmFmEgo6ywqWvbTogdj7cL9p3/yx4M48p7Rnw5z3H890cL/ow/EeWJsuTykeZVXP5Q=="], - - "@radix-ui/react-tabs": ["@radix-ui/react-tabs@1.1.21", "", { "dependencies": { "@radix-ui/primitive": "1.1.7", "@radix-ui/react-context": "1.2.2", "@radix-ui/react-direction": "1.1.4", "@radix-ui/react-id": "1.1.4", "@radix-ui/react-presence": "1.1.10", "@radix-ui/react-primitive": "2.1.10", "@radix-ui/react-roving-focus": "1.1.19", "@radix-ui/react-use-controllable-state": "1.2.6" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-UKxJlZid7FVtsk/WTxj4i4uSEgj2Au+KBbS7SQyTlzMhhn+86Cz3tISZdTa87bfEfcuvZezf2ZsxD4xuEKtkog=="], - - "@radix-ui/react-toggle": ["@radix-ui/react-toggle@1.1.18", "", { "dependencies": { "@radix-ui/primitive": "1.1.7", "@radix-ui/react-primitive": "2.1.10", "@radix-ui/react-use-controllable-state": "1.2.6" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-7lonPlKfSacd20GlOBx2ltuVKz9oqWYZz+oMQyOltw6t1y2nyftj2ZmwwUHYn49kqfDWcp8dNZm5NgV+5Z+mug=="], - - "@radix-ui/react-toggle-group": ["@radix-ui/react-toggle-group@1.1.19", "", { "dependencies": { "@radix-ui/primitive": "1.1.7", "@radix-ui/react-context": "1.2.2", "@radix-ui/react-direction": "1.1.4", "@radix-ui/react-primitive": "2.1.10", "@radix-ui/react-roving-focus": "1.1.19", "@radix-ui/react-toggle": "1.1.18", "@radix-ui/react-use-controllable-state": "1.2.6" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-OtnwuSVjd1Ofi+AdnvhsjQdyuhCDwYs1w9RyB5BN/OavXOVQo42SYqQjwUnbPnaiPFBpQ9aX70dWeee+v2oBLA=="], - - "@radix-ui/react-tooltip": ["@radix-ui/react-tooltip@1.2.16", "", { "dependencies": { "@radix-ui/primitive": "1.1.7", "@radix-ui/react-compose-refs": "1.1.5", "@radix-ui/react-context": "1.2.2", "@radix-ui/react-dismissable-layer": "1.1.19", "@radix-ui/react-id": "1.1.4", "@radix-ui/react-popper": "1.3.7", "@radix-ui/react-portal": "1.1.17", "@radix-ui/react-presence": "1.1.10", "@radix-ui/react-primitive": "2.1.10", "@radix-ui/react-slot": "1.3.3", "@radix-ui/react-use-controllable-state": "1.2.6", "@radix-ui/react-use-layout-effect": "1.1.4", "@radix-ui/react-visually-hidden": "1.2.11" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-6EamKFRRnlpdadndbZ6LMwycfwkwPte1B42hs6QA0gYhjaOKqW4PZ4pjaW9UrlDX5eVt/OjncE7BFTPL5nmZhg=="], - - "@radix-ui/react-use-callback-ref": ["@radix-ui/react-use-callback-ref@1.1.4", "", { "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-R6OUY2e2fA6Yn6s+VSx5KBV6Nx8LQEhu+cz7LCej18rQ1HLyg9PSC9jP/ZNx0o6FAIK9c0F1kHylzSxKsdlkrQ=="], - - "@radix-ui/react-use-controllable-state": ["@radix-ui/react-use-controllable-state@1.2.6", "", { "dependencies": { "@radix-ui/primitive": "1.1.7", "@radix-ui/react-use-effect-event": "0.0.5", "@radix-ui/react-use-layout-effect": "1.1.4" }, "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-uEQJGT97ZA/TgP/Hydw47lHu+/vQj6z/0jA+WeTbK1o9Rx45GImjpD0tc3W5ad3D6XTSR6e1yEO0FvGq6WQfVQ=="], - - "@radix-ui/react-use-effect-event": ["@radix-ui/react-use-effect-event@0.0.5", "", { "dependencies": { "@radix-ui/react-use-layout-effect": "1.1.4" }, "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-7cshFL8HGS/7HEiHH+9kL9HBwp2sa9yX18Knwek6KYWmXwM7pegMgta2AXMQKI+rq3JnfSj9x8wYqFMTdG1Jgg=="], - - "@radix-ui/react-use-is-hydrated": ["@radix-ui/react-use-is-hydrated@0.1.3", "", { "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-umO/aJ+82CpOnhDZUTbILCQf7kU/g0iv+oGs/Q8jw7IkhWBzaEP4sA268PhFAJTFetbwp3ICc6ktpI4TqtxcIw=="], - - "@radix-ui/react-use-layout-effect": ["@radix-ui/react-use-layout-effect@1.1.4", "", { "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-K20DkRkUwDnxEYMBPcg3Y6voLkEy5p5QQmszZgLngKKiC7dzBR/aEuK3w1qlx2JWDUNH6FluahYdgR3BP+QbYw=="], - - "@radix-ui/react-use-previous": ["@radix-ui/react-use-previous@1.1.4", "", { "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-XoSLhbRbqxFtgJoi2fNHA3C6pDlY34x508vUpUGoFZfvePfHXHbE1lC4FYFMnJWgiCRroSTw6fOsXQoVS9RwZg=="], - - "@radix-ui/react-use-rect": ["@radix-ui/react-use-rect@1.1.4", "", { "dependencies": { "@radix-ui/rect": "1.1.3" }, "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-cSOCh6JlkmfjLyNcLiu2nB4v+nm+dkZ+Q5KHWk/soo4U7ZLiEQFKHK9/YmtBHjfCEaU43IBKQOc4/uJmCaiCTQ=="], - - "@radix-ui/react-use-size": ["@radix-ui/react-use-size@1.1.4", "", { "dependencies": { "@radix-ui/react-use-layout-effect": "1.1.4" }, "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-D3anSY15EJoxrihpsXI6SMrmmonnQtR2ni7arO+Lfdg3O95b9hNXxONk8jA5C8ANdF/h5HMAxejgs8PWJ6rlhw=="], - - "@radix-ui/react-visually-hidden": ["@radix-ui/react-visually-hidden@1.2.11", "", { "dependencies": { "@radix-ui/react-primitive": "2.1.10" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-NFS86RYYZb4/exihaESBGOpMJFz8MGLAfu3mOBSGByVnVPC9JPASfYubxd/8KbkQK0sYAv8lVQDEQukDX/qXvQ=="], - - "@radix-ui/rect": ["@radix-ui/rect@1.1.3", "", {}, "sha512-JtyZR+mqgBibTo8xea3B6ZRmzZiM/YeVBtUkas6zMuXjAlfIFIW2FgqeM9eLyvEaYX66vr6DJMK+4U6LV0KhNw=="], - "@replit/codemirror-css-color-picker": ["@replit/codemirror-css-color-picker@6.3.0", "", { "peerDependencies": { "@codemirror/language": "^6.0.0", "@codemirror/state": "^6.0.0", "@codemirror/view": "^6.0.0" } }, "sha512-19biDANghUm7Fz7L1SNMIhK48tagaWuCOHj4oPPxc7hxPGkTVY2lU/jVZ8tsbTKQPVG7BO2CBDzs7CBwb20t4A=="], "@rolldown/binding-android-arm-eabi": ["@rolldown/binding-android-arm-eabi@1.2.7", "", { "os": "android", "cpu": "arm" }, "sha512-EypzgnYCwyVY4NDHKzGmNJT5b+XaQEBniHxsMdeIQLB/tcCzZnhqrzHpZFbX9iaxx+5RiB8caATBtfvZP7zVxQ=="], @@ -1203,8 +1119,6 @@ "detect-node": ["detect-node@2.1.0", "", {}, "sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g=="], - "detect-node-es": ["detect-node-es@1.1.0", "", {}, "sha512-ypdmJU/TbBby2Dxibuv7ZLW3Bs1QEmM7nHjEANfohJLvE0XVujisn1qPJcZxg+qDucsr+bP6fLD1rPS3AhJ7EQ=="], - "devlop": ["devlop@1.1.0", "", { "dependencies": { "dequal": "^2.0.0" } }, "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA=="], "diff": ["diff@8.0.4", "", {}, "sha512-DPi0FmjiSU5EvQV0++GFDOJ9ASQUVFh5kD+OzOnYdi7n3Wpm9hWWGfB/O2blfHcMVTL5WkQXSnRiK9makhrcnw=="], @@ -1373,8 +1287,6 @@ "get-intrinsic": ["get-intrinsic@1.3.0", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.2", "es-define-property": "^1.0.1", "es-errors": "^1.3.0", "es-object-atoms": "^1.1.1", "function-bind": "^1.1.2", "get-proto": "^1.0.1", "gopd": "^1.2.0", "has-symbols": "^1.1.0", "hasown": "^2.0.2", "math-intrinsics": "^1.1.0" } }, "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ=="], - "get-nonce": ["get-nonce@1.0.1", "", {}, "sha512-FJhYRoDaiatfEkUK8HKlicmu/3SGFD51q3itKDGoSTysQJBnfOcxU5GxnhE1E6soB76MbT0MBtnKJuXyAx+96Q=="], - "get-own-enumerable-keys": ["get-own-enumerable-keys@1.0.0", "", {}, "sha512-PKsK2FSrQCyxcGHsGrLDcK0lx+0Ke+6e8KFFozA9/fIQLhQzPaRvJFdcz7+Axg3jUH/Mq+NI4xa5u/UT2tQskA=="], "get-proto": ["get-proto@1.0.1", "", { "dependencies": { "dunder-proto": "^1.0.1", "es-object-atoms": "^1.0.0" } }, "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g=="], @@ -1479,8 +1391,6 @@ "i18next": ["i18next@26.4.2", "", { "peerDependencies": { "typescript": "^5 || ^6 || ^7" }, "optionalPeers": ["typescript"] }, "sha512-RX+R0VLg13IbvRuJSxnqykUFS9vQZTl8wYpWPCIUDWVrSGjsQywB5Y+pjzrkboxGAuYfJZVH1InFTdgBdxq6ug=="], - "i18next-browser-languagedetector": ["i18next-browser-languagedetector@8.2.1", "", { "dependencies": { "@babel/runtime": "^7.23.2" } }, "sha512-bZg8+4bdmaOiApD7N7BPT9W8MLZG+nPTOFlLiJiT8uzKXFjhxw4v2ierCXOwB5sFDMtuA5G4kgYZ0AznZxQ/cw=="], - "iconv-lite": ["iconv-lite@0.7.3", "", { "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" } }, "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ=="], "identifier-regex": ["identifier-regex@1.1.0", "", { "dependencies": { "reserved-identifiers": "^1.0.0" } }, "sha512-SLX4H/vtcYlYnL7XqnuJKHU7Z8517TgsW9nmQiGOgMCjQ8V/deLYu6bEmbGoXe7WMMhc9+EUGyFFneHja8KabA=="], @@ -1961,12 +1871,6 @@ "react-is": ["react-is@17.0.2", "", {}, "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="], - "react-remove-scroll": ["react-remove-scroll@2.7.2", "", { "dependencies": { "react-remove-scroll-bar": "^2.3.7", "react-style-singleton": "^2.2.3", "tslib": "^2.1.0", "use-callback-ref": "^1.3.3", "use-sidecar": "^1.1.3" }, "peerDependencies": { "@types/react": "*", "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-Iqb9NjCCTt6Hf+vOdNIZGdTiH1QSqr27H/Ek9sv/a97gfueI/5h1s3yRi1nngzMUaOOToin5dI1dXKdXiF+u0Q=="], - - "react-remove-scroll-bar": ["react-remove-scroll-bar@2.3.8", "", { "dependencies": { "react-style-singleton": "^2.2.2", "tslib": "^2.0.0" }, "peerDependencies": { "@types/react": "*", "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-9r+yi9+mgU33AKcj6IbT9oRCO78WriSj6t/cF8DWBZJ9aOGPOTEDvdUDz1FwKim7QXWwmHqtdHnRJfhAxEG46Q=="], - - "react-style-singleton": ["react-style-singleton@2.2.3", "", { "dependencies": { "get-nonce": "^1.0.0", "tslib": "^2.0.0" }, "peerDependencies": { "@types/react": "*", "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-b6jSvxvVnyptAiLjbkWLE/lOnR4lfTtDAl+eUC7RZy+QQWc6wRzIV2CE6xBuMmDxc2qIihtDCZD5NPOFl7fRBQ=="], - "read-binary-file-arch": ["read-binary-file-arch@1.0.6", "", { "dependencies": { "debug": "^4.3.4" }, "bin": { "read-binary-file-arch": "cli.js" } }, "sha512-BNg9EN3DD3GsDXX7Aa8O4p92sryjkmzYYgmgTAc6CA4uGLEDzFfxOxugu21akOxpcXHiEgsYkC6nPsQvLLLmEg=="], "readable-stream": ["readable-stream@2.3.8", "", { "dependencies": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", "isarray": "~1.0.0", "process-nextick-args": "~2.0.0", "safe-buffer": "~5.1.1", "string_decoder": "~1.1.1", "util-deprecate": "~1.0.1" } }, "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA=="], @@ -2153,7 +2057,7 @@ "tagged-tag": ["tagged-tag@1.0.0", "", {}, "sha512-yEFYrVhod+hdNyx7g5Bnkkb0G6si8HJurOoOEgC8B/O0uXLHlaey/65KRv6cuWBNhBgHKAROVpc7QyYqE5gFng=="], - "tailwind-merge": ["tailwind-merge@3.7.0", "", {}, "sha512-XPPUyAc+cvspz3lHTcR/QgPfW2A0lv/xQNIjX3HGhLR+Nq2lHaLq5MtTesHn8GUr3W3DguT2KT5x3NVgRtYwmA=="], + "tailwind-merge": ["tailwind-merge@3.5.0", "", {}, "sha512-I8K9wewnVDkL1NTGoqWmVEIlUcB9gFriAEkXkfCjX5ib8ezGxtR3xD7iZIxrfArjEsH7F1CHD4RFUtxefdqV/A=="], "tailwindcss": ["tailwindcss@4.3.3", "", {}, "sha512-gOhV3P7ufE62QDGg1zVaTgCR+EtPv92k2nIhVcVKcLmxT1sUBsQGhnZj175j+MqRt4zLF7ic+sCYjfhxMxj7YQ=="], @@ -2263,10 +2167,6 @@ "update-browserslist-db": ["update-browserslist-db@1.3.2", "", { "dependencies": { "escalade": "^3.2.0", "picocolors": "^1.1.1" }, "peerDependencies": { "browserslist": ">= 4.21.0" }, "bin": { "update-browserslist-db": "cli.js" } }, "sha512-UQ+MSxlhRm1bzjhU+DcuXfjFO1FzNtqhK5+9Yvlp90ItDLk5vT932A0rFu619nf7RVS+Y/VeaUW1jaRDqZ8VJw=="], - "use-callback-ref": ["use-callback-ref@1.3.3", "", { "dependencies": { "tslib": "^2.0.0" }, "peerDependencies": { "@types/react": "*", "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-jQL3lRnocaFtu3V00JToYz/4QkNWswxijDaCVNZRiRTO3HQDLsdu1ZtmIUvV4yPp+rvWm5j0y0TG/S61cuijTg=="], - - "use-sidecar": ["use-sidecar@1.1.3", "", { "dependencies": { "detect-node-es": "^1.1.0", "tslib": "^2.0.0" }, "peerDependencies": { "@types/react": "*", "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-Fedw0aZvkhynoPYlA5WXrMCAMm+nSWdZt6lzJQ7Ok8S6Q+VsHmHpRWndVRJ8Be0ZbkfPc5LRYH+5XrzXcEeLRQ=="], - "use-sync-external-store": ["use-sync-external-store@1.6.0", "", { "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w=="], "utf8-byte-length": ["utf8-byte-length@1.0.5", "", {}, "sha512-Xn0w3MtiQ6zoz2vFyUVruaCL53O/DwUvkEeOvj+uulMm0BkUGYWmBYVyElqZaSLhY6ZD0ulfU3aBra2aVT4xfA=="], @@ -2445,8 +2345,6 @@ "@scalar/types/zod": ["zod@4.5.4", "", {}, "sha512-sC95tT5iHHH9gtpj6A81kh+NEaRAUFN+qlUPDUbRfOMvNf5QCBqsb3WgvnpVtK5Y+4UfA6KqufotuTvMGiTlsA=="], - "@scalar/use-hooks/tailwind-merge": ["tailwind-merge@3.5.0", "", {}, "sha512-I8K9wewnVDkL1NTGoqWmVEIlUcB9gFriAEkXkfCjX5ib8ezGxtR3xD7iZIxrfArjEsH7F1CHD4RFUtxefdqV/A=="], - "@scalar/workspace-store/yaml": ["yaml@2.9.0", "", { "bin": { "yaml": "bin.mjs" } }, "sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA=="], "@tailwindcss/node/lightningcss": ["lightningcss@1.32.0", "", { "dependencies": { "detect-libc": "^2.0.3" }, "optionalDependencies": { "lightningcss-android-arm64": "1.32.0", "lightningcss-darwin-arm64": "1.32.0", "lightningcss-darwin-x64": "1.32.0", "lightningcss-freebsd-x64": "1.32.0", "lightningcss-linux-arm-gnueabihf": "1.32.0", "lightningcss-linux-arm64-gnu": "1.32.0", "lightningcss-linux-arm64-musl": "1.32.0", "lightningcss-linux-x64-gnu": "1.32.0", "lightningcss-linux-x64-musl": "1.32.0", "lightningcss-win32-arm64-msvc": "1.32.0", "lightningcss-win32-x64-msvc": "1.32.0" } }, "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ=="], diff --git a/docs/STRUCTURE.md b/docs/STRUCTURE.md index 81d1c9ab0..b7075c654 100644 --- a/docs/STRUCTURE.md +++ b/docs/STRUCTURE.md @@ -54,8 +54,8 @@ VoiceStudio/ │ ├── src/main/ lifecycle, backend supervisor, runtime setup, updater, native IPC │ ├── src/preload/ typed contextBridge → window.voicestudio │ ├── src/renderer/ desktop React app: routes/, features/, components/, i18n/locales/ -│ ├── src/shared/ modules shared by the desktop and browser builds (api/, i18n/, -│ │ store/, ui/, utils/) — not a runnable app +│ ├── src/shared/ modules shared by the desktop and browser builds (api/, store/, +│ │ utils/) — not a runnable app │ ├── tests/ packaged-app, installer and workflow smoke tests │ ├── build/ packaging inputs: icons, entitlements, Info.plist │ ├── scripts/ dev launcher, AppImage update-info embedding diff --git a/docs/branding.md b/docs/branding.md index 14e21a34a..0da1bf9ac 100644 --- a/docs/branding.md +++ b/docs/branding.md @@ -10,7 +10,6 @@ spark identifies creation. The product voice is clear, calm, and direct. | Primary vector mark | `docs/logo.svg` | | README mark | `docs/logo.png` and `docs/logo-256.png` | | Browser icon | `electron/public/favicon.svg` | -| In-app mark | `electron/src/shared/components/brand/VoiceStudioMark.jsx` | | Desktop/platform icons | `electron/build/icons/` | | macOS menu-bar templates | `electron/build/icons/trayTemplate.svg` and `trayRecordingTemplate.svg` | | Electron sidebar and browser icon | `electron/public/favicon.svg` via `electron/src/renderer/src/lib/brand.ts` | @@ -50,7 +49,7 @@ macOS artwork (`icon.icns` and `icon-macos.png`) keeps Apple's icon grid: the ti spans the centred 824 px of a 1024 px canvas, so it matches other apps in the Dock, Launchpad and Finder. `tests/test_macos_icon_grid.py` checks it. -Do not redraw the waveform per screen. Use `VoiceStudioMark` in React and the +Do not redraw the waveform per screen. Use `electron/src/renderer/src/lib/brand.ts` in React and the canonical SVG elsewhere so the silhouette stays recognizable at 16–512 px. ## Palette diff --git a/electron/package.json b/electron/package.json index bf79d377c..86e02065f 100644 --- a/electron/package.json +++ b/electron/package.json @@ -42,15 +42,6 @@ "@electron-toolkit/utils": "^4.0.0", "@fontsource-variable/inter": "^5.3.0", "@lobehub/icons-static-svg": "^1.95.0", - "@radix-ui/react-dialog": "^1.1.23", - "@radix-ui/react-dropdown-menu": "^2.1.24", - "@radix-ui/react-progress": "^1.1.16", - "@radix-ui/react-slider": "^1.4.7", - "@radix-ui/react-slot": "^1.3.3", - "@radix-ui/react-tabs": "^1.1.21", - "@radix-ui/react-toggle": "^1.1.18", - "@radix-ui/react-toggle-group": "^1.1.19", - "@radix-ui/react-tooltip": "^1.2.16", "@scalar/api-reference-react": "^0.9.67", "@tanstack/react-form": "^1.33.5", "@tanstack/react-pacer": "^0.23.0", @@ -62,7 +53,6 @@ "@vidstack/react": "1.15.6", "@xyflow/react": "^12.12.0", "class-variance-authority": "^0.7.1", - "clsx": "^2.1.1", "cn": "^0.3.0", "country-flag-icons": "^1.6.20", "dashjs": "^5.2.1", @@ -70,7 +60,6 @@ "hls.js": "^1.7.3", "html-entities": "^2.6.0", "i18next": "^26.4.2", - "i18next-browser-languagedetector": "^8.2.1", "lucide-react": "^1.46.0", "proxy-agent": "6.5.0", "qrcode": "^1.5.4", @@ -80,7 +69,6 @@ "react-i18next": "^17.0.14", "shadcn": "^4.21.0", "sonner": "^2.0.8", - "tailwind-merge": "^3.6.0", "tw-animate-css": "^1.4.0", "wavesurfer.js": "^7.12.12", "word-extractor": "1.0.4", diff --git a/electron/src/renderer/src/features/settings/engine-license.test.ts b/electron/src/renderer/src/features/settings/engine-license.test.ts new file mode 100644 index 000000000..5a433cca4 --- /dev/null +++ b/electron/src/renderer/src/features/settings/engine-license.test.ts @@ -0,0 +1,18 @@ +import { describe, expect, it } from 'vitest'; +import { licensedEngine } from './engine-license'; + +// A license-gated engine must always offer its Accept flow until the backend +// reports it accepted; the gate keys off the structured flags, never off the +// wording of the unavailable reason. +describe('licensedEngine', () => { + it.each(['supertonic3', 'pockettts'])('offers the license for %s until accepted', (id) => { + expect(licensedEngine(id, true, false)).toBe(id); + expect(licensedEngine(id, true, undefined)).toBe(id); + }); + + it('offers nothing once accepted, when not required, or for other engines', () => { + expect(licensedEngine('supertonic3', true, true)).toBeNull(); + expect(licensedEngine('pockettts', undefined, false)).toBeNull(); + expect(licensedEngine('kokoro', true, false)).toBeNull(); + }); +}); diff --git a/electron/src/renderer/src/features/settings/refine-note.test.ts b/electron/src/renderer/src/features/settings/refine-note.test.ts new file mode 100644 index 000000000..c24ea7fd8 --- /dev/null +++ b/electron/src/renderer/src/features/settings/refine-note.test.ts @@ -0,0 +1,22 @@ +import { describe, expect, it } from 'vitest'; +import { refineFailureNoteKey } from '@shared/components/settings/refineStatus'; +import en from '@/i18n/locales/en.json'; + +const dictation = en.dictation as Record; + +describe('refineFailureNoteKey', () => { + it('is silent without a status or after a successful refinement', () => { + expect(refineFailureNoteKey(null)).toBeNull(); + expect(refineFailureNoteKey(undefined)).toBeNull(); + expect(refineFailureNoteKey({ ok: true })).toBeNull(); + }); + + it('maps a timeout and any other failure to distinct, translated notes', () => { + const timeout = refineFailureNoteKey({ ok: false, reason: 'timeout' }); + const failed = refineFailureNoteKey({ ok: false, reason: 'RuntimeError' }); + expect(timeout).toBe('dictation.refine_timeout_note'); + expect(failed).toBe('dictation.refine_failed_note'); + expect(dictation.refine_timeout_note).toMatch(/timed out/i); + expect(dictation.refine_failed_note).toMatch(/failed/i); + }); +}); diff --git a/electron/src/renderer/src/i18n/locale-guards.test.ts b/electron/src/renderer/src/i18n/locale-guards.test.ts new file mode 100644 index 000000000..81afb9a3f --- /dev/null +++ b/electron/src/renderer/src/i18n/locale-guards.test.ts @@ -0,0 +1,70 @@ +import { afterEach, describe, expect, it } from 'vitest'; +import en from './locales/en.json'; +import i18n, { APP_LANGUAGES, SUPPORTED_LOCALES } from './index'; + +const catalogs = import.meta.glob<{ default: Record }>('./locales/*.json', { + eager: true, +}); + +describe('selectable UI languages', () => { + it('lists every supported locale with a language name and English first', () => { + expect(SUPPORTED_LOCALES[0]).toBe('en'); + expect(APP_LANGUAGES.map(({ code }) => code)).toEqual([...SUPPORTED_LOCALES]); + expect(APP_LANGUAGES.every(({ label }) => label.trim().length > 0)).toBe(true); + }); + + it('ships a catalog file for each supported locale', () => { + for (const code of SUPPORTED_LOCALES) + expect(catalogs[`./locales/${code}.json`], code).toBeTruthy(); + expect(Object.keys(catalogs)).toHaveLength(SUPPORTED_LOCALES.length); + }); +}); + +describe('document direction follows the active locale', () => { + afterEach(async () => { + await i18n.changeLanguage('en'); + }); + + it('switching to Arabic sets ', async () => { + await i18n.changeLanguage('ar'); + expect(document.documentElement.dir).toBe('rtl'); + expect(document.documentElement.lang).toBe('ar'); + }); + + it('switching back to English restores ', async () => { + await i18n.changeLanguage('ar'); + await i18n.changeLanguage('en'); + expect(document.documentElement.dir).toBe('ltr'); + expect(document.documentElement.lang).toBe('en'); + }); + + it('left-to-right locales stay left-to-right', async () => { + await i18n.changeLanguage('de'); + expect(document.documentElement.dir).toBe('ltr'); + expect(document.documentElement.lang).toBe('de'); + }); +}); + +describe('failure copy keeps the real error', () => { + it('gallery.use_failed interpolates the backend message', () => { + expect((en.gallery as Record).use_failed).toContain('{{message}}'); + }); + + it.each([ + ['it', 'Altre righe: 1', 'Altre righe: 2'], + ['nl', 'Extra rijen: 1', 'Extra rijen: 2'], + ['pl', 'Dodatkowe wiersze: 1', 'Dodatkowe wiersze: 2'], + ['pt', 'Linhas adicionais: 1', 'Linhas adicionais: 2'], + ['ru', 'Дополнительных строк: 1', 'Дополнительных строк: 2'], + ])('%s keeps the pasted-translation row count readable', async (locale, one, other) => { + const catalog = catalogs[`./locales/${locale}.json`]!.default; + const instance = i18n.createInstance(); + await instance.init({ + lng: locale, + fallbackLng: false, + resources: { [locale]: { translation: catalog } }, + }); + expect(instance.t('dub.paste_translation_more_rows', { count: 1 })).toBe(one); + expect(instance.t('dub.paste_translation_more_rows', { count: 2 })).toBe(other); + }); +}); diff --git a/electron/src/shared/api/audiobook.ts b/electron/src/shared/api/audiobook.ts deleted file mode 100644 index 2b0bc70fc..000000000 --- a/electron/src/shared/api/audiobook.ts +++ /dev/null @@ -1,203 +0,0 @@ -import { apiFetch } from './client'; - -interface AudiobookSpan { - voice_id: string | null; - text: string; - pause_ms_after: number; -} -interface AudiobookChapter { - title: string; - char_count: number; - spans: AudiobookSpan[]; -} -export interface AudiobookPlan { - chapters: AudiobookChapter[]; - chapter_count: number; - char_count: number; -} - -/** Parse a script into a chapter/span plan (pure preview, no synthesis). */ -export async function audiobookPlan(body: { - text: string; - default_voice?: string | null; -}): Promise { - const res = await apiFetch('/audiobook/plan', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(body), - }); - return res.json(); -} - -export interface AudiobookPreview { - output: string; // path under OUTPUTS_DIR, served via /audio - duration_s: number; - cached: boolean; - title: string; -} - -/** - * Expressive/quality knobs shared by the audiobook synth + per-chapter preview - * (#1208). All optional — an omitted field reproduces today's exact render on - * the backend. Preview MUST carry the same fields as the full render so a - * previewed chapter warms exactly the cache slot the render reuses. - */ -export interface ExpressiveRequestFields { - num_step?: number | null; - guidance_scale?: number | null; - position_temperature?: number | null; - class_temperature?: number | null; - postprocess_output?: boolean | null; - seed?: number | null; - emo_vector?: number[] | null; - emo_text?: string | null; - emo_alpha?: number | null; - vary_repeats?: boolean; -} - -/** Render a single chapter to audition it (also warms the resume cache). */ -export async function audiobookPreviewChapter( - body: { - text: string; - chapter_index: number; - default_voice?: string | null; - language?: string | null; - lexicon?: Record | null; - // Cast map {[voice:NAME] → profile id} — must match the render's (#1217). - voice_map?: Record | null; - } & ExpressiveRequestFields, -): Promise { - const res = await apiFetch('/audiobook/preview', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(body), - }); - return res.json(); -} - -/** Global tags embedded in the output file (player-visible). */ -interface AudiobookMetadata { - title?: string; - author?: string; - narrator?: string; - year?: string; - genre?: string; - description?: string; -} - -export interface AudiobookGenerateBody extends ExpressiveRequestFields { - text: string; - default_voice?: string | null; - // #1208 / #505: the backend AudiobookRequest has always accepted `language`, - // but this body omitted it, so an audiobook language pick could never reach - // the backend. Now threaded through ('Auto' → the profile's language). - language?: string | null; - bitrate?: string; - format?: 'm4b' | 'mp3'; - loudness?: 'off' | 'acx' | 'podcast' | null; - cover_path?: string | null; - metadata?: AudiobookMetadata | null; - lexicon?: Record | null; - // Multi-voice cast map {[voice:NAME] → profile id} (#1217). Absent/empty - // reproduces today's single-voice render + cache keys. - voice_map?: Record | null; -} - -/** - * Start the synth job. Returns the raw streaming Response; the caller reads - * `response.body` with a reader + the sseParse helpers. (apiFetch throws on a - * non-2xx status, so a returned Response is always a live stream.) - * - * `opts.signal` wires an AbortController into the fetch so a Stop cancels the - * request end-to-end (#1216): aborting closes the connection, the backend's - * `is_disconnected()` poll trips, and it stops scheduling further chapters - * instead of rendering the whole book into a stream nobody is reading. - */ -export async function audiobookGenerate( - body: AudiobookGenerateBody, - opts: { signal?: AbortSignal } = {}, -): Promise { - return apiFetch('/audiobook', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(body), - signal: opts.signal, - }); -} - -export interface ResumableAudiobookJob { - job_id: string; - type: 'audiobook' | 'longform'; - status: string; - title: string; - total_chapters: number; - chapters_done: number; - created_at: number | null; -} - -/** Fetch the renders the backend has on disk that can still be resumed. */ -export async function audiobookListJobs(): Promise<{ jobs: ResumableAudiobookJob[] }> { - const res = await apiFetch('/audiobook/jobs', { method: 'GET' }); - return res.json(); -} - -/** Ask the backend to continue one render; consumers read events from the response body. */ -export async function audiobookResume( - jobId: string, - opts: { signal?: AbortSignal } = {}, -): Promise { - const route = ['/audiobook/resume', encodeURIComponent(jobId)].join('/'); - const requestOptions: RequestInit = { method: 'POST' }; - if (opts.signal) requestOptions.signal = opts.signal; - return apiFetch(route, requestOptions); -} - -/** Upload a cover image; returns the server-side path to pass as `cover_path`. */ -export async function audiobookUploadCover(file: File): Promise<{ path: string }> { - const form = new FormData(); - form.append('cover', file); - const res = await apiFetch('/audiobook/cover', { method: 'POST', body: form }); - return res.json(); -} - -/** Import a .txt/.md/.epub/.pdf into a chapter-delimited script. */ -export async function audiobookImport(file: File): Promise<{ text: string; chapters: number }> { - const form = new FormData(); - form.append('file', file); - const res = await apiFetch('/audiobook/import', { method: 'POST', body: form }); - return res.json(); -} - -export interface LongformRenderBody extends ExpressiveRequestFields { - chapters: Array<{ - title?: string; - spans: Array<{ - voice_id: string | null; - text: string; - pause_ms_after: number; - speed?: number | null; - }>; - }>; - default_voice?: string | null; - language?: string | null; - bitrate?: string; - format?: 'm4b' | 'mp3'; - loudness?: 'off' | 'acx' | 'podcast' | null; - cover_path?: string | null; - metadata?: AudiobookMetadata | null; - voice_map?: Record | null; -} - -/** - * Render a pre-built chapter/span plan through the shared chapterized renderer - * (the convergence endpoint Stories posts to). Returns the raw SSE stream - * Response — read `response.body` with the sseParse helpers, same as - * `audiobookGenerate`. - */ -export async function longformRender(body: LongformRenderBody): Promise { - return apiFetch('/longform/render', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(body), - }); -} diff --git a/electron/src/shared/api/batch.test.js b/electron/src/shared/api/batch.test.js deleted file mode 100644 index 279a6ea8b..000000000 --- a/electron/src/shared/api/batch.test.js +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Contract test for the batch API client: /batch/enqueue receives uploaded - * File BYTES only. Filesystem paths must never appear in the request — the - * watch-folder feature (and everything else) rides the same guarantee. - */ -import { beforeEach, describe, expect, it, vi } from 'vitest'; -import fs from 'node:fs'; -import path from 'node:path'; -import { fileURLToPath } from 'node:url'; - -const invoke = vi.fn(); -vi.mock('@tauri-apps/api/core', () => ({ invoke: (...args) => invoke(...args) })); - -vi.mock('./client', () => ({ - ApiError: class ApiError extends Error { - constructor(message, init = {}) { - super(message); - Object.assign(this, init); - } - }, - apiJson: vi.fn(), - apiPost: vi.fn(async () => ({ job_id: 'j1', status: 'queued', queue_position: 0 })), - apiDelete: vi.fn(), - API: 'http://127.0.0.1:3900', -})); - -import { apiPost } from './client'; -import { enqueueBatchJob } from './batch'; - -describe('enqueueBatchJob', () => { - beforeEach(() => vi.clearAllMocks()); - - it('uploads the File itself — no filesystem path in any form field', async () => { - const file = new File(['bytes'], 'clip.mp4', { type: 'video/mp4' }); - // Desktop-flavored File objects sometimes carry a path property; even if - // one sneaks in, the client must not serialize it. - Object.defineProperty(file, 'path', { value: '/Users/me/Watched/clip.mp4' }); - - await enqueueBatchJob(file, ['es', 'fr'], 'voice-1', false); - - expect(apiPost).toHaveBeenCalledTimes(1); - const [url, form] = apiPost.mock.calls[0]; - expect(url).toBe('/batch/enqueue'); - expect(form).toBeInstanceOf(FormData); - - expect([...form.keys()].sort()).toEqual(['langs', 'preserve_bg', 'video', 'voice_id']); - expect(form.get('video')).toBeInstanceOf(File); - expect(form.get('video').name).toBe('clip.mp4'); - expect(form.get('langs')).toBe('es,fr'); - expect(form.get('voice_id')).toBe('voice-1'); - expect(form.get('preserve_bg')).toBe('false'); - - for (const [, value] of form.entries()) { - if (typeof value === 'string') { - expect(value).not.toContain('/Users/me'); - } - } - }); - - it('streams native watch entries without constructing FormData in the renderer', async () => { - const watched = { - __voiceStudioNativeWatchUpload: /** @type {const} */ (true), - token: 'a'.repeat(64), - name: 'large.mkv', - size: 8 * 1024 * 1024 * 1024, - mtime: 1234, - }; - invoke.mockResolvedValueOnce({ - status: 200, - body: { job_id: 'native-1', status: 'queued', queue_position: 1 }, - }); - - await expect(enqueueBatchJob(watched, ['es'], '', true)).resolves.toMatchObject({ - job_id: 'native-1', - }); - expect(invoke).toHaveBeenCalledWith('watch_folder_enqueue', { - token: watched.token, - name: 'large.mkv', - expectedSize: watched.size, - expectedMtime: watched.mtime, - langs: ['es'], - voiceId: '', - preserveBg: true, - }); - expect(apiPost).not.toHaveBeenCalled(); - }); - - it('preserves structured backend errors from native watch uploads', async () => { - const detail = { error: 'asr_model_missing', recommended: { repo_id: 'model/repo' } }; - invoke.mockResolvedValueOnce({ status: 409, body: { detail } }); - const watched = { - __voiceStudioNativeWatchUpload: /** @type {const} */ (true), - token: 'b'.repeat(64), - name: 'clip.mp4', - size: 4, - mtime: 1, - }; - - await expect(enqueueBatchJob(watched, ['es'])).rejects.toMatchObject({ status: 409, detail }); - }); - - it('the batch client source never touches a path at all', () => { - const source = fs.readFileSync( - path.join(path.dirname(fileURLToPath(import.meta.url)), 'batch.ts'), - 'utf-8', - ); - // No `path` identifier anywhere: not a form field, not a query param, not - // a property read. (Regression guard for the watch-folder rule that the - // backend only ever receives uploaded bytes.) - expect(source).not.toMatch(/[^A-Za-z]path/i); - }); -}); diff --git a/electron/src/shared/api/batch.ts b/electron/src/shared/api/batch.ts deleted file mode 100644 index 60c0cee24..000000000 --- a/electron/src/shared/api/batch.ts +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Batch dubbing API — wraps the /batch/* backend endpoints. - * - * Used by BatchQueue and BatchAddDialog to enqueue, monitor, and - * manage batch dub jobs. - */ -import { apiJson, apiPost, apiDelete, ApiError } from './client'; - -export interface BatchJob { - id: string; - status: 'queued' | 'running' | 'done' | 'failed' | 'cancelled'; - filename: string; - langs: string[]; - voice_id?: string; - preserve_bg: boolean; - created_at: number; - started_at?: number; - finished_at?: number; - error?: string; - progress?: { - stage: string; - percent: number; - current_lang?: string; - current_segment?: number; - total_segments?: number; - segments_count?: number; - }; - outputs?: Record; -} - -interface NativeWatchUpload { - __voiceStudioNativeWatchUpload: true; - token: string; - name: string; - size: number; - mtime: number; -} - -function isNativeWatchUpload(file: File | NativeWatchUpload): file is NativeWatchUpload { - return !(file instanceof File) && file.__voiceStudioNativeWatchUpload === true; -} - -/** List batch jobs, optionally filtered by status. */ -export async function listBatchJobs(status?: string, limit = 50): Promise { - const qs = new URLSearchParams(); - if (status) qs.set('status', status); - qs.set('limit', String(limit)); - return apiJson(`/batch/jobs?${qs.toString()}`); -} - -/** Get a single batch job (used to resolve why a job left the active list). */ -export async function getBatchJob(id: string): Promise { - return apiJson(`/batch/jobs/${id}`); -} - -/** Enqueue a video for batch dubbing. */ -export async function enqueueBatchJob( - file: File | NativeWatchUpload, - langs: string[], - voiceId?: string, - preserveBg = true, -): Promise<{ job_id: string; status: string; queue_position: number }> { - if (isNativeWatchUpload(file)) { - const { invoke } = await import('@tauri-apps/api/core'); - const reply = await invoke<{ status: number; body: unknown }>('watch_folder_enqueue', { - token: file.token, - name: file.name, - expectedSize: file.size, - expectedMtime: file.mtime, - langs, - voiceId, - preserveBg, - }); - if (reply.status < 200 || reply.status >= 300) { - const detail = (reply.body as { detail?: unknown })?.detail ?? reply.body; - throw new ApiError(`Watch-folder upload failed (${reply.status})`, { - status: reply.status, - detail, - }); - } - return reply.body as { job_id: string; status: string; queue_position: number }; - } - const form = new FormData(); - form.append('video', file); - form.append('langs', langs.join(',')); - if (voiceId) form.append('voice_id', voiceId); - form.append('preserve_bg', String(preserveBg)); - return apiPost('/batch/enqueue', form); -} - -/** Cancel a batch job. */ -export async function cancelBatchJob(id: string): Promise { - return apiPost(`/batch/jobs/${id}/cancel`, {}); -} - -/** Delete a batch job and its files. */ -export async function deleteBatchJob(id: string): Promise { - const res = await apiDelete(`/batch/jobs/${id}`); - return res.json(); -} diff --git a/electron/src/shared/api/exports.ts b/electron/src/shared/api/exports.ts deleted file mode 100644 index fd4dd710f..000000000 --- a/electron/src/shared/api/exports.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { apiJson, apiPost } from './client'; - -export async function listExportHistory(): Promise { - return apiJson('/export/history'); -} - -export async function exportAction(body: Record): Promise { - return apiPost('/export', body); -} - -export async function exportReveal(body: Record): Promise { - if (typeof window !== 'undefined' && '__TAURI_INTERNALS__' in window) { - const { invoke } = await import('@tauri-apps/api/core'); - return invoke('reveal_host_path', { path: body.path }); - } - return apiPost('/export/reveal', body); -} - -export async function exportRecord(body: Record): Promise { - return apiPost('/export/record', body); -} diff --git a/electron/src/shared/api/stories.ts b/electron/src/shared/api/stories.ts deleted file mode 100644 index d6627249b..000000000 --- a/electron/src/shared/api/stories.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { apiFetch } from './client'; - -/** - * Transcode a client-stitched WAV blob to a compressed format via the backend - * ffmpeg endpoint. Same-origin + PIN-aware (apiFetch). Throws on failure so the - * caller can fall back to the raw WAV. - */ -export async function encodeAudio(wavBlob: Blob, format = 'mp3', bitrate = '192k'): Promise { - const fd = new FormData(); - fd.append('file', wavBlob, 'story.wav'); - fd.append('format', format); - fd.append('bitrate', bitrate); - const res = await apiFetch('/stories/encode', { method: 'POST', body: fd }); - return res.blob(); -} diff --git a/electron/src/shared/components/AsrModelChooser.jsx b/electron/src/shared/components/AsrModelChooser.jsx deleted file mode 100644 index 0e9651a1c..000000000 --- a/electron/src/shared/components/AsrModelChooser.jsx +++ /dev/null @@ -1,155 +0,0 @@ -/** - * AsrModelChooser — the "no speech-to-text model installed" empty state's - * model picker. - * - * The page used to offer exactly one button: download the backend's - * recommended model. That hid the six other catalogue models — the English - * Parakeet that is markedly more accurate, the 25–44 MB streaming models that - * show text while you speak, the bilingual zh/en ones — behind Settings, and - * a user who already had one of them on disk still saw "download Whisper - * Tiny". This lists the whole sherpa-onnx catalogue grouped by what the user - * is choosing between (accuracy vs latency), with languages and size on every - * row, and lets them install any of them, or switch to one already installed. - * - * Falls back to the single recommended-download button when the catalogue - * can't be read (backend restarting, older backend), so the page is never - * left without a way forward. - */ -import React, { useEffect, useState } from 'react'; -import { useTranslation } from 'react-i18next'; -import { Check, Download } from 'lucide-react'; -import { apiJson } from '../api/client'; -import { Badge, Button } from '../ui'; - -function fmtSize(sizeGb) { - if (sizeGb == null) return ''; - if (sizeGb < 1) return `${Math.round(sizeGb * 1000)} MB`; - return `${sizeGb.toFixed(sizeGb < 10 ? 1 : 0)} GB`; -} - -// Offline models transcribe once you stop (best accuracy); streaming ones emit -// partial text as you speak (lowest latency). That is the real trade-off, so -// it is the grouping — not the engine's internal `kind`. -const GROUPS = [ - { tag: 'offline', title: 'asr_missing.group_offline' }, - { tag: 'streaming', title: 'asr_missing.group_streaming' }, -]; - -export default function AsrModelChooser({ fallback, onInstall, onSelect, disabled = false }) { - const { t } = useTranslation(); - // null = loading, [] = catalogue unavailable. - const [models, setModels] = useState(null); - - useEffect(() => { - let live = true; - apiJson('/dictation/models') - .then((data) => { - if (live) setModels(Array.isArray(data?.models) ? data.models : []); - }) - .catch(() => { - if (live) setModels([]); - }); - return () => { - live = false; - }; - }, []); - - if (models === null) return null; - - if (models.length === 0) { - if (!fallback?.repo_id) return null; - return ( - - ); - } - - const desc = (m) => t(`voicePanel.model_desc.${m.id}`, { defaultValue: m.languages || '' }); - - return ( -
-

{t('asr_missing.choose')}

- {GROUPS.map(({ tag, title }) => { - const rows = models - .filter((m) => m.tag === tag) - .sort((a, b) => Number(b.recommended) - Number(a.recommended)); - if (rows.length === 0) return null; - return ( -
-

- {t(title)} -

-
    - {rows.map((m) => ( -
  • -
    -
    - {m.label} - {m.recommended && ( - - {t('voicePanel.badge_recommended')} - - )} - {m.installed && ( - - {t('asr_missing.installed')} - - )} - - {fmtSize(m.size_gb)} - -
    -

    - {desc(m)} - {m.languages && ( - <> - {' · '} - {m.languages} - - )} -

    -
    - {m.installed ? ( - - ) : ( - - )} -
  • - ))} -
-
- ); - })} -
- ); -} diff --git a/electron/src/shared/components/BootstrapSplash.jsx b/electron/src/shared/components/BootstrapSplash.jsx deleted file mode 100644 index 83d29af5a..000000000 --- a/electron/src/shared/components/BootstrapSplash.jsx +++ /dev/null @@ -1,1179 +0,0 @@ -/** - * First-run bootstrap splash — the "installing" act of the first-run journey. - * - * Two data sources drive this UI: - * 1. `bootstrap_status` Tauri command (polled every 1 s) — coarse stage. - * 2. `bootstrap-log` + `bootstrap-progress` Tauri events — live stdout - * from `uv sync`, ffmpeg byte counts, etc. The log panel shows the - * last N lines so users can see *something* happening during the 5–10 - * min dependency install. - * - * Built on standard shadcn primitives + Tailwind utilities (themed by the - * palette tokens), sharing the breathing-waveform / rise keyframes in - * firstrun.css so setup → install → model wizard reads as one experience. - */ -import { Suspense, lazy, useEffect, useMemo, useRef, useState } from 'react'; -import { - Brush, - Check, - ChevronDown, - ChevronRight, - Clipboard, - FolderOpen, - Globe, - Lightbulb, - Wrench, -} from 'lucide-react'; -import { cn } from '@/lib/utils'; -import { copyText } from '../utils/copyText'; -import { useTranslation } from 'react-i18next'; -import i18n, { LANGUAGES } from '../i18n'; -import { useAppStore } from '../store'; -import { getApiBase } from '../utils/apiBase'; -import { startSplashWatchdog, startHealthRecoveryPoll } from '../utils/splashWatchdog'; -import { flushApplicationPersistence } from '../utils/persistenceLifecycle'; -import { Button, Progress, Select } from '../ui'; -import UiScaleControl from './UiScaleControl'; - -// First-run only: keep the setup screen out of the main bundle so every -// regular launch pays nothing for it. -const FirstRunSetup = lazy(() => import('./FirstRunSetup')); - -const getSystemLanguage = () => { - if (typeof navigator === 'undefined') return 'en'; - const navLang = navigator.language || (navigator.languages && navigator.languages[0]) || 'en'; - if (navLang.toLowerCase().includes('tw') || navLang.toLowerCase().includes('hk')) return 'zh-TW'; - const match = [ - 'zh-CN', - 'es', - 'fr', - 'de', - 'ja', - 'pt', - 'it', - 'ru', - 'ko', - 'hi', - 'tr', - 'pl', - 'nl', - 'sv', - 'th', - 'vi', - 'id', - 'uk', - 'ar', - 'gl', - ].find((code) => navLang.startsWith(code.split('-')[0])); - return match || 'en'; -}; - -// Vite injects package.json version at build time. -const APP_VERSION = __APP_VERSION__ || '0.0.0'; - -const STAGE_LABEL = { - checking: 'Checking environment…', - downloading_uv: 'Downloading uv (Python package manager)…', - creating_venv: 'Creating Python virtual environment…', - installing_deps: 'Installing dependencies — first run, 5–10 min.', - starting_backend: 'Starting backend…', - ready: 'Ready', - failed: 'Setup failed', - ipc_lost: 'Startup issue detected', -}; - -/** Race a promise against a timeout. Used for IPC calls made from the - * recovery panel (#879): the whole point of that state is that IPC may be - * hung, so every invoke gets a bounded wait + a manual fallback. */ -function withTimeout(promise, ms) { - return Promise.race([ - promise, - new Promise((_, reject) => setTimeout(() => reject(new Error('ipc timeout')), ms)), - ]); -} - -/** Platform-default log directory, computed client-side (no IPC available in - * the recovery state). Mirrors src-tauri/src/backend.rs `backend_log_path()`. - * The Windows form uses %LOCALAPPDATA% literally — Explorer expands it. */ -function defaultLogDirForPlatform() { - const ua = typeof navigator !== 'undefined' ? navigator.userAgent || '' : ''; - if (ua.includes('Windows')) return '%LOCALAPPDATA%\\OmniVoice\\Logs'; - if (ua.includes('Mac')) return '~/Library/Logs/OmniVoice'; - return '~/.local/state/OmniVoice'; -} - -/** WebView2 profile cache path shown in the manual-repair fallback (#879). */ -const WEBVIEW_CACHE_PATH_WIN = - '%LOCALAPPDATA%\\com.debpalash.omnivoice-studio\\EBWebView\\Default\\Cache'; - -/** True on Windows. Deliberately reads the user agent, NOT a Tauri plugin — - * in the recovery state IPC is presumed dead, so OS detection must not - * round-trip through it. */ -function isWindowsUA() { - return typeof navigator !== 'undefined' && (navigator.userAgent || '').includes('Windows'); -} - -const STEPS = [ - 'checking', - 'downloading_uv', - 'creating_venv', - 'installing_deps', - 'starting_backend', -]; - -// Stages that mean real install work is underway. `awaiting_setup` counts: Rust -// found no venv, so work is about to start even though FirstRunSetup (not the -// step list) is what renders for it. -const INSTALL_WORK_STAGES = [ - 'downloading_uv', - 'creating_venv', - 'installing_deps', - 'awaiting_setup', -]; - -// How many log lines the
 shows. `logs` state holds exactly this tail and
-// nothing more, so the per-event array copy stays bounded no matter how long a
-// bootstrap runs.
-//
-// The FULL run lives in `allLogsRef` instead (#1847). Four consumers need every
-// line — the Activity counter, the Copy button, the actionable failure hints and
-// the unrecoverable-retry gate — and capping the state they read meant a cold
-// install silently destroyed its own early output. A ref rather than state
-// because appending to it is O(1); `totalLines` is what makes a new line
-// re-render. It lives for exactly one bootstrap: both retry paths clear it, and
-// App.jsx unmounts the splash the moment the stage flips to 'ready'.
-const VISIBLE_LOG_LINES = 200;
-
-/** Scan logs + error message for known failure patterns and return i18n keys
- *  for actionable hints (resolved with `t(...)` at render — English defaults
- *  live in locales/en.json under `bootstrap.hint_*`).
- *
- *  Exported (#1177) so BackendStartFailureNotice — which surfaces the SAME
- *  `BootstrapStage::Failed { message }` after the splash is gone — offers the
- *  same actionable next steps instead of re-deriving a second, drifting set. */
-export function detectHints(message, logs = []) {
-  const hints = [];
-  const all = (message || '') + '\n' + logs.map((l) => l.line).join('\n');
-  if (/README\.md/i.test(all)) hints.push('bootstrap.hint_readme');
-  // python-build-standalone download failure (issue #57, #60): user's network
-  // can't reach the github.com release. We auto-retry with a system-Python
-  // fallback in bootstrap.rs, but if that also fails the user needs an actionable next step.
-  if (/python-build-standalone|managed-python download failed/i.test(all)) {
-    hints.push('bootstrap.hint_python_mirror');
-  }
-  if (/uv.*download|uv.*install/i.test(all) && /timeout|connection/i.test(all))
-    hints.push('bootstrap.hint_uv_timeout');
-  if (/uv sync failed/i.test(all)) hints.push('bootstrap.hint_uv_sync');
-  if (/hatchling|build_editable/i.test(all)) hints.push('bootstrap.hint_build_backend');
-  if (/ffmpeg/i.test(all) && /download|timeout/i.test(all)) hints.push('bootstrap.hint_ffmpeg');
-  // #1223: Windows' WSAEADDRINUSE text is "only one usage of each socket
-  // address is normally permitted" — it contains neither "port ... in use" nor
-  // "address ... in use", and the OS translates it into the user's locale
-  // (the report that surfaced this was in Russian). Match the locale-
-  // independent errnos too: 10048 (Windows), 48 (macOS/BSD), 98 (Linux), and
-  // the backend's own EX_CONFIG exit code for this case.
-  if (
-    /port.*in use|address.*in use|errno 10048|errno 48|errno 98|only one usage of each socket|exit code 78/i.test(
-      all,
-    )
-  )
-    hints.push('bootstrap.hint_port');
-  if (/no error output/i.test(all)) hints.push('bootstrap.hint_silent_crash');
-  if (/seems stuck at|never reported ready/i.test(all)) hints.push('bootstrap.hint_stuck');
-  if (/blocking GitHub|couldn't download Python|python-build-standalone|dns error/i.test(all))
-    hints.push('bootstrap.hint_github_blocked');
-  // Intel-Mac backend unsupported (#889): PyTorch ships no macOS x86_64
-  // wheels, so bootstrap.rs pre-fails with this message before any sync.
-  if (/Intel Macs can't run the local AI backend/i.test(all)) {
-    return ['bootstrap.hint_intel_mac']; // retrying can never help — show only this
-  }
-  if (hints.length === 0) hints.push('bootstrap.hint_default');
-  return hints;
-}
-
-/** Failures no retry can ever fix — offering a Retry button for these is the
- *  dead end #1112 reported ("clicking the buttons does nothing"): the bootstrap
- *  re-fails identically every time. Today that's the Intel Mac (#889): PyTorch
- *  ships no macOS x86_64 wheels, so the dependency set can never resolve there.
- *  Keyed off the same hint the matcher produces, so the two can't drift.
- *  Pure + exported for tests. */
-export function isUnrecoverableFailure(message, logs = []) {
-  return detectHints(message, logs).includes('bootstrap.hint_intel_mac');
-}
-
-function formatEta(seconds) {
-  if (!Number.isFinite(seconds) || seconds <= 0) return '';
-  if (seconds < 60) return '<1m';
-  return `${Math.round(seconds / 60)}m`;
-}
-
-function formatBytes(n) {
-  if (!n || n < 0) return '';
-  const units = ['B', 'KB', 'MB', 'GB'];
-  let i = 0;
-  let v = n;
-  while (v >= 1024 && i < units.length - 1) {
-    v /= 1024;
-    i += 1;
-  }
-  return `${v.toFixed(v < 10 ? 1 : 0)} ${units[i]}`;
-}
-
-/** Whisper waveform — same speech-cadence silhouette as the setup screen.
- *  Memoized like its FirstRunSetup/SetupWizard twins: the splash re-renders
- *  every poll tick and the silhouette never changes. */
-function Waveform({ bars = 96 }) {
-  const heights = useMemo(
-    () =>
-      Array.from({ length: bars }, (_, i) => {
-        const t = i / bars;
-        const v = Math.abs(
-          Math.sin(t * Math.PI * 7.3) * 0.55 +
-            Math.sin(t * Math.PI * 2.1 + 1.2) * 0.3 +
-            Math.sin(t * Math.PI * 17.0 + 0.4) * 0.15,
-        );
-        return 0.18 + v * 0.82;
-      }),
-    [bars],
-  );
-  return (
-    
-  );
-}
-
-/** Three-stage breadcrumb — setup done, installing active. */
-function JourneyRail({ t }) {
-  const stages = [
-    [t('firstrun.stage_setup', 'Setup'), 'done'],
-    [t('firstrun.installing_title', 'Installing'), 'active'],
-    [t('firstrun.stage_models', 'Models & engines'), 'pending'],
-  ];
-  return (
-    
-  );
-}
-
-/**
- * Recovery panel for the stuck-startup state (#879): the Tauri IPC layer is
- * silent AND the backend never answered /health within the recovery window.
- * Explains what happened and offers actionable exits instead of an infinite
- * spinner. The "Repair and restart" affordance is Windows-only (it clears the
- * cache-only directories under the WebView2 `EBWebView` profile — a
- * Windows-specific artifact) and only
- * exists inside this error-recovery state, never as default-mode UI.
- */
-function IpcLostRecovery({ t }) {
-  const [showLogHint, setShowLogHint] = useState(false);
-  const [repairing, setRepairing] = useState(false);
-  const [repairFailed, setRepairFailed] = useState(false);
-
-  const handleOpenLogs = async () => {
-    try {
-      // Best effort over IPC (it may be partially alive); bounded so a hung
-      // invoke can't make the button feel dead.
-      const { invoke } = await import('@tauri-apps/api/core');
-      const tail = await withTimeout(invoke('read_log_tail', { source: 'backend' }), 3000);
-      if (!tail?.path) throw new Error('no log path');
-      const { revealItemInDir } = await import('@tauri-apps/plugin-opener');
-      await withTimeout(revealItemInDir(tail.path), 3000);
-    } catch {
-      // IPC is dead (the expected case here) — show where the logs live.
-      setShowLogHint(true);
-    }
-  };
-
-  const handleRepairRestart = async () => {
-    if (repairing) return;
-    if (!confirm(t('bootstrap.ipc_lost_repair_confirm'))) return;
-    setRepairing(true);
-    try {
-      const { invoke } = await import('@tauri-apps/api/core');
-      try {
-        await flushApplicationPersistence();
-      } catch (error) {
-        // Persistence may be the broken subsystem that led here. Keep the
-        // explicit recovery action available, matching the native exit timeout.
-        console.warn('[persistence] cache-repair flush failed', error);
-      }
-      // The command returns once the persistence-gated restart is queued; its
-      // native three-second deadline handles a webview that cannot acknowledge.
-      // This outer timeout catches an IPC bridge too broken to queue it at all.
-      await withTimeout(invoke('clear_webview_cache_and_relaunch'), 8000);
-    } catch (e) {
-      if (e?.message !== 'ipc timeout') console.error('repair failed', e);
-      setRepairFailed(true);
-      setRepairing(false);
-    }
-  };
-
-  return (
-    
-

- {t('bootstrap.ipc_lost_title', "The app can't finish starting")} -

-

{t('bootstrap.ipc_lost_body')}

- {showLogHint && ( - - {t('bootstrap.ipc_lost_log_hint', { path: defaultLogDirForPlatform() })} - - )} - {repairFailed && ( - - {t('bootstrap.ipc_lost_repair_failed', { path: WEBVIEW_CACHE_PATH_WIN })} - - )} -
- - {isWindowsUA() && ( - - )} -
-
- ); -} - -/** Mono error block. */ -/** When the backend last produced ANY line of bootstrap output. - * - * #1791: the stall watchdog in `useBootstrapStage` keys on `bootstrap_status`, - * which sits on a single stage for the whole of a slow start — a cold `import - * torch` off a mapped network drive can hold `starting_backend` for many - * minutes. The narration that proves it is alive ("Loading ML runtime - * (PyTorch)…") arrives on the separate `bootstrap-log` event stream instead, - * so the watchdog never saw it and called a live launch stuck. A splash that - * is still printing new lines is by definition not the info-less spinner the - * watchdog exists to break. - * - * Module-scoped rather than a ref because the two halves live in different - * components — `BootstrapSplash` owns the event subscription, `useBootstrapStage` - * owns the watchdog — and they are always mounted as a pair. - */ -let lastBootstrapLogTs = 0; - -export function noteBootstrapLogActivity(ts = Date.now()) { - lastBootstrapLogTs = ts; -} - -function ErrorBox({ children }) { - return ( -
-      {children}
-    
- ); -} - -export function BootstrapSplash({ stage, message, attempt = 0 }) { - const { t } = useTranslation(); - const locale = useAppStore((s) => s.locale); - const setLocale = useAppStore((s) => s.setLocale); - - const handleLocaleChange = (id) => { - setLocale(id); - i18n.changeLanguage(id); - }; - - const systemLang = getSystemLanguage(); - const [showSuggestion, setShowSuggestion] = useState(false); - - useEffect(() => { - const dismissed = localStorage.getItem('dismissed_lang_suggestion'); - if (systemLang !== locale && systemLang !== 'en' && !dismissed) { - setShowSuggestion(true); - } - }, [locale, systemLang]); - - const acceptSuggestion = () => { - handleLocaleChange(systemLang); - setShowSuggestion(false); - }; - - const dismissSuggestion = () => { - localStorage.setItem('dismissed_lang_suggestion', 'true'); - setShowSuggestion(false); - }; - - // ── Hooks FIRST, derived values AFTER ────────────────────────────────── - // Every useState/useRef must be declared before any plain `const` that - // reads its result. When a derived const (e.g. `isUnrecoverable`, which - // reads `logs`) sits *between* two hook calls, the production minifier - // (esbuild) merges the declarations into one comma-list and can hoist the - // derived const ahead of the `useState` binding it depends on — emitting - // `isUnrecoverable = isFailed && f(message, logs), [logs] = useState([])`. - // That is a temporal-dead-zone access ("Cannot access 'logs' before - // initialization"): it throws during render, React unmounts to an empty - // #root, and the whole app is a black screen. Dev/unminified builds - // short-circuit on `isFailed` so they never trip it — it only bites the - // minified release bundle (shipped in v0.3.22). Keeping all hooks above all - // derived reads makes the class impossible regardless of how the minifier - // reorders. (Guarded by tests/frontend that no derived const is interleaved - // among hooks.) - const [logs, setLogs] = useState([]); - const [logsOpen, setLogsOpen] = useState(true); - const [copied, setCopied] = useState(false); - const [progress, setProgress] = useState(null); - const [region, setRegionState] = useState('auto'); - const [retrying, setRetrying] = useState(false); - // Stages the status poll has reported during the current attempt. - const [polledStages, setPolledStages] = useState(() => new Set([stage])); - // Every line of this bootstrap. `logs` above is only the rendered tail. - const [totalLines, setTotalLines] = useState(0); - const allLogsRef = useRef([]); - // Backfill and the live listener can overlap by a few lines at handover. - // Dedup guards that seam and nothing else — see the listener. - const handoverDoneRef = useRef(false); - const logRef = useRef(null); - const prevAttemptRef = useRef(attempt); // last attempt id Rust reported - const prevProgRef = useRef(null); // {bytes, t} — last progress event - const rateRef = useRef(0); // EMA bytes/sec across events - - // A stage counts as observed when the poll reported it OR a stage-tagged log - // line of this attempt proves it ran. Polling is ~1/s, so a quick stage can - // slip between two ticks; its log lines are separate evidence. Lines are - // matched on attempt id equality, so a retry never inherits proof from a - // previous run. - const observedStages = useMemo(() => { - const seen = new Set(polledStages); - for (const entry of allLogsRef.current) { - if (entry.stage && entry.attempt === attempt) seen.add(entry.stage); - } - return seen; - // allLogsRef is a ref; totalLines is the signal that it changed. - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [polledStages, totalLines, attempt]); - - const label = t(`bootstrap.${stage}`, STAGE_LABEL[stage]); - const stepIndex = Math.max(0, STEPS.indexOf(stage)); - const isFailed = stage === 'failed'; - // Retrying an Intel-Mac install can never succeed — don't offer the dead end. - // Reads the full run, not the rendered tail: an Intel-Mac marker printed - // early in a long install used to scroll out of the capped array, and the - // dead-end detection went with it. Only evaluated once `isFailed`, by which - // point no more lines are arriving. - const isUnrecoverable = isFailed && isUnrecoverableFailure(message, allLogsRef.current); - - const resetLogs = () => { - allLogsRef.current = []; - handoverDoneRef.current = false; - setTotalLines(0); - setLogs([]); - }; - - const installWorkSeen = INSTALL_WORK_STAGES.some((s) => observedStages.has(s)); - - // Fresh-run presentation reset for a user-requested retry. Where an attempt - // begins is decided by Rust (#1900); this only clears what is on screen. - const beginAttempt = () => { - resetLogs(); - setPolledStages(new Set()); - }; - - const handleRetry = async () => { - if (retrying) return; - setRetrying(true); - try { - const { invoke } = await import('@tauri-apps/api/core'); - beginAttempt(); - await invoke('retry_bootstrap'); - } catch (e) { - console.error('retry failed', e); - } finally { - setRetrying(false); - } - }; - - const handleCleanRetry = async () => { - if (retrying) return; - if (!confirm(t('bootstrap.clean_retry_confirm'))) return; - setRetrying(true); - try { - const { invoke } = await import('@tauri-apps/api/core'); - beginAttempt(); - await invoke('clean_and_retry_bootstrap'); - } catch (e) { - console.error('clean retry failed', e); - } finally { - setRetrying(false); - } - }; - - // Track observed stages. Within an attempt the set only grows; a new attempt - // id (compared by equality alone) starts it over from the current stage. - useEffect(() => { - if (prevAttemptRef.current !== attempt) { - prevAttemptRef.current = attempt; - setPolledStages(new Set([stage])); - return; - } - setPolledStages((prev) => { - if (prev.has(stage)) return prev; - const next = new Set(prev); - next.add(stage); - return next; - }); - }, [stage, attempt]); - - // Load persisted region on mount. - useEffect(() => { - if (typeof window === 'undefined' || !('__TAURI_INTERNALS__' in window)) return; - (async () => { - try { - const { invoke } = await import('@tauri-apps/api/core'); - const r = await invoke('get_region'); - if (r) setRegionState(r); - } catch { - /* older build without region support */ - } - })(); - }, []); - - const handleRegionChange = async (newRegion) => { - setRegionState(newRegion); - try { - const { invoke } = await import('@tauri-apps/api/core'); - await invoke('set_region', { region: newRegion }); - } catch { - /* silent */ - } - }; - - // Subscribe to live log + progress events from the Rust bootstrap. - // Also backfill any logs emitted before the webview finished loading. - useEffect(() => { - if (typeof window === 'undefined') return; - if (!('__TAURI_INTERNALS__' in window)) return; - let unlistenLog = null; - let unlistenProgress = null; - let cancelled = false; - - (async () => { - try { - const { listen } = await import('@tauri-apps/api/event'); - const { invoke } = await import('@tauri-apps/api/core'); - if (cancelled) return; - - // Backfill: fetch all log lines buffered on the Rust side before - // the webview was ready to receive events. - try { - const buffered = await invoke('get_bootstrap_logs'); - if (!cancelled && Array.isArray(buffered) && buffered.length > 0) { - const entries = buffered.map(({ attempt: a, stage: s, line }) => ({ - attempt: a ?? 0, - stage: s, - line, - t: Date.now(), - })); - allLogsRef.current = entries; - setTotalLines(entries.length); - setLogs(entries.slice(-VISIBLE_LOG_LINES)); - } - } catch { - /* command may not exist in older builds */ - } - - // Subscribe to live events for anything new from here on. - unlistenLog = await listen('bootstrap-log', (e) => { - const { attempt: a, stage: s, line } = e.payload || {}; - if (!line) return; - noteBootstrapLogActivity(); - // Dedup ONLY across the backfill→live seam. The overlap it exists - // for can only happen on the first live event; running it for the - // whole bootstrap silently dropped legitimate repeats, and installer - // output repeats itself constantly. Telling a true repeat from a - // replayed one needs a sequence number from the Rust side, so the - // window is narrowed to where the ambiguity actually is instead of - // guessing for the rest of the run. - if (!handoverDoneRef.current) { - const seam = allLogsRef.current.slice(-5); - // The attempt is part of the identity (#1900, CodeRabbit): the - // same stage and the same text from a DIFFERENT attempt is not a - // replay of a buffered line, it is this attempt's own evidence. - // Matching on stage+line alone dropped it, which can remove the - // only proof for a stage the poll never sampled. - if (seam.some((l) => l.attempt === (a ?? 0) && l.stage === s && l.line === line)) - return; - handoverDoneRef.current = true; - } - const entry = { attempt: a ?? 0, stage: s, line, t: Date.now() }; - allLogsRef.current.push(entry); - setTotalLines(allLogsRef.current.length); - setLogs((prev) => { - const next = prev.concat([entry]); - return next.length > VISIBLE_LOG_LINES - ? next.slice(next.length - VISIBLE_LOG_LINES) - : next; - }); - }); - unlistenProgress = await listen('bootstrap-progress', (e) => { - const payload = e.payload || null; - // EMA byte-rate from successive events → ETA for the long stretch. - if (payload?.bytes_done != null) { - const now = Date.now(); - const prev = prevProgRef.current; - if (prev && payload.bytes_done > prev.bytes && now > prev.t) { - const inst = (payload.bytes_done - prev.bytes) / ((now - prev.t) / 1000); - rateRef.current = rateRef.current ? rateRef.current * 0.7 + inst * 0.3 : inst; - } - prevProgRef.current = { bytes: payload.bytes_done, t: now }; - } - setProgress(payload); - }); - } catch { - /* not in Tauri or listen unavailable — silent */ - } - })(); - return () => { - cancelled = true; - if (unlistenLog) unlistenLog(); - if (unlistenProgress) unlistenProgress(); - }; - }, []); - - // Auto-scroll the log panel to the latest line whenever it opens or - // new lines arrive. - useEffect(() => { - if (logsOpen && logRef.current) { - logRef.current.scrollTop = logRef.current.scrollHeight; - } - }, [logs, logsOpen]); - - // Auto-expand logs on failure so users can see + copy the full output. - useEffect(() => { - if (isFailed) setLogsOpen(true); - }, [isFailed]); - - // Serializes the WHOLE run, not the visible tail (#1847). A user filing a - // bootstrap bug is asked for this output, and the early lines — which stage - // failed first, which mirror was reached — are the ones that scrolled out. - const handleCopyLogs = () => { - const all = allLogsRef.current; - const logText = - all.length === 0 - ? 'No log output captured.' - : all.map((l) => `[${l.stage}] ${l.line}`).join('\n'); - const full = - isFailed && message ? `ERROR: ${message}\n\n--- Bootstrap Logs ---\n${logText}` : logText; - copyText(full) - .then(() => { - setCopied(true); - setTimeout(() => setCopied(false), 2000); - }) - .catch(() => {}); - }; - - const stageProgress = progress && progress.stage === stage ? progress : null; - const pctFromBytes = stageProgress?.percent != null ? stageProgress.percent : null; - // Overall journey progress: completed steps + byte-progress within the - // current step when the backend reports it. - const overallPct = Math.min( - 100, - ((stepIndex + (pctFromBytes != null ? pctFromBytes / 100 : 0.4)) / STEPS.length) * 100, - ); - - // First run with nothing installed: Rust parks in `awaiting_setup` and the - // install-plan screen takes over. complete_setup advances the stage, and - // the regular progress UI below resumes automatically on the next poll. - // (Checked after every hook above so the setup → install transition keeps - // the hook order stable.) - if (stage === 'awaiting_setup') { - return ( - }> - - - ); - } - - return ( -
-
- {/* ── Masthead: same identity as the setup screen ─────────────────── */} -
- - {installWorkSeen && } -
-
- {/* Version rides beside the app name — same masthead across all - three first-run acts (setup → install → models & engines), so a - screenshot from any of them identifies the build. */} -
-

- {t('bootstrap.title', 'VoiceStudio')} -

- - v{APP_VERSION} - -
-

- {label} -

-
-
- - - -
-
-
- - {showSuggestion && ( -
- - {' '} - {t('bootstrap.suggest_lang', { - lang: LANGUAGES.find((l) => l.code === systemLang)?.label || systemLang, - })} - -
- - -
-
- )} - - {stage === 'ipc_lost' ? ( - - ) : isFailed ? ( -
-

- {t('bootstrap.failed', 'Setup failed')} -

- {message || t('bootstrap.unknown_error')} -
- - {t('bootstrap.what_to_try', 'What to try:')} - -
    - {detectHints(message, allLogsRef.current).map((key) => ( -
  • {t(key)}
  • - ))} -
-
-
- {/* #1112: some failures can NEVER be retried away — an Intel Mac - has no PyTorch wheels, so every retry re-fails identically and - the buttons just look broken ("clicking them does nothing"). - Say so plainly and don't offer the dead end. */} - {isUnrecoverable ? ( - - {t( - 'bootstrap.unrecoverable', - 'Retrying cannot fix this — see the guidance above.', - )} - - ) : ( - <> - - - - )} -
-
- ) : ( -
- {installWorkSeen && ( -

- {t('firstrun.installing_title', 'Installing')} -

- )} - {/* Overall journey meter. */} - - {installWorkSeen && ( -
    - {STEPS.map((s, i) => { - const active = i === stepIndex; - // Never infer "done" from list position: warm starts and repair - // syncs skip the earlier stages entirely. - const done = !active && observedStages.has(s); - const total = stageProgress?.bytes_total ?? stageProgress?.total_bytes; - const bytesDone = stageProgress?.bytes_done; - const hasTotal = total > 0; - const showEta = - hasTotal && rateRef.current > 0 && bytesDone != null && bytesDone < total; - return ( -
  1. -
  2. - ); - })} -
- )} - {installWorkSeen && ( -

- {t( - 'firstrun.resume_note', - 'Interrupted downloads pick up where they left off. You can close the app safely.', - )} -

- )} -
- )} - - {/* ── Live log — always reachable, quiet by design ────────────────── */} -
-

- {t('firstrun.activity_title', 'Activity')} - - {totalLines > 0 && t('bootstrap.lines', { count: totalLines })} - -

-
- - -
- {logsOpen && ( -
-              {logs.length === 0
-                ? t('bootstrap.waiting_output', 'Waiting for output…')
-                : logs.map((l) => `[${l.stage}] ${l.line}`).join('\n')}
-            
- )} -
-
-
- ); -} - -/** - * Hook: polls the Rust `bootstrap_status` command every pollMs ms. Returns - * the current stage (string) + message. In a non-Tauri context (dev web), - * returns 'ready' immediately so the splash never mounts. - */ -export function useBootstrapStage(pollMs = 1000) { - // `attempt` is Rust's bootstrap-attempt id (#1900). 0 means "none reported", - // which is where the non-Tauri and dev-web short-circuits below settle. - const [state, setState] = useState({ stage: 'checking', message: null, attempt: 0 }); - - useEffect(() => { - if (typeof window === 'undefined') { - setState({ stage: 'ready', message: null, attempt: 0 }); - return; - } - if (!('__TAURI_INTERNALS__' in window)) { - setState({ stage: 'ready', message: null, attempt: 0 }); - return; - } - if (import.meta.env.DEV) { - setState({ stage: 'ready', message: null, attempt: 0 }); - return; - } - - let cancelled = false; - let timer = null; - let misses = 0; - // #1156: `failed` is terminal for the IPC poll loop, and by then the - // successful IPC reply has disarmed the #879 watchdog — so nothing was - // left to notice the backend coming back (supervisor restart, finished - // repair) and the "Setup failed" card trapped the user until a manual - // reload. On entering `failed`, poll /health over plain HTTP and - // auto-dismiss to the app the moment the backend answers. - let failedRecovery = null; - const startFailedRecovery = () => { - if (failedRecovery || cancelled) return; - failedRecovery = startHealthRecoveryPoll({ - healthUrl: `${getApiBase()}/health`, - onHealthy: () => { - if (cancelled) return; - setState({ stage: 'ready', message: null, attempt: 0 }); - }, - }); - }; - // IPC watchdog (#879): the poll loop below rides entirely on Tauri IPC. - // After an unclean shutdown, a corrupted WebView cache can break BOTH the - // IPC custom protocol and its postMessage fallback — `invoke()` then hangs - // without ever resolving OR rejecting, so neither the stall watchdog - // (#474) nor the miss counter below can fire, and the splash would spin - // forever even with a healthy backend. This watchdog is IPC-independent: - // if no `bootstrap_status` response arrives at all, it polls /health over - // plain HTTP and either proceeds to the app ('ready') or flips to the - // 'ipc_lost' recovery panel. Started synchronously, before the dynamic - // import — in a corrupted-webview world even that import may stall. - let httpForcedReady = false; - const watchdog = startSplashWatchdog({ - healthUrl: `${getApiBase()}/health`, - onReadyViaHttp: () => { - if (cancelled) return; - httpForcedReady = true; - setState({ stage: 'ready', message: null, attempt: 0 }); - }, - onStuck: () => { - if (cancelled || httpForcedReady) return; - setState({ stage: 'ipc_lost', message: null, attempt: 0 }); - }, - }); - // Stall watchdog (#474): if the backend hangs in a non-terminal stage and - // never reports `ready` (e.g. a failed Python-backend spawn on a from-source - // build), the poll loop would otherwise spin forever and trap the user on a - // buttonless splash. Track when the (stage,message) last changed; if it - // stays put past the stage's budget, flip to `failed` so the existing - // hints + Retry + logs surface instead of an info-less infinite spinner. - // installing_deps legitimately runs 5–10 min, so it gets a long leash; any - // (stage,message) change resets the clock so a live install never trips it. - let lastChangeTs = Date.now(); - let lastKey = ''; - // `awaiting_setup` is gated on a HUMAN, not on work. Rust parks there - // deliberately ("nothing downloads or installs in this stage — - // complete_setup is the only way out of it") and waits for the install - // plan: mode, storage locations, region, mirrors. That is a screen built - // for deliberation, and a person reading it routinely takes longer than - // any machine stage — so a stall budget there fires on a perfectly healthy - // first run, replaces the setup screen with "Setup failed", and stops the - // IPC poll. Retry re-enters the bootstrap, which parks at awaiting_setup - // again, and it fails again on the same clock: an unescapable loop on the - // very first thing a new user sees (#1376). No budget for a stage only a - // person can leave. - const stallBudgetMs = (stage) => { - if (stage === 'awaiting_setup') return Infinity; - if (stage === 'installing_deps') return 20 * 60 * 1000; - // Rust owns the backend launch and waits up to five minutes so slow - // torch/CUDA imports can finish. Keep the splash alive beyond that - // window; otherwise it reports a false failure at two minutes while - // the supervised backend is still healthy and making progress (#1749). - return stage === 'starting_backend' ? 6 * 60 * 1000 : 120 * 1000; - }; - const invoke = async () => { - try { - const { invoke: tauriInvoke } = await import('@tauri-apps/api/core'); - return tauriInvoke; - } catch { - return null; - } - }; - (async () => { - const tauriInvoke = await invoke(); - if (!tauriInvoke) { - watchdog.cancel(); - setState({ stage: 'ready', message: null, attempt: 0 }); - return; - } - const tick = async () => { - if (cancelled) return; - try { - const res = await tauriInvoke('bootstrap_status'); - if (cancelled) return; - // IPC answered — the normal path owns the transition; disarm the - // HTTP watchdog for good (#879). But if the watchdog already - // force-transitioned to the app via HTTP health, a late-thawing - // IPC response must not yank the user back to the splash. - watchdog.markIpcAlive(); - if (httpForcedReady) return; - misses = 0; - const stage = res.stage || 'ready'; - const message = res.message || null; - // Rust's bootstrap-attempt id (#1900). A build that predates the - // field reports nothing, which reads as 0 — never a live attempt. - const attempt = typeof res.attempt === 'number' ? res.attempt : 0; - // Reset the stall clock whenever something actually changes. - const key = `${stage}|${message || ''}`; - if (key !== lastKey) { - lastKey = key; - lastChangeTs = Date.now(); - } - // Rust returns { stage: 'ready' } or { stage: 'failed', message: '…' } etc. - if (stage !== 'ready' && stage !== 'failed') { - const lastActivity = Math.max(lastChangeTs, lastBootstrapLogTs); - if (Date.now() - lastActivity > stallBudgetMs(stage)) { - // Stuck — surface it as a failure so Retry/logs/hints appear. - setState({ - attempt, - stage: 'failed', - message: - (message ? message + '\n\n' : '') + - `Setup seems stuck at "${stage}" — the backend never reported ready. ` + - `Check the log below, then Retry. If you're running from source, make sure ` + - `\`uv sync\` completed and uv/Python are on your PATH.`, - }); - startFailedRecovery(); - return; // stop IPC polling — only /health recovery remains - } - setState({ attempt, stage, message }); - timer = setTimeout(tick, pollMs); - } else { - setState({ attempt, stage, message }); - if (stage === 'failed') startFailedRecovery(); - } - } catch { - // A transient IPC hiccup (e.g. the very first poll racing webview - // init) must NOT permanently declare 'ready' — that kills the poll - // loop and silently skips the awaiting_setup / progress screens. - // Retry a few times before conceding. - misses += 1; - if (cancelled) return; - if (misses < 5) { - timer = setTimeout(tick, pollMs); - } else { - // Conceding 'ready' after repeated fast rejections — stop the - // HTTP watchdog too, so it can't flip to 'ipc_lost' underneath - // the already-mounted main UI (#879). - watchdog.cancel(); - setState({ stage: 'ready', message: null, attempt: 0 }); - } - } - }; - tick(); - })(); - return () => { - cancelled = true; - watchdog.cancel(); - if (failedRecovery) failedRecovery.cancel(); - if (timer) clearTimeout(timer); - }; - }, [pollMs]); - - return state; -} diff --git a/electron/src/shared/components/DictationDemo.jsx b/electron/src/shared/components/DictationDemo.jsx deleted file mode 100644 index b781a29b0..000000000 --- a/electron/src/shared/components/DictationDemo.jsx +++ /dev/null @@ -1,365 +0,0 @@ -/** - * DictationDemo — guided walkthrough for the real-time dictation feature. - * - * What this surfaces: - * 1. Active hotkey display (including a portal-selected Wayland shortcut). - * 2. Three script cards — short utterances the user can read aloud OR - * replay from a bundled WAV. The replay path posts the bundled audio - * to POST /transcribe and renders the recognized text below the card - * so dictation can be demoed even when the user hasn't granted mic - * permission yet, or is on a headless / VM / CI box. - * 3. Hotkey verification status — subscribes to the `tray-dictate` and - * `tray-dictate-stop` Tauri events so we can show "verified" the - * moment the user presses the shortcut for the first time. - * - * Cross-platform: the replay path uses the existing backend transcribe - * endpoint and works identically on macOS / Windows / Linux. The hotkey - * verification path requires Tauri (gracefully no-ops in the web UI). - * - * Where this is mounted: - * - Settings → Capture & Dictation (above HotkeyTab) — always available - * - SetupWizard step 4 — first-run onboarding - */ -import { useEffect, useRef, useState } from 'react'; -import { Play, Pause, Keyboard, Mic, CheckCircle2, AlertTriangle } from 'lucide-react'; -import { useTranslation } from 'react-i18next'; -import { API, apiFetch } from '../api/client'; -import { asrMissingPayload, toastAsrModelMissing } from '../utils/asrModelMissing'; -import { useEffectiveDictationShortcut } from '../hooks/useEffectiveDictationShortcut'; -import { useDictationReadiness } from '../hooks/useDictationReadiness'; -import AsrModelChooser from './AsrModelChooser'; -import { Button } from '../ui'; - -// Shared status-pill base; per-state color/bg/border appended below. The gruvbox -// status hues are intentionally preserved (palette kept) as arbitrary utilities. -const STATUS_BASE = - 'inline-flex items-center gap-[6px] text-[11px] px-[8px] py-[3px] rounded-[999px] border'; - -const SCRIPTS = [ - { - id: 'en_conversational', - labelKey: 'demo.script_conversational', - language: 'English', - text: 'Schedule a meeting with Pat for Tuesday at three PM and remind me to bring the quarterly report.', - wav: '/demo_audio/dictation/en_conversational.wav', - }, - { - id: 'en_technical', - labelKey: 'demo.script_technical', - language: 'English', - text: 'Patch the WebGPU shader in renderer.tsx, then bump pnpm to nine point fifteen and rerun the Vitest suite.', - wav: '/demo_audio/dictation/en_technical.wav', - }, - { - id: 'fr_reservation', - labelKey: 'demo.script_french', - language: 'French', - text: 'Bonjour, je voudrais réserver une table pour deux personnes à vingt heures.', - wav: '/demo_audio/dictation/fr_reservation.wav', - }, -]; - -function isTauri() { - return typeof window !== 'undefined' && '__TAURI_INTERNALS__' in window; -} - -export default function DictationDemo({ embedded = false }) { - const { t } = useTranslation(); - const [hotkeyState, setHotkeyState] = useState('unknown'); // unknown | registered | verified - const desktop = isTauri(); - const { info: shortcut } = useEffectiveDictationShortcut(desktop); - // Transcribing a sample needs a speech-to-text model, and the mandatory-only - // install path ships none. Rendering the cards regardless meant the final - // onboarding step opened with one hard error per card and invited the user - // to press a hotkey that could not work (#1856). Probed for the same reason - // the demo already probes for its sample WAVs below. - const readiness = useDictationReadiness(); - const [playingId, setPlayingId] = useState(null); - const [transcripts, setTranscripts] = useState({}); // {scriptId: {state, text, error}} - // null = probing, true/false once the demo assets are confirmed present. - // The sample WAVs are rendered by scripts/build_demos.sh and may be absent - // (e.g. source checkout without a render step). When absent we hide the demo - // rather than show cards that fail on click (#119/#124 follow-up). - const [assetsAvailable, setAssetsAvailable] = useState(null); - const audioRef = useRef(null); - - // Probe whether the bundled dictation samples actually exist; hide the whole - // demo if not, mirroring DubbingDemo's missing-manifest behavior. - useEffect(() => { - let cancelled = false; - apiFetch(`${API}${SCRIPTS[0].wav}`, { method: 'HEAD' }) - .then(() => { - if (!cancelled) setAssetsAvailable(true); - }) - .catch(() => { - if (!cancelled) setAssetsAvailable(false); - }); - return () => { - cancelled = true; - }; - }, []); - - useEffect(() => { - if (!desktop) return; - // `unregistered` is its own state, not a flavour of `unknown`: the OS - // refused the accelerator, usually because another app already holds it - // (the default collides with 1Password Quick Access on macOS). Saying - // "no hotkey registered" there would read as "we have not checked yet", - // when what the user needs to know is that this specific combination is - // taken and they should pick another (#1858). - setHotkeyState((current) => { - if (shortcut.backend === 'unregistered') return 'unregistered'; - if (current === 'verified') return current; - return shortcut.backend === 'focused' ? 'unknown' : 'registered'; - }); - }, [desktop, shortcut.backend]); - - // Subscribe to dictation events: the moment the user presses their - // hotkey while this panel is mounted, flip to verified. - useEffect(() => { - if (!isTauri()) return; - let unlistenStart, unlistenStop; - (async () => { - try { - const { listen } = await import('@tauri-apps/api/event'); - unlistenStart = await listen('tray-dictate', () => { - setHotkeyState('verified'); - }); - unlistenStop = await listen('tray-dictate-stop', () => { - setHotkeyState('verified'); - }); - } catch { - // Tauri event API unavailable — leave state alone. - } - })(); - return () => { - try { - unlistenStart && unlistenStart(); - } catch { - /* noop */ - } - try { - unlistenStop && unlistenStop(); - } catch { - /* noop */ - } - }; - }, []); - - const togglePlay = (script) => { - const audio = audioRef.current; - if (!audio) return; - if (playingId === script.id) { - audio.pause(); - setPlayingId(null); - return; - } - audio.src = `${API}${script.wav}`; - audio.currentTime = 0; - audio - .play() - .then(() => setPlayingId(script.id)) - .catch((e) => { - console.warn('Sample playback failed:', e); - setPlayingId(null); - }); - }; - - // Replay path: fetch the bundled WAV, post it to the transcribe endpoint, - // render what the engine heard. Demonstrates the full dictation pipeline - // without requiring mic permission or a hotkey press. - const replay = async (script) => { - setTranscripts((prev) => ({ - ...prev, - [script.id]: { state: 'loading', text: '', error: '' }, - })); - try { - const wavRes = await apiFetch(`${API}${script.wav}`); - const blob = await wavRes.blob(); - const fd = new FormData(); - fd.append('audio', blob, `${script.id}.wav`); - const tRes = await apiFetch(`${API}/transcribe`, { method: 'POST', body: fd }); - const json = await tRes.json(); - setTranscripts((prev) => ({ - ...prev, - [script.id]: { state: 'ok', text: json.text || '', error: '' }, - })); - } catch (e) { - // Typed 409 on a TTS-only install: no ASR model on disk. Render the - // human message + the one-click download CTA instead of the raw - // "409 Conflict: …" string. - const missing = asrMissingPayload(e); - if (missing) toastAsrModelMissing(missing); - setTranscripts((prev) => ({ - ...prev, - [script.id]: { - state: 'fail', - text: '', - error: missing ? t('asr_missing.message') : e?.message || String(e), - }, - })); - } - }; - - const statusBadge = (() => { - switch (hotkeyState) { - case 'verified': - return ( - - {t('demo.dictation_status_ok')} - - ); - case 'unregistered': - return ( - - {' '} - {t('demo.dictation_status_taken', { - defaultValue: - 'Another app already uses this shortcut — pick a different one in Settings.', - })}{' '} - - {shortcut.display} - - - ); - case 'registered': - return ( - - {t('demo.dictation_status_pending')}{' '} - - {shortcut.display} - - - ); - default: - return ( - - {t('demo.dictation_status_warn')} - - ); - } - })(); - - // The hotkey card always has something real to teach (the registered - // shortcut + live press-to-verify) — only the replayable script cards - // depend on the bundled WAVs, which installs don't always ship. Hiding - // the whole panel left the wizard's "Try dictation" act completely - // blank on every such install (#119/#124 follow-up, refined). - // `checking` still shows the cards: the probe resolves in well under a - // second and flashing the install panel first would be worse than a brief - // wait. Only a confirmed-missing model swaps them out. - const asrMissing = readiness.phase === 'missing'; - const showScripts = assetsAvailable !== false && !asrMissing; - - return ( -
-
-

- {t('demo.dictation_title')} -

- {statusBadge} -
- -

- {showScripts - ? t('demo.dictation_lede') - : t( - 'demo.dictation_lede_hotkey_only', - 'Hold the shortcut above anywhere on your desktop, speak, release — the text lands in whatever app has focus. Press it now to verify it works.', - )} -

- -
- ); -} diff --git a/electron/src/shared/components/DictationModelPicker.jsx b/electron/src/shared/components/DictationModelPicker.jsx deleted file mode 100644 index 7fda11c34..000000000 --- a/electron/src/shared/components/DictationModelPicker.jsx +++ /dev/null @@ -1,129 +0,0 @@ -import React, { useEffect, useState } from 'react'; -import { Check, Download, Loader } from 'lucide-react'; -import { useQuery } from '@tanstack/react-query'; -import { useTranslation } from 'react-i18next'; -import { apiJson } from '../api/client'; -import { useInstallModel } from '../api/hooks'; -import { useAppStore } from '../store'; - -function fmtSize(sizeGb) { - if (sizeGb == null) return ''; - if (sizeGb < 1) return `${Math.round(sizeGb * 1000)} MB`; - return `${sizeGb.toFixed(sizeGb < 10 ? 1 : 0)} GB`; -} - -/** - * The sherpa-onnx dictation model list, nested under the "Sherpa-ONNX - * dictation" row of the Transcription engine picker. The engine row switches - * the *engine*; this switches which of the seven catalogue models that engine - * (and the live-dictation hotkey) loads — the same `dictation.model_id` pref - * the Settings → Voice panel writes, so both surfaces always agree. - * - * Picking a model that isn't downloaded yet persists the choice and starts - * the download in one click (mirrors VoicePanel.onPick): the user gets the - * model the moment it lands rather than a second "now install it" step. - */ -export default function DictationModelPicker({ embedded = false }) { - const { t } = useTranslation(); - const modelId = useAppStore((s) => s.dictationModelId); - const setModelId = useAppStore((s) => s.setDictationModelId); - const loadPrefs = useAppStore((s) => s.loadDictationPrefs); - const dictationLoaded = useAppStore((s) => s.dictationLoaded); - const installMutation = useInstallModel(); - const [installing, setInstalling] = useState(() => new Set()); - - useEffect(() => { - if (!dictationLoaded) loadPrefs(); - }, [dictationLoaded, loadPrefs]); - - const { data, refetch } = useQuery({ - queryKey: ['dictation-models'], - queryFn: () => apiJson('/dictation/models'), - staleTime: 10_000, - retry: false, - // While a download runs, poll so the "installed" state flips without a - // reopen — the quick menu has no SSE progress stream of its own. - refetchInterval: installing.size > 0 ? 2_000 : false, - }); - const models = Array.isArray(data?.models) ? data.models : []; - if (models.length === 0) return null; - - const selectedId = models.some((m) => m.id === modelId) - ? modelId - : (models.find((m) => m.recommended) || models[0]).id; - - const pick = async (model) => { - if (model.id !== selectedId) setModelId(model.id); - if (model.installed || installing.has(model.repo_id)) return; - setInstalling((prev) => new Set(prev).add(model.repo_id)); - try { - await installMutation.mutateAsync(model.repo_id); - await refetch(); - } catch { - // The install surface (Settings → Voice / Model Catalogue) reports the - // failure with full detail; here the row simply returns to "download". - } finally { - setInstalling((prev) => { - const next = new Set(prev); - next.delete(model.repo_id); - return next; - }); - } - }; - - return ( -
-

- {t('engines.dictation_model')} -

- {models.map((m) => { - const isSel = m.id === selectedId; - const busy = installing.has(m.repo_id); - const desc = t(`voicePanel.model_desc.${m.id}`, { defaultValue: m.languages || '' }); - return ( - - ); - })} -
- ); -} diff --git a/electron/src/shared/components/DictationModelPicker.test.jsx b/electron/src/shared/components/DictationModelPicker.test.jsx deleted file mode 100644 index 7082ea5d6..000000000 --- a/electron/src/shared/components/DictationModelPicker.test.jsx +++ /dev/null @@ -1,169 +0,0 @@ -import React from 'react'; -import { beforeEach, describe, expect, it, vi } from 'vitest'; -import { fireEvent, render, screen, waitFor } from '@testing-library/react'; -import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; - -vi.mock('react-hot-toast', () => ({ toast: { success: vi.fn(), error: vi.fn() } })); - -const { listEngines, selectEngine, listLoadedModels, apiJson, apiPost, installMutate } = vi.hoisted( - () => ({ - listEngines: vi.fn(), - selectEngine: vi.fn(), - listLoadedModels: vi.fn(), - apiJson: vi.fn(), - apiPost: vi.fn(), - installMutate: vi.fn(), - }), -); -vi.mock('../api/engines', () => ({ listEngines, selectEngine })); -vi.mock('../api/system', () => ({ listLoadedModels })); -vi.mock('../api/client', async (importOriginal) => ({ - ...(await importOriginal()), - apiJson: (...a) => apiJson(...a), - apiPost: (...a) => apiPost(...a), -})); -vi.mock('../api/hooks', async (importOriginal) => ({ - ...(await importOriginal()), - useInstallModel: () => ({ mutateAsync: installMutate }), -})); - -import EngineQuickSwitch from './EngineQuickSwitch'; -import { useAppStore } from '../store'; - -const ASR_INVENTORY = { - tts: { - active: 'omnivoice', - backends: [{ id: 'omnivoice', display_name: 'OmniVoice', available: true }], - }, - asr: { - active: 'whisperx', - backends: [ - { id: 'whisperx', display_name: 'WhisperX (faster-whisper + wav2vec2)', available: true }, - { - id: 'sherpa-onnx-asr', - display_name: 'Sherpa-ONNX dictation (live, CPU — streaming + offline)', - available: true, - }, - { id: 'nemo-parakeet', display_name: 'Parakeet TDT (NVIDIA NeMo)', available: false }, - ], - }, - llm: { active: 'off', backends: [] }, -}; - -const MODELS = { - models: [ - { - id: 'sherpa-whisper-tiny', - repo_id: 'csukuangfj/sherpa-onnx-whisper-tiny', - label: 'Whisper Tiny', - tag: 'offline', - recommended: true, - size_gb: 0.104, - languages: '90+ languages', - installed: true, - }, - { - id: 'sherpa-parakeet-tdt-v3', - repo_id: 'csukuangfj/sherpa-onnx-nemo-parakeet-tdt-0.6b-v3-int8', - label: 'Parakeet TDT v3', - tag: 'offline', - recommended: false, - size_gb: 0.67, - languages: '25 European languages', - installed: true, - }, - { - id: 'sherpa-zipformer-en-20m', - repo_id: 'csukuangfj/sherpa-onnx-streaming-zipformer-en-20M-2023-02-17', - label: 'Zipformer Streaming EN', - tag: 'streaming', - recommended: false, - size_gb: 0.044, - languages: 'English', - installed: false, - }, - ], - default_model_id: 'sherpa-whisper-tiny', -}; - -function renderSwitch(props = {}) { - const client = new QueryClient({ defaultOptions: { queries: { retry: false } } }); - return render( - - - , - ); -} - -describe('EngineQuickSwitch → dictation model picker', () => { - beforeEach(() => { - vi.clearAllMocks(); - listEngines.mockResolvedValue(ASR_INVENTORY); - listLoadedModels.mockResolvedValue({ models: [] }); - apiJson.mockImplementation(async (path) => { - if (path === '/dictation/models') return MODELS; - if (path === '/dictation/prefs') - return { enabled: true, mode: 'toggle', model_id: 'sherpa-whisper-tiny' }; - throw new Error(`unexpected GET ${path}`); - }); - apiPost.mockImplementation(async (path, body) => { - if (path === '/dictation/prefs') - return { enabled: true, mode: 'toggle', model_id: body.model_id }; - throw new Error(`unexpected POST ${path}`); - }); - installMutate.mockResolvedValue({}); - useAppStore.setState({ dictationModelId: 'sherpa-whisper-tiny', dictationLoaded: true }); - }); - - it('lists the sherpa dictation models under the Sherpa-ONNX engine row only', async () => { - renderSwitch(); - const picker = await screen.findByTestId('dictation-model-picker'); - expect(picker).toHaveTextContent('Whisper Tiny'); - expect(picker).toHaveTextContent('Parakeet TDT v3'); - expect(picker).toHaveTextContent('Zipformer Streaming EN'); - // Nested directly after the Sherpa row, not after WhisperX. - const sherpaRow = screen.getByText('Sherpa-ONNX dictation').closest('button'); - expect(sherpaRow.nextElementSibling).toBe(picker); - // Engine rows themselves are untouched. - expect(screen.getByText('WhisperX').closest('button')).toBeInTheDocument(); - expect(screen.getByTestId('dictation-model-sherpa-whisper-tiny')).toHaveAttribute( - 'aria-pressed', - 'true', - ); - }); - - it('does not render the picker for a family without the Sherpa engine', async () => { - renderSwitch({ family: 'tts' }); - expect(await screen.findByText('OmniVoice')).toBeInTheDocument(); - expect(screen.queryByTestId('dictation-model-picker')).not.toBeInTheDocument(); - }); - - it('selecting an installed model writes dictation.model_id and does not download', async () => { - renderSwitch(); - fireEvent.click(await screen.findByTestId('dictation-model-sherpa-parakeet-tdt-v3')); - await waitFor(() => - expect(apiPost).toHaveBeenCalledWith('/dictation/prefs', { - model_id: 'sherpa-parakeet-tdt-v3', - }), - ); - expect(installMutate).not.toHaveBeenCalled(); - expect(useAppStore.getState().dictationModelId).toBe('sherpa-parakeet-tdt-v3'); - expect(screen.getByTestId('dictation-model-sherpa-parakeet-tdt-v3')).toHaveAttribute( - 'aria-pressed', - 'true', - ); - }); - - it('selecting a model that is not installed persists the choice and starts the download', async () => { - renderSwitch(); - fireEvent.click(await screen.findByTestId('dictation-model-sherpa-zipformer-en-20m')); - await waitFor(() => - expect(installMutate).toHaveBeenCalledWith( - 'csukuangfj/sherpa-onnx-streaming-zipformer-en-20M-2023-02-17', - ), - ); - expect(apiPost).toHaveBeenCalledWith('/dictation/prefs', { - model_id: 'sherpa-zipformer-en-20m', - }); - }); -}); diff --git a/electron/src/shared/components/DonateMomentPopover.jsx b/electron/src/shared/components/DonateMomentPopover.jsx deleted file mode 100644 index a4d961057..000000000 --- a/electron/src/shared/components/DonateMomentPopover.jsx +++ /dev/null @@ -1,104 +0,0 @@ -import React from 'react'; -import { useTranslation } from 'react-i18next'; -import { openExternal } from '../api/external'; -import { KOFI_URL, PAYPAL_URL } from '../utils/donateLinks'; -import { DONATE_LINE_COUNT } from '../utils/donationMoments'; - -/** - * DonateMomentPopover — the friendly "Clippy-like" speech bubble that - * LogsFooter anchors above the donate heart when a donation moment fires - * (see utils/donationMoments.js for the strict eligibility gates). - * - * Deliberately NO backdrop and NO focus trap: it's an aside, not a modal — - * the user can keep working and it auto-dismisses on its own. Bounce-in - * animation collapses to a plain fade under `prefers-reduced-motion`. - * Chrome palette throughout so it reads as part of the footer. - */ - -/** How long the popover lingers before quietly dismissing itself. */ -export const DONATE_POPOVER_AUTO_DISMISS_MS = 15_000; - -// Small pill CTA shared by the Ko-fi / PayPal buttons. -const CTA_BTN = - 'inline-flex items-center gap-[5px] px-[10px] h-[24px] rounded-[5px] cursor-pointer ' + - 'border border-solid border-transparent text-[11px] font-semibold [font-family:inherit] ' + - '[background:var(--chrome-accent-bg)] [color:var(--chrome-fg)] transition-colors ' + - 'hover:[border-color:var(--chrome-accent-border)] hover:[color:var(--chrome-accent)]'; - -const QUIET_BTN = - 'bg-transparent border-0 cursor-pointer p-0 text-[11px] [font-family:inherit] ' + - '[color:var(--chrome-fg-muted)] hover:[color:var(--chrome-fg)] transition-colors'; - -export default function DonateMomentPopover({ line = 0, onLater, onOptOut }) { - const { t } = useTranslation(); - // Rotate through the friendly lines; clamp so a stale/oversized index from - // the event detail can never resolve to a missing i18n key. - const lineKey = `footer_donate.line_${(Math.abs(line | 0) % DONATE_LINE_COUNT) + 1}`; - - return ( -
- {/* Speech-bubble tail, pointing down at the heart. */} -
- ); -} diff --git a/electron/src/shared/components/DubSegmentRow.jsx b/electron/src/shared/components/DubSegmentRow.jsx deleted file mode 100644 index 39bb9177a..000000000 --- a/electron/src/shared/components/DubSegmentRow.jsx +++ /dev/null @@ -1,679 +0,0 @@ -import React, { memo, useRef } from 'react'; -import { useTranslation } from 'react-i18next'; -import { - CheckCircle, - AlertCircle, - Circle, - Trash2, - Loader, - Headphones, - Scissors, - Merge, - MoreHorizontal, - Minus, - Plus, - Sparkles, - Volume2, - BookOpen, -} from 'lucide-react'; -import { formatTime } from '../utils/format'; -import { LANG_CODES } from '../utils/languages'; -import { MIN_SEG_DUR } from '../utils/timeline'; -import { Menu } from '../ui'; -import VoiceSelector from './VoiceSelector'; - -const CHAR_BUDGET_RATIO = 1.3; -const SENTENCE_END = /[.!?。!?]/; -const TIME_EPSILON = 1e-9; - -function rowClass(isActive, isDone, selected, isPlaying, timelineSelected) { - return `segment-row${isActive ? ' segment-active' : ''}${isDone ? ' segment-done' : ''}${selected ? ' segment-selected' : ''}${isPlaying ? ' segment-playing' : ''}${timelineSelected ? ' segment-timeline-selected' : ''}`; -} - -// Best split point for the Scissors menu when the user hasn't placed a cursor — -// prefer the sentence boundary nearest the middle, then a whitespace boundary, -// then the literal midpoint as a last resort. -function bestSplitPoint(text) { - const mid = Math.floor(text.length / 2); - let best = -1, - bestDist = Infinity; - for (let i = 0; i < text.length; i++) { - if (SENTENCE_END.test(text[i])) { - const d = Math.abs(i + 1 - mid); - if (d < bestDist) { - best = i + 1; - bestDist = d; - } - } - } - if (best > 0 && best < text.length) return best; - for (let r = 0; r < text.length; r++) { - for (const i of [mid - r, mid + r]) { - if (i > 0 && i < text.length && /\s/.test(text[i])) return i; - } - } - return mid; -} - -// Accept "m:ss[.s]" or raw seconds; return null on garbage so the field can revert. -function parseTime(s) { - const m = /^\s*(\d+):([0-5]?\d(?:\.\d+)?)\s*$/.exec(s); - if (m) return parseInt(m[1], 10) * 60 + parseFloat(m[2]); - if (String(s).includes(':') || !/^\s*\d+(?:\.\d+)?\s*$/.test(s)) return null; - const n = Number(s); - return Number.isFinite(n) ? n : null; -} - -function DubSegmentRow({ - seg, - idx, - style, - ariaAttributes, - disabled, - isActive, - isDone, - isPlaying, - previewLoading, - selected, - profiles, - speakerClones, - onEditField, - onDelete, - onRestore, - onPreview, - onSelect, - onSplit, - onMerge, - onInsert, - onMoveResize, - canMerge, - canMergePrev, - onDirect, - onSeek, - timelineSelected, - hasOverlap, - liveEnabled, - liveActive, - onLiveEdit, - onLiveToggle, -}) { - const { t } = useTranslation(); - const textInputRef = useRef(null); - // Remember where the caret was inside the text field even after it loses - // focus — Radix's menu trigger steals focus, so by the time the Scissors - // item fires, selectionStart on the input would otherwise read as null. - const lastCursorRef = useRef(null); - const speakerOptions = speakerClones ? Object.keys(speakerClones) : []; - const speakerListId = `seg-speakers-${seg.id}`; - - // Truthful per-segment fit badge. The backend's new fit_status object is - // the source of truth — describes exactly what the mix loop did: - // "fits" → audio fit cleanly inside the slot (or its gap). - // "overflows" → concise mode hard-trimmed +Ns past slot; user - // should shorten the text for a cleaner result. - // "video_stretched" → stretch_video mode lengthened the source clip by - // the stretch ratio to fit natural-rate audio. - // We fall back to the legacy sync_ratio bucketing only when fit_status is - // missing (older jobs / partial-regen with no done event yet) — and even - // then we now display the *raw* ratio so it stops claiming 100% when the - // audio was actually compressed at synthesis time. - const fitStatus = seg.fit_status && typeof seg.fit_status === 'object' ? seg.fit_status : null; - let fitBadge = null; - if (fitStatus) { - if (fitStatus.status === 'fits') { - fitBadge = { - color: '#b8bb26', - Icon: CheckCircle, - label: t('segment.fit_fits'), - title: t('segment.fit_fits_title'), - }; - } else if (fitStatus.status === 'overflows') { - const over = fitStatus.overflow_s || 0; - fitBadge = { - color: over > 0.5 ? '#fb4934' : '#fabd2f', - Icon: AlertCircle, - label: t('segment.fit_overflows', { seconds: over.toFixed(2) }), - title: t('segment.fit_overflows_title', { seconds: over.toFixed(2) }), - }; - } else if (fitStatus.status === 'video_stretched') { - const r = fitStatus.stretch_ratio || 1.0; - fitBadge = { - color: r > 1.18 ? '#fb4934' : r > 1.05 ? '#fabd2f' : '#83a598', - Icon: Circle, - label: t('segment.fit_stretched', { ratio: r.toFixed(2) }), - title: t('segment.fit_stretched_title', { ratio: r.toFixed(2) }), - }; - } else if (fitStatus.status === 'audio_slowed') { - // Underrun fill: the line ran shorter than its slot and was slowed - // (pitch-preserved) toward it so speech covers the on-screen mouth time. - const r = fitStatus.audio_rate || 1.0; - fitBadge = { - color: '#83a598', - Icon: Circle, - label: t('segment.fit_slowed', { ratio: r.toFixed(2) }), - title: t('segment.fit_slowed_title', { ratio: r.toFixed(2) }), - }; - } - } else if (seg.sync_ratio !== undefined) { - const r = seg.sync_ratio; - if (r > 1.25) { - fitBadge = { - color: '#fb4934', - Icon: AlertCircle, - label: `${Math.round(r * 100)}%`, - title: t('segment.fit_compressed_title', { pct: Math.round(r * 100) }), - }; - } else if (r >= 0.95 && r <= 1.05) { - fitBadge = { - color: '#b8bb26', - Icon: CheckCircle, - label: t('segment.fit_fits'), - title: t('segment.fit_audio_title'), - }; - } else { - fitBadge = { - color: '#fabd2f', - Icon: Circle, - label: `${Math.round(r * 100)}%`, - title: t('segment.fit_ratio_title', { pct: Math.round(r * 100) }), - }; - } - } - - const overBudget = - seg.text_original && seg.text.length > Math.ceil(seg.text_original.length * CHAR_BUDGET_RATIO); - - // Both time fields commit through the SAME path the timeline drag handles - // use (segmentMoveResize → commitMoveResize), so typing a time and dragging - // its edge produce identical results — including the speed recompute that - // keeps the dubbed audio inside a resized slot. The numeric start field used - // to write `start` raw and skip that compensation, so the two UIs disagreed. - // The fields show tenths, so leaving one untouched must not commit that - // rounding; only a field typed into since it was focused commits. - const editedTimeRef = useRef({}); - const timeKeyDown = (edge) => (e) => { - if (e.key === 'Enter') e.target.blur(); - if (e.key === 'Escape') { - editedTimeRef.current[edge] = false; - e.target.value = formatTime(seg[edge]); - e.target.blur(); - } - }; - - const commitTime = (edge) => (e) => { - const current = seg[edge]; - if (!editedTimeRef.current[edge]) return; - editedTimeRef.current[edge] = false; - const v = parseTime(e.target.value); - const inRange = - edge === 'start' - ? v >= 0 && v <= seg.end - MIN_SEG_DUR + TIME_EPSILON - : v >= seg.start + MIN_SEG_DUR - TIME_EPSILON; - if (v == null || !inRange) { - e.target.value = formatTime(current); - return; - } - if (Math.abs(v - current) <= 1e-3) { - e.target.value = formatTime(current); - return; - } - const next = +v.toFixed(3); - onMoveResize(seg.id, { - start: edge === 'start' ? next : seg.start, - end: edge === 'end' ? next : seg.end, - }); - }; - - const nudgeTime = (edge, delta) => { - const current = seg[edge]; - const limit = edge === 'start' ? seg.end - MIN_SEG_DUR : seg.start + MIN_SEG_DUR; - const next = +( - edge === 'start' - ? Math.max(0, Math.min(limit, current + delta)) - : Math.max(limit, current + delta) - ).toFixed(3); - if (Math.abs(next - current) <= 1e-3) return; - onMoveResize(seg.id, { - start: edge === 'start' ? next : seg.start, - end: edge === 'end' ? next : seg.end, - }); - }; - - const handleTextKeyDown = (e) => { - if ((e.ctrlKey || e.metaKey) && (e.key === 'd' || e.key === 'D')) { - e.preventDefault(); - const pos = e.target.selectionStart ?? seg.text.length; - onSplit(seg.id, pos); - } else if ((e.ctrlKey || e.metaKey) && (e.key === 'm' || e.key === 'M')) { - e.preventDefault(); - if (e.shiftKey) { - if (canMergePrev) onMerge(seg.id, 'prev'); - } else if (canMerge) onMerge(seg.id, 'next'); - } - }; - - const captureCursor = (e) => { - const pos = e.target.selectionStart; - if (pos != null) lastCursorRef.current = pos; - }; - - // Row click → seek the player to this segment. We don't fire when the click - // originates in an interactive element (input, button, the actions cluster) - // so per-field editing keeps working. - const handleRowClick = (e) => { - if (!onSeek) return; - if (e.target.closest('input, button, select, textarea, label, [data-noseek]')) return; - onSeek(seg.start); - }; - - return ( -
- onSelect(seg.id, idx, e.nativeEvent.shiftKey)} - onClick={(e) => onSelect(seg.id, idx, e.shiftKey)} - disabled={disabled} - className="seg-select cursor-pointer justify-self-center" - title={t('segment.select_title')} - /> - - -