Onboarding Flow
Relevant source files
The following files were used as context for generating this wiki page:
The Onboarding Flow is a critical sequence for first-time users of VoiceInk. Its primary purpose is to guide the user through essential setup steps, including granting necessary system permissions, downloading a default AI transcription model, and completing an interactive tutorial. This ensures the application is fully functional before the user accesses the main interface.
The entire flow is controlled by the hasCompletedOnboarding boolean value, which is persisted in @AppStorage. Once this flag is set to true, the onboarding process is skipped on subsequent app launches, and the user is taken directly to the main ContentView.
Sources: VoiceInk/VoiceInk.swift:26, VoiceInk/VoiceInk.swift:102-143
Onboarding View Sequence
The onboarding process is a linear progression through four distinct SwiftUI views. Each view is responsible for a specific part of the setup, and successful completion of one step transitions the user to the next.
This diagram illustrates the high-level flow between the different onboarding views.
View Responsibilities
| View | File | Purpose |
|---|---|---|
OnboardingView | OnboardingView.swift | The initial welcome screen. Presents an introduction and a "Get Started" button to begin the process. |
OnboardingPermissionsView | OnboardingPermissionsView.swift | A sequential wizard for requesting necessary system permissions like Microphone, Accessibility, and Screen Recording. |
OnboardingModelDownloadView | OnboardingModelDownloadView.swift | Manages the download and setup of the default AI transcription model. |
OnboardingTutorialView | OnboardingTutorialView.swift | An interactive tutorial where the user can test their setup by speaking and seeing the transcription in real-time. |
Flow Trigger
The application's entry point in VoiceInk.swift determines whether to initiate the onboarding flow. It checks the hasCompletedOnboarding flag. If false, the OnboardingView is presented; otherwise, the main ContentView is shown.
// Source: VoiceInk/VoiceInk.swift:102-143
@main
struct VoiceInkApp: App {
// ...
@AppStorage("hasCompletedOnboarding") private var hasCompletedOnboarding = false
// ...
var body: some Scene {
WindowGroup {
if hasCompletedOnboarding {
ContentView()
// ... environment objects
} else {
OnboardingView(hasCompletedOnboarding: $hasCompletedOnboarding)
// ... environment objects
.frame(minWidth: 880, minHeight: 780)
// ...
}
}
// ...
}
}
Onboarding Steps
1. Welcome Screen (OnboardingView)
This is the first view the user sees. It displays an animated welcome message and a "Get Started" button.
- State Management: It uses a local
@StatevariableshowPermissionsto control the transition to the next screen. - Navigation:
- Clicking "Get Started" sets
showPermissionstotrue, which conditionally renders theOnboardingPermissionsView. - A "Skip Tour" button is available to immediately set
hasCompletedOnboarding = trueand exit the flow.
- Clicking "Get Started" sets
Sources: VoiceInk/Views/Onboarding/OnboardingView.swift:6-68
2. Permissions Setup (OnboardingPermissionsView)
This view guides the user through a series of required and optional system permissions. It presents one permission at a time and checks for its status before allowing the user to proceed.
The following permissions are requested in sequence:
| Permission | Icon | Description | System Check/Request Functions |
|---|---|---|---|
| Microphone Access | waveform | To capture the user's voice for transcription. | AVCaptureDevice.requestAccess(for: .audio) |
| Microphone Selection | headphones | To allow the user to select a specific audio input device. | AudioDeviceManager.shared |
| Accessibility Access | accessibility | To paste the transcribed text into other applications. | AXIsProcessTrusted(), AXIsProcessTrustedWithOptions() |
| Screen Recording | rectangle.inset.filled.and.person.filled | To improve transcription accuracy with on-screen context. | CGPreflightScreenCaptureAccess(), CGRequestScreenCaptureAccess() |
| Keyboard Shortcut | keyboard | To set a global hotkey for triggering VoiceInk. | KeyboardShortcuts.Recorder |
Sources: VoiceInk/Views/Onboarding/OnboardingPermissionsView.swift:8-46, VoiceInk/Views/Onboarding/OnboardingPermissionsView.swift:220-289
The view uses a Timer to poll for permission status changes after a request is made, particularly for Accessibility and Screen Recording, which require user action in System Settings.
The following diagram shows the sequence of requesting a permission.
3. AI Model Download (OnboardingModelDownloadView)
After permissions are set, the user is prompted to download an optimized AI model for transcription.
- Default Model: The view is hardcoded to download the
ggml-large-v3-turbo-q5_0model. - State Management: It interacts with the
WhisperStateenvironment object to manage the download and model state. - Logic Flow: The
handleAction()function orchestrates the process:- If the model is not downloaded, it calls
whisperState.downloadModel(). - Once downloaded, it calls
whisperState.setDefaultTranscriptionModel(). - The UI updates to reflect the current state (e.g., "Download Model", "Downloading...", "Set as Default", "Continue").
- If the model is not downloaded, it calls
- Navigation: Upon successful setup, it sets
showTutorial = true, which transitions to theOnboardingTutorialView. A skip option is also available.
// Source: VoiceInk/Views/Onboarding/OnboardingModelDownloadView.swift:122-143
private func handleAction() {
if isModelSet {
withAnimation {
showTutorial = true
}
} else if whisperState.availableModels.contains(where: { $0.name == turboModel.name }) {
if let modelToSet = whisperState.allAvailableModels.first(where: { $0.name == turboModel.name }) {
Task {
await whisperState.setDefaultTranscriptionModel(modelToSet)
withAnimation {
isModelSet = true
}
}
}
} else {
withAnimation {
isDownloading = true
}
Task {
await whisperState.downloadModel(turboModel)
// ... set as default after download
}
}
}
4. Interactive Tutorial (OnboardingTutorialView)
This is the final step, allowing the user to test their complete setup.
- Shortcut Display: It retrieves and displays the user's configured hotkey from
hotkeyManager. - Interactive Editor: A
TextEditoris provided. The user is instructed to click the editor, use their shortcut, speak, and use the shortcut again to see the transcribed text appear. - Completion: The "Complete Setup" button is only enabled once transcription has occurred (
transcribedTextis not empty). Clicking this button (or the "Skip for now" button) setshasCompletedOnboarding = true, which dismisses the entire onboarding window and reveals the main application.
Sources: VoiceInk/Views/Onboarding/OnboardingTutorialView.swift:39-60, VoiceInk/Views/Onboarding/OnboardingTutorialView.swift:79-92, VoiceInk/Views/Onboarding/OnboardingTutorialView.swift:121-130
Conclusion
The onboarding flow is a comprehensive, multi-stage process designed to ensure a smooth and successful first-run experience. By breaking down the setup into a series of clear, manageable steps—from permissions to model downloads to an interactive test—it guarantees that the application is properly configured and that the user understands its basic operation before they begin regular use. The entire flow is managed by a single @AppStorage flag, making it a self-contained and non-repeating part of the user journey.