Skip to content

πŸ—οΈ Provider Configuration FoundationΒ #29

@gitcoder89431

Description

@gitcoder89431

πŸ—οΈ Provider Configuration Foundation

Context

Establish the core architecture for managing LOCAL and OPENROUTER provider configurations with validation states and secure storage.

Task

Build the foundational data structures and validation system for provider configuration management.

Requirements

Provider Configuration Types

#[derive(Debug, Clone)]
pub enum ProviderType {
    Local,
    OpenRouter,
}

#[derive(Debug, Clone)]
pub struct ProviderConfig {
    pub provider_type: ProviderType,
    pub endpoint_url: Option<String>,  // For LOCAL
    pub api_key: Option<String>,       // For OPENROUTER
    pub validation_status: ValidationStatus,
}

#[derive(Debug, Clone, PartialEq)]
pub enum ValidationStatus {
    Unchecked,   // Initial state
    Checking,    // Validation in progress
    Valid,       // βœ… Connection successful
    Invalid,     // ❌ Connection failed
}

Settings Structure Extension

Extend existing Settings struct:

pub struct Settings {
    pub theme_variant: ThemeVariant,
    pub selected_theme_index: usize,
    pub available_themes: Vec<ThemeVariant>,
    
    // Provider configuration
    pub local_provider: ProviderConfig,
    pub openrouter_provider: ProviderConfig,
    pub selected_provider_index: usize,  // For UI navigation
    pub focused_field: Option<ProviderField>,
}

#[derive(Debug, Clone)]
pub enum ProviderField {
    LocalEndpoint,
    OpenRouterApiKey,
}

Settings Actions Extension

pub enum SettingsAction {
    // Theme actions
    ChangeTheme(ThemeVariant),
    NavigateThemePrevious,
    NavigateThemeNext,
    
    // Provider actions
    NavigateProviderPrevious,
    NavigateProviderNext,
    FocusField(ProviderField),
    UpdateField(ProviderField, String),
    ValidateProvider(ProviderType),
    SaveConfiguration,
}

Input Validation Rules

  • LOCAL Endpoint: Must be valid URL format (http://localhost:* preferred)
  • API Key Masking: Show only first 10 and last 3 characters after save
  • Required Fields: At least one provider must be configured
  • Connection Testing: Non-blocking async validation

Success Criteria

  • βœ… Provider configuration data structures defined
  • βœ… Validation status management system ready
  • βœ… Settings actions support provider operations
  • βœ… Clean separation between LOCAL and OPENROUTER configs
  • βœ… Extensible architecture for future providers
  • βœ… Secure handling of sensitive data (API keys)

Dependencies

  • Requires: RUI-28 (Settings Module Foundation)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions