| 175 | |
| 176 | // swiftlint:disable type_body_length file_length |
| 177 | struct ContentView: View { |
| 178 | private enum ActiveRecordingMode: String { |
| 179 | case none |
| 180 | case dictate |
| 181 | case promptMode |
| 182 | case edit |
| 183 | case command |
| 184 | } |
| 185 | |
| 186 | private enum DictationOutputRoute: String { |
| 187 | case normal |
| 188 | case onboardingSandbox |
| 189 | } |
| 190 | |
| 191 | @EnvironmentObject private var appServices: AppServices |
| 192 | @StateObject private var mouseTracker = MousePositionTracker() |
| 193 | @StateObject private var commandModeService = CommandModeService() |
| 194 | @StateObject private var rewriteModeService = RewriteModeService() |
| 195 | @EnvironmentObject private var menuBarManager: MenuBarManager |
| 196 | @ObservedObject private var settings = SettingsStore.shared |
| 197 | |
| 198 | /// Computed properties to access shared services from AppServices container |
| 199 | /// This maintains backward compatibility with the existing code while |
| 200 | /// removing the duplicate service instances that cause startup crashes. |
| 201 | private var asr: ASRService { |
| 202 | self.appServices.asr |
| 203 | } |
| 204 | |
| 205 | private var audioObserver: AudioHardwareObserver { |
| 206 | self.appServices.audioObserver |
| 207 | } |
| 208 | |
| 209 | @Environment(\.theme) private var theme |
| 210 | @State private var hotkeyManager: GlobalHotkeyManager? = nil |
| 211 | @State private var hotkeyManagerInitialized: Bool = false |
| 212 | |
| 213 | @State private var appear = false |
| 214 | @State private var accessibilityEnabled = false |
| 215 | @State private var primaryDictationShortcuts: [HotkeyShortcut] = SettingsStore.shared.primaryDictationShortcuts |
| 216 | @State private var promptModeHotkeyShortcut: HotkeyShortcut = SettingsStore.shared.promptModeHotkeyShortcut |
| 217 | @State private var commandModeHotkeyShortcut: HotkeyShortcut? = SettingsStore.shared.commandModeHotkeyShortcut |
| 218 | @State private var rewriteModeHotkeyShortcut: HotkeyShortcut = SettingsStore.shared.rewriteModeHotkeyShortcut |
| 219 | @State private var cancelRecordingHotkeyShortcut: HotkeyShortcut = SettingsStore.shared.cancelRecordingHotkeyShortcut |
| 220 | @State private var pasteLastTranscriptionHotkeyShortcut: HotkeyShortcut? = SettingsStore.shared.pasteLastTranscriptionHotkeyShortcut |
| 221 | @State private var isPasteLastTranscriptionShortcutEnabled: Bool = SettingsStore.shared.pasteLastTranscriptionShortcutEnabled |
| 222 | @State private var isPromptModeShortcutEnabled: Bool = SettingsStore.shared.promptModeShortcutEnabled |
| 223 | @State private var isCommandModeShortcutEnabled: Bool = SettingsStore.shared.commandModeShortcutEnabled |
| 224 | @State private var isRewriteModeShortcutEnabled: Bool = SettingsStore.shared.rewriteModeShortcutEnabled |
| 225 | @State private var isRecordingForRewrite: Bool = false // Track if current recording is for rewrite mode |
| 226 | @State private var isRecordingForCommand: Bool = false // Track if current recording is for command mode |
| 227 | @State private var promptModeOverrideText: String? // System prompt text to use when in prompt mode |
| 228 | @State private var activeDictationShortcutSlot: SettingsStore.DictationShortcutSlot? = nil |
| 229 | @State private var activeRecordingMode: ActiveRecordingMode = .none |
| 230 | @State private var pendingAIReprocessText: String? = nil |
| 231 | @State private var activeShortcutRecordingTarget: ShortcutRecordingTarget? = nil |
| 232 | @State private var currentRecordingModifierKeyCodes: Set<UInt16> = [] |
| 233 | @State private var pendingModifierKeyCodes: Set<UInt16> = [] |
| 234 | @State private var pendingModifierFlags: NSEvent.ModifierFlags = [] |
no test coverage detected