import SwiftUI

@main
struct NotesWatchApp: App {
    @State private var services = WatchAppServices()
    @Environment(\.scenePhase) private var scenePhase

    var body: some Scene {
        WindowGroup {
            NavigationStack {
                RecordView()
            }
            .environment(services)
            .task {
                services.bootstrap()
                #if DEBUG
                // CLI-driven repro of the record button (simctl launch … autorecord).
                if ProcessInfo.processInfo.arguments.contains("autorecord") {
                    await services.startRecording()
                }
                #endif
            }
            .onOpenURL { url in services.handleDeepLink(url) }
        }
        .onChange(of: scenePhase) { _, phase in
            services.handleScenePhase(phase)
        }
    }
}
