Skip to content

Commit 92254d9

Browse files
Merge pull request #42 from gitcoder89431/33-implement-query-gating-for-provider-validation
chore: Update documentation for event handling and settings modules
2 parents 17d3d68 + e7b489b commit 92254d9

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

src/events.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ impl EventHandler {
5353
match key_event.code {
5454
KeyCode::Char('q') => Ok(AppEvent::Quit),
5555
KeyCode::Esc => Ok(AppEvent::CloseSettings),
56-
KeyCode::Char(',') | KeyCode::Char('s') | KeyCode::Char('S') => Ok(AppEvent::OpenSettings),
56+
KeyCode::Char(',') | KeyCode::Char('s') | KeyCode::Char('S') => {
57+
Ok(AppEvent::OpenSettings)
58+
}
5759
KeyCode::Up | KeyCode::Char('k') => Ok(AppEvent::NavigateUp),
5860
KeyCode::Down | KeyCode::Char('j') => Ok(AppEvent::NavigateDown),
5961
KeyCode::Enter | KeyCode::Char(' ') => Ok(AppEvent::Select),

src/settings.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,28 +1129,28 @@ impl Settings {
11291129
},
11301130
}
11311131
}
1132-
1132+
11331133
/// Check if at least one provider is valid and ready for queries
11341134
pub fn has_valid_provider(&self) -> bool {
11351135
self.local_provider.validation_status == ValidationStatus::Valid
11361136
|| self.openrouter_provider.validation_status == ValidationStatus::Valid
11371137
}
1138-
1138+
11391139
/// Get list of available (valid) providers
11401140
pub fn get_available_providers(&self) -> Vec<ProviderType> {
11411141
let mut providers = Vec::new();
1142-
1142+
11431143
if self.local_provider.validation_status == ValidationStatus::Valid {
11441144
providers.push(ProviderType::Local);
11451145
}
1146-
1146+
11471147
if self.openrouter_provider.validation_status == ValidationStatus::Valid {
11481148
providers.push(ProviderType::OpenRouter);
11491149
}
1150-
1150+
11511151
providers
11521152
}
1153-
1153+
11541154
/// Get provider configuration status for UI display
11551155
pub fn get_provider_status_summary(&self) -> Vec<(ProviderType, ValidationStatus, String)> {
11561156
vec![
@@ -1160,15 +1160,15 @@ impl Settings {
11601160
match &self.local_provider.endpoint_url {
11611161
Some(url) => url.clone(),
11621162
None => "Not configured".to_string(),
1163-
}
1163+
},
11641164
),
11651165
(
11661166
ProviderType::OpenRouter,
11671167
self.openrouter_provider.validation_status.clone(),
11681168
match &self.openrouter_provider.api_key {
11691169
Some(_) => "API configured".to_string(),
11701170
None => "Not configured".to_string(),
1171-
}
1171+
},
11721172
),
11731173
]
11741174
}

src/ui/app.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl App {
4848
} else {
4949
AppState::WaitingForConfig
5050
};
51-
51+
5252
Self {
5353
state: initial_state,
5454
previous_state: AppState::Main,
@@ -361,7 +361,7 @@ impl App {
361361
AppState::WaitingForConfig => {
362362
let provider_status = self.settings().get_provider_status_summary();
363363
let available_providers = self.settings().get_available_providers();
364-
364+
365365
let status_display = if provider_status.is_empty() {
366366
" No providers configured yet".to_string()
367367
} else {
@@ -378,7 +378,7 @@ impl App {
378378
.collect::<Vec<_>>()
379379
.join("\n")
380380
};
381-
381+
382382
format!(r#"
383383
384384
╔═══════════════════════════════════════════════════════════════╗
@@ -530,7 +530,7 @@ impl App {
530530
self.settings.reset_to_defaults();
531531
self.settings.get().apply_theme(&mut self.theme);
532532
}
533-
533+
534534
/// Check provider readiness and update app state accordingly
535535
pub fn check_provider_readiness(&mut self) {
536536
if !self.settings.get().has_valid_provider() {
@@ -543,12 +543,14 @@ impl App {
543543
}
544544
}
545545
}
546-
546+
547547
/// Handle validation event results and update provider status
548548
pub fn update_provider_status(&mut self, validation_event: crate::settings::ValidationEvent) {
549549
// Update the provider status through settings
550-
self.settings.get_mut().handle_validation_event(validation_event);
551-
550+
self.settings
551+
.get_mut()
552+
.handle_validation_event(validation_event);
553+
552554
// Check if we need to change app state
553555
self.check_provider_readiness();
554556
}

0 commit comments

Comments
 (0)