537a68552a
Reduce perceived latency from key release to final text: - Adaptive chunking: 2.5s first chunk + 5s follow-ups so short utterances start on-device recognition while still recording. - Session-level ASR warmup and audio-format cache reuse to remove per-utterance cold-start of SpeechAnalyzer. - Mirror live pipelined partials to the keyboard transcript line via a new flow.transcriptionPartial App Group key + Darwin ping. Also commits the accumulated custom language model, Flow session, keyboard extension restructure, and Xiaomi MiMo provider work in progress on this branch.
55 lines
1.6 KiB
Swift
55 lines
1.6 KiB
Swift
// MainAppRoot.swift
|
||
// OSGKeyboard · Main App
|
||
//
|
||
// Host-app shell that owns `ProviderConfig` and `FlowSessionManager`.
|
||
// Only constructed when `AppGroup.isAvailable` so the error path never
|
||
// touches App Group–backed singletons.
|
||
|
||
import SwiftUI
|
||
import OSGKeyboardShared
|
||
|
||
struct MainAppRoot: View {
|
||
@Environment(\.scenePhase) private var scenePhase
|
||
|
||
@StateObject private var config = ProviderConfig.shared
|
||
@StateObject private var flowManager = FlowSessionManager()
|
||
|
||
var body: some View {
|
||
Group {
|
||
if config.hasCompletedOnboarding {
|
||
MainTabView()
|
||
} else {
|
||
OnboardingView(config: config)
|
||
}
|
||
}
|
||
.environment(\.locale, config.uiLanguage.swiftUILocale)
|
||
.environmentObject(flowManager)
|
||
.onAppear {
|
||
flowManager.setAppForeground(scenePhase == .active)
|
||
}
|
||
.onOpenURL { url in
|
||
guard url.scheme == "osgkeyboard" else { return }
|
||
switch url.host {
|
||
case "startflow":
|
||
flowManager.startSession()
|
||
default:
|
||
break
|
||
}
|
||
}
|
||
.onChange(of: config.hasCompletedOnboarding) { _, done in
|
||
if done {
|
||
flowManager.autoStartIfNeeded()
|
||
}
|
||
}
|
||
.onChange(of: scenePhase) { _, phase in
|
||
flowManager.handleScenePhase(phase)
|
||
guard phase == .active, config.hasCompletedOnboarding else { return }
|
||
if flowManager.isActive {
|
||
flowManager.extendSession()
|
||
} else {
|
||
flowManager.autoStartIfNeeded()
|
||
}
|
||
}
|
||
}
|
||
}
|