//
// OpenRocky — Voice-first AI Agent
// https://github.com/openrocky
//
// Developed by everettjf with the assistance of Claude Code and Codex.
// Date: 2026-04-13
// Copyright (c) 2026 everettjf. All rights reserved.
//

import SwiftUI

struct OpenRockyPreferencesView: View {
    @Bindable private var preferences = OpenRockyPreferences.shared

    var body: some View {
        List {
            Section {
                Toggle("Auto-Start on Launch", isOn: $preferences.voiceAutoStartOnLaunch)
                Toggle("Voice Interruption", isOn: $preferences.voiceInterruptionEnabled)
                Toggle("Auto Greeting", isOn: $preferences.voiceAutoGreeting)
                Toggle("Show Transcript", isOn: $preferences.voiceTranscriptVisible)
                Stepper(
                    "Context Messages: \(preferences.voiceContextMessageCount)",
                    value: $preferences.voiceContextMessageCount,
                    in: 2...100,
                    step: 2
                )
            } header: {
                Text("Voice Session")
            } footer: {
                Text("Auto-Start on Launch enters voice mode automatically when the app cold-starts (Siri launches always auto-enter regardless). Context Messages is the number of recent messages included as context for the realtime voice session — more context = better memory but higher latency.")
            }

            Section {
                Toggle("Auto-save Conversations", isOn: $preferences.chatAutoSaveConversation)
                Toggle("Haptic Feedback", isOn: $preferences.hapticFeedbackEnabled)
            } header: {
                Text("General")
            }
        }
        .navigationTitle("Preferences")
        .navigationBarTitleDisplayMode(.inline)
    }
}
