first pass of merging in warp (doesn't build)

This commit is contained in:
Ryan Ward
2026-07-01 16:08:58 -05:00
parent 2f64909469
commit 4770ac06b5
3662 changed files with 414574 additions and 89772 deletions
+468 -104
View File
@@ -1,63 +1,68 @@
use std::sync::Arc;
use ai::api_keys::{ApiKeyManager, ApiKeyManagerEvent};
use galaxyui::{
elements::{
Border, ChildAnchor, ChildView, ConstrainedBox, Container, CornerRadius,
CrossAxisAlignment, Empty, Flex, Hoverable, MouseStateHandle, OffsetPositioning,
ParentAnchor, ParentElement as _, ParentOffsetBounds, PositionedElementAnchor,
PositionedElementOffsetBounds, Radius, SavePosition, Stack, Text,
DEFAULT_UI_LINE_HEIGHT_RATIO,
},
platform::Cursor,
text_layout::ClipConfig,
ui_components::components::UiComponent,
AppContext, Element, Entity, EntityId, ModelHandle, SingletonEntity as _, TypedActionView,
View, ViewContext, ViewHandle,
};
use indexmap::IndexMap;
use instant::{Duration, Instant};
use parking_lot::FairMutex;
use pathfinder_color::ColorU;
use pathfinder_geometry::vector::vec2f;
use std::sync::Arc;
use galaxyui::elements::{
Border, ChildAnchor, ChildView, ConstrainedBox, Container, CornerRadius, CrossAxisAlignment,
DropShadow, Empty, Expanded, Flex, Hoverable, MainAxisAlignment, MainAxisSize,
MouseStateHandle, OffsetPositioning, ParentAnchor, ParentElement as _, ParentOffsetBounds,
Percentage, PositionedElementAnchor, PositionedElementOffsetBounds, Radius, Rect, SavePosition,
Stack, Text, DEFAULT_UI_LINE_HEIGHT_RATIO,
};
use galaxyui::platform::Cursor;
use galaxyui::text_layout::ClipConfig;
use galaxyui::ui_components::components::UiComponent;
use galaxyui::{
AppContext, Element, Entity, EntityId, ModelHandle, SingletonEntity as _, TypedActionView,
View, ViewContext, ViewHandle,
};
const SIDECAR_POSITION_ID: &str = "model_sidecar_panel";
use crate::{
ai::{
blocklist::{
prompt::PromptIconButtonTheme, BlocklistAIController, BlocklistAIControllerEvent,
BlocklistAIInputEvent, BlocklistAIInputModel,
},
execution_profiles::{
model_menu_items::{available_model_menu_items, has_reasoning_variants, is_auto},
profiles::{AIExecutionProfilesModel, AIExecutionProfilesModelEvent, ClientProfileId},
},
llms::{dedupe_model_display_names, LLMId, LLMInfo, LLMPreferences, LLMPreferencesEvent},
},
appearance::Appearance,
cloud_object::model::generic_string_model::StringModel,
context_chips::{
display_chip::{udi_font_size, udi_icon_size},
spacing,
},
menu::{Event as MenuEvent, Menu, MenuItem, MenuItemFields},
settings_view::SettingsSection,
terminal::view::ambient_agent::AmbientAgentViewModel,
terminal::{
input::{MenuPositioning, MenuPositioningProvider},
TerminalModel,
},
ui_components::icons::Icon,
view_components::{
action_button::{ActionButton, ActionButtonTheme, ButtonSize},
FeaturePopup, NewFeaturePopupEvent, NewFeaturePopupLabel,
},
};
use galaxy_cli::agent::Harness;
use galaxy_core::features::FeatureFlag;
use galaxy_core::ui::color::{coloru_with_opacity, Opacity};
use galaxy_core::ui::theme::color::internal_colors;
use galaxy_core::ui::theme::Fill;
use galaxy_core::ui::theme::{color::internal_colors, Fill};
use galaxy_core::{
features::FeatureFlag,
ui::color::{coloru_with_opacity, Opacity},
use crate::ai::blocklist::prompt::PromptIconButtonTheme;
use crate::ai::blocklist::{
BlocklistAIController, BlocklistAIControllerEvent, BlocklistAIInputEvent, BlocklistAIInputModel,
};
use crate::ai::cloud_agent_settings::CloudAgentSettings;
use crate::ai::custom_model_routers::is_custom_router_id;
use crate::ai::execution_profiles::model_menu_items::{
available_model_menu_items, has_reasoning_variants, is_auto,
};
use crate::ai::execution_profiles::profiles::{
AIExecutionProfilesModel, AIExecutionProfilesModelEvent, ClientProfileId,
};
use crate::ai::harness_availability::{
HarnessAvailabilityEvent, HarnessAvailabilityModel, HarnessModelInfo,
};
use crate::ai::llms::{
dedupe_model_display_names, is_using_api_key_for_provider, LLMId, LLMInfo, LLMPreferences,
LLMPreferencesEvent, LLMSpec,
};
use crate::appearance::Appearance;
use crate::cloud_object::model::generic_string_model::StringModel;
use crate::context_chips::display_chip::{udi_font_size, udi_icon_size};
use crate::context_chips::spacing;
use crate::menu::{Event as MenuEvent, Menu, MenuItem, MenuItemFields};
use crate::settings_view::SettingsSection;
use crate::terminal::input::{MenuPositioning, MenuPositioningProvider};
use crate::terminal::view::ambient_agent::AmbientAgentViewModel;
use crate::terminal::TerminalModel;
use crate::ui_components::icons::Icon;
use crate::view_components::action_button::{
ActionButton, ActionButtonTheme, ButtonSize, SecondaryTheme,
};
use crate::view_components::{FeaturePopup, NewFeaturePopupEvent, NewFeaturePopupLabel};
use crate::workspace::WorkspaceAction;
const MENU_WIDTH: f32 = 480.;
const NEW_MODEL_CHOICES_POPUP_DELAY: Duration = Duration::from_millis(500);
@@ -76,6 +81,12 @@ const MAX_PROFILE_NAME_WIDTH_SCALE_FACTOR: f32 = 10.0;
const PROFILE_SELECTOR_POSITION_ID: &str = "profile_selector";
const PROFILE_PICKER_TOOLTIP: &str = "Choose an AI execution profile";
const MODEL_PICKER_TOOLTIP: &str = "Choose an agent model";
const MODEL_LOCKED_FOR_FOLLOWUP_TOOLTIP: &str = "Follow-ups use the original run's model";
const MODEL_REQUIRES_EDIT_ACCESS_TOOLTIP: &str = "Request edit access to change model";
const HARNESS_DEFAULT_MODEL_LABEL: &str = "default";
pub fn calculate_scaled_font_size(appearance: &galaxy_core::ui::appearance::Appearance) -> f32 {
if FeatureFlag::AgentView.is_enabled() {
udi_font_size(appearance)
@@ -167,7 +178,7 @@ pub struct ProfileModelSelector {
is_blurred: bool,
new_model_popup: ViewHandle<FeaturePopup>,
input_model: ModelHandle<BlocklistAIInputModel>,
ambient_agent_view_model: ModelHandle<AmbientAgentViewModel>,
ambient_agent_view_model: Option<ModelHandle<AmbientAgentViewModel>>,
render_compact: bool,
hovered_llm_info: Option<LLMInfo>,
terminal_model: Arc<FairMutex<TerminalModel>>,
@@ -186,6 +197,10 @@ pub enum ProfileModelSelectorAction {
SelectModel(LLMId),
SelectAutoModel,
SelectReasoningModel(String),
SelectHarnessModel {
model_id: String,
reasoning_level: Option<String>,
},
ManageProfiles,
ToggleProfileMenu,
ToggleModelMenu,
@@ -225,7 +240,7 @@ impl ProfileModelSelector {
menu_positioning_provider: Arc<dyn crate::terminal::input::MenuPositioningProvider>,
terminal_view_id: EntityId,
input_model: ModelHandle<BlocklistAIInputModel>,
ambient_agent_view_model: ModelHandle<AmbientAgentViewModel>,
ambient_agent_view_model: Option<ModelHandle<AmbientAgentViewModel>>,
terminal_model: Arc<FairMutex<TerminalModel>>,
controller: Option<ModelHandle<BlocklistAIController>>,
ctx: &mut ViewContext<Self>,
@@ -253,7 +268,7 @@ impl ProfileModelSelector {
),
is_blurred: false,
})
.with_tooltip("Choose an AI execution profile")
.with_tooltip(PROFILE_PICKER_TOOLTIP)
.with_size(ButtonSize::UDIButton)
.with_icon(Icon::Psychology)
});
@@ -281,14 +296,14 @@ impl ProfileModelSelector {
),
is_blurred: false,
})
.with_tooltip("Choose an agent model")
.with_tooltip(MODEL_PICKER_TOOLTIP)
.with_size(ButtonSize::UDIButton)
});
let profile_compact_button = ctx.add_typed_action_view(|_| {
ActionButton::new("", PromptIconButtonTheme::new(false))
.with_icon(Icon::Psychology)
.with_tooltip("Choose an AI execution profile")
.with_tooltip(PROFILE_PICKER_TOOLTIP)
.with_size(ButtonSize::UDIButton)
.on_click(|ctx| {
ctx.dispatch_typed_action(ProfileModelSelectorAction::ToggleProfileMenu);
@@ -298,7 +313,7 @@ impl ProfileModelSelector {
let model_compact_button = ctx.add_typed_action_view(|_| {
ActionButton::new("", PromptIconButtonTheme::new(false))
.with_icon(Icon::Neurology)
.with_tooltip("Choose an agent model")
.with_tooltip(MODEL_PICKER_TOOLTIP)
.with_size(ButtonSize::UDIButton)
.on_click(|ctx| {
ctx.dispatch_typed_action(ProfileModelSelectorAction::ToggleModelMenu);
@@ -500,6 +515,43 @@ impl ProfileModelSelector {
},
);
if let Some(ref ambient_model) = ambient_agent_view_model {
ctx.subscribe_to_model(ambient_model, |me, _, event, ctx| {
use crate::terminal::view::ambient_agent::AmbientAgentViewModelEvent;
if matches!(
event,
AmbientAgentViewModelEvent::HarnessSelected
| AmbientAgentViewModelEvent::HarnessModelSelected
| AmbientAgentViewModelEvent::RunLifecycleChanged
| AmbientAgentViewModelEvent::SessionReady { .. }
| AmbientAgentViewModelEvent::FollowupDispatched
) {
me.refresh_state(ctx);
}
});
}
ctx.subscribe_to_model(
&HarnessAvailabilityModel::handle(ctx),
|me, _, event, ctx| {
if let HarnessAvailabilityEvent::Changed = event {
me.refresh_state(ctx);
}
},
);
let manage_api_key_button = ctx.add_typed_action_view(|_ctx| {
ActionButton::new("Manage", SecondaryTheme)
.with_tooltip("Manage API keys")
.with_size(ButtonSize::XSmall)
.on_click(|ctx| {
ctx.dispatch_typed_action(WorkspaceAction::ShowSettingsPageWithSearch {
search_query: "api".to_string(),
section: Some(SettingsSection::WarpAgent),
});
})
});
let mut me = Self {
profile_button,
model_button,
@@ -577,6 +629,40 @@ impl ProfileModelSelector {
format!("{PROFILE_SELECTOR_POSITION_ID}_{llm_id}")
}
/// Locked because the user is composing a follow-up to a Cloud Mode run
/// that has ended. The server inherits the original task's model config
/// when accepting the follow-up, so changing the model locally is
/// meaningless.
fn is_locked_for_cloud_followup(&self, app: &AppContext) -> bool {
self.ambient_agent_view_model
.as_ref()
.is_some_and(|m| m.as_ref(app).is_ready_for_cloud_followup_prompt())
}
/// Locked because a non-Oz cloud run (e.g. Claude Code, Codex) has been
/// spawned. The harness owns model selection, so changing the model
/// locally has no effect on the run. We lock silently in this case
/// because the harness selection itself communicates the lock.
fn is_locked_for_non_oz_run(&self, app: &AppContext) -> bool {
self.ambient_agent_view_model.as_ref().is_some_and(|m| {
let model = m.as_ref(app);
model.task_id().is_some()
&& !matches!(model.selected_harness(), Harness::Oz | Harness::Unknown)
})
}
fn is_model_locked(&self, app: &AppContext) -> bool {
self.is_locked_for_cloud_followup(app) || self.is_locked_for_non_oz_run(app)
}
/// True when a non-Oz harness is selected.
fn is_third_party_harness(&self, app: &AppContext) -> bool {
self.ambient_agent_view_model.as_ref().is_some_and(|m| {
let model = m.as_ref(app);
!matches!(model.selected_harness(), Harness::Oz | Harness::Unknown)
})
}
fn refresh_state(&mut self, ctx: &mut ViewContext<Self>) {
self.refresh_profile_menu(ctx);
self.refresh_model_menu(ctx);
@@ -594,7 +680,9 @@ impl ProfileModelSelector {
});
}
let model_name = {
let model_name = if self.is_third_party_harness(ctx) {
self.harness_model_display_name(ctx)
} else {
let llm_preferences = LLMPreferences::as_ref(ctx);
let active_llm = if FeatureFlag::InlineMenuHeaders.is_enabled()
&& self
@@ -609,14 +697,43 @@ impl ProfileModelSelector {
llm_preferences.get_active_base_model(ctx, Some(self.terminal_view_id))
};
if let Some(description) = &active_llm.description {
format!("{} ({})", active_llm.display_name, description)
// Don't append description for custom model routers — it would add a
// redundant "(Custom auto · Local)" suffix to the button label.
if !is_custom_router_id(active_llm.id.as_str()) {
if let Some(description) = &active_llm.description {
format!("{} ({})", active_llm.display_name, description)
} else {
active_llm.display_name.clone()
}
} else {
active_llm.display_name.clone()
}
};
// Non-Oz runs lock silently: the harness owns model selection, and the
// user already knows that, so no tooltip is shown.
let model_tooltip: Option<&str> = if self.is_locked_for_cloud_followup(ctx) {
Some(MODEL_LOCKED_FOR_FOLLOWUP_TOOLTIP)
} else if self.is_locked_for_non_oz_run(ctx) {
None
} else {
Some(MODEL_PICKER_TOOLTIP)
};
let locked = self.is_model_locked(ctx);
self.model_button.update(ctx, |button, ctx| {
button.set_label(model_name, ctx);
button.set_disabled(locked, ctx);
match model_tooltip {
Some(t) => button.set_tooltip(Some(t), ctx),
None => button.clear_tooltip(ctx),
}
});
self.model_compact_button.update(ctx, |button, ctx| {
button.set_disabled(locked, ctx);
match model_tooltip {
Some(t) => button.set_tooltip(Some(t), ctx),
None => button.clear_tooltip(ctx),
}
});
ctx.notify();
}
@@ -745,7 +862,103 @@ impl ProfileModelSelector {
});
}
// Checks that we have a harness in the `AmbientAgentViewModel` and returns model options from
// the `HarnessAvailabilityModel` for that harness.
fn active_harness_model_info<'a>(&self, app: &'a AppContext) -> Option<&'a HarnessModelInfo> {
let ambient_model = self.ambient_agent_view_model.as_ref()?.as_ref(app);
let harness = ambient_model.selected_harness();
let model_id = ambient_model.selected_harness_model_id()?;
let reasoning_level = ambient_model.selected_harness_reasoning_level();
HarnessAvailabilityModel::as_ref(app)
.models_for(harness)?
.iter()
.find(|m| m.id == model_id && m.reasoning_level.as_deref() == reasoning_level)
}
fn harness_model_display_name(&self, app: &AppContext) -> String {
self.active_harness_model_info(app)
.map(|info| info.display_name.clone())
.unwrap_or_else(|| HARNESS_DEFAULT_MODEL_LABEL.to_string())
}
fn refresh_harness_model_menu(&mut self, ctx: &mut ViewContext<Self>) {
let ambient_model = match self.ambient_agent_view_model.as_ref() {
Some(m) => m,
None => return,
};
let harness = ambient_model.as_ref(ctx).selected_harness();
let selected_model_id = ambient_model
.as_ref(ctx)
.selected_harness_model_id()
.map(str::to_owned);
let selected_reasoning = ambient_model
.as_ref(ctx)
.selected_harness_reasoning_level()
.map(str::to_owned);
let models = HarnessAvailabilityModel::as_ref(ctx).models_for(harness);
let mut items: Vec<MenuItem<ProfileModelSelectorAction>> = Vec::new();
let default_selected = selected_model_id.is_none();
let default_action = ProfileModelSelectorAction::SelectHarnessModel {
model_id: String::new(),
reasoning_level: None,
};
let mut default_fields =
MenuItemFields::new(HARNESS_DEFAULT_MODEL_LABEL).with_on_select_action(default_action);
if default_selected {
default_fields = default_fields.with_icon(Icon::Check);
} else {
default_fields = default_fields.with_indent();
}
items.push(MenuItem::Item(default_fields));
if let Some(models) = models {
for model in models {
let is_selected = selected_model_id.as_deref() == Some(&model.id)
&& selected_reasoning.as_deref() == model.reasoning_level.as_deref();
let mut fields = MenuItemFields::new(model.display_name.clone())
.with_on_select_action(ProfileModelSelectorAction::SelectHarnessModel {
model_id: model.id.clone(),
reasoning_level: model.reasoning_level.clone(),
});
if is_selected {
fields = fields.with_icon(Icon::Check);
} else {
fields = fields.with_indent();
}
items.push(MenuItem::Item(fields));
}
}
let selected_index = items
.iter()
.position(|item| {
matches!(
item.item_on_select_action(),
Some(ProfileModelSelectorAction::SelectHarnessModel { model_id, reasoning_level })
if (model_id.is_empty() && default_selected)
|| (selected_model_id.as_deref() == Some(model_id.as_str())
&& selected_reasoning.as_deref() == reasoning_level.as_deref())
)
})
.unwrap_or(0);
self.model_dropdown.update(ctx, |menu, ctx| {
menu.set_width(MENU_WIDTH);
menu.set_items(items, ctx);
menu.set_selected_by_index(selected_index, ctx);
ctx.notify();
});
}
fn refresh_model_menu(&mut self, ctx: &mut ViewContext<Self>) {
if self.is_third_party_harness(ctx) {
self.refresh_harness_model_menu(ctx);
return;
}
let llm_preferences = LLMPreferences::as_ref(ctx);
let active_llm = llm_preferences.get_active_base_model(ctx, Some(self.terminal_view_id));
@@ -768,15 +981,33 @@ impl ProfileModelSelector {
// Store all model choices for reasoning variant lookups
self.all_model_choices = llm_preferences
.get_base_llm_choices_for_agent_mode()
.get_base_llm_choices_for_agent_mode(ctx)
.cloned()
.collect();
// Partition into server-provided choices (subject to auto/reasoning collapsing) and
// custom-endpoint choices (rendered separately under a `Custom models` sub-header so
// the server-curated list stays visually distinct).
let custom_ids: std::collections::HashSet<LLMId> = llm_preferences
.custom_llm_choices(ctx)
.map(|info| info.id.clone())
.collect();
let server_choices: Vec<&LLMInfo> = self
.all_model_choices
.iter()
.filter(|llm| !custom_ids.contains(&llm.id))
.collect();
let custom_choices: Vec<&LLMInfo> = self
.all_model_choices
.iter()
.filter(|llm| custom_ids.contains(&llm.id))
.collect();
// Group models by base_model_name to collapse reasoning variants.
// Use "auto" as the key for all auto models so they collapse together.
// Only group models that have reasoning levels - others stay separate.
let mut groups: IndexMap<String, Vec<&LLMInfo>> = IndexMap::new();
for llm in &self.all_model_choices {
for llm in &server_choices {
let key = if is_auto(llm) {
"auto".to_string()
} else if llm.has_reasoning_level() {
@@ -784,17 +1015,24 @@ impl ProfileModelSelector {
} else {
llm.id.to_string()
};
groups.entry(key).or_default().push(llm);
groups.entry(key).or_default().push(*llm);
}
// Build collapsed list: for each group, take first model (preserves server order)
let choices: Vec<_> = groups
.into_iter()
.filter_map(|(_, variants)| variants.into_iter().next())
.collect();
// Split collapsed choices so custom models can be placed right after auto models.
let mut auto_choices: Vec<&LLMInfo> = Vec::new();
let mut other_choices: Vec<&LLMInfo> = Vec::new();
for (_, variants) in groups {
if let Some(first) = variants.into_iter().next() {
if is_auto(first) {
auto_choices.push(first);
} else {
other_choices.push(first);
}
}
}
let items = available_model_menu_items(
choices,
let mut items = available_model_menu_items(
auto_choices,
|llm| {
let all_refs: Vec<_> = self.all_model_choices.iter().collect();
if is_auto(llm) {
@@ -814,6 +1052,58 @@ impl ProfileModelSelector {
ctx,
);
// Append the "Custom models" section when the user has any custom endpoints configured.
// Each row gets its own atomic `SelectModel(config_key)` action; no auto/reasoning
// collapsing applies.
if !custom_choices.is_empty() {
let appearance = Appearance::as_ref(ctx);
if !items.is_empty() {
items.push(MenuItem::Separator);
}
items.push(MenuItem::Header {
fields: MenuItemFields::new("Custom models").with_override_text_color(
appearance
.theme()
.sub_text_color(appearance.theme().background())
.into_solid(),
),
clickable: false,
right_side_fields: None,
});
for llm in &custom_choices {
let fields = MenuItemFields::new(llm.menu_display_name())
.with_right_side_icon(Icon::Key)
.with_on_select_action(ProfileModelSelectorAction::SelectModel(llm.id.clone()));
items.push(MenuItem::Item(fields));
}
}
if !other_choices.is_empty() {
if !items.is_empty() {
items.push(MenuItem::Separator);
}
items.extend(available_model_menu_items(
other_choices,
|llm| {
let all_refs: Vec<_> = self.all_model_choices.iter().collect();
if is_auto(llm) {
ProfileModelSelectorAction::SelectAutoModel
} else if has_reasoning_variants(llm, &all_refs) {
ProfileModelSelectorAction::SelectReasoningModel(
llm.base_model_name().to_string(),
)
} else {
ProfileModelSelectorAction::SelectModel(llm.id.clone())
}
},
model_id_to_add_profile_default_label_to,
Some(&|llm_id| self.model_menu_item_position_id(llm_id)),
true,
true,
ctx,
));
}
let selected_index = Self::find_selected_index(&items, active_llm);
self.model_dropdown.update(ctx, |menu, ctx| {
menu.set_width(MENU_WIDTH);
@@ -835,7 +1125,7 @@ impl ProfileModelSelector {
let items: Vec<MenuItem<ProfileModelSelectorAction>> = match kind {
ModelSpecSidecarKind::Auto => llm_preferences
.get_base_llm_choices_for_agent_mode()
.get_base_llm_choices_for_agent_mode(ctx)
.filter(|llm| is_auto(llm))
.map(|llm| {
let is_selected = llm.id == active_llm_id;
@@ -1032,7 +1322,7 @@ impl ProfileModelSelector {
// Get the first "auto" variant as the generic auto model
let llm_prefs = LLMPreferences::as_ref(ctx);
llm_prefs
.get_base_llm_choices_for_agent_mode()
.get_base_llm_choices_for_agent_mode(ctx)
.find(|llm| is_auto(llm))
.cloned()
}
@@ -1275,16 +1565,16 @@ impl ProfileModelSelector {
)))
.finish();
let tooltip_text = "Choose an AI execution profile".to_owned();
let tooltip = appearance.ui_builder().tool_tip(tooltip_text);
let tooltip = appearance
.ui_builder()
.tool_tip(PROFILE_PICKER_TOOLTIP.to_owned());
let mut stack = Stack::new();
stack.add_child(button_with_hover);
stack.add_positioned_child(
stack.add_positioned_overlay_child(
tooltip.build().finish(),
OffsetPositioning::offset_from_parent(
vec2f(0., -10.),
ParentOffsetBounds::Unbounded,
ParentOffsetBounds::WindowByPosition,
ParentAnchor::TopLeft,
ChildAnchor::BottomLeft,
),
@@ -1308,10 +1598,14 @@ impl ProfileModelSelector {
// Allow editing if composing an ambient agent query, or if the user has edit access
// in a shared session (i.e., not a viewer, or is an executor).
let is_composing_ambient_agent = self
.ambient_agent_view_model
.as_ref(app)
.is_configuring_ambient_agent();
let is_composing_ambient_agent =
self.ambient_agent_view_model
.as_ref()
.is_some_and(|ambient_agent_model| {
ambient_agent_model
.as_ref(app)
.is_configuring_ambient_agent()
});
let terminal_model = self.terminal_model.lock();
let has_edit_access = is_composing_ambient_agent
|| !terminal_model.shared_session_status().is_viewer()
@@ -1323,7 +1617,9 @@ impl ProfileModelSelector {
.is_agent_in_control_or_tagged_in();
drop(terminal_model);
let model_display_name = if is_lrc {
let model_display_name = if self.is_third_party_harness(app) {
self.harness_model_display_name(app)
} else if is_lrc {
llm_preferences
.get_active_cli_agent_model(app, Some(self.terminal_view_id))
.menu_display_name()
@@ -1403,8 +1699,13 @@ impl ProfileModelSelector {
let button_with_save_position =
SavePosition::new(button, "profile_model_selector_model_button").finish();
let is_locked_for_followup = self.is_locked_for_cloud_followup(app);
let is_locked_for_non_oz = self.is_locked_for_non_oz_run(app);
let is_locked = is_locked_for_followup || is_locked_for_non_oz;
let can_interact = has_edit_access && !is_locked;
let hoverable = Hoverable::new(self.model_mouse_state.clone(), move |state| {
if state.is_hovered() {
if state.is_hovered() && can_interact {
let button_with_hover = Container::new(button_with_save_position)
.with_background(theme.surface_2())
.with_corner_radius(CornerRadius::with_right(Radius::Pixels(
@@ -1412,40 +1713,62 @@ impl ProfileModelSelector {
)))
.finish();
let tooltip_text = if !has_edit_access {
"Request edit access to change model".to_owned()
} else {
"Choose an agent model".to_owned()
};
let tooltip = appearance.ui_builder().tool_tip(tooltip_text);
let tooltip = appearance
.ui_builder()
.tool_tip(MODEL_PICKER_TOOLTIP.to_owned());
let mut stack = Stack::new();
stack.add_child(button_with_hover);
stack.add_positioned_child(
stack.add_positioned_overlay_child(
tooltip.build().finish(),
OffsetPositioning::offset_from_parent(
vec2f(0., -10.),
ParentOffsetBounds::Unbounded,
ParentOffsetBounds::WindowByPosition,
ParentAnchor::TopLeft,
ChildAnchor::BottomLeft,
),
);
stack.finish()
} else if state.is_hovered() {
// Non-Oz runs lock silently — skip the tooltip entirely.
let tooltip_text: Option<&str> = if is_locked_for_followup {
Some(MODEL_LOCKED_FOR_FOLLOWUP_TOOLTIP)
} else if is_locked_for_non_oz {
None
} else {
Some(MODEL_REQUIRES_EDIT_ACCESS_TOOLTIP)
};
if let Some(text) = tooltip_text {
let tooltip = appearance.ui_builder().tool_tip(text.to_owned());
let mut stack = Stack::new();
stack.add_child(button_with_save_position);
stack.add_positioned_overlay_child(
tooltip.build().finish(),
OffsetPositioning::offset_from_parent(
vec2f(0., -10.),
ParentOffsetBounds::WindowByPosition,
ParentAnchor::TopLeft,
ChildAnchor::BottomLeft,
),
);
stack.finish()
} else {
button_with_save_position
}
} else {
button_with_save_position
}
});
// Only make clickable if the user can click to open the menu (i.e. has edit access)
if !has_edit_access {
hoverable.finish()
} else {
if can_interact {
hoverable
.on_click(|ctx, _app, _position| {
ctx.dispatch_typed_action(ProfileModelSelectorAction::ToggleModelMenu);
})
.with_cursor(Cursor::PointingHand)
.finish()
} else {
hoverable.finish()
}
}
@@ -1504,17 +1827,51 @@ impl TypedActionView for ProfileModelSelector {
| ProfileModelSelectorAction::SelectReasoningModel(_) => {
self.handle_sidecar_selection(ctx);
}
ProfileModelSelectorAction::SelectHarnessModel {
model_id,
reasoning_level,
} => {
let is_default = model_id.is_empty();
if let Some(ambient_agent_model) = self.ambient_agent_view_model.clone() {
ambient_agent_model.update(ctx, |model, ctx| {
model.set_harness_model_selection(
(!is_default).then(|| model_id.clone()),
if is_default {
None
} else {
reasoning_level.clone()
},
ctx,
);
});
let harness = ambient_agent_model.as_ref(ctx).selected_harness();
CloudAgentSettings::handle(ctx).update(ctx, |settings, ctx| {
settings.persist_harness_model_selection(
harness,
model_id,
reasoning_level.clone(),
ctx,
);
});
}
self.set_model_menu_visibility(false, ctx);
}
ProfileModelSelectorAction::ManageProfiles => {
self.set_profile_menu_visibility(false, ctx);
ctx.emit(ProfileModelSelectorEvent::OpenSettings(
SettingsSection::WarpAgent,
SettingsSection::AgentProfiles,
));
}
ProfileModelSelectorAction::ToggleProfileMenu => {
self.set_profile_menu_visibility(!self.is_profile_menu_open, ctx);
}
ProfileModelSelectorAction::ToggleModelMenu => {
if FeatureFlag::InlineMenuHeaders.is_enabled() {
if self.is_model_locked(ctx) {
return;
}
if self.is_third_party_harness(ctx) {
self.set_model_menu_visibility(!self.is_model_menu_open, ctx);
} else if FeatureFlag::InlineMenuHeaders.is_enabled() {
ctx.emit(ProfileModelSelectorEvent::ToggleInlineModelSelector);
} else {
self.set_model_menu_visibility(!self.is_model_menu_open, ctx);
@@ -1546,7 +1903,8 @@ impl View for ProfileModelSelector {
// Only add profile button to compact layout if there are multiple profiles
// and the user is not a viewer (we currently don't support profiles in shared sessions).
let should_show_profile_section = has_multiple_profiles && !is_viewer;
let is_ambient_agent = self.ambient_agent_view_model.is_some();
let should_show_profile_section = has_multiple_profiles && !is_viewer && !is_ambient_agent;
if should_show_profile_section {
let profile_button_with_save_position = SavePosition::new(
ChildView::new(&self.profile_compact_button).finish(),
@@ -1616,12 +1974,18 @@ impl View for ProfileModelSelector {
let is_udi_enabled =
crate::settings::InputSettings::as_ref(app).is_universal_developer_input_enabled(app);
if is_udi_enabled
|| self
.input_model
.as_ref(app)
.last_ai_autodetection_ts()
.is_none_or(|ts| Instant::now().duration_since(ts) > NEW_MODEL_CHOICES_POPUP_DELAY)
// The popup overflows the viewport on wasm mobile.
let is_wasm_mobile = warpui::platform::is_mobile_device();
if !is_wasm_mobile
&& (is_udi_enabled
|| self
.input_model
.as_ref(app)
.last_ai_autodetection_ts()
.is_none_or(|ts| {
Instant::now().duration_since(ts) > NEW_MODEL_CHOICES_POPUP_DELAY
}))
{
let llm_preferences = LLMPreferences::as_ref(app);
match (