1111 * gracefully when the server endpoints aren't live (I2 may not have landed).
1212 */
1313
14- import * as React from "react" ;
1514import { Capacitor } from "@capacitor/core" ;
15+ import * as React from "react" ;
1616import type {
1717 CatalogModel ,
1818 DownloadJob ,
@@ -28,11 +28,11 @@ import { IOS_LOCAL_AGENT_IPC_BASE } from "../../onboarding/mobile-runtime-mode";
2828import type { VoicePrefixStep } from "../../onboarding/voice-prefix" ;
2929import { selectRecommendedModelForSlot } from "../../services/local-inference/recommendation" ;
3030import { toArrayBuffer } from "../../voice/voice-chat-types" ;
31+ import { Button } from "../ui/button" ;
3132import {
32- VoicePrefixSteps ,
3333 type VoiceBundleReadiness ,
34+ VoicePrefixSteps ,
3435} from "./VoicePrefixSteps" ;
35- import { Button } from "../ui/button" ;
3636
3737export interface VoicePrefixGateProps {
3838 /** Called when the user completes or skips the voice prefix flow. */
@@ -163,9 +163,11 @@ function downloadReadiness(
163163function voiceBundleReadinessFromHub (
164164 hub : ModelHubSnapshot ,
165165) : VoiceBundleReadiness {
166- const voiceReadiness = ( hub as ModelHubSnapshot & {
167- voiceReadiness ?: LocalVoiceReadinessSnapshot ;
168- } ) . voiceReadiness ;
166+ const voiceReadiness = (
167+ hub as ModelHubSnapshot & {
168+ voiceReadiness ?: LocalVoiceReadinessSnapshot ;
169+ }
170+ ) . voiceReadiness ;
169171 const model = selectRecommendedModelForSlot (
170172 "TEXT_SMALL" ,
171173 hub . hardware ,
@@ -292,7 +294,9 @@ function voiceBundleStatusBadge(readiness: VoiceBundleReadiness): string {
292294 }
293295}
294296
295- function diagnosticsText ( diagnostics : NativeLocalTtsDiagnostics | null ) : string {
297+ function diagnosticsText (
298+ diagnostics : NativeLocalTtsDiagnostics | null ,
299+ ) : string {
296300 if ( ! diagnostics ) return "" ;
297301 return JSON . stringify ( diagnostics , null , 2 ) . slice ( 0 , 6_000 ) ;
298302}
@@ -326,8 +330,12 @@ async function loadNativeIosLocalTtsStatus(): Promise<VoiceBundleReadiness | nul
326330 if ( ! nativeIosLocalTtsEnabled ( ) ) return null ;
327331 const { ElizaBunRuntime } = await import ( "@elizaos/capacitor-bun-runtime" ) ;
328332 if ( typeof ElizaBunRuntime . getLocalTtsStatus !== "function" ) return null ;
329- const status = ( await ElizaBunRuntime . getLocalTtsStatus ( ) ) as NativeLocalTtsStatus ;
330- if ( status . ready && ( status . status === "engine-ready" || status . status === "ready" ) ) {
333+ const status =
334+ ( await ElizaBunRuntime . getLocalTtsStatus ( ) ) as NativeLocalTtsStatus ;
335+ if (
336+ status . ready &&
337+ ( status . status === "engine-ready" || status . status === "ready" )
338+ ) {
331339 return {
332340 modelId : status . modelId ?? "" ,
333341 status : "engine-ready" ,
@@ -377,7 +385,9 @@ async function synthesizeNativeIosLocalTts(
377385) : Promise < NativeLocalTtsResult > {
378386 const { ElizaBunRuntime } = await import ( "@elizaos/capacitor-bun-runtime" ) ;
379387 if ( typeof ElizaBunRuntime . synthesizeLocalTts !== "function" ) {
380- throw new Error ( "This build is missing the iOS local voice playback engine." ) ;
388+ throw new Error (
389+ "This build is missing the iOS local voice playback engine." ,
390+ ) ;
381391 }
382392 return ElizaBunRuntime . synthesizeLocalTts ( {
383393 text,
@@ -524,7 +534,7 @@ export function VoicePrefixGate({
524534 alive = false ;
525535 window . clearInterval ( interval ) ;
526536 } ;
527- } , [ refreshVoiceBundleReadiness ] ) ;
537+ } , [ ] ) ;
528538
529539 const handleAdvance = React . useCallback (
530540 ( next : VoicePrefixStep | null ) => {
@@ -565,32 +575,35 @@ export function VoicePrefixGate({
565575 }
566576 } , [ ] ) ;
567577
568- const handleNativeTtsDiagnostics = React . useCallback ( async ( probe : boolean ) => {
569- setLocalTtsDiagnosticBusy ( true ) ;
570- try {
571- const diagnostics = await diagnoseNativeIosLocalTts ( probe ) ;
572- setLocalTtsDiagnostics ( diagnostics ) ;
573- if ( diagnostics . probe ?. ok === true ) {
574- setVoiceBundleReadiness ( ( current ) => ( {
575- ...current ,
576- status : "engine-ready" ,
577- message : "Voice engine is warmed and ready." ,
578- percent : 100 ,
579- canStartDownload : false ,
580- } ) ) ;
578+ const handleNativeTtsDiagnostics = React . useCallback (
579+ async ( probe : boolean ) => {
580+ setLocalTtsDiagnosticBusy ( true ) ;
581+ try {
582+ const diagnostics = await diagnoseNativeIosLocalTts ( probe ) ;
583+ setLocalTtsDiagnostics ( diagnostics ) ;
584+ if ( diagnostics . probe ?. ok === true ) {
585+ setVoiceBundleReadiness ( ( current ) => ( {
586+ ...current ,
587+ status : "engine-ready" ,
588+ message : "Voice engine is warmed and ready." ,
589+ percent : 100 ,
590+ canStartDownload : false ,
591+ } ) ) ;
592+ }
593+ } catch ( err ) {
594+ setLocalTtsDiagnostics ( {
595+ available : false ,
596+ message :
597+ err instanceof Error
598+ ? err . message
599+ : "Failed to run local voice diagnostics." ,
600+ } ) ;
601+ } finally {
602+ setLocalTtsDiagnosticBusy ( false ) ;
581603 }
582- } catch ( err ) {
583- setLocalTtsDiagnostics ( {
584- available : false ,
585- message :
586- err instanceof Error
587- ? err . message
588- : "Failed to run local voice diagnostics." ,
589- } ) ;
590- } finally {
591- setLocalTtsDiagnosticBusy ( false ) ;
592- }
593- } , [ ] ) ;
604+ } ,
605+ [ ] ,
606+ ) ;
594607
595608 React . useEffect ( ( ) => {
596609 if ( ! nativeIosLocalTtsEnabled ( ) || autoDiagnosticStartedRef . current ) return ;
@@ -836,11 +849,11 @@ function VoiceBundleStatusStrip({
836849 ? Math . max ( 0 , Math . min ( 100 , readiness . percent ) )
837850 : null ;
838851 const showProgress =
839- ( readiness . status === "queued" ||
840- readiness . status === "downloading" ||
841- readiness . status === "assets-ready" ||
842- readiness . status === "engine-ready" ||
843- readiness . status === "ready" ) ;
852+ readiness . status === "queued" ||
853+ readiness . status === "downloading" ||
854+ readiness . status === "assets-ready" ||
855+ readiness . status === "engine-ready" ||
856+ readiness . status === "ready" ;
844857 const progressWidth =
845858 percent !== null
846859 ? `${ percent } %`
0 commit comments