mirror of
https://github.com/debpalash/VoiceStudio.git
synced 2026-12-04 01:18:16 +00:00
Polish desktop setup, settings and studio workspaces (#4527)
* Polish desktop setup, settings and studio workspaces * Add desktop refresh changelog entry * Check home creation destinations in the desktop guard * Align desktop workflow checks with the redesigned controls and restore paired consent choices * Stabilize native window and titlebar checks during navigation * Restore a continuous workspace background across desktop chrome * Verify workspace and settings panel corners in the theme smoke * Give Support a full-width donation panel and stack sponsor, Pro and contact sections * Give sponsor marks room and simplify Support actions * Organize Support contact actions in a responsive grid * Fix desktop take navigation, drawer visibility and shortcut capture * Recover desktop setup choices when local settings cannot be read or saved * Welcome users with the studio cat and credit the open-source community * Compare exact filesystem identities before claiming an existing terminal command * Check visible setup controls and model headings and isolate Home credits
This commit is contained in:
1 parent
93bc710ba3
commit
4aa2cd27b6
311 files changed
+6758
-3068
No files matched your search
@@ -0,0 +1 @@
|
||||
Desktop setup and settings use more compact layouts, and the studio cat welcomes users to Home and Support with links to sponsors and the open-source project (#4527)
|
||||
@@ -27,6 +27,7 @@ RUN bun install --frozen-lockfile
|
||||
|
||||
# Build the maintained Electron renderer as the browser UI. `electron/src/shared`
|
||||
# contains transitional shared modules only; it has no app entry point.
|
||||
COPY CHANGELOG.md ./
|
||||
COPY frontend/ ./frontend/
|
||||
COPY electron/ ./electron/
|
||||
RUN bun run --cwd electron build:web
|
||||
|
||||
@@ -41,11 +41,11 @@ Setup content is anchored below the fixed brand header with fluid top padding. I
|
||||
|
||||
The branded setup view reports environment checks, uv download, dependency installation and final verification from real runtime phases. During dependency installation it shows the resolved package count, announced transfer bytes, remaining data, current rate, ETA and the largest unfinished package; stale rate and ETA values disappear when the transfer pauses. Once the last announced artifact arrives, the view switches to package installation instead of leaving that artifact displayed as if its download stalled. It also streams the latest setup activity while preserving the full log disclosure. Retry and Clean & Retry preserve uv's verified download cache outside the replaceable Python project, so rebuilding a broken environment does not repeat the multi-gigabyte transfer. Setup writes `.runtime-installing` when it starts and `.runtime-ready` last, after verification; a ready marker newer than the install marker means setup finished, so a leftover install marker is removed instead of offering Resume. Resuming an interrupted install reuses the existing environment and never evicts cached wheels, and a CPU runtime re-sync keeps its installed CPU PyTorch instead of uninstalling and reinstalling it.
|
||||
|
||||
Cancel stops the active process tree or download and returns to setup. Failure preserves logs and offers Retry plus a confirmed Clean & Retry. The setup view keeps to one window: a status line, the runtime folder with free and needed space, and one primary action (Install, Resume, Retry, or Choose another folder when the drive is full or not writable). Language, download region, an existing Python interpreter and a backend on another computer sit under **Options**; Clean & Retry, the repair agent, the connection check and the log sit under **More fixes** after a failure; help links appear once in a single row. Clean recovery removes only the dedicated Python project in the default runtime or a custom runtime Electron has claimed after beginning installation; compatible Tauri environments and unowned custom locations are refused. Incomplete environments or a changed dependency graph require setup again. Source updates replace old bundled modules while preserving the venv.
|
||||
Cancel stops the active process tree or download and returns to setup. Failure preserves logs and offers Retry plus a confirmed Clean & Retry. The setup view keeps to one window: a status line, the runtime folder with free and needed space, and one primary action (Install, Resume, Retry, or Choose another folder when the drive is full or not writable). During setup, an available app update opens a bottom drawer with the download or restart action. Click elsewhere to continue setup. The update stays in a slim bar at the bottom. Select the bar to reopen the drawer. Runtime installation progress and errors appear inline. The notification bell appears in the workspace after setup. The installed version, channel badge and **What’s new** button sit above the welcome banner. The button opens the changelog for the installed release inside the app. The welcome screen preselects unanswered error-reporting and usage-statistics choices. Each has its own confirmation to enable sharing. Opening the page or choosing **Install local runtime** leaves unconfirmed sharing off. The centered **Install** menu above the help links opens on hover or click. Choose **Install local runtime** to start installation or **Set up remote backend** to open connection settings. Each switch has an expandable explanation. On first install, Language and Download region appear in stacked rows with flags beside language and country choices. The privacy controls sit below the runtime and stack in narrow windows. If a language or download-region change fails, setup shows a retry message beside the control. A failed region save keeps the previous download region active. Info controls explain storage and privacy. During recovery these settings sit under **Options**; Clean & Retry, the repair agent, the connection check and the log sit under **More fixes** after a failure; **Join our Discord** stays at the bottom of the window as setup scrolls. Discord, Pro and Cloud links sit at the top right and become icon buttons in narrow windows. Clean recovery removes only the dedicated Python project in the default runtime or a custom runtime Electron has claimed after beginning installation; compatible Tauri environments and unowned custom locations are refused. Incomplete environments or a changed dependency graph require setup again. Source updates replace old bundled modules while preserving the venv.
|
||||
|
||||
Verification: runtime regression tests cover consent gating, dependency changes, incomplete environments, failed repair, cancellation before download, and source replacement. `node electron/tests/packaged-smoke.mjs --setup` verifies the first-run view without initiating an installation. `--install` performs the explicit isolated runtime installation and verifies the packaged renderer's same-origin connection to its managed backend.
|
||||
|
||||
First run has four steps: System check, Model packs, Privacy, and Enter studio. Model packs reuse the existing performance tiers and install only missing supported models after an explicit click. Installed state, remaining download size, disk checks and installation progress appear in one place. Advanced mode reveals individual models, engine tuning, privacy settings and recovery tools; failed system checks still expose recovery without enabling Advanced. The final Enter Studio step opens Advanced expanded, showing optional dictation permissions and shortcuts; either toggle can collapse them. Dictation and its permissions remain optional and available in Settings. Navigation requires passing preflight, required models and the privacy choice; the default voice model is required only while the default engine is selected, so a different TTS engine installed and selected in Advanced also satisfies that step; entering the studio opens the first-voice demo. On narrow windows the step navigation moves above the content and the footer stays visible.
|
||||
First run has four steps: System check, Model packs, Privacy, and Enter studio. Model packs reuse the existing performance tiers and install only missing supported models after an explicit click. Installed state, remaining download size, disk checks and installation progress appear in one place. Advanced mode reveals individual models, engine tuning, privacy settings and recovery tools; failed system checks still expose recovery without enabling Advanced. The final Enter Studio step opens Advanced expanded, showing optional dictation permissions and shortcuts; either toggle can collapse them. Dictation and its permissions remain optional and available in Settings. Navigation requires passing preflight, required models and the privacy choice; the default voice model is required only while the default engine is selected, so a different TTS engine installed and selected in Advanced also satisfies that step; entering the studio opens the first-voice demo. Completed steps show a check mark. On Privacy, the footer points to the next unanswered choice. Both account options have equal weight and the selected option stays visible until you leave the step. On narrow windows the step navigation moves above the content and the footer stays visible.
|
||||
|
||||
A subsequent packaged launch also reused that installed runtime and started a managed backend. Electron discovers compatible Tauri default, custom and portable runtime locations and can reuse them without a download when the interpreter and both frozen dependency manifests match. Its location record distinguishes reused environments from custom runtimes Electron creates. Uninstall includes only an Electron-owned custom runtime; it never claims or removes a reused Tauri runtime.
|
||||
|
||||
@@ -102,7 +102,7 @@ Automatic blank-renderer recovery preserves the current trusted workspace route,
|
||||
|
||||
Branding remains in a fixed native title row while onboarding status loads, installation runs or recovery needs retry. Runtime details scroll independently below it; installer phases wrap into two columns on narrow windows, so a growing progress/log surface cannot clip the wordmark or window controls.
|
||||
|
||||
On Windows and Linux, the collapsed workspace sidebar shows the VoiceStudio icon at the top. Use the toggle beside the page title to expand the sidebar. macOS retains its existing sidebar control.
|
||||
Home has a Saved voices button for opening the voice library on demand. The collapsed rail links directly to Home. More workspaces lets you pin shortcuts, remembers them on this device, and marks an active workspace when its shortcut is hidden. The collapsed workspace sidebar marks the current workspace and groups related pages behind a chevron. Hover or activate a group to see its pages. Press the right arrow to enter the group, use the up and down arrows to move between links, and press the left arrow to return to the rail. The VoiceStudio icon at the top expands the sidebar.
|
||||
|
||||
Every main workspace header exposes the same sidebar toggle, including pages that automatically collapse the voice library at narrow widths. The control reflects the visible sidebar state and explicitly expands it for the current workspace.
|
||||
|
||||
@@ -152,3 +152,5 @@ waits up to 20 seconds for that boot's running reconciliation thread, including
|
||||
when its asyncio task was cancelled; a completed earlier boot cannot bypass the wait.
|
||||
Work not yet submitted is cancelled, and queued executor work remains tracked
|
||||
without requiring another executor thread to enforce the shutdown deadline.
|
||||
|
||||
Voice cloning and Voice design share a synthesis dock. The latest take appears above the generation controls, with playback, quality details and export in the same surface. After the first clone, the lightbulb beside Emotion opens the delivery tip.
|
||||
@@ -29,8 +29,7 @@ HTTP.
|
||||
`custom` section of `tts_infer.yaml` so it points at your own
|
||||
`GPT_weights*` and `SoVITS_weights*` files before starting the server.
|
||||
|
||||
2. Select the engine via **Model Catalogue** (TTS tab → **Use**) or
|
||||
`OMNIVOICE_TTS_BACKEND=gpt-sovits`.
|
||||
2. In **Settings → Models → TTS**, expand **GPT-SoVITS** and choose **Select** once the server is running. The download button beside the engine name shows the size of its pretrained weights. You can also select the engine with `OMNIVOICE_TTS_BACKEND=gpt-sovits`.
|
||||
|
||||
VoiceStudio marks the engine available only when the server responds
|
||||
(2-second reachability probe).
|
||||
|
||||
@@ -317,7 +317,7 @@ interpreter. To verify this invariant on an older or custom image, compare
|
||||
torch.version.hip)"` with `docker exec <container> sh -c 'tr "\\0" " "
|
||||
</proc/1/cmdline'`; PID 1 must begin with `python3 -m uvicorn`.
|
||||
|
||||
If the command prints `False`, run **Settings → About → Run self-check**;
|
||||
If the command prints `False`, run **Settings → Diagnostics → Run self-check**;
|
||||
the GPU row says why. Native Linux has three common answers:
|
||||
|
||||
| What it says | What to do |
|
||||
|
||||
@@ -22,10 +22,11 @@ naming the code and the calling file.
|
||||
|
||||
Before digging through the entries below, let the app diagnose itself:
|
||||
|
||||
- **In the app:** **Settings → About → "Run self-check"** verifies your
|
||||
compute device (CUDA/MPS/CPU), ffmpeg, HuggingFace token, disk space,
|
||||
data-directory permissions, RAM, installed TTS engines, and hub
|
||||
reachability — each with a hint when something's off.
|
||||
- **In the app:** Open **Settings → Diagnostics** to check your compute device,
|
||||
ffmpeg, Hugging Face token, disk space, data-directory permissions, RAM, and
|
||||
installed TTS engines. System information opens automatically. Choose **Copy
|
||||
diagnostics** to copy the displayed report, or **Run self-check** to also test
|
||||
hub reachability.
|
||||
- **Headless / terminal:**
|
||||
|
||||
```bash
|
||||
@@ -37,7 +38,7 @@ Before digging through the entries below, let the app diagnose itself:
|
||||
`--deep` catches "installed but broken" engines. On a fresh install it may
|
||||
cold-load the model (minutes, plus a large download).
|
||||
|
||||
- **Filing an issue?** **Settings → About → "Save diagnostic bundle"**
|
||||
- **Filing an issue?** **Settings → Diagnostics → "Save diagnostic bundle"**
|
||||
produces a zip (self-check report, recent classified errors, scrubbed log
|
||||
tails) you can drag straight onto the GitHub issue. Home paths and
|
||||
anything token-shaped are redacted before they leave your machine.
|
||||
@@ -789,7 +790,7 @@ GPU-only engines still require supported hardware.
|
||||
## 12b. My AMD Radeon GPU is not used (CPU is busy, GPU is idle)
|
||||
|
||||
**Symptom:** generation or transcription is slow, Task Manager shows the CPU
|
||||
busy and the Radeon idle, and **Settings → About → Run self-check** says the
|
||||
busy and the Radeon idle, and **Settings → Diagnostics → Run self-check** says the
|
||||
compute device is `cpu`.
|
||||
|
||||
**Cause:** the default install has the NVIDIA CUDA build of PyTorch (or the
|
||||
|
||||
@@ -186,7 +186,7 @@ verdict for every engine (uses the GPU, runs on the CPU and why, or CPU by
|
||||
design). Manually installed HIP sidecars are recognized in Windows virtual
|
||||
environments too. If HIP cannot enumerate a GPU, diagnostics point to AMD's
|
||||
supported GPU, driver and wheel combination; an SDK directory on PATH alone
|
||||
does not prove a working PyTorch runtime. **Settings → About → Run self-check** names the card instead of just
|
||||
does not prove a working PyTorch runtime. **Settings → Diagnostics → Run self-check** names the card instead of just
|
||||
saying "no GPU acceleration detected".
|
||||
|
||||
## Building from source
|
||||
|
||||
@@ -76,18 +76,18 @@ Clicking it opens the licence dialog, on a solid background, in this order:
|
||||
1. **Summary**: the licence category in plain words, the declared licence, the
|
||||
review state and your acceptance state (accepted with date and terms
|
||||
fingerprint, withdrawn, terms updated with what changed, or not accepted).
|
||||
2. **What this licence allows**: commercial use of the model, commercial use
|
||||
2. Expand **What this licence allows** to see commercial use of the model, commercial use
|
||||
of generated audio, sharing the model files, and voice and recording consent
|
||||
(always your responsibility), each with a status.
|
||||
3. **Source**: the rights holder and links to the licence and the model page.
|
||||
3. Expand **Source** for the rights holder and links to the licence and the model page.
|
||||
4. Collapsed sections: **Files and variants** (files with their own terms;
|
||||
the most restrictive applies), **Recorded notes**, **Technical details**
|
||||
(model and evidence versions, evidence date, terms fingerprint, registry
|
||||
version and acceptance history; long hashes are shortened with a copy
|
||||
button) and **Verified install (preview)**.
|
||||
5. A footer that stays visible: the notice that VoiceStudio is not the licensor
|
||||
and cannot grant access, a confirmation checkbox, and **Accept licence** or
|
||||
**Withdraw acceptance**.
|
||||
5. When acceptance is required, the notice and a checkbox for each model appear
|
||||
above **Accept licence**. Actions stay visible while the terms scroll. After
|
||||
acceptance, **Withdraw acceptance** is available.
|
||||
|
||||
The dialog that opens when another feature needs an unaccepted model shows the
|
||||
same full view for every model involved. Unmapped or conflicting licence data
|
||||
|
||||
+3
-2
@@ -315,8 +315,9 @@ Send, and reports are deleted after 180 days.
|
||||
## For developers
|
||||
|
||||
Both apps follow one contract, [`mobile/contract/SPEC.md`](../mobile/contract/SPEC.md):
|
||||
a feature ships on both or neither. Colors, the API description and the text
|
||||
are generated from the desktop app and backend, never copied by hand:
|
||||
a feature ships on both or neither. Both phone apps use the Electron palette and
|
||||
corner sizes for cards and fields. Native controls keep their platform touch targets
|
||||
and text scaling. These commands generate the shared resources from their sources.
|
||||
|
||||
```sh
|
||||
bun scripts/export-mobile-tokens.ts # theme tokens from the Electron theme
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Model credits in About
|
||||
|
||||
The About section in Settings → About displays model and conversion authors, source links, and upstream
|
||||
Settings → About displays model and conversion authors, source links, and upstream
|
||||
terms in the maintained Electron desktop and web UI. Credits remain visible before
|
||||
the backend answers or a model is installed. Surrounding labels are translated in
|
||||
all 21 loaded locales; mandatory legal notices retain their original English text.
|
||||
@@ -32,6 +32,6 @@ acceptance requirements, and dependency audits still need separate review.
|
||||
|
||||
The static presentation lives in
|
||||
`electron/src/renderer/src/features/settings/model-credits.tsx`, mounted by
|
||||
`DiagnosticsSettings`. It makes no model downloads, remote licence probes,
|
||||
`AboutSettings`. It makes no model downloads, remote licence probes,
|
||||
entitlement changes, or licence acceptance decisions. Update the source evidence
|
||||
and tests when adding or changing an attribution.
|
||||
+1
-1
@@ -35,7 +35,7 @@ Before touching any knob, check these — they account for most slowness reports
|
||||
- **Settings → Performance → Device & compute** shows the live compute
|
||||
device (`cuda` / `mps` / `cpu`), a "GPU active" badge, and RAM/VRAM
|
||||
readouts.
|
||||
- **Settings → About → Run self-check** (the `/system/diagnose` endpoint)
|
||||
- **Settings → Diagnostics → Run self-check** (the `/system/diagnose` endpoint)
|
||||
warns explicitly: *"cpu (no GPU acceleration detected)"* with a hint
|
||||
about drivers.
|
||||
- **Model Catalogue** shows a routing badge per engine — "GPU active",
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
# Support page
|
||||
|
||||
The support page puts the monthly development goal, donation amounts, and Ko-fi / PayPal links first. Selecting an amount carries it into PayPal; Ko-fi lets you choose the amount on its own page. No checkout opens until you choose a provider.
|
||||
The headphone-wearing studio cat appears on first-run setup, Home, and Settings → Support. Home credits the current sponsors and links to the source code, Discord, and project email. Select the cat on Home to open Support. Its greeting follows your reduced-motion preference.
|
||||
|
||||
Star and community links offer other ways to help. Sponsors remain visible. The Electron page uses the official VoiceStudio logo, a single donation panel, visible sponsor and Pro cards, and an icon grid for contact channels. No accordion hides those actions. Controls support keyboard navigation, and decorative interaction animations respect reduced-motion preferences.
|
||||
Support links to the contributing guide and app licence above the full-width donation panel. Choose an amount and a provider. PayPal carries the selected amount into checkout. GitHub Sponsors and Ko-fi let you choose it on their sites.
|
||||
|
||||
Sponsors, VoiceStudio Pro, and contact channels follow in that order at every window width. Sponsor logos link to each sponsor, and Become a sponsor opens the inquiry form. The contact grid puts bug reports, GitHub Issues, email and private security reporting first, followed by community links.
|
||||
|
||||
Workspace headers link to Support immediately before Search. Integrations is reachable from the sidebar and opens the directory; sponsored entries carry a Featured badge on their card. There is no app-wide footer, partnership form or sponsor tooltip; sponsor and contact details live on this page and in Settings.
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ default; turn it off to download only when you click **Download update**).
|
||||
A background download that fails on the network stays quiet and is retried at
|
||||
the next check. While an update downloads, is ready, or has failed, a small
|
||||
pill sits in the title bar left of your account picture: a progress ring,
|
||||
**Restart**, or **Retry**. Click it for the version change, progress (size,
|
||||
**Restart**, or **Retry**. Click it to open the update drawer from the bottom of the window. Clicking elsewhere leaves a compact update bar below the workspace. Select it to reopen the drawer. The drawer shows the version change, progress (size,
|
||||
speed, percentage and ETA), the release notes, and a link to the GitHub
|
||||
release.
|
||||
|
||||
|
||||
+24
-5
@@ -196,18 +196,37 @@ Its shortcut appears inline when the composer has space, and controls wrap in na
|
||||
Settings layout primitives are adapted from T3 Code `settingsLayout.tsx`,
|
||||
`SettingsSidebarNav.tsx`, and `WorkspacePageContainer.tsx` (MIT; see T3CODE-LICENSE.txt).
|
||||
Appearance and General have direct routes and share a breadcrumb header, searchable
|
||||
sidebar, max-w-4xl scroll frame, grouped sections, and consistent setting rows.
|
||||
sidebar, responsive scroll frame, grouped sections, and consistent setting rows.
|
||||
Sidebar active/hover surfaces use the shared T3 theme tokens.
|
||||
|
||||
Settings keeps common controls on the row and puts longer explanations under the info button.
|
||||
Settings → Models searches local catalogue names, publisher names, repository IDs and engines.
|
||||
Use the **Available** filter to narrow the list to local choices. Install an engine or download its weights at the right of its row. **Install for CUDA**, **Install for CPU** and the other device-specific buttons use the engine’s reported runtime. When both the runtime and the weights are available to install, the button offers both choices and shows the weight download size. Expand the row for the description, licence and selection controls. Model packs,
|
||||
voice previews and mirror options open expanded and can be collapsed individually. Publisher marks are bundled for offline use.
|
||||
[Icon sources and attribution](src/renderer/src/features/settings/model-list/marks/README.md)
|
||||
|
||||
|
||||
The local palette library includes VoiceStudio Original, Canopy, Current, Hearth, and Orchid, with
|
||||
upstream light/dark color definitions with VoiceStudio display names from T3 Code (MIT). VoiceStudio Classic is the default in both light and dark mode. Each appearance keeps
|
||||
its own selected palette. System mode follows live OS appearance changes; the
|
||||
sidebar toggle explicitly switches to light or dark. Choices persist under
|
||||
`voicestudio.theme.v2`, migrating the older light/dark setting. Choose **Studio**
|
||||
in Appearance for T3 Code's neutral palette with a black dark canvas, a
|
||||
near-white light canvas, and blue primary actions. The palette previews share
|
||||
the same color tokens as the app. Shared controls use T3 Code's corner radius
|
||||
scale and elevation tokens. Theme selection works offline.
|
||||
in Appearance for a slate dark canvas or a cool gray light canvas with blue
|
||||
accents. Appearance previews each palette’s canvas, sidebar and action colors in
|
||||
a compact swatch. Theme selection works offline.
|
||||
|
||||
Home offers the most recent Clone take, Design take or saved project beside Clone, Design and Dubbing. Resuming a take opens its inspector. The voice editor
|
||||
keeps the script on the canvas, with language, quality and synthesis in a rounded
|
||||
action bar. Underlined tabs distinguish the active sidebar view. On wide screens,
|
||||
the title bar shows the search label and keyboard shortcut.
|
||||
|
||||
Project and gallery cards, batch jobs, and production panels share the selected
|
||||
palette’s card surface. In Workflows, step details sit on an opaque panel so
|
||||
connections stay behind the inspector in a narrow window. When a designed voice
|
||||
is saving, its name stays visible and the save button displays progress until
|
||||
the profile is ready. At the minimum desktop width, model actions wrap below long
|
||||
model names. The dubbing timeline and voice controls expose their labels to
|
||||
assistive technology.
|
||||
|
||||
Glass mode is an opt-in, persisted appearance setting for translucent in-app
|
||||
surfaces with palette-tinted background depth. It does not make the native window
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 LobeHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
@@ -40,6 +40,7 @@ vi.mock('node:net', () => ({
|
||||
}));
|
||||
vi.mock('./runtime-project', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import('./runtime-project')>()),
|
||||
primeTorchVariantProbe: async () => {},
|
||||
runtimeReady: async () => true,
|
||||
runtimeDependenciesReady: async () => true,
|
||||
stageRuntimeSources: async () => {},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// @vitest-environment node
|
||||
import { beforeEach, afterEach, describe, expect, it, onTestFinished, vi } from 'vitest';
|
||||
import { EventEmitter } from 'node:events';
|
||||
import { chmodSync, existsSync, mkdtempSync, writeFileSync } from 'node:fs';
|
||||
import { chmodSync, existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
const mocks = vi.hoisted(() => ({
|
||||
@@ -88,6 +88,7 @@ vi.mock('node:fs', async (importOriginal) => {
|
||||
vi.mock('node:fs/promises', () => ({ rm: mocks.rm }));
|
||||
vi.mock('./runtime-project', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import('./runtime-project')>()),
|
||||
primeTorchVariantProbe: async () => {},
|
||||
MISSING_SYSTEM_LIBRARY_CODE: 'MISSING_SYSTEM_LIBRARY',
|
||||
OUTDATED_SYSTEM_LIBRARY_CODE: 'OUTDATED_SYSTEM_LIBRARY',
|
||||
TORCH_DLL_INIT_FAILED_CODE: 'TORCH_DLL_INIT_FAILED',
|
||||
@@ -1590,3 +1591,28 @@ it.each(['darwin', 'win32', 'linux'] as const)(
|
||||
await supervisor.shutdown();
|
||||
},
|
||||
);
|
||||
|
||||
it('keeps the active download region when its settings cannot be saved', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('no backend')));
|
||||
vi.stubEnv('OMNIVOICE_BACKEND_CMD', '');
|
||||
vi.stubEnv('VOICESTUDIO_SKIP_BACKEND', '');
|
||||
const supervisor = new BackendSupervisor();
|
||||
try {
|
||||
await supervisor.start();
|
||||
const dir = mkdtempSync(join(tmpdir(), 'vs-region-'));
|
||||
onTestFinished(() => rmSync(dir, { recursive: true, force: true }));
|
||||
const getPath = vi.spyOn(app, 'getPath').mockReturnValue(dir);
|
||||
const file = join(dir, 'runtime-preferences.json');
|
||||
expect(supervisor.setRuntimeRegion('global')).toBe('global');
|
||||
// A file cannot be used as the preferences directory on any desktop OS.
|
||||
getPath.mockReturnValue(file);
|
||||
expect(() => supervisor.setRuntimeRegion('china')).toThrow();
|
||||
expect(supervisor.status.runtimeRegion).toBe('global');
|
||||
expect(JSON.parse(readFileSync(file, 'utf8')).region).toBe('global');
|
||||
getPath.mockReturnValue(dir);
|
||||
expect(supervisor.setRuntimeRegion('china')).toBe('china');
|
||||
expect(JSON.parse(readFileSync(file, 'utf8')).region).toBe('china');
|
||||
} finally {
|
||||
await supervisor.shutdown();
|
||||
}
|
||||
});
|
||||
@@ -32,6 +32,7 @@ vi.mock('node:net', () => ({
|
||||
}));
|
||||
vi.mock('./runtime-project', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import('./runtime-project')>()),
|
||||
primeTorchVariantProbe: async () => {},
|
||||
runtimeReady: async () => true,
|
||||
runtimeCompatible: async () => true,
|
||||
runtimeDependenciesReady: async () => true,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { renameSyncWithRetry } from './rename-retry';
|
||||
import { localDataIdentity } from './local-data-identity';
|
||||
import { decideMissingRuntime, runtimeWasInstalled } from './runtime-repair';
|
||||
import { windowsRocmInstalled, windowsRocmRequested } from './runtime-windows-rocm';
|
||||
@@ -2304,11 +2305,15 @@ export class BackendSupervisor extends EventEmitter<{
|
||||
throw new Error('runtime_region_unavailable');
|
||||
if (typeof raw !== 'string' || !RUNTIME_REGIONS.has(raw as RuntimeRegion))
|
||||
throw new Error('invalid_runtime_region');
|
||||
const path = runtimePreferencesPath();
|
||||
const temporary = path + '.' + process.pid + '.tmp';
|
||||
try {
|
||||
writeFileSync(temporary, JSON.stringify({ region: raw }, null, 2));
|
||||
renameSyncWithRetry(temporary, path);
|
||||
} finally {
|
||||
rmSync(temporary, { force: true });
|
||||
}
|
||||
this.runtimeRegion = raw as RuntimeRegion;
|
||||
writeFileSync(
|
||||
runtimePreferencesPath(),
|
||||
JSON.stringify({ region: this.runtimeRegion }, null, 2),
|
||||
);
|
||||
this.emitStatus();
|
||||
return this.runtimeRegion;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
} from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { afterEach, expect, test } from 'vitest';
|
||||
import { afterEach, expect, test, vi } from 'vitest';
|
||||
import {
|
||||
addTerminalCommandToPath,
|
||||
linkTerminalCommand,
|
||||
@@ -21,8 +21,25 @@ import {
|
||||
} from './terminal-command';
|
||||
import { removeTempDir } from './test-support/remove-temp-dir';
|
||||
|
||||
const inodes = vi.hoisted(() => new Map<string, bigint>());
|
||||
vi.mock('node:fs', async (importOriginal) => {
|
||||
const fs = await importOriginal<typeof import('node:fs')>();
|
||||
return {
|
||||
...fs,
|
||||
statSync: (...args: Parameters<typeof fs.statSync>) => {
|
||||
const info = fs.statSync(...args);
|
||||
const inode = inodes.get(String(args[0]));
|
||||
if (info && inode !== undefined) {
|
||||
Object.assign(info, { ino: typeof info.ino === 'bigint' ? inode : Number(inode) });
|
||||
}
|
||||
return info;
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
const roots: string[] = [];
|
||||
afterEach(() => {
|
||||
inodes.clear();
|
||||
for (const root of roots.splice(0)) removeTempDir(root);
|
||||
});
|
||||
function fixture() {
|
||||
@@ -199,6 +216,22 @@ test('setup never edits profiles for a command owned by another installation', (
|
||||
expect(existsSync(state)).toBe(false);
|
||||
});
|
||||
|
||||
test.each([
|
||||
[2n ** 53n, 2n ** 53n + 1n],
|
||||
[0n, 0n],
|
||||
])('unrelated commands with rounded or unavailable file IDs remain untouched (%s, %s)', (own, other) => {
|
||||
const f = fixture();
|
||||
const command = join(f.home, '.local/bin/voicestudio');
|
||||
mkdirSync(join(f.home, '.local/bin'), { recursive: true });
|
||||
writeFileSync(command, 'other installation');
|
||||
inodes.set(command, other);
|
||||
inodes.set(join(f.resources, 'cli/voicestudio'), own);
|
||||
|
||||
expect(linkTerminalCommand(f)).toBe('existing');
|
||||
expect(terminalCommandStatus(f).linked).toBe(false);
|
||||
expect(readFileSync(command, 'utf8')).toBe('other installation');
|
||||
});
|
||||
|
||||
test('a setup that failed halfway is finished on the next launch, not marked done', () => {
|
||||
const f = fixture();
|
||||
const state = join(f.home, 'terminal-command.json');
|
||||
|
||||
@@ -98,9 +98,10 @@ function commandPath(home: string): string {
|
||||
*/
|
||||
function isSameFile(command: string, target: string): boolean {
|
||||
try {
|
||||
const a = statSync(command);
|
||||
const b = statSync(target);
|
||||
return a.dev === b.dev && a.ino === b.ino;
|
||||
// Filesystem IDs can exceed Number.MAX_SAFE_INTEGER. A zero inode carries no identity.
|
||||
const a = statSync(command, { bigint: true });
|
||||
const b = statSync(target, { bigint: true });
|
||||
return a.ino !== 0n && a.dev === b.dev && a.ino === b.ino;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,16 @@ it('No turns everything off', async () => {
|
||||
render(<AccountConsent />);
|
||||
fireEvent.click(await screen.findByText('account.use_no'));
|
||||
expect(account.setSwitches).toHaveBeenCalledWith({ accountEnabled: false, syncEnabled: false });
|
||||
await waitFor(() =>
|
||||
expect(screen.getByRole('button', { name: 'account.use_no' })).toHaveAttribute(
|
||||
'aria-pressed',
|
||||
'true',
|
||||
),
|
||||
);
|
||||
expect(screen.getByRole('button', { name: 'account.use_yes' })).toHaveAttribute(
|
||||
'aria-pressed',
|
||||
'false',
|
||||
);
|
||||
});
|
||||
|
||||
it('Yes turns account features on and leaves sync off', async () => {
|
||||
@@ -75,3 +85,30 @@ it('requires nothing in the browser build (no bridge)', async () => {
|
||||
render(<AccountConsent onRequirementChange={required} />);
|
||||
await waitFor(() => expect(required).toHaveBeenLastCalledWith(false));
|
||||
});
|
||||
|
||||
it('can retry a failed local account read without blocking offline setup', async () => {
|
||||
const account = bridgeWith({});
|
||||
account.get.mockRejectedValueOnce(new Error('read failed'));
|
||||
const required = vi.fn();
|
||||
render(<AccountConsent onRequirementChange={required} />);
|
||||
const retry = await screen.findByRole('button', { name: 'account.retry' });
|
||||
expect(required).toHaveBeenLastCalledWith(false);
|
||||
fireEvent.click(retry);
|
||||
expect(await screen.findByText('account.use_no')).toBeVisible();
|
||||
expect(required).toHaveBeenLastCalledWith(true);
|
||||
expect(account.setSwitches).not.toHaveBeenCalled();
|
||||
expect(account.signIn).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('reports a choice that applied for this session but could not be saved', async () => {
|
||||
const account = bridgeWith({});
|
||||
render(<AccountConsent />);
|
||||
const button = await screen.findByRole('button', { name: 'account.use_yes' });
|
||||
account.setSwitches.mockRejectedValueOnce(new Error('disk full'));
|
||||
account.get.mockResolvedValueOnce({ ...base, prompted: true, accountEnabled: true });
|
||||
fireEvent.click(button);
|
||||
expect(await screen.findByRole('alert')).toHaveTextContent('settings.save_failed');
|
||||
expect(button).toHaveAttribute('aria-pressed', 'true');
|
||||
fireEvent.click(button);
|
||||
await waitFor(() => expect(screen.queryByRole('alert')).toBeNull());
|
||||
});
|
||||
@@ -1,41 +1,92 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { CheckIcon, CloudIcon, MonitorIcon } from 'lucide-react';
|
||||
import { useAccount } from '@/features/account/use-account';
|
||||
|
||||
/** First-run choice (owner rule 2026-10-16): equal-weight Yes/No, skipping = off. */
|
||||
const choices = [
|
||||
{ enabled: true, label: 'account.use_yes', icon: CloudIcon },
|
||||
{ enabled: false, label: 'account.use_no', icon: MonitorIcon },
|
||||
] as const;
|
||||
|
||||
export function AccountConsent({
|
||||
onRequirementChange,
|
||||
}: {
|
||||
onRequirementChange?: (required: boolean) => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const { supported, state, setSwitches } = useAccount();
|
||||
const required = Boolean(supported && state?.available && !state.prompted);
|
||||
const { state, loading, readFailed, retryRead, setSwitches } = useAccount();
|
||||
const [answeredHere, setAnsweredHere] = useState(false);
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [failed, setFailed] = useState(false);
|
||||
const required = Boolean(state?.available && !state.prompted);
|
||||
useEffect(() => {
|
||||
if (!supported || state) onRequirementChange?.(required);
|
||||
}, [required, supported, state, onRequirementChange]);
|
||||
if (!required) return null;
|
||||
if (!loading) onRequirementChange?.(required || saving);
|
||||
}, [required, loading, saving, onRequirementChange]);
|
||||
|
||||
if (readFailed && !state)
|
||||
return (
|
||||
<fieldset className="space-y-2">
|
||||
<legend>{t('account.menu_settings')}</legend>
|
||||
<p role="alert">{t('common.error')}</p>
|
||||
<button type="button" onClick={retryRead} className="text-sm underline">{t('account.retry')}</button>
|
||||
</fieldset>
|
||||
);
|
||||
if (!state?.available || (!required && !answeredHere)) return null;
|
||||
|
||||
async function choose(enabled: boolean) {
|
||||
if (saving) return;
|
||||
setSaving(true);
|
||||
setFailed(false);
|
||||
setAnsweredHere(true);
|
||||
try {
|
||||
const result = await setSwitches(
|
||||
enabled ? { accountEnabled: true } : { accountEnabled: false, syncEnabled: false },
|
||||
);
|
||||
setFailed(!result?.prompted || result.accountEnabled !== enabled);
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="space-y-3">
|
||||
<h2 className="text-base font-medium">{t('account.title')}</h2>
|
||||
<p className="text-sm leading-6 text-muted-foreground">{t('account.setup_body')}</p>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={() => void setSwitches({ accountEnabled: true })}
|
||||
>
|
||||
{t('account.use_yes')}
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={() => void setSwitches({ accountEnabled: false, syncEnabled: false })}
|
||||
>
|
||||
{t('account.use_no')}
|
||||
</Button>
|
||||
<fieldset className="min-w-0 space-y-3">
|
||||
<legend className="text-base font-semibold">{t('account.title')}</legend>
|
||||
<p className="max-w-prose text-sm leading-relaxed text-muted-foreground">
|
||||
{t('account.setup_body')}
|
||||
</p>
|
||||
<div className="grid gap-2 sm:grid-cols-2">
|
||||
{choices.map(({ enabled, label, icon: Icon }) => {
|
||||
const selected = state.prompted && state.accountEnabled === enabled;
|
||||
return (
|
||||
<button
|
||||
key={label}
|
||||
type="button"
|
||||
aria-pressed={selected}
|
||||
aria-disabled={saving}
|
||||
onClick={() => void choose(enabled)}
|
||||
className="flex min-h-14 items-center gap-3 rounded-xl border border-border bg-card px-4 py-3 text-start text-sm font-medium hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring aria-pressed:border-primary aria-pressed:bg-primary/10"
|
||||
>
|
||||
<Icon aria-hidden="true" className="size-4 shrink-0 text-muted-foreground" />
|
||||
<span className="min-w-0 flex-1 [overflow-wrap:anywhere]">{t(label)}</span>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={
|
||||
selected
|
||||
? 'rounded-full bg-primary p-0.5 text-primary-foreground'
|
||||
: 'size-4 shrink-0 rounded-full border border-muted-foreground/60'
|
||||
}
|
||||
>
|
||||
{selected && <CheckIcon className="size-3" />}
|
||||
</span>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</section>
|
||||
{failed && (
|
||||
<p role="alert" className="text-sm text-destructive">
|
||||
{t('settings.save_failed')}
|
||||
</p>
|
||||
)}
|
||||
</fieldset>
|
||||
);
|
||||
}
|
||||
@@ -19,7 +19,12 @@ vi.mock('@shared/utils/analytics', () => ({
|
||||
setAnalyticsSender: vi.fn(),
|
||||
}));
|
||||
vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }));
|
||||
import { AnalyticsConsent, AnalyticsRuntime, SetupAnalyticsConsent } from './analytics-consent';
|
||||
import {
|
||||
AnalyticsConsent,
|
||||
AnalyticsRuntime,
|
||||
confirmSetupAnalytics,
|
||||
SetupAnalyticsConsent,
|
||||
} from './analytics-consent';
|
||||
import { capture, enableAnalytics } from '@shared/utils/analytics';
|
||||
import { readSetupAnalytics, rememberSetupAnalytics } from '@/lib/setup-analytics';
|
||||
afterEach(() => {
|
||||
@@ -100,16 +105,48 @@ const failedSetup = {
|
||||
},
|
||||
};
|
||||
|
||||
it('asks before setup with equal buttons and starts nothing until yes', () => {
|
||||
it('keeps setup analytics off until enabled and lets the user withdraw before installing', () => {
|
||||
const { unmount } = render(<SetupAnalyticsConsent />);
|
||||
const toggle = screen.getByRole('switch');
|
||||
expect(toggle).not.toBeChecked();
|
||||
expect(readSetupAnalytics()).toBeNull();
|
||||
expect(enableAnalytics).not.toHaveBeenCalled();
|
||||
fireEvent.click(toggle);
|
||||
expect(toggle).toBeChecked();
|
||||
expect(readSetupAnalytics()).toEqual({ enabled: true, settled: false });
|
||||
unmount();
|
||||
render(<SetupAnalyticsConsent />);
|
||||
const yes = screen.getByRole('button', { name: 'consent.yes' });
|
||||
const no = screen.getByRole('button', { name: 'consent.no' });
|
||||
expect(yes.className).toBe(no.className);
|
||||
expect(enableAnalytics).not.toHaveBeenCalled();
|
||||
fireEvent.click(no);
|
||||
const saved = screen.getByRole('switch');
|
||||
expect(saved).toBeChecked();
|
||||
fireEvent.click(saved);
|
||||
expect(saved).not.toBeChecked();
|
||||
expect(readSetupAnalytics()).toEqual({ enabled: false, settled: false });
|
||||
});
|
||||
|
||||
it('preselects unanswered welcome analytics without enabling it or overriding a saved decline', () => {
|
||||
const view = render(<SetupAnalyticsConsent preselectUnanswered />);
|
||||
expect(screen.getByRole('switch')).toBeChecked();
|
||||
expect(readSetupAnalytics()).toBeNull();
|
||||
expect(enableAnalytics).not.toHaveBeenCalled();
|
||||
expect(screen.getByRole('button', { name: 'consent.no' })).toBeEnabled();
|
||||
fireEvent.click(screen.getByRole('button', { name: 'consent.yes' }));
|
||||
expect(readSetupAnalytics()).toEqual({ enabled: true, settled: false });
|
||||
expect(enableAnalytics).toHaveBeenCalledOnce();
|
||||
fireEvent.click(screen.getByRole('switch'));
|
||||
view.unmount();
|
||||
render(<SetupAnalyticsConsent preselectUnanswered />);
|
||||
expect(screen.getByRole('switch')).not.toBeChecked();
|
||||
});
|
||||
|
||||
it('confirms an untouched switch as off on install and preserves previously saved choices', () => {
|
||||
confirmSetupAnalytics(true);
|
||||
expect(readSetupAnalytics()).toBeNull();
|
||||
confirmSetupAnalytics();
|
||||
expect(readSetupAnalytics()).toEqual({ enabled: false, settled: false });
|
||||
rememberSetupAnalytics({ enabled: true, settled: true });
|
||||
confirmSetupAnalytics();
|
||||
expect(readSetupAnalytics()).toEqual({ enabled: true, settled: true });
|
||||
expect(enableAnalytics).not.toHaveBeenCalled();
|
||||
expect(screen.queryByRole('button', { name: 'consent.yes' })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('does not ask when analytics is switched off for this machine', () => {
|
||||
@@ -214,10 +251,11 @@ it('asks again and stays off when saving the early answer fails', async () => {
|
||||
prompted: false,
|
||||
}),
|
||||
);
|
||||
expect(vi.mocked(mock.api).mock.calls.filter(([, init]) => init?.method === 'PUT')).toHaveLength(1);
|
||||
expect(vi.mocked(mock.api).mock.calls.filter(([, init]) => init?.method === 'PUT')).toHaveLength(
|
||||
1,
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
it('holds first-run events while setup runs and sends them once the backend answers', async () => {
|
||||
const { sendAnalytics: sender } = await import('./analytics-consent');
|
||||
const { apiJson } = await import('@/lib/api/client');
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { SetupPrivacyRow } from './setup-privacy-row';
|
||||
import { getBridge } from './bridge';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
@@ -117,7 +118,8 @@ export function AnalyticsRuntime() {
|
||||
// from here, on the early answer until the backend can give its own.
|
||||
const allowed = analytics.data
|
||||
? analytics.data.available && analytics.data.opted_in && !backend.analyticsDisabled
|
||||
: analyticsAvailable() && setupAnalyticsAllowed(readSetupAnalytics(), backend.analyticsDisabled);
|
||||
: analyticsAvailable() &&
|
||||
setupAnalyticsAllowed(readSetupAnalytics(), backend.analyticsDisabled);
|
||||
useEffect(() => {
|
||||
const events = funnel.current.observe(backend, setupWasCompleted(), allowed);
|
||||
if (!allowed || !events.length) return;
|
||||
@@ -133,35 +135,48 @@ export function AnalyticsRuntime() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** The first-run question, asked before setup so a failed install can be counted. */
|
||||
export function SetupAnalyticsConsent({ analyticsDisabled }: { analyticsDisabled?: boolean }) {
|
||||
function offersSetupAnalytics(analyticsDisabled?: boolean) {
|
||||
return !analyticsDisabled && analyticsAvailable() && !setupWasCompleted();
|
||||
}
|
||||
|
||||
export function confirmSetupAnalytics(analyticsDisabled?: boolean) {
|
||||
if (offersSetupAnalytics(analyticsDisabled) && !readSetupAnalytics()) {
|
||||
rememberSetupAnalytics({ enabled: false, settled: false });
|
||||
}
|
||||
}
|
||||
|
||||
export function SetupAnalyticsConsent({
|
||||
analyticsDisabled,
|
||||
preselectUnanswered = false,
|
||||
}: {
|
||||
analyticsDisabled?: boolean;
|
||||
preselectUnanswered?: boolean;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [answered, setAnswered] = useState(() => readSetupAnalytics() !== null);
|
||||
if (answered || analyticsDisabled || !analyticsAvailable() || setupWasCompleted()) return null;
|
||||
const [choice, setChoice] = useState(readSetupAnalytics);
|
||||
if (choice?.settled || !offersSetupAnalytics(analyticsDisabled)) return null;
|
||||
const choose = (enabled: boolean) => {
|
||||
rememberSetupAnalytics({ enabled, settled: false });
|
||||
setAnswered(true);
|
||||
const next = { enabled, settled: false };
|
||||
rememberSetupAnalytics(next);
|
||||
setChoice(next);
|
||||
if (enabled) void enableAnalytics();
|
||||
else disableAnalytics();
|
||||
else {
|
||||
pendingAnalytics.length = 0;
|
||||
disableAnalytics();
|
||||
}
|
||||
};
|
||||
return (
|
||||
<section
|
||||
className="w-full space-y-2 rounded-lg border border-border/60 bg-muted/20 p-3 text-left"
|
||||
data-testid="setup-analytics-consent"
|
||||
>
|
||||
<h2 className="text-sm font-medium">{t('consent.title')}</h2>
|
||||
<p className="text-xs leading-5 text-muted-foreground">
|
||||
{t('consent.body')} {t('consent.setup_note')}
|
||||
</p>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Button type="button" size="sm" variant="outline" onClick={() => choose(true)}>
|
||||
{t('consent.yes')}
|
||||
</Button>
|
||||
<Button type="button" size="sm" variant="outline" onClick={() => choose(false)}>
|
||||
{t('consent.no')}
|
||||
</Button>
|
||||
</div>
|
||||
</section>
|
||||
<SetupPrivacyRow
|
||||
testId="setup-analytics-consent"
|
||||
icon={BarChart3Icon}
|
||||
title={t('setup.usage_stats')}
|
||||
summary={t('setup.analytics_summary')}
|
||||
details={t('consent.body') + ' ' + t('consent.setup_note')}
|
||||
checked={choice?.enabled ?? preselectUnanswered}
|
||||
declineLabel={t('consent.no')}
|
||||
confirmLabel={preselectUnanswered && !choice ? t('consent.yes') : undefined}
|
||||
onChange={choose}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -239,7 +254,13 @@ export function AnalyticsConsent({
|
||||
{t('consent.learn_more')}
|
||||
</Button>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Button type="button" variant="outline" disabled={busy} onClick={() => void choose(true)}>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
data-consent-choice
|
||||
disabled={busy}
|
||||
onClick={() => void choose(true)}
|
||||
>
|
||||
{t('consent.yes')}
|
||||
</Button>
|
||||
<Button type="button" variant="outline" disabled={busy} onClick={() => void choose(false)}>
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
// @ts-expect-error Shared JSX component has no declaration file.
|
||||
import SearchableSelect from '@shared/components/SearchableSelect';
|
||||
// @ts-expect-error Shared JSX component has no declaration file.
|
||||
import LanguageFlag from '@shared/components/LanguageFlag';
|
||||
import { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { APP_LANGUAGE_ITEMS, setAppLanguage, type AppLocale } from '@/i18n';
|
||||
|
||||
function languageLabel({ value, label }: (typeof APP_LANGUAGE_ITEMS)[number]) {
|
||||
return (
|
||||
<span className="flex min-w-0 items-center gap-2 text-sm">
|
||||
<LanguageFlag code={value} />
|
||||
<span lang={value} dir="auto" className="truncate">
|
||||
{label}
|
||||
</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export function AppLanguageSelect() {
|
||||
const { t, i18n } = useTranslation();
|
||||
const [failed, setFailed] = useState(false);
|
||||
return (
|
||||
<div className="min-w-0">
|
||||
<SearchableSelect
|
||||
ariaLabel={t('settings.language')}
|
||||
value={i18n.resolvedLanguage || i18n.language}
|
||||
options={APP_LANGUAGE_ITEMS}
|
||||
renderValue={languageLabel}
|
||||
renderOption={languageLabel}
|
||||
onChange={async (locale: AppLocale) => {
|
||||
setFailed(false);
|
||||
if ((await setAppLanguage(locale)) === false) setFailed(true);
|
||||
}}
|
||||
menuPortal
|
||||
/>
|
||||
{failed && <p role="alert" className="mt-1 text-xs text-destructive">{t('settings.save_failed')}</p>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -22,7 +22,7 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
it('puts the update pill left of the account control and the bell to its right', () => {
|
||||
render(<AccountCorner notificationsEnabled />);
|
||||
render(<AccountCorner backendStage="ready" />);
|
||||
const [update, account, bell] = screen.getAllByRole('button');
|
||||
expect(update).toHaveTextContent('update');
|
||||
expect(account).toHaveTextContent('account');
|
||||
@@ -31,20 +31,31 @@ it('puts the update pill left of the account control and the bell to its right',
|
||||
expect(bell).toHaveAttribute('data-titlebar', 'true');
|
||||
});
|
||||
|
||||
it.each(['setup_required', 'installing'] as const)(
|
||||
'omits the bell during %s and restores it when ready',
|
||||
(stage) => {
|
||||
const { rerender } = render(<AccountCorner backendStage={stage} />);
|
||||
expect(screen.queryByRole('button', { name: 'bell' })).toBeNull();
|
||||
expect(Boolean(screen.queryByRole('button', { name: 'update' }))).toBe(stage === 'installing');
|
||||
rerender(<AccountCorner backendStage="ready" />);
|
||||
expect(screen.getByRole('button', { name: 'bell' })).toHaveAttribute('data-enabled', 'true');
|
||||
},
|
||||
);
|
||||
|
||||
it('sits left of the Windows/Linux window buttons, and at the corner on macOS', () => {
|
||||
const { unmount } = render(<AccountCorner notificationsEnabled={false} />);
|
||||
const { unmount } = render(<AccountCorner backendStage="starting" />);
|
||||
const corner = () => document.querySelector('[data-slot="account-corner"]')!;
|
||||
expect(corner().className).toMatch(/fixed/);
|
||||
expect(corner().className).toMatch(/app-no-drag/);
|
||||
expect(corner().className).toMatch(/right-\[148px\]/);
|
||||
unmount();
|
||||
mock.mac = true;
|
||||
render(<AccountCorner notificationsEnabled={false} />);
|
||||
render(<AccountCorner backendStage="starting" />);
|
||||
expect(corner().className).toMatch(/right-3\.5/);
|
||||
});
|
||||
|
||||
it('reserves title-bar space while it shows and frees it when it goes', () => {
|
||||
const { unmount } = render(<AccountCorner notificationsEnabled />);
|
||||
const { unmount } = render(<AccountCorner backendStage="ready" />);
|
||||
expect(document.documentElement.style.getPropertyValue('--corner-space')).toMatch(/px$/);
|
||||
unmount();
|
||||
expect(document.documentElement.style.getPropertyValue('--corner-space')).toBe('');
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { useLayoutEffect, useRef } from 'react';
|
||||
import { isMac } from '@/components/bridge';
|
||||
import { isBackendReachable } from '@shared/utils/backendStage';
|
||||
import type { BackendStage } from '../../../../preload/index.d';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { AccountMenu } from './account-menu';
|
||||
import { SystemNotifications } from './system-notifications';
|
||||
@@ -19,7 +21,7 @@ const CORNER_GAP = 12;
|
||||
* shows, `--corner-space` widens every page title bar's right padding
|
||||
* (globals.css), so it never covers a page's own buttons.
|
||||
*/
|
||||
export function AccountCorner({ notificationsEnabled }: { notificationsEnabled: boolean }) {
|
||||
export function AccountCorner({ backendStage }: { backendStage: BackendStage }) {
|
||||
const host = useRef<HTMLDivElement>(null);
|
||||
useLayoutEffect(() => {
|
||||
const root = document.documentElement;
|
||||
@@ -52,9 +54,11 @@ export function AccountCorner({ notificationsEnabled }: { notificationsEnabled:
|
||||
isMac() ? 'right-3.5' : 'right-[148px]',
|
||||
)}
|
||||
>
|
||||
<UpdatePill />
|
||||
{backendStage !== 'setup_required' && <UpdatePill />}
|
||||
<AccountMenu />
|
||||
<SystemNotifications enabled={notificationsEnabled} titlebar />
|
||||
{backendStage !== 'setup_required' && backendStage !== 'installing' && (
|
||||
<SystemNotifications enabled={isBackendReachable(backendStage)} titlebar />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import { RepairAgentDock } from './repair-agent-dock';
|
||||
import { isMac } from '../bridge';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { useBackendStatus } from '@/hooks/use-backend-status';
|
||||
import { isBackendReachable } from '@shared/utils/backendStage';
|
||||
import { AccountCorner } from './account-corner';
|
||||
import { NowPlayingDock } from '@/components/now-playing-dock';
|
||||
|
||||
@@ -36,7 +35,6 @@ export function AppShell() {
|
||||
<WorkspaceSidebar />
|
||||
<SettingsWorkspace
|
||||
data-slot="workspace-content"
|
||||
role={pathname === '/settings/openapi' ? 'main' : undefined}
|
||||
className="@container relative flex min-w-0 flex-1 flex-col overflow-hidden"
|
||||
>
|
||||
<div className="min-h-0 flex-1 overflow-hidden">
|
||||
@@ -65,8 +63,7 @@ export function AppShell() {
|
||||
<NowPlayingDock />
|
||||
{/* Native drag-region hit testing follows document order. Keep these
|
||||
no-drag controls after every workspace titlebar, outside BackendGate. */}
|
||||
{/* Top-right corner on every page and platform: account, then the notifications bell. */}
|
||||
<AccountCorner notificationsEnabled={isBackendReachable(backend.stage)} />
|
||||
<AccountCorner backendStage={backend.stage} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -42,3 +42,11 @@ it('reopens a collapsed library pane when a library shortcut opens it', () => {
|
||||
fireEvent.click(screen.getByRole('button', { name: 'paneActions.collapse' }));
|
||||
expect(setWorkspace).toHaveBeenCalledWith({ libraryOpen: false });
|
||||
});
|
||||
|
||||
it('keeps the Home canvas clear until the voice library is requested', () => {
|
||||
route.pathname = '/';
|
||||
workspace.libraryOpen = true;
|
||||
const { container } = render(<ContextSidebar />);
|
||||
expect(container).toBeEmptyDOMElement();
|
||||
route.pathname = '/clone';
|
||||
});
|
||||
@@ -9,17 +9,21 @@ import { LIBRARY_ROUTES } from './use-workspace-sidebar';
|
||||
/** The user's saved voices and recent takes, beside the slim navigation column. */
|
||||
export function ContextSidebar() {
|
||||
const { t } = useTranslation();
|
||||
const { libraryOpen, libraryTab } = useWorkspace();
|
||||
const { libraryOpen, libraryTab, homeLibraryOpen } = useWorkspace();
|
||||
const pathname = useRouterState({ select: (state) => state.location.pathname });
|
||||
if (!LIBRARY_ROUTES.has(pathname.replace(/\/+$/, '') || '/')) return null;
|
||||
const home = pathname === '/';
|
||||
if (home && !homeLibraryOpen) return null;
|
||||
return (
|
||||
<SecondarySidebar
|
||||
title={t('nav.voice')}
|
||||
icon={LibraryIcon}
|
||||
variant="library"
|
||||
className="flex flex-col overflow-hidden p-0"
|
||||
collapsed={!libraryOpen}
|
||||
onCollapsedChange={(collapsed) => setWorkspace({ libraryOpen: !collapsed })}
|
||||
collapsed={!home && !libraryOpen}
|
||||
onCollapsedChange={(collapsed) =>
|
||||
setWorkspace(home ? { homeLibraryOpen: !collapsed } : { libraryOpen: !collapsed })
|
||||
}
|
||||
>
|
||||
<VoicesSidebar initialTab={libraryTab} />
|
||||
</SecondarySidebar>
|
||||
|
||||
@@ -68,7 +68,7 @@ it('shows an exact live count and refreshes it every 20 minutes', async () => {
|
||||
expect(fetchCount).toHaveBeenCalledTimes(2);
|
||||
vi.useRealTimers();
|
||||
await waitFor(() => expect(screen.getByText('43.9K')).toBeVisible());
|
||||
expect(screen.getByRole('link', { name: 'support.star_github' })).toHaveAttribute(
|
||||
expect(screen.getByRole('link', { name: /support.star_short.*43.9K/ })).toHaveAttribute(
|
||||
'href',
|
||||
'https://github.com/debpalash/VoiceStudio',
|
||||
);
|
||||
|
||||
@@ -48,7 +48,7 @@ export function GithubStar() {
|
||||
href={REPO_URL}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
aria-label={t('support.star_github')}
|
||||
aria-description={t('support.star_github')}
|
||||
className="github-star-shortcut app-no-drag inline-flex shrink-0 items-stretch text-xs font-medium focus-visible:outline-2 focus-visible:outline-ring"
|
||||
onClick={(event) => {
|
||||
const bridge = getBridge();
|
||||
|
||||
@@ -196,7 +196,7 @@ export function SystemNotifications({
|
||||
'relative shrink-0 text-muted-foreground hover:text-foreground',
|
||||
titlebar && 'app-no-drag',
|
||||
)}
|
||||
aria-label={triggerLabel}
|
||||
aria-label={total ? `${total > 9 ? '9+' : total} · ${triggerLabel}` : triggerLabel}
|
||||
/>
|
||||
}
|
||||
>
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
.update-drawer {
|
||||
bottom: var(--setup-community-height, 0px);
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
transition: transform 250ms cubic-bezier(0.22, 1, 0.36, 1);
|
||||
}
|
||||
|
||||
.update-drawer[data-starting-style],
|
||||
.update-drawer[data-ending-style] {
|
||||
transform: translateY(100%);
|
||||
}
|
||||
|
||||
/* Reserve the bar’s height so the last workspace or setup control stays reachable. */
|
||||
body:has(> .update-dock) {
|
||||
--update-dock-height: calc(2.5rem + env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
body:has(> .update-dock) > #root {
|
||||
height: calc(100% - var(--update-dock-height));
|
||||
}
|
||||
|
||||
.update-dock {
|
||||
height: var(--update-dock-height);
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
|
||||
.update-drawer-paw {
|
||||
fill: currentColor;
|
||||
stroke-width: 1.25;
|
||||
transform-origin: 50% 85%;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
.update-drawer-paw {
|
||||
animation: update-paw-wave 620ms 180ms ease-in-out both;
|
||||
}
|
||||
|
||||
@keyframes update-paw-wave {
|
||||
25% {
|
||||
transform: rotate(-16deg);
|
||||
}
|
||||
55% {
|
||||
transform: rotate(12deg);
|
||||
}
|
||||
80% {
|
||||
transform: rotate(-5deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.update-drawer {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,21 @@
|
||||
import { useState } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { AlertTriangleIcon, DownloadIcon, ExternalLinkIcon, RotateCwIcon } from 'lucide-react';
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/popover';
|
||||
import {
|
||||
AlertTriangleIcon,
|
||||
ChevronUpIcon,
|
||||
DownloadIcon,
|
||||
ExternalLinkIcon,
|
||||
PawPrintIcon,
|
||||
RotateCwIcon,
|
||||
XIcon,
|
||||
} from 'lucide-react';
|
||||
import { Dialog as DialogPrimitive } from '@base-ui/react/dialog';
|
||||
import './update-drawer.css';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { MarkdownLite } from '@/components/markdown-lite';
|
||||
import { useThrottledUpdate, useUpdateState } from '@/hooks/use-update-state';
|
||||
import { runUpdateAction, type UpdateAction } from '@/lib/update-actions';
|
||||
import { primaryUpdateAction, runUpdateAction, type UpdateAction } from '@/lib/update-actions';
|
||||
import { formatBytes, updateErrorTitleKey } from '@/lib/update-format';
|
||||
import { splitRoundedMinutes } from '@shared/utils/timeFormat';
|
||||
import { cn } from '@/lib/utils';
|
||||
@@ -54,31 +64,39 @@ function ProgressRing({ pct }: { pct: number }) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The title-bar update control, left of the account avatar: a ring while an
|
||||
* update downloads, Restart once it is verified, Retry after a failure. Its
|
||||
* popover carries the details and every action.
|
||||
*/
|
||||
export function UpdatePill() {
|
||||
type DrawerView = 'expanded' | 'docked' | 'closed';
|
||||
|
||||
/** Setup surfaces each new release immediately. The workspace pill opens it on demand. */
|
||||
export function UpdatePill({ setup = false }: { setup?: boolean }) {
|
||||
const { t } = useTranslation();
|
||||
const live = useUpdateState();
|
||||
const state = useThrottledUpdate(live);
|
||||
const [open, setOpen] = useState(false);
|
||||
const state = useThrottledUpdate(useUpdateState());
|
||||
const [choice, setChoice] = useState<{ version?: string; view: DrawerView } | null>(null);
|
||||
if (!updatePillVisible(state)) return null;
|
||||
|
||||
const version = state.availableVersion;
|
||||
const choiceForRelease = choice && choice.version === version ? choice.view : undefined;
|
||||
const view =
|
||||
choiceForRelease ??
|
||||
(setup && version && state.dismissedVersion !== version ? 'expanded' : 'closed');
|
||||
const setView = (view: DrawerView) => setChoice({ version, view });
|
||||
const primary = primaryUpdateAction(state);
|
||||
const pct = Math.round(state.progress);
|
||||
const act = (action: UpdateAction) => {
|
||||
if (action !== 'retry' && action !== 'download') setOpen(false);
|
||||
if (action !== 'retry' && action !== 'download') setView('closed');
|
||||
void runUpdateAction(action, state, t);
|
||||
};
|
||||
const label =
|
||||
state.status === 'downloading'
|
||||
? t('update.downloading', { pct })
|
||||
: state.status === 'downloaded'
|
||||
? t('update.ready', { version: state.availableVersion ?? '' })
|
||||
? setup
|
||||
? t('update.prompt_ready')
|
||||
: t('update.ready', { version: state.availableVersion ?? '' })
|
||||
: state.status === 'error'
|
||||
? t(updateErrorTitleKey(state), { version: state.availableVersion ?? '' })
|
||||
: t('update.available', { version: state.availableVersion ?? '' });
|
||||
: t(setup ? 'update.prompt_available' : 'update.available', {
|
||||
version: state.availableVersion ?? '',
|
||||
});
|
||||
const detail =
|
||||
state.status === 'downloading' && state.totalBytes
|
||||
? t('update.download_detail', {
|
||||
@@ -90,8 +108,16 @@ export function UpdatePill() {
|
||||
: null;
|
||||
|
||||
return (
|
||||
<Popover open={open} onOpenChange={setOpen}>
|
||||
<PopoverTrigger
|
||||
<DialogPrimitive.Root
|
||||
modal={false}
|
||||
open={view === 'expanded'}
|
||||
onOpenChange={(open, { reason }) => {
|
||||
if (open) setView('expanded');
|
||||
else if (reason === 'outside-press' || reason === 'focus-out') setView('docked');
|
||||
else setView('closed');
|
||||
}}
|
||||
>
|
||||
<DialogPrimitive.Trigger
|
||||
render={
|
||||
<Button
|
||||
variant="ghost"
|
||||
@@ -130,89 +156,135 @@ export function UpdatePill() {
|
||||
<span>{t('update.pill_update')}</span>
|
||||
</>
|
||||
)}
|
||||
</PopoverTrigger>
|
||||
<PopoverContent
|
||||
side="bottom"
|
||||
align="end"
|
||||
className="flex w-[min(22rem,calc(100vw-2rem))] flex-col gap-2.5 p-3 text-sm"
|
||||
>
|
||||
<div className="min-w-0">
|
||||
<p className="font-medium">{label}</p>
|
||||
<p className="mt-0.5 text-xs text-muted-foreground tabular-nums">
|
||||
v{state.currentVersion}
|
||||
{state.availableVersion && ` → v${state.availableVersion}`}
|
||||
</p>
|
||||
</div>
|
||||
{state.status === 'downloading' && (
|
||||
<div className="space-y-1.5">
|
||||
<div
|
||||
role="progressbar"
|
||||
aria-label={label}
|
||||
aria-valuemin={0}
|
||||
aria-valuemax={100}
|
||||
aria-valuenow={pct}
|
||||
className="h-1.5 w-full overflow-hidden rounded-full bg-muted"
|
||||
>
|
||||
<div
|
||||
className="h-full rounded-full bg-primary transition-[width] duration-300 motion-reduce:transition-none"
|
||||
style={{ width: `${pct}%` }}
|
||||
/>
|
||||
</div>
|
||||
{detail && <p className="text-[11px] text-muted-foreground tabular-nums">{detail}</p>}
|
||||
</div>
|
||||
</DialogPrimitive.Trigger>
|
||||
{view === 'docked' &&
|
||||
createPortal(
|
||||
<button
|
||||
type="button"
|
||||
data-testid="update-dock"
|
||||
aria-haspopup="dialog"
|
||||
aria-expanded={false}
|
||||
className="update-dock app-no-drag fixed inset-x-0 bottom-0 z-30 flex w-full items-center justify-center gap-2 border-t border-border bg-popover px-4 text-sm text-popover-foreground hover:bg-accent focus-visible:outline-ring"
|
||||
onClick={() => setView('expanded')}
|
||||
>
|
||||
<PawPrintIcon aria-hidden="true" className="size-4 shrink-0 text-primary" />
|
||||
<span className="truncate">{label}</span>
|
||||
<ChevronUpIcon aria-hidden="true" className="size-4 shrink-0 text-muted-foreground" />
|
||||
</button>,
|
||||
document.body,
|
||||
)}
|
||||
{state.status === 'downloaded' && (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{t(state.installOnQuit ? 'update.ready_hint_quit' : 'update.ready_hint_restart')}
|
||||
</p>
|
||||
)}
|
||||
{state.status === 'error' && state.error && (
|
||||
<details className="text-xs text-muted-foreground">
|
||||
<summary className="cursor-pointer">{t('common.more_info')}</summary>
|
||||
<p className="mt-1 break-words">{state.error}</p>
|
||||
</details>
|
||||
)}
|
||||
{state.notes && state.status !== 'error' && (
|
||||
<div className="max-h-48 overflow-y-auto rounded-md border border-border/60 bg-muted/30 px-2.5 py-2">
|
||||
<MarkdownLite
|
||||
text={capNotes(state.notes)}
|
||||
className="text-xs leading-5 text-muted-foreground"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
className="inline-flex items-center gap-1 self-start text-xs text-primary hover:underline"
|
||||
onClick={() => act('manual')}
|
||||
<DialogPrimitive.Portal>
|
||||
<DialogPrimitive.Popup
|
||||
initialFocus={choiceForRelease === 'expanded'}
|
||||
finalFocus={view !== 'docked'}
|
||||
className="update-drawer app-no-drag fixed inset-x-0 bottom-0 z-40 mx-auto flex max-h-[85dvh] w-full max-w-lg flex-col overflow-hidden rounded-t-3xl border border-b-0 border-border bg-popover text-popover-foreground shadow-2xl outline-none"
|
||||
data-testid={setup ? 'setup-update-notice' : undefined}
|
||||
>
|
||||
<ExternalLinkIcon className="size-3" aria-hidden="true" />
|
||||
{t(state.status === 'error' ? 'update.download_manually' : 'update.view_release')}
|
||||
</button>
|
||||
<div className="flex items-center justify-end gap-2">
|
||||
{state.status !== 'downloading' && (
|
||||
<Button size="sm" variant="ghost" onClick={() => act('later')}>
|
||||
{t('update.toast_later')}
|
||||
</Button>
|
||||
)}
|
||||
{state.status === 'downloaded' && (
|
||||
<Button size="sm" onClick={() => act('install')}>
|
||||
<RotateCwIcon />
|
||||
{t('update.pill_restart')}
|
||||
</Button>
|
||||
)}
|
||||
{state.status === 'error' && (
|
||||
<Button size="sm" onClick={() => act('retry')}>
|
||||
{t('update.retry')}
|
||||
</Button>
|
||||
)}
|
||||
{state.status === 'available' && (
|
||||
<Button size="sm" onClick={() => act('download')}>
|
||||
<DownloadIcon />
|
||||
{t('update.download')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
<div className="flex shrink-0 items-center gap-3 px-5 pt-5 sm:px-6">
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className="flex size-11 shrink-0 items-center justify-center rounded-2xl bg-primary/12 text-primary"
|
||||
>
|
||||
<PawPrintIcon className="update-drawer-paw size-6" />
|
||||
</span>
|
||||
<div className="min-w-0 flex-1">
|
||||
<DialogPrimitive.Title className="text-base font-semibold leading-snug">
|
||||
{label}
|
||||
</DialogPrimitive.Title>
|
||||
<p dir="ltr" className="mt-1 text-start text-xs text-muted-foreground tabular-nums">
|
||||
v{state.currentVersion}
|
||||
{state.availableVersion && ` → v${state.availableVersion}`}
|
||||
</p>
|
||||
</div>
|
||||
<DialogPrimitive.Close
|
||||
render={<Button size="icon-sm" variant="ghost" aria-label={t('common.close')} />}
|
||||
>
|
||||
<XIcon />
|
||||
</DialogPrimitive.Close>
|
||||
</div>
|
||||
<div className="min-h-0 space-y-3 overflow-y-auto overscroll-contain px-5 py-4 sm:px-6">
|
||||
{setup && state.status === 'available' && (
|
||||
<DialogPrimitive.Description className="text-sm leading-relaxed text-muted-foreground">
|
||||
{t('setup.update_first')}
|
||||
</DialogPrimitive.Description>
|
||||
)}
|
||||
{state.status === 'downloading' && (
|
||||
<div className="space-y-1.5">
|
||||
<div
|
||||
role="progressbar"
|
||||
aria-label={label}
|
||||
aria-valuemin={0}
|
||||
aria-valuemax={100}
|
||||
aria-valuenow={pct}
|
||||
className="h-1.5 w-full overflow-hidden rounded-full bg-muted"
|
||||
>
|
||||
<div
|
||||
className="h-full rounded-full bg-primary transition-[width] duration-300 motion-reduce:transition-none"
|
||||
style={{ width: `${pct}%` }}
|
||||
/>
|
||||
</div>
|
||||
{detail && (
|
||||
<p className="text-[11px] text-muted-foreground tabular-nums">{detail}</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{state.status === 'downloaded' && (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{t(state.installOnQuit ? 'update.ready_hint_quit' : 'update.ready_hint_restart')}
|
||||
</p>
|
||||
)}
|
||||
{state.status === 'error' && state.error && (
|
||||
<details className="text-xs text-muted-foreground">
|
||||
<summary className="cursor-pointer">{t('common.more_info')}</summary>
|
||||
<p className="mt-1 break-words">{state.error}</p>
|
||||
</details>
|
||||
)}
|
||||
{state.notes && state.status !== 'error' && (
|
||||
<details className="text-sm">
|
||||
<summary className="cursor-pointer text-muted-foreground hover:text-foreground">
|
||||
{t('update.whats_new')}
|
||||
</summary>
|
||||
<MarkdownLite
|
||||
text={capNotes(state.notes)}
|
||||
className="mt-2 text-sm leading-relaxed text-muted-foreground"
|
||||
/>
|
||||
</details>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-border/60 px-5 pt-4 pb-2 sm:px-6">
|
||||
<button
|
||||
type="button"
|
||||
className="me-auto inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground hover:underline"
|
||||
onClick={() => act('manual')}
|
||||
>
|
||||
<ExternalLinkIcon className="size-3" aria-hidden="true" />
|
||||
{t(state.status === 'error' ? 'update.download_manually' : 'update.view_release')}
|
||||
</button>
|
||||
{state.status !== 'downloading' && (
|
||||
<Button size="sm" variant="ghost" onClick={() => act('later')}>
|
||||
{t('update.toast_later')}
|
||||
</Button>
|
||||
)}
|
||||
{primary === 'install' && (
|
||||
<Button size="sm" onClick={() => act('install')}>
|
||||
<RotateCwIcon />
|
||||
{t(setup ? 'update.restart' : 'update.pill_restart')}
|
||||
</Button>
|
||||
)}
|
||||
{primary === 'retry' && (
|
||||
<Button size="sm" onClick={() => act('retry')}>
|
||||
{t('update.retry')}
|
||||
</Button>
|
||||
)}
|
||||
{primary === 'download' && (
|
||||
<Button size="sm" onClick={() => act('download')}>
|
||||
<DownloadIcon />
|
||||
{t('update.download')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</DialogPrimitive.Popup>
|
||||
</DialogPrimitive.Portal>
|
||||
</DialogPrimitive.Root>
|
||||
);
|
||||
}
|
||||
@@ -28,7 +28,7 @@ it('keeps every header control on the 28px title bar row', () => {
|
||||
<h1>Design</h1>
|
||||
</WorkspaceHeader>,
|
||||
);
|
||||
expect(screen.getByRole('button', { name: 'preferences.search' })).toHaveClass('h-7');
|
||||
expect(screen.getByRole('button', { name: 'preferences.search ⌘K' })).toHaveClass('h-7');
|
||||
});
|
||||
|
||||
it('lets a page item pushed right sit beside search instead of mid-bar', () => {
|
||||
@@ -42,7 +42,7 @@ it('lets a page item pushed right sit beside search instead of mid-bar', () => {
|
||||
);
|
||||
// Page items share one growing row, so only one auto margin competes for the free space.
|
||||
expect(screen.getByRole('link', { name: 'Projects' }).parentElement).toHaveClass('flex-1');
|
||||
expect(screen.getByRole('button', { name: 'preferences.search' }).parentElement).not.toHaveClass(
|
||||
expect(screen.getByRole('button', { name: 'preferences.search ⌘K' }).parentElement).not.toHaveClass(
|
||||
'ml-auto',
|
||||
);
|
||||
});
|
||||
@@ -44,13 +44,14 @@ export function WorkspaceHeader({ children }: { children: ReactNode }) {
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-7 shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground"
|
||||
aria-label={t('preferences.search')}
|
||||
className="h-7 shrink-0 gap-1.5 rounded-full bg-muted px-2 text-muted-foreground hover:text-foreground @3xl:ms-2 @3xl:min-w-32 @3xl:px-3"
|
||||
aria-keyshortcuts={isMac() ? 'Meta+K' : 'Control+K'}
|
||||
title={isMac() ? 'Command + K' : 'Ctrl + K'}
|
||||
onClick={() => window.dispatchEvent(new Event('voicestudio:commands'))}
|
||||
>
|
||||
<SearchIcon />
|
||||
<span className="hidden text-xs font-medium lg:inline">{isMac() ? '⌘K' : 'Ctrl K'}</span>
|
||||
<span className="sr-only @3xl:not-sr-only @3xl:text-xs">{t('preferences.search')}</span>{' '}
|
||||
<span className="ms-auto hidden text-[11px] font-medium tabular-nums @3xl:inline">{isMac() ? '⌘K' : 'Ctrl K'}</span>
|
||||
</Button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -50,12 +50,69 @@
|
||||
--workspace-icon-accent: var(--color-red-500);
|
||||
}
|
||||
|
||||
.workspace-nav-item[aria-current='page']::before {
|
||||
position: absolute;
|
||||
inset-inline-start: 0;
|
||||
inset-block: 28%;
|
||||
width: 0.1875rem;
|
||||
border-radius: var(--control-radius);
|
||||
background-color: var(--sidebar-primary);
|
||||
content: '';
|
||||
}
|
||||
|
||||
.workspace-nav-item:is(:hover, :focus-visible, [aria-current='page'], [data-active='true'])
|
||||
.workspace-nav-icon {
|
||||
color: color-mix(in oklab, var(--workspace-icon-accent) 78%, var(--foreground));
|
||||
filter: drop-shadow(0 0 4px color-mix(in srgb, var(--workspace-icon-accent) 32%, transparent));
|
||||
}
|
||||
|
||||
[data-slot='compact-main-sidebar'] .workspace-nav-item {
|
||||
position: relative;
|
||||
width: 2.5rem;
|
||||
max-width: 100%;
|
||||
height: 2.5rem;
|
||||
flex-shrink: 0;
|
||||
border-radius: 0.7rem;
|
||||
}
|
||||
|
||||
[data-slot='compact-main-sidebar'] .workspace-nav-icon {
|
||||
width: 1.125rem;
|
||||
height: 1.125rem;
|
||||
animation: none !important;
|
||||
}
|
||||
|
||||
[data-slot='compact-main-sidebar'] .workspace-nav-item:is(:hover, :focus-visible, [aria-current='page'], [data-active='true']) .workspace-nav-icon {
|
||||
filter: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
[data-slot='compact-main-sidebar'] .workspace-nav-item:is([aria-current='page'], [data-active='true']) {
|
||||
background: color-mix(in srgb, var(--sidebar-primary) 13%, var(--sidebar));
|
||||
color: var(--sidebar-primary);
|
||||
}
|
||||
|
||||
[data-slot='compact-main-sidebar'] .workspace-nav-item:is([aria-current='page'], [data-active='true'])::before {
|
||||
position: absolute;
|
||||
inset-inline-start: 0;
|
||||
inset-block: 34%;
|
||||
width: 0.15rem;
|
||||
border-radius: 1rem;
|
||||
background: currentColor;
|
||||
content: '';
|
||||
}
|
||||
|
||||
[data-rail-group]::after {
|
||||
position: absolute;
|
||||
inset-inline-end: 0.25rem;
|
||||
width: 0.23rem;
|
||||
height: 0.23rem;
|
||||
border-top: 1px solid currentColor;
|
||||
border-right: 1px solid currentColor;
|
||||
transform: rotate(45deg);
|
||||
opacity: 0.65;
|
||||
content: '';
|
||||
}
|
||||
|
||||
.workspace-nav-item:is(:hover, :focus-visible) .workspace-nav-icon[data-motion='pulse'] {
|
||||
animation: workspace-icon-pulse 400ms ease-out both;
|
||||
}
|
||||
@@ -118,3 +175,21 @@
|
||||
transition-duration: 0ms;
|
||||
}
|
||||
}
|
||||
|
||||
/* Keep flyout icons aligned and still while the pointer moves between destinations. */
|
||||
.workspace-flyout .workspace-nav-item .workspace-nav-icon {
|
||||
animation: none;
|
||||
filter: none;
|
||||
color: var(--muted-foreground);
|
||||
}
|
||||
|
||||
.workspace-flyout .workspace-nav-item:is(:hover, :focus-visible, [aria-current='page']) .workspace-nav-icon {
|
||||
color: currentColor;
|
||||
animation: none;
|
||||
filter: none;
|
||||
}
|
||||
|
||||
[data-slot='compact-main-sidebar'] [data-rail-group][aria-expanded='true'] {
|
||||
background-color: var(--sidebar-accent);
|
||||
color: var(--sidebar-accent-foreground);
|
||||
}
|
||||
@@ -4,14 +4,19 @@ import { expect, it, vi } from 'vitest';
|
||||
const route = vi.hoisted(() => ({ pathname: '/gallery' }));
|
||||
vi.mock('@tanstack/react-router', () => ({
|
||||
useRouterState: ({ select }: any) => select({ location: route }),
|
||||
Link: ({ to, activeProps: _activeProps, children, ...props }: any) => (
|
||||
Link: ({
|
||||
to,
|
||||
activeProps: _activeProps,
|
||||
activeOptions: _activeOptions,
|
||||
children,
|
||||
...props
|
||||
}: any) => (
|
||||
<a href={to} {...props}>
|
||||
{children}
|
||||
</a>
|
||||
),
|
||||
}));
|
||||
vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }));
|
||||
vi.mock('@/lib/store/workspace', () => ({ setWorkspace: vi.fn() }));
|
||||
import { WorkspaceNavigation } from './workspace-menu';
|
||||
|
||||
it('opens the current workflow, lets users collapse it, and follows route changes', () => {
|
||||
@@ -53,10 +58,26 @@ it('opens a compact group for a mouse hover while ignoring touch hover', async (
|
||||
fireEvent.pointerEnter(voice, { pointerType: 'touch' });
|
||||
expect(screen.queryByRole('link', { name: 'nav.clone_short' })).toBeNull();
|
||||
fireEvent.pointerEnter(voice, { pointerType: 'mouse' });
|
||||
fireEvent.mouseEnter(voice);
|
||||
fireEvent.mouseMove(voice);
|
||||
expect(await screen.findByRole('link', { name: 'nav.clone_short' })).toBeInTheDocument();
|
||||
expect(voice).toHaveAttribute('aria-expanded', 'true');
|
||||
});
|
||||
|
||||
it('switches compact groups without leaving two navigation panels open', async () => {
|
||||
render(<WorkspaceNavigation compact />);
|
||||
const voice = screen.getByRole('button', { name: 'nav.voice' });
|
||||
fireEvent.click(voice);
|
||||
await screen.findByRole('link', { name: 'nav.gallery' });
|
||||
const stories = screen.getByRole('button', { name: 'nav.stories' });
|
||||
fireEvent.pointerEnter(stories, { pointerType: 'mouse' });
|
||||
fireEvent.mouseEnter(stories);
|
||||
fireEvent.mouseMove(stories);
|
||||
await screen.findByRole('link', { name: 'audiobook.title' });
|
||||
expect(stories).toHaveAttribute('aria-expanded', 'true');
|
||||
expect(voice).toHaveAttribute('aria-expanded', 'false');
|
||||
});
|
||||
|
||||
it('keeps the compact flyout mounted until navigation changes the route', async () => {
|
||||
route.pathname = '/gallery';
|
||||
const { rerender } = render(<WorkspaceNavigation compact />);
|
||||
@@ -76,3 +97,36 @@ it('closes the compact flyout when choosing the current route again', async () =
|
||||
fireEvent.click(await screen.findByRole('link', { name: 'nav.gallery' }));
|
||||
await waitFor(() => expect(screen.queryByRole('link', { name: 'nav.gallery' })).toBeNull());
|
||||
});
|
||||
|
||||
it('moves focus between compact group links with arrow keys and returns to the trigger', async () => {
|
||||
render(<WorkspaceNavigation compact />);
|
||||
const group = screen.getByRole('button', { name: 'nav.voice' });
|
||||
group.focus();
|
||||
fireEvent.keyDown(group, { key: 'ArrowRight' });
|
||||
const first = await screen.findByRole('link', { name: 'nav.clone_short' });
|
||||
const last = screen.getByRole('link', { name: 'nav.gallery' });
|
||||
await waitFor(() => expect(first).toHaveFocus());
|
||||
fireEvent.keyDown(first, { key: 'ArrowUp' });
|
||||
expect(last).toHaveFocus();
|
||||
fireEvent.keyDown(last, { key: 'ArrowDown' });
|
||||
expect(first).toHaveFocus();
|
||||
fireEvent.keyDown(first, { key: 'ArrowLeft' });
|
||||
await waitFor(() => expect(group).toHaveAttribute('aria-expanded', 'false'));
|
||||
expect(group).toHaveFocus();
|
||||
});
|
||||
|
||||
it('lets a compact rail keep a workspace pinned and marks More when the current workspace is unpinned', async () => {
|
||||
route.pathname = '/integrations';
|
||||
render(<WorkspaceNavigation compact />);
|
||||
const more = screen.getByRole('button', { name: 'nav.more_workspaces' });
|
||||
expect(more).toHaveAttribute('data-active', 'true');
|
||||
fireEvent.click(more);
|
||||
const pin = (await screen.findAllByRole('button', { name: 'nav.pin_workspace' })).at(-1)!;
|
||||
fireEvent.click(pin);
|
||||
expect(pin).toHaveAttribute('aria-pressed', 'true');
|
||||
expect(more).toHaveAttribute('data-active', 'false');
|
||||
expect(document.querySelector('nav a[href="/integrations"]')).not.toBeNull();
|
||||
fireEvent.click(pin);
|
||||
expect(document.querySelector('nav a[href="/integrations"]')).toBeNull();
|
||||
expect(more).toHaveAttribute('data-active', 'true');
|
||||
});
|
||||
@@ -7,6 +7,9 @@ import {
|
||||
BookOpenIcon,
|
||||
FolderIcon,
|
||||
WrenchIcon,
|
||||
EllipsisIcon,
|
||||
PinIcon,
|
||||
HouseIcon,
|
||||
LayersIcon,
|
||||
LibraryIcon,
|
||||
FilmIcon,
|
||||
@@ -19,12 +22,13 @@ import {
|
||||
} from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
|
||||
import { setWorkspace } from '@/lib/store/workspace';
|
||||
import { setWorkspace, useWorkspace } from '@/lib/store/workspace';
|
||||
import { cn } from '@/lib/utils';
|
||||
import './workspace-menu.css';
|
||||
|
||||
type Destination = readonly [
|
||||
to:
|
||||
| '/'
|
||||
| '/clone'
|
||||
| '/stories'
|
||||
| '/audiobook'
|
||||
@@ -69,10 +73,16 @@ const laterDestinations: Destination[] = [
|
||||
|
||||
const itemClass =
|
||||
'workspace-nav-item group relative flex h-9 min-w-0 items-center overflow-hidden rounded-lg text-sm text-sidebar-foreground/80 outline-none transition-colors hover:bg-sidebar-accent/50 hover:text-sidebar-foreground focus-visible:ring-2 focus-visible:ring-ring';
|
||||
const flyoutClass =
|
||||
'workspace-flyout max-h-[var(--available-height)] max-w-[var(--available-width)] overflow-y-auto rounded-xl bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-border/70 data-open:zoom-in-100 data-closed:zoom-out-100';
|
||||
const flyoutHeading = 'px-2.5 pb-1 pt-1.5 text-xs font-medium text-muted-foreground';
|
||||
type FlyoutChange = (group: string, open: boolean) => void;
|
||||
|
||||
const iconClass =
|
||||
'workspace-nav-icon size-4 shrink-0 text-muted-foreground transition-[color,filter] duration-150';
|
||||
|
||||
const iconMotion: Record<Destination[0], string> = {
|
||||
'/': 'lift',
|
||||
'/clone': 'pulse',
|
||||
'/design': 'tilt',
|
||||
'/personas': 'nudge',
|
||||
@@ -115,13 +125,14 @@ function NavigationLink({
|
||||
compact
|
||||
? 'h-10 justify-center px-0'
|
||||
: flyout
|
||||
? 'h-10 gap-2 px-3 text-sm'
|
||||
? 'min-h-8 h-auto gap-2.5 rounded-md px-2.5 py-1.5 leading-5 text-popover-foreground/85 hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent focus-visible:ring-inset'
|
||||
: nested
|
||||
? 'gap-2 px-2'
|
||||
: 'gap-2.5 px-2.5',
|
||||
)}
|
||||
activeOptions={{ exact: to === '/' }}
|
||||
activeProps={{
|
||||
className: 'bg-sidebar-accent/80 font-semibold text-sidebar-foreground',
|
||||
className: 'bg-[var(--sidebar-row-active)] font-semibold text-sidebar-foreground',
|
||||
'aria-current': 'page',
|
||||
}}
|
||||
>
|
||||
@@ -138,7 +149,9 @@ function NavigationLink({
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger render={link} />
|
||||
<TooltipContent side="right">{t(label)}</TooltipContent>
|
||||
<TooltipContent side="right" sideOffset={6} surface="theme" showArrow={false}>
|
||||
{t(label)}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
@@ -149,12 +162,16 @@ function NavigationGroup({
|
||||
children,
|
||||
compact,
|
||||
pathname,
|
||||
openGroup,
|
||||
onFlyoutChange,
|
||||
}: {
|
||||
label: string;
|
||||
icon: typeof AudioLinesIcon;
|
||||
children: Destination[];
|
||||
compact: boolean;
|
||||
pathname: string;
|
||||
openGroup: string | null;
|
||||
onFlyoutChange: FlyoutChange;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const active = children.some(([to]) => pathname === to || pathname.startsWith(to + '/'));
|
||||
@@ -165,38 +182,12 @@ function NavigationGroup({
|
||||
? 'dubbing-group'
|
||||
: label.slice(4);
|
||||
const [expanded, setExpanded] = useState(active);
|
||||
const [popupOpen, setPopupOpen] = useState(false);
|
||||
const popupOpen = openGroup === label;
|
||||
const setPopupOpen = (open: boolean) => onFlyoutChange(label, open);
|
||||
const triggerRef = useRef<HTMLButtonElement>(null);
|
||||
const pressPointer = useRef('');
|
||||
const popupRef = useRef<HTMLDivElement>(null);
|
||||
const openTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
const closeTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
const cancelOpen = () => {
|
||||
if (openTimer.current !== null) clearTimeout(openTimer.current);
|
||||
openTimer.current = null;
|
||||
};
|
||||
const cancelClose = () => {
|
||||
if (closeTimer.current !== null) clearTimeout(closeTimer.current);
|
||||
closeTimer.current = null;
|
||||
};
|
||||
const scheduleClose = () => {
|
||||
cancelClose();
|
||||
closeTimer.current = setTimeout(() => setPopupOpen(false), 240);
|
||||
};
|
||||
const id = useId();
|
||||
useEffect(
|
||||
() => () => {
|
||||
cancelOpen();
|
||||
cancelClose();
|
||||
},
|
||||
[],
|
||||
);
|
||||
useEffect(() => {
|
||||
cancelOpen();
|
||||
cancelClose();
|
||||
setExpanded(active);
|
||||
setPopupOpen(false);
|
||||
}, [pathname, active]);
|
||||
useEffect(() => setExpanded(active), [pathname, active]);
|
||||
const triggerClass = cn(
|
||||
itemClass,
|
||||
'w-full',
|
||||
@@ -206,47 +197,27 @@ function NavigationGroup({
|
||||
);
|
||||
if (compact)
|
||||
return (
|
||||
<Popover
|
||||
open={popupOpen}
|
||||
onOpenChange={(open) => {
|
||||
cancelOpen();
|
||||
cancelClose();
|
||||
setPopupOpen(open);
|
||||
}}
|
||||
>
|
||||
<Popover open={popupOpen} onOpenChange={setPopupOpen}>
|
||||
<PopoverTrigger
|
||||
ref={triggerRef}
|
||||
aria-label={t(label)}
|
||||
data-active={active}
|
||||
className={triggerClass}
|
||||
data-rail-group=""
|
||||
openOnHover
|
||||
delay={140}
|
||||
closeDelay={140}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key !== 'ArrowRight' && event.key !== 'ArrowDown') return;
|
||||
event.preventDefault();
|
||||
cancelOpen();
|
||||
setPopupOpen(true);
|
||||
requestAnimationFrame(() => popupRef.current?.querySelector('a')?.focus());
|
||||
}}
|
||||
onPointerEnter={(event) => {
|
||||
if (event.pointerType !== 'mouse') return;
|
||||
cancelClose();
|
||||
if (!popupOpen) {
|
||||
cancelOpen();
|
||||
openTimer.current = setTimeout(() => setPopupOpen(true), 90);
|
||||
}
|
||||
}}
|
||||
onPointerLeave={(event) => {
|
||||
if (event.pointerType === 'mouse') {
|
||||
cancelOpen();
|
||||
if (popupOpen) scheduleClose();
|
||||
}
|
||||
}}
|
||||
onPointerDownCapture={(event) => {
|
||||
pressPointer.current = event.pointerType;
|
||||
}}
|
||||
onClickCapture={(event) => {
|
||||
// A press on an already hover-open trigger should keep the flyout
|
||||
// available. Keyboard and touch presses retain Base UI's toggle.
|
||||
if (popupOpen && event.detail > 0 && pressPointer.current === 'mouse') event.stopPropagation();
|
||||
requestAnimationFrame(() => {
|
||||
const popup = popupRef.current;
|
||||
(
|
||||
popup?.querySelector<HTMLAnchorElement>('a[aria-current="page"]') ??
|
||||
popup?.querySelector('a')
|
||||
)?.focus();
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Icon
|
||||
@@ -259,22 +230,31 @@ function NavigationGroup({
|
||||
<PopoverContent
|
||||
ref={popupRef}
|
||||
side="right"
|
||||
sideOffset={0}
|
||||
className="w-52 p-1.5 data-open:zoom-in-100 data-closed:zoom-out-100"
|
||||
onPointerEnter={cancelClose}
|
||||
onPointerLeave={(event) => {
|
||||
if (event.pointerType === 'mouse') scheduleClose();
|
||||
}}
|
||||
aria-label={t(label)}
|
||||
sideOffset={8}
|
||||
className={cn(flyoutClass, 'w-44')}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
||||
const links = Array.from(event.currentTarget.querySelectorAll('a'));
|
||||
if (!links.length) return;
|
||||
const current = links.indexOf(document.activeElement as HTMLAnchorElement);
|
||||
const next =
|
||||
event.key === 'ArrowDown'
|
||||
? current + 1
|
||||
: current < 0
|
||||
? links.length - 1
|
||||
: current - 1;
|
||||
links[(next + links.length) % links.length].focus();
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (event.key !== 'ArrowLeft') return;
|
||||
event.preventDefault();
|
||||
setPopupOpen(false);
|
||||
triggerRef.current?.focus();
|
||||
}}
|
||||
>
|
||||
<div className="px-3 pb-1 pt-1.5 text-xs font-medium text-muted-foreground">
|
||||
{t(label)}
|
||||
</div>
|
||||
<div className={flyoutHeading}>{t(label)}</div>
|
||||
<div>
|
||||
{children.map((destination) => (
|
||||
<NavigationLink
|
||||
@@ -334,26 +314,112 @@ function NavigationGroup({
|
||||
);
|
||||
}
|
||||
|
||||
function WorkspaceShortcuts({
|
||||
pathname,
|
||||
open,
|
||||
onFlyoutChange,
|
||||
}: {
|
||||
pathname: string;
|
||||
open: boolean;
|
||||
onFlyoutChange: FlyoutChange;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const { pinnedWorkspaces } = useWorkspace();
|
||||
const setOpen = (next: boolean) => onFlyoutChange('nav.more_workspaces', next);
|
||||
const pinned = laterDestinations.filter(([to]) => pinnedWorkspaces.includes(to));
|
||||
const currentInMenu = laterDestinations.some(
|
||||
([to]) => !pinnedWorkspaces.includes(to) && (pathname === to || pathname.startsWith(to + '/')),
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
{pinned.map((destination) => (
|
||||
<NavigationLink key={destination[0]} destination={destination} compact />
|
||||
))}
|
||||
<Popover open={open} onOpenChange={setOpen}>
|
||||
<PopoverTrigger
|
||||
aria-label={t('nav.more_workspaces')}
|
||||
title={t('nav.more_workspaces')}
|
||||
aria-current={currentInMenu ? 'location' : undefined}
|
||||
data-active={currentInMenu}
|
||||
className={cn(itemClass, 'justify-center')}
|
||||
>
|
||||
<EllipsisIcon aria-hidden="true" className={iconClass} />
|
||||
</PopoverTrigger>
|
||||
<PopoverContent
|
||||
side="right"
|
||||
sideOffset={8}
|
||||
aria-label={t('nav.more_workspaces')}
|
||||
className={cn(flyoutClass, 'w-56')}
|
||||
>
|
||||
<div className={flyoutHeading}>{t('nav.workspaces')}</div>
|
||||
{laterDestinations.map((destination) => {
|
||||
const [to, label] = destination;
|
||||
const selected = pinnedWorkspaces.includes(to);
|
||||
const pinLabel = t('nav.pin_workspace', { name: t(label) });
|
||||
return (
|
||||
<div key={to} className="grid grid-cols-[minmax(0,1fr)_auto] items-center gap-1">
|
||||
<NavigationLink
|
||||
destination={destination}
|
||||
flyout
|
||||
onCurrentRoute={() => setOpen(false)}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={pinLabel}
|
||||
title={pinLabel}
|
||||
aria-pressed={selected}
|
||||
className="grid size-8 place-items-center rounded-lg text-muted-foreground hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring aria-pressed:bg-muted aria-pressed:text-primary"
|
||||
onClick={() =>
|
||||
setWorkspace({
|
||||
pinnedWorkspaces: selected
|
||||
? pinnedWorkspaces.filter((route) => route !== to)
|
||||
: [...pinnedWorkspaces, to],
|
||||
})
|
||||
}
|
||||
>
|
||||
<PinIcon
|
||||
aria-hidden="true"
|
||||
className={cn('size-3.5', selected && 'fill-current')}
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function WorkspaceNavigation({ compact = false }: { compact?: boolean }) {
|
||||
const { t } = useTranslation();
|
||||
const pathname = useRouterState({
|
||||
select: (state) => state.location.pathname,
|
||||
});
|
||||
const [openGroup, setOpenGroup] = useState<string | null>(null);
|
||||
const changeFlyout: FlyoutChange = (group, open) => {
|
||||
setOpenGroup((current) => (open ? group : current === group ? null : current));
|
||||
};
|
||||
useEffect(() => setOpenGroup(null), [pathname, compact]);
|
||||
return (
|
||||
<nav
|
||||
data-slot="workspace-navigation"
|
||||
aria-label={t('nav.workspaces')}
|
||||
className={cn(
|
||||
'min-h-0 overflow-y-auto overscroll-contain py-2 [scrollbar-width:none]',
|
||||
compact ? 'space-y-0.5 px-1.5' : 'shrink-0 space-y-0.5 px-3',
|
||||
compact ? 'flex flex-col items-center gap-1 px-1' : 'shrink-0 space-y-0.5 px-3',
|
||||
)}
|
||||
>
|
||||
{compact && <NavigationLink compact destination={['/', 'nav.home', HouseIcon]} />}
|
||||
<NavigationGroup
|
||||
label="nav.voice"
|
||||
icon={FingerprintIcon}
|
||||
children={voiceDestinations}
|
||||
compact={compact}
|
||||
pathname={pathname}
|
||||
openGroup={openGroup}
|
||||
onFlyoutChange={changeFlyout}
|
||||
/>
|
||||
<NavigationGroup
|
||||
label="nav.stories"
|
||||
@@ -361,6 +427,8 @@ export function WorkspaceNavigation({ compact = false }: { compact?: boolean })
|
||||
children={storyDestinations}
|
||||
compact={compact}
|
||||
pathname={pathname}
|
||||
openGroup={openGroup}
|
||||
onFlyoutChange={changeFlyout}
|
||||
/>
|
||||
<NavigationGroup
|
||||
label="nav.dub"
|
||||
@@ -368,10 +436,21 @@ export function WorkspaceNavigation({ compact = false }: { compact?: boolean })
|
||||
children={dubDestinations}
|
||||
compact={compact}
|
||||
pathname={pathname}
|
||||
openGroup={openGroup}
|
||||
onFlyoutChange={changeFlyout}
|
||||
/>
|
||||
{laterDestinations.map((destination) => (
|
||||
<NavigationLink key={destination[0]} destination={destination} compact={compact} />
|
||||
))}
|
||||
{compact && <div aria-hidden="true" className="my-1 h-px w-5 shrink-0 bg-sidebar-border" />}
|
||||
{compact ? (
|
||||
<WorkspaceShortcuts
|
||||
pathname={pathname}
|
||||
open={openGroup === 'nav.more_workspaces'}
|
||||
onFlyoutChange={changeFlyout}
|
||||
/>
|
||||
) : (
|
||||
laterDestinations.map((destination) => (
|
||||
<NavigationLink key={destination[0]} destination={destination} />
|
||||
))
|
||||
)}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
@@ -69,7 +69,7 @@ describe('expanded sidebar', () => {
|
||||
expect(versionTranslationKey(false)).toBe('app.version');
|
||||
const link = screen.getByRole('link', { name: /app\.name app\.version/ });
|
||||
expect(link.getAttribute('href')).toBe('/');
|
||||
expect(link.getAttribute('aria-label')).toContain('@7.1.0');
|
||||
expect(link).toHaveAccessibleName(/@7\.1\.0/);
|
||||
});
|
||||
|
||||
it('closes through the header control', () => {
|
||||
@@ -95,7 +95,7 @@ describe('icon rail', () => {
|
||||
it('opens on a double click only', () => {
|
||||
show({ compact: true });
|
||||
const rail = document.querySelector('[data-slot="compact-main-sidebar"]')!;
|
||||
expect(rail.getAttribute('aria-label')).toBe('clone.saved_profiles');
|
||||
expect(rail.getAttribute('aria-label')).toBe('app.name');
|
||||
fireEvent.click(rail);
|
||||
expect(host.open).not.toHaveBeenCalled();
|
||||
fireEvent.doubleClick(rail);
|
||||
|
||||
@@ -55,7 +55,7 @@ export function WorkspaceSidebar() {
|
||||
<>
|
||||
{compact && (
|
||||
<aside
|
||||
aria-label={t('clone.saved_profiles')}
|
||||
aria-label={t('app.name')}
|
||||
data-slot="compact-main-sidebar"
|
||||
onPointerDownCapture={(event) => {
|
||||
railPointer.current = event.pointerType;
|
||||
@@ -139,14 +139,13 @@ export function WorkspaceSidebar() {
|
||||
>
|
||||
<Link
|
||||
to="/"
|
||||
aria-label={`${t('app.name')} ${versionLabel}`}
|
||||
className="flex min-w-0 flex-1 items-center gap-2 rounded outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
||||
>
|
||||
<img src={brandIcon} alt="" className="size-6 shrink-0" />
|
||||
<span className="flex min-w-0 flex-col leading-tight">
|
||||
<span className="truncate text-[15px] font-semibold tracking-tight">
|
||||
{t('app.name')}
|
||||
</span>
|
||||
</span>{' '}
|
||||
<span className="mt-0.5 truncate text-[11px] leading-none text-muted-foreground tabular-nums">
|
||||
{versionLabel}
|
||||
</span>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
|
||||
import { act, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
|
||||
import { QueryClient, QueryClientProvider, onlineManager } from '@tanstack/react-query';
|
||||
import { beforeEach, expect, it, vi } from 'vitest';
|
||||
import i18n from '@/i18n';
|
||||
import i18n, * as locales from '@/i18n';
|
||||
import type { BackendStatus } from '../../../preload/index.d';
|
||||
import { BackendGate, delimitedDiagnostic } from './backend-gate';
|
||||
|
||||
@@ -40,6 +40,7 @@ beforeEach(() => {
|
||||
backendStatus.stage = 'setup_required';
|
||||
backendStatus.elapsedMs = 0;
|
||||
backendStatus.logTail = [];
|
||||
backendStatus.runtimeInterrupted = true;
|
||||
delete backendStatus.message;
|
||||
delete backendStatus.diagnosis;
|
||||
delete backendStatus.setupIssue;
|
||||
@@ -875,7 +876,7 @@ it('labels the binary disk preflight units as GiB and a minimum rather than a do
|
||||
);
|
||||
});
|
||||
|
||||
it('names the app version and Beta channel in the setup header (setup screen info)', () => {
|
||||
it('opens the installed beta’s notes in setup before the runtime is available', async () => {
|
||||
render(
|
||||
<BackendGate>
|
||||
<div>workspace</div>
|
||||
@@ -884,30 +885,66 @@ it('names the app version and Beta channel in the setup header (setup screen inf
|
||||
const header = screen.getByRole('banner');
|
||||
expect(header).toHaveTextContent(i18n.t('app.version', { version: '0.5.8-beta.1' }));
|
||||
expect(header).toHaveTextContent(i18n.t('update.channel_beta'));
|
||||
const notes = screen.getByRole('link', { name: i18n.t('update.whats_new') });
|
||||
expect(notes).toHaveAttribute(
|
||||
'href',
|
||||
'https://github.com/debpalash/VoiceStudio/releases/tag/v0.5.8-beta.1',
|
||||
const notes = screen.getByRole('button', { name: i18n.t('update.whats_new') });
|
||||
fireEvent.click(notes);
|
||||
const dialog = await screen.findByRole('dialog', {
|
||||
name: i18n.t('updates.notes_for', { version: '0.5.8-beta.1' }),
|
||||
});
|
||||
await waitFor(() =>
|
||||
expect(dialog).toHaveTextContent('AMD and Intel GPUs now speed up OmniVoice'),
|
||||
);
|
||||
expect(dialog).not.toHaveTextContent('ElevenLabs-compatible API: point apps');
|
||||
fireEvent.click(screen.getByRole('button', { name: i18n.t('common.close') }));
|
||||
await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull());
|
||||
});
|
||||
|
||||
it('offers help links before anything fails, and names the remote option plainly', () => {
|
||||
it('places the release information in the scrolling content immediately before the welcome banner', () => {
|
||||
backendStatus.runtimeInterrupted = false;
|
||||
render(
|
||||
<BackendGate>
|
||||
<div>workspace</div>
|
||||
</BackendGate>,
|
||||
);
|
||||
renderGate('setup_required');
|
||||
const version = screen.getByTestId('setup-version');
|
||||
const notes = screen.getByRole('button', { name: i18n.t('update.whats_new') });
|
||||
const hero = screen.getByRole('heading', { name: i18n.t('setup.welcome_title') });
|
||||
const row = version.parentElement!;
|
||||
expect(screen.getByTestId('backend-gate-scroll')).toContainElement(row);
|
||||
expect(row).toHaveTextContent(i18n.t('update.channel_beta'));
|
||||
expect(row).toContainElement(notes);
|
||||
expect(row.nextElementSibling).toContainElement(hero);
|
||||
});
|
||||
|
||||
it('offers help links before opening either install option', () => {
|
||||
backendStatus.runtimeInterrupted = false;
|
||||
renderGate('setup_required');
|
||||
const help = screen.getByTestId('setup-help-links');
|
||||
const actions = help.querySelectorAll('a, button');
|
||||
expect(actions).toHaveLength(4);
|
||||
const footer = screen.getByRole('contentinfo');
|
||||
const discord = within(footer).getByRole('link', { name: i18n.t('setupHelp.discord') });
|
||||
expect(discord.querySelector('img')).toHaveAttribute(
|
||||
'src',
|
||||
expect.stringContaining('social/discord.svg'),
|
||||
);
|
||||
expect(screen.getByTestId('backend-gate-scroll')).not.toContainElement(footer);
|
||||
const header = within(screen.getByRole('banner'));
|
||||
expect(header.getByRole('link', { name: i18n.t('setupHelp.discord_short') })).toHaveAttribute(
|
||||
'href',
|
||||
discord.getAttribute('href'),
|
||||
);
|
||||
expect(header.getByRole('link', { name: i18n.t('supportPlans.pro') })).toHaveAttribute(
|
||||
'href',
|
||||
'https://voicestudio.sh/pro',
|
||||
);
|
||||
expect(header.getByRole('link', { name: i18n.t('setupHelp.cloud') })).toHaveAttribute(
|
||||
'href',
|
||||
'https://app.voicestudio.sh',
|
||||
);
|
||||
for (const action of actions)
|
||||
expect(action.querySelector('svg[aria-hidden="true"]')).toBeTruthy();
|
||||
expect(help).toHaveTextContent(i18n.t('setup.help_install'));
|
||||
expect(help).toHaveTextContent(i18n.t('setup.help_troubleshooting'));
|
||||
expect(
|
||||
screen.getByRole('link', { name: new RegExp(i18n.t('setup.help_install')) }),
|
||||
).toHaveAttribute('href', expect.stringContaining('docs/install/linux.md'));
|
||||
openPanel('setup.options');
|
||||
expect(
|
||||
screen.getByRole('button', { name: i18n.t('setup.use_other_computer') }),
|
||||
).toBeInTheDocument();
|
||||
expect(screen.queryByRole('textbox', { name: i18n.t('settings.remote_backend_url') })).toBeNull();
|
||||
backendStatus.runtimeInterrupted = true;
|
||||
});
|
||||
|
||||
@@ -957,13 +994,6 @@ it('offers a newer app before the runtime download', async () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('links development builds to the release list, not a tag of the same version', async () => {
|
||||
const { releaseNotesUrl } = await import('./setup-extras');
|
||||
expect(releaseNotesUrl('0.5.8-beta.1', false)).toMatch(/\/releases\/tag\/v0\.5\.8-beta\.1$/);
|
||||
expect(releaseNotesUrl('0.5.8-beta.1', true)).toMatch(/\/releases$/);
|
||||
expect(releaseNotesUrl('0.5.8-dev', false)).toMatch(/\/releases$/);
|
||||
});
|
||||
|
||||
it('keeps install help visible after a setup failure', () => {
|
||||
backendStatus.message = 'uv sync failed';
|
||||
backendStatus.runtimeInterrupted = false;
|
||||
@@ -998,6 +1028,57 @@ function updateBridge(snapshot: unknown, extra: Record<string, unknown> = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
it('opens the update drawer once per offered version and lets setup continue after closing it', async () => {
|
||||
const offer = {
|
||||
status: 'available',
|
||||
currentVersion: '0.5.8-beta.1',
|
||||
availableVersion: '0.5.8-beta.2',
|
||||
progress: 0,
|
||||
};
|
||||
const bridge = updateBridge(offer);
|
||||
renderGate('setup_required');
|
||||
await act(async () => bridge.resolveSnapshot());
|
||||
const title = i18n.t('update.prompt_available', { version: offer.availableVersion });
|
||||
expect(await screen.findByRole('dialog', { name: title })).toBeVisible();
|
||||
fireEvent.click(screen.getByRole('button', { name: i18n.t('common.close') }));
|
||||
await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull());
|
||||
await act(async () => bridge.emit({ ...offer, status: 'downloading', progress: 5 }));
|
||||
expect(screen.queryByRole('dialog')).toBeNull();
|
||||
fireEvent.click(screen.getByRole('button', { name: i18n.t('update.downloading', { pct: 5 }) }));
|
||||
expect(await screen.findByRole('progressbar')).toHaveAttribute('aria-valuenow', '5');
|
||||
});
|
||||
|
||||
it('keeps the update in a bottom bar while using other setup controls', async () => {
|
||||
backendStatus.runtimeInterrupted = false;
|
||||
const bridge = updateBridge({
|
||||
status: 'available',
|
||||
currentVersion: '0.5.8-beta.1',
|
||||
availableVersion: '0.5.8-beta.2',
|
||||
progress: 0,
|
||||
});
|
||||
renderGate('setup_required');
|
||||
const install = screen.getByRole('button', { name: i18n.t('modelMaintenance.install') });
|
||||
install.focus();
|
||||
await act(async () => bridge.resolveSnapshot());
|
||||
const title = i18n.t('update.prompt_available', { version: '0.5.8-beta.2' });
|
||||
expect(await screen.findByRole('dialog', { name: title })).toBeVisible();
|
||||
expect(install).toHaveFocus();
|
||||
const notes = screen.getByRole('button', { name: i18n.t('update.whats_new') });
|
||||
fireEvent.mouseDown(notes);
|
||||
fireEvent.mouseUp(notes);
|
||||
fireEvent.click(notes);
|
||||
const releaseDialog = await screen.findByRole('dialog', {
|
||||
name: i18n.t('updates.notes_for', { version: '0.5.8-beta.1' }),
|
||||
});
|
||||
expect(releaseDialog).toBeVisible();
|
||||
const dock = await screen.findByTestId('update-dock');
|
||||
expect(dock).toHaveTextContent(title);
|
||||
fireEvent.click(within(releaseDialog).getByRole('button', { name: i18n.t('common.close') }));
|
||||
await waitFor(() => expect(releaseDialog).not.toBeInTheDocument());
|
||||
fireEvent.click(dock);
|
||||
expect(await screen.findByRole('dialog', { name: title })).toBeVisible();
|
||||
});
|
||||
|
||||
it('a failed update download keeps the notice with Retry', async () => {
|
||||
const bridge = updateBridge({
|
||||
status: 'error',
|
||||
@@ -1080,41 +1161,98 @@ it('shows no hardware line when none was detected', () => {
|
||||
expect(screen.queryByTestId('setup-hardware')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('leads with the essentials and keeps every option collapsed by default', () => {
|
||||
it('shows the install action, region and Python on first launch, and opens remote settings from Install', async () => {
|
||||
backendStatus.runtimeInterrupted = false;
|
||||
backendStatus.runtimeFreeGib = 120;
|
||||
try {
|
||||
renderGate('setup_required');
|
||||
expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent(
|
||||
i18n.t('backend.setup_required'),
|
||||
i18n.t('setup.welcome_title'),
|
||||
);
|
||||
expect(screen.getByRole('button', { name: i18n.t('backend.setup_required') })).toBeEnabled();
|
||||
const install = screen.getByRole('button', { name: i18n.t('modelMaintenance.install') });
|
||||
expect(install).toBeEnabled();
|
||||
expect(screen.getByTestId('setup-help-links').parentElement).toContainElement(install);
|
||||
const runtimeSection = screen
|
||||
.getByRole('heading', {
|
||||
name: i18n.t('settings.python_runtime_title'),
|
||||
})
|
||||
.closest('section');
|
||||
expect(runtimeSection).toContainElement(
|
||||
screen.getByRole('region', { name: i18n.t('firstrun.env_dir') }),
|
||||
);
|
||||
expect(runtimeSection).toContainElement(screen.getByTestId('python-runtime-quick-search'));
|
||||
expect(screen.getByTestId('setup-free-space')).toBeVisible();
|
||||
const toggle = screen.getByRole('button', { name: i18n.t('setup.options') });
|
||||
expect(toggle).toHaveAttribute('aria-expanded', 'false');
|
||||
for (const name of ['settings.language', 'firstrun.region_label']) {
|
||||
expect(screen.queryByRole('combobox', { name: i18n.t(name) })).not.toBeInTheDocument();
|
||||
}
|
||||
expect(screen.queryByTestId('python-runtime-quick-search')).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole('button', { name: i18n.t('setup.options') })).toBeNull();
|
||||
expect(screen.getByRole('button', { name: i18n.t('settings.language') })).toBeVisible();
|
||||
expect(screen.getByRole('button', { name: i18n.t('firstrun.region_label') })).toBeVisible();
|
||||
expect(screen.getByTestId('python-runtime-quick-search')).toBeVisible();
|
||||
expect(
|
||||
screen.queryByRole('button', { name: i18n.t('setup.use_other_computer') }),
|
||||
).not.toBeInTheDocument();
|
||||
// A fresh install has nothing to recover from: no recovery disclosure or actions.
|
||||
screen.queryByRole('textbox', { name: i18n.t('settings.remote_backend_url') }),
|
||||
).toBeNull();
|
||||
fireEvent.click(install);
|
||||
fireEvent.click(
|
||||
await screen.findByRole('menuitem', { name: i18n.t('setup.configure_remote') }),
|
||||
);
|
||||
expect(
|
||||
await screen.findByRole('dialog', { name: i18n.t('settings.remote_backend_title') }),
|
||||
).toBeVisible();
|
||||
expect(
|
||||
screen.getByRole('textbox', { name: i18n.t('settings.remote_backend_url') }),
|
||||
).toBeVisible();
|
||||
expect(
|
||||
screen.getByLabelText(i18n.t('settings.remote_backend_key'), { selector: 'input' }),
|
||||
).toBeVisible();
|
||||
expect(screen.queryByRole('button', { name: i18n.t('setup.more_fixes') })).toBeNull();
|
||||
expect(screen.queryByRole('button', { name: i18n.t('bootstrap.clean_retry') })).toBeNull();
|
||||
|
||||
fireEvent.click(toggle);
|
||||
expect(toggle).toHaveAttribute('aria-expanded', 'true');
|
||||
expect(toggle).toHaveAttribute('aria-controls', 'setup-panel-options');
|
||||
expect(document.getElementById('setup-panel-options')).toBeInTheDocument();
|
||||
expect(screen.getByRole('combobox', { name: i18n.t('settings.language') })).toBeVisible();
|
||||
expect(screen.getByRole('combobox', { name: i18n.t('firstrun.region_label') })).toBeVisible();
|
||||
expect(screen.getByTestId('python-runtime-quick-search')).toBeVisible();
|
||||
} finally {
|
||||
backendStatus.runtimeInterrupted = true;
|
||||
}
|
||||
});
|
||||
|
||||
it('shows flags on the selected language and country-specific region choices', async () => {
|
||||
backendStatus.runtimeInterrupted = false;
|
||||
renderGate('setup_required');
|
||||
const language = screen.getByRole('button', { name: i18n.t('settings.language') });
|
||||
expect(language.querySelector('svg[data-language-flag="en"]')).toBeInTheDocument();
|
||||
fireEvent.click(language);
|
||||
const languages = screen.getAllByRole('option');
|
||||
expect(languages).toHaveLength(22);
|
||||
for (const option of languages)
|
||||
expect(option.querySelector('svg[data-language-flag]')).toBeInTheDocument();
|
||||
fireEvent.click(language);
|
||||
const region = screen.getByRole('button', { name: i18n.t('firstrun.region_label') });
|
||||
fireEvent.click(region);
|
||||
for (const code of ['china', 'russia']) {
|
||||
const option = screen.getByRole('option', { name: i18n.t(`bootstrap.region_${code}`) });
|
||||
expect(option.querySelector('svg')).toHaveAttribute('aria-hidden', 'true');
|
||||
}
|
||||
});
|
||||
|
||||
it('starts runtime setup from the footer without granting reporting consent', async () => {
|
||||
backendStatus.runtimeInterrupted = false;
|
||||
const setupRuntime = vi.fn().mockResolvedValue(undefined);
|
||||
const setConsent = vi.fn();
|
||||
bridgeStub.current = {
|
||||
backend: { setupRuntime, getConnection: async () => ({ remote: false }) },
|
||||
diagnostics: {
|
||||
getStatus: async () => ({
|
||||
enabled: false,
|
||||
available: true,
|
||||
opted_in: false,
|
||||
prompted: false,
|
||||
}),
|
||||
setConsent,
|
||||
},
|
||||
};
|
||||
renderGate('setup_required');
|
||||
expect(await screen.findByRole('switch', { name: i18n.t('diagnostics.title') })).toBeChecked();
|
||||
fireEvent.click(screen.getByRole('button', { name: i18n.t('modelMaintenance.install') }));
|
||||
expect(setupRuntime).not.toHaveBeenCalled();
|
||||
fireEvent.click(await screen.findByRole('menuitem', { name: i18n.t('backend.setup_required') }));
|
||||
await waitFor(() => expect(setupRuntime).toHaveBeenCalledOnce());
|
||||
expect(setConsent).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('offers each help destination once, swapping in the prefilled report after a failure', () => {
|
||||
backendStatus.message = 'uv sync failed';
|
||||
backendStatus.runtimeInterrupted = false;
|
||||
@@ -1127,7 +1265,6 @@ it('offers each help destination once, swapping in the prefilled report after a
|
||||
i18n.t('setup.help_install'),
|
||||
i18n.t('setup.help_troubleshooting'),
|
||||
i18n.t('reportBug.label'),
|
||||
i18n.t('setupHelp.discord'),
|
||||
]);
|
||||
expect(screen.getAllByRole('link', { name: i18n.t('setupHelp.discord') })).toHaveLength(1);
|
||||
expect(screen.getAllByRole('button', { name: i18n.t('setupHelp.download_log') })).toHaveLength(
|
||||
@@ -1220,9 +1357,9 @@ it('keeps an in-flight interpreter check and its result across closing and reope
|
||||
});
|
||||
|
||||
it('offers independent diagnostic consent before setup and keeps the choice through failures', async () => {
|
||||
const setConsent = vi.fn(async () => ({
|
||||
enabled: false,
|
||||
opted_in: false,
|
||||
const setConsent = vi.fn(async (enabled: boolean) => ({
|
||||
enabled,
|
||||
opted_in: enabled,
|
||||
available: true,
|
||||
prompted: true,
|
||||
}));
|
||||
@@ -1250,7 +1387,7 @@ it('offers independent diagnostic consent before setup and keeps the choice thro
|
||||
);
|
||||
try {
|
||||
const view = render(tree);
|
||||
expect(await screen.findByRole('button', { name: i18n.t('diagnostics.allow') })).toBeEnabled();
|
||||
expect(await screen.findByRole('switch', { name: i18n.t('diagnostics.title') })).toBeEnabled();
|
||||
for (const stage of ['installing', 'crashed'] as const) {
|
||||
backendStatus.stage = stage;
|
||||
view.rerender(
|
||||
@@ -1259,19 +1396,53 @@ it('offers independent diagnostic consent before setup and keeps the choice thro
|
||||
</BackendGate>,
|
||||
);
|
||||
expect(
|
||||
await screen.findByRole('button', { name: i18n.t('diagnostics.allow') }),
|
||||
await screen.findByRole('switch', { name: i18n.t('diagnostics.title') }),
|
||||
).toBeEnabled();
|
||||
}
|
||||
expect(setConsent).not.toHaveBeenCalled();
|
||||
fireEvent.click(screen.getByRole('button', { name: i18n.t('diagnostics.keep_off') }));
|
||||
const toggle = screen.getByRole('switch', { name: i18n.t('diagnostics.title') });
|
||||
fireEvent.click(toggle);
|
||||
await waitFor(() => expect(toggle).toBeChecked());
|
||||
fireEvent.click(toggle);
|
||||
await waitFor(() => expect(setConsent).toHaveBeenCalledWith(false));
|
||||
await waitFor(() =>
|
||||
expect(
|
||||
screen.queryByRole('button', { name: i18n.t('diagnostics.allow') }),
|
||||
).not.toBeInTheDocument(),
|
||||
);
|
||||
expect(screen.getByRole('switch', { name: i18n.t('diagnostics.title') })).not.toBeChecked();
|
||||
await waitFor(() => expect(toggle).not.toBeChecked());
|
||||
} finally {
|
||||
localStorage.removeItem('voicestudio.setup.analytics-consent.v1');
|
||||
}
|
||||
});
|
||||
|
||||
it('shows a retryable region save failure and clears it on success', async () => {
|
||||
backendStatus.runtimeInterrupted = false;
|
||||
const setRuntimeRegion = vi.fn().mockRejectedValueOnce(new Error('disk')).mockResolvedValue('china');
|
||||
bridgeStub.current = { backend: { setRuntimeRegion, getConnection: async () => ({ remote: false }) } };
|
||||
renderGate('setup_required');
|
||||
const choose = () => {
|
||||
fireEvent.click(screen.getByRole('button', { name: i18n.t('firstrun.region_label') }));
|
||||
fireEvent.click(screen.getByRole('option', { name: i18n.t('bootstrap.region_china') }));
|
||||
};
|
||||
choose();
|
||||
const message = await screen.findByText(i18n.t('settings.save_failed'));
|
||||
expect(message).toBeVisible();
|
||||
choose();
|
||||
await waitFor(() => expect(message).not.toBeInTheDocument());
|
||||
expect(setRuntimeRegion).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('reports a language load failure and clears it on a successful choice', async () => {
|
||||
backendStatus.runtimeInterrupted = false;
|
||||
const change = vi.spyOn(locales, 'setAppLanguage').mockResolvedValueOnce(false).mockResolvedValue(true);
|
||||
try {
|
||||
renderGate('setup_required');
|
||||
const choose = () => {
|
||||
fireEvent.click(screen.getByRole('button', { name: i18n.t('settings.language') }));
|
||||
fireEvent.click(screen.getByRole('option', { name: /Deutsch/i }));
|
||||
};
|
||||
choose();
|
||||
const message = await screen.findByText(i18n.t('settings.save_failed'));
|
||||
choose();
|
||||
await waitFor(() => expect(message).not.toBeInTheDocument());
|
||||
expect(change).toHaveBeenCalledTimes(2);
|
||||
} finally {
|
||||
change.mockRestore();
|
||||
}
|
||||
});
|
||||
@@ -1,8 +1,9 @@
|
||||
import { useVisibleInterval } from '@/lib/visible-interval';
|
||||
import { SetupGate } from './setup-gate';
|
||||
import { SetupInstallMenu } from './setup-install-menu';
|
||||
import { SetupProgressCard } from './setup-progress-card';
|
||||
import { ReportBug } from './report-bug';
|
||||
import { SetupAnalyticsConsent } from './analytics-consent';
|
||||
import { confirmSetupAnalytics, SetupAnalyticsConsent } from './analytics-consent';
|
||||
import { DiagnosticConsent } from './diagnostic-consent';
|
||||
import {
|
||||
SetupConnectionCheck,
|
||||
@@ -13,7 +14,7 @@ import {
|
||||
setupNeedsHelp,
|
||||
setupStalled,
|
||||
} from './setup-support';
|
||||
import { SetupLocation, SetupOptions } from './setup-options';
|
||||
import { SetupLocaleRows, SetupLocation, SetupOptions } from './setup-options';
|
||||
import { CrashDetails } from './crash-details';
|
||||
import {
|
||||
BackendOfflineBar,
|
||||
@@ -50,11 +51,16 @@ import {
|
||||
failureGuidance,
|
||||
} from '@shared/utils/installFailure';
|
||||
import { scrubText } from '@shared/utils/scrub';
|
||||
import { brandIcon } from '@/lib/brand';
|
||||
import { brandArtwork, brandIcon, studioCat } from '@/lib/brand';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { getBridge, isMac } from './bridge';
|
||||
import { ExternalLink } from './external-link';
|
||||
import { SetupHelpLinks, SetupUpdateNotice, SetupVersion } from './setup-extras';
|
||||
import {
|
||||
SetupCommunityFooter,
|
||||
SetupHeaderLinks,
|
||||
SetupHelpLinks,
|
||||
SetupVersion,
|
||||
} from './setup-extras';
|
||||
|
||||
interface BackendGateProps {
|
||||
children: ReactNode;
|
||||
@@ -64,6 +70,10 @@ interface BackendGateProps {
|
||||
const RELEASES_URL = 'https://github.com/debpalash/VoiceStudio/releases/latest';
|
||||
const RETRYABLE = new Set(['crashed', 'failed', 'port_in_use']);
|
||||
|
||||
// Size the columns to the space in the setup pane, including at larger UI scales.
|
||||
const welcomeColumns =
|
||||
'grid grid-cols-[repeat(auto-fit,minmax(min(100%,16.5rem),1fr))] items-start gap-3 sm:gap-4';
|
||||
|
||||
type SetupPanel = 'options' | 'troubleshoot';
|
||||
|
||||
/** A disclosure button for the setup screen's Options and Troubleshoot panels. */
|
||||
@@ -275,6 +285,7 @@ export function BackendGate({ children, repairDock }: BackendGateProps) {
|
||||
const runSetup = async (clean = false) => {
|
||||
setRestarting(true);
|
||||
try {
|
||||
if (setup) confirmSetupAnalytics(status.analyticsDisabled);
|
||||
if (clean) await getBridge()?.backend.cleanSetupRuntime();
|
||||
else await getBridge()?.backend.setupRuntime();
|
||||
} catch {
|
||||
@@ -296,6 +307,14 @@ export function BackendGate({ children, repairDock }: BackendGateProps) {
|
||||
};
|
||||
|
||||
const setupBlocked = unsupportedPlatform || wrongArchitecture;
|
||||
const welcome =
|
||||
setup &&
|
||||
!setupFailed &&
|
||||
!setupBlocked &&
|
||||
!status.runtimeInterrupted &&
|
||||
!status.setupIssue &&
|
||||
!status.failure &&
|
||||
!status.smartAppControlWarning;
|
||||
const setupBusy = restarting || choosingLocation || installStuck;
|
||||
const needsHelp = setupNeedsHelp(status);
|
||||
// A full drive or an unwritable folder is fixed by moving the app-managed
|
||||
@@ -326,6 +345,17 @@ export function BackendGate({ children, repairDock }: BackendGateProps) {
|
||||
setPanel((open) => (open === next ? null : next));
|
||||
};
|
||||
|
||||
const runtimeLocation = setup && !unsupportedPlatform && (
|
||||
<SetupLocation
|
||||
status={status}
|
||||
disabled={setupBusy}
|
||||
compact={welcome}
|
||||
showChange={!setupFolderFix}
|
||||
onChange={() => void chooseSetupFolder()}
|
||||
/>
|
||||
);
|
||||
|
||||
const showSetupLinks = setup || installing || failed;
|
||||
const gate = (
|
||||
<div
|
||||
className={cn(
|
||||
@@ -335,143 +365,179 @@ export function BackendGate({ children, repairDock }: BackendGateProps) {
|
||||
>
|
||||
<header
|
||||
className={cn(
|
||||
'workspace-titlebar flex shrink-0 items-center gap-2 px-5',
|
||||
isMac() && 'pl-24',
|
||||
'workspace-titlebar setup-window-header @container shrink-0 px-4',
|
||||
isMac() ? 'account-corner-safe pl-24' : 'native-controls-right',
|
||||
)}
|
||||
>
|
||||
<img src={brandIcon} alt="" className="size-6 shrink-0" />
|
||||
<span className="whitespace-nowrap text-sm font-medium tracking-tight">
|
||||
{t('app.name')}
|
||||
</span>
|
||||
<SetupVersion />
|
||||
<div className="flex min-h-[52px] min-w-0 flex-wrap items-center gap-x-2">
|
||||
<img src={brandIcon} alt="" className="size-6 shrink-0" />
|
||||
<span className="whitespace-nowrap text-sm font-medium tracking-tight @max-[14rem]:sr-only">
|
||||
{t('app.name')}
|
||||
</span>
|
||||
{!welcome && (
|
||||
<div className="min-w-0 @max-[28rem]:order-last @max-[28rem]:w-full @max-[28rem]:pb-1">
|
||||
<SetupVersion showUpdate={setup} />
|
||||
</div>
|
||||
)}
|
||||
{showSetupLinks && <SetupHeaderLinks />}
|
||||
</div>
|
||||
</header>
|
||||
<div
|
||||
data-testid="backend-gate-scroll"
|
||||
className="studio-scrollbar min-h-0 flex-1 overflow-y-auto"
|
||||
>
|
||||
<div className="mx-auto flex min-h-full w-full max-w-2xl flex-col justify-center gap-4 px-6 py-8">
|
||||
<div
|
||||
className={cn(
|
||||
'mx-auto flex min-h-full w-full flex-col gap-4 px-5 sm:px-7',
|
||||
welcome ? 'max-w-5xl pt-5 pb-8 sm:pt-8' : 'max-w-2xl justify-center py-6',
|
||||
)}
|
||||
>
|
||||
{welcome && <SetupVersion showUpdate={setup} />}
|
||||
{/* 1. Status: what is happening or what went wrong, in plain words. */}
|
||||
<div className="flex items-start gap-4">
|
||||
{setup || installing ? (
|
||||
{welcome ? (
|
||||
<div className="relative isolate overflow-hidden rounded-2xl border border-border/50 bg-[#0b0c12] text-white">
|
||||
<img
|
||||
src={brandArtwork}
|
||||
alt=""
|
||||
className="pointer-events-none absolute inset-y-0 end-0 -z-10 h-full w-[72%] object-cover object-right opacity-85 rtl:-scale-x-100"
|
||||
/>
|
||||
<div
|
||||
className="flex size-10 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary ring-1 ring-primary/20"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<DownloadIcon className="size-5" />
|
||||
className="absolute inset-0 -z-10 bg-linear-to-r from-[#0b0c12] via-[#0b0c12]/90 to-transparent rtl:bg-linear-to-l"
|
||||
/>
|
||||
<div className="flex items-center gap-4 px-5 py-5 sm:gap-6 sm:px-7 sm:py-6">
|
||||
<img src={studioCat} alt="" width={96} height={96} className="size-16 shrink-0 object-contain sm:size-24" />
|
||||
<div className="min-w-0">
|
||||
<h1 className="text-balance text-2xl font-semibold tracking-tight sm:text-3xl">
|
||||
{t('setup.welcome_title')}
|
||||
</h1>
|
||||
<p className="mt-2 max-w-[37ch] text-pretty text-sm leading-relaxed text-white/80">
|
||||
{t('setup.welcome_runtime')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
) : failed ? (
|
||||
<div
|
||||
className="flex size-10 shrink-0 items-center justify-center rounded-xl bg-destructive/10 text-destructive ring-1 ring-destructive/20"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<TriangleAlertIcon className="size-5" />
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex size-10 shrink-0 items-center justify-center">
|
||||
<Spinner className="size-7 text-primary" aria-label={t('common.loading')} />
|
||||
</div>
|
||||
)}
|
||||
<div className="min-w-0 flex-1 space-y-1.5">
|
||||
{!setup && !installing && (failed || running) ? (
|
||||
<BackendStatusPill state={pillState} seconds={seconds} repeats={repeats} />
|
||||
) : null}
|
||||
<h1
|
||||
className={cn(
|
||||
'text-2xl font-semibold tracking-[-0.025em] [overflow-wrap:anywhere]',
|
||||
failed && 'text-destructive',
|
||||
)}
|
||||
>
|
||||
{stageText}
|
||||
</h1>
|
||||
{problemText ? (
|
||||
<p
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex items-start gap-4">
|
||||
{setup || installing ? (
|
||||
<div
|
||||
className="flex size-10 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary ring-1 ring-primary/20"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<DownloadIcon className="size-5" />
|
||||
</div>
|
||||
) : failed ? (
|
||||
<div
|
||||
className="flex size-10 shrink-0 items-center justify-center rounded-xl bg-destructive/10 text-destructive ring-1 ring-destructive/20"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<TriangleAlertIcon className="size-5" />
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex size-10 shrink-0 items-center justify-center">
|
||||
<Spinner className="size-7 text-primary" aria-label={t('common.loading')} />
|
||||
</div>
|
||||
)}
|
||||
<div className="min-w-0 flex-1 space-y-1.5">
|
||||
{!setup && !installing && (failed || running) ? (
|
||||
<BackendStatusPill state={pillState} seconds={seconds} repeats={repeats} />
|
||||
) : null}
|
||||
<h1
|
||||
className={cn(
|
||||
'text-sm',
|
||||
setup ? 'font-medium text-destructive' : 'text-muted-foreground',
|
||||
'text-2xl font-semibold tracking-[-0.025em] [overflow-wrap:anywhere]',
|
||||
failed && 'text-destructive',
|
||||
)}
|
||||
>
|
||||
{problemText}
|
||||
</p>
|
||||
) : setup && !setupBlocked ? (
|
||||
<p className="text-sm leading-relaxed text-foreground/65">
|
||||
{t('backend.setup_hint')}
|
||||
</p>
|
||||
) : null}
|
||||
{wrongArchitecture ? (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{t('backend.setup_wrong_architecture')}
|
||||
</p>
|
||||
) : null}
|
||||
{unsupportedPlatform ? (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{t('backend.setup_unsupported_platform')}
|
||||
</p>
|
||||
) : null}
|
||||
{/* Only while the Python environment is actually being prepared (first
|
||||
{stageText}
|
||||
</h1>
|
||||
{problemText ? (
|
||||
<p
|
||||
className={cn(
|
||||
'text-sm',
|
||||
setup ? 'font-medium text-destructive' : 'text-muted-foreground',
|
||||
)}
|
||||
>
|
||||
{problemText}
|
||||
</p>
|
||||
) : setup && !setupBlocked ? (
|
||||
<p className="text-sm leading-relaxed text-foreground/65">
|
||||
{t('backend.setup_hint')}
|
||||
</p>
|
||||
) : null}
|
||||
{wrongArchitecture ? (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{t('backend.setup_wrong_architecture')}
|
||||
</p>
|
||||
) : null}
|
||||
{unsupportedPlatform ? (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{t('backend.setup_unsupported_platform')}
|
||||
</p>
|
||||
) : null}
|
||||
{/* Only while the Python environment is actually being prepared (first
|
||||
run or repair). Ordinary launches also pass through `starting` and
|
||||
`attaching`; the long-wait wording is false there (#4228). */}
|
||||
{installing ? (
|
||||
<p className="text-sm text-foreground/65">{t('backend.first_run_hint')}</p>
|
||||
) : null}
|
||||
{cause ? (
|
||||
<p className="text-sm font-medium" data-testid="backend-cause">
|
||||
{t(`backend.cause_${cause}`)}
|
||||
</p>
|
||||
) : null}
|
||||
{failureCode === 'RUNTIME_DOWNLOAD_INTERRUPTED' &&
|
||||
status.failure?.failedDownloadHost ? (
|
||||
// Name the host that failed, so a blocked github.com is not read
|
||||
// as a slow connection (#4502).
|
||||
<p className="text-sm text-muted-foreground" data-testid="backend-download-host">
|
||||
{t('backend.download_failed_host', { host: status.failure.failedDownloadHost })}
|
||||
</p>
|
||||
) : null}
|
||||
{guidance
|
||||
? guidance.hints.map((key) => (
|
||||
<p
|
||||
key={key}
|
||||
className="text-sm text-muted-foreground"
|
||||
data-testid="backend-hint"
|
||||
{installing ? (
|
||||
<p className="text-sm text-foreground/65">{t('backend.first_run_hint')}</p>
|
||||
) : null}
|
||||
{cause ? (
|
||||
<p className="text-sm font-medium" data-testid="backend-cause">
|
||||
{t(`backend.cause_${cause}`)}
|
||||
</p>
|
||||
) : null}
|
||||
{failureCode === 'RUNTIME_DOWNLOAD_INTERRUPTED' &&
|
||||
status.failure?.failedDownloadHost ? (
|
||||
// Name the host that failed, so a blocked github.com is not read
|
||||
// as a slow connection (#4502).
|
||||
<p className="text-sm text-muted-foreground" data-testid="backend-download-host">
|
||||
{t('backend.download_failed_host', { host: status.failure.failedDownloadHost })}
|
||||
</p>
|
||||
) : null}
|
||||
{guidance
|
||||
? guidance.hints.map((key) => (
|
||||
<p
|
||||
key={key}
|
||||
className="text-sm text-muted-foreground"
|
||||
data-testid="backend-hint"
|
||||
>
|
||||
{t(key)}
|
||||
</p>
|
||||
))
|
||||
: null}
|
||||
{setupConnectionError(status) ? (
|
||||
<p role="alert" className="text-sm text-muted-foreground">
|
||||
{t('setupHelp.connection_error')}
|
||||
</p>
|
||||
) : null}
|
||||
{failureCode && failureCode !== 'UNCLASSIFIED' ? (
|
||||
<p className="flex flex-wrap items-center gap-x-2 text-xs text-muted-foreground">
|
||||
<ExternalLink
|
||||
href={`${DEFAULT_DOCS}#${failureDocsAnchor(failureCode)}`}
|
||||
variant="link"
|
||||
showIcon={false}
|
||||
className="h-auto px-0 text-xs"
|
||||
>
|
||||
{t(key)}
|
||||
</p>
|
||||
))
|
||||
: null}
|
||||
{setupConnectionError(status) ? (
|
||||
<p role="alert" className="text-sm text-muted-foreground">
|
||||
{t('setupHelp.connection_error')}
|
||||
</p>
|
||||
) : null}
|
||||
{failureCode && failureCode !== 'UNCLASSIFIED' ? (
|
||||
<p className="flex flex-wrap items-center gap-x-2 text-xs text-muted-foreground">
|
||||
<ExternalLink
|
||||
href={`${DEFAULT_DOCS}#${failureDocsAnchor(failureCode)}`}
|
||||
variant="link"
|
||||
showIcon={false}
|
||||
className="h-auto px-0 text-xs"
|
||||
>
|
||||
{t('backend.fix_docs')}
|
||||
</ExternalLink>
|
||||
<code
|
||||
data-testid="backend-failure-code"
|
||||
className="rounded bg-muted/60 px-1.5 py-px font-mono text-[10px] text-muted-foreground"
|
||||
>
|
||||
{failureCode}
|
||||
</code>
|
||||
</p>
|
||||
) : null}
|
||||
{setup && status.smartAppControlWarning && !status.failure ? (
|
||||
<p className="text-sm text-warning" data-testid="setup-smart-app-control">
|
||||
{t('backend.setup_smart_app_control')}
|
||||
</p>
|
||||
) : null}
|
||||
{t('backend.fix_docs')}
|
||||
</ExternalLink>
|
||||
<code
|
||||
data-testid="backend-failure-code"
|
||||
className="rounded bg-muted/60 px-1.5 py-px font-mono text-[10px] text-muted-foreground"
|
||||
>
|
||||
{failureCode}
|
||||
</code>
|
||||
</p>
|
||||
) : null}
|
||||
{setup && status.smartAppControlWarning && !status.failure ? (
|
||||
<p className="text-sm text-warning" data-testid="setup-smart-app-control">
|
||||
{t('backend.setup_smart_app_control')}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 2. Anything that must be answered or fixed right here. */}
|
||||
{setup ? <SetupUpdateNotice /> : null}
|
||||
{setup || installing || failed ? <DiagnosticConsent /> : null}
|
||||
{setup ? <SetupAnalyticsConsent analyticsDisabled={status.analyticsDisabled} /> : null}
|
||||
{welcome && <SetupLocaleRows status={status} disabled={setupBusy} />}
|
||||
{setupBlocked || (failed && status.diagnosis === 'auth_required') ? (
|
||||
// Intel Macs only have a remote backend; an expired remote session is
|
||||
// repaired here because the gated workspace hides Settings.
|
||||
@@ -491,20 +557,37 @@ export function BackendGate({ children, repairDock }: BackendGateProps) {
|
||||
onCancel={retry}
|
||||
/>
|
||||
) : null}
|
||||
{setup && !unsupportedPlatform ? (
|
||||
<SetupLocation
|
||||
status={status}
|
||||
disabled={setupBusy}
|
||||
showChange={!setupFolderFix}
|
||||
onChange={() => void chooseSetupFolder()}
|
||||
/>
|
||||
) : null}
|
||||
{welcome ? (
|
||||
<ExistingPythonSettings compact>{runtimeLocation}</ExistingPythonSettings>
|
||||
) : (
|
||||
runtimeLocation
|
||||
)}
|
||||
{(setup || installing || failed) && (
|
||||
<div
|
||||
className={
|
||||
welcome
|
||||
? cn(
|
||||
welcomeColumns,
|
||||
'items-stretch empty:hidden [&>section]:rounded-xl [&>section]:border [&>section]:border-border/50 [&>section]:bg-card/20',
|
||||
)
|
||||
: 'divide-y divide-border/50 overflow-hidden rounded-xl border border-border/50 bg-card/20 empty:hidden'
|
||||
}
|
||||
>
|
||||
<DiagnosticConsent preselectUnanswered={welcome} />
|
||||
{setup && (
|
||||
<SetupAnalyticsConsent
|
||||
preselectUnanswered={welcome}
|
||||
analyticsDisabled={status.analyticsDisabled}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{/* A saved interpreter that broke later fails the launch, not setup: keep
|
||||
the way back to the managed runtime (or another interpreter) here. */}
|
||||
{failed && !status.remote ? <ExistingPythonSettings onlyWhenSelected /> : null}
|
||||
|
||||
{/* 3. The one primary action, then the two disclosures. */}
|
||||
{setup || failed || canTroubleshoot ? (
|
||||
{(setup && !welcome) || failed || canTroubleshoot ? (
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{wrongArchitecture ? (
|
||||
<ExternalLink href={RELEASES_URL} variant="secondary">
|
||||
@@ -522,7 +605,7 @@ export function BackendGate({ children, repairDock }: BackendGateProps) {
|
||||
{t('backend.retry')}
|
||||
</Button>
|
||||
</>
|
||||
) : setup && !setupBlocked ? (
|
||||
) : setup && !setupBlocked && !welcome ? (
|
||||
<Button
|
||||
className="h-auto min-h-8 max-w-full whitespace-normal py-1.5 text-center"
|
||||
disabled={setupBusy}
|
||||
@@ -608,7 +691,7 @@ export function BackendGate({ children, repairDock }: BackendGateProps) {
|
||||
onToggle={() => togglePanel('troubleshoot')}
|
||||
/>
|
||||
) : null}
|
||||
{setup ? (
|
||||
{setup && !welcome ? (
|
||||
<PanelToggle
|
||||
id="options"
|
||||
open={panel === 'options'}
|
||||
@@ -660,7 +743,7 @@ export function BackendGate({ children, repairDock }: BackendGateProps) {
|
||||
) : null}
|
||||
</section>
|
||||
) : null}
|
||||
{setup && mounted.options ? (
|
||||
{setup && !welcome && mounted.options ? (
|
||||
<section
|
||||
id="setup-panel-options"
|
||||
hidden={panel !== 'options'}
|
||||
@@ -677,8 +760,17 @@ export function BackendGate({ children, repairDock }: BackendGateProps) {
|
||||
) : null}
|
||||
|
||||
{/* 4. One help row: each destination once. */}
|
||||
{setup || installing || failed ? (
|
||||
<div className="border-t border-border/40 pt-3">
|
||||
{showSetupLinks ? (
|
||||
<div
|
||||
className={
|
||||
welcome ? 'mt-2 border-t border-border/40 pt-5' : 'border-t border-border/40 pt-3'
|
||||
}
|
||||
>
|
||||
{welcome && (
|
||||
<div className="mb-3 flex justify-center">
|
||||
<SetupInstallMenu disabled={setupBusy} onInstall={() => void runSetup()} />
|
||||
</div>
|
||||
)}
|
||||
<SetupHelpLinks
|
||||
leading={setup || installing ? <SetupLogButton /> : undefined}
|
||||
report={
|
||||
@@ -706,6 +798,7 @@ export function BackendGate({ children, repairDock }: BackendGateProps) {
|
||||
</div>
|
||||
</div>
|
||||
{!recovering && repairDock}
|
||||
{showSetupLinks && <SetupCommunityFooter />}
|
||||
</div>
|
||||
);
|
||||
|
||||
|
||||
@@ -15,11 +15,12 @@ export function formatComputeRuntime(runtime: string) {
|
||||
return runtime
|
||||
.replace(/^cpu/i, 'CPU')
|
||||
.replace(/^cuda/i, 'CUDA')
|
||||
.replace(/^rocm/i, 'ROCm')
|
||||
.replace(/^hip/i, 'HIP')
|
||||
.replace(/^rocm/i, 'AMD ROCm')
|
||||
.replace(/^hip/i, 'AMD HIP')
|
||||
.replace(/^xpu/i, 'Intel XPU')
|
||||
.replace(/^mps/i, 'Apple MPS')
|
||||
.replace(/^vulkan/i, 'Vulkan');
|
||||
.replace(/^vulkan/i, 'Vulkan')
|
||||
.replace(/^npu/i, 'NPU');
|
||||
}
|
||||
|
||||
export function ComputeVendorIcon({
|
||||
|
||||
@@ -63,41 +63,59 @@ it('shows a failed initial status read and retries without choosing consent', as
|
||||
render(<DiagnosticConsent />);
|
||||
expect(await screen.findByRole('alert')).toHaveTextContent('diagnostics.save_failed');
|
||||
expect(screen.queryByText('private startup detail')).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole('button', { name: 'diagnostics.allow' })).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole('switch', { name: 'diagnostics.title' })).not.toBeInTheDocument();
|
||||
captureDiagnosticException(new Error('private text'), 'renderer_crash', 'render');
|
||||
expect(mock.capture).not.toHaveBeenCalled();
|
||||
fireEvent.click(screen.getByRole('button', { name: 'common.retry' }));
|
||||
expect(await screen.findByRole('button', { name: 'diagnostics.allow' })).toBeEnabled();
|
||||
expect(screen.getByRole('button', { name: 'diagnostics.keep_off' })).toBeEnabled();
|
||||
expect(await screen.findByRole('switch', { name: 'diagnostics.title' })).toBeEnabled();
|
||||
expect(screen.getByRole('switch', { name: 'diagnostics.title' })).not.toBeChecked();
|
||||
expect(screen.queryByRole('alert')).not.toBeInTheDocument();
|
||||
expect(mock.read).toHaveBeenCalledTimes(2);
|
||||
expect(mock.save).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('offers equal explicit choices with no backend and remembers No independently of analytics', async () => {
|
||||
it('defaults off and remembers a changed choice independently of analytics', async () => {
|
||||
localStorage.setItem('voicestudio.setup.analytics-consent.v1', JSON.stringify({ enabled: true }));
|
||||
const first = render(<DiagnosticConsent />);
|
||||
const yes = await screen.findByRole('button', { name: 'diagnostics.allow' });
|
||||
const no = screen.getByRole('button', { name: 'diagnostics.keep_off' });
|
||||
expect(yes.className).toBe(no.className);
|
||||
const toggle = await screen.findByRole('switch', { name: 'diagnostics.title' });
|
||||
expect(toggle).not.toBeChecked();
|
||||
captureDiagnosticException(new Error('private text'), 'renderer_crash', 'render');
|
||||
expect(mock.capture).not.toHaveBeenCalled();
|
||||
expect(mock.save).not.toHaveBeenCalled();
|
||||
fireEvent.click(no);
|
||||
fireEvent.click(toggle);
|
||||
await waitFor(() => expect(toggle).toBeChecked());
|
||||
fireEvent.click(toggle);
|
||||
await waitFor(() => expect(mock.save).toHaveBeenCalledWith(false));
|
||||
await waitFor(() => expect(screen.queryByTestId('diagnostic-consent')).not.toBeInTheDocument());
|
||||
first.unmount();
|
||||
render(<DiagnosticConsent />);
|
||||
await waitFor(() => expect(screen.queryByTestId('diagnostic-consent')).not.toBeInTheDocument());
|
||||
expect(await screen.findByRole('switch', { name: 'diagnostics.title' })).not.toBeChecked();
|
||||
localStorage.clear();
|
||||
});
|
||||
|
||||
it('preselects only an unanswered welcome choice and requires a separate grant', async () => {
|
||||
const view = render(<DiagnosticConsent preselectUnanswered />);
|
||||
const toggle = await screen.findByRole('switch');
|
||||
expect(toggle).toBeChecked();
|
||||
expect(mock.save).not.toHaveBeenCalled();
|
||||
expect(screen.getByRole('button', { name: 'diagnostics.keep_off' })).toBeEnabled();
|
||||
fireEvent.click(screen.getByRole('button', { name: 'diagnostics.allow' }));
|
||||
await waitFor(() => expect(mock.save).toHaveBeenCalledWith(true));
|
||||
await waitFor(() =>
|
||||
expect(screen.queryByRole('button', { name: 'diagnostics.allow' })).toBeNull(),
|
||||
);
|
||||
fireEvent.click(toggle);
|
||||
await waitFor(() => expect(mock.save).toHaveBeenCalledWith(false));
|
||||
view.unmount();
|
||||
render(<DiagnosticConsent preselectUnanswered />);
|
||||
expect(await screen.findByRole('switch')).not.toBeChecked();
|
||||
});
|
||||
|
||||
it('a failed Yes keeps collection off and the choice retryable', async () => {
|
||||
mock.save.mockRejectedValue(new Error('private failure detail'));
|
||||
render(<DiagnosticConsent />);
|
||||
fireEvent.click(await screen.findByRole('button', { name: 'diagnostics.allow' }));
|
||||
fireEvent.click(await screen.findByRole('switch', { name: 'diagnostics.title' }));
|
||||
expect(await screen.findByRole('alert')).toHaveTextContent('diagnostics.save_failed');
|
||||
expect(screen.getByRole('button', { name: 'diagnostics.keep_off' })).toBeEnabled();
|
||||
expect(screen.getByRole('switch', { name: 'diagnostics.title' })).not.toBeChecked();
|
||||
captureDiagnosticException(new Error('private text'), 'renderer_crash', 'render');
|
||||
expect(mock.capture).not.toHaveBeenCalled();
|
||||
expect(screen.queryByText('private failure detail')).not.toBeInTheDocument();
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { BugIcon } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { SetupPrivacyRow } from './setup-privacy-row';
|
||||
import { getBridge } from './bridge';
|
||||
import { Button } from './ui/button';
|
||||
import { Switch } from './ui/switch';
|
||||
@@ -15,7 +17,9 @@ function choose(enabled: boolean): void {
|
||||
void setDiagnosticConsent(enabled).catch(() => {});
|
||||
}
|
||||
|
||||
export function DiagnosticConsent() {
|
||||
export function DiagnosticConsent({
|
||||
preselectUnanswered = false,
|
||||
}: { preselectUnanswered?: boolean } = {}) {
|
||||
const { t } = useTranslation();
|
||||
const { status, loading, saving, error } = useDiagnostics();
|
||||
if (!status && error)
|
||||
@@ -35,51 +39,48 @@ export function DiagnosticConsent() {
|
||||
</p>
|
||||
</section>
|
||||
);
|
||||
if (status?.prompted || status?.opted_in)
|
||||
return (
|
||||
<section className="rounded-lg border border-border/60 bg-muted/20">
|
||||
<DiagnosticPrivacySetting />
|
||||
</section>
|
||||
);
|
||||
if (
|
||||
!status?.available ||
|
||||
status.prompted ||
|
||||
(status.externally_managed && !getBridge()?.diagnostics)
|
||||
)
|
||||
return null;
|
||||
if (!status) return null;
|
||||
const managed = Boolean(status.externally_managed && !getBridge()?.diagnostics);
|
||||
if (!status.prompted && !status.opted_in && (!status.available || managed)) return null;
|
||||
const pending =
|
||||
preselectUnanswered &&
|
||||
!status.prompted &&
|
||||
!status.opted_in &&
|
||||
status.available &&
|
||||
!managed &&
|
||||
!saving &&
|
||||
!error;
|
||||
return (
|
||||
<section
|
||||
className="space-y-2 rounded-lg border border-border/60 bg-muted/20 p-3 text-left"
|
||||
data-testid="diagnostic-consent"
|
||||
<SetupPrivacyRow
|
||||
testId="diagnostic-consent"
|
||||
icon={BugIcon}
|
||||
title={t('diagnostics.title')}
|
||||
summary={t('setup.reports_summary')}
|
||||
details={t('diagnostics.body')}
|
||||
checked={pending || status.opted_in}
|
||||
declineLabel={t('diagnostics.keep_off')}
|
||||
confirmLabel={pending ? t('diagnostics.allow') : undefined}
|
||||
disabled={saving || managed || (!status.available && !status.opted_in)}
|
||||
onChange={choose}
|
||||
>
|
||||
<h2 className="text-sm font-medium">{t('diagnostics.title')}</h2>
|
||||
<p className="text-xs leading-5 text-muted-foreground">{t('diagnostics.body')}</p>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="outline"
|
||||
disabled={saving}
|
||||
onClick={() => choose(true)}
|
||||
>
|
||||
{t('diagnostics.allow')}
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="outline"
|
||||
disabled={saving}
|
||||
onClick={() => choose(false)}
|
||||
>
|
||||
{t('diagnostics.keep_off')}
|
||||
</Button>
|
||||
</div>
|
||||
{!status.available && (
|
||||
<p className="text-xs text-muted-foreground">{t('diagnostics.unavailable')}</p>
|
||||
)}
|
||||
{managed && <p className="text-xs text-muted-foreground">{t('diagnostics.managed')}</p>}
|
||||
{error && (
|
||||
<p role="alert" className="text-xs text-destructive">
|
||||
{t('diagnostics.save_failed')}
|
||||
{t('diagnostics.save_failed')}{' '}
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
disabled={saving}
|
||||
onClick={() => void retryDiagnosticConsent().catch(() => {})}
|
||||
>
|
||||
{t('common.retry')}
|
||||
</Button>
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
</SetupPrivacyRow>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,14 @@ export function ExternalLink({
|
||||
showIcon = true,
|
||||
variant = 'outline',
|
||||
className,
|
||||
title,
|
||||
}: {
|
||||
href: string;
|
||||
children: React.ReactNode;
|
||||
showIcon?: boolean;
|
||||
variant?: 'outline' | 'ghost' | 'secondary' | 'link';
|
||||
className?: string;
|
||||
title?: string;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [failed, setFailed] = useState(false);
|
||||
@@ -23,6 +25,7 @@ export function ExternalLink({
|
||||
<>
|
||||
<a
|
||||
href={href}
|
||||
title={title}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className={cn(buttonVariants({ variant, size: 'sm' }), className)}
|
||||
|
||||
@@ -27,7 +27,7 @@ function PopoverContent({
|
||||
<PopoverPrimitive.Popup
|
||||
data-slot="popover-content"
|
||||
className={cn(
|
||||
'origin-(--transform-origin) rounded-lg surface-glass text-popover-foreground shadow-md ring-1 ring-border outline-none duration-100 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 motion-reduce:animate-none',
|
||||
'origin-(--transform-origin) rounded-field surface-glass text-popover-foreground shadow-md ring-1 ring-border outline-none duration-100 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 motion-reduce:animate-none',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
import { useEffect, useState, type ReactNode } from 'react';
|
||||
import { XIcon } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button } from './ui/button';
|
||||
import { Dialog, DialogClose, DialogContent, DialogTitle, DialogTrigger } from './ui/dialog';
|
||||
import { MarkdownLite } from './markdown-lite';
|
||||
import { ExternalLink } from './external-link';
|
||||
|
||||
function ReleaseNotes({ version }: { version: string }) {
|
||||
const { t } = useTranslation();
|
||||
const [notes, setNotes] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
// The local changelog is a separate asset, loaded only when the dialog opens.
|
||||
void import('../../../../../CHANGELOG.md?raw')
|
||||
.then(({ default: changelog }) => {
|
||||
const section = changelog
|
||||
.split(/^## /m)
|
||||
.slice(1)
|
||||
.find((entry) => entry.startsWith(`[${version}]`));
|
||||
if (active) setNotes(section?.slice(section.indexOf('\n') + 1).trim() ?? '');
|
||||
})
|
||||
.catch(() => {
|
||||
if (active) setNotes('');
|
||||
});
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, [version]);
|
||||
|
||||
if (notes === null) return <p role="status">{t('common.loading')}</p>;
|
||||
if (notes) return <MarkdownLite text={notes} />;
|
||||
const releaseTag = /^\d+\.\d+\.\d+(-beta\.\d+)?$/.test(version);
|
||||
const releases = 'https://github.com/debpalash/VoiceStudio/releases';
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
<p>{t('updates.none')}</p>
|
||||
<ExternalLink href={releaseTag ? `${releases}/tag/v${version}` : releases}>
|
||||
{t(releaseTag ? 'update.view_release' : 'updates.open_releases')}
|
||||
</ExternalLink>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function ReleaseNotesDialog({
|
||||
version,
|
||||
className,
|
||||
children,
|
||||
}: {
|
||||
version: string;
|
||||
className: string;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Dialog>
|
||||
<DialogTrigger render={<Button variant="link" size="sm" className={className} />}>
|
||||
{children}
|
||||
</DialogTrigger>
|
||||
<DialogContent
|
||||
showCloseButton={false}
|
||||
className="max-h-[85dvh] grid-rows-[auto_minmax(0,1fr)] gap-0 overflow-hidden p-0 sm:max-w-xl"
|
||||
>
|
||||
<div className="flex items-center justify-between gap-3 border-b border-border/60 px-5 py-3">
|
||||
<DialogTitle className="text-base">{t('updates.notes_for', { version })}</DialogTitle>
|
||||
<DialogClose
|
||||
render={<Button size="icon-sm" variant="ghost" aria-label={t('common.close')} />}
|
||||
>
|
||||
<XIcon aria-hidden="true" />
|
||||
</DialogClose>
|
||||
</div>
|
||||
<div
|
||||
tabIndex={0}
|
||||
className="min-h-0 overflow-y-auto overscroll-contain px-5 py-4 text-sm leading-relaxed text-muted-foreground"
|
||||
>
|
||||
<ReleaseNotes key={version} version={version} />
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { BugIcon } from 'lucide-react';
|
||||
import { useRef, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { composeBugReportUrl } from '@shared/utils/bugReportDocument';
|
||||
@@ -365,6 +366,7 @@ export function ReportBug({
|
||||
setDialogOpen(true);
|
||||
}}
|
||||
>
|
||||
{variant === 'ghost' && <BugIcon className="size-3.5" aria-hidden="true" />}
|
||||
{t(busy ? 'common.loading' : 'reportBug.label')}
|
||||
</Button>
|
||||
{failed && (
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { CpuIcon } from 'lucide-react';
|
||||
import { useEffect, useState, type ReactNode } from 'react';
|
||||
import { BookOpenIcon, BugIcon, CloudIcon, CpuIcon, GemIcon, WrenchIcon } from 'lucide-react';
|
||||
import type { ReactNode } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { primaryUpdateAction, runUpdateAction } from '@/lib/update-actions';
|
||||
import { updateErrorTitleKey } from '@/lib/update-format';
|
||||
import { UpdatePill } from './app-shell/update-pill';
|
||||
import { DISCORD_URL, ISSUES_URL } from '@shared/utils/contactLinks';
|
||||
import type { BackendStatus, UpdateState } from '../../../preload/index.d';
|
||||
import { appVersion, getBridge, platformFamily } from './bridge';
|
||||
import type { BackendStatus } from '../../../preload/index.d';
|
||||
import { appVersion, platformFamily } from './bridge';
|
||||
import { ExternalLink } from './external-link';
|
||||
import { ReleaseNotesDialog } from './release-notes-dialog';
|
||||
|
||||
const REPO = 'https://github.com/debpalash/VoiceStudio';
|
||||
const INSTALL_GUIDES = {
|
||||
@@ -17,24 +16,14 @@ const INSTALL_GUIDES = {
|
||||
} as const;
|
||||
const TROUBLESHOOTING = `${REPO}/blob/main/docs/install/troubleshooting.md`;
|
||||
|
||||
/**
|
||||
* Release page for this exact build. Development and preview builds carry the
|
||||
* same version as the last release but different code, so they get the list.
|
||||
*/
|
||||
export function releaseNotesUrl(version: string, isDev: boolean): string {
|
||||
return !isDev && /^\d+\.\d+\.\d+(-beta\.\d+)?$/.test(version)
|
||||
? `${REPO}/releases/tag/v${version}`
|
||||
: `${REPO}/releases`;
|
||||
}
|
||||
|
||||
/** Version and channel beside the logo on the setup screen, with a link to its notes. */
|
||||
export function SetupVersion() {
|
||||
/** Installed version, release channel and release notes. */
|
||||
export function SetupVersion({ showUpdate = false }: { showUpdate?: boolean }) {
|
||||
const { t } = useTranslation();
|
||||
const version = appVersion();
|
||||
if (!version) return null;
|
||||
const beta = /-beta\.\d+$/.test(version);
|
||||
return (
|
||||
<span className="flex min-w-0 items-center gap-2 text-xs text-muted-foreground">
|
||||
<span className="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground">
|
||||
<span className="tabular-nums" data-testid="setup-version">
|
||||
{t('app.version', { version })}
|
||||
</span>
|
||||
@@ -43,88 +32,19 @@ export function SetupVersion() {
|
||||
{t('update.channel_beta')}
|
||||
</span>
|
||||
)}
|
||||
<ExternalLink
|
||||
href={releaseNotesUrl(version, getBridge()?.app?.isDev ?? false)}
|
||||
variant="link"
|
||||
showIcon={false}
|
||||
<ReleaseNotesDialog
|
||||
version={version}
|
||||
className="app-no-drag h-auto px-0 text-xs text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
{t('update.whats_new')}
|
||||
</ExternalLink>
|
||||
</ReleaseNotesDialog>
|
||||
{showUpdate && <UpdatePill setup />}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
// A failed download keeps availableVersion, so it stays here with Retry.
|
||||
const OFFERED = new Set<UpdateState['status']>(['available', 'downloading', 'downloaded', 'error']);
|
||||
|
||||
/**
|
||||
* Offers a newer app before the runtime download: the runtime is installed for
|
||||
* this app's pins, so updating first avoids downloading several GB twice.
|
||||
*/
|
||||
export function SetupUpdateNotice() {
|
||||
const { t } = useTranslation();
|
||||
const [state, setState] = useState<UpdateState | null>(null);
|
||||
useEffect(() => {
|
||||
const updates = getBridge()?.updates;
|
||||
if (!updates) return;
|
||||
let active = true;
|
||||
// An event can arrive before the initial snapshot resolves; the event is newer.
|
||||
let heard = false;
|
||||
const unsubscribe = updates.onState((next) => {
|
||||
heard = true;
|
||||
setState(next);
|
||||
});
|
||||
void updates
|
||||
.getState()
|
||||
.then((next) => active && !heard && setState(next))
|
||||
.catch(() => {});
|
||||
return () => {
|
||||
active = false;
|
||||
unsubscribe();
|
||||
};
|
||||
}, []);
|
||||
if (!state || !OFFERED.has(state.status) || !state.availableVersion) return null;
|
||||
const action = primaryUpdateAction(state);
|
||||
const title =
|
||||
state.status === 'error'
|
||||
? t(updateErrorTitleKey(state), { version: state.availableVersion })
|
||||
: state.status === 'downloaded'
|
||||
? t('update.prompt_ready')
|
||||
: state.status === 'downloading'
|
||||
? t('update.downloading', { pct: Math.round(state.progress) })
|
||||
: t('update.prompt_available', { version: state.availableVersion });
|
||||
return (
|
||||
<div
|
||||
role="status"
|
||||
data-testid="setup-update-notice"
|
||||
className="flex w-full flex-wrap items-center gap-3 rounded-xl border border-primary/30 bg-primary/[0.06] px-4 py-3 text-left"
|
||||
>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-sm font-medium">{title}</p>
|
||||
<p className="text-xs text-muted-foreground">{t('setup.update_first')}</p>
|
||||
</div>
|
||||
{action === 'download' && (
|
||||
<Button size="sm" onClick={() => void runUpdateAction('download', state, t)}>
|
||||
{t('update.download')}
|
||||
</Button>
|
||||
)}
|
||||
{action === 'install' && (
|
||||
<Button size="sm" onClick={() => void runUpdateAction('install', state, t)}>
|
||||
{t('update.restart')}
|
||||
</Button>
|
||||
)}
|
||||
{action === 'retry' && (
|
||||
<Button size="sm" onClick={() => void runUpdateAction('retry', state, t)}>
|
||||
{t('update.retry')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The one help row on the setup screen, there before anything goes wrong. A
|
||||
* Setup help is available before anything goes wrong. A
|
||||
* failure swaps the plain issue link for its prefilled report (`report`), so
|
||||
* no destination is offered twice.
|
||||
*/
|
||||
@@ -134,24 +54,84 @@ export function SetupHelpLinks({ leading, report }: { leading?: ReactNode; repor
|
||||
<nav
|
||||
aria-label={t('setup.help_label')}
|
||||
data-testid="setup-help-links"
|
||||
className="-mx-2 flex flex-wrap items-start gap-x-0.5 gap-y-1 text-muted-foreground [&_:is(a,button)]:h-7 [&_:is(a,button)]:px-2 [&_:is(a,button)]:text-xs [&_:is(a,button)]:font-normal [&_:is(a,button)]:text-muted-foreground [&_:is(a,button):hover]:text-foreground"
|
||||
className="setup-help-links flex flex-wrap items-center justify-center gap-1"
|
||||
>
|
||||
{leading}
|
||||
<ExternalLink href={INSTALL_GUIDES[platformFamily()]} variant="ghost" showIcon={false}>
|
||||
<BookOpenIcon className="size-3.5" aria-hidden="true" />
|
||||
{t('setup.help_install')}
|
||||
</ExternalLink>
|
||||
<ExternalLink href={TROUBLESHOOTING} variant="ghost" showIcon={false}>
|
||||
<WrenchIcon className="size-3.5" aria-hidden="true" />
|
||||
{t('setup.help_troubleshooting')}
|
||||
</ExternalLink>
|
||||
{report ?? (
|
||||
<ExternalLink href={ISSUES_URL} variant="ghost" showIcon={false}>
|
||||
<BugIcon className="size-3.5" aria-hidden="true" />
|
||||
{t('setup.help_report')}
|
||||
</ExternalLink>
|
||||
)}
|
||||
<ExternalLink href={DISCORD_URL} variant="ghost" showIcon={false}>
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
||||
function DiscordMark() {
|
||||
return (
|
||||
<img
|
||||
src="./social/discord.svg"
|
||||
alt=""
|
||||
className="size-4 shrink-0 opacity-80 brightness-0 dark:invert"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function SetupHeaderLinks() {
|
||||
const { t } = useTranslation();
|
||||
const links = [
|
||||
{ label: t('setupHelp.discord_short'), href: DISCORD_URL, icon: <DiscordMark /> },
|
||||
{
|
||||
label: t('supportPlans.pro'),
|
||||
href: 'https://voicestudio.sh/pro',
|
||||
icon: <GemIcon aria-hidden="true" />,
|
||||
},
|
||||
{
|
||||
label: t('setupHelp.cloud'),
|
||||
href: 'https://app.voicestudio.sh',
|
||||
icon: <CloudIcon aria-hidden="true" />,
|
||||
},
|
||||
];
|
||||
return (
|
||||
<div className="ms-auto flex shrink-0 items-center gap-0.5">
|
||||
{links.map(({ label, href, icon }) => (
|
||||
<ExternalLink
|
||||
key={href}
|
||||
href={href}
|
||||
variant="ghost"
|
||||
showIcon={false}
|
||||
title={label}
|
||||
className="min-h-8 min-w-8 gap-1.5 px-2 text-xs text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
{icon}
|
||||
<span className="@max-[28rem]:sr-only">{label}</span>
|
||||
</ExternalLink>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function SetupCommunityFooter() {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<footer className="setup-community-footer flex shrink-0 items-center justify-center border-t border-border/50 bg-background">
|
||||
<ExternalLink
|
||||
href={DISCORD_URL}
|
||||
showIcon={false}
|
||||
className="h-auto min-h-8 max-w-full gap-2 rounded-lg px-3 py-1.5 text-sm font-medium whitespace-normal"
|
||||
>
|
||||
<DiscordMark />
|
||||
{t('setupHelp.discord')}
|
||||
</ExternalLink>
|
||||
</nav>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -185,7 +165,9 @@ export function SetupHardware({ hardware }: { hardware: BackendStatus['setupHard
|
||||
className="mt-1 flex items-center gap-1.5 text-xs text-muted-foreground"
|
||||
>
|
||||
<CpuIcon className="size-3.5 shrink-0" aria-hidden="true" />
|
||||
<span className="min-w-0 truncate">{text}</span>
|
||||
<span className="min-w-0 break-words" title={text}>
|
||||
{text}
|
||||
</span>
|
||||
</p>
|
||||
);
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useEffect } from 'react';
|
||||
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
import { afterEach, beforeEach, expect, it, vi } from 'vitest';
|
||||
@@ -34,9 +35,10 @@ vi.mock('@/features/settings/privacy-settings', () => ({
|
||||
PrivacySettings: () => <div>Privacy</div>,
|
||||
}));
|
||||
vi.mock('./analytics-consent', () => ({
|
||||
AnalyticsConsent: ({ onRequirementChange }: { onRequirementChange(value: boolean): void }) => (
|
||||
<button onClick={() => onRequirementChange(false)}>Choose privacy</button>
|
||||
),
|
||||
AnalyticsConsent: ({ onRequirementChange }: { onRequirementChange(value: boolean): void }) => {
|
||||
useEffect(() => onRequirementChange(true), [onRequirementChange]);
|
||||
return <button onClick={() => onRequirementChange(false)}>Choose privacy</button>;
|
||||
},
|
||||
}));
|
||||
vi.mock('./account-consent', async () => {
|
||||
const { useEffect } = await import('react');
|
||||
@@ -114,6 +116,8 @@ it('requires passing preflight and installed models before completion', async ()
|
||||
);
|
||||
fireEvent.click(screen.getByRole('button', { name: 'setup.continue_ok' }));
|
||||
await screen.findByRole('button', { name: 'Choose privacy' });
|
||||
expect(screen.queryByText('Privacy')).not.toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('button', { name: 'dub.advanced' }));
|
||||
expect(screen.getByText('Privacy')).toBeVisible();
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Choose privacy' }));
|
||||
await waitFor(() =>
|
||||
@@ -175,7 +179,11 @@ it('the privacy step also waits for the account choice when accounts are offered
|
||||
fireEvent.click(screen.getByRole('button', { name: 'setup.continue_ok' }));
|
||||
fireEvent.click(await screen.findByRole('button', { name: 'Choose privacy' }));
|
||||
expect(screen.getByRole('button', { name: 'setup.continue_ok' })).toBeDisabled();
|
||||
const hint = screen.getByRole('button', { name: /setup.choose_to_continue/ });
|
||||
fireEvent.click(hint);
|
||||
expect(screen.getByRole('button', { name: 'Choose account' })).toHaveFocus();
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Choose account' }));
|
||||
expect(hint).not.toBeInTheDocument();
|
||||
await waitFor(() =>
|
||||
expect(screen.getByRole('button', { name: 'setup.continue_ok' })).toBeEnabled(),
|
||||
);
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
import { Menu } from '@base-ui/react/menu';
|
||||
import { ChevronUpIcon, HardDriveDownloadIcon, ServerIcon, XIcon } from 'lucide-react';
|
||||
import { useRef, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { RemoteBackendSettings } from '@/features/settings/remote-backend-settings';
|
||||
import { Button } from './ui/button';
|
||||
import { Dialog, DialogClose, DialogContent, DialogTitle } from './ui/dialog';
|
||||
|
||||
const itemClass =
|
||||
'flex cursor-default items-center min-h-8 gap-2.5 rounded-md px-2.5 py-1.5 text-sm leading-5 outline-none data-highlighted:bg-accent data-highlighted:text-accent-foreground';
|
||||
|
||||
export function SetupInstallMenu({
|
||||
disabled,
|
||||
onInstall,
|
||||
}: {
|
||||
disabled: boolean;
|
||||
onInstall: () => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const trigger = useRef<HTMLButtonElement>(null);
|
||||
const [remoteOpen, setRemoteOpen] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<Menu.Root>
|
||||
<Menu.Trigger
|
||||
ref={trigger}
|
||||
disabled={disabled}
|
||||
openOnHover
|
||||
closeDelay={180}
|
||||
render={
|
||||
<Button
|
||||
size="lg"
|
||||
className="h-auto min-h-11 min-w-28 gap-3 rounded-xl px-5 py-2 text-base font-bold"
|
||||
/>
|
||||
}
|
||||
>
|
||||
{t('modelMaintenance.install')}
|
||||
<ChevronUpIcon aria-hidden="true" className="size-3.5 opacity-70" />
|
||||
</Menu.Trigger>
|
||||
<Menu.Portal>
|
||||
<Menu.Positioner side="top" align="center" sideOffset={8} className="z-50">
|
||||
<Menu.Popup className="max-w-[calc(100vw-2rem)] rounded-xl bg-popover p-1 ring-1 ring-border/70 text-popover-foreground shadow-lg outline-none">
|
||||
<Menu.Item className={itemClass} onClick={onInstall}>
|
||||
<HardDriveDownloadIcon
|
||||
aria-hidden="true"
|
||||
className="size-4 shrink-0 text-muted-foreground"
|
||||
/>
|
||||
{t('backend.setup_required')}
|
||||
</Menu.Item>
|
||||
<Menu.Item className={itemClass} onClick={() => setRemoteOpen(true)}>
|
||||
<ServerIcon aria-hidden="true" className="size-4 shrink-0 text-muted-foreground" />
|
||||
{t('setup.configure_remote')}
|
||||
</Menu.Item>
|
||||
</Menu.Popup>
|
||||
</Menu.Positioner>
|
||||
</Menu.Portal>
|
||||
</Menu.Root>
|
||||
<Dialog open={remoteOpen} onOpenChange={setRemoteOpen}>
|
||||
<DialogContent
|
||||
finalFocus={trigger}
|
||||
showCloseButton={false}
|
||||
className="max-h-[85dvh] overflow-y-auto sm:max-w-lg"
|
||||
>
|
||||
<DialogTitle className="sr-only">{t('settings.remote_backend_title')}</DialogTitle>
|
||||
<DialogClose
|
||||
render={
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
className="absolute end-3 top-2"
|
||||
aria-label={t('common.close')}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<XIcon aria-hidden="true" />
|
||||
</DialogClose>
|
||||
<RemoteBackendSettings compact />
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,75 +1,158 @@
|
||||
import { ChevronDownIcon, FolderOpenIcon } from 'lucide-react';
|
||||
// @ts-expect-error Shared JSX component has no declaration file.
|
||||
import SearchableSelect from '@shared/components/SearchableSelect';
|
||||
import {
|
||||
ChevronDownIcon,
|
||||
FolderOpenIcon,
|
||||
GlobeIcon,
|
||||
HardDriveIcon,
|
||||
InfoIcon,
|
||||
MessageSquareTextIcon,
|
||||
MapPinIcon,
|
||||
LocateFixedIcon,
|
||||
ShieldIcon,
|
||||
RotateCcwIcon,
|
||||
TriangleAlertIcon,
|
||||
} from 'lucide-react';
|
||||
import { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select';
|
||||
import { ExistingPythonSettings } from '@/features/settings/existing-python-settings';
|
||||
import { RemoteBackendSettings } from '@/features/settings/remote-backend-settings';
|
||||
import i18n, { APP_LANGUAGE_ITEMS, APP_LANGUAGES, setAppLanguage, type AppLocale } from '@/i18n';
|
||||
import { AppLanguageSelect } from './app-language-select';
|
||||
import CN from 'country-flag-icons/react/3x2/CN';
|
||||
import RU from 'country-flag-icons/react/3x2/RU';
|
||||
import { cn } from '@/lib/utils';
|
||||
import type { BackendStatus, RuntimeRegion } from '../../../preload/index.d';
|
||||
import { getBridge } from './bridge';
|
||||
import { MODEL_HEADROOM_GIB, SetupHardware } from './setup-extras';
|
||||
|
||||
const selectRow =
|
||||
'grid min-w-0 grid-cols-[auto_minmax(0,1fr)_minmax(0,min(50%,13rem))] items-center gap-x-2.5 px-3.5 py-2 text-sm text-muted-foreground';
|
||||
|
||||
export function SetupLocaleRows({
|
||||
status,
|
||||
disabled,
|
||||
}: {
|
||||
status: BackendStatus;
|
||||
disabled: boolean;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div className="divide-y divide-border/50 rounded-xl border border-border/50 bg-card/20">
|
||||
<div className={selectRow}>
|
||||
<MessageSquareTextIcon aria-hidden="true" className="size-4 shrink-0" />
|
||||
<span className="font-medium text-foreground">{t('settings.language')}</span>
|
||||
<AppLanguageSelect />
|
||||
</div>
|
||||
<SetupRegion status={status} disabled={disabled} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Where the runtime goes and whether it fits: one compact card above the install button. */
|
||||
export function SetupLocation({
|
||||
status,
|
||||
disabled,
|
||||
showChange,
|
||||
compact = false,
|
||||
onChange,
|
||||
}: {
|
||||
status: BackendStatus;
|
||||
disabled: boolean;
|
||||
/** False when the primary action already is "Choose another folder". */
|
||||
showChange: boolean;
|
||||
compact?: boolean;
|
||||
onChange: () => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
if (!status.runtimePath) return null;
|
||||
const { runtimeFreeGib: free, setupRequiredGib: needed } = status;
|
||||
const measured = free !== undefined && needed !== undefined;
|
||||
const lowHeadroom = measured && free >= needed && free < needed + MODEL_HEADROOM_GIB;
|
||||
return (
|
||||
<section
|
||||
aria-label={t('firstrun.env_dir')}
|
||||
className="flex items-start gap-3 rounded-xl border border-border/50 bg-card/20 px-3.5 py-3"
|
||||
className={cn(
|
||||
'min-w-0 px-3.5 py-3',
|
||||
compact
|
||||
? 'grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-2'
|
||||
: 'flex items-start gap-3 rounded-xl border border-border/50 bg-card/20',
|
||||
)}
|
||||
>
|
||||
<FolderOpenIcon className="mt-0.5 size-4 shrink-0 text-muted-foreground" aria-hidden="true" />
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="flex min-w-0 flex-wrap items-baseline gap-x-2 text-sm">
|
||||
<div className={compact ? 'contents' : 'min-w-0 flex-1'}>
|
||||
<div className="flex min-w-0 flex-wrap items-center gap-x-2 text-sm">
|
||||
<span className="font-medium">{t('firstrun.env_dir')}</span>
|
||||
<span className="text-xs text-muted-foreground">
|
||||
{t(status.runtimeStorage ? 'firstrun.env_dir_desc_scoped' : 'firstrun.env_dir_desc')}
|
||||
</span>
|
||||
</p>
|
||||
<p
|
||||
className="mt-0.5 truncate font-mono text-xs text-muted-foreground"
|
||||
title={status.runtimePath}
|
||||
>
|
||||
{status.runtimePath}
|
||||
</p>
|
||||
{compact && (
|
||||
<details className="group contents">
|
||||
<summary
|
||||
aria-label={t('firstrun.env_dir') + ' · ' + t('common.more_info')}
|
||||
className="grid size-6 cursor-pointer list-none place-items-center rounded text-muted-foreground hover:bg-muted focus-visible:outline-ring"
|
||||
>
|
||||
{lowHeadroom ? (
|
||||
<TriangleAlertIcon className="size-3.5 text-warning" aria-hidden="true" />
|
||||
) : (
|
||||
<InfoIcon className="size-3.5" aria-hidden="true" />
|
||||
)}
|
||||
</summary>
|
||||
<div className="order-last w-full pb-1 text-xs leading-5 text-muted-foreground">
|
||||
{t(
|
||||
status.runtimeStorage ? 'firstrun.env_dir_desc_scoped' : 'firstrun.env_dir_desc',
|
||||
)}
|
||||
<p className="break-all font-mono" dir="auto">
|
||||
{status.runtimePath}
|
||||
</p>
|
||||
{lowHeadroom && (
|
||||
<p data-testid="setup-model-space" className="mt-1 text-warning">
|
||||
{t('setup.models_space')}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</details>
|
||||
)}
|
||||
{!compact && (
|
||||
<span className="text-xs text-muted-foreground">
|
||||
{t(status.runtimeStorage ? 'firstrun.env_dir_desc_scoped' : 'firstrun.env_dir_desc')}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{!compact && (
|
||||
<p
|
||||
className="mt-0.5 truncate font-mono text-xs text-muted-foreground"
|
||||
title={status.runtimePath}
|
||||
>
|
||||
{status.runtimePath}
|
||||
</p>
|
||||
)}
|
||||
{measured ? (
|
||||
<p
|
||||
data-testid="setup-free-space"
|
||||
className={cn('mt-1 text-xs', free < needed ? 'text-warning' : 'text-muted-foreground')}
|
||||
className={cn(
|
||||
'mt-1 flex items-center gap-1.5 text-xs',
|
||||
compact && 'col-span-full',
|
||||
free < needed ? 'text-warning' : 'text-muted-foreground',
|
||||
)}
|
||||
>
|
||||
{t('firstrun.free_space', { free, needed })}
|
||||
{compact && <HardDriveIcon className="size-3.5 shrink-0" aria-hidden="true" />}
|
||||
{t(compact ? 'setup.drive_space' : 'firstrun.free_space', { free, needed })}
|
||||
</p>
|
||||
) : null}
|
||||
{measured && free >= needed && free < needed + MODEL_HEADROOM_GIB ? (
|
||||
<p data-testid="setup-model-space" className="mt-0.5 text-xs text-warning">
|
||||
{lowHeadroom && !compact ? (
|
||||
<p
|
||||
data-testid="setup-model-space"
|
||||
className="mt-0.5 flex items-center gap-1.5 text-xs text-warning"
|
||||
>
|
||||
{t('setup.models_space')}
|
||||
</p>
|
||||
) : null}
|
||||
<SetupHardware hardware={status.setupHardware} />
|
||||
{status.setupHardware && (
|
||||
<div className={compact ? 'col-span-full' : undefined}>
|
||||
<SetupHardware hardware={status.setupHardware} />
|
||||
</div>
|
||||
)}
|
||||
{status.runtimeStorage && (
|
||||
<dl className="mt-1.5 space-y-0.5 text-xs text-muted-foreground">
|
||||
<dl className="col-span-full mt-1.5 space-y-0.5 text-xs text-muted-foreground">
|
||||
{(['data', 'models', 'temp'] as const).map((kind) => (
|
||||
<div key={kind} className="flex gap-2">
|
||||
<dt className="shrink-0">{t(`firstrun.storage_${kind}`)}</dt>
|
||||
@@ -81,11 +164,18 @@ export function SetupLocation({
|
||||
</dl>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex shrink-0 flex-wrap justify-end gap-1">
|
||||
<div
|
||||
className={cn(
|
||||
'flex shrink-0 flex-wrap justify-end gap-1',
|
||||
compact && 'col-start-3 row-start-1',
|
||||
)}
|
||||
>
|
||||
{status.runtimeCustom && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
title={t('firstrun.reset_default')}
|
||||
aria-label={t('firstrun.reset_default')}
|
||||
disabled={disabled}
|
||||
onClick={() => {
|
||||
void getBridge()
|
||||
@@ -95,7 +185,7 @@ export function SetupLocation({
|
||||
});
|
||||
}}
|
||||
>
|
||||
{t('firstrun.reset_default')}
|
||||
{compact ? <RotateCcwIcon className="size-4" /> : t('firstrun.reset_default')}
|
||||
</Button>
|
||||
)}
|
||||
{showChange && (
|
||||
@@ -110,11 +200,63 @@ export function SetupLocation({
|
||||
|
||||
const REGIONS = ['auto', 'global', 'china', 'russia', 'restricted'] as const;
|
||||
|
||||
/**
|
||||
* Everything a first install rarely needs, behind the Options disclosure:
|
||||
* app language, download region, an existing Python interpreter and using a
|
||||
* VoiceStudio backend on another computer instead.
|
||||
*/
|
||||
const regionIcons = {
|
||||
auto: LocateFixedIcon,
|
||||
global: GlobeIcon,
|
||||
china: CN,
|
||||
russia: RU,
|
||||
restricted: ShieldIcon,
|
||||
};
|
||||
|
||||
function regionLabel({ value, label }: { value: RuntimeRegion; label: string }) {
|
||||
const Icon = regionIcons[value];
|
||||
return (
|
||||
<span className="flex min-w-0 items-center gap-2 text-sm">
|
||||
<Icon aria-hidden="true" className="h-3.5 w-[18px] shrink-0 rounded-[2px]" />
|
||||
<span className="truncate">{label}</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function SetupRegion({ status, disabled }: { status: BackendStatus; disabled: boolean }) {
|
||||
const { t } = useTranslation();
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [failed, setFailed] = useState(false);
|
||||
const options = REGIONS.map((value) => ({
|
||||
value,
|
||||
label: t(value === 'auto' ? 'bootstrap.auto_detect' : `bootstrap.region_${value}`),
|
||||
}));
|
||||
return (
|
||||
<div className={selectRow}>
|
||||
<MapPinIcon className="size-4 shrink-0" aria-hidden="true" />
|
||||
<span className="font-medium text-foreground">{t('firstrun.region_label')}</span>
|
||||
<div className="min-w-0 max-w-full">
|
||||
<SearchableSelect
|
||||
ariaLabel={t('firstrun.region_label')}
|
||||
value={status.runtimeRegion || 'auto'}
|
||||
options={options}
|
||||
renderValue={regionLabel}
|
||||
renderOption={regionLabel}
|
||||
menuPortal
|
||||
disabled={disabled || saving}
|
||||
onChange={async (value: RuntimeRegion) => {
|
||||
setFailed(false);
|
||||
setSaving(true);
|
||||
try {
|
||||
await getBridge()?.backend.setRuntimeRegion(value);
|
||||
} catch {
|
||||
setFailed(true);
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{failed && <p role="alert" className="mt-1 text-xs text-destructive">{t('settings.save_failed')}</p>}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function SetupOptions({
|
||||
status,
|
||||
regionDisabled,
|
||||
@@ -128,64 +270,12 @@ export function SetupOptions({
|
||||
showRemote: boolean;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [choosingRegion, setChoosingRegion] = useState(false);
|
||||
const [connectionOpen, setConnectionOpen] = useState(false);
|
||||
// Mounted on first open and kept, so a typed address or a running test survives a toggle.
|
||||
const [connectionShown, setConnectionShown] = useState(false);
|
||||
const regionItems = REGIONS.map((region) => ({
|
||||
value: region,
|
||||
label: t(region === 'auto' ? 'bootstrap.auto_detect' : `bootstrap.region_${region}`),
|
||||
}));
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
||||
<label className="space-y-1 text-xs text-muted-foreground">
|
||||
<span>{t('settings.language')}</span>
|
||||
<Select
|
||||
items={APP_LANGUAGE_ITEMS}
|
||||
value={i18n.resolvedLanguage || i18n.language}
|
||||
onValueChange={(value) => void setAppLanguage(value as AppLocale)}
|
||||
>
|
||||
<SelectTrigger className="w-full bg-muted/20" aria-label={t('settings.language')}>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent align="start">
|
||||
{APP_LANGUAGES.map(({ code, label }) => (
|
||||
<SelectItem key={code} value={code}>
|
||||
{label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</label>
|
||||
<label className="space-y-1 text-xs text-muted-foreground">
|
||||
<span>{t('firstrun.region_label')}</span>
|
||||
<Select
|
||||
items={regionItems}
|
||||
value={status.runtimeRegion || 'auto'}
|
||||
disabled={choosingRegion || regionDisabled}
|
||||
onValueChange={async (value) => {
|
||||
setChoosingRegion(true);
|
||||
try {
|
||||
await getBridge()?.backend.setRuntimeRegion(value as RuntimeRegion);
|
||||
} finally {
|
||||
setChoosingRegion(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<SelectTrigger className="w-full bg-muted/20" aria-label={t('firstrun.region_label')}>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent align="end">
|
||||
{regionItems.map((item) => (
|
||||
<SelectItem key={item.value} value={item.value}>
|
||||
{item.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</label>
|
||||
</div>
|
||||
<SetupLocaleRows status={status} disabled={regionDisabled} />
|
||||
{showPython ? <ExistingPythonSettings /> : null}
|
||||
{showRemote ? (
|
||||
<Collapsible
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
import { useId, type ReactNode } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { InfoIcon, type LucideIcon } from 'lucide-react';
|
||||
import { Button } from './ui/button';
|
||||
import { Switch } from './ui/switch';
|
||||
|
||||
export function SetupPrivacyRow({
|
||||
title,
|
||||
icon: Icon,
|
||||
summary,
|
||||
details,
|
||||
checked,
|
||||
confirmLabel,
|
||||
declineLabel,
|
||||
disabled,
|
||||
onChange,
|
||||
children,
|
||||
testId,
|
||||
}: {
|
||||
title: string;
|
||||
icon: LucideIcon;
|
||||
summary: string;
|
||||
details: string;
|
||||
checked: boolean;
|
||||
confirmLabel?: string;
|
||||
declineLabel: string;
|
||||
disabled?: boolean;
|
||||
onChange: (enabled: boolean) => void;
|
||||
children?: ReactNode;
|
||||
testId: string;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const id = useId();
|
||||
return (
|
||||
<section
|
||||
data-testid={testId}
|
||||
className="grid grid-cols-[auto_minmax(0,1fr)_auto_auto] content-start items-center gap-x-1.5 px-3.5 py-3"
|
||||
>
|
||||
<Icon className="col-start-1 row-start-1 size-4 text-muted-foreground" aria-hidden="true" />
|
||||
<label htmlFor={id} className="col-start-2 row-start-1 cursor-pointer text-sm font-medium">
|
||||
{title}
|
||||
</label>
|
||||
<details className="contents">
|
||||
<summary
|
||||
aria-label={title + ' · ' + t('common.more_info')}
|
||||
title={t('common.more_info')}
|
||||
className="col-start-3 row-start-1 grid size-7 cursor-pointer list-none place-items-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-ring"
|
||||
>
|
||||
<InfoIcon className="size-3.5" aria-hidden="true" />
|
||||
</summary>
|
||||
<p className="order-last col-span-full pt-1.5 text-xs leading-relaxed text-muted-foreground">
|
||||
{details}
|
||||
</p>
|
||||
</details>
|
||||
<Switch
|
||||
id={id}
|
||||
aria-label={title}
|
||||
aria-describedby={id + '-summary'}
|
||||
className="col-start-4 row-start-1"
|
||||
size="sm"
|
||||
checked={checked}
|
||||
disabled={disabled}
|
||||
onCheckedChange={onChange}
|
||||
/>
|
||||
<span className="sr-only" id={id + '-summary'}>
|
||||
{summary}
|
||||
</span>
|
||||
{confirmLabel && (
|
||||
<div className="col-span-full flex flex-wrap items-center gap-2 pt-1 text-xs text-muted-foreground">
|
||||
<span className="me-auto">{summary}</span>
|
||||
{[{ label: confirmLabel, enabled: true }, { label: declineLabel, enabled: false }].map(({ label, enabled }) => (
|
||||
<Button
|
||||
key={label}
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="h-auto min-h-7 whitespace-normal"
|
||||
disabled={disabled}
|
||||
onClick={() => onChange(enabled)}
|
||||
>
|
||||
{label}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{children && <div className="order-last col-span-full">{children}</div>}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { TriangleAlertIcon } from 'lucide-react';
|
||||
import { FileDownIcon, TriangleAlertIcon } from 'lucide-react';
|
||||
import type {
|
||||
BackendStatus,
|
||||
SetupConnectionCheck as ConnectionCheckResult,
|
||||
@@ -64,6 +64,7 @@ export function SetupLogButton() {
|
||||
}
|
||||
}}
|
||||
>
|
||||
<FileDownIcon className="size-3.5" aria-hidden="true" />
|
||||
{t('setupHelp.download_log')}
|
||||
</Button>
|
||||
{failed && (
|
||||
|
||||
@@ -4,7 +4,7 @@ import { AnalyticsConsent } from './analytics-consent';
|
||||
import { AccountConsent } from './account-consent';
|
||||
import { DiagnosticConsent } from './diagnostic-consent';
|
||||
import { SetupRecovery } from './setup-recovery';
|
||||
import { useState } from 'react';
|
||||
import { useRef, useState } from 'react';
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button } from '@/components/ui/button';
|
||||
@@ -24,17 +24,17 @@ import { appearanceScales, useAppearance } from '@/hooks/use-appearance';
|
||||
import { FIRST_SOUND_EVENT } from '@/lib/first-sound';
|
||||
import { isMac } from './bridge';
|
||||
import { rememberSetupCompleted } from '@/lib/setup-progress';
|
||||
import { AudioLinesIcon, CpuIcon, SparklesIcon, ShieldCheckIcon } from 'lucide-react';
|
||||
import { ArrowUpIcon, CheckIcon } from 'lucide-react';
|
||||
|
||||
export interface SetupStatus {
|
||||
models_ready: boolean;
|
||||
missing: { repo_id: string; label: string }[];
|
||||
}
|
||||
const steps = [
|
||||
{ label: 'setup.system_check', icon: CpuIcon },
|
||||
{ label: 'models.pack_title', icon: AudioLinesIcon },
|
||||
{ label: 'settings.privacy', icon: ShieldCheckIcon },
|
||||
{ label: 'setup.enter_studio', icon: SparklesIcon },
|
||||
'setup.system_check',
|
||||
'models.pack_title',
|
||||
'settings.privacy',
|
||||
'setup.enter_studio',
|
||||
] as const;
|
||||
|
||||
/**
|
||||
@@ -52,8 +52,15 @@ export function SetupWizard({ onComplete }: { onComplete: () => void }) {
|
||||
const advanced = step === 3 ? dictationSetup : setupAdvanced;
|
||||
const setAdvanced = step === 3 ? setDictationSetup : setSetupAdvanced;
|
||||
const [family, setFamily] = useState<ModelFamily>('tts');
|
||||
const [consentRequired, setConsentRequired] = useState(true);
|
||||
const [accountChoiceRequired, setAccountChoiceRequired] = useState(false);
|
||||
const [consentRequired, setConsentRequired] = useState<boolean>();
|
||||
const [accountChoiceRequired, setAccountChoiceRequired] = useState<boolean>();
|
||||
const accountOptions = useRef<HTMLDivElement>(null);
|
||||
const analyticsOptions = useRef<HTMLDivElement>(null);
|
||||
const pendingOptions = accountChoiceRequired
|
||||
? accountOptions
|
||||
: consentRequired
|
||||
? analyticsOptions
|
||||
: null;
|
||||
const [enteringStudio, setEnteringStudio] = useState(false);
|
||||
const status = useQuery({
|
||||
queryKey: ['setup-status'],
|
||||
@@ -74,7 +81,7 @@ export function SetupWizard({ onComplete }: { onComplete: () => void }) {
|
||||
: step === 1
|
||||
? status.data?.models_ready
|
||||
: step === 2
|
||||
? !consentRequired && !accountChoiceRequired
|
||||
? consentRequired === false && accountChoiceRequired === false
|
||||
: true);
|
||||
return (
|
||||
<div className="flex h-full min-h-0 min-w-0 flex-1 flex-col">
|
||||
@@ -106,7 +113,7 @@ export function SetupWizard({ onComplete }: { onComplete: () => void }) {
|
||||
</header>
|
||||
<div className="flex min-h-0 flex-1 flex-col md:flex-row">
|
||||
<nav className="grid shrink-0 grid-cols-2 gap-1 border-b border-border/50 bg-sidebar p-3 md:flex md:w-48 md:flex-col md:border-r md:border-b-0">
|
||||
{steps.map(({ label, icon: Icon }, index) => (
|
||||
{steps.map((label, index) => (
|
||||
<Button
|
||||
key={label}
|
||||
// #2940: a long single-word label (ru "Конфиденциальность") cannot wrap at a
|
||||
@@ -119,8 +126,17 @@ export function SetupWizard({ onComplete }: { onComplete: () => void }) {
|
||||
disabled={index > step}
|
||||
onClick={() => setStep(index)}
|
||||
>
|
||||
<Icon />
|
||||
<span className="shrink-0 tabular-nums text-muted-foreground">{index + 1}.</span>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={cn(
|
||||
'grid size-6 shrink-0 place-items-center rounded-full border border-border text-xs tabular-nums text-muted-foreground',
|
||||
index === step && 'border-primary bg-primary text-primary-foreground',
|
||||
index < step && 'border-transparent bg-muted text-foreground',
|
||||
)}
|
||||
>
|
||||
{index < step ? <CheckIcon className="size-3.5" /> : index + 1}
|
||||
</span>
|
||||
<span className="sr-only">{index + 1}.</span>
|
||||
<span
|
||||
data-setup-step-label
|
||||
className="line-clamp-2 min-w-0 flex-1 hyphens-auto [overflow-wrap:anywhere]"
|
||||
@@ -135,7 +151,7 @@ export function SetupWizard({ onComplete }: { onComplete: () => void }) {
|
||||
<div className="mx-auto max-w-3xl space-y-6">
|
||||
<div className="flex flex-wrap items-center justify-between gap-3">
|
||||
<h2 className="min-w-0 flex-1 hyphens-auto text-lg font-semibold [overflow-wrap:anywhere]">
|
||||
{t(steps[step].label)}
|
||||
{t(steps[step])}
|
||||
</h2>
|
||||
<Button
|
||||
className="h-auto min-h-8 max-w-full whitespace-normal py-1.5"
|
||||
@@ -196,9 +212,22 @@ export function SetupWizard({ onComplete }: { onComplete: () => void }) {
|
||||
status.isError) && <SetupRecovery />}
|
||||
{step === 2 && (
|
||||
<>
|
||||
<AnalyticsConsent onRequirementChange={setConsentRequired} />
|
||||
<AccountConsent onRequirementChange={setAccountChoiceRequired} />
|
||||
<PrivacySettings showAnalytics={false} />
|
||||
<div ref={accountOptions} id="setup-account-options" className="empty:hidden">
|
||||
<AccountConsent onRequirementChange={setAccountChoiceRequired} />
|
||||
</div>
|
||||
<div ref={analyticsOptions} id="setup-analytics-options" className="empty:hidden">
|
||||
<AnalyticsConsent onRequirementChange={setConsentRequired} />
|
||||
</div>
|
||||
{advanced && <PrivacySettings showAnalytics={false} />}
|
||||
{canContinue && (
|
||||
<p
|
||||
role="status"
|
||||
className="flex items-center gap-2 text-sm text-muted-foreground"
|
||||
>
|
||||
<CheckIcon aria-hidden="true" className="size-4 text-primary" />
|
||||
{t('setup.privacy_ready')}
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{step === 3 && (
|
||||
@@ -232,6 +261,27 @@ export function SetupWizard({ onComplete }: { onComplete: () => void }) {
|
||||
>
|
||||
{t('setup.back')}
|
||||
</Button>
|
||||
{step === 2 && pendingOptions && (
|
||||
<button
|
||||
type="button"
|
||||
aria-controls={
|
||||
accountChoiceRequired ? 'setup-account-options' : 'setup-analytics-options'
|
||||
}
|
||||
className="ms-auto flex min-w-0 items-center gap-1.5 rounded-md px-1 text-start text-xs text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring"
|
||||
onClick={() => {
|
||||
const region = pendingOptions.current;
|
||||
const choice =
|
||||
region?.querySelector<HTMLButtonElement>('[data-consent-choice]') ??
|
||||
region?.querySelector('button');
|
||||
choice?.focus();
|
||||
}}
|
||||
>
|
||||
<ArrowUpIcon aria-hidden="true" className="size-3.5 shrink-0" />
|
||||
{t('setup.choose_to_continue', {
|
||||
section: t(accountChoiceRequired ? 'account.title' : 'consent.title'),
|
||||
})}
|
||||
</button>
|
||||
)}
|
||||
<Button
|
||||
className="h-auto min-h-8 min-w-0 max-w-[55%] whitespace-normal py-1.5 text-center"
|
||||
disabled={!canContinue}
|
||||
|
||||
@@ -7,7 +7,14 @@ type SynthesisDockProps = HTMLAttributes<HTMLDivElement> & {
|
||||
|
||||
export function SynthesisDock({ output, children, className, ...props }: SynthesisDockProps) {
|
||||
return (
|
||||
<div className={cn('z-10 mt-auto shrink-0 bg-background', className)} {...props}>
|
||||
<div
|
||||
data-slot="synthesis-dock"
|
||||
className={cn(
|
||||
'composer-surface relative z-10 mx-auto mt-auto mb-3 w-[calc(100%-1.5rem)] max-w-4xl shrink-0',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{output}
|
||||
{children}
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { cva, type VariantProps } from "class-variance-authority";
|
||||
import { cn } from "cn";
|
||||
|
||||
const alertVariants = cva(
|
||||
"group/alert relative grid w-full gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4",
|
||||
"group/alert relative grid w-full gap-0.5 rounded-field border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
|
||||
@@ -3,11 +3,11 @@ import { cva, type VariantProps } from "class-variance-authority"
|
||||
import { cn } from "cn"
|
||||
|
||||
const buttonVariants = cva(
|
||||
"group/button inline-flex shrink-0 items-center justify-center rounded-(--control-radius) border border-transparent bg-clip-padding text-sm leading-5 font-medium whitespace-nowrap transition-[color,background-color,border-color,box-shadow,opacity] outline-none select-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
"group/button inline-flex shrink-0 items-center justify-center rounded-(--control-radius) border border-transparent bg-clip-padding text-sm leading-5 font-medium whitespace-nowrap transition-[color,background-color,border-color,box-shadow,opacity,scale] motion-safe:enabled:active:scale-[0.98] outline-none select-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "border-primary bg-primary text-primary-foreground shadow-xs inset-shadow-control-highlight hover:bg-primary/90 active:shadow-none active:inset-shadow-control-pressed",
|
||||
default: "border-primary bg-primary text-primary-foreground hover:bg-primary/90 active:bg-primary/80",
|
||||
outline:
|
||||
"border-border hover:bg-input/50 hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:bg-input/30",
|
||||
secondary:
|
||||
@@ -15,7 +15,7 @@ const buttonVariants = cva(
|
||||
ghost:
|
||||
"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
||||
destructive:
|
||||
"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
||||
"bg-destructive/10 text-destructive-foreground hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/10 dark:text-[color-mix(in_oklab,var(--destructive-foreground)_80%,var(--foreground))] dark:hover:bg-destructive/15 dark:focus-visible:ring-destructive/40",
|
||||
link: "text-primary underline-offset-4 hover:underline",
|
||||
},
|
||||
size: {
|
||||
|
||||
@@ -11,7 +11,7 @@ function Card({
|
||||
data-slot="card"
|
||||
data-size={size}
|
||||
className={cn(
|
||||
"group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-lg bg-card py-(--card-spacing) text-xs/relaxed text-card-foreground ring-1 ring-border [--card-spacing:--spacing(4)] has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] *:[img:first-child]:rounded-t-lg *:[img:last-child]:rounded-b-lg",
|
||||
"group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-panel bg-card py-(--card-spacing) text-xs/relaxed text-card-foreground ring-1 ring-border [--card-spacing:--spacing(4)] has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] *:[img:first-child]:rounded-t-panel *:[img:last-child]:rounded-b-panel",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
@@ -24,7 +24,7 @@ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||
<div
|
||||
data-slot="card-header"
|
||||
className={cn(
|
||||
"group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-lg px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)",
|
||||
"group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-panel px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
@@ -80,7 +80,7 @@ function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
||||
<div
|
||||
data-slot="card-footer"
|
||||
className={cn(
|
||||
"flex items-center rounded-b-lg px-(--card-spacing) [.border-t]:pt-(--card-spacing)",
|
||||
"flex items-center rounded-b-panel px-(--card-spacing) [.border-t]:pt-(--card-spacing)",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -53,7 +53,7 @@ function DialogContent({
|
||||
<DialogPrimitive.Popup
|
||||
data-slot="dialog-content"
|
||||
className={cn(
|
||||
"fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl surface-glass p-4 text-sm text-popover-foreground ring-1 ring-border duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
||||
"fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-panel surface-glass p-4 text-sm text-popover-foreground ring-1 ring-border duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -8,7 +8,7 @@ function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
||||
type={type}
|
||||
data-slot="input"
|
||||
className={cn(
|
||||
"h-8 w-full min-w-0 rounded-md border border-input bg-input/20 px-2 py-0.5 text-sm transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
||||
"h-8 w-full min-w-0 rounded-field border border-input bg-card px-2 py-0.5 text-sm transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 md:text-sm dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -29,7 +29,7 @@ const Toaster = ({ ...props }: ToasterProps) => {
|
||||
"--normal-bg": "var(--popover)",
|
||||
"--normal-text": "var(--popover-foreground)",
|
||||
"--normal-border": "var(--border)",
|
||||
"--border-radius": "var(--radius)",
|
||||
"--border-radius": "var(--studio-field-radius)",
|
||||
} as React.CSSProperties
|
||||
}
|
||||
toastOptions={{
|
||||
|
||||
@@ -23,7 +23,7 @@ function Tabs({
|
||||
}
|
||||
|
||||
const tabsListVariants = cva(
|
||||
"group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none",
|
||||
"group/tabs-list inline-flex w-fit items-center justify-center rounded-field p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
@@ -59,7 +59,7 @@ function TabsTrigger({ className, ...props }: TabsPrimitive.Tab.Props) {
|
||||
className={cn(
|
||||
"relative inline-flex h-full flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0 text-sm leading-5 font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start group-data-vertical/tabs:py-[calc(--spacing(1.25))] hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
"group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent",
|
||||
"data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground",
|
||||
"data-active:bg-card data-active:text-foreground data-active:shadow-xs dark:data-active:border-input group-data-[variant=line]/tabs-list:data-active:shadow-none",
|
||||
"after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",
|
||||
className
|
||||
)}
|
||||
|
||||
@@ -9,7 +9,7 @@ function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
||||
// Urdu, Uyghur): let the text decide its own direction (#2810).
|
||||
dir="auto"
|
||||
className={cn(
|
||||
"flex field-sizing-content min-h-16 w-full resize-none rounded-md border border-input bg-input/20 px-2 py-2 text-sm transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
||||
"flex field-sizing-content min-h-16 w-full resize-none rounded-field border border-input bg-card px-2 py-2 text-sm transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 md:text-sm dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -42,7 +42,7 @@ export function WorkspacePane({
|
||||
data-layout={layout}
|
||||
style={{ width, maxWidth: 'calc(100% - 3rem)' }}
|
||||
className={cn(
|
||||
'workspace-pane relative flex h-full min-h-0 shrink-0 flex-col border-l border-border/55 bg-[color-mix(in_oklab,var(--muted)_13%,var(--background))] shadow-[inset_1px_0_0_color-mix(in_oklab,var(--foreground)_2%,transparent)]',
|
||||
'workspace-pane relative flex h-full min-h-0 shrink-0 flex-col',
|
||||
className,
|
||||
)}
|
||||
>
|
||||
@@ -59,7 +59,7 @@ export function WorkspacePane({
|
||||
>
|
||||
<div className="flex min-w-0 flex-1 items-center gap-2.5">
|
||||
{Icon && (
|
||||
<span className="grid size-7 shrink-0 place-items-center rounded-lg border border-border/45 bg-background/50 text-primary shadow-[inset_0_1px_0_rgb(255_255_255/7%)]">
|
||||
<span className="grid size-7 shrink-0 place-items-center rounded-lg border border-border/45 bg-card text-primary">
|
||||
<Icon aria-hidden="true" className="size-4" />
|
||||
</span>
|
||||
)}
|
||||
|
||||
@@ -216,9 +216,9 @@ export function SecondarySidebar({
|
||||
onClick={() => chooseView(value)}
|
||||
title={label}
|
||||
className={cn(
|
||||
'h-7 min-w-0 flex-1 truncate rounded-md px-2 text-xs font-medium outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring',
|
||||
'relative h-7 min-w-0 truncate rounded-sm px-2 text-sm font-medium outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring',
|
||||
view === value
|
||||
? 'bg-accent/80 text-foreground'
|
||||
? 'text-foreground after:absolute after:inset-x-2 after:bottom-0 after:h-0.5 after:rounded-full after:bg-current'
|
||||
: 'text-muted-foreground hover:bg-accent/45 hover:text-foreground',
|
||||
)}
|
||||
>
|
||||
@@ -248,7 +248,7 @@ export function SecondarySidebar({
|
||||
} as CSSProperties
|
||||
}
|
||||
className={cn(
|
||||
'secondary-sidebar relative [--pane-resize-display:flex] @max-[40rem]:[--pane-resize-display:none] flex min-h-0 shrink-0 flex-col border-r border-border/55 bg-[color-mix(in_oklab,var(--muted)_13%,var(--background))] [container-type:inline-size]',
|
||||
'secondary-sidebar relative [--pane-resize-display:flex] @max-[40rem]:[--pane-resize-display:none] flex min-h-0 shrink-0 flex-col [container-type:inline-size]',
|
||||
collapsed
|
||||
? 'w-11'
|
||||
: 'w-[var(--secondary-sidebar-width)] @max-[40rem]:max-h-[40%] @max-[40rem]:w-full @max-[40rem]:border-r-0 @max-[40rem]:border-b',
|
||||
@@ -273,7 +273,7 @@ export function SecondarySidebar({
|
||||
{!collapsed && headerTabs && tabList('flex-1')}
|
||||
{!collapsed && !headerTabs && (
|
||||
<>
|
||||
<span className="grid size-7 shrink-0 place-items-center rounded-lg border border-border/45 bg-background/50 text-primary shadow-[inset_0_1px_0_rgb(255_255_255/7%)]">
|
||||
<span className="grid size-7 shrink-0 place-items-center rounded-lg border border-border/45 bg-card text-primary">
|
||||
<Icon aria-hidden="true" className="size-4" />
|
||||
</span>
|
||||
{/* The page header already names the page top left; a same-named pane keeps
|
||||
|
||||
@@ -5,29 +5,47 @@ import type { AccountPublicState } from '../../../../preload/index.d';
|
||||
export function useAccount() {
|
||||
const account = getBridge()?.account;
|
||||
const [state, setState] = useState<AccountPublicState | undefined>();
|
||||
const [readFailed, setReadFailed] = useState(false);
|
||||
const [readAttempt, setReadAttempt] = useState(0);
|
||||
useEffect(() => {
|
||||
if (!account) return;
|
||||
let live = true;
|
||||
let receivedUpdate = false;
|
||||
void account
|
||||
.get()
|
||||
.then((s) => live && setState(s))
|
||||
.catch(() => {});
|
||||
const off = account.onState((s) => live && setState(s));
|
||||
.then((s) => live && !receivedUpdate && setState(s))
|
||||
.catch(() => live && !receivedUpdate && setReadFailed(true));
|
||||
const off = account.onState((s) => {
|
||||
if (!live) return;
|
||||
receivedUpdate = true;
|
||||
setReadFailed(false);
|
||||
setState(s);
|
||||
});
|
||||
return () => {
|
||||
live = false;
|
||||
off();
|
||||
};
|
||||
}, [account]);
|
||||
}, [account, readAttempt]);
|
||||
return {
|
||||
supported: Boolean(account),
|
||||
readFailed,
|
||||
retryRead: () => {
|
||||
setReadFailed(false);
|
||||
setReadAttempt((attempt) => attempt + 1);
|
||||
},
|
||||
state,
|
||||
loading: Boolean(account && !state && !readFailed),
|
||||
setSwitches: async (p: { accountEnabled?: boolean; syncEnabled?: boolean }) => {
|
||||
if (!account) return;
|
||||
try {
|
||||
setState(await account.setSwitches(p));
|
||||
const next = await account.setSwitches(p);
|
||||
setState(next);
|
||||
return next;
|
||||
} catch {
|
||||
// Main applies the change for this run even when saving fails; show what is real.
|
||||
setState(await account.get().catch(() => undefined));
|
||||
const next = await account.get().catch(() => undefined);
|
||||
if (next) setState(next);
|
||||
// The recovered live state cannot confirm that the choice was saved.
|
||||
}
|
||||
},
|
||||
/** Reload profile, plan and photo from VoiceStudio Cloud (Refresh, or Retry after a failure). */
|
||||
|
||||
@@ -214,7 +214,7 @@ export function BatchPage() {
|
||||
}}
|
||||
/>
|
||||
<section
|
||||
className="space-y-3 rounded-xl border border-border/60 bg-muted/20 p-3"
|
||||
className="space-y-3 studio-panel p-3"
|
||||
onDragOver={(event) => event.preventDefault()}
|
||||
onDrop={(event) => {
|
||||
event.preventDefault();
|
||||
@@ -259,7 +259,7 @@ export function BatchPage() {
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
<section className="space-y-3 rounded-xl border border-border/60 bg-muted/20 p-3">
|
||||
<section className="space-y-3 studio-panel p-3">
|
||||
<h2 className="flex items-center gap-2 text-xs font-medium text-muted-foreground">
|
||||
<LanguagesIcon className="size-4" />
|
||||
{t('batch.target_languages')}
|
||||
@@ -303,7 +303,7 @@ export function BatchPage() {
|
||||
/>
|
||||
)}
|
||||
</section>
|
||||
<section className="space-y-3 rounded-xl border border-border/60 bg-muted/20 p-3">
|
||||
<section className="space-y-3 studio-panel p-3">
|
||||
<details className="text-xs">
|
||||
<summary className="cursor-pointer font-medium">{t('batch.voice_kicker')}</summary>
|
||||
<div className="mt-2 flex flex-wrap gap-1">
|
||||
@@ -496,9 +496,9 @@ export function BatchPage() {
|
||||
const statusAppearance = {
|
||||
queued: { icon: CircleIcon, className: 'text-muted-foreground' },
|
||||
running: { icon: ActivityIcon, className: 'text-primary' },
|
||||
done: { icon: CheckCircle2Icon, className: 'text-emerald-500' },
|
||||
done: { icon: CheckCircle2Icon, className: 'text-[var(--success-foreground)]' },
|
||||
failed: { icon: AlertCircleIcon, className: 'text-destructive' },
|
||||
cancelled: { icon: SquareIcon, className: 'text-amber-500' },
|
||||
cancelled: { icon: SquareIcon, className: 'text-[var(--warning-foreground)]' },
|
||||
} satisfies Record<BatchJob['status'], { icon: typeof CircleIcon; className: string }>;
|
||||
|
||||
function BatchJobCard({
|
||||
@@ -528,7 +528,7 @@ function BatchJobCard({
|
||||
const created = formatTimestamp(job.created_at, i18n.resolvedLanguage);
|
||||
|
||||
return (
|
||||
<article className="rounded-xl border border-border/50 bg-card/20 p-4 transition-colors hover:border-border">
|
||||
<article className="studio-panel p-4 transition-colors hover:border-border">
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted/35 text-muted-foreground">
|
||||
<FilmIcon className="size-4" />
|
||||
|
||||
@@ -122,7 +122,7 @@ export function InboundSettings({
|
||||
<Link
|
||||
to="/integrations/$slug"
|
||||
params={{ slug: 'twilio' }}
|
||||
className="text-primary underline-offset-2 hover:underline"
|
||||
className="text-primary underline underline-offset-2"
|
||||
>
|
||||
{t('calls.setup_twilio')}
|
||||
</Link>
|
||||
|
||||
@@ -220,11 +220,11 @@ export function NewCallForm({
|
||||
)}
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{t('calls.voice_rule')}{' '}
|
||||
<Link to="/personas" className="text-primary underline-offset-2 hover:underline">
|
||||
<Link to="/personas" className="text-primary underline underline-offset-2">
|
||||
{t('calls.verify_voice')}
|
||||
</Link>
|
||||
{' · '}
|
||||
<Link to="/design" className="text-primary underline-offset-2 hover:underline">
|
||||
<Link to="/design" className="text-primary underline underline-offset-2">
|
||||
{t('calls.design_voice')}
|
||||
</Link>
|
||||
</p>
|
||||
@@ -295,7 +295,7 @@ export function NewCallForm({
|
||||
|
||||
<section
|
||||
aria-labelledby={`${ids}-plan`}
|
||||
className="space-y-2 rounded-xl border border-border/60 bg-muted/25 p-3 text-sm"
|
||||
className="space-y-2 studio-panel p-3 text-sm"
|
||||
>
|
||||
<h3 id={`${ids}-plan`} className="flex items-center gap-2 font-medium">
|
||||
<ShieldCheckIcon aria-hidden="true" className="size-4 text-primary" />
|
||||
|
||||
@@ -280,7 +280,7 @@ export function ActionBar({ setup: shared }: { setup?: EngineSetup } = {}) {
|
||||
const script = useCloneSetting('text');
|
||||
|
||||
return (
|
||||
<section className="@container/composer">
|
||||
<section className="@container/composer min-w-0 p-2.5">
|
||||
{needsSetup ? (
|
||||
<EngineSetupStatus setup={setup} id={readinessId} />
|
||||
) : (
|
||||
@@ -296,18 +296,18 @@ export function ActionBar({ setup: shared }: { setup?: EngineSetup } = {}) {
|
||||
onDismiss={clearError}
|
||||
/>
|
||||
)}
|
||||
{!demo && !isGenerating && <ExpressionTip />}
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<div className="flex items-center gap-1 rounded-lg bg-background/50 p-1 ring-1 ring-border/50">
|
||||
<div className="flex min-w-0 max-w-full flex-wrap items-center gap-0.5">
|
||||
<EngineLanguagePicker />
|
||||
<PresetVoicePicker />
|
||||
<span aria-hidden="true" className="mx-1 h-4 w-px bg-border" />
|
||||
<QualityControls />
|
||||
<VoiceControls />
|
||||
<EmotionControls />
|
||||
{!demo && !isGenerating && <ExpressionTip />}
|
||||
</div>
|
||||
|
||||
<div className="relative ml-auto flex max-w-full min-w-0 shrink-0 gap-2">
|
||||
<div className="relative ms-auto flex max-w-full min-w-0 flex-wrap justify-end gap-2">
|
||||
{demo ? (
|
||||
<CloneDemoAction />
|
||||
) : needsSetup ? (
|
||||
@@ -319,7 +319,7 @@ export function ActionBar({ setup: shared }: { setup?: EngineSetup } = {}) {
|
||||
) : (
|
||||
<Button
|
||||
size="lg"
|
||||
className="h-10 w-60 max-w-full shrink-0 justify-between overflow-hidden rounded-lg ps-4 pe-2.5 shadow-sm transition-colors"
|
||||
className="h-10 w-60 max-w-full min-w-0 gap-3 justify-between overflow-hidden rounded-lg ps-4 pe-2.5 shadow-sm transition-colors"
|
||||
onClick={() => void generate()}
|
||||
disabled={isGenerating || blocker !== null}
|
||||
aria-describedby={blocker ? readinessId : undefined}
|
||||
@@ -352,7 +352,7 @@ export function ActionBar({ setup: shared }: { setup?: EngineSetup } = {}) {
|
||||
{[mac ? '⌘' : 'Ctrl', '↵'].map((key) => (
|
||||
<Kbd
|
||||
key={key}
|
||||
className="h-5 min-w-5 rounded-[5px] bg-primary-foreground/15 px-1 text-[11px] text-primary-foreground/85 shadow-[inset_0_-1px_0_rgb(0_0_0/18%)]"
|
||||
className="h-5 min-w-5 rounded-[5px] bg-current/10 px-1 text-[11px] text-inherit shadow-[inset_0_-1px_0_rgb(0_0_0/18%)]"
|
||||
>
|
||||
{key}
|
||||
</Kbd>
|
||||
|
||||
@@ -215,7 +215,7 @@ export function ClonePage() {
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<Button
|
||||
variant="ghost"
|
||||
aria-label={t('cloneFlow.change_voice')}
|
||||
aria-description={t('cloneFlow.change_voice')}
|
||||
className="h-12 min-w-0 justify-start gap-2.5 px-0 hover:bg-transparent"
|
||||
onClick={() => {
|
||||
openTake(null);
|
||||
@@ -260,11 +260,7 @@ export function ClonePage() {
|
||||
</div>
|
||||
{((!choosingVoice && !savingUpload) || isGenerating) && (
|
||||
<SynthesisDock output={<OutputPanel />}>
|
||||
<div className="mx-auto w-full max-w-4xl px-6 pb-4">
|
||||
<div className="glass-panel composer-surface rounded-xl border border-border/60 bg-muted/30 p-2.5 shadow-composer dark:shadow-composer-dark">
|
||||
<ActionBar setup={setup} />
|
||||
</div>
|
||||
</div>
|
||||
<ActionBar setup={setup} />
|
||||
</SynthesisDock>
|
||||
)}
|
||||
</section>
|
||||
|
||||
@@ -16,7 +16,7 @@ it('updates allowed choices after an engine switch without rewriting the saved l
|
||||
vi.spyOn(HTMLElement.prototype, 'offsetWidth', 'get').mockReturnValue(340);
|
||||
const onValueChange = vi.fn();
|
||||
const view = render(<EngineLanguagePicker onValueChange={onValueChange} />);
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Language' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: /^Language\b/ }));
|
||||
// The saved unsupported choice stays visible rather than hiding behind "Show all languages".
|
||||
expect(await screen.findByRole('option', { name: 'Japanese' })).toBeDisabled();
|
||||
// A toggle that cannot hide the saved choice would do nothing, so none is offered.
|
||||
|
||||
@@ -13,7 +13,8 @@ describe('ExpressionTip (#3422)', () => {
|
||||
|
||||
output.result = { blob: new Blob() };
|
||||
rerender(<ExpressionTip />);
|
||||
expect(screen.getByRole('status')).toHaveTextContent(/shape the delivery with Emotion/);
|
||||
fireEvent.click(screen.getByRole('button', { name: /shape the delivery with Emotion/ }));
|
||||
expect(await screen.findByRole('status')).toHaveTextContent(/shape the delivery with Emotion/);
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Dismiss' }));
|
||||
expect(screen.queryByRole('status')).toBeNull();
|
||||
|
||||
@@ -2,7 +2,8 @@ import { LightbulbIcon, XIcon } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Store } from '@tanstack/store';
|
||||
import { useStore } from '@tanstack/react-store';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/popover';
|
||||
import { Button, buttonVariants } from '@/components/ui/button';
|
||||
import { useLatestOutput } from '@/lib/store/output';
|
||||
|
||||
const STORAGE_KEY = 'voicestudio.clone.expression-tip.v1';
|
||||
@@ -35,21 +36,32 @@ export function ExpressionTip() {
|
||||
const { result } = useLatestOutput();
|
||||
if (seen || !result) return null;
|
||||
return (
|
||||
<div
|
||||
role="status"
|
||||
className="mb-3 flex items-center gap-2 rounded-lg border border-primary/15 bg-primary/5 px-3 py-2 text-xs text-muted-foreground"
|
||||
>
|
||||
<LightbulbIcon className="size-3.5 shrink-0 text-primary" aria-hidden="true" />
|
||||
<span className="min-w-0 flex-1">{t('expression.tip')}</span>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon-xs"
|
||||
aria-label={t('common.dismiss')}
|
||||
onClick={markExpressionTipSeen}
|
||||
<Popover>
|
||||
<PopoverTrigger
|
||||
aria-label={t('expression.tip')}
|
||||
title={t('expression.tip')}
|
||||
className={buttonVariants({ variant: 'ghost', size: 'icon-sm', className: 'text-primary' })}
|
||||
>
|
||||
<XIcon aria-hidden="true" />
|
||||
</Button>
|
||||
</div>
|
||||
<LightbulbIcon aria-hidden="true" />
|
||||
</PopoverTrigger>
|
||||
<PopoverContent
|
||||
side="top"
|
||||
aria-label={t('cloneEmotion.title')}
|
||||
className="flex w-64 max-w-[var(--available-width)] items-start gap-2 p-3"
|
||||
>
|
||||
<p role="status" className="min-w-0 flex-1 text-sm">
|
||||
{t('expression.tip')}
|
||||
</p>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon-xs"
|
||||
aria-label={t('common.dismiss')}
|
||||
onClick={markExpressionTipSeen}
|
||||
>
|
||||
<XIcon aria-hidden="true" />
|
||||
</Button>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
@@ -258,7 +258,6 @@ export function LanguageMenu({
|
||||
<Popover.Trigger
|
||||
ref={trigger}
|
||||
disabled={disabled}
|
||||
aria-label={ariaLabel}
|
||||
aria-describedby={current?.disabled ? `${id}-invalid` : undefined}
|
||||
className={`inline-flex h-9 min-w-0 items-center gap-2 rounded-lg px-2.5 text-sm outline-none hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 ${buttonClassName}`}
|
||||
onKeyDown={(event) => {
|
||||
@@ -268,6 +267,7 @@ export function LanguageMenu({
|
||||
}
|
||||
}}
|
||||
>
|
||||
<span className="sr-only">{ariaLabel}</span>{' '}
|
||||
{renderValue ? renderValue(current) : current?.label || value}
|
||||
<ChevronDown className="size-3.5 shrink-0 text-muted-foreground" aria-hidden="true" />
|
||||
</Popover.Trigger>
|
||||
|
||||
@@ -17,7 +17,7 @@ it('shows language options after the popover mounts and supports filtered select
|
||||
vi.spyOn(HTMLElement.prototype, 'offsetHeight', 'get').mockReturnValue(320);
|
||||
vi.spyOn(HTMLElement.prototype, 'offsetWidth', 'get').mockReturnValue(340);
|
||||
render(<LanguagePicker />);
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Language' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: /^Language\b/ }));
|
||||
expect((await screen.findAllByRole('option', { name: 'English' })).length).toBeGreaterThan(0);
|
||||
fireEvent.change(screen.getByRole('combobox'), { target: { value: 'Japanese' } });
|
||||
fireEvent.click(await screen.findByRole('option', { name: 'Japanese' }));
|
||||
@@ -29,7 +29,7 @@ it('disables unsupported languages for pointer and keyboard selection', async ()
|
||||
vi.spyOn(HTMLElement.prototype, 'offsetWidth', 'get').mockReturnValue(340);
|
||||
const onValueChange = vi.fn();
|
||||
render(<LanguagePicker supportedOptions={['english']} onValueChange={onValueChange} />);
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Language' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: /^Language\b/ }));
|
||||
fireEvent.change(screen.getByRole('combobox'), { target: { value: 'Japanese' } });
|
||||
const japanese = await screen.findByRole('option', { name: 'Japanese' });
|
||||
expect(japanese).toBeDisabled();
|
||||
@@ -56,7 +56,7 @@ it('resets keyboard selection when the engine changes while open', async () => {
|
||||
const { rerender } = render(
|
||||
<LanguagePicker supportedOptions={['english', 'japanese']} onValueChange={onValueChange} />,
|
||||
);
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Language' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: /^Language\b/ }));
|
||||
await screen.findAllByRole('option', { name: 'English' });
|
||||
fireEvent.keyDown(screen.getByRole('combobox'), { key: 'ArrowDown' });
|
||||
fireEvent.keyDown(screen.getByRole('combobox'), { key: 'ArrowDown' });
|
||||
@@ -72,7 +72,7 @@ it('preserves keyboard selection when a refresh returns the same supported set',
|
||||
const { rerender } = render(
|
||||
<LanguagePicker supportedOptions={['english', 'japanese']} onValueChange={onValueChange} />,
|
||||
);
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Language' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: /^Language\b/ }));
|
||||
await screen.findAllByRole('option', { name: 'English' });
|
||||
fireEvent.keyDown(screen.getByRole('combobox'), { key: 'ArrowDown' });
|
||||
fireEvent.keyDown(screen.getByRole('combobox'), { key: 'ArrowDown' });
|
||||
@@ -93,7 +93,7 @@ it('commits the current search immediately, including native names and codes', a
|
||||
onValueChange={onValueChange}
|
||||
/>,
|
||||
);
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Language' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: /^Language\b/ }));
|
||||
const input = await screen.findByRole('combobox');
|
||||
fireEvent.change(input, { target: { value: 'Deutsch' } });
|
||||
expect(screen.getByRole('option', { name: 'German' })).toBeInTheDocument();
|
||||
@@ -108,7 +108,7 @@ it('ranks enabled options before disabled matches and keeps every language uniqu
|
||||
render(
|
||||
<LanguagePicker options={['Japanese', 'English', 'Japanese']} supportedOptions={['english']} />,
|
||||
);
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Language' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: /^Language\b/ }));
|
||||
const rows = await screen.findAllByRole('option');
|
||||
expect(rows.map((row) => row.getAttribute('aria-label'))).toEqual([
|
||||
'English',
|
||||
@@ -135,7 +135,7 @@ it('collapses unsupported languages behind one keyboard-reachable row', async ()
|
||||
onValueChange={onValueChange}
|
||||
/>,
|
||||
);
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Language' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: /^Language\b/ }));
|
||||
const search = await screen.findByRole('combobox');
|
||||
expect(screen.queryByRole('option', { name: 'Japanese' })).not.toBeInTheDocument();
|
||||
fireEvent.keyDown(search, { key: 'ArrowDown' });
|
||||
@@ -160,7 +160,7 @@ it('puts recent choices first under a Recent heading', async () => {
|
||||
onValueChange={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Language' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: /^Language\b/ }));
|
||||
const rows = await screen.findAllByRole('option');
|
||||
expect(rows.map((row) => row.getAttribute('aria-label'))).toEqual([
|
||||
'Auto',
|
||||
@@ -177,7 +177,7 @@ it('does not select while an IME composition is in progress', async () => {
|
||||
vi.spyOn(HTMLElement.prototype, 'offsetWidth', 'get').mockReturnValue(340);
|
||||
const onValueChange = vi.fn();
|
||||
render(<LanguagePicker onValueChange={onValueChange} />);
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Language' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: /^Language\b/ }));
|
||||
await screen.findAllByRole('option', { name: 'English' });
|
||||
const search = screen.getByRole('combobox');
|
||||
fireEvent.keyDown(search, { key: 'Enter', isComposing: true });
|
||||
@@ -201,7 +201,7 @@ it('shows a saved plain Portuguese as Brazilian and says the accent follows the
|
||||
onValueChange={onValueChange}
|
||||
/>,
|
||||
);
|
||||
const button = screen.getByRole('button', { name: 'Language' });
|
||||
const button = screen.getByRole('button', { name: /^Language\b/ });
|
||||
expect(button).toHaveTextContent('Brazilian Portuguese');
|
||||
fireEvent.click(button);
|
||||
expect(
|
||||
@@ -224,6 +224,6 @@ it('names the variant a model speaks instead of the chosen one (#3143)', async (
|
||||
onValueChange={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Language' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: /^Language\b/ }));
|
||||
expect(await screen.findByText('Kokoro speaks Brazilian Portuguese only.')).toBeInTheDocument();
|
||||
});
|
||||
@@ -22,7 +22,7 @@ export function OutputPanel() {
|
||||
return (
|
||||
<section
|
||||
aria-label={t('clone.output_title')}
|
||||
className="w-full shrink-0 border-t border-border/60 bg-muted/15 px-6 py-2"
|
||||
className="w-full min-w-0 border-b border-border/60 px-4 pt-3 pb-2"
|
||||
>
|
||||
<div className="flex flex-col gap-1.5">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
|
||||
@@ -102,7 +102,7 @@ export function SaveProfileForm({
|
||||
|
||||
return (
|
||||
<form
|
||||
className="flex flex-col gap-4 rounded-xl border border-border/60 bg-muted/20 p-5"
|
||||
className="flex flex-col gap-4 studio-panel p-5"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
@@ -96,7 +96,7 @@ export function TakeDetails({ item }: { item: HistoryItem }) {
|
||||
};
|
||||
return (
|
||||
<div className="flex flex-col gap-5">
|
||||
<section className="flex min-w-0 items-center gap-3 rounded-xl border border-border/60 bg-muted/20 p-3">
|
||||
<section className="flex min-w-0 items-center gap-3 studio-panel p-3">
|
||||
{voice ? (
|
||||
<ProfileAvatar name={voice.name} imageUrl={voice.image_url} className="size-10" />
|
||||
) : (
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useNavigate, useRouterState } from '@tanstack/react-router';
|
||||
import { PlayInDockButton } from '@/components/now-playing-dock';
|
||||
import { SaveAudioButton } from '@/components/save-audio-button';
|
||||
import { takePlaybackKind } from '@/lib/audio/playback-kind';
|
||||
import { isVoiceWorkspaceTake, takePlaybackKind } from '@/lib/audio/playback-kind';
|
||||
import { ProfileAvatar } from '@/components/profile-avatar';
|
||||
import { setWorkspace } from '@/lib/store/workspace';
|
||||
import { openTake, reuseTake, useSelectedTake } from '@/lib/store/takes';
|
||||
@@ -530,9 +530,7 @@ function RecentTakes({ scrollRef }: RecentTakesProps) {
|
||||
const [confirmClear, setConfirmClear] = useState(false);
|
||||
|
||||
const items = useMemo(() => {
|
||||
const all = (history.data ?? []).filter(
|
||||
(item) => !item.mode || item.mode === 'clone' || item.mode === 'design',
|
||||
);
|
||||
const all = (history.data ?? []).filter(isVoiceWorkspaceTake);
|
||||
if (filter === 'starred') return all.filter((item) => Boolean(item.starred));
|
||||
if (filter === 'clone') return all.filter((item) => !item.mode || item.mode === 'clone');
|
||||
if (filter === 'design') return all.filter((item) => item.mode === 'design');
|
||||
@@ -668,12 +666,12 @@ export function VoicesSidebar({
|
||||
className="flex min-h-0 flex-1 flex-col gap-0"
|
||||
>
|
||||
<div className="px-2 py-2">
|
||||
<TabsList className="flex w-full min-w-0 gap-1 bg-transparent p-0">
|
||||
<TabsList variant="line" className="flex w-full min-w-0 justify-start gap-1 border-b border-border bg-transparent p-0">
|
||||
<TabsTrigger
|
||||
value="voices"
|
||||
title={t('clone.saved_profiles')}
|
||||
aria-label={t('clone.saved_profiles')}
|
||||
className="min-w-0 flex-1 rounded-lg text-sidebar-foreground/60 hover:bg-sidebar-accent/50 data-active:bg-[var(--sidebar-row-active)] data-active:text-sidebar-foreground dark:data-active:border-transparent dark:data-active:bg-[var(--sidebar-row-active)] dark:data-active:text-sidebar-foreground"
|
||||
className="min-w-0 flex-initial rounded-md px-2 text-muted-foreground hover:text-foreground after:inset-x-2! after:bottom-0! after:rounded-full data-active:text-sidebar-foreground"
|
||||
>
|
||||
<UsersRoundIcon aria-hidden="true" />
|
||||
<span className="min-w-0 truncate">{t('clone.savedTab')}</span>
|
||||
@@ -681,8 +679,8 @@ export function VoicesSidebar({
|
||||
<TabsTrigger
|
||||
value="takes"
|
||||
title={t('clone.history_title')}
|
||||
aria-label={t('clone.history_title')}
|
||||
className="min-w-0 flex-1 rounded-lg text-sidebar-foreground/60 hover:bg-sidebar-accent/50 data-active:bg-[var(--sidebar-row-active)] data-active:text-sidebar-foreground dark:data-active:border-transparent dark:data-active:bg-[var(--sidebar-row-active)] dark:data-active:text-sidebar-foreground"
|
||||
aria-description={t('clone.history_title')}
|
||||
className="min-w-0 flex-initial rounded-md px-2 text-muted-foreground hover:text-foreground after:inset-x-2! after:bottom-0! after:rounded-full data-active:text-sidebar-foreground"
|
||||
>
|
||||
<HistoryIcon aria-hidden="true" />
|
||||
<span className="min-w-0 truncate">{t('clone.recentsTab')}</span>
|
||||
|
||||
@@ -52,7 +52,7 @@ export function DemoPresets({
|
||||
.map((preset) => (
|
||||
<article
|
||||
key={preset.id}
|
||||
className="flex min-w-0 flex-col gap-2 rounded-xl border border-border/40 bg-muted/15 p-3"
|
||||
className="flex min-w-0 flex-col gap-2 studio-panel p-3"
|
||||
>
|
||||
<h3 className="text-sm font-medium">{preset.name}</h3>
|
||||
<p className="text-xs leading-5 text-muted-foreground">{preset.description}</p>
|
||||
|
||||
@@ -60,7 +60,7 @@ export function DesignComposer({
|
||||
)
|
||||
: t('clone.synthesize');
|
||||
return (
|
||||
<div className="@container/composer mx-auto w-full max-w-4xl shrink-0 px-6 pt-3 pb-4">
|
||||
<div className="@container/composer w-full min-w-0 p-2.5">
|
||||
{needsSetup && <EngineSetupStatus setup={setup} id={statusId} />}
|
||||
{(blocker === 'design' || blocker === 'cloning') && !isGenerating && (
|
||||
<div className="mb-2.5 flex flex-wrap items-center justify-between gap-2 px-1 text-sm text-muted-foreground">
|
||||
@@ -90,10 +90,7 @@ export function DesignComposer({
|
||||
)}
|
||||
{/* Wraps instead of overlapping: the tools take their natural width and
|
||||
the action drops to its own line when the column is too narrow. */}
|
||||
<div
|
||||
data-testid="design-composer"
|
||||
className="glass-panel relative flex flex-wrap items-center gap-2 overflow-hidden rounded-xl border border-border/60 bg-muted/30 p-2.5"
|
||||
>
|
||||
<div data-testid="design-composer" className="relative flex flex-wrap items-center gap-2">
|
||||
<div className="flex min-w-0 flex-auto items-center gap-1">
|
||||
<EngineLanguagePicker operation="tts" />
|
||||
<QualityControls size="sm" disabled={isGenerating} />
|
||||
|
||||
@@ -37,6 +37,7 @@ import { useDescription } from './use-description';
|
||||
import { useFollowLatestTake } from './use-follow-latest-take';
|
||||
import { useProfiles } from '@/hooks/use-profiles';
|
||||
import { useEngines } from '@/hooks/use-engines';
|
||||
import { Spinner } from '@/components/ui/spinner';
|
||||
import { AudioPreviewButton } from '@/components/audio-preview-button';
|
||||
import { apiJson, describeError, profileAudioUrl } from '@/lib/api/client';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
@@ -64,6 +65,7 @@ import { useHistory } from '@/hooks/use-history';
|
||||
import { DESIGN_CARD, DesignDisclosure, DesignHeading } from './design-section';
|
||||
import { detailLabel, plainLabel } from './detail-labels';
|
||||
import { useGenerateClone } from '@/hooks/use-generate';
|
||||
import { SynthesisDock } from '@/components/synthesis-dock';
|
||||
import { OutputPanel } from '@/features/clone/output-panel';
|
||||
import { queryKeys } from '@/lib/query';
|
||||
import { cn } from '@/lib/utils';
|
||||
@@ -171,7 +173,7 @@ export function DesignPage() {
|
||||
// Below this width the takes pane overlays the script as a drawer instead of
|
||||
// squeezing it into a narrow column.
|
||||
const drawer =
|
||||
'@max-[76rem]:absolute @max-[76rem]:inset-y-0 @max-[76rem]:right-0 @max-[76rem]:z-30 @max-[76rem]:shadow-2xl';
|
||||
'@max-[76rem]:absolute @max-[76rem]:inset-y-0 @max-[76rem]:right-0 @max-[76rem]:z-30 @max-[76rem]:bg-background @max-[76rem]:shadow-2xl';
|
||||
const paneOpen = Boolean(editingProfile || selectedTake?.mode === 'design');
|
||||
return (
|
||||
<div className="flex h-full min-h-0 flex-col">
|
||||
@@ -426,6 +428,7 @@ export function DesignPage() {
|
||||
>
|
||||
<Input
|
||||
value={name}
|
||||
disabled={saving}
|
||||
onChange={(event) => setName(event.target.value)}
|
||||
aria-label={t('clone.profile_name')}
|
||||
placeholder={`${t('clone.profile_name')}…`}
|
||||
@@ -442,11 +445,12 @@ export function DesignPage() {
|
||||
type="submit"
|
||||
size="sm"
|
||||
className="w-full"
|
||||
aria-busy={saving}
|
||||
disabled={!name.trim() || saving || mapper.pending || generation.isGenerating}
|
||||
aria-describedby={describedBy}
|
||||
>
|
||||
<SaveIcon />
|
||||
{t('clone.save_as_profile')}
|
||||
{saving ? <Spinner aria-hidden="true" /> : <SaveIcon />}
|
||||
{t(saving ? 'common.saving' : 'clone.save_as_profile')}
|
||||
</Button>
|
||||
)}
|
||||
</DisabledReason>
|
||||
@@ -463,7 +467,7 @@ export function DesignPage() {
|
||||
<Button
|
||||
variant="ghost"
|
||||
disabled={generation.isGenerating || designProfiles.length === 0}
|
||||
aria-label={t('cloneFlow.change_voice')}
|
||||
aria-description={t('cloneFlow.change_voice')}
|
||||
className="h-12 w-fit min-w-0 max-w-full justify-start gap-2.5 px-0 hover:bg-transparent"
|
||||
onClick={() => {
|
||||
const control = savedProfilesRef.current;
|
||||
@@ -520,18 +524,18 @@ export function DesignPage() {
|
||||
/>
|
||||
<div
|
||||
data-slot="design-script"
|
||||
className="flex min-h-52 flex-1 flex-col rounded-xl border border-border/45 bg-muted/10 transition-[border-color,box-shadow] duration-150 hover:border-border/70 focus-within:border-primary/40 focus-within:ring-2 focus-within:ring-ring/20"
|
||||
className="flex min-h-52 flex-1 flex-col border-t border-border pt-3"
|
||||
>
|
||||
<label
|
||||
htmlFor="design-script"
|
||||
className="px-4 pt-3 text-xs font-medium text-muted-foreground"
|
||||
className="px-1 pt-2 text-xs font-medium text-muted-foreground"
|
||||
>
|
||||
{t('clone.text_label')}
|
||||
</label>
|
||||
<textarea
|
||||
dir="auto"
|
||||
id="design-script"
|
||||
className="min-h-32 flex-1 resize-none bg-transparent px-4 pt-1.5 pb-2 text-base leading-7 outline-none placeholder:text-muted-foreground/70"
|
||||
className="mt-1 min-h-32 flex-1 resize-none rounded-lg bg-transparent px-1 py-2 text-lg leading-8 outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"
|
||||
value={draft.text}
|
||||
placeholder={t('clone.prompt_placeholder')}
|
||||
onChange={(event) =>
|
||||
@@ -541,30 +545,31 @@ export function DesignPage() {
|
||||
}))
|
||||
}
|
||||
/>
|
||||
<span className="self-end px-4 pb-2.5 text-xs tabular-nums text-muted-foreground">
|
||||
<span className="self-end px-1 pb-2.5 text-xs tabular-nums text-muted-foreground">
|
||||
{t('clone.characters', { count: draft.text.length })}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<OutputPanel />
|
||||
<DesignComposer
|
||||
generation={generation}
|
||||
blocker={designBlocker}
|
||||
// Free-form engines take the description itself, so a mapping still
|
||||
// in flight does not hold them back.
|
||||
ready={Boolean(draft.text.trim()) && (freeform || !mapper.pending)}
|
||||
engineName={activeEngine?.display_name ?? ''}
|
||||
text={draft.text}
|
||||
onSynthesize={() =>
|
||||
void generation.generateDesign({
|
||||
text: draft.text,
|
||||
instruct: designInstruct(draft, generation.instructVocabulary),
|
||||
recipe: designRecipe(draft),
|
||||
seed: designRequestSeed(draft, activeProfile),
|
||||
profileId: activeProfile?.id ?? null,
|
||||
})
|
||||
}
|
||||
/>
|
||||
<SynthesisDock output={<OutputPanel />}>
|
||||
<DesignComposer
|
||||
generation={generation}
|
||||
blocker={designBlocker}
|
||||
// Free-form engines take the description itself, so a mapping still
|
||||
// in flight does not hold them back.
|
||||
ready={Boolean(draft.text.trim()) && (freeform || !mapper.pending)}
|
||||
engineName={activeEngine?.display_name ?? ''}
|
||||
text={draft.text}
|
||||
onSynthesize={() =>
|
||||
void generation.generateDesign({
|
||||
text: draft.text,
|
||||
instruct: designInstruct(draft, generation.instructVocabulary),
|
||||
recipe: designRecipe(draft),
|
||||
seed: designRequestSeed(draft, activeProfile),
|
||||
profileId: activeProfile?.id ?? null,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</SynthesisDock>
|
||||
</section>
|
||||
{paneOpen && (
|
||||
// Drawer mode: a click beside the pane closes it, as with any overlay.
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ChevronDownIcon, type LucideIcon } from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
/** The Design panel's one card style: same radius, padding and quiet border everywhere. */
|
||||
export const DESIGN_CARD = 'rounded-xl border border-border/40 bg-muted/15 p-3';
|
||||
export const DESIGN_CARD = 'studio-panel p-3';
|
||||
|
||||
/** A section heading row: icon, title, then whatever sits at its end. */
|
||||
export function DesignHeading({
|
||||
|
||||
@@ -108,7 +108,7 @@ export function CastingBoard({
|
||||
return (
|
||||
<details
|
||||
open={open}
|
||||
className="group rounded-xl border border-border/40 bg-muted/15 p-3"
|
||||
className="group studio-panel p-3"
|
||||
onToggle={(event) => {
|
||||
setOpen(event.currentTarget.open);
|
||||
if (!event.currentTarget.open) setDropTarget(null);
|
||||
|
||||
@@ -75,15 +75,12 @@ export function DubProgress({
|
||||
export function DubEmptyState({
|
||||
session,
|
||||
busy,
|
||||
stage,
|
||||
localPreview,
|
||||
demo,
|
||||
onChangeFile,
|
||||
}: {
|
||||
session: DubSession;
|
||||
busy: boolean;
|
||||
/** Translation key of the running stage. */
|
||||
stage: string;
|
||||
/** Object URL of the file picked in this window, when the sidebar shows no preview. */
|
||||
localPreview?: string;
|
||||
/** The sample comparison, shown only while nothing is loaded. */
|
||||
@@ -132,16 +129,12 @@ export function DubEmptyState({
|
||||
<h2 className="truncate text-base font-semibold" title={session.filename}>
|
||||
{compactSourceLabel(session.filename)}
|
||||
</h2>
|
||||
{busy ? (
|
||||
<p role="status" className="text-sm text-muted-foreground">
|
||||
{t(stage)}
|
||||
</p>
|
||||
) : issue ? (
|
||||
{!busy && issue && (
|
||||
<p role="status" className="flex items-center justify-center gap-1.5 text-sm">
|
||||
<TriangleAlertIcon aria-hidden="true" className="size-4 shrink-0 text-warning" />
|
||||
{t(DUB_INPUT_ISSUE_KEYS[issue])}
|
||||
</p>
|
||||
) : null}
|
||||
)}
|
||||
</div>
|
||||
{issue && !busy && (
|
||||
<Button size="sm" variant="outline" onClick={onChangeFile}>
|
||||
|
||||
@@ -154,7 +154,7 @@ export function DubExportPanel({ session, disabled }: { session: DubSession; dis
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<details className="group rounded-xl border border-border/40 bg-muted/15 p-3">
|
||||
<details className="group studio-panel p-3">
|
||||
<summary className="flex cursor-pointer list-none items-center gap-2 text-sm font-medium">
|
||||
<DownloadIcon className="size-4 text-muted-foreground" />
|
||||
{t('exportModal.export_options')}
|
||||
|
||||
@@ -40,6 +40,9 @@ it('inspects saved takes and waits for a deliberate start before generating anyt
|
||||
);
|
||||
const start = vi.fn();
|
||||
render(<DubGenerationReview {...props} onConfirm={start} />);
|
||||
expect(screen.getByRole('dialog', { name: 'dub.guide_audio' })).toBeTruthy();
|
||||
expect(screen.getAllByRole('heading', { name: 'dub.guide_audio' })).toHaveLength(1);
|
||||
expect(screen.getAllByText('dub.plan_mix_hint')).toHaveLength(1);
|
||||
expect(screen.getByRole('button', { name: 'dub.plan_checking' }).hasAttribute('disabled')).toBe(
|
||||
true,
|
||||
);
|
||||
|
||||
@@ -6,7 +6,6 @@ import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogDescription,
|
||||
} from '@/components/ui/dialog';
|
||||
@@ -165,12 +164,14 @@ function OpenDubGenerationReview({
|
||||
: 'dub.flow_generate_count',
|
||||
{ amount: totalNew },
|
||||
);
|
||||
const Title = inline ? 'h2' : DialogTitle;
|
||||
const Description = inline ? 'p' : DialogDescription;
|
||||
const content = (
|
||||
<div className="space-y-3">
|
||||
<div className="space-y-1">
|
||||
<h2 className="text-sm font-medium">
|
||||
<Title className="text-sm font-medium">
|
||||
{t(mixOnly ? 'dub.assemble_track' : 'dub.guide_audio')}
|
||||
</h2>
|
||||
</Title>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{t(force ? 'dub.plan_forced' : 'dub.plan_needed')}
|
||||
</p>
|
||||
@@ -249,7 +250,7 @@ function OpenDubGenerationReview({
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<p className="text-xs text-muted-foreground">{t('dub.plan_mix_hint')}</p>
|
||||
<Description className="text-xs text-muted-foreground">{t('dub.plan_mix_hint')}</Description>
|
||||
{options.preview && session.quality !== 'agent' && (
|
||||
<p className="text-xs text-muted-foreground">{t('dub.plan_preview_hint')}</p>
|
||||
)}
|
||||
@@ -282,10 +283,6 @@ function OpenDubGenerationReview({
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-lg" showCloseButton={false}>
|
||||
<DialogHeader className="sr-only">
|
||||
<DialogTitle>{t('dub.guide_audio')}</DialogTitle>
|
||||
<DialogDescription>{t('dub.plan_mix_hint')}</DialogDescription>
|
||||
</DialogHeader>
|
||||
{content}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
@@ -1109,7 +1109,7 @@ export function DubPage() {
|
||||
</section>
|
||||
)}
|
||||
{segmentPreview && segmentPreview.jobId === session.jobId && (
|
||||
<section className="space-y-2 rounded-xl border border-border/40 bg-muted/15 p-3">
|
||||
<section className="space-y-2 studio-panel p-3">
|
||||
<div className="flex items-center gap-2 text-xs font-medium">
|
||||
<HeadphonesIcon className="size-3.5 text-primary" />
|
||||
<span className="mr-auto">{t('dub.live_preview')}</span>
|
||||
@@ -1157,7 +1157,7 @@ export function DubPage() {
|
||||
/>
|
||||
</div>
|
||||
{!session.narration?.enabled && (
|
||||
<details className="group rounded-xl border border-border/40 bg-muted/15 p-3">
|
||||
<details className="group studio-panel p-3">
|
||||
<summary className="flex cursor-pointer list-none items-center gap-2 text-sm font-medium">
|
||||
<Clock3Icon className="size-4 text-muted-foreground" />
|
||||
{t('dub.timing_label')}
|
||||
@@ -1272,7 +1272,7 @@ export function DubPage() {
|
||||
</div>
|
||||
</details>
|
||||
)}
|
||||
<details className="group rounded-xl border border-border/40 bg-muted/15 p-3">
|
||||
<details className="group studio-panel p-3">
|
||||
<summary className="flex cursor-pointer list-none items-center gap-2 text-sm font-medium">
|
||||
<SlidersHorizontalIcon className="size-4 text-muted-foreground" />
|
||||
{t('clone.production_overrides')}
|
||||
@@ -1423,7 +1423,7 @@ export function DubPage() {
|
||||
data-slot="dub-complete-audio"
|
||||
className="shrink-0 border-b border-emerald-500/20 bg-emerald-500/5 px-4 py-3 space-y-2"
|
||||
>
|
||||
<p className="text-sm font-medium text-emerald-600 dark:text-emerald-400">
|
||||
<p className="text-sm font-medium text-success-foreground">
|
||||
{t('dub.flow_ready')}
|
||||
</p>
|
||||
<p className="text-xs text-muted-foreground">{t('dub.listen_saved_hint')}</p>
|
||||
@@ -1942,7 +1942,6 @@ export function DubPage() {
|
||||
<DubEmptyState
|
||||
session={session}
|
||||
busy={busy}
|
||||
stage={stage}
|
||||
localPreview={
|
||||
localSource?.name === session.filename &&
|
||||
['idle', 'preparing'].includes(session.phase)
|
||||
@@ -2257,7 +2256,7 @@ export function DubPage() {
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
className={cn(
|
||||
'h-6 min-w-0 max-w-[14rem] justify-start px-1 text-[11px] font-medium tracking-[0.01em] text-muted-foreground/55 hover:text-foreground group-hover/segment:text-muted-foreground/75 group-focus-within/segment:text-foreground/85',
|
||||
'h-6 min-w-0 max-w-[14rem] justify-start px-1 text-[11px] font-medium tracking-[0.01em] text-muted-foreground hover:text-foreground group-hover/segment:text-foreground group-focus-within/segment:text-foreground/85',
|
||||
selectedSegmentId === segment.id && 'text-foreground/85',
|
||||
)}
|
||||
aria-expanded={expandedSegmentId === segment.id}
|
||||
@@ -2289,7 +2288,7 @@ export function DubPage() {
|
||||
{segment.text_original && segment.text_original !== segment.text ? (
|
||||
<p
|
||||
className={cn(
|
||||
'min-w-0 flex-1 px-1 text-xs text-muted-foreground/50 transition-colors group-hover/segment:text-muted-foreground/70 group-focus-within/segment:text-foreground/70',
|
||||
'min-w-0 flex-1 px-1 text-xs text-muted-foreground transition-colors group-hover/segment:text-foreground group-focus-within/segment:text-foreground/70',
|
||||
selectedSegmentId === segment.id && 'text-foreground/72',
|
||||
// Show the whole line while it holds the active find hit.
|
||||
find.holdsActive(segment.id, 'text_original')
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { ReactNode } from 'react';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
/** The Dubbing panel's card: same radius, padding and quiet border as the Design panel. */
|
||||
export const DUB_CARD = 'rounded-xl border border-border/40 bg-muted/15 p-3';
|
||||
export const DUB_CARD = 'studio-panel p-3';
|
||||
|
||||
/** A numbered step heading with an optional action at its end. */
|
||||
export function DubStepHeading({
|
||||
|
||||
@@ -79,7 +79,6 @@ it('replaces the welcome placeholder with the loaded source and its status', ()
|
||||
<DubEmptyState
|
||||
session={session({ inputIssue: 'no_audio' })}
|
||||
busy={false}
|
||||
stage="dub.prep_preparing"
|
||||
onChangeFile={onChangeFile}
|
||||
/>,
|
||||
);
|
||||
@@ -96,7 +95,6 @@ it('keeps the placeholder only while nothing is loaded', () => {
|
||||
<DubEmptyState
|
||||
session={session({ jobId: null, filename: '' })}
|
||||
busy={false}
|
||||
stage=""
|
||||
onChangeFile={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
@@ -117,11 +115,12 @@ it('labels subtitle-first preparation without claiming to transcribe or translat
|
||||
} as DubSession
|
||||
}
|
||||
busy
|
||||
stage="dub.preparing"
|
||||
onChangeFile={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
expect(screen.queryByText('dub.upload_transcribe')).toBeNull();
|
||||
expect(screen.getByText('dub.prepare_project')).toBeTruthy();
|
||||
expect(screen.getByText('dub.prepare_project').closest('[aria-current="step"]')).toBeTruthy();
|
||||
// The page footer announces preparation progress while the source panel shows the steps.
|
||||
expect(screen.queryByRole('status')).toBeNull();
|
||||
expect(screen.getByText('dub.srt_in_target')).toBeTruthy();
|
||||
});
|
||||
@@ -17,9 +17,9 @@ it('keeps short segments proportional on long recordings and offers zoom', () =>
|
||||
expect(parseFloat(options[0].style.width)).toBeCloseTo(100 / 1980, 4);
|
||||
expect(parseFloat(options[0].style.width)).toBeLessThan(parseFloat(options[1].style.left));
|
||||
fireEvent.click(screen.getByRole('button', { name: 'trimmer.zoom_in' }));
|
||||
expect(screen.getByRole('listbox').style.width).toBe('200%');
|
||||
expect(screen.getByRole('listbox', { name: 'segmentEditing.timeline' }).style.width).toBe('200%');
|
||||
fireEvent.click(screen.getByRole('button', { name: 'trimmer.fit_all' }));
|
||||
expect(screen.getByRole('listbox').style.width).toBe('100%');
|
||||
expect(screen.getByRole('listbox', { name: 'segmentEditing.timeline' }).style.width).toBe('100%');
|
||||
});
|
||||
it('snaps to an onset with S but leaves Mod+S and Alt+S alone', () => {
|
||||
render(<DubTimeline segments={[{id:'a',start:0.2,end:1,text:'a',text_original:'a'}]}
|
||||
|
||||
@@ -325,7 +325,7 @@ export function DubTimeline({
|
||||
return (
|
||||
<section
|
||||
aria-label={t('segmentEditing.timeline')}
|
||||
className="rounded-xl border border-border/60 bg-card/35 p-3 shadow-sm [@media(max-height:700px)]:p-2"
|
||||
className="studio-panel p-3 shadow-sm [@media(max-height:700px)]:p-2"
|
||||
>
|
||||
<div className="mb-2 flex justify-end gap-1">
|
||||
<Button
|
||||
@@ -360,6 +360,7 @@ export function DubTimeline({
|
||||
ref={host}
|
||||
style={{ width: `${zoom * 100}%` }}
|
||||
role="listbox"
|
||||
aria-label={t('segmentEditing.timeline')}
|
||||
aria-orientation="horizontal"
|
||||
onClick={(event) => {
|
||||
if ((event.target as HTMLElement).closest('[data-timeline-segment]')) return;
|
||||
|
||||
Loaded 100 of 311 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user