@ondeinference / cli / commits / 4153c49

Refactor key handling with pattern guards for clarity

keypair34 committed Apr 22, 2026 at 18:14 UTC 4153c49d9d9efb4668e54d9459dfc211894b062b
1 file changed +18 -23
src/app.rs
+18 -23
@@ -661,20 +661,17 @@ fn handle_key_apps(
661 }
662 clamp_apps_scroll(app, MAX_VISIBLE);
663 }
664 - (Enter, _) => {
665 - if !app.apps.is_empty() {
666 - app.screen = Screen::AppDetail;
667 - app.renaming_app = false;
668 - app.rename_input.clear();
669 - let app_name = app
670 - .apps
671 - .get(app.apps_cursor)
672 - .map(|a| a.name.as_str())
673 - .unwrap_or("app");
674 - app.status = Status::neutral(format!(
675 - "{app_name} — m · model r · rename Esc · back"
676 - ));
677 - }
664 + (Enter, _) if !app.apps.is_empty() => {
665 + app.screen = Screen::AppDetail;
666 + app.renaming_app = false;
667 + app.rename_input.clear();
668 + let app_name = app
669 + .apps
670 + .get(app.apps_cursor)
671 + .map(|a| a.name.as_str())
672 + .unwrap_or("app");
673 + app.status =
674 + Status::neutral(format!("{app_name} — m · model r · rename Esc · back"));
675 }
676 (Char('n'), KeyModifiers::NONE) => {
677 app.creating_app = true;
@@ -865,10 +862,10 @@ fn handle_key_downloads(
862 (Up, _) | (Char('k'), KeyModifiers::NONE) => {
863 app.hf_search_cursor = app.hf_search_cursor.saturating_sub(1);
864 }
868 - (Down, _) | (Char('j'), KeyModifiers::NONE) => {
869 - if app.hf_search_cursor + 1 < app.hf_search_results.len() {
870 - app.hf_search_cursor += 1;
871 - }
865 + (Down, _) | (Char('j'), KeyModifiers::NONE)
866 + if app.hf_search_cursor + 1 < app.hf_search_results.len() =>
867 + {
868 + app.hf_search_cursor += 1;
869 }
870 (Backspace, _) => {
871 if !app.hf_search_results.is_empty() {
@@ -908,11 +905,9 @@ fn handle_key_downloads(
905 }
906 clamp_downloads_scroll(app, MAX_VISIBLE);
907 }
911 - (Enter, _) => {
912 - if !app.downloads.is_empty() {
913 - app.screen = Screen::ModelDetail;
914 - app.status = Status::neutral("Model details.");
915 - }
908 + (Enter, _) if !app.downloads.is_empty() => {
909 + app.screen = Screen::ModelDetail;
910 + app.status = Status::neutral("Model details.");
911 }
912 (Char('/'), KeyModifiers::NONE) => {
913 app.hf_search_active = true;