From 3102dee9da9baaa786250bba282064d46d59b8f1 Mon Sep 17 00:00:00 2001 From: UtkarshUsername Date: Thu, 5 Nov 2026 20:24:50 +0530 Subject: [PATCH 1/7] fix(web): place voice tests beside their settings --- .../settings/VoiceSettingsPanel.tsx | 291 ++++++++++-------- 1 file changed, 162 insertions(+), 129 deletions(-) diff --git a/apps/web/src/components/settings/VoiceSettingsPanel.tsx b/apps/web/src/components/settings/VoiceSettingsPanel.tsx index 75823d74f2977..35da3046369dc 100644 --- a/apps/web/src/components/settings/VoiceSettingsPanel.tsx +++ b/apps/web/src/components/settings/VoiceSettingsPanel.tsx @@ -34,7 +34,7 @@ import { Trash2Icon, XIcon, } from "lucide-react"; -import { useEffect, useRef, useState } from "react"; +import { useEffect, useRef, useState, type ReactNode } from "react"; import { useStableCallback } from "~/hooks/useStableCallback"; import { listBrowserMicrophones, type BrowserMicrophone } from "../../speech/browserMicrophones"; @@ -57,7 +57,7 @@ import { useEnvironmentSpeechInput, useVoiceTranscriptionDestination, } from "../../speech/useEnvironmentSpeechInput"; -import { ComposerSpeechButton, ComposerSpeechRecordingPill } from "../chat/ComposerSpeechButton"; +import { ComposerSpeechRecordingPill } from "../chat/ComposerSpeechButton"; import { ProviderModelPicker } from "../chat/ProviderModelPicker"; import { TraitsPicker } from "../chat/TraitsPicker"; import { VoiceInputSetup } from "../chat/VoiceInputSetup"; @@ -75,6 +75,7 @@ import { SettingResetButton, SettingsPageContainer, SettingsRow, + SettingsSearchTarget, SettingsSection, } from "./settingsLayout"; import { searchableSetting } from "./settingsSearch"; @@ -113,7 +114,7 @@ const modelSortOrder = (model: EnvironmentSpeechModel) => { return model.recommended ? 3 : 4; }; -function ModelCard(props: { +type ModelCardProps = { readonly model: EnvironmentSpeechModel; readonly busy: boolean; readonly canCancel: boolean; @@ -121,12 +122,16 @@ function ModelCard(props: { readonly onSelect: () => void; readonly onCancel: () => void; readonly onDelete: () => void; -}) { + readonly testControls?: ReactNode; + readonly children?: ReactNode; +}; + +function ModelCard(props: ModelCardProps) { const { model } = props; const downloading = model.state === "downloading" || model.state === "verifying"; const progress = model.downloaded === undefined ? 0 : (model.downloaded / model.size) * 100; return ( -
+
{model.name} @@ -180,7 +185,7 @@ function ModelCard(props: {
) : null}
-
+
{downloading ? (
+ {props.children}
); } @@ -485,6 +492,9 @@ function EnvironmentModelsSection(props: { readonly prepared: PreparedConnection; readonly status: EnvironmentSpeechStatus | null; readonly onStatus: (connection: PreparedConnection, status: EnvironmentSpeechStatus) => void; + readonly testEnvironmentId: EnvironmentId; + readonly projectId: ProjectId | null; + readonly projectName: string | null; }) { const { prepared, status, onStatus } = props; const canManage = useEnvironmentScope(prepared.environmentId, AuthSettingsWriteScope); @@ -702,40 +712,45 @@ function EnvironmentModelsSection(props: {

No matching models.

) : null}
- {sortedModels.map((model) => ( - { + const card: ModelCardProps = { + model: model.id === requestedDownload && model.state === "downloadable" ? { ...model, state: "downloading" } - : model - } - busy={controlsDisabled} - canCancel={canManage && !busy} - onDownload={() => + : model, + busy: controlsDisabled, + canCancel: canManage && !busy, + onDownload: () => void run( "Could not download the model", () => runtime.runPromise(downloadEnvironmentSpeechModel(prepared, model.id)), model.id, - ) - } - onSelect={() => + ), + onSelect: () => void run("Could not select the model", () => runtime.runPromise(selectEnvironmentSpeechModel(prepared, model.id)), - ) - } - onCancel={() => + ), + onCancel: () => void run("Could not cancel the download", () => runtime.runPromise(cancelEnvironmentSpeechModelDownload(prepared, model.id)), - ) - } - onDelete={() => + ), + onDelete: () => void run("Could not delete the model", () => runtime.runPromise(removeEnvironmentSpeechModel(prepared, model.id)), - ) - } - /> - ))} + ), + }; + return model.active ? ( + + ) : ( + + ); + })}
) : null} @@ -748,12 +763,13 @@ function EnvironmentModelsSection(props: { * never the cleanup provider: this checks the model, the loopback test checks the mic. */ function TranscriptionTest(props: { + readonly card: ModelCardProps; readonly environmentId: EnvironmentId; readonly projectId: ProjectId | null; readonly projectName: string | null; - readonly modelName: string | null; }) { const [draft, setDraft] = useState(""); + const [showTranscript, setShowTranscript] = useState(false); const draftRef = useRef(draft); // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- publishes the committed draft to the asynchronous transcription controller useEffect(() => { @@ -773,51 +789,79 @@ function TranscriptionTest(props: { commitDraft: (text) => setDraft(text), }); return ( - - void speech.start()} - onStop={() => void speech.stop()} - onCancel={() => speech.cancel()} - onSkipPostProcessing={() => speech.skipPostProcessing()} - /> - {speech.available ? ( - + + void speech.start()} + onStop={() => void speech.stop()} onCancel={() => speech.cancel()} + onSkipPostProcessing={() => speech.skipPostProcessing()} /> - ) : ( - - {speech.status?.supported === false - ? speech.status.reason - : "Waiting for the environment"} - - )} -
- } - > - {speech.preview ? ( -

- {speech.preview.committed} - {speech.preview.tentative} -

- ) : null} -