Skip to content

Commit 0592939

Browse files
committed
🏗️ Update provider configuration UI layout demo and tests
1 parent eda5d4a commit 0592939

File tree

4 files changed

+105
-43
lines changed

4 files changed

+105
-43
lines changed

examples/issue_30_demo.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Issue #30 Provider Configuration UI Layout Demo
2-
//!
2+
//!
33
//! Demonstrates the completed provider configuration UI layout implementation
44
//! Features: Provider sections, status icons, theme selection at bottom
55
@@ -8,7 +8,7 @@ use std::io::{self, Write};
88
fn main() {
99
println!("🎨 Issue #30: Provider Configuration UI Layout Demo");
1010
println!("{}", "=".repeat(65));
11-
11+
1212
// ASCII Art representation of the new UI layout
1313
println!("\n📋 NEW SETTINGS MODAL LAYOUT (80% width, 70% height):");
1414
println!("┌─────────────────────────────────────────────────────────────┐");
@@ -30,7 +30,7 @@ fn main() {
3030
println!("├─────────────────────────────────────────────────────────────┤");
3131
println!("│ ESC: Close ↑↓: Navigate Enter: Edit S: Save │");
3232
println!("└─────────────────────────────────────────────────────────────┘");
33-
33+
3434
println!("\n✨ KEY FEATURES IMPLEMENTED:");
3535
println!(" 🎯 Provider sections with clear status icons:");
3636
println!(" ⚪ Unchecked 🟡 Checking ✅ Valid ❌ Invalid");
@@ -40,15 +40,15 @@ fn main() {
4040
println!(" 📖 Comprehensive help text");
4141
println!(" 📐 80% modal width for better visibility");
4242
println!(" 🏗️ Modular rendering functions for maintainability");
43-
43+
4444
println!("\n🔧 TECHNICAL IMPLEMENTATION:");
4545
println!(" • ProviderSection & ConfigField data structures");
4646
println!(" • render_provider_sections() helper function");
4747
println!(" • render_theme_selection() at bottom");
4848
println!(" • Status icon mapping with validation states");
4949
println!(" • Field focus indicators with underline characters");
5050
println!(" • Responsive 5-section modal layout");
51-
51+
5252
println!("\n📊 ISSUE #30 COMPLETION STATUS:");
5353
println!(" ✅ Provider Configuration UI Layout - COMPLETED");
5454
println!(" ✅ Theme selection positioned at bottom");
@@ -57,12 +57,12 @@ fn main() {
5757
println!(" ✅ Save functionality integration");
5858
println!(" ✅ Help text and navigation instructions");
5959
println!(" ✅ All 10 tests passing");
60-
60+
6161
print!("\n🚀 Ready to test the UI? Press Enter to see instructions...");
6262
io::stdout().flush().unwrap();
6363
let mut input = String::new();
6464
io::stdin().read_line(&mut input).unwrap();
65-
65+
6666
println!("\n📋 TESTING INSTRUCTIONS:");
6767
println!(" 1. Run: cargo run");
6868
println!(" 2. Press 'S' to open settings modal");
@@ -71,7 +71,7 @@ fn main() {
7171
println!(" 5. Use ← → arrows for theme selection");
7272
println!(" 6. Press 'S' to save configuration");
7373
println!(" 7. Press ESC to close modal");
74-
74+
7575
println!("\n🎉 Issue #30 Implementation Complete!");
7676
println!("📋 Ready for: https://github.com/gitcoder89431/agentic/issues/31");
7777
}

examples/ui_layout_test.rs

Lines changed: 59 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,85 @@
11
//! Provider Configuration UI Layout Test
2-
//!
2+
//!
33
//! Tests the new provider configuration UI layout with theme selection at bottom
44
55
use agentic::{
6-
settings::{Settings, ProviderConfig, ValidationStatus},
6+
settings::{ProviderConfig, Settings, ValidationStatus},
77
theme::{Theme, ThemeVariant},
88
};
99

1010
fn main() {
1111
println!("🧪 Testing Provider Configuration UI Layout Implementation");
1212
println!("{}", "=".repeat(60));
13-
13+
1414
// Test provider section creation
1515
let mut settings = Settings::default();
16-
16+
1717
// Test provider configurations
1818
println!("✅ Testing provider configuration creation:");
19-
19+
2020
// Update Local provider
21-
settings.local_provider.set_endpoint_url("http://localhost:8080".to_string());
22-
21+
settings
22+
.local_provider
23+
.set_endpoint_url("http://localhost:8080".to_string());
24+
2325
// Update OpenRouter provider
24-
settings.openrouter_provider.set_api_key("or-test-key".to_string());
25-
26-
println!(" 📦 Local Provider: {}", ValidationStatusDisplay(&settings.local_provider.validation_status));
27-
println!(" Endpoint: {}", settings.local_provider.endpoint_url.as_ref().unwrap_or(&"None".to_string()));
28-
println!(" Configured: {}", settings.local_provider.is_configured());
29-
30-
println!(" 🌐 OpenRouter Provider: {}", ValidationStatusDisplay(&settings.openrouter_provider.validation_status));
31-
println!(" API Key: {}", settings.openrouter_provider.get_masked_api_key().unwrap_or("None".to_string()));
32-
println!(" Configured: {}", settings.openrouter_provider.is_configured());
33-
26+
settings
27+
.openrouter_provider
28+
.set_api_key("or-test-key".to_string());
29+
30+
println!(
31+
" 📦 Local Provider: {}",
32+
ValidationStatusDisplay(&settings.local_provider.validation_status)
33+
);
34+
println!(
35+
" Endpoint: {}",
36+
settings
37+
.local_provider
38+
.endpoint_url
39+
.as_ref()
40+
.unwrap_or(&"None".to_string())
41+
);
42+
println!(
43+
" Configured: {}",
44+
settings.local_provider.is_configured()
45+
);
46+
47+
println!(
48+
" 🌐 OpenRouter Provider: {}",
49+
ValidationStatusDisplay(&settings.openrouter_provider.validation_status)
50+
);
51+
println!(
52+
" API Key: {}",
53+
settings
54+
.openrouter_provider
55+
.get_masked_api_key()
56+
.unwrap_or("None".to_string())
57+
);
58+
println!(
59+
" Configured: {}",
60+
settings.openrouter_provider.is_configured()
61+
);
62+
3463
// Test theme configuration
3564
println!("\n✅ Testing theme configuration:");
36-
65+
3766
let theme = Theme::new(ThemeVariant::EverforestDark);
3867
println!(" 🎨 Default Theme: EverforestDark");
39-
68+
4069
let _light_theme = Theme::new(ThemeVariant::EverforestLight);
4170
println!(" 🌞 Light Theme: EverforestLight");
42-
71+
4372
// Test validation states
4473
println!("\n✅ Testing validation states:");
45-
println!(" 🔍 Local provider configured: {}", settings.local_provider.is_configured());
46-
println!(" 🔍 OpenRouter provider configured: {}", settings.openrouter_provider.is_configured());
47-
74+
println!(
75+
" 🔍 Local provider configured: {}",
76+
settings.local_provider.is_configured()
77+
);
78+
println!(
79+
" 🔍 OpenRouter provider configured: {}",
80+
settings.openrouter_provider.is_configured()
81+
);
82+
4883
println!("\n🎉 Provider Configuration UI Layout Implementation Test Complete!");
4984
println!("\n📋 Issue #30 Status: READY FOR TESTING");
5085
println!(" - ✅ Provider sections with status icons");
@@ -63,7 +98,7 @@ impl<'a> std::fmt::Display for ValidationStatusDisplay<'a> {
6398
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6499
let display = match self.0 {
65100
ValidationStatus::Valid => "✅ Valid",
66-
ValidationStatus::Invalid => "❌ Invalid",
101+
ValidationStatus::Invalid => "❌ Invalid",
67102
ValidationStatus::Checking => "🟡 Checking",
68103
ValidationStatus::Unchecked => "⚪ Unchecked",
69104
};

src/settings.rs

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,9 @@ impl Settings {
323323

324324
/// Create local provider section for UI
325325
fn create_local_provider_section(&self) -> ProviderSection {
326-
let endpoint_value = self.local_provider.endpoint_url
326+
let endpoint_value = self
327+
.local_provider
328+
.endpoint_url
327329
.as_ref()
328330
.unwrap_or(&"Not configured".to_string())
329331
.clone();
@@ -338,7 +340,8 @@ impl Settings {
338340

339341
ProviderSection {
340342
title: "LOCAL Provider".to_string(),
341-
status_icon: Self::get_validation_status_icon(&self.local_provider.validation_status).to_string(),
343+
status_icon: Self::get_validation_status_icon(&self.local_provider.validation_status)
344+
.to_string(),
342345
fields: vec![endpoint_field],
343346
is_focused: self.selected_provider_index == 0,
344347
}
@@ -347,7 +350,9 @@ impl Settings {
347350
/// Create OpenRouter provider section for UI
348351
fn create_openrouter_provider_section(&self) -> ProviderSection {
349352
let api_key_value = if let Some(ref key) = self.openrouter_provider.api_key {
350-
self.openrouter_provider.get_masked_api_key().unwrap_or_else(|| key.clone())
353+
self.openrouter_provider
354+
.get_masked_api_key()
355+
.unwrap_or_else(|| key.clone())
351356
} else {
352357
"Not configured".to_string()
353358
};
@@ -362,7 +367,10 @@ impl Settings {
362367

363368
ProviderSection {
364369
title: "OPENROUTER Provider".to_string(),
365-
status_icon: Self::get_validation_status_icon(&self.openrouter_provider.validation_status).to_string(),
370+
status_icon: Self::get_validation_status_icon(
371+
&self.openrouter_provider.validation_status,
372+
)
373+
.to_string(),
366374
fields: vec![api_key_field],
367375
is_focused: self.selected_provider_index == 1,
368376
}
@@ -590,13 +598,13 @@ pub fn render_settings_modal(
590598
/// Render provider configuration sections
591599
fn render_provider_sections(f: &mut Frame, area: Rect, settings: &Settings, theme: &Theme) {
592600
let provider_sections = settings.get_provider_sections();
593-
601+
594602
// Split area for each provider section
595603
let section_constraints: Vec<Constraint> = provider_sections
596604
.iter()
597605
.map(|_| Constraint::Length(4)) // Each provider section takes 4 lines
598606
.collect();
599-
607+
600608
let section_layout = Layout::default()
601609
.direction(Direction::Vertical)
602610
.constraints(section_constraints)
@@ -627,7 +635,7 @@ fn render_provider_section(f: &mut Frame, area: Rect, section: &ProviderSection,
627635
} else {
628636
theme.text_style()
629637
};
630-
638+
631639
let title_line = format!(" {} {}", section.title, section.status_icon);
632640
let title_paragraph = Paragraph::new(title_line)
633641
.style(title_style)
@@ -678,7 +686,12 @@ fn add_underline(text: &str) -> String {
678686
}
679687

680688
/// Render theme selection section (moved to bottom as requested)
681-
fn render_theme_selection(f: &mut Frame, area: Rect, modal_state: &SettingsModalState, theme: &Theme) {
689+
fn render_theme_selection(
690+
f: &mut Frame,
691+
area: Rect,
692+
modal_state: &SettingsModalState,
693+
theme: &Theme,
694+
) {
682695
// Layout for theme section
683696
let theme_layout = Layout::default()
684697
.direction(Direction::Vertical)
@@ -702,8 +715,16 @@ fn render_theme_selection(f: &mut Frame, area: Rect, modal_state: &SettingsModal
702715

703716
let theme_line = format!(
704717
" [{}] ← → [{}]",
705-
if current_theme_name == "Dark" { "●Dark" } else { "Dark" },
706-
if current_theme_name == "Light" { "●Light" } else { "Light" }
718+
if current_theme_name == "Dark" {
719+
"●Dark"
720+
} else {
721+
"Dark"
722+
},
723+
if current_theme_name == "Light" {
724+
"●Light"
725+
} else {
726+
"Light"
727+
}
707728
);
708729

709730
let theme_selection = Paragraph::new(theme_line)

src/ui/app.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,13 @@ impl App {
224224
if matches!(self.state, AppState::Settings)
225225
&& let Some(ref modal_state) = self.modal_state
226226
{
227-
crate::settings::render_settings_modal(frame, size, modal_state, self.settings.get(), &self.theme);
227+
crate::settings::render_settings_modal(
228+
frame,
229+
size,
230+
modal_state,
231+
self.settings.get(),
232+
&self.theme,
233+
);
228234
}
229235
}
230236

0 commit comments

Comments
 (0)