fixing /model dropdown if no args provided

This commit is contained in:
pap
2025-08-01 18:08:23 +01:00
parent 5d4ade38a4
commit a2fe6336b6
2 changed files with 16 additions and 1 deletions

View File

@@ -394,7 +394,10 @@ impl App<'_> {
}));
}
SlashCommand::Model => {
// Disallow `/model` without arguments; no action.
// Open the model selector when `/model` has no arguments.
if let AppState::Chat { widget } = &mut self.app_state {
widget.show_model_selector();
}
}
},
AppEvent::DispatchCommandWithArgs(command, args) => match command {

View File

@@ -291,6 +291,18 @@ impl ChatComposer<'_> {
String::new()
};
// Special-case: for `/model` with no arguments, keep the composer as "/model "
// so the model selector opens and the user can type to filter.
if *cmd == SlashCommand::Model && args.trim().is_empty() {
// Replace the entire input with "/model " (with a trailing space).
self.textarea.select_all();
self.textarea.cut();
let _ = self.textarea.insert_str(format!("/{} ", cmd.command()));
// Hide the slash-command popup; sync logic will open the model selector.
self.active_popup = ActivePopup::None;
return (InputResult::None, true);
}
// Send command + args to the app layer.
self.app_event_tx
.send(AppEvent::DispatchCommandWithArgs(*cmd, args));