[JJC-20260618-005-B] Fix 6 critical bugs from review
- BUG-1: Restore KeyboardRootView top highlight + divider - BUG-2: App Group unavailable -> friendly error view (no fatalError) - BUG-3: pressBegan race condition (sync phase to .requestingPermissions) - BUG-4: cancelled LLMError no longer re-inserts original text - BUG-6: mode switch during recording flushes partial - ARCH-A1: State.Phase add .requestingPermissions + .denied(Reason) Notes: - 8/8 tests pass (LLMClientTests) - BUILD SUCCEEDED for both OSGKeyboard and OSGKeyboardExt - New file AppGroupErrorView.swift auto-registered via XcodeGen - Info.plist left untouched (NSSpeechRecognitionUsageDescription kept from A block)
This commit is contained in:
@@ -11,12 +11,14 @@ struct OSGKeyboardApp: App {
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
ThemedRoot {
|
||||
Group {
|
||||
if AppGroup.isAvailable {
|
||||
if config.isConfigured {
|
||||
HomeView()
|
||||
} else {
|
||||
OnboardingView(config: config)
|
||||
}
|
||||
} else {
|
||||
AppGroupErrorView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
// AppGroupErrorView.swift
|
||||
// OSGKeyboard · Main App
|
||||
//
|
||||
// Shown in place of the normal Home/Onboarding flow when the App Group
|
||||
// container is not configured. The whole app is unusable without it (the
|
||||
// keyboard extension and the main app cannot share state), so we don't
|
||||
// try to be clever — we show a clear, actionable error and stop.
|
||||
//
|
||||
// We deliberately do NOT fatalError in release: the developer might be
|
||||
// running a TestFlight build with a stripped entitlement, and a friendly
|
||||
// screen is much better than a crash loop.
|
||||
|
||||
import SwiftUI
|
||||
import OSGKeyboardShared
|
||||
|
||||
struct AppGroupErrorView: View {
|
||||
var body: some View {
|
||||
VStack(spacing: Spacing.lg) {
|
||||
Image(systemName: "exclamationmark.triangle.fill")
|
||||
.font(.system(size: 48))
|
||||
.foregroundStyle(Palette.danger)
|
||||
Text("App Group 未配置")
|
||||
.font(TypeStyle.title2)
|
||||
Text("OSGKeyboard 需要 App Group 才能在键盘扩展和主 App 之间共享配置。")
|
||||
.font(TypeStyle.body)
|
||||
.multilineTextAlignment(.center)
|
||||
.foregroundStyle(Palette.textSecondary)
|
||||
VStack(alignment: .leading, spacing: Spacing.sm) {
|
||||
Label("在 Apple Developer 后台创建 group.com.osgkeyboard.shared", systemImage: "1.circle")
|
||||
Label("主 App 和键盘扩展都启用该 App Group", systemImage: "2.circle")
|
||||
Label("重新生成 provisioning profile 并下载", systemImage: "3.circle")
|
||||
}
|
||||
.font(TypeStyle.body)
|
||||
.foregroundStyle(Palette.textPrimary)
|
||||
}
|
||||
.padding(Spacing.lg)
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
#Preview {
|
||||
ThemedRoot {
|
||||
AppGroupErrorView()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user