hex/ios/HEXMobile/HEXMobileApp.swift
Ryan Vogel 843122d24e
iOS: Home card for Hex's own speech model, and Speech model in keyboard moves to Settings › Dictation (#2437)
* iOS: Home shows a card about Hex's own speech model and where its download stands

What changed
- SpeechModelHomeCard on Home, above the Paste card and in its style: "New: Hex's own speech
  model", "English dictation, right in the keyboard.", then KeyboardParakeetStatus (the
  same waiting, downloading, downloaded, getting ready and ready lines as Settings ›
  Experiments). Shown only while the switch is on, the iPhone fits and no hold says the
  keyboard never will use it (another engine, not English, a keyboard too small). Once ready
  it can be dismissed; the dismissal is kept in the App Group and the card never returns.
- --snap-state model-card-waiting|downloading|ready fixtures for simulator screenshots.
- Two new strings, with Simplified Chinese; every status line is an existing one.

Why
- Ryan asked whether 1.0.3 tells people to try the new model: the only mention was the switch
  under Settings › Experiments.

Verified
- DictationControllerTests: shown while waiting (each hold that clears), downloading or ready;
  not with the switch off, under 6 GB, not English, another engine or a keyboard too small;
  dismissed stays dismissed. Studio suite and screenshots are in the pull request.

* iOS: Speech model in keyboard moves from Settings › Experiments to Settings › Dictation

What changed
- The switch, its detail line and its status line (KeyboardParakeetStatus) leave the
  Experiments page and sit on the Dictation page in a card of their own, directly above the
  keyboard's live-words card (Show what I say, Type as I speak), below the card with Numbers
  as digits. Its own card because its status line sits under it, and it shows on every iOS
  while the live-words card is iOS 26 only.
- Home's card is now a tap target that opens Settings › Dictation (a chevron until it's ready,
  then the dismiss button), and its status line is drawn without a second box inside it.
- Comments and README that sent a reader to Experiments › Speech model in keyboard now name
  Settings › Dictation; README calls it "the switch", not "the experiment".
- Removed from ExperimentsSettingsPage: the row, its state and its onChange, moved unchanged
  into DictationSettingsPage.

Why
- Ryan: "Move it out of Experiments, please. Put it in Settings, Dictation."

Not changed
- The setting: same App Group key (experiments.keyboardParakeet), same default (on for English
  where the keyboard can use it), same turned-on-by-hand meaning, same download rules; a
  switch turned off stays off.

Verified
- Studio suite on the rebased head and simulator screenshots of both pages are in the pull
  request.
2026-11-22 18:03:28 -05:00

85 lines
3.8 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import SwiftUI
import UIKit
@main
struct HEXMobileApp: App {
@Environment(\.scenePhase) private var scenePhase
@State private var dictation = DictationController.shared
@State private var openedFromKeyboard = Self.initialOpenedFromKeyboard
@State private var showSetup = SettingsSnapshotFixture.showsSetupSheet
@State private var openPage: SettingsPage?
init() {
FullKeyboardSettings().applyLaunchArguments()
TypingLogSettings().turnOffOnce()
TypingLogSettings().applyLaunchArguments()
HinglishSettings().applyLaunchArguments()
GreeklishSettings().applyLaunchArguments()
TwoLanguageDictationSettings().applyLaunchArguments()
VoiceIsolationSettings().applyLaunchArguments()
MultilingualParakeetSettings().applyLaunchArguments()
KeyboardParakeetSettings().applyLaunchArguments()
SettingsSnapshotFixture.applyDefaults()
}
private static var initialOpenedFromKeyboard: Bool {
let args = ProcessInfo.processInfo.arguments
guard let idx = args.firstIndex(of: "--snap-state"), idx + 1 < args.count else {
return false
}
return args[idx + 1].hasPrefix("handoff-")
}
var body: some Scene {
WindowGroup {
if ProcessInfo.processInfo.environment["XCTestConfigurationFilePath"] != nil {
Color.clear
} else if let keyboardScene = KeyboardSnapshotStage.requestedScene {
KeyboardSnapshotStage(scene: keyboardScene)
} else if let fullKeyboardScene = FullKeyboardSnapshotStage.requestedScene {
FullKeyboardSnapshotStage(scene: fullKeyboardScene)
} else if let experimentsScene = ExperimentsSnapshotStage.requestedScene {
ExperimentsSnapshotStage(scene: experimentsScene)
} else if let hostedScene = HostedKeyboardConversationStage.requestedScene {
HostedKeyboardConversationStage(scene: hostedScene, dictation: dictation)
} else {
ContentView(
dictation: dictation,
openedFromKeyboard: $openedFromKeyboard,
showSetup: $showSetup,
openPage: $openPage
)
.onOpenURL { url in
guard let request = KeyboardLaunchRequest(url: url) else { return }
if case .setup = request {
openedFromKeyboard = false
showSetup = true
} else if case .translationSettings = request {
openedFromKeyboard = false
openPage = .dictation
} else if case .pasteSettings = request {
openedFromKeyboard = false
openPage = .keyboard
if let settingsURL = URL(string: UIApplication.openSettingsURLString) {
UIApplication.shared.open(settingsURL)
}
} else {
openedFromKeyboard = true
}
dictation.handleKeyboardLaunch(request)
}
.onChange(of: scenePhase) { _, phase in
if phase == .background {
openedFromKeyboard = false
dictation.appMovedToBackground()
} else if phase == .active {
dictation.endStaleLiveActivities()
dictation.appBecameActive()
// Settings › Dictation › Speech model in keyboard: picks its download up.
dictation.startKeyboardParakeetDownloadIfWanted()
}
}
}
}
}
}