- AnthropicKeyValidator: local sk-ant- prefix check + URLSession-injectable GET to api.anthropic.com/v1/models; returns typed enum, never logs key - WizardState: @MainActor ObservableObject; D-09 stateless re-entry via refresh(); firstUnresolvedStage advances apiKey → tcc → hotkey → complete - WizardStageAPIKeyView: SecureField, validator + Keychain round-trip; key value lives only in Keychain (SEC-01) - WizardStageTCCView: Input Monitoring row actively probes; Mic/Camera/ Automation rows are explainer-only (D-08/SEC-04); no permission APIs called from the view - WizardStageHotkeyView: ShortcutRecorderView + CollisionDetector wiring; Skip leaves hotkey unbound (SHELL-02) - WizardView: three-stage root with header dots + Back footer - OnboardingWizardController: NSWindow hosting; first-launch .modalPanel + close-button disabled until API key stored (D-06) - AppDelegate: full 8-step launch chain — logging bootstrap (S-8) → entitlement gate (Plan 03) → config load (NSAlert on malformed, D-19/S-6) → menu bar + HUD + banner install → Keychain fetch (.keychainEmpty banner on itemNotFound) → Input Monitoring probe (.inputMonitoringDenied banner on denial, SHELL-06) → HotkeyBinder init → Wizard open on first launch. copyStateDump writes boolean-only presence; API key VALUE never clipboarded - JarvisApp: Settings scene stub; real NSPanels managed by AppDelegate - Tests: 11 new (WizardState 4, AnthropicKeyValidator 3, WizardTCC 1, AppDelegateWiring 4) + updated AppDelegateEntitlementTests for the new launch chain; all 25 JarvisAppTests pass - Re-inserted PBXCopyFilesBuildPhase for Contents/Helpers per Plan 01/03 precedent (xcodegen strips empty copyFiles) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
98 lines
2.9 KiB
Swift
98 lines
2.9 KiB
Swift
import SwiftUI
|
|
import Keychain
|
|
import Shell
|
|
|
|
/// Three-stage root view per UI-SPEC Surface 1 (api key → tcc → hotkey).
|
|
/// Header shows stage dots; footer offers Back (disabled on Stage 1). The
|
|
/// actual modal/non-modal distinction lives at the hosting
|
|
/// `OnboardingWizardController`, not here.
|
|
public struct WizardView: View {
|
|
@ObservedObject var state: WizardState
|
|
let keychain: any KeychainStore
|
|
let validator: AnthropicKeyValidator
|
|
let onGrantInputMonitoring: () -> Bool
|
|
let onComplete: () -> Void
|
|
|
|
public init(
|
|
state: WizardState,
|
|
keychain: any KeychainStore,
|
|
validator: AnthropicKeyValidator,
|
|
onGrantInputMonitoring: @escaping () -> Bool,
|
|
onComplete: @escaping () -> Void
|
|
) {
|
|
self.state = state
|
|
self.keychain = keychain
|
|
self.validator = validator
|
|
self.onGrantInputMonitoring = onGrantInputMonitoring
|
|
self.onComplete = onComplete
|
|
}
|
|
|
|
public var body: some View {
|
|
VStack(spacing: 0) {
|
|
header
|
|
Divider()
|
|
stageBody
|
|
Divider()
|
|
footer
|
|
}
|
|
.frame(width: 560, height: 440)
|
|
}
|
|
|
|
private var header: some View {
|
|
HStack(spacing: 8) {
|
|
ForEach(WizardStage.allCases.filter { $0 != .complete }, id: \.self) { stage in
|
|
Circle()
|
|
.fill(state.currentStage == stage
|
|
? Color(NSColor.controlAccentColor)
|
|
: Color(NSColor.separatorColor))
|
|
.frame(width: 10, height: 10)
|
|
}
|
|
}
|
|
.frame(height: 64)
|
|
.frame(maxWidth: .infinity)
|
|
}
|
|
|
|
@ViewBuilder
|
|
private var stageBody: some View {
|
|
switch state.currentStage {
|
|
case .apiKey:
|
|
WizardStageAPIKeyView(
|
|
state: state,
|
|
validator: validator,
|
|
keychain: keychain,
|
|
onAdvance: { state.currentStage = .tcc }
|
|
)
|
|
case .tcc:
|
|
WizardStageTCCView(
|
|
state: state,
|
|
onAdvance: { state.currentStage = .hotkey },
|
|
onGrantInputMonitoring: onGrantInputMonitoring
|
|
)
|
|
case .hotkey:
|
|
WizardStageHotkeyView(state: state, onAdvance: {
|
|
state.currentStage = .complete
|
|
onComplete()
|
|
})
|
|
case .complete:
|
|
Color.clear
|
|
}
|
|
}
|
|
|
|
private var footer: some View {
|
|
HStack {
|
|
if state.currentStage != .apiKey {
|
|
Button("← Back") {
|
|
switch state.currentStage {
|
|
case .tcc: state.currentStage = .apiKey
|
|
case .hotkey: state.currentStage = .tcc
|
|
default: break
|
|
}
|
|
}
|
|
}
|
|
Spacer()
|
|
}
|
|
.padding(.horizontal, 48)
|
|
.frame(height: 56)
|
|
}
|
|
}
|