Skip to content
Open
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
94 changes: 75 additions & 19 deletions app/src/terminal/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ use crate::terminal::input::rewind::{RewindMenuEvent, RewindMenuView};
use crate::terminal::input::skills::{InlineSkillSelectorEvent, InlineSkillSelectorView};
use crate::terminal::input::slash_command_model::{SlashCommandEntryState, SlashCommandModel};
use crate::terminal::input::slash_commands::{
InlineSlashCommandView, SlashCommandDataSource, SlashCommandTrigger,
CloudModeV2SlashCommandView, InlineSlashCommandView, SlashCommandDataSource,
SlashCommandTrigger,
};
use crate::terminal::input::suggestions_mode_model::{
InputSuggestionsModeEvent, InputSuggestionsModeModel,
Expand Down Expand Up @@ -1612,6 +1613,7 @@ pub struct Input {
prompt_suggestions_view: ViewHandle<PromptSuggestionsView>,

inline_slash_commands_view: ViewHandle<InlineSlashCommandView>,
cloud_mode_v2_slash_commands_view: Option<ViewHandle<CloudModeV2SlashCommandView>>,
slash_command_data_source: ModelHandle<SlashCommandDataSource>,

/// Inline conversation menu for selecting AI conversations.
Expand Down Expand Up @@ -2940,16 +2942,26 @@ impl Input {
});

let slash_command_data_source = ctx.add_model(|ctx| {
SlashCommandDataSource::new(
slash_commands::DataSourceArgs {
active_session: active_session.clone(),
agent_view_controller: agent_view_controller.clone(),
cli_subagent_controller: cli_subagent_controller.clone(),
terminal_view_id,
},
ctx,
)
let args = slash_commands::DataSourceArgs {
active_session: active_session.clone(),
agent_view_controller: agent_view_controller.clone(),
cli_subagent_controller: cli_subagent_controller.clone(),
terminal_view_id,
};
SlashCommandDataSource::new(args, ctx)
});

let v2_slash_command_data_source = if FeatureFlag::CloudModeInputV2.is_enabled() {
let args = slash_commands::DataSourceArgs {
active_session: active_session.clone(),
agent_view_controller: agent_view_controller.clone(),
cli_subagent_controller: cli_subagent_controller.clone(),
terminal_view_id,
};
Some(ctx.add_model(|ctx| SlashCommandDataSource::for_cloud_mode_v2(args, ctx)))
} else {
None
};
let slash_command_model = ctx.add_model(|ctx| {
SlashCommandModel::new(
&buffer_model,
Expand Down Expand Up @@ -3111,6 +3123,25 @@ impl Input {
me.handle_slash_commands_menu_event(event, ctx);
});

let cloud_mode_v2_slash_commands_view =
if let Some(v2_data_source) = v2_slash_command_data_source {
let view = ctx.add_typed_action_view(|ctx| {
CloudModeV2SlashCommandView::new(
&slash_command_model,
v2_data_source,
suggestions_mode_model.clone(),
buffer_model.clone(),
ctx,
)
});
ctx.subscribe_to_view(&view, |me, _, event, ctx| {
me.handle_slash_commands_menu_event(event, ctx);
});
Some(view)
} else {
None
};

ctx.subscribe_to_model(&ai_input_model, move |me, _, event, ctx| {
match event {
BlocklistAIInputEvent::InputTypeChanged { .. }
Expand Down Expand Up @@ -3247,6 +3278,7 @@ impl Input {
prompt_suggestions_view,
slash_command_model,
inline_slash_commands_view,
cloud_mode_v2_slash_commands_view,
inline_conversation_menu_view,
inline_plan_menu_view,
inline_repos_menu_view,
Expand Down Expand Up @@ -7526,9 +7558,17 @@ impl Input {
true
}
InputSuggestionsMode::SlashCommands => {
self.inline_slash_commands_view.update(ctx, |view, ctx| {
view.select_up(ctx);
});
if self.is_cloud_mode_input_v2_composing(ctx) {
if let Some(view) = self.cloud_mode_v2_slash_commands_view.clone() {
view.update(ctx, |view, ctx| {
view.select_up(ctx);
});
}
} else {
self.inline_slash_commands_view.update(ctx, |view, ctx| {
view.select_up(ctx);
});
}
true
}
InputSuggestionsMode::ConversationMenu => {
Expand Down Expand Up @@ -7879,9 +7919,17 @@ impl Input {
true
}
InputSuggestionsMode::SlashCommands => {
self.inline_slash_commands_view.update(ctx, |view, ctx| {
view.select_down(ctx);
});
if self.is_cloud_mode_input_v2_composing(ctx) {
if let Some(view) = self.cloud_mode_v2_slash_commands_view.clone() {
view.update(ctx, |view, ctx| {
view.select_down(ctx);
});
}
} else {
self.inline_slash_commands_view.update(ctx, |view, ctx| {
view.select_down(ctx);
});
}
true
}
InputSuggestionsMode::ConversationMenu => {
Expand Down Expand Up @@ -11729,9 +11777,17 @@ impl Input {
.update(ctx, |view, ctx| view.accept_selected_item(ctx));
return;
} else if self.suggestions_mode_model.as_ref(ctx).is_slash_commands() {
self.inline_slash_commands_view.update(ctx, |view, ctx| {
view.accept_selected_item(false, ctx);
});
if self.is_cloud_mode_input_v2_composing(ctx) {
if let Some(view) = self.cloud_mode_v2_slash_commands_view.clone() {
view.update(ctx, |view, ctx| {
view.accept_selected_item(false, ctx);
});
}
} else {
self.inline_slash_commands_view.update(ctx, |view, ctx| {
view.accept_selected_item(false, ctx);
});
}
return;
} else if self.maybe_queue_input_for_in_progress_conversation(ctx)
|| self.maybe_handle_enter_for_slash_command(ctx)
Expand Down
28 changes: 27 additions & 1 deletion app/src/terminal/input/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::{
},
appearance::Appearance,
context_chips::spacing::{self},
editor::position_id_for_cursor,
features::FeatureFlag,
settings::InputModeSettings,
terminal::{settings::TerminalSettings, view::TerminalAction},
Expand Down Expand Up @@ -247,7 +248,9 @@ impl Input {
.is_profile_selector()
{
column.add_child(ChildView::new(&self.inline_profile_selector_view).finish());
} else if self.suggestions_mode_model.as_ref(app).is_slash_commands() {
} else if self.suggestions_mode_model.as_ref(app).is_slash_commands()
&& !self.is_cloud_mode_input_v2_composing(app)
{
column.add_child(ChildView::new(&self.inline_slash_commands_view).finish());
} else if self.suggestions_mode_model.as_ref(app).is_prompts_menu() {
column.add_child(ChildView::new(&self.inline_prompts_menu_view).finish());
Expand Down Expand Up @@ -389,6 +392,29 @@ impl Input {
);
}

if self.suggestions_mode_model.as_ref(app).is_slash_commands() {
if let Some(view) = self.cloud_mode_v2_slash_commands_view.as_ref() {
let cursor_position = position_id_for_cursor(self.editor.id());
stack.add_positioned_overlay_child(
ChildView::new(view).finish(),
OffsetPositioning::from_axes(
PositioningAxis::relative_to_stack_child(
&cursor_position,
PositionedElementOffsetBounds::WindowByPosition,
OffsetType::Pixel(0.),
AnchorPair::new(XAxisAnchor::Left, XAxisAnchor::Left),
),
PositioningAxis::relative_to_stack_child(
&cursor_position,
PositionedElementOffsetBounds::Unbounded,
OffsetType::Pixel(4.),
AnchorPair::new(YAxisAnchor::Bottom, YAxisAnchor::Top),
),
),
);
}
}

if let Some(selected_workflow_state) = self.workflows_state.selected_workflow_state.as_ref()
{
if selected_workflow_state.should_show_more_info_view {
Expand Down
Loading
Loading