diff --git a/src/events.rs b/src/events.rs index 61a00cb..2239fcc 100644 --- a/src/events.rs +++ b/src/events.rs @@ -53,7 +53,9 @@ impl EventHandler { match key_event.code { KeyCode::Char('q') => Ok(AppEvent::Quit), KeyCode::Esc => Ok(AppEvent::CloseSettings), - KeyCode::Char(',') | KeyCode::Char('s') | KeyCode::Char('S') => Ok(AppEvent::OpenSettings), + KeyCode::Char(',') | KeyCode::Char('s') | KeyCode::Char('S') => { + Ok(AppEvent::OpenSettings) + } KeyCode::Up | KeyCode::Char('k') => Ok(AppEvent::NavigateUp), KeyCode::Down | KeyCode::Char('j') => Ok(AppEvent::NavigateDown), KeyCode::Enter | KeyCode::Char(' ') => Ok(AppEvent::Select), diff --git a/src/settings.rs b/src/settings.rs index af65c6d..2e57476 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -1129,28 +1129,28 @@ impl Settings { }, } } - + /// Check if at least one provider is valid and ready for queries pub fn has_valid_provider(&self) -> bool { self.local_provider.validation_status == ValidationStatus::Valid || self.openrouter_provider.validation_status == ValidationStatus::Valid } - + /// Get list of available (valid) providers pub fn get_available_providers(&self) -> Vec { let mut providers = Vec::new(); - + if self.local_provider.validation_status == ValidationStatus::Valid { providers.push(ProviderType::Local); } - + if self.openrouter_provider.validation_status == ValidationStatus::Valid { providers.push(ProviderType::OpenRouter); } - + providers } - + /// Get provider configuration status for UI display pub fn get_provider_status_summary(&self) -> Vec<(ProviderType, ValidationStatus, String)> { vec![ @@ -1160,7 +1160,7 @@ impl Settings { match &self.local_provider.endpoint_url { Some(url) => url.clone(), None => "Not configured".to_string(), - } + }, ), ( ProviderType::OpenRouter, @@ -1168,7 +1168,7 @@ impl Settings { match &self.openrouter_provider.api_key { Some(_) => "API configured".to_string(), None => "Not configured".to_string(), - } + }, ), ] } diff --git a/src/ui/app.rs b/src/ui/app.rs index 682679b..97b668f 100644 --- a/src/ui/app.rs +++ b/src/ui/app.rs @@ -48,7 +48,7 @@ impl App { } else { AppState::WaitingForConfig }; - + Self { state: initial_state, previous_state: AppState::Main, @@ -361,7 +361,7 @@ impl App { AppState::WaitingForConfig => { let provider_status = self.settings().get_provider_status_summary(); let available_providers = self.settings().get_available_providers(); - + let status_display = if provider_status.is_empty() { " No providers configured yet".to_string() } else { @@ -378,7 +378,7 @@ impl App { .collect::>() .join("\n") }; - + format!(r#" ╔═══════════════════════════════════════════════════════════════╗ @@ -530,7 +530,7 @@ impl App { self.settings.reset_to_defaults(); self.settings.get().apply_theme(&mut self.theme); } - + /// Check provider readiness and update app state accordingly pub fn check_provider_readiness(&mut self) { if !self.settings.get().has_valid_provider() { @@ -543,12 +543,14 @@ impl App { } } } - + /// Handle validation event results and update provider status pub fn update_provider_status(&mut self, validation_event: crate::settings::ValidationEvent) { // Update the provider status through settings - self.settings.get_mut().handle_validation_event(validation_event); - + self.settings + .get_mut() + .handle_validation_event(validation_event); + // Check if we need to change app state self.check_provider_readiness(); }