Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
34 changes: 27 additions & 7 deletions app/src/ai/blocklist/inline_action/orchestration_controls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use crate::ai::cloud_environments::CloudAmbientAgentEnvironment;
use crate::ai::execution_profiles::model_menu_items::available_model_menu_items;
use crate::ai::harness_availability::{AuthSecretFetchState, HarnessAvailabilityModel};
use crate::ai::harness_display;
use crate::ai::llms::LLMInfo;
use crate::ai::local_child_harnesses::{
local_child_harness_disabled_message, local_child_harness_is_enabled,
};
Expand Down Expand Up @@ -433,6 +434,16 @@ pub fn new_standard_picker_dropdown<A: OrchestrationControlAction, V: View>(
})
}

/// Returns Warp base-model choices for orchestration.
fn get_base_model_choices<'a>(
llm_prefs: &'a LLMPreferences,
app: &'a AppContext,
is_local: bool,
) -> impl Iterator<Item = &'a LLMInfo> {
llm_prefs
.get_base_llm_choices_for_agent_mode(app)
.filter(move |llm| is_local || llm_prefs.custom_llm_info_for_id(&llm.id).is_none())
}
/// Populates the model picker based on the active harness.
///
/// - **Oz / empty**: shows the Warp LLM catalog (existing behavior).
Expand All @@ -454,17 +465,27 @@ 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
.get_base_llm_choices_for_agent_mode(ctx_dropdown)
let (auto_models, rest): (Vec<_>, Vec<_>) =
get_base_model_choices(llm_prefs, ctx_dropdown, is_local)
.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 ordered_choices: Vec<_> = auto_models
.into_iter()
.chain(custom_models)
.chain(other_models)
.collect();
let selected_display_name = choices
let selected_display_name = ordered_choices
.iter()
.find(|llm| llm.id.to_string() == initial_model_id)
.map(|llm| llm.menu_display_name());
let items = available_model_menu_items(
choices,
ordered_choices,
move |llm| {
DropdownAction::SelectActionAndClose(A::model_changed(llm.id.to_string()))
},
Expand Down Expand Up @@ -546,8 +567,7 @@ pub fn is_model_in_filtered_choices<V: View>(
match harness {
Some(Harness::Oz) | None => {
let llm_prefs = LLMPreferences::as_ref(ctx);
llm_prefs
.get_base_llm_choices_for_agent_mode(ctx)
get_base_model_choices(llm_prefs, ctx, is_local)
.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