1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
use super::types::*;
use super::wizard::OnboardingWizard;
impl OnboardingWizard {
/// Advance to the next step
pub fn next_step(&mut self) {
self.error_message = None;
self.focused_field = 0;
// Reset manual scroll so each new step starts at the top —
// a Page Down on the previous step shouldn't leave the user
// mid-scroll on a step they haven't seen yet.
self.user_scroll_offset = 0;
// In quick_jump mode, completing a step exits back to chat
// instead of advancing through the wizard flow.
if self.quick_jump {
self.quick_jump_done = true;
return;
}
match self.step {
OnboardingStep::ModeSelect => {
self.step = OnboardingStep::Workspace;
}
OnboardingStep::Workspace => {
// Create config files in the workspace directory
if let Err(e) = self.ensure_config_files() {
self.error_message = Some(format!("Failed to create config files: {}", e));
return;
}
self.step = OnboardingStep::ProviderAuth;
self.auth_field = AuthField::Provider;
self.ps.detect_existing_key();
}
OnboardingStep::ProviderAuth => {
// Keyless providers need no API key: CLI subprocesses (Claude
// CLI, OpenCode CLI) AND any API provider whose onboarding entry
// has an empty key_label. Only demand a key when the provider
// actually has a key field.
let keyless = self.ps.is_keyless();
if self.ps.api_key_input.is_empty() && !self.ps.is_custom() && !keyless {
self.error_message = Some("API key is required".to_string());
return;
}
if self.ps.is_custom()
&& (self.ps.base_url.is_empty()
|| self.ps.custom_model.is_empty()
|| self.ps.custom_name.is_empty())
{
self.error_message = Some(
"Base URL, model name, and provider name are required for custom provider"
.to_string(),
);
return;
}
// QuickStart: skip channels, go straight to daemon
if self.mode == WizardMode::QuickStart {
self.step = OnboardingStep::Daemon;
} else {
tracing::debug!("[next_step] ProviderAuth → Channels");
self.step = OnboardingStep::Channels;
self.focused_field = 0;
}
}
OnboardingStep::Channels => {
// Handled by handle_channels_key — Enter on focused channel or Continue
self.step = OnboardingStep::VoiceSetup;
self.voice_field = VoiceField::SttModeSelect;
self.detect_existing_groq_key();
}
OnboardingStep::TelegramSetup
| OnboardingStep::DiscordSetup
| OnboardingStep::WhatsAppSetup
| OnboardingStep::SlackSetup
| OnboardingStep::TrelloSetup => {
// Return to channel list after completing a channel setup
self.step = OnboardingStep::Channels;
}
OnboardingStep::VoiceSetup => {
self.step = OnboardingStep::ImageSetup;
self.image_field = ImageField::VisionToggle;
self.detect_existing_image_key();
}
OnboardingStep::ImageSetup => {
self.step = OnboardingStep::Daemon;
}
OnboardingStep::Daemon => {
self.step = OnboardingStep::HealthCheck;
self.start_health_check();
}
OnboardingStep::HealthCheck => {
self.step = OnboardingStep::BrainSetup;
self.brain_field = BrainField::AboutMe;
}
OnboardingStep::BrainSetup => {
if self.brain_generated || self.brain_error.is_some() {
self.step = OnboardingStep::Complete;
}
// Otherwise wait for generation to finish or user to trigger it
}
OnboardingStep::Complete => {
// Already complete
}
}
}
/// Go back to the previous step
pub fn prev_step(&mut self) -> bool {
self.error_message = None;
self.focused_field = 0;
self.user_scroll_offset = 0;
match self.step {
OnboardingStep::ModeSelect => {
// Can't go back further — return true to signal "cancel wizard"
return true;
}
OnboardingStep::Workspace => {
self.step = OnboardingStep::ModeSelect;
}
OnboardingStep::ProviderAuth => {
self.step = OnboardingStep::Workspace;
}
OnboardingStep::Channels => {
self.step = OnboardingStep::ProviderAuth;
self.auth_field = AuthField::Provider;
}
OnboardingStep::TelegramSetup => {
self.step = OnboardingStep::Channels;
}
OnboardingStep::DiscordSetup
| OnboardingStep::WhatsAppSetup
| OnboardingStep::SlackSetup
| OnboardingStep::TrelloSetup => {
self.step = OnboardingStep::Channels;
}
OnboardingStep::VoiceSetup => {
self.step = OnboardingStep::Channels;
}
OnboardingStep::ImageSetup => {
self.step = OnboardingStep::VoiceSetup;
self.voice_field = VoiceField::SttModeSelect;
}
OnboardingStep::Daemon => {
// QuickStart: go back to ProviderAuth, Advanced: go back to ImageSetup
if self.mode == WizardMode::QuickStart {
self.step = OnboardingStep::ProviderAuth;
self.auth_field = AuthField::Provider;
} else {
self.step = OnboardingStep::ImageSetup;
self.image_field = ImageField::VisionToggle;
}
}
OnboardingStep::HealthCheck => {
self.step = OnboardingStep::Daemon;
}
OnboardingStep::BrainSetup => {
self.step = OnboardingStep::HealthCheck;
self.brain_generating = false;
self.brain_error = None;
}
OnboardingStep::Complete => {
self.step = OnboardingStep::BrainSetup;
self.brain_field = BrainField::AboutMe;
}
}
false
}
}