Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions app/src/ai/blocklist/inline_action/orchestration_controls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,24 @@ pub fn populate_model_picker_for_harness<A: OrchestrationControlAction, V: View>
let harness = Harness::parse_orchestration_harness(&harness_type);
match harness {
Some(Harness::Oz) | None => {
// Oz / unset: current behavior — Warp LLM catalog.
// Oz / unset: Warp LLM catalog. Custom models excluded for
// cloud runs (not supported by remote workers).
// Order: auto models first, then custom models, then other models.
let llm_prefs = LLMPreferences::as_ref(ctx_dropdown);
let choices: Vec<_> = llm_prefs
let all_choices: Vec<_> = llm_prefs
.get_base_llm_choices_for_agent_mode(ctx_dropdown)
.filter(|llm| is_local || llm_prefs.custom_llm_info_for_id(&llm.id).is_none())
.collect();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to collect into a Vec here? That's a memory allocation that I don't think we need here, since the only time we use all_choices we immediately transform it back into an iterator using into_iter().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, not needed.
removed

let (auto_models, rest): (Vec<_>, Vec<_>) = all_choices
.into_iter()
.partition(|llm| llm.id.as_str().starts_with("auto"));
let (custom_models, other_models): (Vec<_>, Vec<_>) = rest
.into_iter()
.partition(|llm| llm_prefs.custom_llm_info_for_id(&llm.id).is_some());
let choices: Vec<_> = auto_models
.into_iter()
.chain(custom_models)
.chain(other_models)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic here might be clearer if we do something like this to exclude custom models. I think it's a little confusing to filter out the custom models at the all_choices level but still include custom_models in the chain.

let mut choices: Vec<_> = auto_models.into_iter();
if is_local {
  choices = choices.chain(custom_models);
}
choices = choices.chain(other_models);

.collect();
let selected_display_name = choices
.iter()
Expand Down Expand Up @@ -548,6 +562,7 @@ pub fn is_model_in_filtered_choices<V: View>(
let llm_prefs = LLMPreferences::as_ref(ctx);
llm_prefs
.get_base_llm_choices_for_agent_mode(ctx)
.filter(|llm| is_local || llm_prefs.custom_llm_info_for_id(&llm.id).is_none())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the logic here rely on having the same model list as populate_model_picker_for_harness? We might want to extract the logic into a common method to avoid drift.

I wonder if we should include a include_custom_model or is_local parameter on get_base_llm_choices_for_agent_mode so that callers are forced to make a decision on whether or not they want custom models.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, added a common helper

.any(|llm| llm.id.to_string() == model_id)
}
Some(Harness::Codex) if is_local => model_id.is_empty(),
Expand Down
17 changes: 6 additions & 11 deletions app/src/terminal/view/ambient_agent/model_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,41 +468,36 @@ impl ModelSelector {
.clone();

let mut auto_choices = Vec::new();
let mut custom_choices = Vec::new();
let mut other_choices = Vec::new();
for llm in llm_preferences.get_base_llm_choices_for_agent_mode(ctx) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use the common get_base_model_choices method here as well?

if llm_preferences.custom_llm_info_for_id(&llm.id).is_some() {
continue;
}

let display_name = llm.menu_display_name();
if !query.is_empty() && !display_name.to_lowercase().contains(query) {
continue;
}
if is_auto(llm) {
auto_choices.push(llm);
} else if llm_preferences.custom_llm_info_for_id(&llm.id).is_some() {
custom_choices.push(llm);
} else {
other_choices.push(llm);
}
}

let items: Vec<MenuItem<ModelSelectorAction>> = auto_choices
.into_iter()
.chain(custom_choices)
.chain(other_choices)
.map(|llm| {
let display_name = llm.menu_display_name();
let is_custom = llm_preferences.custom_llm_info_for_id(&llm.id).is_some();
let mut fields = MenuItemFields::new(display_name)
let fields = MenuItemFields::new(display_name)
.with_icon(llm.provider.icon().unwrap_or(Icon::Oz))
.with_icon_size_override(ITEM_ICON_SIZE)
.with_font_size_override(ITEM_FONT_SIZE)
.with_padding_override(ITEM_VERTICAL_PADDING, MENU_HORIZONTAL_PADDING)
.with_override_hover_background_color(hover_background)
.with_on_select_action(ModelSelectorAction::SelectModel(llm.id.clone()))
.with_disabled(llm.disable_reason.is_some());
if is_custom {
fields = fields.with_right_side_icon(Icon::Key);
} else {
fields = fields.with_icon(llm.provider.icon().unwrap_or(Icon::Oz));
}
MenuItem::Item(fields)
})
.collect();
Expand Down
Loading