diff --git a/lumni/src/apps/builtin/llm/prompt/src/chat/db/user_profile/database_operations.rs b/lumni/src/apps/builtin/llm/prompt/src/chat/db/user_profile/database_operations.rs index 3ad4fef..8007580 100644 --- a/lumni/src/apps/builtin/llm/prompt/src/chat/db/user_profile/database_operations.rs +++ b/lumni/src/apps/builtin/llm/prompt/src/chat/db/user_profile/database_operations.rs @@ -80,7 +80,7 @@ impl UserProfileDbHandler { profile_name: &str, ) -> Result<(), ApplicationError> { let mut db = self.db.lock().await; - + eprintln!("Setting default profile to {}", profile_name); db.process_queue_with_result(|tx| { tx.execute( "UPDATE user_profiles SET is_default = 0 WHERE is_default = 1", diff --git a/lumni/src/apps/builtin/llm/prompt/src/tui/modals/profiles/mod.rs b/lumni/src/apps/builtin/llm/prompt/src/tui/modals/profiles/mod.rs index e03b839..ccf6e70 100644 --- a/lumni/src/apps/builtin/llm/prompt/src/tui/modals/profiles/mod.rs +++ b/lumni/src/apps/builtin/llm/prompt/src/tui/modals/profiles/mod.rs @@ -44,7 +44,9 @@ impl ProfileEditModal { mut db_handler: UserProfileDbHandler, ) -> Result { let profiles = db_handler.get_profile_list().await?; - let profile_list = ProfileList::new(profiles); + let default_profile = db_handler.get_default_profile().await?; + let profile_list = ProfileList::new(profiles, default_profile); + let settings = if let Some(profile) = profile_list.get_selected_profile() { db_handler diff --git a/lumni/src/apps/builtin/llm/prompt/src/tui/modals/profiles/profile_list.rs b/lumni/src/apps/builtin/llm/prompt/src/tui/modals/profiles/profile_list.rs index cc9ee54..290748c 100644 --- a/lumni/src/apps/builtin/llm/prompt/src/tui/modals/profiles/profile_list.rs +++ b/lumni/src/apps/builtin/llm/prompt/src/tui/modals/profiles/profile_list.rs @@ -7,11 +7,11 @@ pub struct ProfileList { } impl ProfileList { - pub fn new(profiles: Vec) -> Self { + pub fn new(profiles: Vec, default_profile: Option) -> Self { ProfileList { profiles, selected_index: 0, - default_profile: None, + default_profile, } } @@ -94,11 +94,15 @@ impl ProfileList { self.default_profile = Some(profile.to_string()); } + pub fn is_default_profile(&self, profile: &str) -> bool { + self.default_profile.as_ref().map_or(false, |default| default == profile) + } + pub fn get_profiles(&self) -> Vec { self.profiles .iter() .map(|p| { - if Some(p) == self.default_profile.as_ref() { + if self.is_default_profile(p) { format!("* {}", p) // Prepend an asterisk to mark the default profile } else { p.clone()