Files
OSGKeyboard/OSGKeyboard/Views/ManagedServiceActivation.swift
T
Rocky 4dce67df84 chore(release): bump version to 2.1.6 (build 131)
Version: CURRENT_PROJECT_VERSION 130 -> 131 (project.yml, AGENTS.md, READMEs,
docs/llms.txt).

fix(flow): host-app identification now compiles in every build configuration
(Debug, TestFlight, Release). The arbiter probe and HostAppIdentity were
DEBUG-only, so TestFlight/App Store builds never knew the host bundle id and
could not auto-return after a startflow handoff. Debug-only logging and the
Home test card are unchanged.

Also includes the pending work in the tree:
- Home: single account/setup card surface (HomeAccountSurfacePolicy/Views)
- Wide screens: voice key row and centred mic placement, iPhone Duo layout
- Keyboard: clipboard skill ranking and AI skill layout updates
- Debug: account session handoff to the Simulator (+ import script)
- Docs: portfolio assets, privacy policy URL, site/README refresh
2026-10-29 11:54:13 +08:00

52 lines
1.7 KiB
Swift

// ManagedServiceActivation.swift
// OSGKeyboard · Main App
//
// Switching to OSG credits always passes the cloud-sharing consent before the
// managed gateway is prepared. Settings and Home share this path so neither
// can enable credits without the disclosure.
import OSGKeyboardShared
import SwiftUI
@MainActor
enum ManagedServiceActivation {
/// Prepares the managed gateway, then routes recognition and polish
/// through OSG credits. Returns false when the gateway is unavailable.
@discardableResult
static func activate(
config: ProviderConfig,
accountSession: AccountSessionCoordinator
) async -> Bool {
guard await accountSession.prepareManagedGateway() else { return false }
withAnimation(Motion.quick) {
config.engineMode = "cloud"
config.modeId = "polish"
config.credentialSource = .managed
}
return true
}
}
extension View {
/// Consent alert shown before the first switch to OSG credits.
func managedCloudConsentAlert(
isPresented: Binding<Bool>,
config: ProviderConfig,
onAccept: @escaping () -> Void
) -> some View {
alert(
AppL10n.string("settings.aiService.credits.consent.title"),
isPresented: isPresented
) {
Button(AppL10n.string("common.cancel"), role: .cancel) {}
Button(AppL10n.string("settings.aiService.credits.consent.accept")) {
config.hasAcknowledgedCloudSharing = true
onAccept()
}
.accessibilityIdentifier("settings.aiService.credits.consent.accept")
} message: {
Text(AppL10n.string("settings.aiService.credits.consent.message"))
}
}
}