Skip to content

Commit

Permalink
profile selection, minor key tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
aprxi committed Aug 18, 2024
1 parent 0c99272 commit ab39d07
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
23 changes: 4 additions & 19 deletions lumni/src/apps/builtin/llm/prompt/src/tui/modals/profiles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ impl ProfileEditModal {
Some(self.profile_list.start_renaming());
}
}
(EditMode::NotEditing, KeyCode::Char('D')) => {
(EditMode::NotEditing, KeyCode::Char(' ')) => {
if !self.profile_list.is_new_profile_selected() {
self.set_default_profile().await?;
}
}
(EditMode::NotEditing, KeyCode::Char('X')) => {
(EditMode::NotEditing, KeyCode::Char('D')) => {
if !self.profile_list.is_new_profile_selected() {
self.profile_list
.delete_profile(&mut self.db_handler)
Expand Down Expand Up @@ -265,21 +265,6 @@ impl ProfileEditModal {
Ok(WindowEvent::Modal(ModalAction::WaitForKeyEvent))
}

async fn update_selected_profile(
&mut self,
) -> Result<(), ApplicationError> {
if self.profile_list.is_new_profile_selected() {
self.ui_state.set_edit_mode(EditMode::CreatingNewProfile);
self.ui_state.set_focus(Focus::NewProfileType);
self.new_profile_creator.selected_type = 0;
self.settings_editor.clear();
} else {
self.ui_state.set_focus(Focus::SettingsList);
self.load_profile().await?;
}
Ok(())
}

async fn set_default_profile(&mut self) -> Result<(), ApplicationError> {
let selected_profile =
self.profile_list.get_selected_profile().map(String::from);
Expand Down Expand Up @@ -613,7 +598,7 @@ impl ModalWindowTrait for ProfileEditModal {
}
Ok(WindowEvent::Modal(ModalAction::WaitForKeyEvent))
}
KeyCode::Esc => {
KeyCode::Esc | KeyCode::Char('q') => {
if self.ui_state.edit_mode == EditMode::CreatingNewProfile {
self.cancel_new_profile_creation();
self.load_profile_or_clear().await?;
Expand All @@ -639,7 +624,7 @@ impl ModalWindowTrait for ProfileEditModal {
_ => Ok(self.handle_settings_list_input(key_code).await?),
},
Focus::NewProfileType => match key_code {
KeyCode::Esc => {
KeyCode::Esc | KeyCode::Char('q') => {
self.cancel_new_profile_creation();
self.load_profile_or_clear().await?;
Ok(WindowEvent::Modal(ModalAction::WaitForKeyEvent))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ impl ProfileEditRenderer {
) {
(Focus::ProfileList, EditMode::NotEditing) => {
"↑↓: Navigate | Enter: Select/Create | R: Rename | D: Delete | \
→/Tab: Settings | Esc: Close"
Space: Set Default | →/Tab: Settings | Esc: Close"
}
(Focus::RenamingProfile, EditMode::RenamingProfile) => {
"Enter: Confirm Rename | Esc: Cancel"
Expand All @@ -241,7 +241,11 @@ impl ProfileEditRenderer {
"Enter: Save New Value | Esc: Cancel"
}
(Focus::NewProfileType, EditMode::CreatingNewProfile) => {
"↑↓: Select Type | Enter: Create Profile | Esc: Cancel"
"↑↓: Select Type | Enter: Create Profile | q/Esc: Cancel"
}
(Focus::ModelSelection, EditMode::CreatingNewProfile) => {
"↑↓: Select Model | Enter: Confirm | q/Esc: Back to Profile \
Types"
}
_ => "",
};
Expand Down

0 comments on commit ab39d07

Please sign in to comment.